From 37e8f6995071e9e68a90f5d7e8240df3d0bfe0e0 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 16 Dec 2022 16:31:13 -0600 Subject: [PATCH 001/192] paynym api --- lib/utilities/paynym_api.dart | 411 ++++++++++++++++++++++++++++++++++ 1 file changed, 411 insertions(+) create mode 100644 lib/utilities/paynym_api.dart diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_api.dart new file mode 100644 index 000000000..2e3966d38 --- /dev/null +++ b/lib/utilities/paynym_api.dart @@ -0,0 +1,411 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +class Paynym { + static const String baseURL = "https://paynym.is/api"; + static const String version = "/v1"; + + Future> _post( + String endpoint, + Map body, [ + Map additionalHeaders = const {}, + ]) async { + String url = baseURL + + version + + (endpoint.startsWith("/") ? endpoint : "/$endpoint"); + final uri = Uri.parse(url); + final response = await http.post( + uri, + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }..addAll(additionalHeaders), + body: jsonEncode(body), + ); + + // print("response code: ${response.statusCode}"); + + return jsonDecode(response.body) as Map; + } + + // ### `/api/v1/create` + // + // Create a new PayNym entry in the database. + // + // + // + // **Request** + // + // ```json + // POST /api/v1/create + // content-type: application/json + // + // { + // "code":"PM8T..." + // } + // + // ``` + // + // | Value | Key | + // | ----- | -------------------- | + // | code | A valid payment code | + // + // + // + // **Response** (201) + // + // ```json + // { + // "claimed": false, + // "nymID": "v9pJm...", + // "nymName": "snowysea", + // "segwit": true, + // "token": "IlBNOF...", + // } + // ``` + // + // | Code | Meaning | + // | ---- | --------------------------- | + // | 201 | PayNym created successfully | + // | 200 | PayNym already exists | + // | 400 | Bad request | + // + // + // + // ------ + Future> create(String code) async { + return _post("/create", {"code": code}); + } + + // ### `/api/v1/token` + // + // Update the verification token in the database. A token is valid for 24 hours and only for a single authenticated call. The payment code must be in the database or the request will return `404` + // + // + // + // **Request** + // + // ```json + // POST /api/v1/token/ + // content-type: application/json + // + // {"code":"PM8T..."} + // ``` + // + // | Value | Key | + // | ----- | -------------------- | + // | code | A valid payment code | + // + // + // + // **Response** (200) + // + // ```json + // { + // "token": "DP7S3w..." + // } + // ``` + // + // | Code | Meaning | + // | ---- | ------------------------------ | + // | 200 | Token was successfully updated | + // | 404 | Payment code was not found | + // | 400 | Bad request | + // + // + // + // ------ + Future> token(String code) async { + return _post("/token", {"code": code}); + } + + // ### `/api/v1/nym` + // + // Returns all known information about a PayNym account including any other payment codes associated with this Nym. + // + // + // + // **Request** + // + // ```json + // POST /api/v1/nym/ + // content-type: application/json + // + // {"nym":"PM8T..."} + // ``` + // + // | Value | Key | + // | ----- | ---------------------------------------- | + // | nym | A valid payment `code`, `nymID`, or `nymName` | + // + // + // + // **Response** (200) + // + // ```json + // { + // "codes": [ + // { + // "claimed": true, + // "segwit": true, + // "code": "PM8T..." + // } + // ], + // "followers": [ + // { + // "nymId": "5iEpU..." + // } + // ], + // "following": [], + // "nymID": "wXGgdC...", + // "nymName": "littlevoice" + // } + // ``` + // + // If the `compact=true` parameter is added to the URL, follower and following will not returned. This can achieve faster requests. + // + // | Code | Meaning | + // | ---- | ---------------------- | + // | 200 | Nym found and returned | + // | 404 | Nym not found | + // | 400 | Bad request | + + Future> nym(String code) async { + return _post("/nym", {"code": code}); + } + + // ## Authenticated Requests + // + // + // + // ### Making authenticated requests + // + // 1. Set an `auth-token` header containing the `token` + // 2. Sign the `token` with the private key of the notification address of the primary payment code + // 3. Add the `signature` to the body of the request. + // 4. A token can only be used once per authenticated request. A new `token` will be returned in the response of a successful authenticated request + // + + // ### `/api/v1/claim` + // + // Claim ownership of a payment code added to a newly created PayNym identity. + // + // + // + // **Request** + // + // ```json + // POST /api/v1/claim + // content-type: application/json + // auth-token: IlBNOFRKWmt... + // + // + // {"signature":"..."} + // ``` + // + // | Value | Key | + // | --------- | ---------------------------------------- | + // | signature | The `token` signed by the BIP47 notification address | + // + // + // + // **Response** (200) + // + // ```json + // { + // "claimed" : "PM8T...", + // "token" : "IlBNOFRKSmt..." + // } + // ``` + // + // | Code | Meaning | + // | ---- | --------------------------------- | + // | 200 | Payment code successfully claimed | + // | 400 | Bad request | + // + // ------ + Future> claim(String token, String signature) async { + return _post("/nym", {"signature": signature}, {"auth-token": token}); + } + + // ### `/api/v1/follow` + // + // Follow another PayNym account. + // + // + // + // **Request** + // + // ```json + // POST /api/v1/follow/ + // content-type: application/json + // auth-token: IlBNOFRKWmt... + // + // { + // "target": "wXGgdC...", + // "signature":"..." + // } + // ``` + // + // | Key | Value | + // | --------- | ---------------------------------------- | + // | target | The payment code to follow | + // | signature | The `token` signed by the BIP47 notification address | + // + // **Response** (200) + // + // ```json + // { + // "follower": "5iEpU...", + // "following": "wXGgdC...", + // "token" : "IlBNOFRKSmt..." + // } + // ``` + // + // | Code | Meaning | + // | ---- | ---------------------------------------- | + // | 200 | Added to followers | + // | 404 | Payment code not found | + // | 400 | Bad request | + // | 401 | Unauthorized token or signature or Unclaimed payment code | + // + // ------ + Future> follow( + String token, + String signature, + String target, + ) async { + return _post( + "/nym", + { + "target": target, + "signature": signature, + }, + { + "auth-token": token, + }, + ); + } + + // ### `/api/v1/unfollow` + // + // Unfollow another PayNym account. + // + // + // + // **Request** + // + // ```json + // POST /api/v1/unfollow/ + // content-type: application/json + // auth-token: IlBNOFRKWmt... + // + // { + // "target": "wXGgdC...", + // "signature":"..." + // } + // ``` + // + // | Key | Value | + // | --------- | ---------------------------------------- | + // | target | The payment code to unfollow | + // | signature | The `token` signed by the BIP47 notification address | + // + // **Response** (200) + // + // ```json + // { + // "follower": "5iEpU...", + // "unfollowing": "wXGgdC...", + // "token" : "IlBNOFRKSmt..." + // } + // ``` + // + // | Code | Meaning | + // | ---- | ---------------------------------------- | + // | 200 | Unfollowed successfully | + // | 404 | Payment code not found | + // | 400 | Bad request | + // | 401 | Unauthorized token or signature or Unclaimed payment code | + // + // ------ + Future> unfollow( + String token, + String signature, + String target, + ) async { + return _post( + "/nym", + { + "target": target, + "signature": signature, + }, + { + "auth-token": token, + }, + ); + } + + // ### `/api/v1/nym/add` + // + // Add a new payment code to an existing Nym + // + // + // + // **Request** + // + // ```json + // POST /api/v1/nym/add + // content-type: application/json + // auth-token: IlBNOFRKWmt... + // + // { + // "nym": "wXGgdC...", + // "code":"PM8T...", + // "signature":"..." + // } + // ``` + // + // | Key | Value | + // | --------- | ------------------------------------------------------------ | + // | nym | A valid payment `code`, `nymID`, or `nymName` | + // | code | A valid payment code | + // | signature | The `token` signed by the BIP47 notification address of the primary payment code. | + // + // **Response** (200) + // + // ```json + // { + // "code":"PM8T...", + // "segwit": true, + // "token" : "IlBNOFRKSmt..." + // } + // ``` + // + // | Code | Meaning | + // | ---- | --------------------------------------------------------- | + // | 200 | Nym updated successfully | + // | 404 | Nym not found | + // | 400 | Bad request | + // | 401 | Unauthorized token or signature or Unclaimed payment code | + // + // ------ + Future> add( + String token, + String signature, + String nym, + String code, + ) async { + return _post( + "/nym", + { + "nym": nym, + "code": code, + "signature": signature, + }, + { + "auth-token": token, + }, + ); + } +} From 7ae670631ad963581f8c830d3d779d0e10bba938 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 16 Dec 2022 16:49:37 -0600 Subject: [PATCH 002/192] WIP bip47 dep --- pubspec.lock | 77 ++++++++++++++++++++++++++++++++++------------------ pubspec.yaml | 5 ++++ 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index e8f875d35..92f0eb3d7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.1.11" + version: "3.3.0" args: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" barcode_scan2: dependency: "direct main" description: @@ -96,6 +96,15 @@ packages: url: "https://github.com/cypherstack/stack-bip39.git" source: git version: "1.0.6" + bip47: + dependency: "direct main" + description: + path: "." + ref: main + resolved-ref: "48bd568b4f64c976813387fbae71a5daf48cff81" + url: "https://github.com/cypherstack/bip47.git" + source: git + version: "1.0.0" bitbox: dependency: "direct main" description: @@ -190,14 +199,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" checked_yaml: dependency: transitive description: @@ -218,7 +220,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" code_builder: dependency: transitive description: @@ -288,7 +290,7 @@ packages: name: coverage url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.5.0" cross_file: dependency: transitive description: @@ -345,6 +347,27 @@ packages: relative: true source: path version: "0.0.1" + dart_base_x: + dependency: transitive + description: + name: dart_base_x + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + dart_bs58: + dependency: transitive + description: + name: dart_bs58 + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + dart_bs58check: + dependency: transitive + description: + name: dart_bs58check + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" dart_numerics: dependency: "direct main" description: @@ -442,7 +465,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: "direct main" description: @@ -871,21 +894,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" mime: dependency: transitive description: @@ -997,7 +1020,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" path_drawing: dependency: transitive description: @@ -1373,7 +1396,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -1417,7 +1440,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" string_validator: dependency: "direct main" description: @@ -1431,35 +1454,35 @@ packages: name: sync_http url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test: dependency: transitive description: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.21.1" + version: "1.21.4" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.4.13" + version: "0.4.16" time: dependency: transitive description: @@ -1508,7 +1531,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" universal_io: dependency: transitive description: @@ -1592,7 +1615,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "8.2.2" + version: "9.0.0" wakelock: dependency: "direct main" description: @@ -1708,5 +1731,5 @@ packages: source: hosted version: "1.0.0" sdks: - dart: ">=2.17.5 <3.0.0" + dart: ">=2.18.5 <3.0.0" flutter: ">=3.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 0fe5ef6d8..05cbe66b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -56,6 +56,11 @@ dependencies: url: https://github.com/cypherstack/stack_wallet_backup.git ref: 011dc9ce3d29f5fdeeaf711d58b5122f055c146d + bip47: + git: + url: https://github.com/cypherstack/bip47.git + ref: main + # Utility plugins # provider: ^6.0.1 http: ^0.13.4 From 177d2e4bc8d7480dc6f5da4a2339a080e96aba4c Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 16 Dec 2022 17:45:08 -0600 Subject: [PATCH 003/192] correct endpoints --- lib/utilities/paynym_api.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_api.dart index 2e3966d38..cb4300624 100644 --- a/lib/utilities/paynym_api.dart +++ b/lib/utilities/paynym_api.dart @@ -225,7 +225,7 @@ class Paynym { // // ------ Future> claim(String token, String signature) async { - return _post("/nym", {"signature": signature}, {"auth-token": token}); + return _post("/claim", {"signature": signature}, {"auth-token": token}); } // ### `/api/v1/follow` @@ -276,7 +276,7 @@ class Paynym { String target, ) async { return _post( - "/nym", + "/follow", { "target": target, "signature": signature, @@ -335,7 +335,7 @@ class Paynym { String target, ) async { return _post( - "/nym", + "/unfollow", { "target": target, "signature": signature, @@ -397,7 +397,7 @@ class Paynym { String code, ) async { return _post( - "/nym", + "/add", { "nym": nym, "code": code, From 07eabb60926de0d32a2204b77bbb8071c775f623 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 20 Dec 2022 10:08:14 -0600 Subject: [PATCH 004/192] update default btc testnet electrumx url --- lib/utilities/default_nodes.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index f4eb41b7c..e45e33aec 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -158,7 +158,7 @@ abstract class DefaultNodes { isDown: false); static NodeModel get bitcoinTestnet => NodeModel( - host: "electrumx-testnet.cypherstack.com", + host: "bitcoin-testnet.cypherstack.com", port: 51002, name: defaultName, id: _nodeId(Coin.bitcoinTestNet), From 1ae4f40d636613ab1157f077dde0e9fcec42a22a Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 20 Dec 2022 14:29:25 -0600 Subject: [PATCH 005/192] some basic ui prep for paynym integration --- .../wallet_network_settings_view.dart | 6 +- .../sub_widgets/wallet_navigation_bar.dart | 598 ++++++++++-------- lib/pages/wallet_view/wallet_view.dart | 110 ++-- lib/utilities/enums/coin_enum.dart | 29 +- lib/utilities/text_styles.dart | 2 +- pubspec.lock | 4 +- pubspec.yaml | 2 +- 7 files changed, 435 insertions(+), 316 deletions(-) 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 7e29010b1..84cda95fc 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 @@ -507,7 +507,7 @@ class _WalletNetworkSettingsViewState children: [ Text( "Synchronized", - style: STextStyles.w600_10(context), + style: STextStyles.w600_12(context), ), Text( "100%", @@ -581,7 +581,7 @@ class _WalletNetworkSettingsViewState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AnimatedText( - style: STextStyles.w600_10(context), + style: STextStyles.w600_12(context), stringsToLoopThrough: const [ "Synchronizing", "Synchronizing.", @@ -679,7 +679,7 @@ class _WalletNetworkSettingsViewState children: [ Text( "Unable to synchronize", - style: STextStyles.w600_10(context).copyWith( + style: STextStyles.w600_12(context).copyWith( color: Theme.of(context) .extension()! .accentColorRed, diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index 04147c883..50738d483 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -class WalletNavigationBar extends StatelessWidget { +class WalletNavigationBar extends StatefulWidget { const WalletNavigationBar({ Key? key, required this.onReceivePressed, @@ -13,6 +14,7 @@ class WalletNavigationBar extends StatelessWidget { required this.onBuyPressed, required this.height, required this.enableExchange, + required this.coin, }) : super(key: key); final VoidCallback onReceivePressed; @@ -21,265 +23,367 @@ class WalletNavigationBar extends StatelessWidget { final VoidCallback onBuyPressed; final double height; final bool enableExchange; + final Coin coin; + + @override + State createState() => _WalletNavigationBarState(); +} + +class _WalletNavigationBarState extends State { + double scale = 0; + final duration = const Duration(milliseconds: 200); @override Widget build(BuildContext context) { - return Container( - height: height, - decoration: BoxDecoration( - color: Theme.of(context).extension()!.bottomNavBack, - boxShadow: [ - Theme.of(context).extension()!.standardBoxShadow - ], - borderRadius: BorderRadius.circular( - height / 2.0, - ), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 6, - vertical: 4, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - const SizedBox( - width: 12, - ), - RawMaterialButton( - constraints: const BoxConstraints( - minWidth: 66, - ), - onPressed: onReceivePressed, - splashColor: - Theme.of(context).extension()!.highlight, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - height / 2.0, - ), - ), - child: Container( - color: Colors.transparent, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 2.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Spacer(), - Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .accentColorDark - .withOpacity(0.4), - borderRadius: BorderRadius.circular( - 24, - ), - ), - child: Padding( - padding: const EdgeInsets.all(6.0), - child: SvgPicture.asset( - Assets.svg.arrowDownLeft, - width: 12, - height: 12, - color: Theme.of(context) - .extension()! - .accentColorDark, - ), - ), + return Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + // const Spacer(), + + AnimatedScale( + scale: scale, + duration: duration, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + AnimatedOpacity( + opacity: scale, + duration: duration, + child: GestureDetector( + onTap: () {}, + child: Container( + padding: const EdgeInsets.all(16), + width: 146, + decoration: BoxDecoration( + color: + Theme.of(context).extension()!.popupBG, + boxShadow: [ + Theme.of(context) + .extension()! + .standardBoxShadow + ], + borderRadius: BorderRadius.circular( + widget.height / 2.0, ), - const SizedBox( - height: 4, - ), - Text( - "Receive", - style: STextStyles.buttonSmall(context), - ), - const Spacer(), - ], - ), - ), - ), - ), - RawMaterialButton( - constraints: const BoxConstraints( - minWidth: 66, - ), - onPressed: onSendPressed, - splashColor: - Theme.of(context).extension()!.highlight, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - height / 2.0, - ), - ), - child: Container( - color: Colors.transparent, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 2.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Spacer(), - Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .accentColorDark - .withOpacity(0.4), - borderRadius: BorderRadius.circular( - 24, - ), - ), - child: Padding( - padding: const EdgeInsets.all(6.0), - child: SvgPicture.asset( - Assets.svg.arrowUpRight, - width: 12, - height: 12, - color: Theme.of(context) - .extension()! - .accentColorDark, - ), - ), - ), - const SizedBox( - height: 4, - ), - Text( - "Send", - style: STextStyles.buttonSmall(context), - ), - const Spacer(), - ], - ), - ), - ), - ), - if (enableExchange) - RawMaterialButton( - constraints: const BoxConstraints( - minWidth: 66, - ), - onPressed: onExchangePressed, - splashColor: - Theme.of(context).extension()!.highlight, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - height / 2.0, - ), - ), - child: Container( - color: Colors.transparent, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 2.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ - const Spacer(), - SvgPicture.asset( - Assets.svg.exchange(context), - width: 24, - height: 24, - ), - const SizedBox( - height: 4, - ), Text( - "Exchange", - style: STextStyles.buttonSmall(context), + "Whirlpool", + style: STextStyles.w600_12(context), ), - const Spacer(), ], ), ), ), ), - const SizedBox( - width: 12, - ), - // TODO: Do not delete this code. - // only temporarily disabled - // Spacer( - // flex: 2, - // ), - // GestureDetector( - // onTap: onBuyPressed, - // child: Container( - // color: Colors.transparent, - // child: Padding( - // padding: const EdgeInsets.symmetric(vertical: 2.0), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // Spacer(), - // SvgPicture.asset( - // Assets.svg.buy, - // width: 24, - // height: 24, - // ), - // SizedBox( - // height: 4, - // ), - // Text( - // "Buy", - // style: STextStyles.buttonSmall(context), - // ), - // Spacer(), - // ], - // ), - // ), - // ), - // ), - ], + const SizedBox( + height: 8, + ), + AnimatedOpacity( + opacity: scale, + duration: duration, + child: GestureDetector( + onTap: () {}, + child: Container( + padding: const EdgeInsets.all(16), + width: 146, + decoration: BoxDecoration( + color: + Theme.of(context).extension()!.popupBG, + boxShadow: [ + Theme.of(context) + .extension()! + .standardBoxShadow + ], + borderRadius: BorderRadius.circular( + widget.height / 2.0, + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Paynym", + style: STextStyles.w600_12(context), + ), + ], + ), + ), + ), + ), + const SizedBox( + height: 8, + ), + ], + ), ), - ), + Container( + height: widget.height, + decoration: BoxDecoration( + color: Theme.of(context).extension()!.bottomNavBack, + boxShadow: [ + Theme.of(context).extension()!.standardBoxShadow + ], + borderRadius: BorderRadius.circular( + widget.height / 2.0, + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 6, + vertical: 4, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + const SizedBox( + width: 12, + ), + RawMaterialButton( + constraints: const BoxConstraints( + minWidth: 66, + ), + onPressed: widget.onReceivePressed, + splashColor: + Theme.of(context).extension()!.highlight, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + widget.height / 2.0, + ), + ), + child: Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 2.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Spacer(), + Container( + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .accentColorDark + .withOpacity(0.4), + borderRadius: BorderRadius.circular( + 24, + ), + ), + child: Padding( + padding: const EdgeInsets.all(6.0), + child: SvgPicture.asset( + Assets.svg.arrowDownLeft, + width: 12, + height: 12, + color: Theme.of(context) + .extension()! + .accentColorDark, + ), + ), + ), + const SizedBox( + height: 4, + ), + Text( + "Receive", + style: STextStyles.buttonSmall(context), + ), + const Spacer(), + ], + ), + ), + ), + ), + RawMaterialButton( + constraints: const BoxConstraints( + minWidth: 66, + ), + onPressed: widget.onSendPressed, + splashColor: + Theme.of(context).extension()!.highlight, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + widget.height / 2.0, + ), + ), + child: Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 2.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Spacer(), + Container( + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .accentColorDark + .withOpacity(0.4), + borderRadius: BorderRadius.circular( + 24, + ), + ), + child: Padding( + padding: const EdgeInsets.all(6.0), + child: SvgPicture.asset( + Assets.svg.arrowUpRight, + width: 12, + height: 12, + color: Theme.of(context) + .extension()! + .accentColorDark, + ), + ), + ), + const SizedBox( + height: 4, + ), + Text( + "Send", + style: STextStyles.buttonSmall(context), + ), + const Spacer(), + ], + ), + ), + ), + ), + if (widget.enableExchange) + RawMaterialButton( + constraints: const BoxConstraints( + minWidth: 66, + ), + onPressed: widget.onExchangePressed, + splashColor: + Theme.of(context).extension()!.highlight, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + widget.height / 2.0, + ), + ), + child: Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 2.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Spacer(), + SvgPicture.asset( + Assets.svg.exchange(context), + width: 24, + height: 24, + ), + const SizedBox( + height: 4, + ), + Text( + "Exchange", + style: STextStyles.buttonSmall(context), + ), + const Spacer(), + ], + ), + ), + ), + ), + if (widget.coin.hasPaynymSupport) + RawMaterialButton( + constraints: const BoxConstraints( + minWidth: 66, + ), + onPressed: () { + if (scale == 0) { + setState(() { + scale = 1; + }); + } else if (scale == 1) { + setState(() { + scale = 0; + }); + } + }, + splashColor: + Theme.of(context).extension()!.highlight, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + widget.height / 2.0, + ), + ), + child: Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 2.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Spacer(), + const SizedBox( + height: 2, + ), + SvgPicture.asset( + Assets.svg.bars, + width: 20, + height: 20, + ), + const SizedBox( + height: 6, + ), + Text( + "More", + style: STextStyles.buttonSmall(context), + ), + const Spacer(), + ], + ), + ), + ), + ), + const SizedBox( + width: 12, + ), + // TODO: Do not delete this code. + // only temporarily disabled + // Spacer( + // flex: 2, + // ), + // GestureDetector( + // onTap: onBuyPressed, + // child: Container( + // color: Colors.transparent, + // child: Padding( + // padding: const EdgeInsets.symmetric(vertical: 2.0), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Spacer(), + // SvgPicture.asset( + // Assets.svg.buy, + // width: 24, + // height: 24, + // ), + // SizedBox( + // height: 4, + // ), + // Text( + // "Buy", + // style: STextStyles.buttonSmall(context), + // ), + // Spacer(), + // ], + // ), + // ), + // ), + // ), + ], + ), + ), + ), + ], ); } } -// -// class BarButton extends StatelessWidget { -// const BarButton( -// {Key? key, required this.icon, required this.text, this.onPressed}) -// : super(key: key); -// -// final Widget icon; -// final String text; -// final VoidCallback? onPressed; -// -// @override -// Widget build(BuildContext context) { -// return Container( -// child: MaterialButton( -// splashColor: Theme.of(context).extension()!.highlight, -// padding: const EdgeInsets.all(0), -// minWidth: 45, -// shape: RoundedRectangleBorder( -// borderRadius: BorderRadius.circular( -// Constants.size.circularBorderRadius, -// ), -// ), -// materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, -// onPressed: onPressed, -// child: Padding( -// padding: const EdgeInsets.all(4.0), -// child: Column( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// icon, -// SizedBox( -// height: 4, -// ), -// Text( -// text, -// style: STextStyles.itemSubtitle12(context).copyWith( -// fontSize: 10, -// ), -// ), -// ], -// ), -// ), -// ), -// ); -// } -// } diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 4b415074c..16f4519b9 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -35,7 +35,6 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -707,7 +706,6 @@ class _WalletViewState extends ConsumerState { Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - const Spacer(), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -717,67 +715,63 @@ class _WalletViewState extends ConsumerState { left: 16, right: 16, ), - child: SizedBox( + child: WalletNavigationBar( + coin: ref.watch(managerProvider + .select((value) => value.coin)), + enableExchange: Constants.enableExchange && + ref.watch(managerProvider.select( + (value) => value.coin)) != + Coin.epicCash, height: WalletView.navBarHeight, - child: WalletNavigationBar( - enableExchange: - Constants.enableExchange && - ref.watch(managerProvider.select( - (value) => value.coin)) != - Coin.epicCash, - height: WalletView.navBarHeight, - onExchangePressed: () => - _onExchangePressed(context), - onReceivePressed: () async { - final coin = - ref.read(managerProvider).coin; - if (mounted) { - unawaited( - Navigator.of(context).pushNamed( - ReceiveView.routeName, - arguments: Tuple2( - walletId, - coin, - ), - )); - } - }, - onSendPressed: () { - final walletId = - ref.read(managerProvider).walletId; - final coin = - ref.read(managerProvider).coin; - switch (ref - .read( - walletBalanceToggleStateProvider - .state) - .state) { - case WalletBalanceToggleState.full: - ref - .read( - publicPrivateBalanceStateProvider - .state) - .state = "Public"; - break; - case WalletBalanceToggleState - .available: - ref - .read( - publicPrivateBalanceStateProvider - .state) - .state = "Private"; - break; - } - Navigator.of(context).pushNamed( - SendView.routeName, + onExchangePressed: () => + _onExchangePressed(context), + onReceivePressed: () async { + final coin = + ref.read(managerProvider).coin; + if (mounted) { + unawaited( + Navigator.of(context).pushNamed( + ReceiveView.routeName, arguments: Tuple2( walletId, coin, ), - ); - }, - onBuyPressed: () {}, - ), + )); + } + }, + onSendPressed: () { + final walletId = + ref.read(managerProvider).walletId; + final coin = + ref.read(managerProvider).coin; + switch (ref + .read(walletBalanceToggleStateProvider + .state) + .state) { + case WalletBalanceToggleState.full: + ref + .read( + publicPrivateBalanceStateProvider + .state) + .state = "Public"; + break; + case WalletBalanceToggleState.available: + ref + .read( + publicPrivateBalanceStateProvider + .state) + .state = "Private"; + break; + } + Navigator.of(context).pushNamed( + SendView.routeName, + arguments: Tuple2( + walletId, + coin, + ), + ); + }, + onBuyPressed: () {}, ), ), ], diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index e90509305..1d1f6e15d 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -11,12 +11,10 @@ import 'package:stackwallet/services/coins/litecoin/litecoin_wallet.dart' import 'package:stackwallet/services/coins/monero/monero_wallet.dart' as xmr; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart' as nmc; +import 'package:stackwallet/services/coins/particl/particl_wallet.dart' + as particl; import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow; -import 'package:stackwallet/services/coins/particl/particl_wallet.dart' - as particl; import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/services/coins/particl/particl_wallet.dart' - as particl; enum Coin { bitcoin, @@ -174,6 +172,29 @@ extension CoinExt on Coin { } } + bool get hasPaynymSupport { + switch (this) { + case Coin.bitcoin: + case Coin.litecoin: + case Coin.bitcoincash: + case Coin.firo: + case Coin.namecoin: + case Coin.particl: + case Coin.bitcoinTestNet: + case Coin.litecoinTestNet: + case Coin.bitcoincashTestnet: + case Coin.firoTestNet: + case Coin.epicCash: + case Coin.monero: + case Coin.wownero: + return false; + + case Coin.dogecoin: + case Coin.dogecoinTestNet: + return true; + } + } + int get requiredConfirmations { switch (this) { case Coin.bitcoin: diff --git a/lib/utilities/text_styles.dart b/lib/utilities/text_styles.dart index 56c313219..42a0ba488 100644 --- a/lib/utilities/text_styles.dart +++ b/lib/utilities/text_styles.dart @@ -568,7 +568,7 @@ class STextStyles { } } - static TextStyle w600_10(BuildContext context) { + static TextStyle w600_12(BuildContext context) { switch (_theme(context).themeType) { case ThemeType.light: return GoogleFonts.inter( diff --git a/pubspec.lock b/pubspec.lock index 92f0eb3d7..701cc6636 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -100,8 +100,8 @@ packages: dependency: "direct main" description: path: "." - ref: main - resolved-ref: "48bd568b4f64c976813387fbae71a5daf48cff81" + ref: testing + resolved-ref: "8ed2f6245c71a4457ed4ffdd3a74e4bcb9f9d2d0" url: "https://github.com/cypherstack/bip47.git" source: git version: "1.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 05cbe66b0..af8e082e6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -59,7 +59,7 @@ dependencies: bip47: git: url: https://github.com/cypherstack/bip47.git - ref: main + ref: testing # Utility plugins # provider: ^6.0.1 From 7d8c2d1fdac2a3433b167109b1f43c9835583801 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 20 Dec 2022 14:29:35 -0600 Subject: [PATCH 006/192] paynym api rename --- lib/utilities/paynym_api.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_api.dart index cb4300624..9cc7d42e9 100644 --- a/lib/utilities/paynym_api.dart +++ b/lib/utilities/paynym_api.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -class Paynym { +class PaynymAPI { static const String baseURL = "https://paynym.is/api"; static const String version = "/v1"; From 5c8f72afa65e0a0d6a86f0a66035290924d0cdaf Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 20 Dec 2022 14:48:31 -0600 Subject: [PATCH 007/192] claim paynym view --- lib/pages/paynym/paynym_claim_view.dart | 80 +++++++++++++++++++ .../sub_widgets/wallet_navigation_bar.dart | 9 ++- lib/route_generator.dart | 9 ++- 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 lib/pages/paynym/paynym_claim_view.dart diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart new file mode 100644 index 000000000..389c66ce5 --- /dev/null +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -0,0 +1,80 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; + +class PaynymClaimView extends StatefulWidget { + const PaynymClaimView({Key? key}) : super(key: key); + + static const String routeName = "/claimPaynym"; + + @override + State createState() => _PaynymClaimViewState(); +} + +class _PaynymClaimViewState extends State { + @override + Widget build(BuildContext context) { + debugPrint("BUILD: $runtimeType"); + final isDesktop = Util.isDesktop; + + return MasterScaffold( + isDesktop: isDesktop, + appBar: AppBar( + leading: AppBarBackButton( + onPressed: () { + Navigator.of(context).pop(); + }, + ), + titleSpacing: 0, + title: Text( + "PayNym", + style: STextStyles.navBarTitle(context), + overflow: TextOverflow.ellipsis, + ), + ), + body: SafeArea( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + const Spacer( + flex: 1, + ), + Image( + image: AssetImage( + Assets.png.stack, + ), + width: MediaQuery.of(context).size.width / 2, + ), + const SizedBox( + height: 20, + ), + Text( + "You do not have a PayNym yet.\nClaim yours now!", + style: STextStyles.baseXS(context).copyWith( + color: + Theme.of(context).extension()!.textSubtitle1, + ), + textAlign: TextAlign.center, + ), + const Spacer( + flex: 2, + ), + PrimaryButton( + label: "Claim", + onPressed: () { + // generate and submit paynym to api + }, + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index 50738d483..baefa8ebc 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -5,6 +5,8 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import '../../paynym/paynym_claim_view.dart'; + class WalletNavigationBar extends StatefulWidget { const WalletNavigationBar({ Key? key, @@ -86,7 +88,12 @@ class _WalletNavigationBarState extends State { opacity: scale, duration: duration, child: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + scale = 0; + }); + Navigator.of(context).pushNamed(PaynymClaimView.routeName); + }, child: Container( padding: const EdgeInsets.all(16), width: 146, diff --git a/lib/route_generator.dart b/lib/route_generator.dart index ed676c437..514c6614d 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -36,6 +36,7 @@ import 'package:stackwallet/pages/home_view/home_view.dart'; import 'package:stackwallet/pages/intro_view.dart'; import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; import 'package:stackwallet/pages/notification_views/notifications_view.dart'; +import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; import 'package:stackwallet/pages/receive_view/generate_receiving_uri_qr_code_view.dart'; import 'package:stackwallet/pages/receive_view/receive_view.dart'; @@ -172,7 +173,7 @@ class RouteGenerator { } return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => StackPrivacyCalls(isSettings: false), + builder: (_) => const StackPrivacyCalls(isSettings: false), settings: RouteSettings(name: settings.name)); case WalletsView.routeName: @@ -187,6 +188,12 @@ class RouteGenerator { builder: (_) => const AddWalletView(), settings: RouteSettings(name: settings.name)); + case PaynymClaimView.routeName: + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const PaynymClaimView(), + settings: RouteSettings(name: settings.name)); + case GlobalSettingsView.routeName: return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, From f897b677148ced26d2174349818f8d21db0d33fb Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 20 Dec 2022 15:05:11 -0600 Subject: [PATCH 008/192] claiming paynym spinner dialog --- .../dialogs/claiming_paynym_dialog.dart | 114 ++++++++++++++++++ lib/pages/paynym/paynym_claim_view.dart | 19 ++- .../sub_widgets/wallet_navigation_bar.dart | 3 +- lib/providers/global/paynym_api_provider.dart | 4 + 4 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 lib/pages/paynym/dialogs/claiming_paynym_dialog.dart create mode 100644 lib/providers/global/paynym_api_provider.dart diff --git a/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart new file mode 100644 index 000000000..530950ec4 --- /dev/null +++ b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart @@ -0,0 +1,114 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/stack_dialog.dart'; + +class ClaimingPaynymDialog extends StatefulWidget { + const ClaimingPaynymDialog({ + Key? key, + }) : super(key: key); + + @override + State createState() => _RestoringDialogState(); +} + +class _RestoringDialogState extends State + with TickerProviderStateMixin { + late AnimationController? _spinController; + late Animation _spinAnimation; + + @override + void initState() { + _spinController = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + )..repeat(); + + _spinAnimation = CurvedAnimation( + parent: _spinController!, + curve: Curves.linear, + ); + + super.initState(); + } + + @override + void dispose() { + _spinController?.dispose(); + _spinController = null; + + super.dispose(); + } + + @override + Widget build(BuildContext context) { + if (Util.isDesktop) { + return DesktopDialog( + child: Padding( + padding: const EdgeInsets.all(40), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Claiming PayNym", + style: STextStyles.desktopH3(context), + ), + const SizedBox( + height: 20, + ), + Text( + "We are generating your PayNym", + style: STextStyles.desktopSubtitleH1(context), + ), + const SizedBox( + height: 40, + ), + RotationTransition( + turns: _spinAnimation, + child: SvgPicture.asset( + Assets.svg.arrowRotate, + color: Theme.of(context) + .extension()! + .accentColorDark, + width: 24, + height: 24, + ), + ), + ], + ), + ), + ); + } else { + return WillPopScope( + onWillPop: () async { + return false; + }, + child: StackDialog( + title: "Claiming PayNym", + message: "We are generating your PayNym", + icon: RotationTransition( + turns: _spinAnimation, + child: SvgPicture.asset( + Assets.svg.arrowRotate, + color: + Theme.of(context).extension()!.accentColorDark, + width: 24, + height: 24, + ), + ), + rightButton: SecondaryButton( + label: "Cancel", + onPressed: () { + Navigator.of(context).pop(true); + }, + ), + ), + ); + } + } +} diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index 389c66ce5..f0e53fe05 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -7,6 +9,8 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'dialogs/claiming_paynym_dialog.dart'; + class PaynymClaimView extends StatefulWidget { const PaynymClaimView({Key? key}) : super(key: key); @@ -67,8 +71,21 @@ class _PaynymClaimViewState extends State { ), PrimaryButton( label: "Claim", - onPressed: () { + onPressed: () async { + bool shouldCancel = false; + unawaited( + showDialog( + context: context, + builder: (context) => const ClaimingPaynymDialog(), + ).then((value) => shouldCancel = value == true), + ); // generate and submit paynym to api + + await Future.delayed(const Duration(seconds: 3)); + + if (mounted && !shouldCancel) { + Navigator.of(context).pop(); + } }, ), ], diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index baefa8ebc..469d5d169 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -import '../../paynym/paynym_claim_view.dart'; - class WalletNavigationBar extends StatefulWidget { const WalletNavigationBar({ Key? key, diff --git a/lib/providers/global/paynym_api_provider.dart b/lib/providers/global/paynym_api_provider.dart new file mode 100644 index 000000000..06afd0b72 --- /dev/null +++ b/lib/providers/global/paynym_api_provider.dart @@ -0,0 +1,4 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/utilities/paynym_api.dart'; + +final paynymAPIProvider = Provider((_) => PaynymAPI()); From bbd04f46bba3b38452b0bdbebdf5e5058f715c0e Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 20 Dec 2022 16:58:25 -0600 Subject: [PATCH 009/192] created_paynym object --- lib/models/paynym/created_paynym.dart | 35 +++++++++++++++++++++++++++ lib/utilities/paynym_api.dart | 6 +++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 lib/models/paynym/created_paynym.dart diff --git a/lib/models/paynym/created_paynym.dart b/lib/models/paynym/created_paynym.dart new file mode 100644 index 000000000..4efdcb85b --- /dev/null +++ b/lib/models/paynym/created_paynym.dart @@ -0,0 +1,35 @@ +class CreatedPaynym { + final bool claimed; + final String nymAvatar; + final String? nymId; + final String? nymName; + final String? token; + + CreatedPaynym( + this.claimed, + this.nymAvatar, + this.nymId, + this.nymName, + this.token, + ); + + CreatedPaynym.fromMap(Map map) + : claimed = map["claimed"] as bool, + nymAvatar = map["nymAvatar"] as String, + nymId = map["nymId"] as String?, + nymName = map["nymName"] as String?, + token = map["token"] as String?; + + Map toMap() => { + "claimed": claimed, + "nymAvatar": nymAvatar, + "nymId": nymId, + "nymName": nymName, + "token": token, + }; + + @override + String toString() { + return toMap().toString(); + } +} diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_api.dart index 9cc7d42e9..e2ef33a96 100644 --- a/lib/utilities/paynym_api.dart +++ b/lib/utilities/paynym_api.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; +import 'package:stackwallet/models/paynym/created_paynym.dart'; class PaynymAPI { static const String baseURL = "https://paynym.is/api"; @@ -73,8 +74,9 @@ class PaynymAPI { // // // ------ - Future> create(String code) async { - return _post("/create", {"code": code}); + Future create(String code) async { + final map = await _post("/create", {"code": code}); + return CreatedPaynym.fromMap(map); } // ### `/api/v1/token` From a491bfd70f94db61270dd6523634b4a9df587d21 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 20 Dec 2022 17:00:03 -0600 Subject: [PATCH 010/192] WIP paynym ui and claim process --- lib/pages/paynym/paynym_claim_view.dart | 63 ++++++++++++++-- lib/pages/paynym/paynym_home_view.dart | 72 +++++++++++++++++++ .../sub_widgets/wallet_navigation_bar.dart | 7 +- lib/pages/wallet_view/wallet_view.dart | 1 + lib/route_generator.dart | 30 +++++++- lib/services/coins/coin_paynym_extension.dart | 37 ++++++++++ .../coins/dogecoin/dogecoin_wallet.dart | 35 +++++---- 7 files changed, 218 insertions(+), 27 deletions(-) create mode 100644 lib/pages/paynym/paynym_home_view.dart create mode 100644 lib/services/coins/coin_paynym_extension.dart diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index f0e53fe05..adb70f1d8 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -1,6 +1,12 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/pages/paynym/dialogs/claiming_paynym_dialog.dart'; +import 'package:stackwallet/providers/global/paynym_api_provider.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -9,18 +15,21 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'dialogs/claiming_paynym_dialog.dart'; +class PaynymClaimView extends ConsumerStatefulWidget { + const PaynymClaimView({ + Key? key, + required this.walletId, + }) : super(key: key); -class PaynymClaimView extends StatefulWidget { - const PaynymClaimView({Key? key}) : super(key: key); + final String walletId; static const String routeName = "/claimPaynym"; @override - State createState() => _PaynymClaimViewState(); + ConsumerState createState() => _PaynymClaimViewState(); } -class _PaynymClaimViewState extends State { +class _PaynymClaimViewState extends ConsumerState { @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); @@ -81,6 +90,50 @@ class _PaynymClaimViewState extends State { ); // generate and submit paynym to api + final wallet = ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; + final pCode = await wallet.getPaymentCode(); + + final result = await ref + .read(paynymAPIProvider) + .create(pCode.toString()); + + // final result = + // await ref.read(paynymAPIProvider).token(pCode.toString()); + + // final token = + // "IlBNOFRKWWt1U2RZWEpud0RCcThDaGZpbmZYdjNzcnhoUXJ4M2VvRXdiU3c1MXdNamRvOUpKMkRzeWN3VDNndDN6SFE3Y1YxZ3J2YWJNbW1mMUJ0ajZmWTd0Z2tnU3o5QjhNWnVSM2tqWWZnTUxNVVJKQ1hOIg.FoPF3g.KUMZDC4U_ek-B6cqPLYilXniQv8"; + // + // print("======================"); + // print(token); + // print(token.codeUnits); + // print(utf8.encode(token)); + // print(utf8.decode(token.codeUnits)); + // + // print("======================"); + // + // final signed = await wallet.signWithNotificationKey( + // Uint8List.fromList(token.codeUnits)); + // + // final signedString = Format.uint8listToString(signed); + // + // print("======================"); + // print(signed); + // print(signedString); + // + // print("======================"); + + // final result2 = await ref + // .read(paynymAPIProvider) + // .claim(token, signedString); + + // print("======================"); + // print( + // result2); // {claimed: PM8TJYkuSdYXJnwDBq8ChfinfXv3srxhQrx3eoEwbSw51wMjdo9JJ2DsycwT3gt3zHQ7cV1grvabMmmf1Btj6fY7tgkgSz9B8MZuR3kjYfgMLMURJCXN, token: IlBNOFRKWWt1U2RZWEpud0RCcThDaGZpbmZYdjNzcnhoUXJ4M2VvRXdiU3c1MXdNamRvOUpKMkRzeWN3VDNndDN6SFE3Y1YxZ3J2YWJNbW1mMUJ0ajZmWTd0Z2tnU3o5QjhNWnVSM2tqWWZnTUxNVVJKQ1hOIg.FoPF3g.KUMZDC4U_ek-B6cqPLYilXniQv8} + // print("======================"); + await Future.delayed(const Duration(seconds: 3)); if (mounted && !shouldCancel) { diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart new file mode 100644 index 000000000..93873b003 --- /dev/null +++ b/lib/pages/paynym/paynym_home_view.dart @@ -0,0 +1,72 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; + +class PaynymHomeView extends StatefulWidget { + const PaynymHomeView({ + Key? key, + required this.walletId, + required this.paymentCodeString, + }) : super(key: key); + + final String walletId; + final String paymentCodeString; + + static const String routeName = "/paynymHome"; + + @override + State createState() => _PaynymHomeViewState(); +} + +class _PaynymHomeViewState extends State { + @override + Widget build(BuildContext context) { + debugPrint("BUILD: $runtimeType"); + final isDesktop = Util.isDesktop; + + return MasterScaffold( + isDesktop: isDesktop, + appBar: AppBar( + leading: AppBarBackButton( + onPressed: () { + Navigator.of(context).pop(); + }, + ), + titleSpacing: 0, + title: Text( + "PayNym", + style: STextStyles.navBarTitle(context), + overflow: TextOverflow.ellipsis, + ), + ), + body: SafeArea( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + PayNymBot( + paymentCodeString: widget.paymentCodeString, + ), + ], + ), + ), + ), + ); + } +} + +class PayNymBot extends StatelessWidget { + const PayNymBot({ + Key? key, + required this.paymentCodeString, + }) : super(key: key); + + final String paymentCodeString; + + @override + Widget build(BuildContext context) { + return Image.network("https://paynym.is/$paymentCodeString/avatar"); + } +} diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index 469d5d169..41b429311 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -16,6 +16,7 @@ class WalletNavigationBar extends StatefulWidget { required this.height, required this.enableExchange, required this.coin, + required this.walletId, }) : super(key: key); final VoidCallback onReceivePressed; @@ -25,6 +26,7 @@ class WalletNavigationBar extends StatefulWidget { final double height; final bool enableExchange; final Coin coin; + final String walletId; @override State createState() => _WalletNavigationBarState(); @@ -91,7 +93,10 @@ class _WalletNavigationBarState extends State { setState(() { scale = 0; }); - Navigator.of(context).pushNamed(PaynymClaimView.routeName); + Navigator.of(context).pushNamed( + PaynymClaimView.routeName, + arguments: widget.walletId, + ); }, child: Container( padding: const EdgeInsets.all(16), diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 16f4519b9..6d44e226e 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -716,6 +716,7 @@ class _WalletViewState extends ConsumerState { right: 16, ), child: WalletNavigationBar( + walletId: widget.walletId, coin: ref.watch(managerProvider .select((value) => value.coin)), enableExchange: Constants.enableExchange && diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 514c6614d..3da3a29d7 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -37,6 +37,7 @@ import 'package:stackwallet/pages/intro_view.dart'; import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; import 'package:stackwallet/pages/notification_views/notifications_view.dart'; import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; +import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; import 'package:stackwallet/pages/receive_view/generate_receiving_uri_qr_code_view.dart'; import 'package:stackwallet/pages/receive_view/receive_view.dart'; @@ -189,10 +190,33 @@ class RouteGenerator { settings: RouteSettings(name: settings.name)); case PaynymClaimView.routeName: - return getRoute( + if (args is String) { + return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const PaynymClaimView(), - settings: RouteSettings(name: settings.name)); + builder: (_) => PaynymClaimView( + walletId: args, + ), + settings: RouteSettings( + name: settings.name, + ), + ); + } + return _routeError("${settings.name} invalid args: ${args.toString()}"); + + case PaynymHomeView.routeName: + if (args is Tuple2) { + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => PaynymHomeView( + walletId: args.item1, + paymentCodeString: args.item2, + ), + settings: RouteSettings( + name: settings.name, + ), + ); + } + return _routeError("${settings.name} invalid args: ${args.toString()}"); case GlobalSettingsView.routeName: return getRoute( diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart new file mode 100644 index 000000000..99ee6ec32 --- /dev/null +++ b/lib/services/coins/coin_paynym_extension.dart @@ -0,0 +1,37 @@ +import 'dart:typed_data'; + +import 'package:bip47/bip47.dart'; +import 'package:bitcoindart/bitcoindart.dart'; +import 'package:pointycastle/digests/sha256.dart'; +import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; + +extension PayNym on DogecoinWallet { + // fetch or generate this wallet's bip47 payment code + Future getPaymentCode() async { + final paymentCodeString = DB.instance + .get(boxName: walletId, key: "paymentCodeString") as String?; + PaymentCode paymentCode; + if (paymentCodeString == null) { + final node = getBip32Root((await mnemonic).join(" "), network) + .derivePath("m/47'/0'/0'"); + paymentCode = + PaymentCode.initFromPubKey(node.publicKey, node.chainCode, network); + await DB.instance.put( + boxName: walletId, + key: "paymentCodeString", + value: paymentCode.toString()); + } else { + paymentCode = PaymentCode.fromPaymentCode(paymentCodeString, network); + } + return paymentCode; + } + + Future signWithNotificationKey(Uint8List data) async { + final node = getBip32Root((await mnemonic).join(" "), network) + .derivePath("m/47'/0'/0'"); + final pair = ECPair.fromPrivateKey(node.privateKey!, network: network); + final signed = pair.sign(SHA256Digest().process(data)); + return signed; + } +} diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index e477dfc78..696790ad7 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -135,7 +135,7 @@ class DogecoinWallet extends CoinServiceAPI { late final TransactionNotificationTracker txTracker; - NetworkType get _network { + NetworkType get network { switch (coin) { case Coin.dogecoin: return dogecoin; @@ -266,7 +266,7 @@ class DogecoinWallet extends CoinServiceAPI { // Base58check decode fail } if (decodeBase58 != null) { - if (decodeBase58[0] == _network.pubKeyHash) { + if (decodeBase58[0] == network.pubKeyHash) { // P2PKH return DerivePathType.bip44; } @@ -277,7 +277,7 @@ class DogecoinWallet extends CoinServiceAPI { } catch (err) { // Bech32 decode fail } - if (_network.bech32 != decodeBech32!.hrp) { + if (network.bech32 != decodeBech32!.hrp) { throw ArgumentError('Invalid prefix or Network mismatch'); } if (decodeBech32.version != 0) { @@ -385,8 +385,7 @@ class DogecoinWallet extends CoinServiceAPI { switch (type) { case DerivePathType.bip44: address = P2PKH( - data: PaymentData(pubkey: node.publicKey), - network: _network) + data: PaymentData(pubkey: node.publicKey), network: network) .data .address!; break; @@ -472,7 +471,7 @@ class DogecoinWallet extends CoinServiceAPI { Map> p2pkhReceiveDerivations = {}; Map> p2pkhChangeDerivations = {}; - final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, _network)); + final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, network)); List p2pkhReceiveAddressArray = []; int p2pkhReceiveIndex = -1; @@ -1104,7 +1103,7 @@ class DogecoinWallet extends CoinServiceAPI { @override bool validateAddress(String address) { - return Address.validateAddress(address, _network); + return Address.validateAddress(address, network); } @override @@ -1358,7 +1357,7 @@ class DogecoinWallet extends CoinServiceAPI { chain, index, mnemonic!, - _network, + network, derivePathType, ), ); @@ -1367,7 +1366,7 @@ class DogecoinWallet extends CoinServiceAPI { switch (derivePathType) { case DerivePathType.bip44: - address = P2PKH(data: data, network: _network).data.address!; + address = P2PKH(data: data, network: network).data.address!; break; // default: // // should never hit this due to all enum cases handled @@ -1601,7 +1600,7 @@ class DogecoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = _convertToScriptHash(allAddresses[i], network); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -1761,7 +1760,7 @@ class DogecoinWallet extends CoinServiceAPI { Future getTxCount({required String address}) async { String? scripthash; try { - scripthash = _convertToScriptHash(address, _network); + scripthash = _convertToScriptHash(address, network); final transactions = await electrumXClient.getHistory(scripthash: scripthash); return transactions.length; @@ -1779,7 +1778,7 @@ class DogecoinWallet extends CoinServiceAPI { try { final Map> args = {}; for (final entry in addresses.entries) { - args[entry.key] = [_convertToScriptHash(entry.value, _network)]; + args[entry.key] = [_convertToScriptHash(entry.value, network)]; } final response = await electrumXClient.getBatchHistory(args: args); @@ -1971,7 +1970,7 @@ class DogecoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = _convertToScriptHash(allAddresses[i], network); final id = Logger.isTestEnv ? "$i" : const Uuid().v1(); requestIdToAddressMap[id] = allAddresses[i]; batches[batchNumber]!.addAll({ @@ -2746,7 +2745,7 @@ class DogecoinWallet extends CoinServiceAPI { data: PaymentData( pubkey: Format.stringToUint8List( receiveDerivation["pubKey"] as String)), - network: _network, + network: network, ).data; for (String tx in addressTxid[addressesP2PKH[i]]!) { @@ -2754,7 +2753,7 @@ class DogecoinWallet extends CoinServiceAPI { "output": data.output, "keyPair": ECPair.fromWIF( receiveDerivation["wif"] as String, - network: _network, + network: network, ), }; } @@ -2767,7 +2766,7 @@ class DogecoinWallet extends CoinServiceAPI { data: PaymentData( pubkey: Format.stringToUint8List( changeDerivation["pubKey"] as String)), - network: _network, + network: network, ).data; for (String tx in addressTxid[addressesP2PKH[i]]!) { @@ -2775,7 +2774,7 @@ class DogecoinWallet extends CoinServiceAPI { "output": data.output, "keyPair": ECPair.fromWIF( changeDerivation["wif"] as String, - network: _network, + network: network, ), }; } @@ -2802,7 +2801,7 @@ class DogecoinWallet extends CoinServiceAPI { Logging.instance .log("Starting buildTransaction ----------", level: LogLevel.Info); - final txb = TransactionBuilder(network: _network); + final txb = TransactionBuilder(network: network); txb.setVersion(1); // Add transaction inputs From 3b6d53d685c1d2f1dc26490e73ca31a474059dd8 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 10:17:53 -0600 Subject: [PATCH 011/192] WIP paynym home view --- assets/svg/circle-plus-filled.svg | 3 + lib/models/paynym/paynym_account.dart | 48 +++++ lib/models/paynym/paynym_code.dart | 27 +++ lib/pages/paynym/paynym_claim_view.dart | 67 +++--- lib/pages/paynym/paynym_home_view.dart | 199 +++++++++++++++++- .../sub_widgets/wallet_navigation_bar.dart | 121 ++++++++--- lib/route_generator.dart | 5 +- lib/services/coins/coin_paynym_extension.dart | 3 + lib/utilities/assets.dart | 1 + lib/utilities/format.dart | 4 + lib/utilities/paynym_api.dart | 15 +- lib/widgets/desktop/secondary_button.dart | 16 +- lib/widgets/icon_widgets/share_icon.dart | 27 +++ lib/widgets/loading_indicator.dart | 22 +- lib/widgets/toggle.dart | 96 +++++---- pubspec.yaml | 1 + 16 files changed, 521 insertions(+), 134 deletions(-) create mode 100644 assets/svg/circle-plus-filled.svg create mode 100644 lib/models/paynym/paynym_account.dart create mode 100644 lib/models/paynym/paynym_code.dart create mode 100644 lib/widgets/icon_widgets/share_icon.dart diff --git a/assets/svg/circle-plus-filled.svg b/assets/svg/circle-plus-filled.svg new file mode 100644 index 000000000..3e3244adb --- /dev/null +++ b/assets/svg/circle-plus-filled.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/models/paynym/paynym_account.dart b/lib/models/paynym/paynym_account.dart new file mode 100644 index 000000000..08438a6b7 --- /dev/null +++ b/lib/models/paynym/paynym_account.dart @@ -0,0 +1,48 @@ +import 'package:stackwallet/models/paynym/paynym_code.dart'; + +class PaynymAccount { + final String nymID; + final String nymName; + + final List codes; + + /// list of nymId + final List followers; + + /// list of nymId + final List following; + + PaynymAccount( + this.nymID, + this.nymName, + this.codes, + this.followers, + this.following, + ); + + PaynymAccount.fromMap(Map map) + : nymID = map["nymID"] as String, + nymName = map["nymName"] as String, + codes = (map["codes"] as List) + .map((e) => PaynymCode.fromMap(Map.from(e as Map))) + .toList(), + followers = (map["followers"] as List) + .map((e) => e["nymId"] as String) + .toList(), + following = (map["following"] as List) + .map((e) => e["nymId"] as String) + .toList(); + + Map toMap() => { + "nymID": nymID, + "nymName": nymName, + "codes": codes.map((e) => e.toMap()), + "followers": followers.map((e) => {"nymId": e}), + "following": followers.map((e) => {"nymId": e}), + }; + + @override + String toString() { + return toMap().toString(); + } +} diff --git a/lib/models/paynym/paynym_code.dart b/lib/models/paynym/paynym_code.dart new file mode 100644 index 000000000..d01366d20 --- /dev/null +++ b/lib/models/paynym/paynym_code.dart @@ -0,0 +1,27 @@ +class PaynymCode { + final bool claimed; + final bool segwit; + final String code; + + PaynymCode( + this.claimed, + this.segwit, + this.code, + ); + + PaynymCode.fromMap(Map map) + : claimed = map["claimed"] as bool, + segwit = map["segwit"] as bool, + code = map["code"] as String; + + Map toMap() => { + "claimed": claimed, + "segwit": segwit, + "code": code, + }; + + @override + String toString() { + return toMap().toString(); + } +} diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index adb70f1d8..b9b5ebd95 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -8,6 +9,7 @@ import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -88,53 +90,52 @@ class _PaynymClaimViewState extends ConsumerState { builder: (context) => const ClaimingPaynymDialog(), ).then((value) => shouldCancel = value == true), ); - // generate and submit paynym to api + // ghet wallet to access paynym calls final wallet = ref .read(walletsChangeNotifierProvider) .getManager(widget.walletId) .wallet as DogecoinWallet; + + // get payment code final pCode = await wallet.getPaymentCode(); - final result = await ref + // attempt to create new entry in paynym.is db + final created = await ref .read(paynymAPIProvider) .create(pCode.toString()); - // final result = - // await ref.read(paynymAPIProvider).token(pCode.toString()); + if (created.claimed) { + // payment code already claimed + debugPrint("pcode already claimed!!"); + return; + } - // final token = - // "IlBNOFRKWWt1U2RZWEpud0RCcThDaGZpbmZYdjNzcnhoUXJ4M2VvRXdiU3c1MXdNamRvOUpKMkRzeWN3VDNndDN6SFE3Y1YxZ3J2YWJNbW1mMUJ0ajZmWTd0Z2tnU3o5QjhNWnVSM2tqWWZnTUxNVVJKQ1hOIg.FoPF3g.KUMZDC4U_ek-B6cqPLYilXniQv8"; - // - // print("======================"); - // print(token); - // print(token.codeUnits); - // print(utf8.encode(token)); - // print(utf8.decode(token.codeUnits)); - // - // print("======================"); - // - // final signed = await wallet.signWithNotificationKey( - // Uint8List.fromList(token.codeUnits)); - // - // final signedString = Format.uint8listToString(signed); - // - // print("======================"); - // print(signed); - // print(signedString); - // - // print("======================"); + String token; - // final result2 = await ref - // .read(paynymAPIProvider) - // .claim(token, signedString); + if (created.token == null) { + // payment code already in db + // so we need to fetch a token - // print("======================"); - // print( - // result2); // {claimed: PM8TJYkuSdYXJnwDBq8ChfinfXv3srxhQrx3eoEwbSw51wMjdo9JJ2DsycwT3gt3zHQ7cV1grvabMmmf1Btj6fY7tgkgSz9B8MZuR3kjYfgMLMURJCXN, token: IlBNOFRKWWt1U2RZWEpud0RCcThDaGZpbmZYdjNzcnhoUXJ4M2VvRXdiU3c1MXdNamRvOUpKMkRzeWN3VDNndDN6SFE3Y1YxZ3J2YWJNbW1mMUJ0ajZmWTd0Z2tnU3o5QjhNWnVSM2tqWWZnTUxNVVJKQ1hOIg.FoPF3g.KUMZDC4U_ek-B6cqPLYilXniQv8} - // print("======================"); + token = await ref + .read(paynymAPIProvider) + .token(pCode.toString()); + } else { + token = created.token!; + } - await Future.delayed(const Duration(seconds: 3)); + // sign token with notification private key + final signatureBytes = await wallet.signWithNotificationKey( + Uint8List.fromList(token.codeUnits)); + final signature = Format.uint8listToString(signatureBytes); + + // claim paynym account + final claim = + await ref.read(paynymAPIProvider).claim(token, signature); + + if (claim["claimed"] == pCode.toString()) { + // mark claim successful + } if (mounted && !shouldCancel) { Navigator.of(context).pop(); diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 93873b003..4782e2491 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -1,18 +1,31 @@ import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/models/paynym/paynym_account.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart'; +import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; +import 'package:stackwallet/widgets/icon_widgets/share_icon.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'package:stackwallet/widgets/toggle.dart'; class PaynymHomeView extends StatefulWidget { const PaynymHomeView({ Key? key, required this.walletId, - required this.paymentCodeString, + required this.nymAccount, }) : super(key: key); final String walletId; - final String paymentCodeString; + final PaynymAccount nymAccount; static const String routeName = "/paynymHome"; @@ -21,6 +34,8 @@ class PaynymHomeView extends StatefulWidget { } class _PaynymHomeViewState extends State { + bool showFollowing = false; + @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); @@ -40,14 +55,172 @@ class _PaynymHomeViewState extends State { style: STextStyles.navBarTitle(context), overflow: TextOverflow.ellipsis, ), + actions: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: AspectRatio( + aspectRatio: 1, + child: AppBarIconButton( + icon: SvgPicture.asset( + Assets.svg.circlePlusFilled, + width: 20, + height: 20, + color: Theme.of(context).extension()!.textDark, + ), + onPressed: () { + // todo add ? + }, + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: AspectRatio( + aspectRatio: 1, + child: AppBarIconButton( + icon: SvgPicture.asset( + Assets.svg.circleQuestion, + width: 20, + height: 20, + color: Theme.of(context).extension()!.textDark, + ), + onPressed: () { + // todo add ? + }, + ), + ), + ), + const SizedBox( + width: 4, + ), + ], ), body: SafeArea( child: Padding( padding: const EdgeInsets.all(16), child: Column( + crossAxisAlignment: CrossAxisAlignment.center, children: [ PayNymBot( - paymentCodeString: widget.paymentCodeString, + paymentCodeString: widget.nymAccount.codes.first.code, + ), + const SizedBox( + height: 10, + ), + Text( + widget.nymAccount.nymName, + style: STextStyles.desktopMenuItemSelected(context), + ), + const SizedBox( + height: 4, + ), + Text( + Format.shorten(widget.nymAccount.codes.first.code, 12, 5), + style: STextStyles.label(context), + ), + const SizedBox( + height: 11, + ), + Row( + children: [ + Expanded( + child: SecondaryButton( + label: "Copy", + buttonHeight: ButtonHeight.l, + iconSpacing: 4, + icon: CopyIcon( + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + // copy to clipboard + }, + ), + ), + const SizedBox( + width: 13, + ), + Expanded( + child: SecondaryButton( + label: "Share", + buttonHeight: ButtonHeight.l, + iconSpacing: 4, + icon: ShareIcon( + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + // copy to clipboard + }, + ), + ), + const SizedBox( + width: 13, + ), + Expanded( + child: SecondaryButton( + label: "Address", + buttonHeight: ButtonHeight.l, + iconSpacing: 4, + icon: QrCodeIcon( + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + // copy to clipboard + }, + ), + ), + ], + ), + const SizedBox( + height: 24, + ), + SizedBox( + height: 40, + child: Toggle( + onColor: Theme.of(context).extension()!.popupBG, + onText: "Following", + offColor: Theme.of(context) + .extension()! + .textFieldDefaultBG, + offText: "Followers", + isOn: showFollowing, + onValueChanged: (value) { + setState(() { + showFollowing = value; + }); + }, + decoration: BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + ), + ), + const SizedBox( + height: 16, + ), + RoundedWhiteContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Your PayNym contacts will appear here", + style: STextStyles.label(context), + ), + ], + ), ), ], ), @@ -61,12 +234,30 @@ class PayNymBot extends StatelessWidget { const PayNymBot({ Key? key, required this.paymentCodeString, + this.size = 60.0, }) : super(key: key); final String paymentCodeString; + final double size; @override Widget build(BuildContext context) { - return Image.network("https://paynym.is/$paymentCodeString/avatar"); + return ClipRRect( + borderRadius: BorderRadius.circular(size / 2), + child: SizedBox( + width: size, + height: size, + child: Image.network( + "https://paynym.is/$paymentCodeString/avatar", + loadingBuilder: (context, child, event) { + if (event == null) { + return child; + } else { + return const LoadingIndicator(); + } + }, + ), + ), + ); } } diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index 41b429311..af5b19f14 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -1,10 +1,21 @@ +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/paynym/paynym_claim_view.dart'; +import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; +import 'package:stackwallet/providers/global/paynym_api_provider.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:tuple/tuple.dart'; + +import '../../../widgets/loading_indicator.dart'; class WalletNavigationBar extends StatefulWidget { const WalletNavigationBar({ @@ -88,42 +99,84 @@ class _WalletNavigationBarState extends State { AnimatedOpacity( opacity: scale, duration: duration, - child: GestureDetector( - onTap: () { - setState(() { - scale = 0; - }); - Navigator.of(context).pushNamed( - PaynymClaimView.routeName, - arguments: widget.walletId, - ); - }, - child: Container( - padding: const EdgeInsets.all(16), - width: 146, - decoration: BoxDecoration( - color: - Theme.of(context).extension()!.popupBG, - boxShadow: [ - Theme.of(context) - .extension()! - .standardBoxShadow - ], - borderRadius: BorderRadius.circular( - widget.height / 2.0, + child: Consumer(builder: (context, ref, __) { + return GestureDetector( + onTap: () async { + setState(() { + scale = 0; + }); + unawaited( + showDialog( + context: context, + builder: (context) => const LoadingIndicator( + width: 100, + ), + ), + ); + + // todo make generic and not doge specific + final wallet = (ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet); + + final code = await wallet.getPaymentCode(); + + final account = await ref + .read(paynymAPIProvider) + .nym(code.toString()); + + if (mounted) { + Navigator.of(context).pop(); + + // check if account exists and for matching code to see if claimed + if (account != null && + account.codes + .where((e) => + e.code == code.toString() && e.claimed) + .isNotEmpty) { + await Navigator.of(context).pushNamed( + PaynymHomeView.routeName, + arguments: Tuple2( + widget.walletId, + account, + ), + ); + } else { + await Navigator.of(context).pushNamed( + PaynymClaimView.routeName, + arguments: widget.walletId, + ); + } + } + }, + child: Container( + padding: const EdgeInsets.all(16), + width: 146, + decoration: BoxDecoration( + color: + Theme.of(context).extension()!.popupBG, + boxShadow: [ + Theme.of(context) + .extension()! + .standardBoxShadow + ], + borderRadius: BorderRadius.circular( + widget.height / 2.0, + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Paynym", + style: STextStyles.w600_12(context), + ), + ], ), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Paynym", - style: STextStyles.w600_12(context), - ), - ], - ), - ), - ), + ); + }), ), const SizedBox( height: 8, diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 3da3a29d7..3b4c4e103 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -6,6 +6,7 @@ import 'package:stackwallet/models/contact_address_entry.dart'; import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/models/send_view_auto_fill_data.dart'; 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'; @@ -204,12 +205,12 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case PaynymHomeView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => PaynymHomeView( walletId: args.item1, - paymentCodeString: args.item2, + nymAccount: args.item2, ), settings: RouteSettings( name: settings.name, diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 99ee6ec32..366b2cf78 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -34,4 +34,7 @@ extension PayNym on DogecoinWallet { final signed = pair.sign(SHA256Digest().process(data)); return signed; } + + // Future> prepareNotificationTransaction( + // String targetPaymentCode) async {} } diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index b02c6584e..c85a2bf3c 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -76,6 +76,7 @@ class _SVG { String get circleSliders => "assets/svg/configuration.svg"; String get circlePlus => "assets/svg/plus-circle.svg"; + String get circlePlusFilled => "assets/svg/circle-plus-filled.svg"; String get framedGear => "assets/svg/framed-gear.svg"; String get framedAddressBook => "assets/svg/framed-address-book.svg"; String get circleNode => "assets/svg/node-circle.svg"; diff --git a/lib/utilities/format.dart b/lib/utilities/format.dart index 136ec5b95..a0a6613a7 100644 --- a/lib/utilities/format.dart +++ b/lib/utilities/format.dart @@ -8,6 +8,10 @@ import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; abstract class Format { + static String shorten(String value, int beginCount, int endCount) { + return "${value.substring(0, beginCount)}...${value.substring(value.length - endCount)}"; + } + static Decimal satoshisToAmount(int sats, {required Coin coin}) { return (Decimal.fromInt(sats) / Decimal.fromInt(Constants.satsPerCoin(coin))) diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_api.dart index e2ef33a96..65de910a6 100644 --- a/lib/utilities/paynym_api.dart +++ b/lib/utilities/paynym_api.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:stackwallet/models/paynym/created_paynym.dart'; +import 'package:stackwallet/models/paynym/paynym_account.dart'; class PaynymAPI { static const String baseURL = "https://paynym.is/api"; @@ -117,8 +118,9 @@ class PaynymAPI { // // // ------ - Future> token(String code) async { - return _post("/token", {"code": code}); + Future token(String code) async { + final map = await _post("/token", {"code": code}); + return map["token"] as String; } // ### `/api/v1/nym` @@ -172,8 +174,13 @@ class PaynymAPI { // | 404 | Nym not found | // | 400 | Bad request | - Future> nym(String code) async { - return _post("/nym", {"code": code}); + Future nym(String code) async { + final map = await _post("/nym", {"nym": code}); + try { + return PaynymAccount.fromMap(map); + } catch (_) { + return null; + } } // ## Authenticated Requests diff --git a/lib/widgets/desktop/secondary_button.dart b/lib/widgets/desktop/secondary_button.dart index 62bd900dd..5603815b4 100644 --- a/lib/widgets/desktop/secondary_button.dart +++ b/lib/widgets/desktop/secondary_button.dart @@ -16,6 +16,7 @@ class SecondaryButton extends StatelessWidget { this.onPressed, this.enabled = true, this.buttonHeight, + this.iconSpacing = 10, }) : super(key: key); final double? width; @@ -25,6 +26,7 @@ class SecondaryButton extends StatelessWidget { final bool enabled; final Widget? icon; final ButtonHeight? buttonHeight; + final double iconSpacing; TextStyle getStyle(bool isDesktop, BuildContext context) { if (isDesktop) { @@ -66,6 +68,16 @@ class SecondaryButton extends StatelessWidget { : STextStyles.desktopButtonSecondaryDisabled(context); } } else { + if (buttonHeight == ButtonHeight.l) { + return STextStyles.button(context).copyWith( + fontSize: 10, + color: enabled + ? Theme.of(context).extension()!.buttonTextSecondary + : Theme.of(context) + .extension()! + .buttonTextSecondaryDisabled, + ); + } return STextStyles.button(context).copyWith( color: enabled ? Theme.of(context).extension()!.buttonTextSecondary @@ -136,8 +148,8 @@ class SecondaryButton extends StatelessWidget { children: [ if (icon != null) icon!, if (icon != null && label != null) - const SizedBox( - width: 10, + SizedBox( + width: iconSpacing, ), if (label != null) Text( diff --git a/lib/widgets/icon_widgets/share_icon.dart b/lib/widgets/icon_widgets/share_icon.dart new file mode 100644 index 000000000..7a89dd829 --- /dev/null +++ b/lib/widgets/icon_widgets/share_icon.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; + +class ShareIcon extends StatelessWidget { + const ShareIcon({ + Key? key, + this.width = 18, + this.height = 18, + this.color, + }) : super(key: key); + + final double width; + final double height; + final Color? color; + + @override + Widget build(BuildContext context) { + return SvgPicture.asset( + Assets.svg.share, + width: width, + height: height, + color: color ?? Theme.of(context).extension()!.textDark3, + ); + } +} diff --git a/lib/widgets/loading_indicator.dart b/lib/widgets/loading_indicator.dart index de4ed464e..8725af439 100644 --- a/lib/widgets/loading_indicator.dart +++ b/lib/widgets/loading_indicator.dart @@ -1,6 +1,5 @@ -import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; - import 'package:stackwallet/utilities/assets.dart'; class LoadingIndicator extends StatelessWidget { @@ -15,13 +14,18 @@ class LoadingIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - width: width, - height: height, - child: Lottie.asset( - Assets.lottie.test2, - animate: true, - repeat: true, + return Container( + color: Colors.transparent, + child: Center( + child: SizedBox( + width: width, + height: height, + child: Lottie.asset( + Assets.lottie.test2, + animate: true, + repeat: true, + ), + ), ), ); } diff --git a/lib/widgets/toggle.dart b/lib/widgets/toggle.dart index 651f2b5e1..7d3135770 100644 --- a/lib/widgets/toggle.dart +++ b/lib/widgets/toggle.dart @@ -186,29 +186,31 @@ class ToggleState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SvgPicture.asset( - widget.onIcon ?? "", - width: 12, - height: 14, - color: isDesktop - ? !_isOn - ? Theme.of(context) - .extension()! - .accentColorBlue - : Theme.of(context) - .extension()! - .buttonTextSecondary - : !_isOn - ? Theme.of(context) - .extension()! - .textDark - : Theme.of(context) - .extension()! - .textSubtitle1, - ), - const SizedBox( - width: 5, - ), + if (widget.onIcon != null) + SvgPicture.asset( + widget.onIcon ?? "", + width: 12, + height: 14, + color: isDesktop + ? !_isOn + ? Theme.of(context) + .extension()! + .accentColorBlue + : Theme.of(context) + .extension()! + .buttonTextSecondary + : !_isOn + ? Theme.of(context) + .extension()! + .textDark + : Theme.of(context) + .extension()! + .textSubtitle1, + ), + if (widget.onIcon != null) + const SizedBox( + width: 5, + ), Text( widget.onText ?? "", style: isDesktop @@ -243,29 +245,31 @@ class ToggleState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SvgPicture.asset( - widget.offIcon ?? "", - width: 12, - height: 14, - color: isDesktop - ? _isOn - ? Theme.of(context) - .extension()! - .accentColorBlue - : Theme.of(context) - .extension()! - .buttonTextSecondary - : _isOn - ? Theme.of(context) - .extension()! - .textDark - : Theme.of(context) - .extension()! - .textSubtitle1, - ), - const SizedBox( - width: 5, - ), + if (widget.offIcon != null) + SvgPicture.asset( + widget.offIcon ?? "", + width: 12, + height: 14, + color: isDesktop + ? _isOn + ? Theme.of(context) + .extension()! + .accentColorBlue + : Theme.of(context) + .extension()! + .buttonTextSecondary + : _isOn + ? Theme.of(context) + .extension()! + .textDark + : Theme.of(context) + .extension()! + .textSubtitle1, + ), + if (widget.offIcon != null) + const SizedBox( + width: 5, + ), Text( widget.offText ?? "", style: isDesktop diff --git a/pubspec.yaml b/pubspec.yaml index af8e082e6..b5e85fb26 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -305,6 +305,7 @@ flutter: - assets/svg/keys.svg - assets/svg/arrow-down.svg - assets/svg/plus-circle.svg + - assets/svg/circle-plus-filled.svg - assets/svg/configuration.svg # coin icons - assets/svg/coin_icons/Bitcoin.svg From 66271a90189243cb0fcc462d8f48379065d5fa66 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 11:06:53 -0600 Subject: [PATCH 012/192] paynym qr popup --- lib/pages/paynym/dialogs/paynym_qr_popup.dart | 132 ++++++++++++++++++ lib/pages/paynym/paynym_home_view.dart | 9 +- lib/utilities/text_styles.dart | 23 +++ 3 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 lib/pages/paynym/dialogs/paynym_qr_popup.dart diff --git a/lib/pages/paynym/dialogs/paynym_qr_popup.dart b/lib/pages/paynym/dialogs/paynym_qr_popup.dart new file mode 100644 index 000000000..f4169556a --- /dev/null +++ b/lib/pages/paynym/dialogs/paynym_qr_popup.dart @@ -0,0 +1,132 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:qr_flutter/qr_flutter.dart'; +import 'package:stackwallet/models/paynym/paynym_account.dart'; +import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; + +import '../../../notifications/show_flush_bar.dart'; +import '../../../utilities/assets.dart'; + +class PaynymQrPopup extends StatelessWidget { + const PaynymQrPopup({ + Key? key, + required this.paynymAccount, + }) : super(key: key); + + final PaynymAccount paynymAccount; + + @override + Widget build(BuildContext context) { + return DesktopDialog( + maxWidth: MediaQuery.of(context).size.width - 32, + maxHeight: double.infinity, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 24, + top: 24, + right: 24, + bottom: 16, + ), + child: Row( + children: [ + PayNymBot( + paymentCodeString: paynymAccount.codes.first.code, + size: 32, + ), + const SizedBox( + width: 12, + ), + Text( + paynymAccount.nymName, + style: STextStyles.w600_12(context), + ), + ], + ), + ), + Container( + color: Theme.of(context).extension()!.backgroundAppBar, + height: 1, + ), + Padding( + padding: const EdgeInsets.only( + left: 24, + top: 16, + right: 24, + bottom: 24, + ), + child: Row( + children: [ + Expanded( + child: ConstrainedBox( + constraints: const BoxConstraints(minHeight: 107), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Your PayNym address", + style: STextStyles.infoSmall(context), + ), + const SizedBox( + height: 6, + ), + Text( + paynymAccount.codes.first.code, + style: STextStyles.infoSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + const SizedBox( + height: 6, + ), + BlueTextButton( + text: "Copy", + textSize: 10, + onTap: () async { + await Clipboard.setData( + ClipboardData( + text: paynymAccount.codes.first.code, + ), + ); + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: "Copied to clipboard", + iconAsset: Assets.svg.copy, + context: context, + ), + ); + }, + ), + ], + ), + ), + ), + const SizedBox( + width: 20, + ), + QrImage( + padding: const EdgeInsets.all(0), + size: 107, + data: paynymAccount.codes.first.code, + foregroundColor: + Theme.of(context).extension()!.textDark, + ), + ], + ), + ) + ], + ), + ); + } +} diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 4782e2491..76cfc591c 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -17,6 +17,8 @@ import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/toggle.dart'; +import 'dialogs/paynym_qr_popup.dart'; + class PaynymHomeView extends StatefulWidget { const PaynymHomeView({ Key? key, @@ -176,7 +178,12 @@ class _PaynymHomeViewState extends State { .textDark, ), onPressed: () { - // copy to clipboard + showDialog( + context: context, + builder: (context) => PaynymQrPopup( + paynymAccount: widget.nymAccount, + ), + ); }, ), ), diff --git a/lib/utilities/text_styles.dart b/lib/utilities/text_styles.dart index 42a0ba488..8afbf77dd 100644 --- a/lib/utilities/text_styles.dart +++ b/lib/utilities/text_styles.dart @@ -591,6 +591,29 @@ class STextStyles { } } + static TextStyle w500_12(BuildContext context) { + switch (_theme(context).themeType) { + case ThemeType.light: + return GoogleFonts.inter( + color: _theme(context).textDark, + fontWeight: FontWeight.w500, + fontSize: 12, + ); + case ThemeType.oceanBreeze: + return GoogleFonts.inter( + color: _theme(context).textDark, + fontWeight: FontWeight.w500, + fontSize: 12, + ); + case ThemeType.dark: + return GoogleFonts.inter( + color: _theme(context).textDark, + fontWeight: FontWeight.w500, + fontSize: 12, + ); + } + } + static TextStyle syncPercent(BuildContext context) { switch (_theme(context).themeType) { case ThemeType.light: From 6d75f01daec57e319389c05ed902bcd876471f22 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 11:08:14 -0600 Subject: [PATCH 013/192] copy code on paynym home screen --- lib/pages/paynym/paynym_home_view.dart | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 76cfc591c..6d9cba59f 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -1,6 +1,10 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; +import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/format.dart'; @@ -137,8 +141,20 @@ class _PaynymHomeViewState extends State { .extension()! .textDark, ), - onPressed: () { - // copy to clipboard + onPressed: () async { + await Clipboard.setData( + ClipboardData( + text: widget.nymAccount.codes.first.code, + ), + ); + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: "Copied to clipboard", + iconAsset: Assets.svg.copy, + context: context, + ), + ); }, ), ), From 27bb0cf1c925d1e6a805d2b6d39984a610c7e794 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 11:13:41 -0600 Subject: [PATCH 014/192] place holder featured paynyms --- lib/utilities/featured_paynyms.dart | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lib/utilities/featured_paynyms.dart diff --git a/lib/utilities/featured_paynyms.dart b/lib/utilities/featured_paynyms.dart new file mode 100644 index 000000000..87c3f462b --- /dev/null +++ b/lib/utilities/featured_paynyms.dart @@ -0,0 +1,7 @@ +abstract class FeaturedPaynyms { + // TODO: replace with actual values + static const String samouraiWalletDevFund = + "PM8TJYkuSdYXJnwDBq8ChfinfXv3srxhQrx3eoEwbSw51wMjdo9JJ2DsycwT3gt3zHQ7cV1grvabMmmf1Btj6fY7tgkgSz9B8MZuR3kjYfgMLMURJCXN"; + static const String stackWallet = + "PM8TJYkuSdYXJnwDBq8ChfinfXv3srxhQrx3eoEwbSw51wMjdo9JJ2DsycwT3gt3zHQ7cV1grvabMmmf1Btj6fY7tgkgSz9B8MZuR3kjYfgMLMURJCXN"; +} From e12074716647527801c2bc1c1acf9c8e7df44aaf Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 11:14:50 -0600 Subject: [PATCH 015/192] clean up imports --- lib/pages/paynym/dialogs/paynym_qr_popup.dart | 5 ++--- lib/pages/paynym/paynym_home_view.dart | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/pages/paynym/dialogs/paynym_qr_popup.dart b/lib/pages/paynym/dialogs/paynym_qr_popup.dart index f4169556a..3d4ef124f 100644 --- a/lib/pages/paynym/dialogs/paynym_qr_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_qr_popup.dart @@ -4,15 +4,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; +import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; +import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import '../../../notifications/show_flush_bar.dart'; -import '../../../utilities/assets.dart'; - class PaynymQrPopup extends StatelessWidget { const PaynymQrPopup({ Key? key, diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 6d9cba59f..01d547bf7 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/format.dart'; @@ -21,8 +22,6 @@ import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/toggle.dart'; -import 'dialogs/paynym_qr_popup.dart'; - class PaynymHomeView extends StatefulWidget { const PaynymHomeView({ Key? key, From 45754d1565b8feea98330ca38b0574a4fd8be8f5 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 11:18:00 -0600 Subject: [PATCH 016/192] refactor paynym bot image view into its own file --- lib/pages/paynym/dialogs/paynym_qr_popup.dart | 2 +- lib/pages/paynym/paynym_home_view.dart | 34 +----------------- lib/pages/paynym/subwidgets/paynym_bot.dart | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 lib/pages/paynym/subwidgets/paynym_bot.dart diff --git a/lib/pages/paynym/dialogs/paynym_qr_popup.dart b/lib/pages/paynym/dialogs/paynym_qr_popup.dart index 3d4ef124f..fefb8dd59 100644 --- a/lib/pages/paynym/dialogs/paynym_qr_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_qr_popup.dart @@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 01d547bf7..d3c3771ea 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -6,6 +6,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/format.dart'; @@ -18,7 +19,6 @@ import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/share_icon.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/toggle.dart'; @@ -251,35 +251,3 @@ class _PaynymHomeViewState extends State { ); } } - -class PayNymBot extends StatelessWidget { - const PayNymBot({ - Key? key, - required this.paymentCodeString, - this.size = 60.0, - }) : super(key: key); - - final String paymentCodeString; - final double size; - - @override - Widget build(BuildContext context) { - return ClipRRect( - borderRadius: BorderRadius.circular(size / 2), - child: SizedBox( - width: size, - height: size, - child: Image.network( - "https://paynym.is/$paymentCodeString/avatar", - loadingBuilder: (context, child, event) { - if (event == null) { - return child; - } else { - return const LoadingIndicator(); - } - }, - ), - ), - ); - } -} diff --git a/lib/pages/paynym/subwidgets/paynym_bot.dart b/lib/pages/paynym/subwidgets/paynym_bot.dart new file mode 100644 index 000000000..bdb909f9c --- /dev/null +++ b/lib/pages/paynym/subwidgets/paynym_bot.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; + +class PayNymBot extends StatelessWidget { + const PayNymBot({ + Key? key, + required this.paymentCodeString, + this.size = 60.0, + }) : super(key: key); + + final String paymentCodeString; + final double size; + + @override + Widget build(BuildContext context) { + return ClipRRect( + borderRadius: BorderRadius.circular(size / 2), + child: Stack( + children: [ + SizedBox( + width: size, + height: size, + child: const LoadingIndicator(), + ), + SizedBox( + width: size, + height: size, + child: Image.network( + "https://paynym.is/$paymentCodeString/avatar", + ), + ), + ], + ), + ); + } +} From 08ad23cc739f9adeaf786626df59a8330cc093bb Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 12:03:23 -0600 Subject: [PATCH 017/192] featured paynyms widget --- .../subwidgets/featured_paynyms_widget.dart | 81 +++++++++++++++++++ lib/utilities/featured_paynyms.dart | 5 ++ 2 files changed, 86 insertions(+) create mode 100644 lib/pages/paynym/subwidgets/featured_paynyms_widget.dart diff --git a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart new file mode 100644 index 000000000..a9dd34309 --- /dev/null +++ b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/utilities/featured_paynyms.dart'; +import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class FeaturedPaynymsWidget extends StatelessWidget { + const FeaturedPaynymsWidget({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final entries = FeaturedPaynyms.featured.entries.toList(growable: false); + + return RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: Column( + children: [ + for (int i = 0; i < entries.length; i++) + Column( + children: [ + if (i > 0) + Container( + color: Theme.of(context) + .extension()! + .backgroundAppBar, + height: 1, + ), + Padding( + padding: const EdgeInsets.all(12), + child: Row( + children: [ + PayNymBot( + size: 32, + paymentCodeString: entries[i].value, + ), + const SizedBox( + width: 12, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + entries[i].key, + style: STextStyles.w500_12(context), + ), + const SizedBox( + height: 2, + ), + Text( + Format.shorten(entries[i].value, 12, 5), + style: STextStyles.w500_12(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ), + ], + ), + ), + PrimaryButton( + width: 84, + buttonHeight: ButtonHeight.l, + label: "Follow", + onPressed: () { + // todo : follow + }, + ) + ], + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/utilities/featured_paynyms.dart b/lib/utilities/featured_paynyms.dart index 87c3f462b..5abff9f2a 100644 --- a/lib/utilities/featured_paynyms.dart +++ b/lib/utilities/featured_paynyms.dart @@ -4,4 +4,9 @@ abstract class FeaturedPaynyms { "PM8TJYkuSdYXJnwDBq8ChfinfXv3srxhQrx3eoEwbSw51wMjdo9JJ2DsycwT3gt3zHQ7cV1grvabMmmf1Btj6fY7tgkgSz9B8MZuR3kjYfgMLMURJCXN"; static const String stackWallet = "PM8TJYkuSdYXJnwDBq8ChfinfXv3srxhQrx3eoEwbSw51wMjdo9JJ2DsycwT3gt3zHQ7cV1grvabMmmf1Btj6fY7tgkgSz9B8MZuR3kjYfgMLMURJCXN"; + + static Map get featured => { + "Stack Wallet": stackWallet, + "Samourai Wallet Dev Fund": samouraiWalletDevFund, + }; } From 2297fbf0280e276a2dc21838d1d14a0d8a7da503 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 13:46:50 -0600 Subject: [PATCH 018/192] add (follow) new paynym view --- .../paynym/add_new_paynym_follow_view.dart | 306 ++++++++++++++++++ lib/pages/paynym/paynym_claim_view.dart | 1 + lib/pages/paynym/paynym_home_view.dart | 26 +- .../subwidgets/featured_paynyms_widget.dart | 51 +-- lib/pages/paynym/subwidgets/paynym_bot.dart | 23 +- lib/pages/paynym/subwidgets/paynym_card.dart | 70 ++++ lib/route_generator.dart | 16 + lib/utilities/paynym_api.dart | 9 +- lib/utilities/text_styles.dart | 23 ++ lib/widgets/desktop/primary_button.dart | 10 + 10 files changed, 460 insertions(+), 75 deletions(-) create mode 100644 lib/pages/paynym/add_new_paynym_follow_view.dart create mode 100644 lib/pages/paynym/subwidgets/paynym_card.dart diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart new file mode 100644 index 000000000..f6c3003f4 --- /dev/null +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -0,0 +1,306 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/models/paynym/paynym_account.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/featured_paynyms_widget.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; +import 'package:stackwallet/providers/global/paynym_api_provider.dart'; +import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.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_scaffold.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; +import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; +import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'package:stackwallet/widgets/stack_text_field.dart'; +import 'package:stackwallet/widgets/textfield_icon_button.dart'; + +class AddNewPaynymFollowView extends ConsumerStatefulWidget { + const AddNewPaynymFollowView({ + Key? key, + required this.walletId, + required this.nymAccount, + }) : super(key: key); + + final String walletId; + final PaynymAccount nymAccount; + + static const String routeName = "/addNewPaynymFollow"; + + @override + ConsumerState createState() => + _AddNewPaynymFollowViewState(); +} + +class _AddNewPaynymFollowViewState + extends ConsumerState { + late final TextEditingController _searchController; + late final FocusNode searchFieldFocusNode; + + String _searchString = ""; + + bool _didSearch = false; + PaynymAccount? _searchResult; + + Future _search() async { + _didSearch = true; + bool didPopLoading = false; + unawaited( + showDialog( + barrierDismissible: false, + context: context, + builder: (context) => const LoadingIndicator( + width: 200, + ), + ).then((_) => didPopLoading = true), + ); + + final paynymAccount = + await ref.read(paynymAPIProvider).nym(_searchString, true); + + if (mounted) { + if (!didPopLoading) { + Navigator.of(context).pop(); + } + + setState(() { + _searchResult = paynymAccount; + }); + } + } + + @override + void initState() { + _searchController = TextEditingController(); + searchFieldFocusNode = FocusNode(); + super.initState(); + } + + @override + void dispose() { + _searchController.dispose(); + searchFieldFocusNode.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + debugPrint("BUILD: $runtimeType"); + final isDesktop = Util.isDesktop; + + return MasterScaffold( + isDesktop: isDesktop, + appBar: AppBar( + leading: AppBarBackButton( + onPressed: () { + Navigator.of(context).pop(); + }, + ), + titleSpacing: 0, + title: Text( + "Add new", + style: STextStyles.navBarTitle(context), + overflow: TextOverflow.ellipsis, + ), + ), + body: ConditionalParent( + condition: !isDesktop, + builder: (child) => SafeArea( + child: LayoutBuilder( + builder: (context, constraints) => SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: constraints.maxHeight, + ), + child: IntrinsicHeight( + child: child, + ), + ), + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 10, + ), + Text( + "Featured PayNyms", + style: STextStyles.sectionLabelMedium12(context), + ), + const SizedBox( + height: 12, + ), + const FeaturedPaynymsWidget(), + const SizedBox( + height: 24, + ), + Text( + "Add new", + style: STextStyles.sectionLabelMedium12(context), + ), + const SizedBox( + height: 12, + ), + ClipRRect( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + child: TextField( + autocorrect: !isDesktop, + enableSuggestions: !isDesktop, + controller: _searchController, + focusNode: searchFieldFocusNode, + onChanged: (value) { + setState(() { + _searchString = value; + }); + }, + style: isDesktop + ? STextStyles.desktopTextExtraSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + height: 1.8, + ) + : STextStyles.field(context), + decoration: standardInputDecoration( + "Paste payment code", + searchFieldFocusNode, + context, + desktopMed: isDesktop, + ).copyWith( + suffixIcon: Padding( + padding: const EdgeInsets.only(right: 8), + child: UnconstrainedBox( + child: Row( + children: [ + _searchController.text.isNotEmpty + ? TextFieldIconButton( + child: const XIcon(), + onTap: () async { + _searchString = ""; + setState(() { + _searchController.text = ""; + }); + }, + ) + : TextFieldIconButton( + key: const Key( + "paynymPasteAddressFieldButtonKey"), + onTap: () async { + final ClipboardData? data = + await Clipboard.getData( + Clipboard.kTextPlain); + if (data?.text != null && + data!.text!.isNotEmpty) { + String content = data.text!.trim(); + if (content.contains("\n")) { + content = content.substring( + 0, + content.indexOf( + "\n", + ), + ); + } + + _searchString = content; + setState(() { + _searchController.text = content; + _searchController.selection = + TextSelection.collapsed( + offset: content.length, + ); + }); + } + }, + child: const ClipboardIcon(), + ), + TextFieldIconButton( + key: const Key("paynymScanQrButtonKey"), + onTap: () async { + try { + if (FocusScope.of(context).hasFocus) { + FocusScope.of(context).unfocus(); + await Future.delayed( + const Duration(milliseconds: 75)); + } + + final qrResult = + await const BarcodeScannerWrapper() + .scan(); + + final pCodeString = qrResult.rawContent; + + _searchString = pCodeString; + + setState(() { + _searchController.text = pCodeString; + _searchController.selection = + TextSelection.collapsed( + offset: pCodeString.length, + ); + }); + } catch (_) { + // scan failed + } + }, + child: const QrCodeIcon(), + ) + ], + ), + ), + ), + ), + ), + ), + const SizedBox( + height: 12, + ), + SecondaryButton( + label: "Search", + onPressed: _search, + ), + if (_didSearch) + const SizedBox( + height: 20, + ), + if (_didSearch && _searchResult == null) + RoundedWhiteContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Nothing found. Please check the payment code.", + style: STextStyles.label(context), + ), + ], + ), + ), + if (_didSearch && _searchResult != null) + RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: PaynymCard( + label: _searchResult!.nymName, + paymentCodeString: _searchResult!.codes.first.code, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index b9b5ebd95..aa79e57b9 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -87,6 +87,7 @@ class _PaynymClaimViewState extends ConsumerState { unawaited( showDialog( context: context, + barrierDismissible: false, builder: (context) => const ClaimingPaynymDialog(), ).then((value) => shouldCancel = value == true), ); diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index d3c3771ea..6d4713227 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -21,16 +22,17 @@ import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/share_icon.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/toggle.dart'; +import 'package:tuple/tuple.dart'; class PaynymHomeView extends StatefulWidget { const PaynymHomeView({ Key? key, required this.walletId, - required this.nymAccount, + required this.paynymAccount, }) : super(key: key); final String walletId; - final PaynymAccount nymAccount; + final PaynymAccount paynymAccount; static const String routeName = "/paynymHome"; @@ -73,7 +75,13 @@ class _PaynymHomeViewState extends State { color: Theme.of(context).extension()!.textDark, ), onPressed: () { - // todo add ? + Navigator.of(context).pushNamed( + AddNewPaynymFollowView.routeName, + arguments: Tuple2( + widget.walletId, + widget.paynymAccount, + ), + ); }, ), ), @@ -90,7 +98,7 @@ class _PaynymHomeViewState extends State { color: Theme.of(context).extension()!.textDark, ), onPressed: () { - // todo add ? + // todo info ? }, ), ), @@ -107,20 +115,20 @@ class _PaynymHomeViewState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ PayNymBot( - paymentCodeString: widget.nymAccount.codes.first.code, + paymentCodeString: widget.paynymAccount.codes.first.code, ), const SizedBox( height: 10, ), Text( - widget.nymAccount.nymName, + widget.paynymAccount.nymName, style: STextStyles.desktopMenuItemSelected(context), ), const SizedBox( height: 4, ), Text( - Format.shorten(widget.nymAccount.codes.first.code, 12, 5), + Format.shorten(widget.paynymAccount.codes.first.code, 12, 5), style: STextStyles.label(context), ), const SizedBox( @@ -143,7 +151,7 @@ class _PaynymHomeViewState extends State { onPressed: () async { await Clipboard.setData( ClipboardData( - text: widget.nymAccount.codes.first.code, + text: widget.paynymAccount.codes.first.code, ), ); unawaited( @@ -196,7 +204,7 @@ class _PaynymHomeViewState extends State { showDialog( context: context, builder: (context) => PaynymQrPopup( - paynymAccount: widget.nymAccount, + paynymAccount: widget.paynymAccount, ), ); }, diff --git a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart index a9dd34309..ab63f8411 100644 --- a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart +++ b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart @@ -1,10 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; import 'package:stackwallet/utilities/featured_paynyms.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; class FeaturedPaynymsWidget extends StatelessWidget { @@ -28,49 +25,9 @@ class FeaturedPaynymsWidget extends StatelessWidget { .backgroundAppBar, height: 1, ), - Padding( - padding: const EdgeInsets.all(12), - child: Row( - children: [ - PayNymBot( - size: 32, - paymentCodeString: entries[i].value, - ), - const SizedBox( - width: 12, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - entries[i].key, - style: STextStyles.w500_12(context), - ), - const SizedBox( - height: 2, - ), - Text( - Format.shorten(entries[i].value, 12, 5), - style: STextStyles.w500_12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ), - ), - ], - ), - ), - PrimaryButton( - width: 84, - buttonHeight: ButtonHeight.l, - label: "Follow", - onPressed: () { - // todo : follow - }, - ) - ], - ), + PaynymCard( + label: entries[i].key, + paymentCodeString: entries[i].value, ), ], ), diff --git a/lib/pages/paynym/subwidgets/paynym_bot.dart b/lib/pages/paynym/subwidgets/paynym_bot.dart index bdb909f9c..6c6c4ae97 100644 --- a/lib/pages/paynym/subwidgets/paynym_bot.dart +++ b/lib/pages/paynym/subwidgets/paynym_bot.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; class PayNymBot extends StatelessWidget { const PayNymBot({ @@ -15,21 +14,13 @@ class PayNymBot extends StatelessWidget { Widget build(BuildContext context) { return ClipRRect( borderRadius: BorderRadius.circular(size / 2), - child: Stack( - children: [ - SizedBox( - width: size, - height: size, - child: const LoadingIndicator(), - ), - SizedBox( - width: size, - height: size, - child: Image.network( - "https://paynym.is/$paymentCodeString/avatar", - ), - ), - ], + child: SizedBox( + width: size, + height: size, + child: Image.network( + "https://paynym.is/$paymentCodeString/avatar", + // todo: loading indicator that doesn't lag + ), ), ); } diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart new file mode 100644 index 000000000..cc3e60524 --- /dev/null +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; + +class PaynymCard extends StatefulWidget { + const PaynymCard({ + Key? key, + required this.label, + required this.paymentCodeString, + }) : super(key: key); + + final String label; + final String paymentCodeString; + + @override + State createState() => _PaynymCardState(); +} + +class _PaynymCardState extends State { + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(12), + child: Row( + children: [ + PayNymBot( + size: 32, + paymentCodeString: widget.paymentCodeString, + ), + const SizedBox( + width: 12, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.label, + style: STextStyles.w500_12(context), + ), + const SizedBox( + height: 2, + ), + Text( + Format.shorten(widget.paymentCodeString, 12, 5), + style: STextStyles.w500_12(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ), + ], + ), + ), + PrimaryButton( + width: 84, + buttonHeight: ButtonHeight.l, + label: "Follow", + onPressed: () { + // todo : follow + }, + ) + ], + ), + ); + } +} diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 3b4c4e103..30a7313b6 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -37,6 +37,7 @@ import 'package:stackwallet/pages/home_view/home_view.dart'; import 'package:stackwallet/pages/intro_view.dart'; import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; import 'package:stackwallet/pages/notification_views/notifications_view.dart'; +import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; @@ -209,6 +210,21 @@ class RouteGenerator { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => PaynymHomeView( + walletId: args.item1, + paynymAccount: args.item2, + ), + settings: RouteSettings( + name: settings.name, + ), + ); + } + return _routeError("${settings.name} invalid args: ${args.toString()}"); + + case AddNewPaynymFollowView.routeName: + if (args is Tuple2) { + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => AddNewPaynymFollowView( walletId: args.item1, nymAccount: args.item2, ), diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_api.dart index 65de910a6..c8db9f4f4 100644 --- a/lib/utilities/paynym_api.dart +++ b/lib/utilities/paynym_api.dart @@ -173,10 +173,13 @@ class PaynymAPI { // | 200 | Nym found and returned | // | 404 | Nym not found | // | 400 | Bad request | - - Future nym(String code) async { - final map = await _post("/nym", {"nym": code}); + Future nym(String code, [bool compact = false]) async { + final Map requestBody = {"nym": code}; + if (compact) { + requestBody["compact"] = true; + } try { + final map = await _post("/nym", requestBody); return PaynymAccount.fromMap(map); } catch (_) { return null; diff --git a/lib/utilities/text_styles.dart b/lib/utilities/text_styles.dart index 8afbf77dd..51ade8153 100644 --- a/lib/utilities/text_styles.dart +++ b/lib/utilities/text_styles.dart @@ -7,6 +7,29 @@ class STextStyles { static StackColors _theme(BuildContext context) => Theme.of(context).extension()!; + static TextStyle sectionLabelMedium12(BuildContext context) { + switch (_theme(context).themeType) { + case ThemeType.light: + return GoogleFonts.inter( + color: _theme(context).textDark3, + fontWeight: FontWeight.w500, + fontSize: 12, + ); + case ThemeType.oceanBreeze: + return GoogleFonts.inter( + color: _theme(context).textDark3, + fontWeight: FontWeight.w500, + fontSize: 12, + ); + case ThemeType.dark: + return GoogleFonts.inter( + color: _theme(context).textDark3, + fontWeight: FontWeight.w500, + fontSize: 12, + ); + } + } + static TextStyle pageTitleH1(BuildContext context) { switch (_theme(context).themeType) { case ThemeType.light: diff --git a/lib/widgets/desktop/primary_button.dart b/lib/widgets/desktop/primary_button.dart index 9441168e7..de8351122 100644 --- a/lib/widgets/desktop/primary_button.dart +++ b/lib/widgets/desktop/primary_button.dart @@ -63,6 +63,16 @@ class PrimaryButton extends StatelessWidget { : STextStyles.desktopButtonDisabled(context); } } else { + if (buttonHeight == ButtonHeight.l) { + return STextStyles.button(context).copyWith( + fontSize: 10, + color: enabled + ? Theme.of(context).extension()!.buttonTextPrimary + : Theme.of(context) + .extension()! + .buttonTextPrimaryDisabled, + ); + } return STextStyles.button(context).copyWith( color: enabled ? Theme.of(context).extension()!.buttonTextPrimary From 8af4c407e6158ef4dfd4364e5f5ae579cb2103f5 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 16:44:23 -0600 Subject: [PATCH 019/192] add loading bot nym bot network image --- lib/pages/paynym/subwidgets/paynym_bot.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pages/paynym/subwidgets/paynym_bot.dart b/lib/pages/paynym/subwidgets/paynym_bot.dart index 6c6c4ae97..40dadf812 100644 --- a/lib/pages/paynym/subwidgets/paynym_bot.dart +++ b/lib/pages/paynym/subwidgets/paynym_bot.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; class PayNymBot extends StatelessWidget { const PayNymBot({ @@ -19,7 +20,12 @@ class PayNymBot extends StatelessWidget { height: size, child: Image.network( "https://paynym.is/$paymentCodeString/avatar", - // todo: loading indicator that doesn't lag + loadingBuilder: (context, child, loadingProgress) => + loadingProgress == null + ? child + : const Center( + child: LoadingIndicator(), + ), ), ), ); From 0711bd03cf88417b3aebf1261417090c43d550bd Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 16:44:38 -0600 Subject: [PATCH 020/192] paynym api debug logs --- lib/utilities/paynym_api.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_api.dart index c8db9f4f4..2c31f9c49 100644 --- a/lib/utilities/paynym_api.dart +++ b/lib/utilities/paynym_api.dart @@ -1,5 +1,6 @@ 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'; @@ -25,7 +26,8 @@ class PaynymAPI { body: jsonEncode(body), ); - // print("response code: ${response.statusCode}"); + debugPrint("Paynym response code: ${response.statusCode}"); + debugPrint("Paynym response body: ${response.body}"); return jsonDecode(response.body) as Map; } From 7631d3f3c651ec8f08aae4b27610585ffd736ab7 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 17:02:14 -0600 Subject: [PATCH 021/192] WIP follow/unfollow --- lib/models/paynym/created_paynym.dart | 6 +- lib/models/paynym/paynym_account.dart | 24 +- .../paynym/add_new_paynym_follow_view.dart | 10 +- lib/pages/paynym/paynym_claim_view.dart | 51 ++-- lib/pages/paynym/paynym_home_view.dart | 79 ++++-- .../subwidgets/featured_paynyms_widget.dart | 8 +- lib/pages/paynym/subwidgets/paynym_card.dart | 237 +++++++++++++++++- .../sub_widgets/wallet_navigation_bar.dart | 12 +- lib/route_generator.dart | 11 +- lib/services/coins/coin_paynym_extension.dart | 10 + lib/widgets/desktop/primary_button.dart | 6 +- 11 files changed, 377 insertions(+), 77 deletions(-) diff --git a/lib/models/paynym/created_paynym.dart b/lib/models/paynym/created_paynym.dart index 4efdcb85b..8716d7e10 100644 --- a/lib/models/paynym/created_paynym.dart +++ b/lib/models/paynym/created_paynym.dart @@ -1,6 +1,6 @@ class CreatedPaynym { final bool claimed; - final String nymAvatar; + final String? nymAvatar; final String? nymId; final String? nymName; final String? token; @@ -15,8 +15,8 @@ class CreatedPaynym { CreatedPaynym.fromMap(Map map) : claimed = map["claimed"] as bool, - nymAvatar = map["nymAvatar"] as String, - nymId = map["nymId"] as String?, + nymAvatar = map["nymAvatar"] as String?, + nymId = map["nymID"] as String?, nymName = map["nymName"] as String?, token = map["token"] as String?; diff --git a/lib/models/paynym/paynym_account.dart b/lib/models/paynym/paynym_account.dart index 08438a6b7..b2c989014 100644 --- a/lib/models/paynym/paynym_account.dart +++ b/lib/models/paynym/paynym_account.dart @@ -26,19 +26,27 @@ class PaynymAccount { codes = (map["codes"] as List) .map((e) => PaynymCode.fromMap(Map.from(e as Map))) .toList(), - followers = (map["followers"] as List) - .map((e) => e["nymId"] as String) - .toList(), - following = (map["following"] as List) - .map((e) => e["nymId"] as String) - .toList(); + followers = [], + following = [] { + final f1 = map["followers"] as List; + for (final item in f1) { + followers.add(Map.from(item as Map)["nymId"] as String); + } + + final f2 = map["following"] as List; + for (final item in f2) { + final nymId = Map.from(item as Map)["nymId"] as String; + print(nymId + "DDDDDDDDDDDDD"); + following.add(nymId); + } + } Map toMap() => { "nymID": nymID, "nymName": nymName, "codes": codes.map((e) => e.toMap()), - "followers": followers.map((e) => {"nymId": e}), - "following": followers.map((e) => {"nymId": e}), + "followers": followers.map((e) => {"nymId": e}).toList(), + "following": followers.map((e) => {"nymId": e}).toList(), }; @override diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index f6c3003f4..4382c9f7f 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -28,11 +28,9 @@ class AddNewPaynymFollowView extends ConsumerStatefulWidget { const AddNewPaynymFollowView({ Key? key, required this.walletId, - required this.nymAccount, }) : super(key: key); final String walletId; - final PaynymAccount nymAccount; static const String routeName = "/addNewPaynymFollow"; @@ -64,8 +62,7 @@ class _AddNewPaynymFollowViewState ).then((_) => didPopLoading = true), ); - final paynymAccount = - await ref.read(paynymAPIProvider).nym(_searchString, true); + final paynymAccount = await ref.read(paynymAPIProvider).nym(_searchString); if (mounted) { if (!didPopLoading) { @@ -143,7 +140,9 @@ class _AddNewPaynymFollowViewState const SizedBox( height: 12, ), - const FeaturedPaynymsWidget(), + FeaturedPaynymsWidget( + walletId: widget.walletId, + ), const SizedBox( height: 24, ), @@ -295,6 +294,7 @@ class _AddNewPaynymFollowViewState child: PaynymCard( label: _searchResult!.nymName, paymentCodeString: _searchResult!.codes.first.code, + walletId: widget.walletId, ), ), ], diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index aa79e57b9..c49992576 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -1,15 +1,15 @@ import 'dart:async'; -import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages/paynym/dialogs/claiming_paynym_dialog.dart'; +import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; +import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/providers/global/paynym_api_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -106,39 +106,50 @@ class _PaynymClaimViewState extends ConsumerState { .read(paynymAPIProvider) .create(pCode.toString()); + debugPrint("created:$created"); + if (created.claimed) { // payment code already claimed debugPrint("pcode already claimed!!"); + if (mounted) { + Navigator.of(context).popUntil( + ModalRoute.withName( + WalletView.routeName, + ), + ); + } return; } - String token; - - if (created.token == null) { - // payment code already in db - // so we need to fetch a token - - token = await ref - .read(paynymAPIProvider) - .token(pCode.toString()); - } else { - token = created.token!; - } + final token = + await ref.read(paynymAPIProvider).token(pCode.toString()); // sign token with notification private key - final signatureBytes = await wallet.signWithNotificationKey( - Uint8List.fromList(token.codeUnits)); - final signature = Format.uint8listToString(signatureBytes); + final signature = + await wallet.signStringWithNotificationKey(token); // claim paynym account final claim = await ref.read(paynymAPIProvider).claim(token, signature); if (claim["claimed"] == pCode.toString()) { - // mark claim successful - } + final account = + await ref.read(paynymAPIProvider).nym(pCode.toString()); - if (mounted && !shouldCancel) { + ref.read(myPaynymAccountStateProvider.state).state = + account!; + if (mounted) { + Navigator.of(context).popUntil( + ModalRoute.withName( + WalletView.routeName, + ), + ); + await Navigator.of(context).pushNamed( + PaynymHomeView.routeName, + arguments: widget.walletId, + ); + } + } else if (mounted && !shouldCancel) { Navigator.of(context).pop(); } }, diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 6d4713227..c633c0aa6 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; @@ -22,26 +23,35 @@ import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/share_icon.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/toggle.dart'; -import 'package:tuple/tuple.dart'; -class PaynymHomeView extends StatefulWidget { +final myPaynymAccountStateProvider = + StateProvider((ref) => null); + +class PaynymHomeView extends ConsumerStatefulWidget { const PaynymHomeView({ Key? key, required this.walletId, - required this.paynymAccount, }) : super(key: key); final String walletId; - final PaynymAccount paynymAccount; static const String routeName = "/paynymHome"; @override - State createState() => _PaynymHomeViewState(); + ConsumerState createState() => _PaynymHomeViewState(); } -class _PaynymHomeViewState extends State { +class _PaynymHomeViewState extends ConsumerState { bool showFollowing = false; + int secretCount = 0; + Timer? timer; + + @override + void dispose() { + timer?.cancel(); + timer = null; + super.dispose(); + } @override Widget build(BuildContext context) { @@ -77,10 +87,7 @@ class _PaynymHomeViewState extends State { onPressed: () { Navigator.of(context).pushNamed( AddNewPaynymFollowView.routeName, - arguments: Tuple2( - widget.walletId, - widget.paynymAccount, - ), + arguments: widget.walletId, ); }, ), @@ -114,21 +121,54 @@ class _PaynymHomeViewState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - PayNymBot( - paymentCodeString: widget.paynymAccount.codes.first.code, + GestureDetector( + onTap: () { + secretCount++; + if (secretCount > 5) { + debugPrint( + "My Account: ${ref.read(myPaynymAccountStateProvider.state).state}"); + debugPrint( + "My Account: ${ref.read(myPaynymAccountStateProvider.state).state!.following}"); + secretCount = 0; + } + + timer ??= Timer( + const Duration(milliseconds: 1500), + () { + secretCount = 0; + timer = null; + }, + ); + }, + child: PayNymBot( + paymentCodeString: ref + .watch(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + ), ), const SizedBox( height: 10, ), Text( - widget.paynymAccount.nymName, + ref.watch(myPaynymAccountStateProvider.state).state!.nymName, style: STextStyles.desktopMenuItemSelected(context), ), const SizedBox( height: 4, ), Text( - Format.shorten(widget.paynymAccount.codes.first.code, 12, 5), + Format.shorten( + ref + .watch(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + 12, + 5), style: STextStyles.label(context), ), const SizedBox( @@ -151,7 +191,12 @@ class _PaynymHomeViewState extends State { onPressed: () async { await Clipboard.setData( ClipboardData( - text: widget.paynymAccount.codes.first.code, + text: ref + .read(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, ), ); unawaited( @@ -204,7 +249,9 @@ class _PaynymHomeViewState extends State { showDialog( context: context, builder: (context) => PaynymQrPopup( - paynymAccount: widget.paynymAccount, + paynymAccount: ref + .read(myPaynymAccountStateProvider.state) + .state!, ), ); }, diff --git a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart index ab63f8411..f9457374a 100644 --- a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart +++ b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart @@ -5,7 +5,12 @@ import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; class FeaturedPaynymsWidget extends StatelessWidget { - const FeaturedPaynymsWidget({Key? key}) : super(key: key); + const FeaturedPaynymsWidget({ + Key? key, + required this.walletId, + }) : super(key: key); + + final String walletId; @override Widget build(BuildContext context) { @@ -26,6 +31,7 @@ class FeaturedPaynymsWidget extends StatelessWidget { height: 1, ), PaynymCard( + walletId: walletId, label: entries[i].key, paymentCodeString: entries[i].value, ), diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index cc3e60524..6dd00c0ed 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -1,17 +1,29 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/providers/global/paynym_api_provider.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; class PaynymCard extends StatefulWidget { const PaynymCard({ Key? key, + required this.walletId, required this.label, required this.paymentCodeString, }) : super(key: key); + final String walletId; final String label; final String paymentCodeString; @@ -55,16 +67,225 @@ class _PaynymCardState extends State { ], ), ), - PrimaryButton( - width: 84, - buttonHeight: ButtonHeight.l, - label: "Follow", - onPressed: () { - // todo : follow - }, - ) + PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: widget.paymentCodeString, + ), + // PrimaryButton( + // width: 84, + // buttonHeight: ButtonHeight.l, + // label: "Follow", + // onPressed: () { + // // todo : follow + // }, + // ) ], ), ); } } + +class PaynymFollowToggleButton extends ConsumerStatefulWidget { + const PaynymFollowToggleButton({ + Key? key, + required this.walletId, + required this.paymentCodeStringToFollow, + }) : super(key: key); + + final String walletId; + final String paymentCodeStringToFollow; + + @override + ConsumerState createState() => + _PaynymFollowToggleButtonState(); +} + +class _PaynymFollowToggleButtonState + extends ConsumerState { + Future follow() async { + bool loadingPopped = false; + unawaited( + showDialog( + context: context, + builder: (context) => const LoadingIndicator( + width: 200, + ), + ).then( + (_) => loadingPopped = true, + ), + ); + + final wallet = ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; + + final followedAccount = await ref + .read(paynymAPIProvider) + .nym(widget.paymentCodeStringToFollow, true); + await Future.delayed(const Duration(milliseconds: 100)); + + final myPCode = await wallet.getPaymentCode(); + await Future.delayed(const Duration(milliseconds: 100)); + final token = await ref.read(paynymAPIProvider).token(myPCode.toString()); + + await Future.delayed(const Duration(milliseconds: 100)); + + // sign token with notification private key + final signature = await wallet.signStringWithNotificationKey(token); + await Future.delayed(const Duration(milliseconds: 100)); + + final result = await ref + .read(paynymAPIProvider) + .follow(token, signature, followedAccount!.codes.first.code); + await Future.delayed(const Duration(milliseconds: 100)); + + print("Follow result: $result"); + + if (result["following"] == followedAccount.nymID) { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "You are following ${followedAccount.nymName}", + context: context, + ), + ); + ref + .read(myPaynymAccountStateProvider.state) + .state! + .following + .add(followedAccount.codes.first.code); + + setState(() { + isFollowing = true; + }); + + return true; + } else { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Failed to follow ${followedAccount.nymName}", + context: context, + ), + ); + + return false; + } + } + + Future unfollow() async { + bool loadingPopped = false; + unawaited( + showDialog( + context: context, + builder: (context) => const LoadingIndicator( + width: 200, + ), + ).then( + (_) => loadingPopped = true, + ), + ); + + final wallet = ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; + + final followedAccount = await ref + .read(paynymAPIProvider) + .nym(widget.paymentCodeStringToFollow, true); + + final myPCode = await wallet.getPaymentCode(); + final token = await ref.read(paynymAPIProvider).token(myPCode.toString()); + + // sign token with notification private key + final signature = await wallet.signStringWithNotificationKey(token); + + final result = await ref + .read(paynymAPIProvider) + .unfollow(token, signature, followedAccount!.codes.first.code); + + print("Unfollow result: $result"); + + if (result["unfollowing"] == followedAccount.nymID) { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "You have unfollowed ${followedAccount.nymName}", + context: context, + ), + ); + ref + .read(myPaynymAccountStateProvider.state) + .state! + .following + .remove(followedAccount.codes.first.code); + + setState(() { + isFollowing = false; + }); + + return true; + } else { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Failed to unfollow ${followedAccount.nymName}", + context: context, + ), + ); + + return false; + } + } + + bool _lock = false; + late bool isFollowing; + + @override + void initState() { + isFollowing = ref + .read(myPaynymAccountStateProvider.state) + .state! + .following + .contains(widget.paymentCodeStringToFollow); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return PrimaryButton( + width: 84, + buttonHeight: ButtonHeight.l, + label: isFollowing ? "Unfollow" : "Follow", + onPressed: () async { + if (!_lock) { + _lock = true; + if (isFollowing) { + await unfollow(); + } else { + await follow(); + } + _lock = false; + } + }, + ); + } +} diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index af5b19f14..596968c68 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -13,9 +13,7 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -import 'package:tuple/tuple.dart'; - -import '../../../widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; class WalletNavigationBar extends StatefulWidget { const WalletNavigationBar({ @@ -135,12 +133,12 @@ class _WalletNavigationBarState extends State { .where((e) => e.code == code.toString() && e.claimed) .isNotEmpty) { + ref.read(myPaynymAccountStateProvider.state).state = + account; + await Navigator.of(context).pushNamed( PaynymHomeView.routeName, - arguments: Tuple2( - widget.walletId, - account, - ), + arguments: widget.walletId, ); } else { await Navigator.of(context).pushNamed( diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 30a7313b6..203edef4a 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -6,7 +6,6 @@ import 'package:stackwallet/models/contact_address_entry.dart'; import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/models/send_view_auto_fill_data.dart'; 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'; @@ -206,12 +205,11 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case PaynymHomeView.routeName: - if (args is Tuple2) { + if (args is String) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => PaynymHomeView( - walletId: args.item1, - paynymAccount: args.item2, + walletId: args, ), settings: RouteSettings( name: settings.name, @@ -221,12 +219,11 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case AddNewPaynymFollowView.routeName: - if (args is Tuple2) { + if (args is String) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => AddNewPaynymFollowView( - walletId: args.item1, - nymAccount: args.item2, + walletId: args, ), settings: RouteSettings( name: settings.name, diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 366b2cf78..5b6082d75 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -5,6 +5,7 @@ import 'package:bitcoindart/bitcoindart.dart'; import 'package:pointycastle/digests/sha256.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; +import 'package:stackwallet/utilities/format.dart'; extension PayNym on DogecoinWallet { // fetch or generate this wallet's bip47 payment code @@ -35,6 +36,15 @@ extension PayNym on DogecoinWallet { return signed; } + Future signStringWithNotificationKey(String data) async { + final bytes = + await signWithNotificationKey(Uint8List.fromList(data.codeUnits)); + return Format.uint8listToString(bytes); + // final bytes = + // await signWithNotificationKey(Uint8List.fromList(utf8.encode(data))); + // return Format.uint8listToString(bytes); + } + // Future> prepareNotificationTransaction( // String targetPaymentCode) async {} } diff --git a/lib/widgets/desktop/primary_button.dart b/lib/widgets/desktop/primary_button.dart index de8351122..95c28696e 100644 --- a/lib/widgets/desktop/primary_button.dart +++ b/lib/widgets/desktop/primary_button.dart @@ -16,6 +16,7 @@ class PrimaryButton extends StatelessWidget { this.onPressed, this.enabled = true, this.buttonHeight, + this.iconSpacing = 10, }) : super(key: key); final double? width; @@ -25,6 +26,7 @@ class PrimaryButton extends StatelessWidget { final bool enabled; final Widget? icon; final ButtonHeight? buttonHeight; + final double? iconSpacing; TextStyle getStyle(bool isDesktop, BuildContext context) { if (isDesktop) { @@ -143,8 +145,8 @@ class PrimaryButton extends StatelessWidget { children: [ if (icon != null) icon!, if (icon != null && label != null) - const SizedBox( - width: 10, + SizedBox( + width: iconSpacing, ), if (label != null) Text( From b11bd0c20ca8fa6c7bc59c14bda4f1d1cdf9693b Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 17:24:08 -0600 Subject: [PATCH 022/192] add follower/following entity --- lib/models/paynym/paynym_account.dart | 31 ++++++++----------- lib/models/paynym/paynym_account_lite.dart | 31 +++++++++++++++++++ lib/pages/paynym/subwidgets/paynym_card.dart | 19 +++++++----- .../sub_widgets/wallet_navigation_bar.dart | 12 ++++--- 4 files changed, 63 insertions(+), 30 deletions(-) create mode 100644 lib/models/paynym/paynym_account_lite.dart diff --git a/lib/models/paynym/paynym_account.dart b/lib/models/paynym/paynym_account.dart index b2c989014..06a87ce7b 100644 --- a/lib/models/paynym/paynym_account.dart +++ b/lib/models/paynym/paynym_account.dart @@ -1,3 +1,4 @@ +import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/models/paynym/paynym_code.dart'; class PaynymAccount { @@ -7,10 +8,10 @@ class PaynymAccount { final List codes; /// list of nymId - final List followers; + final List followers; /// list of nymId - final List following; + final List following; PaynymAccount( this.nymID, @@ -26,27 +27,21 @@ class PaynymAccount { codes = (map["codes"] as List) .map((e) => PaynymCode.fromMap(Map.from(e as Map))) .toList(), - followers = [], - following = [] { - final f1 = map["followers"] as List; - for (final item in f1) { - followers.add(Map.from(item as Map)["nymId"] as String); - } - - final f2 = map["following"] as List; - for (final item in f2) { - final nymId = Map.from(item as Map)["nymId"] as String; - print(nymId + "DDDDDDDDDDDDD"); - following.add(nymId); - } - } + followers = (map["followers"] as List) + .map((e) => + PaynymAccountLite.fromMap(Map.from(e as Map))) + .toList(), + following = (map["following"] as List) + .map((e) => + PaynymAccountLite.fromMap(Map.from(e as Map))) + .toList(); Map toMap() => { "nymID": nymID, "nymName": nymName, "codes": codes.map((e) => e.toMap()), - "followers": followers.map((e) => {"nymId": e}).toList(), - "following": followers.map((e) => {"nymId": e}).toList(), + "followers": followers.map((e) => e.toMap()), + "following": followers.map((e) => e.toMap()), }; @override diff --git a/lib/models/paynym/paynym_account_lite.dart b/lib/models/paynym/paynym_account_lite.dart new file mode 100644 index 000000000..e1510febc --- /dev/null +++ b/lib/models/paynym/paynym_account_lite.dart @@ -0,0 +1,31 @@ +class PaynymAccountLite { + final String nymId; + final String nymName; + final String code; + final bool segwit; + + PaynymAccountLite( + this.nymId, + this.nymName, + this.code, + this.segwit, + ); + + PaynymAccountLite.fromMap(Map map) + : nymId = map["nymId"] as String, + nymName = map["nymName"] as String, + code = map["code"] as String, + segwit = map["segwit"] as bool; + + Map toMap() => { + "nymId": nymId, + "nymName": nymName, + "code": code, + "segwit": segwit, + }; + + @override + String toString() { + return toMap().toString(); + } +} diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index 6dd00c0ed..c2142b249 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; @@ -154,11 +155,14 @@ class _PaynymFollowToggleButtonState context: context, ), ); - ref - .read(myPaynymAccountStateProvider.state) - .state! - .following - .add(followedAccount.codes.first.code); + ref.read(myPaynymAccountStateProvider.state).state!.following.add( + PaynymAccountLite( + followedAccount.nymID, + followedAccount.nymName, + followedAccount.codes.first.code, + followedAccount.codes.first.segwit, + ), + ); setState(() { isFollowing = true; @@ -232,7 +236,7 @@ class _PaynymFollowToggleButtonState .read(myPaynymAccountStateProvider.state) .state! .following - .remove(followedAccount.codes.first.code); + .removeWhere((e) => e.nymId == followedAccount.nymID); setState(() { isFollowing = false; @@ -265,7 +269,8 @@ class _PaynymFollowToggleButtonState .read(myPaynymAccountStateProvider.state) .state! .following - .contains(widget.paymentCodeStringToFollow); + .where((e) => e.code == widget.paymentCodeStringToFollow) + .isNotEmpty; super.initState(); } diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index 596968c68..8573c4fc4 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -11,6 +11,7 @@ import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.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/theme/stack_colors.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; @@ -124,15 +125,16 @@ class _WalletNavigationBarState extends State { .read(paynymAPIProvider) .nym(code.toString()); + Logging.instance.log( + "my nym account: $account", + level: LogLevel.Info, + ); + if (mounted) { Navigator.of(context).pop(); // check if account exists and for matching code to see if claimed - if (account != null && - account.codes - .where((e) => - e.code == code.toString() && e.claimed) - .isNotEmpty) { + if (account != null && account.codes.first.claimed) { ref.read(myPaynymAccountStateProvider.state).state = account; From 20249f3da85637ab669906bb0a318a0cfdbf4a3f Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 21 Dec 2022 19:07:13 -0600 Subject: [PATCH 023/192] stupid follow/unfollow hack --- lib/pages/paynym/subwidgets/paynym_card.dart | 61 ++++++++++++++----- lib/services/coins/coin_paynym_extension.dart | 3 +- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index c2142b249..2ce0f62f4 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -124,26 +124,38 @@ class _PaynymFollowToggleButtonState final followedAccount = await ref .read(paynymAPIProvider) .nym(widget.paymentCodeStringToFollow, true); - await Future.delayed(const Duration(milliseconds: 100)); final myPCode = await wallet.getPaymentCode(); - await Future.delayed(const Duration(milliseconds: 100)); - final token = await ref.read(paynymAPIProvider).token(myPCode.toString()); - await Future.delayed(const Duration(milliseconds: 100)); + String token = await ref.read(paynymAPIProvider).token(myPCode.toString()); // sign token with notification private key - final signature = await wallet.signStringWithNotificationKey(token); - await Future.delayed(const Duration(milliseconds: 100)); + String signature = await wallet.signStringWithNotificationKey(token); - final result = await ref + var result = await ref .read(paynymAPIProvider) .follow(token, signature, followedAccount!.codes.first.code); - await Future.delayed(const Duration(milliseconds: 100)); - print("Follow result: $result"); + int i = 0; + for (; + i < 10 && result["message"] == "401 Unauthorized - Bad signature"; + i++) { + token = await ref.read(paynymAPIProvider).token(myPCode.toString()); - if (result["following"] == followedAccount.nymID) { + // sign token with notification private key + signature = await wallet.signStringWithNotificationKey(token); + + result = await ref + .read(paynymAPIProvider) + .follow(token, signature, followedAccount!.codes.first.code); + await Future.delayed(const Duration(milliseconds: 200)); + + print("RRR result: $result"); + } + + print("Follow result: $result on try $i"); + + if (result["following"] == followedAccount!.nymID) { if (!loadingPopped && mounted) { Navigator.of(context).pop(); } @@ -209,18 +221,35 @@ class _PaynymFollowToggleButtonState .nym(widget.paymentCodeStringToFollow, true); final myPCode = await wallet.getPaymentCode(); - final token = await ref.read(paynymAPIProvider).token(myPCode.toString()); + + String token = await ref.read(paynymAPIProvider).token(myPCode.toString()); // sign token with notification private key - final signature = await wallet.signStringWithNotificationKey(token); + String signature = await wallet.signStringWithNotificationKey(token); - final result = await ref + var result = await ref .read(paynymAPIProvider) - .unfollow(token, signature, followedAccount!.codes.first.code); + .follow(token, signature, followedAccount!.codes.first.code); - print("Unfollow result: $result"); + int i = 0; + for (; + i < 10 && result["message"] == "401 Unauthorized - Bad signature"; + i++) { + token = await ref.read(paynymAPIProvider).token(myPCode.toString()); - if (result["unfollowing"] == followedAccount.nymID) { + // sign token with notification private key + signature = await wallet.signStringWithNotificationKey(token); + + result = await ref + .read(paynymAPIProvider) + .unfollow(token, signature, followedAccount!.codes.first.code); + await Future.delayed(const Duration(milliseconds: 200)); + print("RRR result: $result"); + } + + print("Unfollow result: $result on try $i"); + + if (result["unfollowing"] == followedAccount!.nymID) { if (!loadingPopped && mounted) { Navigator.of(context).pop(); } diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 5b6082d75..764e69729 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:typed_data'; import 'package:bip47/bip47.dart'; @@ -38,7 +39,7 @@ extension PayNym on DogecoinWallet { Future signStringWithNotificationKey(String data) async { final bytes = - await signWithNotificationKey(Uint8List.fromList(data.codeUnits)); + await signWithNotificationKey(Uint8List.fromList(utf8.encode(data))); return Format.uint8listToString(bytes); // final bytes = // await signWithNotificationKey(Uint8List.fromList(utf8.encode(data))); From f3b1d11a46e7d823fb4e9150b16039b4ed41a6fc Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 2 Jan 2023 15:16:01 -0600 Subject: [PATCH 024/192] added paynym response objects and refactored paynym.is api --- lib/models/paynym/paynym_claim.dart | 20 ++ lib/models/paynym/paynym_follow.dart | 23 ++ lib/models/paynym/paynym_response.dart | 7 + lib/models/paynym/paynym_unfollow.dart | 23 ++ .../paynym/add_new_paynym_follow_view.dart | 2 +- lib/pages/paynym/paynym_claim_view.dart | 13 +- lib/pages/paynym/subwidgets/paynym_card.dart | 65 +++--- .../sub_widgets/wallet_navigation_bar.dart | 5 +- lib/providers/global/paynym_api_provider.dart | 4 +- .../{paynym_api.dart => paynym_is_api.dart} | 218 +++++++++++++++--- 10 files changed, 299 insertions(+), 81 deletions(-) create mode 100644 lib/models/paynym/paynym_claim.dart create mode 100644 lib/models/paynym/paynym_follow.dart create mode 100644 lib/models/paynym/paynym_response.dart create mode 100644 lib/models/paynym/paynym_unfollow.dart rename lib/utilities/{paynym_api.dart => paynym_is_api.dart} (66%) diff --git a/lib/models/paynym/paynym_claim.dart b/lib/models/paynym/paynym_claim.dart new file mode 100644 index 000000000..275063e4a --- /dev/null +++ b/lib/models/paynym/paynym_claim.dart @@ -0,0 +1,20 @@ +class PaynymClaim { + final String claimed; + final String token; + + PaynymClaim(this.claimed, this.token); + + PaynymClaim.fromMap(Map map) + : claimed = map["claimed"] as String, + token = map["token"] as String; + + Map toMap() => { + "claimed": claimed, + "token": token, + }; + + @override + String toString() { + return toMap().toString(); + } +} diff --git a/lib/models/paynym/paynym_follow.dart b/lib/models/paynym/paynym_follow.dart new file mode 100644 index 000000000..56bcb8fa9 --- /dev/null +++ b/lib/models/paynym/paynym_follow.dart @@ -0,0 +1,23 @@ +class PaynymFollow { + final String follower; + final String following; + final String token; + + PaynymFollow(this.follower, this.following, this.token); + + PaynymFollow.fromMap(Map map) + : follower = map["follower"] as String, + following = map["following"] as String, + token = map["token"] as String; + + Map toMap() => { + "follower": follower, + "following": following, + "token": token, + }; + + @override + String toString() { + return toMap().toString(); + } +} \ No newline at end of file diff --git a/lib/models/paynym/paynym_response.dart b/lib/models/paynym/paynym_response.dart new file mode 100644 index 000000000..409a0231e --- /dev/null +++ b/lib/models/paynym/paynym_response.dart @@ -0,0 +1,7 @@ +class PaynymResponse { + final T? value; + final int statusCode; + final String message; + + PaynymResponse(this.value, this.statusCode, this.message); +} diff --git a/lib/models/paynym/paynym_unfollow.dart b/lib/models/paynym/paynym_unfollow.dart new file mode 100644 index 000000000..4aa1ca975 --- /dev/null +++ b/lib/models/paynym/paynym_unfollow.dart @@ -0,0 +1,23 @@ +class PaynymUnfollow { + final String follower; + final String unfollowing; + final String token; + + PaynymUnfollow(this.follower, this.unfollowing, this.token); + + PaynymUnfollow.fromMap(Map map) + : follower = map["follower"] as String, + unfollowing = map["unfollowing"] as String, + token = map["token"] as String; + + Map toMap() => { + "follower": follower, + "unfollowing": unfollowing, + "token": token, + }; + + @override + String toString() { + return toMap().toString(); + } +} diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index 4382c9f7f..30ad12028 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -70,7 +70,7 @@ class _AddNewPaynymFollowViewState } setState(() { - _searchResult = paynymAccount; + _searchResult = paynymAccount.value; }); } } diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index c49992576..61d833688 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -108,7 +108,7 @@ class _PaynymClaimViewState extends ConsumerState { debugPrint("created:$created"); - if (created.claimed) { + if (created.value!.claimed) { // payment code already claimed debugPrint("pcode already claimed!!"); if (mounted) { @@ -126,18 +126,19 @@ class _PaynymClaimViewState extends ConsumerState { // sign token with notification private key final signature = - await wallet.signStringWithNotificationKey(token); + await wallet.signStringWithNotificationKey(token.value!); // claim paynym account - final claim = - await ref.read(paynymAPIProvider).claim(token, signature); + final claim = await ref + .read(paynymAPIProvider) + .claim(token.value!, signature); - if (claim["claimed"] == pCode.toString()) { + if (claim.value?.claimed == pCode.toString()) { final account = await ref.read(paynymAPIProvider).nym(pCode.toString()); ref.read(myPaynymAccountStateProvider.state).state = - account!; + account.value!; if (mounted) { Navigator.of(context).popUntil( ModalRoute.withName( diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index 2ce0f62f4..0c8ea9f19 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; +import 'package:stackwallet/models/paynym/paynym_response.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; @@ -127,27 +128,27 @@ class _PaynymFollowToggleButtonState final myPCode = await wallet.getPaymentCode(); - String token = await ref.read(paynymAPIProvider).token(myPCode.toString()); + PaynymResponse token = + await ref.read(paynymAPIProvider).token(myPCode.toString()); // sign token with notification private key - String signature = await wallet.signStringWithNotificationKey(token); + String signature = await wallet.signStringWithNotificationKey(token.value!); - var result = await ref - .read(paynymAPIProvider) - .follow(token, signature, followedAccount!.codes.first.code); + var result = await ref.read(paynymAPIProvider).follow( + token.value!, signature, followedAccount.value!.codes.first.code); int i = 0; for (; - i < 10 && result["message"] == "401 Unauthorized - Bad signature"; + i < 10 && + result.statusCode == 401; //"401 Unauthorized - Bad signature"; i++) { token = await ref.read(paynymAPIProvider).token(myPCode.toString()); // sign token with notification private key - signature = await wallet.signStringWithNotificationKey(token); + signature = await wallet.signStringWithNotificationKey(token.value!); - result = await ref - .read(paynymAPIProvider) - .follow(token, signature, followedAccount!.codes.first.code); + result = await ref.read(paynymAPIProvider).follow( + token.value!, signature, followedAccount.value!.codes.first.code); await Future.delayed(const Duration(milliseconds: 200)); print("RRR result: $result"); @@ -155,7 +156,7 @@ class _PaynymFollowToggleButtonState print("Follow result: $result on try $i"); - if (result["following"] == followedAccount!.nymID) { + if (result.value!.following == followedAccount.value!.nymID) { if (!loadingPopped && mounted) { Navigator.of(context).pop(); } @@ -163,16 +164,16 @@ class _PaynymFollowToggleButtonState unawaited( showFloatingFlushBar( type: FlushBarType.success, - message: "You are following ${followedAccount.nymName}", + message: "You are following ${followedAccount.value!.nymName}", context: context, ), ); ref.read(myPaynymAccountStateProvider.state).state!.following.add( PaynymAccountLite( - followedAccount.nymID, - followedAccount.nymName, - followedAccount.codes.first.code, - followedAccount.codes.first.segwit, + followedAccount.value!.nymID, + followedAccount.value!.nymName, + followedAccount.value!.codes.first.code, + followedAccount.value!.codes.first.segwit, ), ); @@ -189,7 +190,7 @@ class _PaynymFollowToggleButtonState unawaited( showFloatingFlushBar( type: FlushBarType.warning, - message: "Failed to follow ${followedAccount.nymName}", + message: "Failed to follow ${followedAccount.value!.nymName}", context: context, ), ); @@ -222,34 +223,34 @@ class _PaynymFollowToggleButtonState final myPCode = await wallet.getPaymentCode(); - String token = await ref.read(paynymAPIProvider).token(myPCode.toString()); + PaynymResponse token = + await ref.read(paynymAPIProvider).token(myPCode.toString()); // sign token with notification private key - String signature = await wallet.signStringWithNotificationKey(token); + String signature = await wallet.signStringWithNotificationKey(token.value!); - var result = await ref - .read(paynymAPIProvider) - .follow(token, signature, followedAccount!.codes.first.code); + var result = await ref.read(paynymAPIProvider).unfollow( + token.value!, signature, followedAccount.value!.codes.first.code); int i = 0; for (; - i < 10 && result["message"] == "401 Unauthorized - Bad signature"; + i < 10 && + result.statusCode == 401; //"401 Unauthorized - Bad signature"; i++) { token = await ref.read(paynymAPIProvider).token(myPCode.toString()); // sign token with notification private key - signature = await wallet.signStringWithNotificationKey(token); + signature = await wallet.signStringWithNotificationKey(token.value!); - result = await ref - .read(paynymAPIProvider) - .unfollow(token, signature, followedAccount!.codes.first.code); + result = await ref.read(paynymAPIProvider).unfollow( + token.value!, signature, followedAccount.value!.codes.first.code); await Future.delayed(const Duration(milliseconds: 200)); - print("RRR result: $result"); + print("unfollow RRR result: $result"); } print("Unfollow result: $result on try $i"); - if (result["unfollowing"] == followedAccount!.nymID) { + if (result.value!.unfollowing == followedAccount.value!.nymID) { if (!loadingPopped && mounted) { Navigator.of(context).pop(); } @@ -257,7 +258,7 @@ class _PaynymFollowToggleButtonState unawaited( showFloatingFlushBar( type: FlushBarType.success, - message: "You have unfollowed ${followedAccount.nymName}", + message: "You have unfollowed ${followedAccount.value!.nymName}", context: context, ), ); @@ -265,7 +266,7 @@ class _PaynymFollowToggleButtonState .read(myPaynymAccountStateProvider.state) .state! .following - .removeWhere((e) => e.nymId == followedAccount.nymID); + .removeWhere((e) => e.nymId == followedAccount.value!.nymID); setState(() { isFollowing = false; @@ -280,7 +281,7 @@ class _PaynymFollowToggleButtonState unawaited( showFloatingFlushBar( type: FlushBarType.warning, - message: "Failed to unfollow ${followedAccount.nymName}", + message: "Failed to unfollow ${followedAccount.value!.nymName}", context: context, ), ); diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index 8573c4fc4..ab0358e69 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -134,9 +134,10 @@ class _WalletNavigationBarState extends State { Navigator.of(context).pop(); // check if account exists and for matching code to see if claimed - if (account != null && account.codes.first.claimed) { + if (account.value != null && + account.value!.codes.first.claimed) { ref.read(myPaynymAccountStateProvider.state).state = - account; + account.value!; await Navigator.of(context).pushNamed( PaynymHomeView.routeName, diff --git a/lib/providers/global/paynym_api_provider.dart b/lib/providers/global/paynym_api_provider.dart index 06afd0b72..482b4c2ba 100644 --- a/lib/providers/global/paynym_api_provider.dart +++ b/lib/providers/global/paynym_api_provider.dart @@ -1,4 +1,4 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/paynym_api.dart'; +import 'package:stackwallet/utilities/paynym_is_api.dart'; -final paynymAPIProvider = Provider((_) => PaynymAPI()); +final paynymAPIProvider = Provider((_) => PaynymIsApi()); diff --git a/lib/utilities/paynym_api.dart b/lib/utilities/paynym_is_api.dart similarity index 66% rename from lib/utilities/paynym_api.dart rename to lib/utilities/paynym_is_api.dart index 2c31f9c49..b86b83749 100644 --- a/lib/utilities/paynym_api.dart +++ b/lib/utilities/paynym_is_api.dart @@ -4,12 +4,19 @@ 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:tuple/tuple.dart'; -class PaynymAPI { +// todo: better error message parsing (from response itself?) + +class PaynymIsApi { static const String baseURL = "https://paynym.is/api"; static const String version = "/v1"; - Future> _post( + Future, int>> _post( String endpoint, Map body, [ Map additionalHeaders = const {}, @@ -29,7 +36,10 @@ class PaynymAPI { debugPrint("Paynym response code: ${response.statusCode}"); debugPrint("Paynym response body: ${response.body}"); - return jsonDecode(response.body) as Map; + return Tuple2( + jsonDecode(response.body) as Map, + response.statusCode, + ); } // ### `/api/v1/create` @@ -77,9 +87,28 @@ class PaynymAPI { // // // ------ - Future create(String code) async { - final map = await _post("/create", {"code": code}); - return CreatedPaynym.fromMap(map); + Future> create(String code) async { + final result = await _post("/create", {"code": code}); + + String message; + CreatedPaynym? value; + + switch (result.item2) { + case 201: + message = "PayNym created successfully"; + value = CreatedPaynym.fromMap(result.item1); + break; + case 200: + message = "PayNym already exists"; + value = CreatedPaynym.fromMap(result.item1); + break; + case 400: + message = "Bad request"; + break; + default: + message = "Unknown error"; + } + return PaynymResponse(value, result.item2, message); } // ### `/api/v1/token` @@ -120,9 +149,27 @@ class PaynymAPI { // // // ------ - Future token(String code) async { - final map = await _post("/token", {"code": code}); - return map["token"] as String; + Future> token(String code) async { + final result = await _post("/token", {"code": code}); + + String message; + String? value; + + switch (result.item2) { + case 200: + message = "Token was successfully updated"; + value = result.item1["token"] as String; + break; + case 404: + message = "Payment code was not found"; + break; + case 400: + message = "Bad request"; + break; + default: + message = "Unknown error"; + } + return PaynymResponse(value, result.item2, message); } // ### `/api/v1/nym` @@ -175,17 +222,43 @@ class PaynymAPI { // | 200 | Nym found and returned | // | 404 | Nym not found | // | 400 | Bad request | - Future nym(String code, [bool compact = false]) async { + Future> nym(String code, + [bool compact = false]) async { final Map requestBody = {"nym": code}; if (compact) { requestBody["compact"] = true; } + + String message; + PaynymAccount? value; + int statusCode; + try { - final map = await _post("/nym", requestBody); - return PaynymAccount.fromMap(map); - } catch (_) { - return null; + final result = await _post("/nym", requestBody); + + statusCode = result.item2; + + switch (result.item2) { + case 200: + message = "Nym found and returned"; + value = PaynymAccount.fromMap(result.item1); + break; + case 404: + message = "Nym not found"; + break; + case 400: + message = "Bad request"; + break; + default: + message = "Unknown error"; + statusCode = -1; + } + } catch (e) { + value = null; + message = e.toString(); + statusCode = -1; } + return PaynymResponse(value, statusCode, message); } // ## Authenticated Requests @@ -238,8 +311,31 @@ class PaynymAPI { // | 400 | Bad request | // // ------ - Future> claim(String token, String signature) async { - return _post("/claim", {"signature": signature}, {"auth-token": token}); + Future> claim( + String token, + String signature, + ) async { + final result = await _post( + "/claim", + {"signature": signature}, + {"auth-token": token}, + ); + + String message; + PaynymClaim? value; + + switch (result.item2) { + case 200: + message = "Payment code successfully claimed"; + value = PaynymClaim.fromMap(result.item1); + break; + case 400: + message = "Bad request"; + break; + default: + message = "Unknown error"; + } + return PaynymResponse(value, result.item2, message); } // ### `/api/v1/follow` @@ -284,12 +380,12 @@ class PaynymAPI { // | 401 | Unauthorized token or signature or Unclaimed payment code | // // ------ - Future> follow( + Future> follow( String token, String signature, String target, ) async { - return _post( + final result = await _post( "/follow", { "target": target, @@ -299,6 +395,28 @@ class PaynymAPI { "auth-token": token, }, ); + + String message; + PaynymFollow? value; + + switch (result.item2) { + case 200: + message = "Added to followers"; + value = PaynymFollow.fromMap(result.item1); + break; + case 404: + message = "Payment code not found"; + break; + case 400: + message = "Bad request"; + break; + case 401: + message = "Unauthorized token or signature or Unclaimed payment code"; + break; + default: + message = "Unknown error"; + } + return PaynymResponse(value, result.item2, message); } // ### `/api/v1/unfollow` @@ -343,12 +461,12 @@ class PaynymAPI { // | 401 | Unauthorized token or signature or Unclaimed payment code | // // ------ - Future> unfollow( + Future> unfollow( String token, String signature, String target, ) async { - return _post( + final result = await _post( "/unfollow", { "target": target, @@ -358,6 +476,28 @@ class PaynymAPI { "auth-token": token, }, ); + + String message; + PaynymUnfollow? value; + + switch (result.item2) { + case 200: + message = "Unfollowed successfully"; + value = PaynymUnfollow.fromMap(result.item1); + break; + case 404: + message = "Payment code not found"; + break; + case 400: + message = "Bad request"; + break; + case 401: + message = "Unauthorized token or signature or Unclaimed payment code"; + break; + default: + message = "Unknown error"; + } + return PaynymResponse(value, result.item2, message); } // ### `/api/v1/nym/add` @@ -404,22 +544,24 @@ class PaynymAPI { // | 401 | Unauthorized token or signature or Unclaimed payment code | // // ------ - Future> add( - String token, - String signature, - String nym, - String code, - ) async { - return _post( - "/add", - { - "nym": nym, - "code": code, - "signature": signature, - }, - { - "auth-token": token, - }, - ); - } + +// NOT USED + // Future> add( + // String token, + // String signature, + // String nym, + // String code, + // ) async { + // return _post( + // "/add", + // { + // "nym": nym, + // "code": code, + // "signature": signature, + // }, + // { + // "auth-token": token, + // }, + // ); + // } } From 95f5b41b4dc98029f96b430d1a1be8ea2a949705 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 2 Jan 2023 16:43:04 -0600 Subject: [PATCH 025/192] increase xmr/wow autosave timer period --- lib/services/coins/monero/monero_wallet.dart | 2 +- lib/services/coins/wownero/wownero_wallet.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index f0869259b..96fb2ee7f 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -781,7 +781,7 @@ class MoneroWallet extends CoinServiceAPI { await refresh(); _autoSaveTimer?.cancel(); _autoSaveTimer = Timer.periodic( - const Duration(seconds: 93), + const Duration(seconds: 193), (_) async => await walletBase?.save(), ); } else { diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index d21ebab8c..1f9a3dd96 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -812,7 +812,7 @@ class WowneroWallet extends CoinServiceAPI { await refresh(); _autoSaveTimer?.cancel(); _autoSaveTimer = Timer.periodic( - const Duration(seconds: 93), + const Duration(seconds: 193), (_) async => await walletBase?.save(), ); } else { From e6416f2191dbb5ff08dd1205d80f728800e56015 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 2 Jan 2023 16:43:39 -0600 Subject: [PATCH 026/192] check and update ui if xmr/wow data found during re/scan --- lib/services/coins/monero/monero_wallet.dart | 43 +++++++++++++++++++ .../coins/wownero/wownero_wallet.dart | 43 +++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 96fb2ee7f..d9c6ae42b 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1119,6 +1119,7 @@ class MoneroWallet extends CoinServiceAPI { print("============================="); print("New Block! :: $walletName"); print("============================="); + _refreshTxDataHelper(); } void onNewTransaction() { @@ -1136,6 +1137,48 @@ class MoneroWallet extends CoinServiceAPI { ); } + bool _txRefreshLock = false; + int _lastCheckedHeight = -1; + int _txCount = 0; + + Future _refreshTxDataHelper() async { + if (_txRefreshLock) return; + _txRefreshLock = true; + + final syncStatus = walletBase?.syncStatus; + + if (syncStatus != null && syncStatus is SyncingSyncStatus) { + final int blocksLeft = syncStatus.blocksLeft; + final tenKChange = blocksLeft ~/ 10000; + + // only refresh transactions periodically during a sync + if (_lastCheckedHeight == -1 || tenKChange < _lastCheckedHeight) { + _lastCheckedHeight = tenKChange; + await _refreshTxData(); + } + } else { + await _refreshTxData(); + } + + _txRefreshLock = false; + } + + Future _refreshTxData() async { + final txnData = await _fetchTransactionData(); + final count = txnData.getAllTransactions().length; + + if (count > _txCount) { + _txCount = count; + _transactionData = Future(() => txnData); + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "New transaction data found in $walletId $walletName!", + walletId, + ), + ); + } + } + void syncStatusChanged() async { final syncStatus = walletBase?.syncStatus; if (syncStatus != null) { diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 1f9a3dd96..7abd64f48 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1163,6 +1163,49 @@ class WowneroWallet extends CoinServiceAPI { print("============================="); print("New Wownero Block! :: $walletName"); print("============================="); + _refreshTxDataHelper(); + } + + bool _txRefreshLock = false; + int _lastCheckedHeight = -1; + int _txCount = 0; + + Future _refreshTxDataHelper() async { + if (_txRefreshLock) return; + _txRefreshLock = true; + + final syncStatus = walletBase?.syncStatus; + + if (syncStatus != null && syncStatus is SyncingSyncStatus) { + final int blocksLeft = syncStatus.blocksLeft; + final tenKChange = blocksLeft ~/ 10000; + + // only refresh transactions periodically during a sync + if (_lastCheckedHeight == -1 || tenKChange < _lastCheckedHeight) { + _lastCheckedHeight = tenKChange; + await _refreshTxData(); + } + } else { + await _refreshTxData(); + } + + _txRefreshLock = false; + } + + Future _refreshTxData() async { + final txnData = await _fetchTransactionData(); + final count = txnData.getAllTransactions().length; + + if (count > _txCount) { + _txCount = count; + _transactionData = Future(() => txnData); + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "New transaction data found in $walletId $walletName!", + walletId, + ), + ); + } } void onNewTransaction() { From 772cca4201e3826f3c2eb8224ca4fbd003e18c37 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 08:33:54 -0600 Subject: [PATCH 027/192] paynym api slightly better error message handling --- lib/utilities/paynym_is_api.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/utilities/paynym_is_api.dart b/lib/utilities/paynym_is_api.dart index b86b83749..7d1fc79ed 100644 --- a/lib/utilities/paynym_is_api.dart +++ b/lib/utilities/paynym_is_api.dart @@ -106,7 +106,7 @@ class PaynymIsApi { message = "Bad request"; break; default: - message = "Unknown error"; + message = result.item1["message"] as String? ?? "Unknown error"; } return PaynymResponse(value, result.item2, message); } @@ -167,7 +167,7 @@ class PaynymIsApi { message = "Bad request"; break; default: - message = "Unknown error"; + message = result.item1["message"] as String? ?? "Unknown error"; } return PaynymResponse(value, result.item2, message); } @@ -250,8 +250,7 @@ class PaynymIsApi { message = "Bad request"; break; default: - message = "Unknown error"; - statusCode = -1; + message = result.item1["message"] as String? ?? "Unknown error"; } } catch (e) { value = null; @@ -333,7 +332,7 @@ class PaynymIsApi { message = "Bad request"; break; default: - message = "Unknown error"; + message = result.item1["message"] as String? ?? "Unknown error"; } return PaynymResponse(value, result.item2, message); } @@ -414,7 +413,7 @@ class PaynymIsApi { message = "Unauthorized token or signature or Unclaimed payment code"; break; default: - message = "Unknown error"; + message = result.item1["message"] as String? ?? "Unknown error"; } return PaynymResponse(value, result.item2, message); } @@ -495,7 +494,7 @@ class PaynymIsApi { message = "Unauthorized token or signature or Unclaimed payment code"; break; default: - message = "Unknown error"; + message = result.item1["message"] as String? ?? "Unknown error"; } return PaynymResponse(value, result.item2, message); } From 0b30ac435bb4595221de41f079463eebb9c58e72 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 08:34:18 -0600 Subject: [PATCH 028/192] add toString() to paynym response object --- lib/models/paynym/paynym_response.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/models/paynym/paynym_response.dart b/lib/models/paynym/paynym_response.dart index 409a0231e..3617d12cc 100644 --- a/lib/models/paynym/paynym_response.dart +++ b/lib/models/paynym/paynym_response.dart @@ -4,4 +4,9 @@ class PaynymResponse { final String message; PaynymResponse(this.value, this.statusCode, this.message); + + @override + String toString() { + return "PaynymResponse: value=$value, statusCode=$statusCode, message=$message"; + } } From f4729526e6fe67a7d36b72204abb2ed8db59c143 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 09:41:25 -0600 Subject: [PATCH 029/192] initial desktop paynym ui set up and state provider refactor --- lib/pages/paynym/paynym_claim_view.dart | 1 + lib/pages/paynym/paynym_home_view.dart | 5 +- lib/pages/paynym/subwidgets/paynym_card.dart | 2 +- .../sub_widgets/wallet_navigation_bar.dart | 1 + .../wallet_view/desktop_wallet_view.dart | 68 +++++++++++++++++++ .../my_paynym_account_state_provider.dart | 5 ++ 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 lib/providers/wallet/my_paynym_account_state_provider.dart diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index 61d833688..dc84b29d2 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -7,6 +7,7 @@ import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/providers/global/paynym_api_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index c633c0aa6..d5b044ddc 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -4,11 +4,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/paynym/paynym_account.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/format.dart'; @@ -24,9 +24,6 @@ import 'package:stackwallet/widgets/icon_widgets/share_icon.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/toggle.dart'; -final myPaynymAccountStateProvider = - StateProvider((ref) => null); - class PaynymHomeView extends ConsumerStatefulWidget { const PaynymHomeView({ Key? key, diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index 0c8ea9f19..565bef137 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -5,10 +5,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/models/paynym/paynym_response.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/providers/global/paynym_api_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/format.dart'; diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index ab0358e69..28b4e735c 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -7,6 +7,7 @@ import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/providers/global/paynym_api_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart index 7e57beac9..6c5d16659 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart @@ -17,6 +17,9 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.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'; @@ -36,10 +39,15 @@ import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/hover_text_field.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; +import '../../../pages/paynym/paynym_claim_view.dart'; +import '../../../pages/paynym/paynym_home_view.dart'; +import '../../../providers/global/paynym_api_provider.dart'; + /// [eventBus] should only be set during testing class DesktopWalletView extends ConsumerStatefulWidget { const DesktopWalletView({ @@ -281,6 +289,51 @@ class _DesktopWalletViewState extends ConsumerState { } } + Future onPaynymButtonPressed() async { + unawaited( + showDialog( + context: context, + builder: (context) => const LoadingIndicator( + width: 100, + ), + ), + ); + + // todo make generic and not doge specific + final wallet = (ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet); + + final code = await wallet.getPaymentCode(); + + final account = await ref.read(paynymAPIProvider).nym(code.toString()); + + Logging.instance.log( + "my nym account: $account", + level: LogLevel.Info, + ); + + if (mounted) { + Navigator.of(context, rootNavigator: true).pop(); + + // check if account exists and for matching code to see if claimed + if (account.value != null && account.value!.codes.first.claimed) { + ref.read(myPaynymAccountStateProvider.state).state = account.value!; + + await Navigator.of(context).pushNamed( + PaynymHomeView.routeName, + arguments: widget.walletId, + ); + } else { + await Navigator.of(context).pushNamed( + PaynymClaimView.routeName, + arguments: widget.walletId, + ); + } + } + } + @override void initState() { controller = TextEditingController(); @@ -482,6 +535,21 @@ class _DesktopWalletViewState extends ConsumerState { ); }, ), + if (coin.hasPaynymSupport) + SecondaryButton( + label: "PayNym", + width: 160, + buttonHeight: ButtonHeight.l, + icon: SvgPicture.asset( + Assets.svg.user, + height: 20, + width: 20, + color: Theme.of(context) + .extension()! + .buttonTextSecondary, + ), + onPressed: onPaynymButtonPressed, + ), // if (coin == Coin.firo) const SizedBox(width: 16), // SecondaryButton( // width: 180, diff --git a/lib/providers/wallet/my_paynym_account_state_provider.dart b/lib/providers/wallet/my_paynym_account_state_provider.dart new file mode 100644 index 000000000..1919e2ace --- /dev/null +++ b/lib/providers/wallet/my_paynym_account_state_provider.dart @@ -0,0 +1,5 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/models/paynym/paynym_account.dart'; + +final myPaynymAccountStateProvider = + StateProvider((ref) => null); From 73c94f9927c38e874ce1947e92906fa8dfcd3506 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 10:08:05 -0600 Subject: [PATCH 030/192] desktop layout --- lib/pages/paynym/paynym_claim_view.dart | 129 +++++++++++++++++------- 1 file changed, 95 insertions(+), 34 deletions(-) diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index dc84b29d2..b859e6739 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -2,6 +2,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/paynym/dialogs/claiming_paynym_dialog.dart'; import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; @@ -14,7 +15,9 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.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'; @@ -40,22 +43,54 @@ class _PaynymClaimViewState extends ConsumerState { return MasterScaffold( isDesktop: isDesktop, - appBar: AppBar( - leading: AppBarBackButton( - onPressed: () { - Navigator.of(context).pop(); - }, + appBar: isDesktop + ? DesktopAppBar( + isCompactHeight: true, + background: Theme.of(context).extension()!.popupBG, + leading: Row( + children: [ + const AppBarBackButton( + isCompact: true, + ), + SvgPicture.asset( + Assets.svg.user, + width: 42, + height: 42, + color: Theme.of(context).extension()!.textDark, + ), + const SizedBox( + width: 10, + ), + Text( + "PayNym", + style: STextStyles.desktopH3(context), + ) + ], + ), + ) + : AppBar( + leading: const AppBarBackButton(), + titleSpacing: 0, + title: Text( + "PayNym", + style: STextStyles.navBarTitle(context), + overflow: TextOverflow.ellipsis, + ), + ), + body: ConditionalParent( + condition: !isDesktop, + builder: (child) => SafeArea( + child: Padding( + padding: const EdgeInsets.all(16), + child: child, + ), ), - titleSpacing: 0, - title: Text( - "PayNym", - style: STextStyles.navBarTitle(context), - overflow: TextOverflow.ellipsis, - ), - ), - body: SafeArea( - child: Padding( - padding: const EdgeInsets.all(16), + child: ConditionalParent( + condition: isDesktop, + builder: (child) => SizedBox( + width: 328, + child: child, + ), child: Column( children: [ const Spacer( @@ -72,15 +107,27 @@ class _PaynymClaimViewState extends ConsumerState { ), Text( "You do not have a PayNym yet.\nClaim yours now!", - style: STextStyles.baseXS(context).copyWith( - color: - Theme.of(context).extension()!.textSubtitle1, - ), + style: isDesktop + ? STextStyles.desktopSubtitleH2(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ) + : STextStyles.baseXS(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), textAlign: TextAlign.center, ), - const Spacer( - flex: 2, - ), + if (isDesktop) + const SizedBox( + height: 30, + ), + if (!isDesktop) + const Spacer( + flex: 2, + ), PrimaryButton( label: "Claim", onPressed: () async { @@ -93,7 +140,7 @@ class _PaynymClaimViewState extends ConsumerState { ).then((value) => shouldCancel = value == true), ); - // ghet wallet to access paynym calls + // get wallet to access paynym calls final wallet = ref .read(walletsChangeNotifierProvider) .getManager(widget.walletId) @@ -113,11 +160,16 @@ class _PaynymClaimViewState extends ConsumerState { // payment code already claimed debugPrint("pcode already claimed!!"); if (mounted) { - Navigator.of(context).popUntil( - ModalRoute.withName( - WalletView.routeName, - ), - ); + if (isDesktop) { + Navigator.of(context, rootNavigator: true).pop(); + Navigator.of(context).pop(); + } else { + Navigator.of(context).popUntil( + ModalRoute.withName( + WalletView.routeName, + ), + ); + } } return; } @@ -141,21 +193,30 @@ class _PaynymClaimViewState extends ConsumerState { ref.read(myPaynymAccountStateProvider.state).state = account.value!; if (mounted) { - Navigator.of(context).popUntil( - ModalRoute.withName( - WalletView.routeName, - ), - ); + if (isDesktop) { + Navigator.of(context, rootNavigator: true).pop(); + Navigator.of(context).pop(); + } else { + Navigator.of(context).popUntil( + ModalRoute.withName( + WalletView.routeName, + ), + ); + } await Navigator.of(context).pushNamed( PaynymHomeView.routeName, arguments: widget.walletId, ); } } else if (mounted && !shouldCancel) { - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: isDesktop).pop(); } }, ), + if (isDesktop) + const Spacer( + flex: 2, + ), ], ), ), From 805beb109f9fb7cee01ca586b90286e07d79f26e Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 10:08:36 -0600 Subject: [PATCH 031/192] package imports --- .../my_stack_view/wallet_view/desktop_wallet_view.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart index 6c5d16659..d4a77bae8 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart @@ -8,6 +8,8 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart'; import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart'; +import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; +import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_button.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart'; @@ -15,6 +17,7 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/recent_desktop_transactions.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart'; import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; +import 'package:stackwallet/providers/global/paynym_api_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; @@ -44,10 +47,6 @@ import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; -import '../../../pages/paynym/paynym_claim_view.dart'; -import '../../../pages/paynym/paynym_home_view.dart'; -import '../../../providers/global/paynym_api_provider.dart'; - /// [eventBus] should only be set during testing class DesktopWalletView extends ConsumerStatefulWidget { const DesktopWalletView({ From 930bdfca5e497bcf3947c212250a906b752f4164 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 10:57:04 -0600 Subject: [PATCH 032/192] desktop layout --- lib/pages/paynym/paynym_home_view.dart | 651 ++++++++++++++++++------- 1 file changed, 462 insertions(+), 189 deletions(-) diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index d5b044ddc..a0affc473 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -15,7 +15,9 @@ import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.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/secondary_button.dart'; import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart'; @@ -57,210 +59,464 @@ class _PaynymHomeViewState extends ConsumerState { return MasterScaffold( isDesktop: isDesktop, - appBar: AppBar( - leading: AppBarBackButton( - onPressed: () { - Navigator.of(context).pop(); - }, - ), - titleSpacing: 0, - title: Text( - "PayNym", - style: STextStyles.navBarTitle(context), - overflow: TextOverflow.ellipsis, - ), - actions: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 6), - child: AspectRatio( - aspectRatio: 1, - child: AppBarIconButton( - icon: SvgPicture.asset( - Assets.svg.circlePlusFilled, - width: 20, - height: 20, - color: Theme.of(context).extension()!.textDark, - ), - onPressed: () { - Navigator.of(context).pushNamed( - AddNewPaynymFollowView.routeName, - arguments: widget.walletId, - ); - }, + appBar: isDesktop + ? DesktopAppBar( + isCompactHeight: true, + background: Theme.of(context).extension()!.popupBG, + leading: Row( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 24, + right: 20, + ), + child: AppBarIconButton( + size: 32, + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + shadows: const [], + icon: SvgPicture.asset( + Assets.svg.arrowLeft, + width: 18, + height: 18, + color: Theme.of(context) + .extension()! + .topNavIconPrimary, + ), + onPressed: Navigator.of(context).pop, + ), + ), + SvgPicture.asset( + Assets.svg.user, + width: 32, + height: 32, + color: Theme.of(context).extension()!.textDark, + ), + const SizedBox( + width: 10, + ), + Text( + "PayNym", + style: STextStyles.desktopH3(context), + ) + ], ), - ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 6), - child: AspectRatio( - aspectRatio: 1, - child: AppBarIconButton( - icon: SvgPicture.asset( - Assets.svg.circleQuestion, - width: 20, - height: 20, - color: Theme.of(context).extension()!.textDark, - ), - onPressed: () { - // todo info ? - }, - ), - ), - ), - const SizedBox( - width: 4, - ), - ], - ), - body: SafeArea( - child: Padding( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - secretCount++; - if (secretCount > 5) { - debugPrint( - "My Account: ${ref.read(myPaynymAccountStateProvider.state).state}"); - debugPrint( - "My Account: ${ref.read(myPaynymAccountStateProvider.state).state!.following}"); - secretCount = 0; - } - - timer ??= Timer( - const Duration(milliseconds: 1500), - () { - secretCount = 0; - timer = null; + trailing: Padding( + padding: const EdgeInsets.only(right: 22), + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + Navigator.of(context).pushNamed( + AddNewPaynymFollowView.routeName, + arguments: widget.walletId, + ); }, - ); - }, - child: PayNymBot( - paymentCodeString: ref - .watch(myPaynymAccountStateProvider.state) - .state! - .codes - .first - .code, + child: Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + children: [ + SvgPicture.asset( + Assets.svg.plus, + width: 16, + height: 16, + color: Theme.of(context) + .extension()! + .textDark, + ), + const SizedBox( + width: 8, + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Follow", + style: + STextStyles.desktopButtonSecondaryEnabled( + context) + .copyWith( + fontSize: 16, + ), + ), + const SizedBox( + height: 2, + ), + ], + ), + ], + ), + ), + ), + ), ), ), - const SizedBox( - height: 10, + ) + : AppBar( + leading: AppBarBackButton( + onPressed: () { + Navigator.of(context).pop(); + }, ), - Text( - ref.watch(myPaynymAccountStateProvider.state).state!.nymName, - style: STextStyles.desktopMenuItemSelected(context), + titleSpacing: 0, + title: Text( + "PayNym", + style: STextStyles.navBarTitle(context), + overflow: TextOverflow.ellipsis, ), - const SizedBox( - height: 4, - ), - Text( - Format.shorten( + actions: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: AspectRatio( + aspectRatio: 1, + child: AppBarIconButton( + icon: SvgPicture.asset( + Assets.svg.circlePlusFilled, + width: 20, + height: 20, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + Navigator.of(context).pushNamed( + AddNewPaynymFollowView.routeName, + arguments: widget.walletId, + ); + }, + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: AspectRatio( + aspectRatio: 1, + child: AppBarIconButton( + icon: SvgPicture.asset( + Assets.svg.circleQuestion, + width: 20, + height: 20, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + // todo info ? + }, + ), + ), + ), + const SizedBox( + width: 4, + ), + ], + ), + body: ConditionalParent( + condition: !isDesktop, + builder: (child) => SafeArea( + child: Padding( + padding: const EdgeInsets.all(16), + child: child, + ), + ), + child: Column( + crossAxisAlignment: + isDesktop ? CrossAxisAlignment.start : CrossAxisAlignment.center, + children: [ + if (!isDesktop) + Column( + mainAxisSize: MainAxisSize.min, + children: [ + GestureDetector( + onTap: () { + secretCount++; + if (secretCount > 5) { + debugPrint( + "My Account: ${ref.read(myPaynymAccountStateProvider.state).state}"); + debugPrint( + "My Account: ${ref.read(myPaynymAccountStateProvider.state).state!.following}"); + secretCount = 0; + } + + timer ??= Timer( + const Duration(milliseconds: 1500), + () { + secretCount = 0; + timer = null; + }, + ); + }, + child: PayNymBot( + paymentCodeString: ref + .watch(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + ), + ), + const SizedBox( + height: 10, + ), + Text( ref .watch(myPaynymAccountStateProvider.state) .state! - .codes - .first - .code, - 12, - 5), - style: STextStyles.label(context), - ), - const SizedBox( - height: 11, - ), - Row( - children: [ - Expanded( - child: SecondaryButton( - label: "Copy", - buttonHeight: ButtonHeight.l, - iconSpacing: 4, - icon: CopyIcon( - width: 10, - height: 10, - color: Theme.of(context) - .extension()! - .textDark, - ), - onPressed: () async { - await Clipboard.setData( - ClipboardData( - text: ref - .read(myPaynymAccountStateProvider.state) - .state! - .codes - .first - .code, - ), - ); - unawaited( - showFloatingFlushBar( - type: FlushBarType.info, - message: "Copied to clipboard", - iconAsset: Assets.svg.copy, - context: context, - ), - ); - }, - ), + .nymName, + style: STextStyles.desktopMenuItemSelected(context), ), const SizedBox( - width: 13, + height: 4, ), - Expanded( - child: SecondaryButton( - label: "Share", - buttonHeight: ButtonHeight.l, - iconSpacing: 4, - icon: ShareIcon( - width: 10, - height: 10, - color: Theme.of(context) - .extension()! - .textDark, - ), - onPressed: () { - // copy to clipboard - }, - ), + Text( + Format.shorten( + ref + .watch(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + 12, + 5), + style: STextStyles.label(context), ), const SizedBox( - width: 13, + height: 11, ), - Expanded( - child: SecondaryButton( - label: "Address", - buttonHeight: ButtonHeight.l, - iconSpacing: 4, - icon: QrCodeIcon( - width: 10, - height: 10, - color: Theme.of(context) - .extension()! - .textDark, - ), - onPressed: () { - showDialog( - context: context, - builder: (context) => PaynymQrPopup( - paynymAccount: ref - .read(myPaynymAccountStateProvider.state) - .state!, + Row( + children: [ + Expanded( + child: SecondaryButton( + label: "Copy", + buttonHeight: ButtonHeight.l, + iconSpacing: 4, + icon: CopyIcon( + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .textDark, ), - ); - }, - ), + onPressed: () async { + await Clipboard.setData( + ClipboardData( + text: ref + .read(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + ), + ); + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: "Copied to clipboard", + iconAsset: Assets.svg.copy, + context: context, + ), + ); + }, + ), + ), + const SizedBox( + width: 13, + ), + Expanded( + child: SecondaryButton( + label: "Share", + buttonHeight: ButtonHeight.l, + iconSpacing: 4, + icon: ShareIcon( + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + // copy to clipboard + }, + ), + ), + const SizedBox( + width: 13, + ), + Expanded( + child: SecondaryButton( + label: "Address", + buttonHeight: ButtonHeight.l, + iconSpacing: 4, + icon: QrCodeIcon( + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + showDialog( + context: context, + builder: (context) => PaynymQrPopup( + paynymAccount: ref + .read(myPaynymAccountStateProvider.state) + .state!, + ), + ); + }, + ), + ), + ], ), ], ), + if (isDesktop) + Padding( + padding: const EdgeInsets.all(24), + child: RoundedWhiteContainer( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + const SizedBox( + width: 4, + ), + GestureDetector( + onTap: () { + secretCount++; + if (secretCount > 5) { + debugPrint( + "My Account: ${ref.read(myPaynymAccountStateProvider.state).state}"); + debugPrint( + "My Account: ${ref.read(myPaynymAccountStateProvider.state).state!.following}"); + secretCount = 0; + } + + timer ??= Timer( + const Duration(milliseconds: 1500), + () { + secretCount = 0; + timer = null; + }, + ); + }, + child: PayNymBot( + paymentCodeString: ref + .watch(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + ), + ), + const SizedBox( + width: 16, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + ref + .watch(myPaynymAccountStateProvider.state) + .state! + .nymName, + style: STextStyles.desktopH3(context), + ), + const SizedBox( + height: 4, + ), + Text( + Format.shorten( + ref + .watch(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + 12, + 5), + style: + STextStyles.desktopTextExtraExtraSmall(context), + ), + ], + ), + const Spacer(), + SecondaryButton( + label: "Copy", + buttonHeight: ButtonHeight.l, + width: 160, + icon: CopyIcon( + width: 18, + height: 18, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () async { + await Clipboard.setData( + ClipboardData( + text: ref + .read(myPaynymAccountStateProvider.state) + .state! + .codes + .first + .code, + ), + ); + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: "Copied to clipboard", + iconAsset: Assets.svg.copy, + context: context, + ), + ); + }, + ), + const SizedBox( + width: 16, + ), + SecondaryButton( + label: "Address", + width: 160, + buttonHeight: ButtonHeight.l, + icon: QrCodeIcon( + width: 18, + height: 18, + color: Theme.of(context) + .extension()! + .textDark, + ), + onPressed: () { + showDialog( + context: context, + builder: (context) => PaynymQrPopup( + paynymAccount: ref + .read(myPaynymAccountStateProvider.state) + .state!, + ), + ); + }, + ), + ], + ), + ), + ), + if (!isDesktop) const SizedBox( height: 24, ), - SizedBox( - height: 40, + ConditionalParent( + condition: isDesktop, + builder: (child) => Padding( + padding: const EdgeInsets.only(left: 24), + child: child, + ), + child: SizedBox( + height: isDesktop ? 56 : 40, + width: isDesktop ? 490 : null, child: Toggle( onColor: Theme.of(context).extension()!.popupBG, onText: "Following", @@ -275,29 +531,46 @@ class _PaynymHomeViewState extends ConsumerState { }); }, decoration: BoxDecoration( - color: Colors.blue, + color: Colors.transparent, borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), ), ), ), - const SizedBox( - height: 16, + ), + SizedBox( + height: isDesktop ? 20 : 16, + ), + ConditionalParent( + condition: isDesktop, + builder: (child) => Padding( + padding: const EdgeInsets.only(left: 24), + child: SizedBox( + width: 490, + child: child, + ), ), - RoundedWhiteContainer( + child: RoundedWhiteContainer( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Your PayNym contacts will appear here", - style: STextStyles.label(context), + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ) + : STextStyles.label(context), ), ], ), ), - ], - ), + ), + ], ), ), ); From 0746fe36b7797894d2f810506c69acabfc2fd80a Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 10:57:14 -0600 Subject: [PATCH 033/192] back button style fix --- lib/pages/paynym/paynym_claim_view.dart | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index b859e6739..1f60ecda4 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -49,8 +49,27 @@ class _PaynymClaimViewState extends ConsumerState { background: Theme.of(context).extension()!.popupBG, leading: Row( children: [ - const AppBarBackButton( - isCompact: true, + Padding( + padding: const EdgeInsets.only( + left: 24, + right: 20, + ), + child: AppBarIconButton( + size: 32, + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + shadows: const [], + icon: SvgPicture.asset( + Assets.svg.arrowLeft, + width: 18, + height: 18, + color: Theme.of(context) + .extension()! + .topNavIconPrimary, + ), + onPressed: Navigator.of(context).pop, + ), ), SvgPicture.asset( Assets.svg.user, From 33926d2b5ee3521403dfe9470e08d5f8b1d6804f Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 11:20:25 -0600 Subject: [PATCH 034/192] address popup desktop conditional layout --- lib/pages/paynym/dialogs/paynym_qr_popup.dart | 66 ++++++++++++++----- lib/utilities/text_styles.dart | 26 ++++++++ 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/lib/pages/paynym/dialogs/paynym_qr_popup.dart b/lib/pages/paynym/dialogs/paynym_qr_popup.dart index fefb8dd59..4ff6d9ca0 100644 --- a/lib/pages/paynym/dialogs/paynym_qr_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_qr_popup.dart @@ -9,8 +9,10 @@ import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; class PaynymQrPopup extends StatelessWidget { const PaynymQrPopup({ @@ -22,15 +24,31 @@ class PaynymQrPopup extends StatelessWidget { @override Widget build(BuildContext context) { + final isDesktop = Util.isDesktop; + return DesktopDialog( - maxWidth: MediaQuery.of(context).size.width - 32, + maxWidth: isDesktop ? 580 : MediaQuery.of(context).size.width - 32, maxHeight: double.infinity, child: Column( children: [ + if (isDesktop) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.only(left: 32), + child: Text( + "Address details", + style: STextStyles.desktopH3(context), + ), + ), + const DesktopDialogCloseButton(), + ], + ), Padding( - padding: const EdgeInsets.only( - left: 24, - top: 24, + padding: EdgeInsets.only( + left: isDesktop ? 32 : 24, + top: isDesktop ? 16 : 24, right: 24, bottom: 16, ), @@ -38,22 +56,26 @@ class PaynymQrPopup extends StatelessWidget { children: [ PayNymBot( paymentCodeString: paynymAccount.codes.first.code, - size: 32, + size: isDesktop ? 56 : 32, ), const SizedBox( width: 12, ), Text( paynymAccount.nymName, - style: STextStyles.w600_12(context), + style: isDesktop + ? STextStyles.w500_24(context) + : STextStyles.w600_12(context), ), ], ), ), - Container( - color: Theme.of(context).extension()!.backgroundAppBar, - height: 1, - ), + if (!isDesktop) + Container( + color: + Theme.of(context).extension()!.backgroundAppBar, + height: 1, + ), Padding( padding: const EdgeInsets.only( left: 24, @@ -71,26 +93,34 @@ class PaynymQrPopup extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - "Your PayNym address", - style: STextStyles.infoSmall(context), + isDesktop ? "PayNym address" : "Your PayNym address", + style: isDesktop + ? STextStyles.desktopTextSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ) + : STextStyles.infoSmall(context), ), const SizedBox( height: 6, ), Text( paynymAccount.codes.first.code, - style: STextStyles.infoSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ), + style: isDesktop + ? STextStyles.desktopTextSmall(context) + : STextStyles.infoSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), ), const SizedBox( height: 6, ), BlueTextButton( text: "Copy", - textSize: 10, + textSize: isDesktop ? 18 : 10, onTap: () async { await Clipboard.setData( ClipboardData( diff --git a/lib/utilities/text_styles.dart b/lib/utilities/text_styles.dart index 51ade8153..be176e37d 100644 --- a/lib/utilities/text_styles.dart +++ b/lib/utilities/text_styles.dart @@ -809,6 +809,32 @@ class STextStyles { } } + static TextStyle w500_24(BuildContext context) { + switch (_theme(context).themeType) { + case ThemeType.light: + return GoogleFonts.inter( + color: _theme(context).textDark, + fontWeight: FontWeight.w500, + fontSize: 24, + height: 24 / 24, + ); + case ThemeType.oceanBreeze: + return GoogleFonts.inter( + color: _theme(context).textDark, + fontWeight: FontWeight.w500, + fontSize: 24, + height: 24 / 24, + ); + case ThemeType.dark: + return GoogleFonts.inter( + color: _theme(context).textDark, + fontWeight: FontWeight.w500, + fontSize: 24, + height: 24 / 24, + ); + } + } + static TextStyle desktopTextMedium(BuildContext context) { switch (_theme(context).themeType) { case ThemeType.light: From c4e5e9e8b675ad48f4c36bc97249e774c584cba1 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 11:37:39 -0600 Subject: [PATCH 035/192] paynym claim cancellation hack (should probably not even allow cancel in ui) --- .../dialogs/claiming_paynym_dialog.dart | 82 ++++++++++++------- lib/pages/paynym/paynym_claim_view.dart | 13 +++ 2 files changed, 66 insertions(+), 29 deletions(-) diff --git a/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart index 530950ec4..2a24fd4c8 100644 --- a/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart +++ b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart @@ -5,6 +5,7 @@ import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.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/stack_dialog.dart'; @@ -49,38 +50,61 @@ class _RestoringDialogState extends State Widget build(BuildContext context) { if (Util.isDesktop) { return DesktopDialog( - child: Padding( - padding: const EdgeInsets.all(40), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "Claiming PayNym", - style: STextStyles.desktopH3(context), - ), - const SizedBox( - height: 20, - ), - Text( - "We are generating your PayNym", - style: STextStyles.desktopSubtitleH1(context), - ), - const SizedBox( + maxWidth: 580, + maxHeight: double.infinity, + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + DesktopDialogCloseButton( + onPressedOverride: () => Navigator.of(context).pop(true), + ), + ], + ), + RotationTransition( + turns: _spinAnimation, + child: SvgPicture.asset( + Assets.svg.arrowRotate, + color: + Theme.of(context).extension()!.accentColorDark, + width: 40, height: 40, ), - RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate, - color: Theme.of(context) - .extension()! - .accentColorDark, - width: 24, - height: 24, - ), + ), + Padding( + padding: const EdgeInsets.all(40), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Claiming PayNym", + style: STextStyles.desktopH2(context), + ), + const SizedBox( + height: 20, + ), + Text( + "We are generating your PayNym", + style: STextStyles.desktopTextMedium(context).copyWith( + color: + Theme.of(context).extension()!.textDark3, + ), + ), + const SizedBox( + height: 40, + ), + SecondaryButton( + label: "Cancel", + width: 272, + onPressed: () { + Navigator.of(context).pop(true); + }, + ), + ], ), - ], - ), + ), + ], ), ); } else { diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index 1f60ecda4..cf5ffc671 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -165,15 +165,20 @@ class _PaynymClaimViewState extends ConsumerState { .getManager(widget.walletId) .wallet as DogecoinWallet; + if (shouldCancel) return; + // get payment code final pCode = await wallet.getPaymentCode(); + if (shouldCancel) return; + // attempt to create new entry in paynym.is db final created = await ref .read(paynymAPIProvider) .create(pCode.toString()); debugPrint("created:$created"); + if (shouldCancel) return; if (created.value!.claimed) { // payment code already claimed @@ -193,18 +198,26 @@ class _PaynymClaimViewState extends ConsumerState { return; } + if (shouldCancel) return; + final token = await ref.read(paynymAPIProvider).token(pCode.toString()); + if (shouldCancel) return; + // sign token with notification private key final signature = await wallet.signStringWithNotificationKey(token.value!); + if (shouldCancel) return; + // claim paynym account final claim = await ref .read(paynymAPIProvider) .claim(token.value!, signature); + if (shouldCancel) return; + if (claim.value?.claimed == pCode.toString()) { final account = await ref.read(paynymAPIProvider).nym(pCode.toString()); From a6cc9550904ce4c8cc0ed5f2209a132e22fffbf2 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 12:32:10 -0600 Subject: [PATCH 036/192] paynym desktop search button --- lib/widgets/desktop/paynym_search_button.dart | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/widgets/desktop/paynym_search_button.dart diff --git a/lib/widgets/desktop/paynym_search_button.dart b/lib/widgets/desktop/paynym_search_button.dart new file mode 100644 index 000000000..0d9002ec6 --- /dev/null +++ b/lib/widgets/desktop/paynym_search_button.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; + +class PaynymSearchButton extends StatefulWidget { + const PaynymSearchButton({ + Key? key, + required this.onPressed, + }) : super(key: key); + + final VoidCallback onPressed; + + @override + State createState() => _PaynymSearchButtonState(); +} + +class _PaynymSearchButtonState extends State { + @override + Widget build(BuildContext context) { + return MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: widget.onPressed, + child: RoundedContainer( + width: 56, + height: 56, + color: + Theme.of(context).extension()!.buttonBackSecondary, + child: Center( + child: SvgPicture.asset( + Assets.svg.search, + width: 20, + height: 20, + color: Theme.of(context).extension()!.textDark, + ), + ), + ), + ), + ); + } +} From 97d3b35a22261bbcee1b45a5e7e45e931f41d19a Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 12:32:40 -0600 Subject: [PATCH 037/192] paynym desktop add new follow popup layout --- .../paynym/add_new_paynym_follow_view.dart | 408 ++++++++++++------ lib/pages/paynym/paynym_home_view.dart | 10 +- 2 files changed, 280 insertions(+), 138 deletions(-) diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index 30ad12028..bcd09659d 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -14,12 +14,16 @@ import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.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_dialog.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import 'package:stackwallet/widgets/desktop/paynym_search_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:stackwallet/widgets/textfield_icon_button.dart'; @@ -49,6 +53,8 @@ class _AddNewPaynymFollowViewState bool _didSearch = false; PaynymAccount? _searchResult; + final isDesktop = Util.isDesktop; + Future _search() async { _didSearch = true; bool didPopLoading = false; @@ -75,6 +81,60 @@ class _AddNewPaynymFollowViewState } } + Future _clear() async { + _searchString = ""; + setState(() { + _searchController.text = ""; + }); + } + + Future _paste() async { + final ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain); + if (data?.text != null && data!.text!.isNotEmpty) { + String content = data.text!.trim(); + if (content.contains("\n")) { + content = content.substring( + 0, + content.indexOf( + "\n", + ), + ); + } + + _searchString = content; + setState(() { + _searchController.text = content; + _searchController.selection = TextSelection.collapsed( + offset: content.length, + ); + }); + } + } + + Future _scanQr() async { + try { + if (!isDesktop && FocusScope.of(context).hasFocus) { + FocusScope.of(context).unfocus(); + await Future.delayed(const Duration(milliseconds: 75)); + } + + final qrResult = await const BarcodeScannerWrapper().scan(); + + final pCodeString = qrResult.rawContent; + + _searchString = pCodeString; + + setState(() { + _searchController.text = pCodeString; + _searchController.selection = TextSelection.collapsed( + offset: pCodeString.length, + ); + }); + } catch (_) { + // scan failed + } + } + @override void initState() { _searchController = TextEditingController(); @@ -92,26 +152,25 @@ class _AddNewPaynymFollowViewState @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); - final isDesktop = Util.isDesktop; - return MasterScaffold( - isDesktop: isDesktop, - appBar: AppBar( - leading: AppBarBackButton( - onPressed: () { - Navigator.of(context).pop(); - }, + return ConditionalParent( + condition: !isDesktop, + builder: (child) => MasterScaffold( + isDesktop: isDesktop, + appBar: AppBar( + leading: AppBarBackButton( + onPressed: () { + Navigator.of(context).pop(); + }, + ), + titleSpacing: 0, + title: Text( + "Add new", + style: STextStyles.navBarTitle(context), + overflow: TextOverflow.ellipsis, + ), ), - titleSpacing: 0, - title: Text( - "Add new", - style: STextStyles.navBarTitle(context), - overflow: TextOverflow.ellipsis, - ), - ), - body: ConditionalParent( - condition: !isDesktop, - builder: (child) => SafeArea( + body: SafeArea( child: LayoutBuilder( builder: (context, constraints) => SingleChildScrollView( child: ConstrainedBox( @@ -119,40 +178,183 @@ class _AddNewPaynymFollowViewState minHeight: constraints.maxHeight, ), child: IntrinsicHeight( - child: child, + child: Padding( + padding: const EdgeInsets.all(16), + child: child, + ), ), ), ), ), ), - child: Padding( - padding: const EdgeInsets.all(16), + ), + child: ConditionalParent( + condition: isDesktop, + builder: (child) => DesktopDialog( + maxWidth: 580, + maxHeight: double.infinity, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox( - height: 10, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.only(left: 32), + child: Text( + "Add new", + style: STextStyles.desktopH3(context), + ), + ), + const DesktopDialogCloseButton(), + ], ), - Text( - "Featured PayNyms", - style: STextStyles.sectionLabelMedium12(context), + Padding( + padding: const EdgeInsets.only( + left: 32, + right: 32, + bottom: 32, + ), + child: child, ), - const SizedBox( - height: 12, - ), - FeaturedPaynymsWidget( - walletId: widget.walletId, - ), - const SizedBox( - height: 24, - ), - Text( - "Add new", - style: STextStyles.sectionLabelMedium12(context), - ), - const SizedBox( - height: 12, + ], + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 10, + ), + Text( + "Featured PayNyms", + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.sectionLabelMedium12(context), + ), + const SizedBox( + height: 12, + ), + FeaturedPaynymsWidget( + walletId: widget.walletId, + ), + const SizedBox( + height: 24, + ), + Text( + "Add new", + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.sectionLabelMedium12(context), + ), + const SizedBox( + height: 12, + ), + if (isDesktop) + Row( + children: [ + Expanded( + child: Stack( + children: [ + RoundedContainer( + padding: const EdgeInsets.all(0), + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + height: 56, + child: Center( + child: TextField( + autocorrect: !isDesktop, + enableSuggestions: !isDesktop, + controller: _searchController, + focusNode: searchFieldFocusNode, + onChanged: (value) { + setState(() { + _searchString = value; + }); + }, + style: STextStyles.desktopTextExtraExtraSmall( + context) + .copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + // height: 1.8, + ), + decoration: InputDecoration( + hintText: "Paste payment code", + hoverColor: Colors.transparent, + fillColor: Colors.transparent, + contentPadding: const EdgeInsets.all(16), + hintStyle: + STextStyles.desktopTextFieldLabel(context) + .copyWith( + fontSize: 14, + ), + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + errorBorder: InputBorder.none, + disabledBorder: InputBorder.none, + focusedErrorBorder: InputBorder.none, + suffixIcon: Padding( + padding: const EdgeInsets.only(right: 8), + child: UnconstrainedBox( + child: Row( + children: [ + _searchController.text.isNotEmpty + ? TextFieldIconButton( + onTap: _clear, + child: RoundedContainer( + padding: + const EdgeInsets.all(8), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: const XIcon(), + ), + ) + : TextFieldIconButton( + key: const Key( + "paynymPasteAddressFieldButtonKey"), + onTap: _paste, + child: RoundedContainer( + padding: + const EdgeInsets.all(8), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: const ClipboardIcon(), + ), + ), + TextFieldIconButton( + key: const Key( + "paynymScanQrButtonKey"), + onTap: _scanQr, + child: RoundedContainer( + padding: const EdgeInsets.all(8), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: const QrCodeIcon(), + ), + ) + ], + ), + ), + ), + ), + ), + ), + ), + ], + ), + ), + const SizedBox( + width: 10, + ), + PaynymSearchButton(onPressed: _search), + ], ), + if (!isDesktop) ClipRRect( borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, @@ -167,14 +369,7 @@ class _AddNewPaynymFollowViewState _searchString = value; }); }, - style: isDesktop - ? STextStyles.desktopTextExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveText, - height: 1.8, - ) - : STextStyles.field(context), + style: STextStyles.field(context), decoration: standardInputDecoration( "Paste payment code", searchFieldFocusNode, @@ -188,74 +383,18 @@ class _AddNewPaynymFollowViewState children: [ _searchController.text.isNotEmpty ? TextFieldIconButton( + onTap: _clear, child: const XIcon(), - onTap: () async { - _searchString = ""; - setState(() { - _searchController.text = ""; - }); - }, ) : TextFieldIconButton( key: const Key( "paynymPasteAddressFieldButtonKey"), - onTap: () async { - final ClipboardData? data = - await Clipboard.getData( - Clipboard.kTextPlain); - if (data?.text != null && - data!.text!.isNotEmpty) { - String content = data.text!.trim(); - if (content.contains("\n")) { - content = content.substring( - 0, - content.indexOf( - "\n", - ), - ); - } - - _searchString = content; - setState(() { - _searchController.text = content; - _searchController.selection = - TextSelection.collapsed( - offset: content.length, - ); - }); - } - }, + onTap: _paste, child: const ClipboardIcon(), ), TextFieldIconButton( key: const Key("paynymScanQrButtonKey"), - onTap: () async { - try { - if (FocusScope.of(context).hasFocus) { - FocusScope.of(context).unfocus(); - await Future.delayed( - const Duration(milliseconds: 75)); - } - - final qrResult = - await const BarcodeScannerWrapper() - .scan(); - - final pCodeString = qrResult.rawContent; - - _searchString = pCodeString; - - setState(() { - _searchController.text = pCodeString; - _searchController.selection = - TextSelection.collapsed( - offset: pCodeString.length, - ); - }); - } catch (_) { - // scan failed - } - }, + onTap: _scanQr, child: const QrCodeIcon(), ) ], @@ -265,40 +404,41 @@ class _AddNewPaynymFollowViewState ), ), ), + if (!isDesktop) const SizedBox( height: 12, ), + if (!isDesktop) SecondaryButton( label: "Search", onPressed: _search, ), - if (_didSearch) - const SizedBox( - height: 20, + if (_didSearch) + const SizedBox( + height: 20, + ), + if (_didSearch && _searchResult == null) + RoundedWhiteContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Nothing found. Please check the payment code.", + style: STextStyles.label(context), + ), + ], ), - if (_didSearch && _searchResult == null) - RoundedWhiteContainer( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Nothing found. Please check the payment code.", - style: STextStyles.label(context), - ), - ], - ), + ), + if (_didSearch && _searchResult != null) + RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: PaynymCard( + label: _searchResult!.nymName, + paymentCodeString: _searchResult!.codes.first.code, + walletId: widget.walletId, ), - if (_didSearch && _searchResult != null) - RoundedWhiteContainer( - padding: const EdgeInsets.all(0), - child: PaynymCard( - label: _searchResult!.nymName, - paymentCodeString: _searchResult!.codes.first.code, - walletId: widget.walletId, - ), - ), - ], - ), + ), + ], ), ), ); diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index a0affc473..6a2f7182e 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -108,9 +108,11 @@ class _PaynymHomeViewState extends ConsumerState { cursor: SystemMouseCursors.click, child: GestureDetector( onTap: () { - Navigator.of(context).pushNamed( - AddNewPaynymFollowView.routeName, - arguments: widget.walletId, + showDialog( + context: context, + builder: (context) => AddNewPaynymFollowView( + walletId: widget.walletId, + ), ); }, child: Container( @@ -134,7 +136,7 @@ class _PaynymHomeViewState extends ConsumerState { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - "Follow", + "Add new", style: STextStyles.desktopButtonSecondaryEnabled( context) From b0b2ad14f56c21600aa0eea046f8a1c54ceeb9d2 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 12:44:35 -0600 Subject: [PATCH 038/192] featured paynyms conditional desktop modification --- .../subwidgets/featured_paynyms_widget.dart | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart index f9457374a..c848c090d 100644 --- a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart +++ b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; import 'package:stackwallet/utilities/featured_paynyms.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; class FeaturedPaynymsWidget extends StatelessWidget { @@ -15,21 +17,30 @@ class FeaturedPaynymsWidget extends StatelessWidget { @override Widget build(BuildContext context) { final entries = FeaturedPaynyms.featured.entries.toList(growable: false); + final isDesktop = Util.isDesktop; - return RoundedWhiteContainer( - padding: const EdgeInsets.all(0), + return ConditionalParent( + condition: !isDesktop, + builder: (child) => RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: child, + ), child: Column( children: [ for (int i = 0; i < entries.length; i++) Column( children: [ if (i > 0) - Container( - color: Theme.of(context) - .extension()! - .backgroundAppBar, - height: 1, - ), + isDesktop + ? const SizedBox( + height: 10, + ) + : Container( + color: Theme.of(context) + .extension()! + .backgroundAppBar, + height: 1, + ), PaynymCard( walletId: walletId, label: entries[i].key, From 07addeadd887598cf3fe611055df16917b0f7548 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 12:47:41 -0600 Subject: [PATCH 039/192] refactor paynym toggle follow button --- .../paynym_follow_toggle_button.dart | 255 ++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 lib/widgets/custom_buttons/paynym_follow_toggle_button.dart diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart new file mode 100644 index 000000000..3ac4db4b3 --- /dev/null +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -0,0 +1,255 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; +import 'package:stackwallet/models/paynym/paynym_response.dart'; +import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/providers/global/paynym_api_provider.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; + +class PaynymFollowToggleButton extends ConsumerStatefulWidget { + const PaynymFollowToggleButton({ + Key? key, + required this.walletId, + required this.paymentCodeStringToFollow, + }) : super(key: key); + + final String walletId; + final String paymentCodeStringToFollow; + + @override + ConsumerState createState() => + _PaynymFollowToggleButtonState(); +} + +class _PaynymFollowToggleButtonState + extends ConsumerState { + final isDesktop = Util.isDesktop; + + Future follow() async { + bool loadingPopped = false; + unawaited( + showDialog( + context: context, + builder: (context) => const LoadingIndicator( + width: 200, + ), + ).then( + (_) => loadingPopped = true, + ), + ); + + final wallet = ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; + + final followedAccount = await ref + .read(paynymAPIProvider) + .nym(widget.paymentCodeStringToFollow, true); + + final myPCode = await wallet.getPaymentCode(); + + PaynymResponse token = + await ref.read(paynymAPIProvider).token(myPCode.toString()); + + // sign token with notification private key + String signature = await wallet.signStringWithNotificationKey(token.value!); + + var result = await ref.read(paynymAPIProvider).follow( + token.value!, signature, followedAccount.value!.codes.first.code); + + int i = 0; + for (; + i < 10 && + result.statusCode == 401; //"401 Unauthorized - Bad signature"; + i++) { + token = await ref.read(paynymAPIProvider).token(myPCode.toString()); + + // sign token with notification private key + signature = await wallet.signStringWithNotificationKey(token.value!); + + result = await ref.read(paynymAPIProvider).follow( + token.value!, signature, followedAccount.value!.codes.first.code); + await Future.delayed(const Duration(milliseconds: 200)); + + print("RRR result: $result"); + } + + print("Follow result: $result on try $i"); + + if (result.value!.following == followedAccount.value!.nymID) { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "You are following ${followedAccount.value!.nymName}", + context: context, + ), + ); + ref.read(myPaynymAccountStateProvider.state).state!.following.add( + PaynymAccountLite( + followedAccount.value!.nymID, + followedAccount.value!.nymName, + followedAccount.value!.codes.first.code, + followedAccount.value!.codes.first.segwit, + ), + ); + + setState(() { + isFollowing = true; + }); + + return true; + } else { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Failed to follow ${followedAccount.value!.nymName}", + context: context, + ), + ); + + return false; + } + } + + Future unfollow() async { + bool loadingPopped = false; + unawaited( + showDialog( + context: context, + builder: (context) => const LoadingIndicator( + width: 200, + ), + ).then( + (_) => loadingPopped = true, + ), + ); + + final wallet = ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; + + final followedAccount = await ref + .read(paynymAPIProvider) + .nym(widget.paymentCodeStringToFollow, true); + + final myPCode = await wallet.getPaymentCode(); + + PaynymResponse token = + await ref.read(paynymAPIProvider).token(myPCode.toString()); + + // sign token with notification private key + String signature = await wallet.signStringWithNotificationKey(token.value!); + + var result = await ref.read(paynymAPIProvider).unfollow( + token.value!, signature, followedAccount.value!.codes.first.code); + + int i = 0; + for (; + i < 10 && + result.statusCode == 401; //"401 Unauthorized - Bad signature"; + i++) { + token = await ref.read(paynymAPIProvider).token(myPCode.toString()); + + // sign token with notification private key + signature = await wallet.signStringWithNotificationKey(token.value!); + + result = await ref.read(paynymAPIProvider).unfollow( + token.value!, signature, followedAccount.value!.codes.first.code); + await Future.delayed(const Duration(milliseconds: 200)); + print("unfollow RRR result: $result"); + } + + print("Unfollow result: $result on try $i"); + + if (result.value!.unfollowing == followedAccount.value!.nymID) { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "You have unfollowed ${followedAccount.value!.nymName}", + context: context, + ), + ); + ref + .read(myPaynymAccountStateProvider.state) + .state! + .following + .removeWhere((e) => e.nymId == followedAccount.value!.nymID); + + setState(() { + isFollowing = false; + }); + + return true; + } else { + if (!loadingPopped && mounted) { + Navigator.of(context).pop(); + } + + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Failed to unfollow ${followedAccount.value!.nymName}", + context: context, + ), + ); + + return false; + } + } + + bool _lock = false; + late bool isFollowing; + + @override + void initState() { + isFollowing = ref + .read(myPaynymAccountStateProvider.state) + .state! + .following + .where((e) => e.code == widget.paymentCodeStringToFollow) + .isNotEmpty; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return PrimaryButton( + width: isDesktop ? 120 : 84, + buttonHeight: ButtonHeight.l, + label: isFollowing ? "Unfollow" : "Follow", + onPressed: () async { + if (!_lock) { + _lock = true; + if (isFollowing) { + await unfollow(); + } else { + await follow(); + } + _lock = false; + } + }, + ); + } +} From 056cba2672d2338f7852a6ceabe5c0771218664b Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 13:00:25 -0600 Subject: [PATCH 040/192] desktop paynym card layout --- lib/pages/paynym/subwidgets/paynym_card.dart | 356 ++++--------------- 1 file changed, 63 insertions(+), 293 deletions(-) diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index 565bef137..5aeb8fbfc 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -1,21 +1,12 @@ -import 'dart:async'; - import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/paynym/paynym_response.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; -import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; class PaynymCard extends StatefulWidget { const PaynymCard({ @@ -34,293 +25,72 @@ class PaynymCard extends StatefulWidget { } class _PaynymCardState extends State { + final isDesktop = Util.isDesktop; + @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(12), - child: Row( - children: [ - PayNymBot( - size: 32, - paymentCodeString: widget.paymentCodeString, - ), - const SizedBox( - width: 12, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.label, - style: STextStyles.w500_12(context), - ), - const SizedBox( - height: 2, - ), - Text( - Format.shorten(widget.paymentCodeString, 12, 5), - style: STextStyles.w500_12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, + return ConditionalParent( + condition: isDesktop, + builder: (child) => RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + borderColor: + Theme.of(context).extension()!.backgroundAppBar, + child: child, + ), + child: Padding( + padding: isDesktop + ? const EdgeInsets.symmetric( + vertical: 16, + horizontal: 20, + ) + : const EdgeInsets.all(12), + child: Row( + children: [ + PayNymBot( + size: 32, + paymentCodeString: widget.paymentCodeString, + ), + const SizedBox( + width: 12, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.label, + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + ) + : STextStyles.w500_12(context), ), - ), - ], + const SizedBox( + height: 2, + ), + Text( + Format.shorten(widget.paymentCodeString, 12, 5), + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.w500_12(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ), + ], + ), ), - ), - PaynymFollowToggleButton( - walletId: widget.walletId, - paymentCodeStringToFollow: widget.paymentCodeString, - ), - // PrimaryButton( - // width: 84, - // buttonHeight: ButtonHeight.l, - // label: "Follow", - // onPressed: () { - // // todo : follow - // }, - // ) - ], - ), - ); - } -} - -class PaynymFollowToggleButton extends ConsumerStatefulWidget { - const PaynymFollowToggleButton({ - Key? key, - required this.walletId, - required this.paymentCodeStringToFollow, - }) : super(key: key); - - final String walletId; - final String paymentCodeStringToFollow; - - @override - ConsumerState createState() => - _PaynymFollowToggleButtonState(); -} - -class _PaynymFollowToggleButtonState - extends ConsumerState { - Future follow() async { - bool loadingPopped = false; - unawaited( - showDialog( - context: context, - builder: (context) => const LoadingIndicator( - width: 200, - ), - ).then( - (_) => loadingPopped = true, - ), - ); - - final wallet = ref - .read(walletsChangeNotifierProvider) - .getManager(widget.walletId) - .wallet as DogecoinWallet; - - final followedAccount = await ref - .read(paynymAPIProvider) - .nym(widget.paymentCodeStringToFollow, true); - - final myPCode = await wallet.getPaymentCode(); - - PaynymResponse token = - await ref.read(paynymAPIProvider).token(myPCode.toString()); - - // sign token with notification private key - String signature = await wallet.signStringWithNotificationKey(token.value!); - - var result = await ref.read(paynymAPIProvider).follow( - token.value!, signature, followedAccount.value!.codes.first.code); - - int i = 0; - for (; - i < 10 && - result.statusCode == 401; //"401 Unauthorized - Bad signature"; - i++) { - token = await ref.read(paynymAPIProvider).token(myPCode.toString()); - - // sign token with notification private key - signature = await wallet.signStringWithNotificationKey(token.value!); - - result = await ref.read(paynymAPIProvider).follow( - token.value!, signature, followedAccount.value!.codes.first.code); - await Future.delayed(const Duration(milliseconds: 200)); - - print("RRR result: $result"); - } - - print("Follow result: $result on try $i"); - - if (result.value!.following == followedAccount.value!.nymID) { - if (!loadingPopped && mounted) { - Navigator.of(context).pop(); - } - - unawaited( - showFloatingFlushBar( - type: FlushBarType.success, - message: "You are following ${followedAccount.value!.nymName}", - context: context, - ), - ); - ref.read(myPaynymAccountStateProvider.state).state!.following.add( - PaynymAccountLite( - followedAccount.value!.nymID, - followedAccount.value!.nymName, - followedAccount.value!.codes.first.code, - followedAccount.value!.codes.first.segwit, + PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: widget.paymentCodeString, ), - ); - - setState(() { - isFollowing = true; - }); - - return true; - } else { - if (!loadingPopped && mounted) { - Navigator.of(context).pop(); - } - - unawaited( - showFloatingFlushBar( - type: FlushBarType.warning, - message: "Failed to follow ${followedAccount.value!.nymName}", - context: context, + ], ), - ); - - return false; - } - } - - Future unfollow() async { - bool loadingPopped = false; - unawaited( - showDialog( - context: context, - builder: (context) => const LoadingIndicator( - width: 200, - ), - ).then( - (_) => loadingPopped = true, ), ); - - final wallet = ref - .read(walletsChangeNotifierProvider) - .getManager(widget.walletId) - .wallet as DogecoinWallet; - - final followedAccount = await ref - .read(paynymAPIProvider) - .nym(widget.paymentCodeStringToFollow, true); - - final myPCode = await wallet.getPaymentCode(); - - PaynymResponse token = - await ref.read(paynymAPIProvider).token(myPCode.toString()); - - // sign token with notification private key - String signature = await wallet.signStringWithNotificationKey(token.value!); - - var result = await ref.read(paynymAPIProvider).unfollow( - token.value!, signature, followedAccount.value!.codes.first.code); - - int i = 0; - for (; - i < 10 && - result.statusCode == 401; //"401 Unauthorized - Bad signature"; - i++) { - token = await ref.read(paynymAPIProvider).token(myPCode.toString()); - - // sign token with notification private key - signature = await wallet.signStringWithNotificationKey(token.value!); - - result = await ref.read(paynymAPIProvider).unfollow( - token.value!, signature, followedAccount.value!.codes.first.code); - await Future.delayed(const Duration(milliseconds: 200)); - print("unfollow RRR result: $result"); - } - - print("Unfollow result: $result on try $i"); - - if (result.value!.unfollowing == followedAccount.value!.nymID) { - if (!loadingPopped && mounted) { - Navigator.of(context).pop(); - } - - unawaited( - showFloatingFlushBar( - type: FlushBarType.success, - message: "You have unfollowed ${followedAccount.value!.nymName}", - context: context, - ), - ); - ref - .read(myPaynymAccountStateProvider.state) - .state! - .following - .removeWhere((e) => e.nymId == followedAccount.value!.nymID); - - setState(() { - isFollowing = false; - }); - - return true; - } else { - if (!loadingPopped && mounted) { - Navigator.of(context).pop(); - } - - unawaited( - showFloatingFlushBar( - type: FlushBarType.warning, - message: "Failed to unfollow ${followedAccount.value!.nymName}", - context: context, - ), - ); - - return false; - } - } - - bool _lock = false; - late bool isFollowing; - - @override - void initState() { - isFollowing = ref - .read(myPaynymAccountStateProvider.state) - .state! - .following - .where((e) => e.code == widget.paymentCodeStringToFollow) - .isNotEmpty; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return PrimaryButton( - width: 84, - buttonHeight: ButtonHeight.l, - label: isFollowing ? "Unfollow" : "Follow", - onPressed: () async { - if (!_lock) { - _lock = true; - if (isFollowing) { - await unfollow(); - } else { - await follow(); - } - _lock = false; - } - }, - ); } } From f30c82c748cffc9fffe83a9441ca8f3246a6e4a3 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 13:01:51 -0600 Subject: [PATCH 041/192] button height fix --- lib/widgets/custom_buttons/paynym_follow_toggle_button.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index 3ac4db4b3..e2a00d314 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -237,7 +237,7 @@ class _PaynymFollowToggleButtonState Widget build(BuildContext context) { return PrimaryButton( width: isDesktop ? 120 : 84, - buttonHeight: ButtonHeight.l, + buttonHeight: isDesktop ? ButtonHeight.s : ButtonHeight.l, label: isFollowing ? "Unfollow" : "Follow", onPressed: () async { if (!_lock) { From 1e3a42fd9a2b85fbd5bb95484066290f18e5a137 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 13:06:07 -0600 Subject: [PATCH 042/192] paynym not found desktop style fixes --- lib/pages/paynym/add_new_paynym_follow_view.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index bcd09659d..0329e1120 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -419,12 +419,19 @@ class _AddNewPaynymFollowViewState ), if (_didSearch && _searchResult == null) RoundedWhiteContainer( + borderColor: isDesktop + ? Theme.of(context) + .extension()! + .backgroundAppBar + : null, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Nothing found. Please check the payment code.", - style: STextStyles.label(context), + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.label(context), ), ], ), From 0e5de0d890a27e818bb7423cf8d40d376105f8a7 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 14:31:49 -0600 Subject: [PATCH 043/192] add trusted flag to node model --- lib/models/node_model.dart | 6 ++++++ lib/models/type_adaptors/node_model.g.dart | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/models/node_model.dart b/lib/models/node_model.dart index af5f8cbc1..2aeaa893b 100644 --- a/lib/models/node_model.dart +++ b/lib/models/node_model.dart @@ -26,6 +26,8 @@ class NodeModel { final bool isFailover; // @HiveField(9) final bool isDown; + // @HiveField(10) + final bool? trusted; NodeModel({ required this.host, @@ -38,6 +40,7 @@ class NodeModel { required this.isFailover, required this.isDown, this.loginName, + this.trusted, }); NodeModel copyWith({ @@ -50,6 +53,7 @@ class NodeModel { String? coinName, bool? isFailover, bool? isDown, + bool? trusted, }) { return NodeModel( host: host ?? this.host, @@ -62,6 +66,7 @@ class NodeModel { coinName: coinName ?? this.coinName, isFailover: isFailover ?? this.isFailover, isDown: isDown ?? this.isDown, + trusted: trusted ?? this.trusted, ); } @@ -82,6 +87,7 @@ class NodeModel { map['coinName'] = coinName; map['isFailover'] = isFailover; map['isDown'] = isDown; + map['trusted'] = trusted; return map; } diff --git a/lib/models/type_adaptors/node_model.g.dart b/lib/models/type_adaptors/node_model.g.dart index 580c36a75..5be8f782c 100644 --- a/lib/models/type_adaptors/node_model.g.dart +++ b/lib/models/type_adaptors/node_model.g.dart @@ -26,14 +26,15 @@ class NodeModelAdapter extends TypeAdapter { loginName: fields[5] as String?, coinName: fields[7] as String, isFailover: fields[8] as bool, - isDown: fields[8] as bool, + isDown: fields[9] as bool, + trusted: fields[10] as bool?, ); } @override void write(BinaryWriter writer, NodeModel obj) { writer - ..writeByte(10) + ..writeByte(11) ..writeByte(0) ..write(obj.id) ..writeByte(1) @@ -54,6 +55,8 @@ class NodeModelAdapter extends TypeAdapter { ..write(obj.isFailover) ..writeByte(9) ..write(obj.isDown); + ..writeByte(10) + ..write(obj.trusted); } @override From 929723d0d570ae28eaf579bc670e00c9444b59e4 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 14:46:14 -0600 Subject: [PATCH 044/192] node model fix --- lib/models/type_adaptors/node_model.g.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/models/type_adaptors/node_model.g.dart b/lib/models/type_adaptors/node_model.g.dart index 5be8f782c..597468c56 100644 --- a/lib/models/type_adaptors/node_model.g.dart +++ b/lib/models/type_adaptors/node_model.g.dart @@ -54,7 +54,7 @@ class NodeModelAdapter extends TypeAdapter { ..writeByte(8) ..write(obj.isFailover) ..writeByte(9) - ..write(obj.isDown); + ..write(obj.isDown) ..writeByte(10) ..write(obj.trusted); } From d957cad4ba2ab656e5481f1b2645d94618806390 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 14:56:36 -0600 Subject: [PATCH 045/192] add copy constructor and properly update paynym account model, as well as fix desktop navigation on follow/unfollow --- lib/models/paynym/paynym_account.dart | 16 ++++++++ .../paynym_follow_toggle_button.dart | 39 +++++++++++-------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/lib/models/paynym/paynym_account.dart b/lib/models/paynym/paynym_account.dart index 06a87ce7b..4be59dc0c 100644 --- a/lib/models/paynym/paynym_account.dart +++ b/lib/models/paynym/paynym_account.dart @@ -36,6 +36,22 @@ class PaynymAccount { PaynymAccountLite.fromMap(Map.from(e as Map))) .toList(); + PaynymAccount copyWith({ + String? nymID, + String? nymName, + List? codes, + List? followers, + List? following, + }) { + return PaynymAccount( + nymID ?? this.nymID, + nymName ?? this.nymName, + codes ?? this.codes, + followers ?? this.followers, + following ?? this.following, + ); + } + Map toMap() => { "nymID": nymID, "nymName": nymName, diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index e2a00d314..739ace1ff 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -87,7 +87,7 @@ class _PaynymFollowToggleButtonState if (result.value!.following == followedAccount.value!.nymID) { if (!loadingPopped && mounted) { - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: isDesktop).pop(); } unawaited( @@ -97,14 +97,19 @@ class _PaynymFollowToggleButtonState context: context, ), ); - ref.read(myPaynymAccountStateProvider.state).state!.following.add( - PaynymAccountLite( - followedAccount.value!.nymID, - followedAccount.value!.nymName, - followedAccount.value!.codes.first.code, - followedAccount.value!.codes.first.segwit, - ), - ); + + final myAccount = ref.read(myPaynymAccountStateProvider.state).state!; + + myAccount.following.add( + PaynymAccountLite( + followedAccount.value!.nymID, + followedAccount.value!.nymName, + followedAccount.value!.codes.first.code, + followedAccount.value!.codes.first.segwit, + ), + ); + + ref.read(myPaynymAccountStateProvider.state).state = myAccount.copyWith(); setState(() { isFollowing = true; @@ -113,7 +118,7 @@ class _PaynymFollowToggleButtonState return true; } else { if (!loadingPopped && mounted) { - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: isDesktop).pop(); } unawaited( @@ -181,7 +186,7 @@ class _PaynymFollowToggleButtonState if (result.value!.unfollowing == followedAccount.value!.nymID) { if (!loadingPopped && mounted) { - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: isDesktop).pop(); } unawaited( @@ -191,12 +196,14 @@ class _PaynymFollowToggleButtonState context: context, ), ); - ref - .read(myPaynymAccountStateProvider.state) - .state! - .following + + final myAccount = ref.read(myPaynymAccountStateProvider.state).state!; + + myAccount.following .removeWhere((e) => e.nymId == followedAccount.value!.nymID); + ref.read(myPaynymAccountStateProvider.state).state = myAccount.copyWith(); + setState(() { isFollowing = false; }); @@ -204,7 +211,7 @@ class _PaynymFollowToggleButtonState return true; } else { if (!loadingPopped && mounted) { - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: isDesktop).pop(); } unawaited( From 21cc54525124dc22e3ef230db3de6818a6062326 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 14:57:29 -0600 Subject: [PATCH 046/192] desktop paynym card clean up --- .../paynym/add_new_paynym_follow_view.dart | 5 + .../subwidgets/featured_paynyms_widget.dart | 18 ++- lib/pages/paynym/subwidgets/paynym_card.dart | 113 ++++++++---------- 3 files changed, 70 insertions(+), 66 deletions(-) diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index 0329e1120..e8e978a38 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -439,6 +439,11 @@ class _AddNewPaynymFollowViewState if (_didSearch && _searchResult != null) RoundedWhiteContainer( padding: const EdgeInsets.all(0), + borderColor: isDesktop + ? Theme.of(context) + .extension()! + .backgroundAppBar + : null, child: PaynymCard( label: _searchResult!.nymName, paymentCodeString: _searchResult!.codes.first.code, diff --git a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart index c848c090d..fcb9d1637 100644 --- a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart +++ b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart @@ -41,10 +41,20 @@ class FeaturedPaynymsWidget extends StatelessWidget { .backgroundAppBar, height: 1, ), - PaynymCard( - walletId: walletId, - label: entries[i].key, - paymentCodeString: entries[i].value, + ConditionalParent( + condition: isDesktop, + builder: (child) => RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + borderColor: Theme.of(context) + .extension()! + .backgroundAppBar, + child: child, + ), + child: PaynymCard( + walletId: walletId, + label: entries[i].key, + paymentCodeString: entries[i].value, + ), ), ], ), diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index 5aeb8fbfc..be989a588 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -4,9 +4,7 @@ import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; class PaynymCard extends StatefulWidget { const PaynymCard({ @@ -29,67 +27,58 @@ class _PaynymCardState extends State { @override Widget build(BuildContext context) { - return ConditionalParent( - condition: isDesktop, - builder: (child) => RoundedWhiteContainer( - padding: const EdgeInsets.all(0), - borderColor: - Theme.of(context).extension()!.backgroundAppBar, - child: child, - ), - child: Padding( - padding: isDesktop - ? const EdgeInsets.symmetric( - vertical: 16, - horizontal: 20, - ) - : const EdgeInsets.all(12), - child: Row( - children: [ - PayNymBot( - size: 32, - paymentCodeString: widget.paymentCodeString, + return Padding( + padding: isDesktop + ? const EdgeInsets.symmetric( + vertical: 16, + horizontal: 20, + ) + : const EdgeInsets.all(12), + child: Row( + children: [ + PayNymBot( + size: 32, + paymentCodeString: widget.paymentCodeString, + ), + const SizedBox( + width: 12, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.label, + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + ) + : STextStyles.w500_12(context), + ), + const SizedBox( + height: 2, + ), + Text( + Format.shorten(widget.paymentCodeString, 12, 5), + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.w500_12(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ), + ], ), - const SizedBox( - width: 12, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.label, - style: isDesktop - ? STextStyles.desktopTextExtraExtraSmall(context) - .copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveText, - ) - : STextStyles.w500_12(context), - ), - const SizedBox( - height: 2, - ), - Text( - Format.shorten(widget.paymentCodeString, 12, 5), - style: isDesktop - ? STextStyles.desktopTextExtraExtraSmall(context) - : STextStyles.w500_12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ), - ), - ], - ), - ), - PaynymFollowToggleButton( - walletId: widget.walletId, - paymentCodeStringToFollow: widget.paymentCodeString, - ), - ], - ), + ), + PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: widget.paymentCodeString, + ), + ], ), ); } From 3069ebeae98c3b2d49d1e5ede6b4c8a2b6ca19d7 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 15:28:48 -0600 Subject: [PATCH 047/192] followers/following paynym lists --- lib/pages/paynym/paynym_home_view.dart | 59 ++++---- .../subwidgets/paynym_followers_list.dart | 126 ++++++++++++++++++ .../subwidgets/paynym_following_list.dart | 126 ++++++++++++++++++ 3 files changed, 282 insertions(+), 29 deletions(-) create mode 100644 lib/pages/paynym/subwidgets/paynym_followers_list.dart create mode 100644 lib/pages/paynym/subwidgets/paynym_following_list.dart diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 6a2f7182e..519865c24 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -8,6 +8,8 @@ import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_followers_list.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_following_list.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -41,7 +43,7 @@ class PaynymHomeView extends ConsumerStatefulWidget { } class _PaynymHomeViewState extends ConsumerState { - bool showFollowing = false; + bool showFollowers = false; int secretCount = 0; Timer? timer; @@ -521,15 +523,17 @@ class _PaynymHomeViewState extends ConsumerState { width: isDesktop ? 490 : null, child: Toggle( onColor: Theme.of(context).extension()!.popupBG, - onText: "Following", + onText: + "Following (${ref.watch(myPaynymAccountStateProvider.state).state?.following.length ?? 0})", offColor: Theme.of(context) .extension()! .textFieldDefaultBG, - offText: "Followers", - isOn: showFollowing, + offText: + "Followers (${ref.watch(myPaynymAccountStateProvider.state).state?.followers.length ?? 0})", + isOn: showFollowers, onValueChanged: (value) { setState(() { - showFollowing = value; + showFollowers = value; }); }, decoration: BoxDecoration( @@ -544,31 +548,28 @@ class _PaynymHomeViewState extends ConsumerState { SizedBox( height: isDesktop ? 20 : 16, ), - ConditionalParent( - condition: isDesktop, - builder: (child) => Padding( - padding: const EdgeInsets.only(left: 24), - child: SizedBox( - width: 490, - child: child, + Expanded( + child: ConditionalParent( + condition: isDesktop, + builder: (child) => Padding( + padding: const EdgeInsets.only(left: 24), + child: SizedBox( + width: 490, + child: child, + ), ), - ), - child: RoundedWhiteContainer( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Your PayNym contacts will appear here", - style: isDesktop - ? STextStyles.desktopTextExtraExtraSmall(context) - .copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ) - : STextStyles.label(context), - ), - ], + child: ConditionalParent( + condition: !isDesktop, + builder: (child) => Container( + child: child, + ), + child: !showFollowers + ? PaynymFollowingList( + walletId: widget.walletId, + ) + : PaynymFollowersList( + walletId: widget.walletId, + ), ), ), ), diff --git a/lib/pages/paynym/subwidgets/paynym_followers_list.dart b/lib/pages/paynym/subwidgets/paynym_followers_list.dart new file mode 100644 index 000000000..b0fed7b78 --- /dev/null +++ b/lib/pages/paynym/subwidgets/paynym_followers_list.dart @@ -0,0 +1,126 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class PaynymFollowersList extends ConsumerStatefulWidget { + const PaynymFollowersList({ + Key? key, + required this.walletId, + }) : super(key: key); + + final String walletId; + + @override + ConsumerState createState() => + _PaynymFollowersListState(); +} + +class _PaynymFollowersListState extends ConsumerState { + final isDesktop = Util.isDesktop; + + BorderRadius get _borderRadiusFirst { + return BorderRadius.only( + topLeft: Radius.circular( + Constants.size.circularBorderRadius, + ), + topRight: Radius.circular( + Constants.size.circularBorderRadius, + ), + ); + } + + BorderRadius get _borderRadiusLast { + return BorderRadius.only( + bottomLeft: Radius.circular( + Constants.size.circularBorderRadius, + ), + bottomRight: Radius.circular( + Constants.size.circularBorderRadius, + ), + ); + } + + @override + Widget build(BuildContext context) { + final count = + ref.watch(myPaynymAccountStateProvider.state).state?.followers.length ?? + 0; + if (count == 0) { + return Column( + children: [ + RoundedWhiteContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Your PayNym followers will appear here", + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ) + : STextStyles.label(context), + ), + ], + ), + ), + ], + ); + } else { + final followers = + ref.watch(myPaynymAccountStateProvider.state).state!.followers; + + if (count == 1) { + return Column( + children: [ + RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: PaynymCard( + walletId: widget.walletId, + label: followers[0].nymName, + paymentCodeString: followers[0].code, + ), + ), + ], + ); + } else { + return ListView.separated( + itemCount: count, + separatorBuilder: (BuildContext context, int index) => Container( + height: 1.5, + color: Colors.transparent, + ), + itemBuilder: (BuildContext context, int index) { + BorderRadius? borderRadius; + if (index == 0) { + borderRadius = _borderRadiusFirst; + } else if (index == count - 1) { + borderRadius = _borderRadiusLast; + } + + return Container( + key: Key("paynymCardKey_${followers[index].nymId}"), + decoration: BoxDecoration( + borderRadius: borderRadius, + color: Theme.of(context).extension()!.popupBG, + ), + child: PaynymCard( + walletId: widget.walletId, + label: followers[index].nymName, + paymentCodeString: followers[index].code, + ), + ); + }, + ); + } + } + } +} diff --git a/lib/pages/paynym/subwidgets/paynym_following_list.dart b/lib/pages/paynym/subwidgets/paynym_following_list.dart new file mode 100644 index 000000000..5ab0c19b5 --- /dev/null +++ b/lib/pages/paynym/subwidgets/paynym_following_list.dart @@ -0,0 +1,126 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; +import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class PaynymFollowingList extends ConsumerStatefulWidget { + const PaynymFollowingList({ + Key? key, + required this.walletId, + }) : super(key: key); + + final String walletId; + + @override + ConsumerState createState() => + _PaynymFollowingListState(); +} + +class _PaynymFollowingListState extends ConsumerState { + final isDesktop = Util.isDesktop; + + BorderRadius get _borderRadiusFirst { + return BorderRadius.only( + topLeft: Radius.circular( + Constants.size.circularBorderRadius, + ), + topRight: Radius.circular( + Constants.size.circularBorderRadius, + ), + ); + } + + BorderRadius get _borderRadiusLast { + return BorderRadius.only( + bottomLeft: Radius.circular( + Constants.size.circularBorderRadius, + ), + bottomRight: Radius.circular( + Constants.size.circularBorderRadius, + ), + ); + } + + @override + Widget build(BuildContext context) { + final count = + ref.watch(myPaynymAccountStateProvider.state).state?.following.length ?? + 0; + if (count == 0) { + return Column( + children: [ + RoundedWhiteContainer( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Your PayNym contacts will appear here", + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ) + : STextStyles.label(context), + ), + ], + ), + ), + ], + ); + } else { + final following = + ref.watch(myPaynymAccountStateProvider.state).state!.following; + + if (count == 1) { + return Column( + children: [ + RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: PaynymCard( + walletId: widget.walletId, + label: following[0].nymName, + paymentCodeString: following[0].code, + ), + ), + ], + ); + } else { + return ListView.separated( + itemCount: count, + separatorBuilder: (BuildContext context, int index) => Container( + height: 1.5, + color: Colors.transparent, + ), + itemBuilder: (BuildContext context, int index) { + BorderRadius? borderRadius; + if (index == 0) { + borderRadius = _borderRadiusFirst; + } else if (index == count - 1) { + borderRadius = _borderRadiusLast; + } + + return Container( + key: Key("paynymCardKey_${following[index].nymId}"), + decoration: BoxDecoration( + borderRadius: borderRadius, + color: Theme.of(context).extension()!.popupBG, + ), + child: PaynymCard( + walletId: widget.walletId, + label: following[index].nymName, + paymentCodeString: following[index].code, + ), + ); + }, + ); + } + } + } +} From 8c0366904ab1beda2e8783bd7aa76faac6e915d8 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 4 Jan 2023 16:01:26 -0600 Subject: [PATCH 048/192] followers/following paynym lists clean up --- .../paynym/add_new_paynym_follow_view.dart | 4 +- lib/pages/paynym/paynym_home_view.dart | 2 +- .../subwidgets/paynym_followers_list.dart | 102 ++++++++---------- .../subwidgets/paynym_following_list.dart | 102 ++++++++---------- 4 files changed, 95 insertions(+), 115 deletions(-) diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index e8e978a38..b5c1ba85e 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -165,7 +165,7 @@ class _AddNewPaynymFollowViewState ), titleSpacing: 0, title: Text( - "Add new", + "New follow", style: STextStyles.navBarTitle(context), overflow: TextOverflow.ellipsis, ), @@ -201,7 +201,7 @@ class _AddNewPaynymFollowViewState Padding( padding: const EdgeInsets.only(left: 32), child: Text( - "Add new", + "New follow", style: STextStyles.desktopH3(context), ), ), diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 519865c24..ba12e517f 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -138,7 +138,7 @@ class _PaynymHomeViewState extends ConsumerState { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - "Add new", + "Follow", style: STextStyles.desktopButtonSecondaryEnabled( context) diff --git a/lib/pages/paynym/subwidgets/paynym_followers_list.dart b/lib/pages/paynym/subwidgets/paynym_followers_list.dart index b0fed7b78..8c58de3ce 100644 --- a/lib/pages/paynym/subwidgets/paynym_followers_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_followers_list.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; @@ -48,13 +50,19 @@ class _PaynymFollowersListState extends ConsumerState { @override Widget build(BuildContext context) { - final count = - ref.watch(myPaynymAccountStateProvider.state).state?.followers.length ?? - 0; - if (count == 0) { - return Column( - children: [ - RoundedWhiteContainer( + final followers = + ref.watch(myPaynymAccountStateProvider.state).state?.followers; + final count = followers?.length ?? 0; + + return ListView.separated( + itemCount: max(count, 1), + separatorBuilder: (BuildContext context, int index) => Container( + height: 1.5, + color: Colors.transparent, + ), + itemBuilder: (BuildContext context, int index) { + if (count == 0) { + return RoundedWhiteContainer( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -71,56 +79,38 @@ class _PaynymFollowersListState extends ConsumerState { ), ], ), - ), - ], - ); - } else { - final followers = - ref.watch(myPaynymAccountStateProvider.state).state!.followers; - - if (count == 1) { - return Column( - children: [ - RoundedWhiteContainer( - padding: const EdgeInsets.all(0), - child: PaynymCard( - walletId: widget.walletId, - label: followers[0].nymName, - paymentCodeString: followers[0].code, - ), + ); + } else if (count == 1) { + return RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: PaynymCard( + walletId: widget.walletId, + label: followers![0].nymName, + paymentCodeString: followers[0].code, ), - ], - ); - } else { - return ListView.separated( - itemCount: count, - separatorBuilder: (BuildContext context, int index) => Container( - height: 1.5, - color: Colors.transparent, - ), - itemBuilder: (BuildContext context, int index) { - BorderRadius? borderRadius; - if (index == 0) { - borderRadius = _borderRadiusFirst; - } else if (index == count - 1) { - borderRadius = _borderRadiusLast; - } + ); + } else { + BorderRadius? borderRadius; + if (index == 0) { + borderRadius = _borderRadiusFirst; + } else if (index == count - 1) { + borderRadius = _borderRadiusLast; + } - return Container( - key: Key("paynymCardKey_${followers[index].nymId}"), - decoration: BoxDecoration( - borderRadius: borderRadius, - color: Theme.of(context).extension()!.popupBG, - ), - child: PaynymCard( - walletId: widget.walletId, - label: followers[index].nymName, - paymentCodeString: followers[index].code, - ), - ); - }, - ); - } - } + return Container( + key: Key("paynymCardKey_${followers![index].nymId}"), + decoration: BoxDecoration( + borderRadius: borderRadius, + color: Theme.of(context).extension()!.popupBG, + ), + child: PaynymCard( + walletId: widget.walletId, + label: followers[index].nymName, + paymentCodeString: followers[index].code, + ), + ); + } + }, + ); } } diff --git a/lib/pages/paynym/subwidgets/paynym_following_list.dart b/lib/pages/paynym/subwidgets/paynym_following_list.dart index 5ab0c19b5..76c4dbbfb 100644 --- a/lib/pages/paynym/subwidgets/paynym_following_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_following_list.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; @@ -48,13 +50,19 @@ class _PaynymFollowingListState extends ConsumerState { @override Widget build(BuildContext context) { - final count = - ref.watch(myPaynymAccountStateProvider.state).state?.following.length ?? - 0; - if (count == 0) { - return Column( - children: [ - RoundedWhiteContainer( + final following = + ref.watch(myPaynymAccountStateProvider.state).state?.following; + final count = following?.length ?? 0; + + return ListView.separated( + itemCount: max(count, 1), + separatorBuilder: (BuildContext context, int index) => Container( + height: 1.5, + color: Colors.transparent, + ), + itemBuilder: (BuildContext context, int index) { + if (count == 0) { + return RoundedWhiteContainer( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -71,56 +79,38 @@ class _PaynymFollowingListState extends ConsumerState { ), ], ), - ), - ], - ); - } else { - final following = - ref.watch(myPaynymAccountStateProvider.state).state!.following; - - if (count == 1) { - return Column( - children: [ - RoundedWhiteContainer( - padding: const EdgeInsets.all(0), - child: PaynymCard( - walletId: widget.walletId, - label: following[0].nymName, - paymentCodeString: following[0].code, - ), + ); + } else if (count == 1) { + return RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: PaynymCard( + walletId: widget.walletId, + label: following![0].nymName, + paymentCodeString: following[0].code, ), - ], - ); - } else { - return ListView.separated( - itemCount: count, - separatorBuilder: (BuildContext context, int index) => Container( - height: 1.5, - color: Colors.transparent, - ), - itemBuilder: (BuildContext context, int index) { - BorderRadius? borderRadius; - if (index == 0) { - borderRadius = _borderRadiusFirst; - } else if (index == count - 1) { - borderRadius = _borderRadiusLast; - } + ); + } else { + BorderRadius? borderRadius; + if (index == 0) { + borderRadius = _borderRadiusFirst; + } else if (index == count - 1) { + borderRadius = _borderRadiusLast; + } - return Container( - key: Key("paynymCardKey_${following[index].nymId}"), - decoration: BoxDecoration( - borderRadius: borderRadius, - color: Theme.of(context).extension()!.popupBG, - ), - child: PaynymCard( - walletId: widget.walletId, - label: following[index].nymName, - paymentCodeString: following[index].code, - ), - ); - }, - ); - } - } + return Container( + key: Key("paynymCardKey_${following![index].nymId}"), + decoration: BoxDecoration( + borderRadius: borderRadius, + color: Theme.of(context).extension()!.popupBG, + ), + child: PaynymCard( + walletId: widget.walletId, + label: following[index].nymName, + paymentCodeString: following[index].code, + ), + ); + } + }, + ); } } From 915458dbf3ad295f72b2d770f4b5c41018e2ee24 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 5 Jan 2023 12:48:18 -0600 Subject: [PATCH 049/192] dirty WIP notification tx creation --- lib/services/coins/coin_paynym_extension.dart | 207 ++++++++++ .../coins/dogecoin/dogecoin_wallet.dart | 360 +++++++++--------- 2 files changed, 393 insertions(+), 174 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 764e69729..22d8edb0b 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -2,12 +2,19 @@ import 'dart:convert'; import 'dart:typed_data'; import 'package:bip47/bip47.dart'; +import 'package:bip47/src/util.dart'; import 'package:bitcoindart/bitcoindart.dart'; +import 'package:bitcoindart/src/utils/constants/op.dart' as op; +import 'package:bitcoindart/src/utils/script.dart' as bscript; +import 'package:decimal/decimal.dart'; import 'package:pointycastle/digests/sha256.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/models/paymint/utxo_model.dart'; + extension PayNym on DogecoinWallet { // fetch or generate this wallet's bip47 payment code Future getPaymentCode() async { @@ -48,4 +55,204 @@ extension PayNym on DogecoinWallet { // Future> prepareNotificationTransaction( // String targetPaymentCode) async {} + + Future createNotificationTx( + String targetPaymentCodeString, + List utxosToUse, + ) async { + final utxoSigningData = await fetchBuildTxData(utxosToUse); + final targetPaymentCode = + PaymentCode.fromPaymentCode(targetPaymentCodeString, network); + final myCode = await getPaymentCode(); + + final utxo = utxosToUse.first; + final txPoint = utxo.txid.fromHex.toList(); + final txPointIndex = utxo.vout; + + final rev = Uint8List(txPoint.length + 4); + Util.copyBytes(Uint8List.fromList(txPoint), 0, rev, 0, txPoint.length); + final buffer = rev.buffer.asByteData(); + buffer.setUint32(txPoint.length, txPointIndex, Endian.little); + + final myKeyPair = utxoSigningData[utxo.txid]["keyPair"] as ECPair; + + final S = SecretPoint( + myKeyPair.privateKey!, + targetPaymentCode.notificationPublicKey(), + ); + + final blindingMask = PaymentCode.getMask(S.ecdhSecret(), rev); + + final blindedPaymentCode = PaymentCode.blind( + myCode.getPayload(), + blindingMask, + ); + + final opReturnScript = bscript.compile([ + (op.OPS["OP_RETURN"] as int), + blindedPaymentCode, + ]); + + final bobP2PKH = P2PKH( + data: PaymentData( + pubkey: targetPaymentCode.notificationPublicKey(), + ), + ).data; + final notificationScript = bscript.compile([bobP2PKH.output]); + + // build a notification tx + final txb = TransactionBuilder(); + txb.setVersion(1); + + txb.addInput( + "9c6000d597c5008f7bfc2618aed5e4a6ae57677aab95078aae708e1cab11f486", + txPointIndex, + ); + + txb.addOutput(targetPaymentCode.notificationAddress(), + Format.decimalAmountToSatoshis(Decimal.one, coin)); + txb.addOutput( + opReturnScript, Format.decimalAmountToSatoshis(Decimal.one, coin)); + + txb.sign( + vin: 0, + keyPair: myKeyPair, + ); + + final builtTx = txb.build(); + + return builtTx.toHex(); + } +} + +Future> parseTransaction( + Map txData, + dynamic electrumxClient, + Set myAddresses, + Set myChangeAddresses, + Coin coin, + int minConfirms, + Decimal currentPrice, +) async { + Set inputAddresses = {}; + Set outputAddresses = {}; + + int totalInputValue = 0; + int totalOutputValue = 0; + + int amountSentFromWallet = 0; + int amountReceivedInWallet = 0; + + // parse inputs + for (final input in txData["vin"] as List) { + final prevTxid = input["txid"] as String; + final prevOut = input["vout"] as int; + + // fetch input tx to get address + final inputTx = await electrumxClient.getTransaction( + txHash: prevTxid, + coin: coin, + ); + + for (final output in inputTx["vout"] as List) { + // check matching output + if (prevOut == output["n"]) { + // get value + final value = Format.decimalAmountToSatoshis( + Decimal.parse(output["value"].toString()), + coin, + ); + + // add value to total + totalInputValue += value; + + // get input(prevOut) address + final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? + output["scriptPubKey"]?["address"] as String?; + if (address != null) { + inputAddresses.add(address); + + // if input was from my wallet, add value to amount sent + if (myAddresses.contains(address)) { + amountSentFromWallet += value; + } + } + } + } + } + + // parse outputs + for (final output in txData["vout"] as List) { + // get value + final value = Format.decimalAmountToSatoshis( + Decimal.parse(output["value"].toString()), + coin, + ); + + // add value to total + totalOutputValue += value; + + // get output address + final address = output["scriptPubKey"]["addresses"][0] as String? ?? + output["scriptPubKey"]["address"] as String?; + if (address != null) { + outputAddresses.add(address); + + // if output was from my wallet, add value to amount received + if (myAddresses.contains(address)) { + amountReceivedInWallet += value; + } + } + } + + final mySentFromAddresses = myAddresses.intersection(inputAddresses); + final myReceivedOnAddresses = myAddresses.intersection(outputAddresses); + + final fee = totalInputValue - totalOutputValue; + + // create normalized tx data map + Map normalizedTx = {}; + + final int confirms = txData["confirmations"] as int? ?? 0; + + normalizedTx["txid"] = txData["txid"] as String; + normalizedTx["confirmed_status"] = confirms >= minConfirms; + normalizedTx["confirmations"] = confirms; + normalizedTx["timestamp"] = txData["blocktime"] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000); + normalizedTx["aliens"] = []; + normalizedTx["fees"] = fee; + normalizedTx["address"] = txData["address"] as String; + normalizedTx["inputSize"] = txData["vin"].length; + normalizedTx["outputSize"] = txData["vout"].length; + normalizedTx["inputs"] = txData["vin"]; + normalizedTx["outputs"] = txData["vout"]; + normalizedTx["height"] = txData["height"] as int; + + int amount; + String type; + if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { + // tx is sent to self + type = "Sent to self"; + amount = amountReceivedInWallet - amountSentFromWallet; + } else if (mySentFromAddresses.isNotEmpty) { + // outgoing tx + type = "Sent"; + amount = amountSentFromWallet; + } else { + // incoming tx + type = "Received"; + amount = amountReceivedInWallet; + } + + normalizedTx["txType"] = type; + normalizedTx["amount"] = amount; + normalizedTx["worthNow"] = (Format.satoshisToAmount( + amount, + coin: coin, + ) * + currentPrice) + .toStringAsFixed(2); + + return normalizedTx; } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 349609f18..3a5c9fb99 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -20,6 +20,7 @@ import 'package:stackwallet/models/models.dart' as models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/models/paymint/transactions_model.dart'; import 'package:stackwallet/models/paymint/utxo_model.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.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/refresh_percent_changed_event.dart'; @@ -1063,7 +1064,8 @@ class DogecoinWallet extends CoinServiceAPI { final priceData = await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; final String worthNow = Format.localizedStringAsFixed( value: ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / @@ -2091,180 +2093,190 @@ class DogecoinWallet extends CoinServiceAPI { await fastFetch(vHashes.toList()); for (final txObject in allTransactions) { - List sendersArray = []; - List recipientsArray = []; + // List sendersArray = []; + // List recipientsArray = []; + // + // // Usually only has value when txType = 'Send' + // int inputAmtSentFromWallet = 0; + // // Usually has value regardless of txType due to change addresses + // int outputAmtAddressedToWallet = 0; + // int fee = 0; + // + // Map midSortedTx = {}; + // + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"][i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, coin: coin); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // final address = out["scriptPubKey"]["addresses"][0] as String?; + // if (address != null) { + // sendersArray.add(address); + // } + // } + // } + // } + // + // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); + // + // for (final output in txObject["vout"] as List) { + // final address = output["scriptPubKey"]["addresses"][0] as String?; + // if (address != null) { + // recipientsArray.add(address); + // } + // } + // + // Logging.instance + // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); + // + // final foundInSenders = + // allAddresses.any((element) => sendersArray.contains(element)); + // Logging.instance + // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); + // + // // If txType = Sent, then calculate inputAmtSentFromWallet + // if (foundInSenders) { + // int totalInput = 0; + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"][i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // inputAmtSentFromWallet += + // (Decimal.parse(out["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // totalInput = inputAmtSentFromWallet; + // int totalOutput = 0; + // + // for (final output in txObject["vout"] as List) { + // final address = output["scriptPubKey"]["addresses"][0]; + // final value = output["value"]; + // final _value = (Decimal.parse(value.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOutput += _value; + // if (changeAddressesP2PKH.contains(address)) { + // inputAmtSentFromWallet -= _value; + // } else { + // // change address from 'sent from' to the 'sent to' address + // txObject["address"] = address; + // } + // } + // // calculate transaction fee + // fee = totalInput - totalOutput; + // // subtract fee from sent to calculate correct value of sent tx + // inputAmtSentFromWallet -= fee; + // } else { + // // counters for fee calculation + // int totalOut = 0; + // int totalIn = 0; + // + // // add up received tx value + // for (final output in txObject["vout"] as List) { + // final address = output["scriptPubKey"]["addresses"][0]; + // if (address != null) { + // final value = (Decimal.parse(output["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOut += value; + // if (allAddresses.contains(address)) { + // outputAmtAddressedToWallet += value; + // } + // } + // } + // + // // calculate fee for received tx + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"][i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // totalIn += (Decimal.parse(out["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // fee = totalIn - totalOut; + // } + // + // // create final tx map + // midSortedTx["txid"] = txObject["txid"]; + // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && + // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); + // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; + // midSortedTx["timestamp"] = txObject["blocktime"] ?? + // (DateTime.now().millisecondsSinceEpoch ~/ 1000); + // + // if (foundInSenders) { + // midSortedTx["txType"] = "Sent"; + // midSortedTx["amount"] = inputAmtSentFromWallet; + // final String worthNow = + // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // midSortedTx["worthAtBlockTimestamp"] = worthNow; + // } else { + // midSortedTx["txType"] = "Received"; + // midSortedTx["amount"] = outputAmtAddressedToWallet; + // final worthNow = + // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // } + // midSortedTx["aliens"] = []; + // midSortedTx["fees"] = fee; + // midSortedTx["address"] = txObject["address"]; + // midSortedTx["inputSize"] = txObject["vin"].length; + // midSortedTx["outputSize"] = txObject["vout"].length; + // midSortedTx["inputs"] = txObject["vin"]; + // midSortedTx["outputs"] = txObject["vout"]; + // + // final int height = txObject["height"] as int; + // midSortedTx["height"] = height; + // + // if (height >= latestTxnBlockHeight) { + // latestTxnBlockHeight = height; + // } - // Usually only has value when txType = 'Send' - int inputAmtSentFromWallet = 0; - // Usually has value regardless of txType due to change addresses - int outputAmtAddressedToWallet = 0; - int fee = 0; - - Map midSortedTx = {}; - - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, coin: coin); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - final address = out["scriptPubKey"]["addresses"][0] as String?; - if (address != null) { - sendersArray.add(address); - } - } - } - } - - Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0] as String?; - if (address != null) { - recipientsArray.add(address); - } - } - - Logging.instance - .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - - final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)); - Logging.instance - .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - - // If txType = Sent, then calculate inputAmtSentFromWallet - if (foundInSenders) { - int totalInput = 0; - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - inputAmtSentFromWallet += - (Decimal.parse(out["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - totalInput = inputAmtSentFromWallet; - int totalOutput = 0; - - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0]; - final value = output["value"]; - final _value = (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOutput += _value; - if (changeAddressesP2PKH.contains(address)) { - inputAmtSentFromWallet -= _value; - } else { - // change address from 'sent from' to the 'sent to' address - txObject["address"] = address; - } - } - // calculate transaction fee - fee = totalInput - totalOutput; - // subtract fee from sent to calculate correct value of sent tx - inputAmtSentFromWallet -= fee; - } else { - // counters for fee calculation - int totalOut = 0; - int totalIn = 0; - - // add up received tx value - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0]; - if (address != null) { - final value = (Decimal.parse(output["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOut += value; - if (allAddresses.contains(address)) { - outputAmtAddressedToWallet += value; - } - } - } - - // calculate fee for received tx - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - totalIn += (Decimal.parse(out["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - fee = totalIn - totalOut; - } - - // create final tx map - midSortedTx["txid"] = txObject["txid"]; - midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - midSortedTx["timestamp"] = txObject["blocktime"] ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000); - - if (foundInSenders) { - midSortedTx["txType"] = "Sent"; - midSortedTx["amount"] = inputAmtSentFromWallet; - final String worthNow = - ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - } else { - midSortedTx["txType"] = "Received"; - midSortedTx["amount"] = outputAmtAddressedToWallet; - final worthNow = - ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - } - midSortedTx["aliens"] = []; - midSortedTx["fees"] = fee; - midSortedTx["address"] = txObject["address"]; - midSortedTx["inputSize"] = txObject["vin"].length; - midSortedTx["outputSize"] = txObject["vout"].length; - midSortedTx["inputs"] = txObject["vin"]; - midSortedTx["outputs"] = txObject["vout"]; - - final int height = txObject["height"] as int; - midSortedTx["height"] = height; - - if (height >= latestTxnBlockHeight) { - latestTxnBlockHeight = height; - } + final midSortedTx = await parseTransaction( + txObject, + cachedElectrumXClient, + allAddresses.toSet(), + (changeAddressesP2PKH as List).toSet(), + coin, + MINIMUM_CONFIRMATIONS, + currentPrice, + ); midSortedArray.add(midSortedTx); } From 3d6d3d5d455cef39297bc36d617949729153ca49 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 5 Jan 2023 12:52:14 -0600 Subject: [PATCH 050/192] tx list styling fix for single tx --- .../wallet_view/sub_widgets/transactions_list.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index 704a4e3d8..667d46aae 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -247,7 +247,11 @@ class _TransactionsListState extends ConsumerState { ? ListView.separated( itemBuilder: (context, index) { BorderRadius? radius; - if (index == list.length - 1) { + if (list.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == list.length - 1) { radius = _borderRadiusLast; } else if (index == 0) { radius = _borderRadiusFirst; @@ -270,7 +274,11 @@ class _TransactionsListState extends ConsumerState { itemCount: list.length, itemBuilder: (context, index) { BorderRadius? radius; - if (index == list.length - 1) { + if (list.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == list.length - 1) { radius = _borderRadiusLast; } else if (index == 0) { radius = _borderRadiusFirst; From ca4cdd40c0a404633090ab00af810e32c7704240 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 5 Jan 2023 16:19:02 -0600 Subject: [PATCH 051/192] paynym card refactor and paynym details popup for mobile WIP --- .../paynym/dialogs/paynym_details_popup.dart | 195 ++++++++++++++++++ .../paynym/subwidgets/paynym_card_button.dart | 102 +++++++++ .../subwidgets/paynym_followers_list.dart | 12 +- .../subwidgets/paynym_following_list.dart | 12 +- .../paynym_follow_toggle_button.dart | 63 ++++-- 5 files changed, 354 insertions(+), 30 deletions(-) create mode 100644 lib/pages/paynym/dialogs/paynym_details_popup.dart create mode 100644 lib/pages/paynym/subwidgets/paynym_card_button.dart diff --git a/lib/pages/paynym/dialogs/paynym_details_popup.dart b/lib/pages/paynym/dialogs/paynym_details_popup.dart new file mode 100644 index 000000000..1e50723e6 --- /dev/null +++ b/lib/pages/paynym/dialogs/paynym_details_popup.dart @@ -0,0 +1,195 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:qr_flutter/qr_flutter.dart'; +import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; +import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; + +class PaynymDetailsPopup extends StatefulWidget { + const PaynymDetailsPopup({ + Key? key, + required this.walletId, + required this.accountLite, + }) : super(key: key); + + final String walletId; + final PaynymAccountLite accountLite; + + @override + State createState() => _PaynymDetailsPopupState(); +} + +class _PaynymDetailsPopupState extends State { + @override + Widget build(BuildContext context) { + return DesktopDialog( + maxWidth: MediaQuery.of(context).size.width - 32, + maxHeight: double.infinity, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 24, + top: 24, + right: 24, + bottom: 16, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + PayNymBot( + paymentCodeString: widget.accountLite.code, + size: 32, + ), + const SizedBox( + width: 12, + ), + Text( + widget.accountLite.nymName, + style: STextStyles.w600_12(context), + ), + ], + ), + PrimaryButton( + label: "Connect", + buttonHeight: ButtonHeight.l, + icon: SvgPicture.asset( + Assets.svg.circlePlusFilled, + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .buttonTextPrimary, + ), + iconSpacing: 4, + width: 86, + onPressed: () { + // todo notification tx + }, + ), + ], + ), + ), + Container( + color: Theme.of(context).extension()!.backgroundAppBar, + height: 1, + ), + Padding( + padding: const EdgeInsets.only( + left: 24, + top: 16, + right: 24, + bottom: 16, + ), + child: Row( + children: [ + Expanded( + child: ConstrainedBox( + constraints: const BoxConstraints(minHeight: 86), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "PayNym address", + style: STextStyles.infoSmall(context), + ), + const SizedBox( + height: 6, + ), + Text( + widget.accountLite.code, + style: STextStyles.infoSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + const SizedBox( + height: 6, + ), + ], + ), + ), + ), + const SizedBox( + width: 20, + ), + QrImage( + padding: const EdgeInsets.all(0), + size: 86, + data: widget.accountLite.code, + foregroundColor: + Theme.of(context).extension()!.textDark, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 24, + right: 24, + bottom: 24, + ), + child: Row( + children: [ + Expanded( + child: PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: widget.accountLite.code, + style: PaynymFollowToggleButtonStyle.detailsPopup, + ), + ), + const SizedBox( + width: 12, + ), + Expanded( + child: SecondaryButton( + label: "Copy", + buttonHeight: ButtonHeight.l, + icon: SvgPicture.asset( + Assets.svg.copy, + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .buttonTextSecondary, + ), + iconSpacing: 4, + onPressed: () async { + await Clipboard.setData( + ClipboardData( + text: widget.accountLite.code, + ), + ); + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: "Copied to clipboard", + iconAsset: Assets.svg.copy, + context: context, + ), + ); + }, + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/paynym/subwidgets/paynym_card_button.dart b/lib/pages/paynym/subwidgets/paynym_card_button.dart new file mode 100644 index 000000000..f69700b87 --- /dev/null +++ b/lib/pages/paynym/subwidgets/paynym_card_button.dart @@ -0,0 +1,102 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; +import 'package:stackwallet/pages/paynym/dialogs/paynym_details_popup.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; + +class PaynymCardButton extends StatefulWidget { + const PaynymCardButton({ + Key? key, + required this.walletId, + required this.accountLite, + }) : super(key: key); + + final String walletId; + final PaynymAccountLite accountLite; + + @override + State createState() => _PaynymCardButtonState(); +} + +class _PaynymCardButtonState extends State { + final isDesktop = Util.isDesktop; + + @override + Widget build(BuildContext context) { + return Padding( + padding: isDesktop + ? const EdgeInsets.symmetric( + vertical: 8, + horizontal: 12, + ) + : const EdgeInsets.all(4), + child: RawMaterialButton( + padding: const EdgeInsets.all(0), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + onPressed: () { + showDialog( + context: context, + builder: (context) => PaynymDetailsPopup( + accountLite: widget.accountLite, + walletId: widget.walletId, + ), + ); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + PayNymBot( + size: 32, + paymentCodeString: widget.accountLite.code, + ), + const SizedBox( + width: 12, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.accountLite.nymName, + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + ) + : STextStyles.w500_12(context), + ), + const SizedBox( + height: 2, + ), + Text( + Format.shorten(widget.accountLite.code, 12, 5), + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.w500_12(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/paynym/subwidgets/paynym_followers_list.dart b/lib/pages/paynym/subwidgets/paynym_followers_list.dart index 8c58de3ce..dbec19692 100644 --- a/lib/pages/paynym/subwidgets/paynym_followers_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_followers_list.dart @@ -2,7 +2,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_card_button.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -83,10 +83,9 @@ class _PaynymFollowersListState extends ConsumerState { } else if (count == 1) { return RoundedWhiteContainer( padding: const EdgeInsets.all(0), - child: PaynymCard( + child: PaynymCardButton( walletId: widget.walletId, - label: followers![0].nymName, - paymentCodeString: followers[0].code, + accountLite: followers![0], ), ); } else { @@ -103,10 +102,9 @@ class _PaynymFollowersListState extends ConsumerState { borderRadius: borderRadius, color: Theme.of(context).extension()!.popupBG, ), - child: PaynymCard( + child: PaynymCardButton( walletId: widget.walletId, - label: followers[index].nymName, - paymentCodeString: followers[index].code, + accountLite: followers[index], ), ); } diff --git a/lib/pages/paynym/subwidgets/paynym_following_list.dart b/lib/pages/paynym/subwidgets/paynym_following_list.dart index 76c4dbbfb..754fd6a45 100644 --- a/lib/pages/paynym/subwidgets/paynym_following_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_following_list.dart @@ -2,7 +2,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_card_button.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -83,10 +83,9 @@ class _PaynymFollowingListState extends ConsumerState { } else if (count == 1) { return RoundedWhiteContainer( padding: const EdgeInsets.all(0), - child: PaynymCard( + child: PaynymCardButton( walletId: widget.walletId, - label: following![0].nymName, - paymentCodeString: following[0].code, + accountLite: following![0], ), ); } else { @@ -103,10 +102,9 @@ class _PaynymFollowingListState extends ConsumerState { borderRadius: borderRadius, color: Theme.of(context).extension()!.popupBG, ), - child: PaynymCard( + child: PaynymCardButton( walletId: widget.walletId, - label: following[index].nymName, - paymentCodeString: following[index].code, + accountLite: following[index], ), ); } diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index 739ace1ff..64348e9cd 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/models/paynym/paynym_response.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; @@ -10,19 +11,29 @@ import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; +enum PaynymFollowToggleButtonStyle { + primary, + detailsPopup, +} + class PaynymFollowToggleButton extends ConsumerStatefulWidget { const PaynymFollowToggleButton({ Key? key, required this.walletId, required this.paymentCodeStringToFollow, + this.style = PaynymFollowToggleButtonStyle.primary, }) : super(key: key); final String walletId; final String paymentCodeStringToFollow; + final PaynymFollowToggleButtonStyle style; @override ConsumerState createState() => @@ -229,6 +240,18 @@ class _PaynymFollowToggleButtonState bool _lock = false; late bool isFollowing; + Future _onPressed() async { + if (!_lock) { + _lock = true; + if (isFollowing) { + await unfollow(); + } else { + await follow(); + } + _lock = false; + } + } + @override void initState() { isFollowing = ref @@ -242,21 +265,29 @@ class _PaynymFollowToggleButtonState @override Widget build(BuildContext context) { - return PrimaryButton( - width: isDesktop ? 120 : 84, - buttonHeight: isDesktop ? ButtonHeight.s : ButtonHeight.l, - label: isFollowing ? "Unfollow" : "Follow", - onPressed: () async { - if (!_lock) { - _lock = true; - if (isFollowing) { - await unfollow(); - } else { - await follow(); - } - _lock = false; - } - }, - ); + switch (widget.style) { + case PaynymFollowToggleButtonStyle.primary: + return PrimaryButton( + width: isDesktop ? 120 : 84, + buttonHeight: isDesktop ? ButtonHeight.s : ButtonHeight.l, + label: isFollowing ? "Unfollow" : "Follow", + onPressed: _onPressed, + ); + + case PaynymFollowToggleButtonStyle.detailsPopup: + return SecondaryButton( + label: isFollowing ? "- Unfollow" : "+ Follow", + buttonHeight: ButtonHeight.l, + icon: SvgPicture.asset( + Assets.svg.user, + width: 10, + height: 10, + color: + Theme.of(context).extension()!.buttonTextSecondary, + ), + iconSpacing: 0, + onPressed: _onPressed, + ); + } } } From 35a8172d35f1b5cdbd22f0d56c4db02f795fd032 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 5 Jan 2023 16:57:53 -0600 Subject: [PATCH 052/192] paynym notif tx and tx parsing tweaks --- lib/pages/send_view/send_view.dart | 2 +- lib/services/coins/coin_paynym_extension.dart | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index e34b9d8ad..8afa6a6e9 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -1526,7 +1526,7 @@ class _SendViewState extends ConsumerState { // TODO: remove the need for this!! final bool isOwnAddress = await manager.isOwnAddress(_address!); - if (isOwnAddress) { + if (isOwnAddress && coin != Coin.dogecoinTestNet) { await showDialog( context: context, useSafeArea: false, diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 22d8edb0b..6136171c2 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -9,12 +9,11 @@ import 'package:bitcoindart/src/utils/script.dart' as bscript; import 'package:decimal/decimal.dart'; import 'package:pointycastle/digests/sha256.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; - extension PayNym on DogecoinWallet { // fetch or generate this wallet's bip47 payment code Future getPaymentCode() async { @@ -59,6 +58,7 @@ extension PayNym on DogecoinWallet { Future createNotificationTx( String targetPaymentCodeString, List utxosToUse, + int dustLimit, ) async { final utxoSigningData = await fetchBuildTxData(utxosToUse); final targetPaymentCode = @@ -105,14 +105,14 @@ extension PayNym on DogecoinWallet { txb.setVersion(1); txb.addInput( - "9c6000d597c5008f7bfc2618aed5e4a6ae57677aab95078aae708e1cab11f486", + utxo.txid, txPointIndex, ); - txb.addOutput(targetPaymentCode.notificationAddress(), - Format.decimalAmountToSatoshis(Decimal.one, coin)); - txb.addOutput( - opReturnScript, Format.decimalAmountToSatoshis(Decimal.one, coin)); + txb.addOutput(targetPaymentCode.notificationAddress(), dustLimit); + txb.addOutput(opReturnScript, 0); + + // TODO: add possible change output and mark output as dangerous txb.sign( vin: 0, @@ -234,7 +234,7 @@ Future> parseTransaction( if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self type = "Sent to self"; - amount = amountReceivedInWallet - amountSentFromWallet; + amount = amountSentFromWallet - amountReceivedInWallet - fee; } else if (mySentFromAddresses.isNotEmpty) { // outgoing tx type = "Sent"; From 54767947ed7e722ba763bd3dc818501ce32dc1cf Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 6 Jan 2023 13:55:47 -0600 Subject: [PATCH 053/192] WIP notif txn --- lib/services/coins/coin_paynym_extension.dart | 266 +++++++++++++++++- .../coins/dogecoin/dogecoin_wallet.dart | 22 +- 2 files changed, 269 insertions(+), 19 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 6136171c2..743e1336f 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -13,6 +13,20 @@ import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; +import 'package:tuple/tuple.dart'; + +class SWException with Exception { + SWException(this.message); + + final String message; + + @override + toString() => message; +} + +class InsufficientBalanceException extends SWException { + InsufficientBalanceException(super.message); +} extension PayNym on DogecoinWallet { // fetch or generate this wallet's bip47 payment code @@ -55,12 +69,187 @@ extension PayNym on DogecoinWallet { // Future> prepareNotificationTransaction( // String targetPaymentCode) async {} - Future createNotificationTx( - String targetPaymentCodeString, - List utxosToUse, - int dustLimit, - ) async { - final utxoSigningData = await fetchBuildTxData(utxosToUse); + Future> buildNotificationTx({ + required int selectedTxFeeRate, + required String targetPaymentCodeString, + int additionalOutputs = 0, + List? utxos, + }) async { + const amountToSend = DUST_LIMIT; + final List availableOutputs = utxos ?? outputsList; + final List spendableOutputs = []; + int spendableSatoshiValue = 0; + + // Build list of spendable outputs and totaling their satoshi amount + for (var i = 0; i < availableOutputs.length; i++) { + if (availableOutputs[i].blocked == false && + availableOutputs[i].status.confirmed == true) { + spendableOutputs.add(availableOutputs[i]); + spendableSatoshiValue += availableOutputs[i].value; + } + } + + if (spendableSatoshiValue < amountToSend) { + // insufficient balance + throw InsufficientBalanceException( + "Spendable balance is less than the minimum required for a notification transaction."); + } else if (spendableSatoshiValue == amountToSend) { + // insufficient balance due to missing amount to cover fee + throw InsufficientBalanceException( + "Remaining balance does not cover the network fee."); + } + + // sort spendable by age (oldest first) + spendableOutputs.sort( + (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + + int satoshisBeingUsed = 0; + int outputsBeingUsed = 0; + List utxoObjectsToUse = []; + + for (int i = 0; + satoshisBeingUsed < amountToSend && i < spendableOutputs.length; + i++) { + utxoObjectsToUse.add(spendableOutputs[i]); + satoshisBeingUsed += spendableOutputs[i].value; + outputsBeingUsed += 1; + } + + // add additional outputs if required + for (int i = 0; + i < additionalOutputs && outputsBeingUsed < spendableOutputs.length; + i++) { + utxoObjectsToUse.add(spendableOutputs[outputsBeingUsed]); + satoshisBeingUsed += spendableOutputs[outputsBeingUsed].value; + outputsBeingUsed += 1; + } + + // gather required signing data + final utxoSigningData = await fetchBuildTxData(utxoObjectsToUse); + + final int vSizeForNoChange = (await _createNotificationTx( + targetPaymentCodeString: targetPaymentCodeString, + utxosToUse: utxoObjectsToUse, + utxoSigningData: utxoSigningData, + change: 0)) + .item2; + + final int vSizeForWithChange = (await _createNotificationTx( + targetPaymentCodeString: targetPaymentCodeString, + utxosToUse: utxoObjectsToUse, + utxoSigningData: utxoSigningData, + change: satoshisBeingUsed - amountToSend)) + .item2; + + // Assume 2 outputs, for recipient and payment code script + int feeForNoChange = estimateTxFee( + vSize: vSizeForNoChange, + feeRatePerKB: selectedTxFeeRate, + ); + + // Assume 3 outputs, for recipient, payment code script, and change + int feeForWithChange = estimateTxFee( + vSize: vSizeForWithChange, + feeRatePerKB: selectedTxFeeRate, + ); + + if (feeForNoChange < vSizeForNoChange * 1000) { + feeForNoChange = vSizeForNoChange * 1000; + } + if (feeForWithChange < vSizeForWithChange * 1000) { + feeForWithChange = vSizeForWithChange * 1000; + } + + if (satoshisBeingUsed - amountToSend > feeForNoChange + DUST_LIMIT) { + // try to add change output due to "left over" amount being greater than + // the estimated fee + the dust limit + int changeAmount = satoshisBeingUsed - amountToSend - feeForWithChange; + + // check estimates are correct and build notification tx + if (changeAmount >= DUST_LIMIT && + satoshisBeingUsed - amountToSend - changeAmount == feeForWithChange) { + final txn = await _createNotificationTx( + targetPaymentCodeString: targetPaymentCodeString, + utxosToUse: utxoObjectsToUse, + utxoSigningData: utxoSigningData, + change: changeAmount, + ); + + int feeBeingPaid = satoshisBeingUsed - amountToSend - changeAmount; + + Map transactionObject = { + "hex": txn.item1, + "recipientPaynym": targetPaymentCodeString, + // "recipientAmt": recipientsAmtArray[0], + "fee": feeBeingPaid, + "vSize": txn.item2, + }; + return transactionObject; + } else { + // something broke during fee estimation or the change amount is smaller + // than the dust limit. Try without change + final txn = await _createNotificationTx( + targetPaymentCodeString: targetPaymentCodeString, + utxosToUse: utxoObjectsToUse, + utxoSigningData: utxoSigningData, + change: 0, + ); + + int feeBeingPaid = satoshisBeingUsed - amountToSend; + + Map transactionObject = { + "hex": txn.item1, + "recipientPaynym": targetPaymentCodeString, + // "recipientAmt": recipientsAmtArray[0], + "fee": feeBeingPaid, + "vSize": txn.item2, + }; + return transactionObject; + } + } else if (satoshisBeingUsed - amountToSend >= feeForNoChange) { + // since we already checked if we need to add a change output we can just + // build without change here + final txn = await _createNotificationTx( + targetPaymentCodeString: targetPaymentCodeString, + utxosToUse: utxoObjectsToUse, + utxoSigningData: utxoSigningData, + change: 0, + ); + + int feeBeingPaid = satoshisBeingUsed - amountToSend; + + Map transactionObject = { + "hex": txn.item1, + "recipientPaynym": targetPaymentCodeString, + // "recipientAmt": recipientsAmtArray[0], + "fee": feeBeingPaid, + "vSize": txn.item2, + }; + return transactionObject; + } else { + // if we get here we do not have enough funds to cover the tx total so we + // check if we have any more available outputs and try again + if (spendableOutputs.length > outputsBeingUsed) { + return buildNotificationTx( + selectedTxFeeRate: selectedTxFeeRate, + targetPaymentCodeString: targetPaymentCodeString, + additionalOutputs: additionalOutputs + 1, + ); + } else { + throw InsufficientBalanceException( + "Remaining balance does not cover the network fee."); + } + } + } + + // return tuple with string value equal to the raw tx hex and the int value + // equal to its vSize + Future> _createNotificationTx({ + required String targetPaymentCodeString, + required List utxosToUse, + required Map utxoSigningData, + required int change, + }) async { final targetPaymentCode = PaymentCode.fromPaymentCode(targetPaymentCodeString, network); final myCode = await getPaymentCode(); @@ -109,19 +298,80 @@ extension PayNym on DogecoinWallet { txPointIndex, ); - txb.addOutput(targetPaymentCode.notificationAddress(), dustLimit); + txb.addOutput(targetPaymentCode.notificationAddress(), DUST_LIMIT); txb.addOutput(opReturnScript, 0); // TODO: add possible change output and mark output as dangerous + if (change > 0) { + // generate new change address if current change address has been used + await checkChangeAddressForTransactions(DerivePathType.bip44); + final String changeAddress = + await getCurrentAddressForChain(1, DerivePathType.bip44); + txb.addOutput(changeAddress, change); + } txb.sign( vin: 0, keyPair: myKeyPair, ); + // sign rest of possible inputs + for (var i = 1; i < utxosToUse.length - 1; i++) { + final txid = utxosToUse[i].txid; + txb.sign( + vin: i, + keyPair: utxoSigningData[txid]["keyPair"] as ECPair, + // witnessValue: utxosToUse[i].value, + ); + } + final builtTx = txb.build(); - return builtTx.toHex(); + return Tuple2(builtTx.toHex(), builtTx.virtualSize()); + } + + Future hasConfirmedNotificationTxSentTo( + String paymentCodeString) async { + final targetPaymentCode = + PaymentCode.fromPaymentCode(paymentCodeString, network); + final targetNotificationAddress = targetPaymentCode.notificationAddress(); + + final myTxHistory = (await transactionData) + .getAllTransactions() + .entries + .map((e) => e.value) + .where((e) => + e.txType == "Sent" && e.address == targetNotificationAddress); + + return myTxHistory.isNotEmpty; + } + + // fetch paynym notification tx meta data + Set> getPaynymNotificationTxInfo() { + final set = DB.instance.get( + boxName: walletId, key: "paynymNotificationTxInfo") as Set? ?? + {}; + + return Set>.from(set); + } + + // add/update paynym notification tx meta data entry + Future updatePaynymNotificationInfo({ + required String txid, + required bool confirmed, + required String paymentCodeString, + }) async { + final data = getPaynymNotificationTxInfo(); + data.add({ + "txid": txid, + "confirmed": confirmed, + "paymentCodeString": paymentCodeString, + }); + await DB.instance.put( + boxName: walletId, + key: "paynymNotificationTxInfo", + value: data, + ); } } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 3a5c9fb99..a28d027e3 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -204,7 +204,7 @@ class DogecoinWallet extends CoinServiceAPI { @override Future get currentReceivingAddress => _currentReceivingAddressP2PKH ??= - _getCurrentAddressForChain(0, DerivePathType.bip44); + getCurrentAddressForChain(0, DerivePathType.bip44); Future? _currentReceivingAddressP2PKH; @@ -776,7 +776,7 @@ class DogecoinWallet extends CoinServiceAPI { } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - await _checkChangeAddressForTransactions(DerivePathType.bip44); + await checkChangeAddressForTransactions(DerivePathType.bip44); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); await _checkCurrentReceivingAddressesForTransactions(); @@ -1446,7 +1446,7 @@ class DogecoinWallet extends CoinServiceAPI { /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// and /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _getCurrentAddressForChain( + Future getCurrentAddressForChain( int chain, DerivePathType derivePathType) async { // Here, we assume that chain == 1 if it isn't 0 String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; @@ -1801,7 +1801,7 @@ class DogecoinWallet extends CoinServiceAPI { DerivePathType derivePathType) async { try { final String currentExternalAddr = - await _getCurrentAddressForChain(0, derivePathType); + await getCurrentAddressForChain(0, derivePathType); final int txCount = await getTxCount(address: currentExternalAddr); Logging.instance.log( 'Number of txs for current receiving address $currentExternalAddr: $txCount', @@ -1850,11 +1850,11 @@ class DogecoinWallet extends CoinServiceAPI { } } - Future _checkChangeAddressForTransactions( + Future checkChangeAddressForTransactions( DerivePathType derivePathType) async { try { final String currentExternalAddr = - await _getCurrentAddressForChain(1, derivePathType); + await getCurrentAddressForChain(1, derivePathType); final int txCount = await getTxCount(address: currentExternalAddr); Logging.instance.log( 'Number of txs for current change address $currentExternalAddr: $txCount', @@ -1916,7 +1916,7 @@ class DogecoinWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { for (final type in DerivePathType.values) { - await _checkChangeAddressForTransactions(type); + await checkChangeAddressForTransactions(type); } } catch (e, s) { Logging.instance.log( @@ -2480,7 +2480,7 @@ class DogecoinWallet extends CoinServiceAPI { utxoSigningData: utxoSigningData, recipients: [ _recipientAddress, - await _getCurrentAddressForChain(1, DerivePathType.bip44), + await getCurrentAddressForChain(1, DerivePathType.bip44), ], satoshiAmounts: [ satoshiAmountToSend, @@ -2532,9 +2532,9 @@ class DogecoinWallet extends CoinServiceAPI { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize == feeForTwoOutputs) { // generate new change address if current change address has been used - await _checkChangeAddressForTransactions(DerivePathType.bip44); + await checkChangeAddressForTransactions(DerivePathType.bip44); final String newChangeAddress = - await _getCurrentAddressForChain(1, DerivePathType.bip44); + await getCurrentAddressForChain(1, DerivePathType.bip44); int feeBeingPaid = satoshisBeingUsed - satoshiAmountToSend - changeOutputSize; @@ -2685,7 +2685,7 @@ class DogecoinWallet extends CoinServiceAPI { }; return transactionObject; } else { - // Remember that returning 2 indicates that the user does not have a sufficient balance to + // Remember that returning 2 iTndicates that the user does not have a sufficient balance to // pay for the transaction fee. Ideally, at this stage, we should check if the user has any // additional outputs they're able to spend and then recalculate fees. Logging.instance.log( From 16dc9efa521f65c7dc1655802e2643ebc474ea89 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 6 Jan 2023 16:31:04 -0600 Subject: [PATCH 054/192] added assets --- assets/svg/user-minus.svg | 3 +++ assets/svg/user-plus.svg | 3 +++ lib/utilities/assets.dart | 2 ++ pubspec.yaml | 2 ++ 4 files changed, 10 insertions(+) create mode 100644 assets/svg/user-minus.svg create mode 100644 assets/svg/user-plus.svg diff --git a/assets/svg/user-minus.svg b/assets/svg/user-minus.svg new file mode 100644 index 000000000..a454f5d00 --- /dev/null +++ b/assets/svg/user-minus.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/svg/user-plus.svg b/assets/svg/user-plus.svg new file mode 100644 index 000000000..10795f73c --- /dev/null +++ b/assets/svg/user-plus.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index c85a2bf3c..b1f5dd243 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -135,6 +135,8 @@ class _SVG { String get thickX => "assets/svg/x-fat.svg"; String get x => "assets/svg/x.svg"; String get user => "assets/svg/user.svg"; + String get userPlus => "assets/svg/user-plus.svg"; + String get userMinus => "assets/svg/user-minus.svg"; String get trash => "assets/svg/trash.svg"; String get eye => "assets/svg/eye.svg"; String get eyeSlash => "assets/svg/eye-slash.svg"; diff --git a/pubspec.yaml b/pubspec.yaml index 2ad0f75c6..552370dc3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -260,6 +260,8 @@ flutter: - assets/svg/x.svg - assets/svg/x-fat.svg - assets/svg/user.svg + - assets/svg/user-plus.svg + - assets/svg/user-minus.svg - assets/svg/trash.svg - assets/svg/eye.svg - assets/svg/eye-slash.svg From 0177784c229baa96e24154e99a02cc21cc5bce00 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 6 Jan 2023 16:31:21 -0600 Subject: [PATCH 055/192] confirm paynym connect dialog --- .../confirm_paynym_connect_dialog.dart | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart diff --git a/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart b/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart new file mode 100644 index 000000000..5f89c54ae --- /dev/null +++ b/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/stack_dialog.dart'; + +class ConfirmPaynymConnectDialog extends StatelessWidget { + const ConfirmPaynymConnectDialog({ + Key? key, + required this.nymName, + required this.onConfirmPressed, + required this.amount, + required this.coin, + }) : super(key: key); + + final String nymName; + final VoidCallback onConfirmPressed; + final int amount; + final Coin coin; + + @override + Widget build(BuildContext context) { + return StackDialog( + title: "Connect to $nymName", + icon: SvgPicture.asset( + Assets.svg.userPlus, + color: Theme.of(context).extension()!.textDark, + width: 24, + height: 24, + ), + message: "A one-time connection fee of " + "${Format.satoshisToAmount(amount, coin: coin)} ${coin.ticker} " + "will be charged to connect to this PayNym.\n\nThis fee " + "covers the cost of creating a one-time transaction to create a " + "record on the blockchain. This keeps PayNyms decentralized.", + leftButton: SecondaryButton( + buttonHeight: ButtonHeight.xl, + label: "Cancel", + onPressed: Navigator.of(context).pop, + ), + rightButton: PrimaryButton( + buttonHeight: ButtonHeight.xl, + label: "Connect", + onPressed: onConfirmPressed, + ), + ); + } +} From e8ef0be9774768d9dde9a2d7adf7f87ebb390624 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 6 Jan 2023 16:31:36 -0600 Subject: [PATCH 056/192] WIP connect tx flow --- .../paynym/dialogs/paynym_details_popup.dart | 111 +++++++++++++++++- lib/services/coins/coin_paynym_extension.dart | 70 ++++++++--- 2 files changed, 159 insertions(+), 22 deletions(-) diff --git a/lib/pages/paynym/dialogs/paynym_details_popup.dart b/lib/pages/paynym/dialogs/paynym_details_popup.dart index 1e50723e6..a26905e7c 100644 --- a/lib/pages/paynym/dialogs/paynym_details_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_details_popup.dart @@ -2,11 +2,18 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/route_generator.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -14,8 +21,9 @@ import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.d import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; -class PaynymDetailsPopup extends StatefulWidget { +class PaynymDetailsPopup extends ConsumerStatefulWidget { const PaynymDetailsPopup({ Key? key, required this.walletId, @@ -26,10 +34,103 @@ class PaynymDetailsPopup extends StatefulWidget { final PaynymAccountLite accountLite; @override - State createState() => _PaynymDetailsPopupState(); + ConsumerState createState() => _PaynymDetailsPopupState(); } -class _PaynymDetailsPopupState extends State { +class _PaynymDetailsPopupState extends ConsumerState { + Future _onConnectPressed() async { + bool canPop = false; + unawaited( + showDialog( + context: context, + builder: (context) => WillPopScope( + onWillPop: () async => canPop, + child: const LoadingIndicator( + width: 200, + ), + ), + ), + ); + + final wallet = ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; + + // sanity check to prevent second notifcation tx + if (wallet.hasConnectedConfirmed(widget.accountLite.code)) { + canPop = true; + Navigator.of(context).pop(); + // TODO show info popup + return; + } else if (wallet.hasConnected(widget.accountLite.code)) { + canPop = true; + Navigator.of(context).pop(); + // TODO show info popup + return; + } + + final rates = await wallet.fees; + + Map preparedTx; + + try { + preparedTx = await wallet.buildNotificationTx( + selectedTxFeeRate: rates.medium, + targetPaymentCodeString: widget.accountLite.code, + ); + } on InsufficientBalanceException catch (e) { + if (mounted) { + canPop = true; + Navigator.of(context).pop(); + } + // TODO show info popup + print(e); + return; + } + + if (mounted) { + // We have enough balance and prepared tx should be good to go. + + canPop = true; + // close loading + Navigator.of(context).pop(); + + // Close details + Navigator.of(context).pop(); + + // show info pop up + await showDialog( + context: context, + builder: (context) => ConfirmPaynymConnectDialog( + nymName: widget.accountLite.nymName, + onConfirmPressed: () { + // + print("CONFIRM NOTIF TX: $preparedTx"); + + Navigator.of(context).push( + RouteGenerator.getRoute( + builder: (_) => ConfirmTransactionView( + walletId: wallet.walletId, + transactionInfo: { + "hex": preparedTx["hex"], + "recipient": preparedTx["recipientPaynym"], + "recipientAmt": preparedTx["amount"], + "fee": preparedTx["fee"], + "vSize": preparedTx["vSize"], + "note": "PayNym connect" + }, + ), + ), + ); + }, + amount: (preparedTx["amount"] as int) + (preparedTx["fee"] as int), + coin: wallet.coin, + ), + ); + } + } + @override Widget build(BuildContext context) { return DesktopDialog( @@ -75,9 +176,7 @@ class _PaynymDetailsPopupState extends State { ), iconSpacing: 4, width: 86, - onPressed: () { - // todo notification tx - }, + onPressed: _onConnectPressed, ), ], ), diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 743e1336f..732e6d454 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -15,6 +15,8 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:tuple/tuple.dart'; +import '../../utilities/logger.dart'; + class SWException with Exception { SWException(this.message); @@ -180,7 +182,7 @@ extension PayNym on DogecoinWallet { Map transactionObject = { "hex": txn.item1, "recipientPaynym": targetPaymentCodeString, - // "recipientAmt": recipientsAmtArray[0], + "amount": amountToSend, "fee": feeBeingPaid, "vSize": txn.item2, }; @@ -200,7 +202,7 @@ extension PayNym on DogecoinWallet { Map transactionObject = { "hex": txn.item1, "recipientPaynym": targetPaymentCodeString, - // "recipientAmt": recipientsAmtArray[0], + "amount": amountToSend, "fee": feeBeingPaid, "vSize": txn.item2, }; @@ -221,7 +223,7 @@ extension PayNym on DogecoinWallet { Map transactionObject = { "hex": txn.item1, "recipientPaynym": targetPaymentCodeString, - // "recipientAmt": recipientsAmtArray[0], + "amount": amountToSend, "fee": feeBeingPaid, "vSize": txn.item2, }; @@ -290,7 +292,7 @@ extension PayNym on DogecoinWallet { final notificationScript = bscript.compile([bobP2PKH.output]); // build a notification tx - final txb = TransactionBuilder(); + final txb = TransactionBuilder(network: network); txb.setVersion(1); txb.addInput( @@ -330,20 +332,56 @@ extension PayNym on DogecoinWallet { return Tuple2(builtTx.toHex(), builtTx.virtualSize()); } - Future hasConfirmedNotificationTxSentTo( - String paymentCodeString) async { - final targetPaymentCode = - PaymentCode.fromPaymentCode(paymentCodeString, network); - final targetNotificationAddress = targetPaymentCode.notificationAddress(); + Future confirmNotificationTx( + {required Map preparedTx}) async { + try { + Logging.instance.log("confirmNotificationTx txData: $preparedTx", + level: LogLevel.Info); + final txHash = await electrumXClient.broadcastTransaction( + rawTx: preparedTx["hex"] as String); + Logging.instance.log("Sent txHash: $txHash", level: LogLevel.Info); - final myTxHistory = (await transactionData) - .getAllTransactions() - .entries - .map((e) => e.value) + await updatePaynymNotificationInfo( + txid: txHash, + confirmed: false, + paymentCodeString: preparedTx["paymentCodeString"] as String, + ); + return txHash; + } catch (e, s) { + Logging.instance.log("Exception rethrown from confirmSend(): $e\n$s", + level: LogLevel.Error); + rethrow; + } + } + + // Future hasConfirmedNotificationTxSentTo( + // String paymentCodeString) async { + // final targetPaymentCode = + // PaymentCode.fromPaymentCode(paymentCodeString, network); + // final targetNotificationAddress = targetPaymentCode.notificationAddress(); + // + // final myTxHistory = (await transactionData) + // .getAllTransactions() + // .entries + // .map((e) => e.value) + // .where((e) => + // e.txType == "Sent" && e.address == targetNotificationAddress); + // + // return myTxHistory.isNotEmpty; + // } + + bool hasConnected(String paymentCodeString) { + return getPaynymNotificationTxInfo() + .where((e) => e["paymentCodeString"] == paymentCodeString) + .isNotEmpty; + } + + bool hasConnectedConfirmed(String paymentCodeString) { + return getPaynymNotificationTxInfo() .where((e) => - e.txType == "Sent" && e.address == targetNotificationAddress); - - return myTxHistory.isNotEmpty; + e["paymentCodeString"] == paymentCodeString && + e["confirmed"] == true) + .isNotEmpty; } // fetch paynym notification tx meta data From 5a77efe5f8b3d8c07ebb1ec48ce80ea60fc56425 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 6 Jan 2023 17:40:15 -0600 Subject: [PATCH 057/192] update button to use proper icons --- lib/widgets/custom_buttons/paynym_follow_toggle_button.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index 64348e9cd..d5a0ea07f 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -276,16 +276,16 @@ class _PaynymFollowToggleButtonState case PaynymFollowToggleButtonStyle.detailsPopup: return SecondaryButton( - label: isFollowing ? "- Unfollow" : "+ Follow", + label: isFollowing ? "Unfollow" : "Follow", buttonHeight: ButtonHeight.l, icon: SvgPicture.asset( - Assets.svg.user, + isFollowing ? Assets.svg.userMinus : Assets.svg.userPlus, width: 10, height: 10, color: Theme.of(context).extension()!.buttonTextSecondary, ), - iconSpacing: 0, + iconSpacing: 4, onPressed: _onPressed, ); } From ae7dbeb988d068b8d27d76e1231f089d6e511400 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 11:05:13 -0600 Subject: [PATCH 058/192] WIP send/receive address derivation for the target payment code + my private key context --- lib/services/coins/coin_paynym_extension.dart | 100 ++++++++++++++++-- 1 file changed, 89 insertions(+), 11 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 732e6d454..bfb95db93 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -11,12 +11,12 @@ import 'package:pointycastle/digests/sha256.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; +import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/utilities/logger.dart'; import 'package:tuple/tuple.dart'; -import '../../utilities/logger.dart'; - class SWException with Exception { SWException(this.message); @@ -30,6 +30,10 @@ class InsufficientBalanceException extends SWException { InsufficientBalanceException(super.message); } +class PaynymSendException extends SWException { + PaynymSendException(super.message); +} + extension PayNym on DogecoinWallet { // fetch or generate this wallet's bip47 payment code Future getPaymentCode() async { @@ -68,8 +72,89 @@ extension PayNym on DogecoinWallet { // return Format.uint8listToString(bytes); } - // Future> prepareNotificationTransaction( - // String targetPaymentCode) async {} + void preparePaymentCodeSend(PaymentCode pCode) async { + final notifTx = await hasSentNotificationTx(pCode); + + if (notifTx == null) { + throw PaynymSendException("No notification transaction sent to $pCode"); + } else if (!notifTx.confirmedStatus) { + throw PaynymSendException( + "Notification transaction sent to $pCode has not confirmed yet"); + } else { + final node = getBip32Root((await mnemonic).join(" "), network) + .derivePath("m/47'/0'/0'"); + final sendToAddress = await nextUnusedSendAddressFrom( + pCode, + node.derive(0).privateKey!, + ); + + // todo: Actual transaction build + } + } + + /// get the next unused address to send to given the receiver's payment code + /// and your own private key + Future nextUnusedSendAddressFrom( + PaymentCode pCode, + Uint8List privateKey, + ) async { + // https://en.bitcoin.it/wiki/BIP_0047#Path_levels + const maxCount = 2147483647; + + final paymentAddress = PaymentAddress.initWithPrivateKey( + privateKey, + pCode, + 0, // initial index to check + ); + + for (paymentAddress.index = 0; + paymentAddress.index <= maxCount; + paymentAddress.index++) { + final address = paymentAddress.getSendAddress(); + + final transactionIds = await electrumXClient.getHistory( + scripthash: AddressUtils.convertToScriptHash( + address, + network, + ), + ); + + if (transactionIds.isEmpty) { + return address; + } + } + + throw PaynymSendException("Exhausted unused send addresses!"); + } + + /// get your receiving addresses given the sender's payment code and your own + /// private key + List deriveReceivingAddressesFor( + PaymentCode pCode, + Uint8List privateKey, + int count, + ) { + // https://en.bitcoin.it/wiki/BIP_0047#Path_levels + const maxCount = 2147483647; + assert(count <= maxCount); + + final paymentAddress = PaymentAddress.initWithPrivateKey( + privateKey, + pCode, + 0, // initial index + ); + + final List result = []; + for (paymentAddress.index = 0; + paymentAddress.index < count; + paymentAddress.index++) { + final address = paymentAddress.getReceiveAddress(); + + result.add(address); + } + + return result; + } Future> buildNotificationTx({ required int selectedTxFeeRate, @@ -284,13 +369,6 @@ extension PayNym on DogecoinWallet { blindedPaymentCode, ]); - final bobP2PKH = P2PKH( - data: PaymentData( - pubkey: targetPaymentCode.notificationPublicKey(), - ), - ).data; - final notificationScript = bscript.compile([bobP2PKH.output]); - // build a notification tx final txb = TransactionBuilder(network: network); txb.setVersion(1); From 3c1bc42bbf449033d2a4c5d8eddcab0a000efb24 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 11:09:26 -0600 Subject: [PATCH 059/192] added check functions too see if a notification tx was sent from my wallet to the target payment code, and if any transactions have been received on my notification address which are then cached/stored locally --- lib/services/coins/coin_paynym_extension.dart | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index bfb95db93..fe31a4945 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -9,6 +9,7 @@ import 'package:bitcoindart/src/utils/script.dart' as bscript; import 'package:decimal/decimal.dart'; import 'package:pointycastle/digests/sha256.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/models.dart' as models; import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/address_utils.dart'; @@ -72,6 +73,75 @@ extension PayNym on DogecoinWallet { // return Format.uint8listToString(bytes); } + /// Update cached lists of notification transaction IDs. + /// Returns true if there are new notification transactions found since last + /// checked. + Future checkForNotificationTransactions() async { + final myPCode = await getPaymentCode(); + + final transactionIds = await electrumXClient.getHistory( + scripthash: AddressUtils.convertToScriptHash( + myPCode.notificationAddress(), + network, + ), + ); + + final confirmedNotificationTransactionIds = DB.instance.get( + boxName: walletId, + key: "confirmedNotificationTransactionIds", + ) as Set? ?? + {}; + + final unconfirmedNotificationTransactionIds = DB.instance.get( + boxName: walletId, + key: "unconfirmedNotificationTransactionIds", + ) as Set? ?? + {}; + + // since we are only checking for newly found transactions here we can use the sum + final totalCount = confirmedNotificationTransactionIds.length + + unconfirmedNotificationTransactionIds.length; + + for (final entry in transactionIds) { + final txid = entry["tx_hash"] as String; + + final tx = await cachedElectrumXClient.getTransaction( + txHash: txid, + coin: coin, + ); + + // check if tx is confirmed + if ((tx["confirmations"] as int? ?? 0) > MINIMUM_CONFIRMATIONS) { + // remove it from unconfirmed set + unconfirmedNotificationTransactionIds.remove(txid); + + // add it to confirmed set + confirmedNotificationTransactionIds.add(txid); + } else { + // otherwise add it to the unconfirmed set + unconfirmedNotificationTransactionIds.add(txid); + } + } + + final newTotalCount = confirmedNotificationTransactionIds.length + + unconfirmedNotificationTransactionIds.length; + + return newTotalCount > totalCount; + } + + /// return the notification tx sent from my wallet if it exists + Future hasSentNotificationTx(PaymentCode pCode) async { + final txData = await transactionData; + + for (final tx in txData.getAllTransactions().values) { + if (tx.address == pCode.notificationAddress()) { + return tx; + } + } + + return null; + } + void preparePaymentCodeSend(PaymentCode pCode) async { final notifTx = await hasSentNotificationTx(pCode); From 91696ebb4b757271ff1a5585624ac2b75fa6a04c Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 13:15:15 -0600 Subject: [PATCH 060/192] desktop paynym details subview --- lib/pages/paynym/paynym_home_view.dart | 46 ++- .../subwidgets/desktop_paynym_details.dart | 271 ++++++++++++++++++ .../paynym/subwidgets/paynym_card_button.dart | 154 +++++----- ...selected_paynym_details_item_Provider.dart | 5 + .../paynym_follow_toggle_button.dart | 16 ++ lib/widgets/desktop/primary_button.dart | 17 +- lib/widgets/desktop/secondary_button.dart | 17 +- 7 files changed, 451 insertions(+), 75 deletions(-) create mode 100644 lib/pages/paynym/subwidgets/desktop_paynym_details.dart create mode 100644 lib/providers/ui/selected_paynym_details_item_Provider.dart diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index ba12e517f..cdfba4529 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -7,9 +7,11 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/desktop_paynym_details.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_followers_list.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_following_list.dart'; +import 'package:stackwallet/providers/ui/selected_paynym_details_item_Provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -553,9 +555,47 @@ class _PaynymHomeViewState extends ConsumerState { condition: isDesktop, builder: (child) => Padding( padding: const EdgeInsets.only(left: 24), - child: SizedBox( - width: 490, - child: child, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 490, + child: child, + ), + const SizedBox( + width: 24, + ), + if (ref + .watch(selectedPaynymDetailsItemProvider.state) + .state != + null) + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ConstrainedBox( + constraints: const BoxConstraints( + maxWidth: 600, + ), + child: DesktopPaynymDetails( + walletId: widget.walletId, + accountLite: ref + .watch(selectedPaynymDetailsItemProvider + .state) + .state!, + ), + ), + ], + ), + ), + if (ref + .watch(selectedPaynymDetailsItemProvider.state) + .state != + null) + const SizedBox( + width: 24, + ), + ], ), ), child: ConditionalParent( diff --git a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart new file mode 100644 index 000000000..ce6dedabe --- /dev/null +++ b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart @@ -0,0 +1,271 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:qr_flutter/qr_flutter.dart'; +import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; +import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; +import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/route_generator.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; +import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +import '../../../notifications/show_flush_bar.dart'; + +class DesktopPaynymDetails extends ConsumerStatefulWidget { + const DesktopPaynymDetails({ + Key? key, + required this.walletId, + required this.accountLite, + }) : super(key: key); + + final String walletId; + final PaynymAccountLite accountLite; + + @override + ConsumerState createState() => + _PaynymDetailsPopupState(); +} + +class _PaynymDetailsPopupState extends ConsumerState { + Future _onConnectPressed() async { + bool canPop = false; + unawaited( + showDialog( + context: context, + builder: (context) => WillPopScope( + onWillPop: () async => canPop, + child: const LoadingIndicator( + width: 200, + ), + ), + ), + ); + + final wallet = ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; + + // sanity check to prevent second notifcation tx + if (wallet.hasConnectedConfirmed(widget.accountLite.code)) { + canPop = true; + Navigator.of(context).pop(); + // TODO show info popup + return; + } else if (wallet.hasConnected(widget.accountLite.code)) { + canPop = true; + Navigator.of(context).pop(); + // TODO show info popup + return; + } + + final rates = await wallet.fees; + + Map preparedTx; + + try { + preparedTx = await wallet.buildNotificationTx( + selectedTxFeeRate: rates.medium, + targetPaymentCodeString: widget.accountLite.code, + ); + } on InsufficientBalanceException catch (e) { + if (mounted) { + canPop = true; + Navigator.of(context).pop(); + } + // TODO show info popup + print(e); + return; + } + + if (mounted) { + // We have enough balance and prepared tx should be good to go. + + canPop = true; + // close loading + Navigator.of(context).pop(); + + // Close details + Navigator.of(context).pop(); + + // show info pop up + await showDialog( + context: context, + builder: (context) => ConfirmPaynymConnectDialog( + nymName: widget.accountLite.nymName, + onConfirmPressed: () { + // + print("CONFIRM NOTIF TX: $preparedTx"); + + Navigator.of(context).push( + RouteGenerator.getRoute( + builder: (_) => ConfirmTransactionView( + walletId: wallet.walletId, + transactionInfo: { + "hex": preparedTx["hex"], + "recipient": preparedTx["recipientPaynym"], + "recipientAmt": preparedTx["amount"], + "fee": preparedTx["fee"], + "vSize": preparedTx["vSize"], + "note": "PayNym connect" + }, + ), + ), + ); + }, + amount: (preparedTx["amount"] as int) + (preparedTx["fee"] as int), + coin: wallet.coin, + ), + ); + } + } + + @override + Widget build(BuildContext context) { + return RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + PayNymBot( + paymentCodeString: widget.accountLite.code, + size: 32, + ), + const SizedBox( + width: 12, + ), + Text( + widget.accountLite.nymName, + style: STextStyles.desktopTextSmall(context), + ), + ], + ), + const SizedBox( + height: 20, + ), + Row( + children: [ + Expanded( + child: PrimaryButton( + label: "Connect", + buttonHeight: ButtonHeight.s, + icon: SvgPicture.asset( + Assets.svg.circlePlusFilled, + width: 16, + height: 16, + color: Theme.of(context) + .extension()! + .buttonTextPrimary, + ), + iconSpacing: 6, + onPressed: _onConnectPressed, + ), + ), + const SizedBox( + width: 20, + ), + Expanded( + child: PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: widget.accountLite.code, + style: PaynymFollowToggleButtonStyle.detailsDesktop, + ), + ), + ], + ), + ], + ), + ), + Container( + color: Theme.of(context).extension()!.backgroundAppBar, + height: 1, + ), + Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "PayNym address", + style: STextStyles.desktopTextExtraExtraSmall(context), + ), + const SizedBox( + height: 8, + ), + Row( + children: [ + Expanded( + child: ConstrainedBox( + constraints: const BoxConstraints(minHeight: 100), + child: Text( + widget.accountLite.code, + style: STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + ), + ), + const SizedBox( + width: 20, + ), + QrImage( + padding: const EdgeInsets.all(0), + size: 100, + data: widget.accountLite.code, + foregroundColor: + Theme.of(context).extension()!.textDark, + ), + ], + ), + const SizedBox( + height: 8, + ), + BlueTextButton( + text: "Copy", + onTap: () async { + await Clipboard.setData( + ClipboardData( + text: widget.accountLite.code, + ), + ); + unawaited( + showFloatingFlushBar( + type: FlushBarType.info, + message: "Copied to clipboard", + iconAsset: Assets.svg.copy, + context: context, + ), + ); + }, + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/paynym/subwidgets/paynym_card_button.dart b/lib/pages/paynym/subwidgets/paynym_card_button.dart index f69700b87..75c4d2cc0 100644 --- a/lib/pages/paynym/subwidgets/paynym_card_button.dart +++ b/lib/pages/paynym/subwidgets/paynym_card_button.dart @@ -1,14 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/pages/paynym/dialogs/paynym_details_popup.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; +import 'package:stackwallet/providers/ui/selected_paynym_details_item_Provider.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; -class PaynymCardButton extends StatefulWidget { +class PaynymCardButton extends ConsumerStatefulWidget { const PaynymCardButton({ Key? key, required this.walletId, @@ -19,81 +22,100 @@ class PaynymCardButton extends StatefulWidget { final PaynymAccountLite accountLite; @override - State createState() => _PaynymCardButtonState(); + ConsumerState createState() => _PaynymCardButtonState(); } -class _PaynymCardButtonState extends State { +class _PaynymCardButtonState extends ConsumerState { final isDesktop = Util.isDesktop; @override Widget build(BuildContext context) { return Padding( - padding: isDesktop - ? const EdgeInsets.symmetric( - vertical: 8, - horizontal: 12, - ) - : const EdgeInsets.all(4), - child: RawMaterialButton( + padding: const EdgeInsets.all(4), + child: RoundedContainer( padding: const EdgeInsets.all(0), - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - onPressed: () { - showDialog( - context: context, - builder: (context) => PaynymDetailsPopup( - accountLite: widget.accountLite, - walletId: widget.walletId, + color: isDesktop && + ref + .watch(selectedPaynymDetailsItemProvider.state) + .state + ?.nymId == + widget.accountLite.nymId + ? Theme.of(context) + .extension()! + .accentColorDark + .withOpacity(0.08) + : Colors.transparent, + child: RawMaterialButton( + padding: const EdgeInsets.all(0), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, ), - ); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - PayNymBot( - size: 32, - paymentCodeString: widget.accountLite.code, - ), - const SizedBox( - width: 12, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.accountLite.nymName, - style: isDesktop - ? STextStyles.desktopTextExtraExtraSmall(context) - .copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveText, - ) - : STextStyles.w500_12(context), - ), - const SizedBox( - height: 2, - ), - Text( - Format.shorten(widget.accountLite.code, 12, 5), - style: isDesktop - ? STextStyles.desktopTextExtraExtraSmall(context) - : STextStyles.w500_12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ), - ), - ], + ), + onPressed: () { + if (isDesktop) { + ref.read(selectedPaynymDetailsItemProvider.state).state = + widget.accountLite; + } else { + showDialog( + context: context, + builder: (context) => PaynymDetailsPopup( + accountLite: widget.accountLite, + walletId: widget.walletId, ), - ), - ], + ); + } + }, + child: Padding( + padding: isDesktop + ? const EdgeInsets.symmetric( + vertical: 8, + horizontal: 12, + ) + : const EdgeInsets.all(8.0), + child: Row( + children: [ + PayNymBot( + size: 32, + paymentCodeString: widget.accountLite.code, + ), + const SizedBox( + width: 12, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.accountLite.nymName, + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveText, + ) + : STextStyles.w500_12(context), + ), + const SizedBox( + height: 2, + ), + Text( + Format.shorten(widget.accountLite.code, 12, 5), + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + : STextStyles.w500_12(context).copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ), + ], + ), + ), + ], + ), ), ), ), diff --git a/lib/providers/ui/selected_paynym_details_item_Provider.dart b/lib/providers/ui/selected_paynym_details_item_Provider.dart new file mode 100644 index 000000000..153145710 --- /dev/null +++ b/lib/providers/ui/selected_paynym_details_item_Provider.dart @@ -0,0 +1,5 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; + +final selectedPaynymDetailsItemProvider = + StateProvider.autoDispose((_) => null); diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index d5a0ea07f..ea3771d95 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -21,6 +21,7 @@ import 'package:stackwallet/widgets/loading_indicator.dart'; enum PaynymFollowToggleButtonStyle { primary, detailsPopup, + detailsDesktop, } class PaynymFollowToggleButton extends ConsumerStatefulWidget { @@ -288,6 +289,21 @@ class _PaynymFollowToggleButtonState iconSpacing: 4, onPressed: _onPressed, ); + + case PaynymFollowToggleButtonStyle.detailsDesktop: + return SecondaryButton( + label: isFollowing ? "Unfollow" : "Follow", + buttonHeight: ButtonHeight.s, + icon: SvgPicture.asset( + isFollowing ? Assets.svg.userMinus : Assets.svg.userPlus, + width: 16, + height: 16, + color: + Theme.of(context).extension()!.buttonTextSecondary, + ), + iconSpacing: 6, + onPressed: _onPressed, + ); } } } diff --git a/lib/widgets/desktop/primary_button.dart b/lib/widgets/desktop/primary_button.dart index 95c28696e..a4fb4c35c 100644 --- a/lib/widgets/desktop/primary_button.dart +++ b/lib/widgets/desktop/primary_button.dart @@ -149,9 +149,20 @@ class PrimaryButton extends StatelessWidget { width: iconSpacing, ), if (label != null) - Text( - label!, - style: getStyle(isDesktop, context), + Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + label!, + style: getStyle(isDesktop, context), + ), + if (buttonHeight != null && buttonHeight == ButtonHeight.s) + const SizedBox( + height: 2, + ), + ], ), ], ), diff --git a/lib/widgets/desktop/secondary_button.dart b/lib/widgets/desktop/secondary_button.dart index 5603815b4..244ee356a 100644 --- a/lib/widgets/desktop/secondary_button.dart +++ b/lib/widgets/desktop/secondary_button.dart @@ -152,9 +152,20 @@ class SecondaryButton extends StatelessWidget { width: iconSpacing, ), if (label != null) - Text( - label!, - style: getStyle(isDesktop, context), + Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + label!, + style: getStyle(isDesktop, context), + ), + if (buttonHeight != null && buttonHeight == ButtonHeight.s) + const SizedBox( + height: 2, + ), + ], ), ], ), From 512711183c7d751534ffc45d5725cbba82eb9716 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 13:22:05 -0600 Subject: [PATCH 061/192] add hover color to desktop new follow button --- lib/pages/paynym/paynym_home_view.dart | 47 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index cdfba4529..4d4efeb0d 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -27,6 +27,7 @@ import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; import 'package:stackwallet/widgets/icon_widgets/share_icon.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/toggle.dart'; @@ -49,6 +50,8 @@ class _PaynymHomeViewState extends ConsumerState { int secretCount = 0; Timer? timer; + bool _followButtonHoverState = false; + @override void dispose() { timer?.cancel(); @@ -107,22 +110,34 @@ class _PaynymHomeViewState extends ConsumerState { ], ), trailing: Padding( - padding: const EdgeInsets.only(right: 22), - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - showDialog( - context: context, - builder: (context) => AddNewPaynymFollowView( - walletId: widget.walletId, - ), - ); - }, - child: Container( - color: Colors.transparent, - child: Padding( - padding: const EdgeInsets.all(10.0), + padding: const EdgeInsets.only(right: 12), + child: SizedBox( + height: 56, + child: MouseRegion( + cursor: SystemMouseCursors.click, + onEnter: (_) => setState(() { + _followButtonHoverState = true; + }), + onExit: (_) => setState(() { + _followButtonHoverState = false; + }), + child: GestureDetector( + onTap: () { + showDialog( + context: context, + builder: (context) => AddNewPaynymFollowView( + walletId: widget.walletId, + ), + ); + }, + child: RoundedContainer( + padding: const EdgeInsets.symmetric(horizontal: 24.0), + color: _followButtonHoverState + ? Theme.of(context) + .extension()! + .highlight + : Colors.transparent, + radiusMultiplier: 100, child: Row( children: [ SvgPicture.asset( From 039508ee327e52059ce26b222be94b2fd28be3b7 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 13:57:12 -0600 Subject: [PATCH 062/192] show insufficient balance warning on connect to paynym attempt --- .../paynym/dialogs/paynym_details_popup.dart | 91 +++++++++++++------ .../subwidgets/desktop_paynym_details.dart | 52 ++++++++--- 2 files changed, 103 insertions(+), 40 deletions(-) diff --git a/lib/pages/paynym/dialogs/paynym_details_popup.dart b/lib/pages/paynym/dialogs/paynym_details_popup.dart index a26905e7c..76b0575a3 100644 --- a/lib/pages/paynym/dialogs/paynym_details_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_details_popup.dart @@ -15,6 +15,7 @@ import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; @@ -22,6 +23,7 @@ import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; class PaynymDetailsPopup extends ConsumerStatefulWidget { const PaynymDetailsPopup({ @@ -38,6 +40,8 @@ class PaynymDetailsPopup extends ConsumerStatefulWidget { } class _PaynymDetailsPopupState extends ConsumerState { + bool _showInsufficientFundsInfo = false; + Future _onConnectPressed() async { bool canPop = false; unawaited( @@ -79,13 +83,14 @@ class _PaynymDetailsPopupState extends ConsumerState { selectedTxFeeRate: rates.medium, targetPaymentCodeString: widget.accountLite.code, ); - } on InsufficientBalanceException catch (e) { + } on InsufficientBalanceException catch (_) { if (mounted) { canPop = true; Navigator.of(context).pop(); } - // TODO show info popup - print(e); + setState(() { + _showInsufficientFundsInfo = true; + }); return; } @@ -145,39 +150,69 @@ class _PaynymDetailsPopupState extends ConsumerState { right: 24, bottom: 16, ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + child: Column( children: [ Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - PayNymBot( - paymentCodeString: widget.accountLite.code, - size: 32, + Row( + children: [ + PayNymBot( + paymentCodeString: widget.accountLite.code, + size: 32, + ), + const SizedBox( + width: 12, + ), + Text( + widget.accountLite.nymName, + style: STextStyles.w600_12(context), + ), + ], ), - const SizedBox( - width: 12, - ), - Text( - widget.accountLite.nymName, - style: STextStyles.w600_12(context), + PrimaryButton( + label: "Connect", + buttonHeight: ButtonHeight.l, + icon: SvgPicture.asset( + Assets.svg.circlePlusFilled, + width: 10, + height: 10, + color: Theme.of(context) + .extension()! + .buttonTextPrimary, + ), + iconSpacing: 4, + width: 86, + onPressed: _onConnectPressed, ), ], ), - PrimaryButton( - label: "Connect", - buttonHeight: ButtonHeight.l, - icon: SvgPicture.asset( - Assets.svg.circlePlusFilled, - width: 10, - height: 10, - color: Theme.of(context) - .extension()! - .buttonTextPrimary, + if (_showInsufficientFundsInfo) + Column( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox( + height: 24, + ), + RoundedContainer( + color: Theme.of(context) + .extension()! + .warningBackground, + child: Text( + "Adding a PayNym to your contacts requires a one-time " + "transaction fee for creating the record on the " + "blockchain. Please deposit more " + "${ref.read(walletsChangeNotifierProvider).getManager(widget.walletId).wallet.coin.ticker} " + "into your wallet and try again.", + style: STextStyles.infoSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .warningForeground, + ), + ), + ), + ], ), - iconSpacing: 4, - width: 86, - onPressed: _onConnectPressed, - ), ], ), ), diff --git a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart index ce6dedabe..7962c9462 100644 --- a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart +++ b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart @@ -6,6 +6,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; +import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; @@ -14,16 +15,16 @@ import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; -import '../../../notifications/show_flush_bar.dart'; - class DesktopPaynymDetails extends ConsumerStatefulWidget { const DesktopPaynymDetails({ Key? key, @@ -40,6 +41,8 @@ class DesktopPaynymDetails extends ConsumerStatefulWidget { } class _PaynymDetailsPopupState extends ConsumerState { + bool _showInsufficientFundsInfo = false; + Future _onConnectPressed() async { bool canPop = false; unawaited( @@ -59,15 +62,15 @@ class _PaynymDetailsPopupState extends ConsumerState { .getManager(widget.walletId) .wallet as DogecoinWallet; - // sanity check to prevent second notifcation tx + // sanity check to prevent second notification tx if (wallet.hasConnectedConfirmed(widget.accountLite.code)) { canPop = true; - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: true).pop(); // TODO show info popup return; } else if (wallet.hasConnected(widget.accountLite.code)) { canPop = true; - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: true).pop(); // TODO show info popup return; } @@ -84,10 +87,11 @@ class _PaynymDetailsPopupState extends ConsumerState { } on InsufficientBalanceException catch (e) { if (mounted) { canPop = true; - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: true).pop(); } - // TODO show info popup - print(e); + setState(() { + _showInsufficientFundsInfo = true; + }); return; } @@ -96,10 +100,7 @@ class _PaynymDetailsPopupState extends ConsumerState { canPop = true; // close loading - Navigator.of(context).pop(); - - // Close details - Navigator.of(context).pop(); + Navigator.of(context, rootNavigator: true).pop(); // show info pop up await showDialog( @@ -192,6 +193,33 @@ class _PaynymDetailsPopupState extends ConsumerState { ), ], ), + if (_showInsufficientFundsInfo) + Column( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox( + height: 24, + ), + RoundedContainer( + color: Theme.of(context) + .extension()! + .warningBackground, + child: Text( + "Adding a PayNym to your contacts requires a one-time " + "transaction fee for creating the record on the " + "blockchain. Please deposit more " + "${ref.read(walletsChangeNotifierProvider).getManager(widget.walletId).wallet.coin.ticker} " + "into your wallet and try again.", + style: STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .warningForeground, + ), + ), + ), + ], + ), ], ), ), From 12477e8fb5dd0b3847aaf173787282bf2e7a94d5 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 14:11:26 -0600 Subject: [PATCH 063/192] desktop connect confirm dialog layout --- .../confirm_paynym_connect_dialog.dart | 134 ++++++++++++++---- 1 file changed, 110 insertions(+), 24 deletions(-) diff --git a/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart b/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart index 5f89c54ae..9dc653118 100644 --- a/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart +++ b/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart @@ -3,7 +3,11 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.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'; @@ -22,31 +26,113 @@ class ConfirmPaynymConnectDialog extends StatelessWidget { final int amount; final Coin coin; + String get title => "Connect to $nymName"; + + String get message => "A one-time connection fee of " + "${Format.satoshisToAmount(amount, coin: coin)} ${coin.ticker} " + "will be charged to connect to this PayNym.\n\nThis fee " + "covers the cost of creating a one-time transaction to create a " + "record on the blockchain. This keeps PayNyms decentralized."; + @override Widget build(BuildContext context) { - return StackDialog( - title: "Connect to $nymName", - icon: SvgPicture.asset( - Assets.svg.userPlus, - color: Theme.of(context).extension()!.textDark, - width: 24, - height: 24, - ), - message: "A one-time connection fee of " - "${Format.satoshisToAmount(amount, coin: coin)} ${coin.ticker} " - "will be charged to connect to this PayNym.\n\nThis fee " - "covers the cost of creating a one-time transaction to create a " - "record on the blockchain. This keeps PayNyms decentralized.", - leftButton: SecondaryButton( - buttonHeight: ButtonHeight.xl, - label: "Cancel", - onPressed: Navigator.of(context).pop, - ), - rightButton: PrimaryButton( - buttonHeight: ButtonHeight.xl, - label: "Connect", - onPressed: onConfirmPressed, - ), - ); + if (Util.isDesktop) { + return DesktopDialog( + maxHeight: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.only(left: 40), + child: SvgPicture.asset( + Assets.svg.userPlus, + color: Theme.of(context).extension()!.textDark, + width: 32, + height: 32, + ), + ), + const DesktopDialogCloseButton(), + ], + ), + Padding( + padding: const EdgeInsets.only( + left: 40, + bottom: 32, + right: 40, + ), + child: Text( + title, + style: STextStyles.desktopH3(context), + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 40, + right: 40, + ), + child: Text( + message, + style: STextStyles.desktopTextMedium(context).copyWith( + color: Theme.of(context).extension()!.textDark3, + ), + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 40, + bottom: 40, + right: 40, + top: 32, + ), + child: Row( + children: [ + Expanded( + child: SecondaryButton( + buttonHeight: ButtonHeight.l, + label: "Cancel", + onPressed: Navigator.of(context).pop, + ), + ), + const SizedBox( + width: 16, + ), + Expanded( + child: PrimaryButton( + buttonHeight: ButtonHeight.l, + label: "Connect", + onPressed: onConfirmPressed, + ), + ), + ], + ), + ) + ], + ), + ); + } else { + return StackDialog( + title: title, + icon: SvgPicture.asset( + Assets.svg.userPlus, + color: Theme.of(context).extension()!.textDark, + width: 24, + height: 24, + ), + message: message, + leftButton: SecondaryButton( + buttonHeight: ButtonHeight.xl, + label: "Cancel", + onPressed: Navigator.of(context).pop, + ), + rightButton: PrimaryButton( + buttonHeight: ButtonHeight.xl, + label: "Connect", + onPressed: onConfirmPressed, + ), + ); + } } } From cba33a1d69ff7d91323f4dd748e332c8d18f0b72 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 15:42:37 -0600 Subject: [PATCH 064/192] notification tx record type storage fix and a couple other little fixes --- lib/services/coins/coin_paynym_extension.dart | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index fe31a4945..b64c7dbfa 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -492,7 +492,7 @@ extension PayNym on DogecoinWallet { await updatePaynymNotificationInfo( txid: txHash, confirmed: false, - paymentCodeString: preparedTx["paymentCodeString"] as String, + paymentCodeString: preparedTx["address"] as String, ); return txHash; } catch (e, s) { @@ -520,12 +520,14 @@ extension PayNym on DogecoinWallet { bool hasConnected(String paymentCodeString) { return getPaynymNotificationTxInfo() + .values .where((e) => e["paymentCodeString"] == paymentCodeString) .isNotEmpty; } bool hasConnectedConfirmed(String paymentCodeString) { return getPaynymNotificationTxInfo() + .values .where((e) => e["paymentCodeString"] == paymentCodeString && e["confirmed"] == true) @@ -533,12 +535,12 @@ extension PayNym on DogecoinWallet { } // fetch paynym notification tx meta data - Set> getPaynymNotificationTxInfo() { - final set = DB.instance.get( - boxName: walletId, key: "paynymNotificationTxInfo") as Set? ?? + Map getPaynymNotificationTxInfo() { + final map = DB.instance.get( + boxName: walletId, key: "paynymNotificationTxInfo") as Map? ?? {}; - return Set>.from(set); + return Map.from(map); } // add/update paynym notification tx meta data entry @@ -548,11 +550,11 @@ extension PayNym on DogecoinWallet { required String paymentCodeString, }) async { final data = getPaynymNotificationTxInfo(); - data.add({ + data[txid] = { "txid": txid, "confirmed": confirmed, "paymentCodeString": paymentCodeString, - }); + }; await DB.instance.put( boxName: walletId, key: "paynymNotificationTxInfo", @@ -605,6 +607,7 @@ Future> parseTransaction( // get input(prevOut) address final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? output["scriptPubKey"]?["address"] as String?; + if (address != null) { inputAddresses.add(address); @@ -629,8 +632,8 @@ Future> parseTransaction( totalOutputValue += value; // get output address - final address = output["scriptPubKey"]["addresses"][0] as String? ?? - output["scriptPubKey"]["address"] as String?; + final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? + output["scriptPubKey"]?["address"] as String?; if (address != null) { outputAddresses.add(address); From bffe5e09cafb2ebdda741dd1f1b608be5e9bf7bb Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 15:43:16 -0600 Subject: [PATCH 065/192] paynym confirm transaction view flags and routing branch --- .../send_view/confirm_transaction_view.dart | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index b7e2181a1..1164e0418 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -12,6 +12,8 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; import 'package:stackwallet/route_generator.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -41,6 +43,9 @@ class ConfirmTransactionView extends ConsumerStatefulWidget { required this.walletId, this.routeOnSuccessName = WalletView.routeName, this.isTradeTransaction = false, + this.isPaynymTransaction = false, + this.isPaynymNotificationTransaction = false, + this.onSuccessInsteadOfRouteOnSuccess, }) : super(key: key); static const String routeName = "/confirmTransactionView"; @@ -49,6 +54,9 @@ class ConfirmTransactionView extends ConsumerStatefulWidget { final String walletId; final String routeOnSuccessName; final bool isTradeTransaction; + final bool isPaynymTransaction; + final bool isPaynymNotificationTransaction; + final VoidCallback? onSuccessInsteadOfRouteOnSuccess; @override ConsumerState createState() => @@ -83,14 +91,22 @@ class _ConfirmTransactionViewState try { String txid; - final coin = manager.coin; - if ((coin == Coin.firo || coin == Coin.firoTestNet) && - ref.read(publicPrivateBalanceStateProvider.state).state != - "Private") { - txid = await (manager.wallet as FiroWallet) - .confirmSendPublic(txData: transactionInfo); + if (widget.isPaynymNotificationTransaction) { + txid = await (manager.wallet as DogecoinWallet) + .confirmNotificationTx(preparedTx: transactionInfo); + } else if (widget.isPaynymTransaction) { + // + throw UnimplementedError("paynym send not implemented yet"); } else { - txid = await manager.confirmSend(txData: transactionInfo); + final coin = manager.coin; + if ((coin == Coin.firo || coin == Coin.firoTestNet) && + ref.read(publicPrivateBalanceStateProvider.state).state != + "Private") { + txid = await (manager.wallet as FiroWallet) + .confirmSendPublic(txData: transactionInfo); + } else { + txid = await manager.confirmSend(txData: transactionInfo); + } } // save note @@ -102,7 +118,12 @@ class _ConfirmTransactionViewState // pop back to wallet if (mounted) { - Navigator.of(context).popUntil(ModalRoute.withName(routeOnSuccessName)); + if (widget.onSuccessInsteadOfRouteOnSuccess == null) { + Navigator.of(context) + .popUntil(ModalRoute.withName(routeOnSuccessName)); + } else { + widget.onSuccessInsteadOfRouteOnSuccess!.call(); + } } } on BadEpicHttpAddressException catch (_) { if (mounted) { From e66205ac32df9abeca5dcede8c901853e831fd9e Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 15:46:52 -0600 Subject: [PATCH 066/192] routing and parse fix --- lib/pages/paynym/dialogs/paynym_details_popup.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pages/paynym/dialogs/paynym_details_popup.dart b/lib/pages/paynym/dialogs/paynym_details_popup.dart index 76b0575a3..72c4a2f46 100644 --- a/lib/pages/paynym/dialogs/paynym_details_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_details_popup.dart @@ -8,6 +8,7 @@ import 'package:qr_flutter/qr_flutter.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; +import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; @@ -117,9 +118,11 @@ class _PaynymDetailsPopupState extends ConsumerState { RouteGenerator.getRoute( builder: (_) => ConfirmTransactionView( walletId: wallet.walletId, + routeOnSuccessName: PaynymHomeView.routeName, + isPaynymNotificationTransaction: true, transactionInfo: { "hex": preparedTx["hex"], - "recipient": preparedTx["recipientPaynym"], + "address": preparedTx["recipientPaynym"], "recipientAmt": preparedTx["amount"], "fee": preparedTx["fee"], "vSize": preparedTx["vSize"], From 69e1d8d20bf17562175774ccd5f43c15b30f3e9a Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 15:47:10 -0600 Subject: [PATCH 067/192] reduce minimum doge confirms --- lib/services/coins/dogecoin/dogecoin_wallet.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index a28d027e3..457dc5c8c 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -43,7 +43,7 @@ import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; -const int MINIMUM_CONFIRMATIONS = 3; +const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 1000000; const String GENESIS_HASH_MAINNET = From 178912a3237079f99dd7cf396c9c277533e541ab Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 15:47:40 -0600 Subject: [PATCH 068/192] routing fix --- .../subwidgets/desktop_paynym_details.dart | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart index 7962c9462..9a53d38e0 100644 --- a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart +++ b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart @@ -11,7 +11,6 @@ import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.d import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -20,6 +19,7 @@ import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/rounded_container.dart'; @@ -110,19 +110,38 @@ class _PaynymDetailsPopupState extends ConsumerState { onConfirmPressed: () { // print("CONFIRM NOTIF TX: $preparedTx"); - - Navigator.of(context).push( - RouteGenerator.getRoute( - builder: (_) => ConfirmTransactionView( - walletId: wallet.walletId, - transactionInfo: { - "hex": preparedTx["hex"], - "recipient": preparedTx["recipientPaynym"], - "recipientAmt": preparedTx["amount"], - "fee": preparedTx["fee"], - "vSize": preparedTx["vSize"], - "note": "PayNym connect" - }, + Navigator.of(context, rootNavigator: true).pop(); + unawaited( + showDialog( + context: context, + builder: (context) => DesktopDialog( + maxHeight: double.infinity, + maxWidth: 580, + child: ConfirmTransactionView( + walletId: wallet.walletId, + isPaynymNotificationTransaction: true, + transactionInfo: { + "hex": preparedTx["hex"], + "address": preparedTx["recipientPaynym"], + "recipientAmt": preparedTx["amount"], + "fee": preparedTx["fee"], + "vSize": preparedTx["vSize"], + "note": "PayNym connect" + }, + onSuccessInsteadOfRouteOnSuccess: () { + Navigator.of(context, rootNavigator: true).pop(); + Navigator.of(context, rootNavigator: true).pop(); + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: + "Connection initiated to ${widget.accountLite.nymName}", + iconAsset: Assets.svg.copy, + context: context, + ), + ); + }, + ), ), ), ); From 2da1e23251c75e8ed312f44bb2069a7fef3defbb Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 9 Jan 2023 15:48:32 -0600 Subject: [PATCH 069/192] WIP initial paynym send ui --- .../subwidgets/desktop_paynym_details.dart | 54 ++++++++++++++----- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart index 9a53d38e0..d51a0fecd 100644 --- a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart +++ b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart @@ -153,8 +153,16 @@ class _PaynymDetailsPopupState extends ConsumerState { } } + Future _onSend() async { + print("sned"); + } + @override Widget build(BuildContext context) { + final wallet = ref + .watch(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .wallet as DogecoinWallet; return RoundedWhiteContainer( padding: const EdgeInsets.all(0), child: Column( @@ -184,22 +192,40 @@ class _PaynymDetailsPopupState extends ConsumerState { ), Row( children: [ - Expanded( - child: PrimaryButton( - label: "Connect", - buttonHeight: ButtonHeight.s, - icon: SvgPicture.asset( - Assets.svg.circlePlusFilled, - width: 16, - height: 16, - color: Theme.of(context) - .extension()! - .buttonTextPrimary, + if (!wallet.hasConnected(widget.accountLite.code)) + Expanded( + child: PrimaryButton( + label: "Connect", + buttonHeight: ButtonHeight.s, + icon: SvgPicture.asset( + Assets.svg.circlePlusFilled, + width: 16, + height: 16, + color: Theme.of(context) + .extension()! + .buttonTextPrimary, + ), + iconSpacing: 6, + onPressed: _onConnectPressed, + ), + ), + if (wallet.hasConnected(widget.accountLite.code)) + Expanded( + child: PrimaryButton( + label: "Send", + buttonHeight: ButtonHeight.s, + icon: SvgPicture.asset( + Assets.svg.circleArrowUpRight, + width: 16, + height: 16, + color: Theme.of(context) + .extension()! + .buttonTextPrimary, + ), + iconSpacing: 6, + onPressed: _onSend, ), - iconSpacing: 6, - onPressed: _onConnectPressed, ), - ), const SizedBox( width: 20, ), From c4cc5b1a022d59b1d26f713434c44b1d5f8fbe27 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 08:49:51 -0600 Subject: [PATCH 070/192] WIP Isar transaction object skeletons --- .../isar/models/blockchain_data/input.dart | 30 ++++++++++ .../isar/models/blockchain_data/output.dart | 20 +++++++ .../models/blockchain_data/transaction.dart | 59 +++++++++++++++++++ .../isar/models/blockchain_data/utxo.dart | 37 ++++++++++++ lib/models/isar/models/transaction_note.dart | 12 ++++ pubspec.lock | 6 +- pubspec.yaml | 6 +- 7 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 lib/models/isar/models/blockchain_data/input.dart create mode 100644 lib/models/isar/models/blockchain_data/output.dart create mode 100644 lib/models/isar/models/blockchain_data/transaction.dart create mode 100644 lib/models/isar/models/blockchain_data/utxo.dart create mode 100644 lib/models/isar/models/transaction_note.dart diff --git a/lib/models/isar/models/blockchain_data/input.dart b/lib/models/isar/models/blockchain_data/input.dart new file mode 100644 index 000000000..be19cc082 --- /dev/null +++ b/lib/models/isar/models/blockchain_data/input.dart @@ -0,0 +1,30 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; + +@Collection() +class Input { + Id id = Isar.autoIncrement; + + late String txid; + + late int vout; + + late String? scriptSig; + + late String? scriptSigAsm; + + // TODO: find witness type // is it even used? + // late List? witness; + + late bool? isCoinbase; + + late int? sequence; + + late String? innerRedeemScriptAsm; + + final prevOut = IsarLink(); + + @Backlink(to: 'inputs') + final transaction = IsarLink(); +} diff --git a/lib/models/isar/models/blockchain_data/output.dart b/lib/models/isar/models/blockchain_data/output.dart new file mode 100644 index 000000000..5c34800ad --- /dev/null +++ b/lib/models/isar/models/blockchain_data/output.dart @@ -0,0 +1,20 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; + +@Collection() +class Output { + Id id = Isar.autoIncrement; + + late String? scriptPubKey; + + late String? scriptPubKeyAsm; + + late String? scriptPubKeyType; + + late String scriptPubKeyAddress; + + late int value; + + @Backlink(to: 'outputs') + final transaction = IsarLink(); +} diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart new file mode 100644 index 000000000..e3ae9cedc --- /dev/null +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -0,0 +1,59 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; +import 'package:stackwallet/models/isar/models/transaction_note.dart'; + +@Collection() +class Transaction { + Id id = Isar.autoIncrement; + + late String txid; + + late bool confirmed; + + late int confirmations; + + late int timestamp; + + late TransactionType txType; + + late String subType; + + late int amount; + + // TODO: do we need this? + // late List aliens; + + late String worthAtBlockTimestamp; + + late int fee; + + late String address; + + late int height; + + late bool cancelled; + + late String? slateId; + + late String? otherData; + + final inputs = IsarLinks(); + + final outputs = IsarLinks(); + + final note = IsarLink(); +} + +// Used in Isar db and stored there as int indexes so adding/removing values +// in this definition should be done extremely carefully in production +enum TransactionType with IsarEnum { + // TODO: add more types before prod release? + outgoing, + incoming, + sendToSelf, // should we keep this? + anonymize; // firo specific + + @override + int get value => index; +} diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart new file mode 100644 index 000000000..6539ea2cb --- /dev/null +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -0,0 +1,37 @@ +import 'package:isar/isar.dart'; + +@Collection() +class UTXO { + Id id = Isar.autoIncrement; + + late String txid; + + late int vout; + + late Status status; + + late int value; + + late String fiatWorth; + + late String txName; + + late bool blocked; + + late bool isCoinbase; +} + +@Embedded() +class Status { + Id id = Isar.autoIncrement; + + late bool confirmed; + + late int confirmations; + + late String blockHash; + + late int blockHeight; + + late int blockTime; +} diff --git a/lib/models/isar/models/transaction_note.dart b/lib/models/isar/models/transaction_note.dart new file mode 100644 index 000000000..3dbd53e81 --- /dev/null +++ b/lib/models/isar/models/transaction_note.dart @@ -0,0 +1,12 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; + +@Collection() +class TransactionNote { + Id id = Isar.autoIncrement; + + late String value; + + @Backlink(to: 'note') + final transaction = IsarLink(); +} diff --git a/pubspec.lock b/pubspec.lock index 701cc6636..c6e2a2019 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -803,21 +803,21 @@ packages: name: isar url: "https://pub.dartlang.org" source: hosted - version: "3.0.0-dev.10" + version: "3.0.5" isar_flutter_libs: dependency: "direct main" description: name: isar_flutter_libs url: "https://pub.dartlang.org" source: hosted - version: "3.0.0-dev.10" + version: "3.0.5" isar_generator: dependency: "direct dev" description: name: isar_generator url: "https://pub.dartlang.org" source: hosted - version: "3.0.0-dev.10" + version: "3.0.5" js: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 552370dc3..a1ade167d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -135,8 +135,8 @@ dependencies: file_picker: ^5.0.1 connectivity_plus: 2.3.6+1 # document_file_save_plus: ^1.0.5 - isar: 3.0.0-dev.10 - isar_flutter_libs: 3.0.0-dev.10 # contains the binaries + isar: 3.0.5 + isar_flutter_libs: 3.0.5 # contains the binaries dropdown_button2: 1.7.2 string_validator: ^0.3.0 @@ -156,7 +156,7 @@ dev_dependencies: analyzer: ^4.6.0 import_sorter: ^4.6.0 flutter_lints: ^2.0.1 - isar_generator: 3.0.0-dev.10 + isar_generator: 3.0.5 flutter_icons: android: true From 5712fab88fda88008dbeaedfe87885457639a81c Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 09:21:22 -0600 Subject: [PATCH 071/192] WIP Isar transaction sub type enum --- .../isar/models/blockchain_data/transaction.dart | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index e3ae9cedc..522b30730 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -17,7 +17,7 @@ class Transaction { late TransactionType txType; - late String subType; + late TransactionSubType subType; late int amount; @@ -57,3 +57,15 @@ enum TransactionType with IsarEnum { @override int get value => index; } + +// Used in Isar db and stored there as int indexes so adding/removing values +// in this definition should be done extremely carefully in production +enum TransactionSubType with IsarEnum { + // TODO: add more types before prod release? + none, + bip47Notification, // bip47 payment code notification transaction flag + mint; // firo specific + + @override + int get value => index; +} From a0df73551ea7ef3e921192b065e1ba9b0b948c5b Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 10:02:54 -0600 Subject: [PATCH 072/192] update generated files --- .../isar/models/blockchain_data/input.dart | 2 + .../isar/models/blockchain_data/input.g.dart | 1347 ++++++++++ .../isar/models/blockchain_data/output.dart | 2 + .../isar/models/blockchain_data/output.g.dart | 1152 +++++++++ .../models/blockchain_data/transaction.dart | 12 +- .../models/blockchain_data/transaction.g.dart | 2213 +++++++++++++++++ .../isar/models/blockchain_data/utxo.dart | 4 +- .../isar/models/blockchain_data/utxo.g.dart | 1520 +++++++++++ .../isar/models/encrypted_string_value.g.dart | 128 +- lib/models/isar/models/log.dart | 2 + lib/models/isar/models/log.g.dart | 140 +- lib/models/isar/models/transaction_note.dart | 2 + .../isar/models/transaction_note.g.dart | 470 ++++ lib/utilities/enums/log_level_enum.dart | 7 +- .../pages/send_view/send_view_test.mocks.dart | 10 + .../exchange/exchange_view_test.mocks.dart | 5 + test/services/wallets_service_test.mocks.dart | 25 + .../managed_favorite_test.mocks.dart | 10 + .../node_options_sheet_test.mocks.dart | 10 + .../table_view/table_view_row_test.mocks.dart | 10 + .../transaction_card_test.mocks.dart | 10 + test/widget_tests/wallet_card_test.mocks.dart | 10 + ...et_info_row_balance_future_test.mocks.dart | 10 + .../wallet_info_row_test.mocks.dart | 10 + 24 files changed, 6977 insertions(+), 134 deletions(-) create mode 100644 lib/models/isar/models/blockchain_data/input.g.dart create mode 100644 lib/models/isar/models/blockchain_data/output.g.dart create mode 100644 lib/models/isar/models/blockchain_data/transaction.g.dart create mode 100644 lib/models/isar/models/blockchain_data/utxo.g.dart create mode 100644 lib/models/isar/models/transaction_note.g.dart diff --git a/lib/models/isar/models/blockchain_data/input.dart b/lib/models/isar/models/blockchain_data/input.dart index be19cc082..0be374b81 100644 --- a/lib/models/isar/models/blockchain_data/input.dart +++ b/lib/models/isar/models/blockchain_data/input.dart @@ -2,6 +2,8 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; +part 'input.g.dart'; + @Collection() class Input { Id id = Isar.autoIncrement; diff --git a/lib/models/isar/models/blockchain_data/input.g.dart b/lib/models/isar/models/blockchain_data/input.g.dart new file mode 100644 index 000000000..b4a9c2865 --- /dev/null +++ b/lib/models/isar/models/blockchain_data/input.g.dart @@ -0,0 +1,1347 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'input.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetInputCollection on Isar { + IsarCollection get inputs => this.collection(); +} + +const InputSchema = CollectionSchema( + name: r'Input', + id: 1962449150546623042, + properties: { + r'innerRedeemScriptAsm': PropertySchema( + id: 0, + name: r'innerRedeemScriptAsm', + type: IsarType.string, + ), + r'isCoinbase': PropertySchema( + id: 1, + name: r'isCoinbase', + type: IsarType.bool, + ), + r'scriptSig': PropertySchema( + id: 2, + name: r'scriptSig', + type: IsarType.string, + ), + r'scriptSigAsm': PropertySchema( + id: 3, + name: r'scriptSigAsm', + type: IsarType.string, + ), + r'sequence': PropertySchema( + id: 4, + name: r'sequence', + type: IsarType.long, + ), + r'txid': PropertySchema( + id: 5, + name: r'txid', + type: IsarType.string, + ), + r'vout': PropertySchema( + id: 6, + name: r'vout', + type: IsarType.long, + ) + }, + estimateSize: _inputEstimateSize, + serialize: _inputSerialize, + deserialize: _inputDeserialize, + deserializeProp: _inputDeserializeProp, + idName: r'id', + indexes: {}, + links: { + r'prevOut': LinkSchema( + id: 2963704715567457192, + name: r'prevOut', + target: r'Output', + single: true, + ), + r'transaction': LinkSchema( + id: -7488914266019463608, + name: r'transaction', + target: r'Transaction', + single: true, + linkName: r'inputs', + ) + }, + embeddedSchemas: {}, + getId: _inputGetId, + getLinks: _inputGetLinks, + attach: _inputAttach, + version: '3.0.5', +); + +int _inputEstimateSize( + Input object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.innerRedeemScriptAsm; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.scriptSig; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.scriptSigAsm; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.txid.length * 3; + return bytesCount; +} + +void _inputSerialize( + Input object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.innerRedeemScriptAsm); + writer.writeBool(offsets[1], object.isCoinbase); + writer.writeString(offsets[2], object.scriptSig); + writer.writeString(offsets[3], object.scriptSigAsm); + writer.writeLong(offsets[4], object.sequence); + writer.writeString(offsets[5], object.txid); + writer.writeLong(offsets[6], object.vout); +} + +Input _inputDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = Input(); + object.id = id; + object.innerRedeemScriptAsm = reader.readStringOrNull(offsets[0]); + object.isCoinbase = reader.readBoolOrNull(offsets[1]); + object.scriptSig = reader.readStringOrNull(offsets[2]); + object.scriptSigAsm = reader.readStringOrNull(offsets[3]); + object.sequence = reader.readLongOrNull(offsets[4]); + object.txid = reader.readString(offsets[5]); + object.vout = reader.readLong(offsets[6]); + return object; +} + +P _inputDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readBoolOrNull(offset)) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + case 3: + return (reader.readStringOrNull(offset)) as P; + case 4: + return (reader.readLongOrNull(offset)) as P; + case 5: + return (reader.readString(offset)) as P; + case 6: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _inputGetId(Input object) { + return object.id; +} + +List> _inputGetLinks(Input object) { + return [object.prevOut, object.transaction]; +} + +void _inputAttach(IsarCollection col, Id id, Input object) { + object.id = id; + object.prevOut.attach(col, col.isar.collection(), r'prevOut', id); + object.transaction + .attach(col, col.isar.collection(), r'transaction', id); +} + +extension InputQueryWhereSort on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension InputQueryWhere on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } +} + +extension InputQueryFilter on QueryBuilder { + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'innerRedeemScriptAsm', + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'innerRedeemScriptAsm', + )); + }); + } + + QueryBuilder innerRedeemScriptAsmEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'innerRedeemScriptAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'innerRedeemScriptAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'innerRedeemScriptAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder innerRedeemScriptAsmBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'innerRedeemScriptAsm', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'innerRedeemScriptAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'innerRedeemScriptAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'innerRedeemScriptAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder innerRedeemScriptAsmMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'innerRedeemScriptAsm', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'innerRedeemScriptAsm', + value: '', + )); + }); + } + + QueryBuilder + innerRedeemScriptAsmIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'innerRedeemScriptAsm', + value: '', + )); + }); + } + + QueryBuilder isCoinbaseIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isCoinbase', + )); + }); + } + + QueryBuilder isCoinbaseIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isCoinbase', + )); + }); + } + + QueryBuilder isCoinbaseEqualTo( + bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isCoinbase', + value: value, + )); + }); + } + + QueryBuilder scriptSigIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scriptSig', + )); + }); + } + + QueryBuilder scriptSigIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scriptSig', + )); + }); + } + + QueryBuilder scriptSigEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptSig', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scriptSig', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scriptSig', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scriptSig', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'scriptSig', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'scriptSig', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'scriptSig', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'scriptSig', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptSig', + value: '', + )); + }); + } + + QueryBuilder scriptSigIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'scriptSig', + value: '', + )); + }); + } + + QueryBuilder scriptSigAsmIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scriptSigAsm', + )); + }); + } + + QueryBuilder scriptSigAsmIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scriptSigAsm', + )); + }); + } + + QueryBuilder scriptSigAsmEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptSigAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scriptSigAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scriptSigAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scriptSigAsm', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'scriptSigAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'scriptSigAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'scriptSigAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'scriptSigAsm', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptSigAsmIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptSigAsm', + value: '', + )); + }); + } + + QueryBuilder scriptSigAsmIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'scriptSigAsm', + value: '', + )); + }); + } + + QueryBuilder sequenceIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'sequence', + )); + }); + } + + QueryBuilder sequenceIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'sequence', + )); + }); + } + + QueryBuilder sequenceEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'sequence', + value: value, + )); + }); + } + + QueryBuilder sequenceGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'sequence', + value: value, + )); + }); + } + + QueryBuilder sequenceLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'sequence', + value: value, + )); + }); + } + + QueryBuilder sequenceBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'sequence', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder txidEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'txid', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'txid', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: '', + )); + }); + } + + QueryBuilder txidIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'txid', + value: '', + )); + }); + } + + QueryBuilder voutEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'vout', + value: value, + )); + }); + } + + QueryBuilder voutGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'vout', + value: value, + )); + }); + } + + QueryBuilder voutLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'vout', + value: value, + )); + }); + } + + QueryBuilder voutBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'vout', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension InputQueryObject on QueryBuilder {} + +extension InputQueryLinks on QueryBuilder { + QueryBuilder prevOut( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'prevOut'); + }); + } + + QueryBuilder prevOutIsNull() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'prevOut', 0, true, 0, true); + }); + } + + QueryBuilder transaction( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'transaction'); + }); + } + + QueryBuilder transactionIsNull() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', 0, true, 0, true); + }); + } +} + +extension InputQuerySortBy on QueryBuilder { + QueryBuilder sortByInnerRedeemScriptAsm() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'innerRedeemScriptAsm', Sort.asc); + }); + } + + QueryBuilder sortByInnerRedeemScriptAsmDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'innerRedeemScriptAsm', Sort.desc); + }); + } + + QueryBuilder sortByIsCoinbase() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.asc); + }); + } + + QueryBuilder sortByIsCoinbaseDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.desc); + }); + } + + QueryBuilder sortByScriptSig() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSig', Sort.asc); + }); + } + + QueryBuilder sortByScriptSigDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSig', Sort.desc); + }); + } + + QueryBuilder sortByScriptSigAsm() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSigAsm', Sort.asc); + }); + } + + QueryBuilder sortByScriptSigAsmDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSigAsm', Sort.desc); + }); + } + + QueryBuilder sortBySequence() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sequence', Sort.asc); + }); + } + + QueryBuilder sortBySequenceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sequence', Sort.desc); + }); + } + + QueryBuilder sortByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder sortByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + + QueryBuilder sortByVout() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.asc); + }); + } + + QueryBuilder sortByVoutDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.desc); + }); + } +} + +extension InputQuerySortThenBy on QueryBuilder { + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByInnerRedeemScriptAsm() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'innerRedeemScriptAsm', Sort.asc); + }); + } + + QueryBuilder thenByInnerRedeemScriptAsmDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'innerRedeemScriptAsm', Sort.desc); + }); + } + + QueryBuilder thenByIsCoinbase() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.asc); + }); + } + + QueryBuilder thenByIsCoinbaseDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.desc); + }); + } + + QueryBuilder thenByScriptSig() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSig', Sort.asc); + }); + } + + QueryBuilder thenByScriptSigDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSig', Sort.desc); + }); + } + + QueryBuilder thenByScriptSigAsm() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSigAsm', Sort.asc); + }); + } + + QueryBuilder thenByScriptSigAsmDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptSigAsm', Sort.desc); + }); + } + + QueryBuilder thenBySequence() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sequence', Sort.asc); + }); + } + + QueryBuilder thenBySequenceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'sequence', Sort.desc); + }); + } + + QueryBuilder thenByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder thenByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + + QueryBuilder thenByVout() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.asc); + }); + } + + QueryBuilder thenByVoutDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.desc); + }); + } +} + +extension InputQueryWhereDistinct on QueryBuilder { + QueryBuilder distinctByInnerRedeemScriptAsm( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'innerRedeemScriptAsm', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByIsCoinbase() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isCoinbase'); + }); + } + + QueryBuilder distinctByScriptSig( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'scriptSig', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByScriptSigAsm( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'scriptSigAsm', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySequence() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'sequence'); + }); + } + + QueryBuilder distinctByTxid( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'txid', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByVout() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'vout'); + }); + } +} + +extension InputQueryProperty on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder + innerRedeemScriptAsmProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'innerRedeemScriptAsm'); + }); + } + + QueryBuilder isCoinbaseProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isCoinbase'); + }); + } + + QueryBuilder scriptSigProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scriptSig'); + }); + } + + QueryBuilder scriptSigAsmProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scriptSigAsm'); + }); + } + + QueryBuilder sequenceProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'sequence'); + }); + } + + QueryBuilder txidProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'txid'); + }); + } + + QueryBuilder voutProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'vout'); + }); + } +} diff --git a/lib/models/isar/models/blockchain_data/output.dart b/lib/models/isar/models/blockchain_data/output.dart index 5c34800ad..0e4361a15 100644 --- a/lib/models/isar/models/blockchain_data/output.dart +++ b/lib/models/isar/models/blockchain_data/output.dart @@ -1,6 +1,8 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; +part 'output.g.dart'; + @Collection() class Output { Id id = Isar.autoIncrement; diff --git a/lib/models/isar/models/blockchain_data/output.g.dart b/lib/models/isar/models/blockchain_data/output.g.dart new file mode 100644 index 000000000..086fd0684 --- /dev/null +++ b/lib/models/isar/models/blockchain_data/output.g.dart @@ -0,0 +1,1152 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'output.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetOutputCollection on Isar { + IsarCollection get outputs => this.collection(); +} + +const OutputSchema = CollectionSchema( + name: r'Output', + id: 3359341097909611106, + properties: { + r'scriptPubKey': PropertySchema( + id: 0, + name: r'scriptPubKey', + type: IsarType.string, + ), + r'scriptPubKeyAddress': PropertySchema( + id: 1, + name: r'scriptPubKeyAddress', + type: IsarType.string, + ), + r'scriptPubKeyAsm': PropertySchema( + id: 2, + name: r'scriptPubKeyAsm', + type: IsarType.string, + ), + r'scriptPubKeyType': PropertySchema( + id: 3, + name: r'scriptPubKeyType', + type: IsarType.string, + ), + r'value': PropertySchema( + id: 4, + name: r'value', + type: IsarType.long, + ) + }, + estimateSize: _outputEstimateSize, + serialize: _outputSerialize, + deserialize: _outputDeserialize, + deserializeProp: _outputDeserializeProp, + idName: r'id', + indexes: {}, + links: { + r'transaction': LinkSchema( + id: -2089310750171432135, + name: r'transaction', + target: r'Transaction', + single: true, + linkName: r'outputs', + ) + }, + embeddedSchemas: {}, + getId: _outputGetId, + getLinks: _outputGetLinks, + attach: _outputAttach, + version: '3.0.5', +); + +int _outputEstimateSize( + Output object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.scriptPubKey; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.scriptPubKeyAddress.length * 3; + { + final value = object.scriptPubKeyAsm; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.scriptPubKeyType; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + return bytesCount; +} + +void _outputSerialize( + Output object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.scriptPubKey); + writer.writeString(offsets[1], object.scriptPubKeyAddress); + writer.writeString(offsets[2], object.scriptPubKeyAsm); + writer.writeString(offsets[3], object.scriptPubKeyType); + writer.writeLong(offsets[4], object.value); +} + +Output _outputDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = Output(); + object.id = id; + object.scriptPubKey = reader.readStringOrNull(offsets[0]); + object.scriptPubKeyAddress = reader.readString(offsets[1]); + object.scriptPubKeyAsm = reader.readStringOrNull(offsets[2]); + object.scriptPubKeyType = reader.readStringOrNull(offsets[3]); + object.value = reader.readLong(offsets[4]); + return object; +} + +P _outputDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readStringOrNull(offset)) as P; + case 3: + return (reader.readStringOrNull(offset)) as P; + case 4: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _outputGetId(Output object) { + return object.id; +} + +List> _outputGetLinks(Output object) { + return [object.transaction]; +} + +void _outputAttach(IsarCollection col, Id id, Output object) { + object.id = id; + object.transaction + .attach(col, col.isar.collection(), r'transaction', id); +} + +extension OutputQueryWhereSort on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension OutputQueryWhere on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } +} + +extension OutputQueryFilter on QueryBuilder { + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder scriptPubKeyIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scriptPubKey', + )); + }); + } + + QueryBuilder scriptPubKeyIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scriptPubKey', + )); + }); + } + + QueryBuilder scriptPubKeyEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scriptPubKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scriptPubKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scriptPubKey', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'scriptPubKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'scriptPubKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'scriptPubKey', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'scriptPubKey', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKey', + value: '', + )); + }); + } + + QueryBuilder scriptPubKeyIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'scriptPubKey', + value: '', + )); + }); + } + + QueryBuilder + scriptPubKeyAddressEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKeyAddress', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scriptPubKeyAddress', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scriptPubKeyAddress', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scriptPubKeyAddress', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'scriptPubKeyAddress', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'scriptPubKeyAddress', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'scriptPubKeyAddress', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'scriptPubKeyAddress', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAddressIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKeyAddress', + value: '', + )); + }); + } + + QueryBuilder + scriptPubKeyAddressIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'scriptPubKeyAddress', + value: '', + )); + }); + } + + QueryBuilder scriptPubKeyAsmIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scriptPubKeyAsm', + )); + }); + } + + QueryBuilder + scriptPubKeyAsmIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scriptPubKeyAsm', + )); + }); + } + + QueryBuilder scriptPubKeyAsmEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKeyAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyAsmGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scriptPubKeyAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyAsmLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scriptPubKeyAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyAsmBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scriptPubKeyAsm', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyAsmStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'scriptPubKeyAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyAsmEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'scriptPubKeyAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyAsmContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'scriptPubKeyAsm', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyAsmMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'scriptPubKeyAsm', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyAsmIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKeyAsm', + value: '', + )); + }); + } + + QueryBuilder + scriptPubKeyAsmIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'scriptPubKeyAsm', + value: '', + )); + }); + } + + QueryBuilder scriptPubKeyTypeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'scriptPubKeyType', + )); + }); + } + + QueryBuilder + scriptPubKeyTypeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'scriptPubKeyType', + )); + }); + } + + QueryBuilder scriptPubKeyTypeEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKeyType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyTypeGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'scriptPubKeyType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyTypeLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'scriptPubKeyType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyTypeBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'scriptPubKeyType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyTypeStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'scriptPubKeyType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyTypeEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'scriptPubKeyType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyTypeContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'scriptPubKeyType', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder scriptPubKeyTypeMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'scriptPubKeyType', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + scriptPubKeyTypeIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'scriptPubKeyType', + value: '', + )); + }); + } + + QueryBuilder + scriptPubKeyTypeIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'scriptPubKeyType', + value: '', + )); + }); + } + + QueryBuilder valueEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: value, + )); + }); + } + + QueryBuilder valueGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'value', + value: value, + )); + }); + } + + QueryBuilder valueLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'value', + value: value, + )); + }); + } + + QueryBuilder valueBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'value', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension OutputQueryObject on QueryBuilder {} + +extension OutputQueryLinks on QueryBuilder { + QueryBuilder transaction( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'transaction'); + }); + } + + QueryBuilder transactionIsNull() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', 0, true, 0, true); + }); + } +} + +extension OutputQuerySortBy on QueryBuilder { + QueryBuilder sortByScriptPubKey() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKey', Sort.asc); + }); + } + + QueryBuilder sortByScriptPubKeyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKey', Sort.desc); + }); + } + + QueryBuilder sortByScriptPubKeyAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAddress', Sort.asc); + }); + } + + QueryBuilder sortByScriptPubKeyAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAddress', Sort.desc); + }); + } + + QueryBuilder sortByScriptPubKeyAsm() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAsm', Sort.asc); + }); + } + + QueryBuilder sortByScriptPubKeyAsmDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAsm', Sort.desc); + }); + } + + QueryBuilder sortByScriptPubKeyType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyType', Sort.asc); + }); + } + + QueryBuilder sortByScriptPubKeyTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyType', Sort.desc); + }); + } + + QueryBuilder sortByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder sortByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } +} + +extension OutputQuerySortThenBy on QueryBuilder { + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByScriptPubKey() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKey', Sort.asc); + }); + } + + QueryBuilder thenByScriptPubKeyDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKey', Sort.desc); + }); + } + + QueryBuilder thenByScriptPubKeyAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAddress', Sort.asc); + }); + } + + QueryBuilder thenByScriptPubKeyAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAddress', Sort.desc); + }); + } + + QueryBuilder thenByScriptPubKeyAsm() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAsm', Sort.asc); + }); + } + + QueryBuilder thenByScriptPubKeyAsmDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyAsm', Sort.desc); + }); + } + + QueryBuilder thenByScriptPubKeyType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyType', Sort.asc); + }); + } + + QueryBuilder thenByScriptPubKeyTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'scriptPubKeyType', Sort.desc); + }); + } + + QueryBuilder thenByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder thenByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } +} + +extension OutputQueryWhereDistinct on QueryBuilder { + QueryBuilder distinctByScriptPubKey( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'scriptPubKey', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByScriptPubKeyAddress( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'scriptPubKeyAddress', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByScriptPubKeyAsm( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'scriptPubKeyAsm', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByScriptPubKeyType( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'scriptPubKeyType', + caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByValue() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'value'); + }); + } +} + +extension OutputQueryProperty on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder scriptPubKeyProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scriptPubKey'); + }); + } + + QueryBuilder scriptPubKeyAddressProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scriptPubKeyAddress'); + }); + } + + QueryBuilder scriptPubKeyAsmProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scriptPubKeyAsm'); + }); + } + + QueryBuilder scriptPubKeyTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'scriptPubKeyType'); + }); + } + + QueryBuilder valueProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'value'); + }); + } +} diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 522b30730..e5c4abd6a 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -3,6 +3,8 @@ import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; import 'package:stackwallet/models/isar/models/transaction_note.dart'; +part 'transaction.g.dart'; + @Collection() class Transaction { Id id = Isar.autoIncrement; @@ -15,8 +17,10 @@ class Transaction { late int timestamp; + @enumerated late TransactionType txType; + @enumerated late TransactionSubType subType; late int amount; @@ -47,25 +51,21 @@ class Transaction { // Used in Isar db and stored there as int indexes so adding/removing values // in this definition should be done extremely carefully in production -enum TransactionType with IsarEnum { +enum TransactionType { // TODO: add more types before prod release? outgoing, incoming, sendToSelf, // should we keep this? anonymize; // firo specific - @override - int get value => index; } // Used in Isar db and stored there as int indexes so adding/removing values // in this definition should be done extremely carefully in production -enum TransactionSubType with IsarEnum { +enum TransactionSubType { // TODO: add more types before prod release? none, bip47Notification, // bip47 payment code notification transaction flag mint; // firo specific - @override - int get value => index; } diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart new file mode 100644 index 000000000..0e968227d --- /dev/null +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -0,0 +1,2213 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'transaction.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetTransactionCollection on Isar { + IsarCollection get transactions => this.collection(); +} + +const TransactionSchema = CollectionSchema( + name: r'Transaction', + id: 5320225499417954855, + properties: { + r'address': PropertySchema( + id: 0, + name: r'address', + type: IsarType.string, + ), + r'amount': PropertySchema( + id: 1, + name: r'amount', + type: IsarType.long, + ), + r'cancelled': PropertySchema( + id: 2, + name: r'cancelled', + type: IsarType.bool, + ), + r'confirmations': PropertySchema( + id: 3, + name: r'confirmations', + type: IsarType.long, + ), + r'confirmed': PropertySchema( + id: 4, + name: r'confirmed', + type: IsarType.bool, + ), + r'fee': PropertySchema( + id: 5, + name: r'fee', + type: IsarType.long, + ), + r'height': PropertySchema( + id: 6, + name: r'height', + type: IsarType.long, + ), + r'otherData': PropertySchema( + id: 7, + name: r'otherData', + type: IsarType.string, + ), + r'slateId': PropertySchema( + id: 8, + name: r'slateId', + type: IsarType.string, + ), + r'subType': PropertySchema( + id: 9, + name: r'subType', + type: IsarType.byte, + enumMap: _TransactionsubTypeEnumValueMap, + ), + r'timestamp': PropertySchema( + id: 10, + name: r'timestamp', + type: IsarType.long, + ), + r'txType': PropertySchema( + id: 11, + name: r'txType', + type: IsarType.byte, + enumMap: _TransactiontxTypeEnumValueMap, + ), + r'txid': PropertySchema( + id: 12, + name: r'txid', + type: IsarType.string, + ), + r'worthAtBlockTimestamp': PropertySchema( + id: 13, + name: r'worthAtBlockTimestamp', + type: IsarType.string, + ) + }, + estimateSize: _transactionEstimateSize, + serialize: _transactionSerialize, + deserialize: _transactionDeserialize, + deserializeProp: _transactionDeserializeProp, + idName: r'id', + indexes: {}, + links: { + r'inputs': LinkSchema( + id: 4634425919890543640, + name: r'inputs', + target: r'Input', + single: false, + ), + r'outputs': LinkSchema( + id: 1341997944984495532, + name: r'outputs', + target: r'Output', + single: false, + ), + r'note': LinkSchema( + id: 1009915346265072213, + name: r'note', + target: r'TransactionNote', + single: true, + ) + }, + embeddedSchemas: {}, + getId: _transactionGetId, + getLinks: _transactionGetLinks, + attach: _transactionAttach, + version: '3.0.5', +); + +int _transactionEstimateSize( + Transaction object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.address.length * 3; + { + final value = object.otherData; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + { + final value = object.slateId; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.txid.length * 3; + bytesCount += 3 + object.worthAtBlockTimestamp.length * 3; + return bytesCount; +} + +void _transactionSerialize( + Transaction object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.address); + writer.writeLong(offsets[1], object.amount); + writer.writeBool(offsets[2], object.cancelled); + writer.writeLong(offsets[3], object.confirmations); + writer.writeBool(offsets[4], object.confirmed); + writer.writeLong(offsets[5], object.fee); + writer.writeLong(offsets[6], object.height); + writer.writeString(offsets[7], object.otherData); + writer.writeString(offsets[8], object.slateId); + writer.writeByte(offsets[9], object.subType.index); + writer.writeLong(offsets[10], object.timestamp); + writer.writeByte(offsets[11], object.txType.index); + writer.writeString(offsets[12], object.txid); + writer.writeString(offsets[13], object.worthAtBlockTimestamp); +} + +Transaction _transactionDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = Transaction(); + object.address = reader.readString(offsets[0]); + object.amount = reader.readLong(offsets[1]); + object.cancelled = reader.readBool(offsets[2]); + object.confirmations = reader.readLong(offsets[3]); + object.confirmed = reader.readBool(offsets[4]); + object.fee = reader.readLong(offsets[5]); + object.height = reader.readLong(offsets[6]); + object.id = id; + object.otherData = reader.readStringOrNull(offsets[7]); + object.slateId = reader.readStringOrNull(offsets[8]); + object.subType = + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[9])] ?? + TransactionSubType.none; + object.timestamp = reader.readLong(offsets[10]); + object.txType = + _TransactiontxTypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? + TransactionType.outgoing; + object.txid = reader.readString(offsets[12]); + object.worthAtBlockTimestamp = reader.readString(offsets[13]); + return object; +} + +P _transactionDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + case 2: + return (reader.readBool(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readBool(offset)) as P; + case 5: + return (reader.readLong(offset)) as P; + case 6: + return (reader.readLong(offset)) as P; + case 7: + return (reader.readStringOrNull(offset)) as P; + case 8: + return (reader.readStringOrNull(offset)) as P; + case 9: + return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? + TransactionSubType.none) as P; + case 10: + return (reader.readLong(offset)) as P; + case 11: + return (_TransactiontxTypeValueEnumMap[reader.readByteOrNull(offset)] ?? + TransactionType.outgoing) as P; + case 12: + return (reader.readString(offset)) as P; + case 13: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _TransactionsubTypeEnumValueMap = { + 'none': 0, + 'bip47Notification': 1, + 'mint': 2, +}; +const _TransactionsubTypeValueEnumMap = { + 0: TransactionSubType.none, + 1: TransactionSubType.bip47Notification, + 2: TransactionSubType.mint, +}; +const _TransactiontxTypeEnumValueMap = { + 'outgoing': 0, + 'incoming': 1, + 'sendToSelf': 2, + 'anonymize': 3, +}; +const _TransactiontxTypeValueEnumMap = { + 0: TransactionType.outgoing, + 1: TransactionType.incoming, + 2: TransactionType.sendToSelf, + 3: TransactionType.anonymize, +}; + +Id _transactionGetId(Transaction object) { + return object.id; +} + +List> _transactionGetLinks(Transaction object) { + return [object.inputs, object.outputs, object.note]; +} + +void _transactionAttach( + IsarCollection col, Id id, Transaction object) { + object.id = id; + object.inputs.attach(col, col.isar.collection(), r'inputs', id); + object.outputs.attach(col, col.isar.collection(), r'outputs', id); + object.note.attach(col, col.isar.collection(), r'note', id); +} + +extension TransactionQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension TransactionQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } +} + +extension TransactionQueryFilter + on QueryBuilder { + QueryBuilder addressEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'address', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'address', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder + addressIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder amountEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amount', + value: value, + )); + }); + } + + QueryBuilder + amountGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'amount', + value: value, + )); + }); + } + + QueryBuilder amountLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'amount', + value: value, + )); + }); + } + + QueryBuilder amountBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'amount', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + cancelledEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'cancelled', + value: value, + )); + }); + } + + QueryBuilder + confirmationsEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'confirmations', + value: value, + )); + }); + } + + QueryBuilder + confirmationsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'confirmations', + value: value, + )); + }); + } + + QueryBuilder + confirmationsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'confirmations', + value: value, + )); + }); + } + + QueryBuilder + confirmationsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'confirmations', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + confirmedEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'confirmed', + value: value, + )); + }); + } + + QueryBuilder feeEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fee', + value: value, + )); + }); + } + + QueryBuilder feeGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'fee', + value: value, + )); + }); + } + + QueryBuilder feeLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'fee', + value: value, + )); + }); + } + + QueryBuilder feeBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'fee', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder heightEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'height', + value: value, + )); + }); + } + + QueryBuilder + heightGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'height', + value: value, + )); + }); + } + + QueryBuilder heightLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'height', + value: value, + )); + }); + } + + QueryBuilder heightBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'height', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + otherDataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'otherData', + )); + }); + } + + QueryBuilder + otherDataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'otherData', + )); + }); + } + + QueryBuilder + otherDataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'otherData', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'otherData', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + otherDataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'otherData', + value: '', + )); + }); + } + + QueryBuilder + otherDataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'otherData', + value: '', + )); + }); + } + + QueryBuilder + slateIdIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'slateId', + )); + }); + } + + QueryBuilder + slateIdIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'slateId', + )); + }); + } + + QueryBuilder slateIdEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'slateId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + slateIdGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'slateId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder slateIdLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'slateId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder slateIdBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'slateId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + slateIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'slateId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder slateIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'slateId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder slateIdContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'slateId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder slateIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'slateId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + slateIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'slateId', + value: '', + )); + }); + } + + QueryBuilder + slateIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'slateId', + value: '', + )); + }); + } + + QueryBuilder subTypeEqualTo( + TransactionSubType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'subType', + value: value, + )); + }); + } + + QueryBuilder + subTypeGreaterThan( + TransactionSubType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'subType', + value: value, + )); + }); + } + + QueryBuilder subTypeLessThan( + TransactionSubType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'subType', + value: value, + )); + }); + } + + QueryBuilder subTypeBetween( + TransactionSubType lower, + TransactionSubType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'subType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + timestampEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'timestamp', + value: value, + )); + }); + } + + QueryBuilder + timestampGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'timestamp', + value: value, + )); + }); + } + + QueryBuilder + timestampLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'timestamp', + value: value, + )); + }); + } + + QueryBuilder + timestampBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'timestamp', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder txTypeEqualTo( + TransactionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txType', + value: value, + )); + }); + } + + QueryBuilder + txTypeGreaterThan( + TransactionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'txType', + value: value, + )); + }); + } + + QueryBuilder txTypeLessThan( + TransactionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'txType', + value: value, + )); + }); + } + + QueryBuilder txTypeBetween( + TransactionType lower, + TransactionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'txType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder txidEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'txid', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'txid', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: '', + )); + }); + } + + QueryBuilder + txidIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'txid', + value: '', + )); + }); + } + + QueryBuilder + worthAtBlockTimestampEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'worthAtBlockTimestamp', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'worthAtBlockTimestamp', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'worthAtBlockTimestamp', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'worthAtBlockTimestamp', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'worthAtBlockTimestamp', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'worthAtBlockTimestamp', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'worthAtBlockTimestamp', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'worthAtBlockTimestamp', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + worthAtBlockTimestampIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'worthAtBlockTimestamp', + value: '', + )); + }); + } + + QueryBuilder + worthAtBlockTimestampIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'worthAtBlockTimestamp', + value: '', + )); + }); + } +} + +extension TransactionQueryObject + on QueryBuilder {} + +extension TransactionQueryLinks + on QueryBuilder { + QueryBuilder inputs( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'inputs'); + }); + } + + QueryBuilder + inputsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'inputs', length, true, length, true); + }); + } + + QueryBuilder + inputsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'inputs', 0, true, 0, true); + }); + } + + QueryBuilder + inputsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'inputs', 0, false, 999999, true); + }); + } + + QueryBuilder + inputsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'inputs', 0, true, length, include); + }); + } + + QueryBuilder + inputsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'inputs', length, include, 999999, true); + }); + } + + QueryBuilder + inputsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength( + r'inputs', lower, includeLower, upper, includeUpper); + }); + } + + QueryBuilder outputs( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'outputs'); + }); + } + + QueryBuilder + outputsLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'outputs', length, true, length, true); + }); + } + + QueryBuilder + outputsIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'outputs', 0, true, 0, true); + }); + } + + QueryBuilder + outputsIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'outputs', 0, false, 999999, true); + }); + } + + QueryBuilder + outputsLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'outputs', 0, true, length, include); + }); + } + + QueryBuilder + outputsLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'outputs', length, include, 999999, true); + }); + } + + QueryBuilder + outputsLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength( + r'outputs', lower, includeLower, upper, includeUpper); + }); + } + + QueryBuilder note( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'note'); + }); + } + + QueryBuilder noteIsNull() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'note', 0, true, 0, true); + }); + } +} + +extension TransactionQuerySortBy + on QueryBuilder { + QueryBuilder sortByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder sortByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder sortByAmount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amount', Sort.asc); + }); + } + + QueryBuilder sortByAmountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amount', Sort.desc); + }); + } + + QueryBuilder sortByCancelled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'cancelled', Sort.asc); + }); + } + + QueryBuilder sortByCancelledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'cancelled', Sort.desc); + }); + } + + QueryBuilder sortByConfirmations() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmations', Sort.asc); + }); + } + + QueryBuilder + sortByConfirmationsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmations', Sort.desc); + }); + } + + QueryBuilder sortByConfirmed() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmed', Sort.asc); + }); + } + + QueryBuilder sortByConfirmedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmed', Sort.desc); + }); + } + + QueryBuilder sortByFee() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fee', Sort.asc); + }); + } + + QueryBuilder sortByFeeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fee', Sort.desc); + }); + } + + QueryBuilder sortByHeight() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'height', Sort.asc); + }); + } + + QueryBuilder sortByHeightDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'height', Sort.desc); + }); + } + + QueryBuilder sortByOtherData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.asc); + }); + } + + QueryBuilder sortByOtherDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.desc); + }); + } + + QueryBuilder sortBySlateId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'slateId', Sort.asc); + }); + } + + QueryBuilder sortBySlateIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'slateId', Sort.desc); + }); + } + + QueryBuilder sortBySubType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.asc); + }); + } + + QueryBuilder sortBySubTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.desc); + }); + } + + QueryBuilder sortByTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'timestamp', Sort.asc); + }); + } + + QueryBuilder sortByTimestampDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'timestamp', Sort.desc); + }); + } + + QueryBuilder sortByTxType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txType', Sort.asc); + }); + } + + QueryBuilder sortByTxTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txType', Sort.desc); + }); + } + + QueryBuilder sortByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder sortByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + + QueryBuilder + sortByWorthAtBlockTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'worthAtBlockTimestamp', Sort.asc); + }); + } + + QueryBuilder + sortByWorthAtBlockTimestampDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'worthAtBlockTimestamp', Sort.desc); + }); + } +} + +extension TransactionQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder thenByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder thenByAmount() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amount', Sort.asc); + }); + } + + QueryBuilder thenByAmountDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amount', Sort.desc); + }); + } + + QueryBuilder thenByCancelled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'cancelled', Sort.asc); + }); + } + + QueryBuilder thenByCancelledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'cancelled', Sort.desc); + }); + } + + QueryBuilder thenByConfirmations() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmations', Sort.asc); + }); + } + + QueryBuilder + thenByConfirmationsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmations', Sort.desc); + }); + } + + QueryBuilder thenByConfirmed() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmed', Sort.asc); + }); + } + + QueryBuilder thenByConfirmedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'confirmed', Sort.desc); + }); + } + + QueryBuilder thenByFee() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fee', Sort.asc); + }); + } + + QueryBuilder thenByFeeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fee', Sort.desc); + }); + } + + QueryBuilder thenByHeight() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'height', Sort.asc); + }); + } + + QueryBuilder thenByHeightDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'height', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByOtherData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.asc); + }); + } + + QueryBuilder thenByOtherDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.desc); + }); + } + + QueryBuilder thenBySlateId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'slateId', Sort.asc); + }); + } + + QueryBuilder thenBySlateIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'slateId', Sort.desc); + }); + } + + QueryBuilder thenBySubType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.asc); + }); + } + + QueryBuilder thenBySubTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.desc); + }); + } + + QueryBuilder thenByTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'timestamp', Sort.asc); + }); + } + + QueryBuilder thenByTimestampDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'timestamp', Sort.desc); + }); + } + + QueryBuilder thenByTxType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txType', Sort.asc); + }); + } + + QueryBuilder thenByTxTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txType', Sort.desc); + }); + } + + QueryBuilder thenByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder thenByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + + QueryBuilder + thenByWorthAtBlockTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'worthAtBlockTimestamp', Sort.asc); + }); + } + + QueryBuilder + thenByWorthAtBlockTimestampDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'worthAtBlockTimestamp', Sort.desc); + }); + } +} + +extension TransactionQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByAddress( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'address', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByAmount() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'amount'); + }); + } + + QueryBuilder distinctByCancelled() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'cancelled'); + }); + } + + QueryBuilder distinctByConfirmations() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'confirmations'); + }); + } + + QueryBuilder distinctByConfirmed() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'confirmed'); + }); + } + + QueryBuilder distinctByFee() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'fee'); + }); + } + + QueryBuilder distinctByHeight() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'height'); + }); + } + + QueryBuilder distinctByOtherData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'otherData', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySlateId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'slateId', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySubType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'subType'); + }); + } + + QueryBuilder distinctByTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'timestamp'); + }); + } + + QueryBuilder distinctByTxType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'txType'); + }); + } + + QueryBuilder distinctByTxid( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'txid', caseSensitive: caseSensitive); + }); + } + + QueryBuilder + distinctByWorthAtBlockTimestamp({bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'worthAtBlockTimestamp', + caseSensitive: caseSensitive); + }); + } +} + +extension TransactionQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder addressProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'address'); + }); + } + + QueryBuilder amountProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'amount'); + }); + } + + QueryBuilder cancelledProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'cancelled'); + }); + } + + QueryBuilder confirmationsProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'confirmations'); + }); + } + + QueryBuilder confirmedProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'confirmed'); + }); + } + + QueryBuilder feeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'fee'); + }); + } + + QueryBuilder heightProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'height'); + }); + } + + QueryBuilder otherDataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'otherData'); + }); + } + + QueryBuilder slateIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'slateId'); + }); + } + + QueryBuilder + subTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'subType'); + }); + } + + QueryBuilder timestampProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'timestamp'); + }); + } + + QueryBuilder + txTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'txType'); + }); + } + + QueryBuilder txidProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'txid'); + }); + } + + QueryBuilder + worthAtBlockTimestampProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'worthAtBlockTimestamp'); + }); + } +} diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index 6539ea2cb..5882d0b61 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -1,5 +1,7 @@ import 'package:isar/isar.dart'; +part 'utxo.g.dart'; + @Collection() class UTXO { Id id = Isar.autoIncrement; @@ -23,8 +25,6 @@ class UTXO { @Embedded() class Status { - Id id = Isar.autoIncrement; - late bool confirmed; late int confirmations; diff --git a/lib/models/isar/models/blockchain_data/utxo.g.dart b/lib/models/isar/models/blockchain_data/utxo.g.dart new file mode 100644 index 000000000..7511b11df --- /dev/null +++ b/lib/models/isar/models/blockchain_data/utxo.g.dart @@ -0,0 +1,1520 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'utxo.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetUTXOCollection on Isar { + IsarCollection get uTXOs => this.collection(); +} + +const UTXOSchema = CollectionSchema( + name: r'UTXO', + id: 5934032492047519621, + properties: { + r'blocked': PropertySchema( + id: 0, + name: r'blocked', + type: IsarType.bool, + ), + r'fiatWorth': PropertySchema( + id: 1, + name: r'fiatWorth', + type: IsarType.string, + ), + r'isCoinbase': PropertySchema( + id: 2, + name: r'isCoinbase', + type: IsarType.bool, + ), + r'status': PropertySchema( + id: 3, + name: r'status', + type: IsarType.object, + target: r'Status', + ), + r'txName': PropertySchema( + id: 4, + name: r'txName', + type: IsarType.string, + ), + r'txid': PropertySchema( + id: 5, + name: r'txid', + type: IsarType.string, + ), + r'value': PropertySchema( + id: 6, + name: r'value', + type: IsarType.long, + ), + r'vout': PropertySchema( + id: 7, + name: r'vout', + type: IsarType.long, + ) + }, + estimateSize: _uTXOEstimateSize, + serialize: _uTXOSerialize, + deserialize: _uTXODeserialize, + deserializeProp: _uTXODeserializeProp, + idName: r'id', + indexes: {}, + links: {}, + embeddedSchemas: {r'Status': StatusSchema}, + getId: _uTXOGetId, + getLinks: _uTXOGetLinks, + attach: _uTXOAttach, + version: '3.0.5', +); + +int _uTXOEstimateSize( + UTXO object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.fiatWorth.length * 3; + bytesCount += 3 + + StatusSchema.estimateSize(object.status, allOffsets[Status]!, allOffsets); + bytesCount += 3 + object.txName.length * 3; + bytesCount += 3 + object.txid.length * 3; + return bytesCount; +} + +void _uTXOSerialize( + UTXO object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeBool(offsets[0], object.blocked); + writer.writeString(offsets[1], object.fiatWorth); + writer.writeBool(offsets[2], object.isCoinbase); + writer.writeObject( + offsets[3], + allOffsets, + StatusSchema.serialize, + object.status, + ); + writer.writeString(offsets[4], object.txName); + writer.writeString(offsets[5], object.txid); + writer.writeLong(offsets[6], object.value); + writer.writeLong(offsets[7], object.vout); +} + +UTXO _uTXODeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = UTXO(); + object.blocked = reader.readBool(offsets[0]); + object.fiatWorth = reader.readString(offsets[1]); + object.id = id; + object.isCoinbase = reader.readBool(offsets[2]); + object.status = reader.readObjectOrNull( + offsets[3], + StatusSchema.deserialize, + allOffsets, + ) ?? + Status(); + object.txName = reader.readString(offsets[4]); + object.txid = reader.readString(offsets[5]); + object.value = reader.readLong(offsets[6]); + object.vout = reader.readLong(offsets[7]); + return object; +} + +P _uTXODeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readBool(offset)) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readBool(offset)) as P; + case 3: + return (reader.readObjectOrNull( + offset, + StatusSchema.deserialize, + allOffsets, + ) ?? + Status()) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (reader.readString(offset)) as P; + case 6: + return (reader.readLong(offset)) as P; + case 7: + return (reader.readLong(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _uTXOGetId(UTXO object) { + return object.id; +} + +List> _uTXOGetLinks(UTXO object) { + return []; +} + +void _uTXOAttach(IsarCollection col, Id id, UTXO object) { + object.id = id; +} + +extension UTXOQueryWhereSort on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension UTXOQueryWhere on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } +} + +extension UTXOQueryFilter on QueryBuilder { + QueryBuilder blockedEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blocked', + value: value, + )); + }); + } + + QueryBuilder fiatWorthEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fiatWorth', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'fiatWorth', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'fiatWorth', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'fiatWorth', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'fiatWorth', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'fiatWorth', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'fiatWorth', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'fiatWorth', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder fiatWorthIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'fiatWorth', + value: '', + )); + }); + } + + QueryBuilder fiatWorthIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'fiatWorth', + value: '', + )); + }); + } + + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder isCoinbaseEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isCoinbase', + value: value, + )); + }); + } + + QueryBuilder txNameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'txName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'txName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'txName', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'txName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'txName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'txName', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'txName', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txNameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txName', + value: '', + )); + }); + } + + QueryBuilder txNameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'txName', + value: '', + )); + }); + } + + QueryBuilder txidEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'txid', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidMatches(String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'txid', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder txidIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: '', + )); + }); + } + + QueryBuilder txidIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'txid', + value: '', + )); + }); + } + + QueryBuilder valueEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: value, + )); + }); + } + + QueryBuilder valueGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'value', + value: value, + )); + }); + } + + QueryBuilder valueLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'value', + value: value, + )); + }); + } + + QueryBuilder valueBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'value', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder voutEqualTo(int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'vout', + value: value, + )); + }); + } + + QueryBuilder voutGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'vout', + value: value, + )); + }); + } + + QueryBuilder voutLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'vout', + value: value, + )); + }); + } + + QueryBuilder voutBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'vout', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension UTXOQueryObject on QueryBuilder { + QueryBuilder status( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.object(q, r'status'); + }); + } +} + +extension UTXOQueryLinks on QueryBuilder {} + +extension UTXOQuerySortBy on QueryBuilder { + QueryBuilder sortByBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blocked', Sort.asc); + }); + } + + QueryBuilder sortByBlockedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blocked', Sort.desc); + }); + } + + QueryBuilder sortByFiatWorth() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fiatWorth', Sort.asc); + }); + } + + QueryBuilder sortByFiatWorthDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fiatWorth', Sort.desc); + }); + } + + QueryBuilder sortByIsCoinbase() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.asc); + }); + } + + QueryBuilder sortByIsCoinbaseDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.desc); + }); + } + + QueryBuilder sortByTxName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txName', Sort.asc); + }); + } + + QueryBuilder sortByTxNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txName', Sort.desc); + }); + } + + QueryBuilder sortByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder sortByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + + QueryBuilder sortByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder sortByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } + + QueryBuilder sortByVout() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.asc); + }); + } + + QueryBuilder sortByVoutDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.desc); + }); + } +} + +extension UTXOQuerySortThenBy on QueryBuilder { + QueryBuilder thenByBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blocked', Sort.asc); + }); + } + + QueryBuilder thenByBlockedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blocked', Sort.desc); + }); + } + + QueryBuilder thenByFiatWorth() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fiatWorth', Sort.asc); + }); + } + + QueryBuilder thenByFiatWorthDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'fiatWorth', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByIsCoinbase() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.asc); + }); + } + + QueryBuilder thenByIsCoinbaseDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCoinbase', Sort.desc); + }); + } + + QueryBuilder thenByTxName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txName', Sort.asc); + }); + } + + QueryBuilder thenByTxNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txName', Sort.desc); + }); + } + + QueryBuilder thenByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder thenByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + + QueryBuilder thenByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder thenByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } + + QueryBuilder thenByVout() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.asc); + }); + } + + QueryBuilder thenByVoutDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'vout', Sort.desc); + }); + } +} + +extension UTXOQueryWhereDistinct on QueryBuilder { + QueryBuilder distinctByBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'blocked'); + }); + } + + QueryBuilder distinctByFiatWorth( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'fiatWorth', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByIsCoinbase() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isCoinbase'); + }); + } + + QueryBuilder distinctByTxName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'txName', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByTxid( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'txid', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByValue() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'value'); + }); + } + + QueryBuilder distinctByVout() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'vout'); + }); + } +} + +extension UTXOQueryProperty on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder blockedProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'blocked'); + }); + } + + QueryBuilder fiatWorthProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'fiatWorth'); + }); + } + + QueryBuilder isCoinbaseProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isCoinbase'); + }); + } + + QueryBuilder statusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'status'); + }); + } + + QueryBuilder txNameProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'txName'); + }); + } + + QueryBuilder txidProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'txid'); + }); + } + + QueryBuilder valueProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'value'); + }); + } + + QueryBuilder voutProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'vout'); + }); + } +} + +// ************************************************************************** +// IsarEmbeddedGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +const StatusSchema = Schema( + name: r'Status', + id: -8158262482337811485, + properties: { + r'blockHash': PropertySchema( + id: 0, + name: r'blockHash', + type: IsarType.string, + ), + r'blockHeight': PropertySchema( + id: 1, + name: r'blockHeight', + type: IsarType.long, + ), + r'blockTime': PropertySchema( + id: 2, + name: r'blockTime', + type: IsarType.long, + ), + r'confirmations': PropertySchema( + id: 3, + name: r'confirmations', + type: IsarType.long, + ), + r'confirmed': PropertySchema( + id: 4, + name: r'confirmed', + type: IsarType.bool, + ) + }, + estimateSize: _statusEstimateSize, + serialize: _statusSerialize, + deserialize: _statusDeserialize, + deserializeProp: _statusDeserializeProp, +); + +int _statusEstimateSize( + Status object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.blockHash.length * 3; + return bytesCount; +} + +void _statusSerialize( + Status object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.blockHash); + writer.writeLong(offsets[1], object.blockHeight); + writer.writeLong(offsets[2], object.blockTime); + writer.writeLong(offsets[3], object.confirmations); + writer.writeBool(offsets[4], object.confirmed); +} + +Status _statusDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = Status(); + object.blockHash = reader.readString(offsets[0]); + object.blockHeight = reader.readLong(offsets[1]); + object.blockTime = reader.readLong(offsets[2]); + object.confirmations = reader.readLong(offsets[3]); + object.confirmed = reader.readBool(offsets[4]); + return object; +} + +P _statusDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + case 1: + return (reader.readLong(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readLong(offset)) as P; + case 4: + return (reader.readBool(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +extension StatusQueryFilter on QueryBuilder { + QueryBuilder blockHashEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockHash', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'blockHash', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockHash', + value: '', + )); + }); + } + + QueryBuilder blockHashIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'blockHash', + value: '', + )); + }); + } + + QueryBuilder blockHeightEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockHeight', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder blockTimeEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockTime', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder confirmationsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'confirmations', + value: value, + )); + }); + } + + QueryBuilder confirmationsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'confirmations', + value: value, + )); + }); + } + + QueryBuilder confirmationsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'confirmations', + value: value, + )); + }); + } + + QueryBuilder confirmationsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'confirmations', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder confirmedEqualTo( + bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'confirmed', + value: value, + )); + }); + } +} + +extension StatusQueryObject on QueryBuilder {} diff --git a/lib/models/isar/models/encrypted_string_value.g.dart b/lib/models/isar/models/encrypted_string_value.g.dart index 2315c5d85..fdfe5527a 100644 --- a/lib/models/isar/models/encrypted_string_value.g.dart +++ b/lib/models/isar/models/encrypted_string_value.g.dart @@ -7,7 +7,7 @@ part of 'encrypted_string_value.dart'; // ************************************************************************** // coverage:ignore-file -// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, join_return_with_assignment, avoid_js_rounded_ints, prefer_final_locals +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters extension GetEncryptedStringValueCollection on Isar { IsarCollection get encryptedStringValues => @@ -30,12 +30,9 @@ const EncryptedStringValueSchema = CollectionSchema( ) }, estimateSize: _encryptedStringValueEstimateSize, - serializeNative: _encryptedStringValueSerializeNative, - deserializeNative: _encryptedStringValueDeserializeNative, - deserializePropNative: _encryptedStringValueDeserializePropNative, - serializeWeb: _encryptedStringValueSerializeWeb, - deserializeWeb: _encryptedStringValueDeserializeWeb, - deserializePropWeb: _encryptedStringValueDeserializePropWeb, + serialize: _encryptedStringValueSerialize, + deserialize: _encryptedStringValueDeserialize, + deserializeProp: _encryptedStringValueDeserializeProp, idName: r'id', indexes: { r'key': IndexSchema( @@ -57,7 +54,7 @@ const EncryptedStringValueSchema = CollectionSchema( getId: _encryptedStringValueGetId, getLinks: _encryptedStringValueGetLinks, attach: _encryptedStringValueAttach, - version: 5, + version: '3.0.5', ); int _encryptedStringValueEstimateSize( @@ -71,20 +68,19 @@ int _encryptedStringValueEstimateSize( return bytesCount; } -int _encryptedStringValueSerializeNative( +void _encryptedStringValueSerialize( EncryptedStringValue object, - IsarBinaryWriter writer, + IsarWriter writer, List offsets, Map> allOffsets, ) { writer.writeString(offsets[0], object.key); writer.writeString(offsets[1], object.value); - return writer.usedBytes; } -EncryptedStringValue _encryptedStringValueDeserializeNative( - int id, - IsarBinaryReader reader, +EncryptedStringValue _encryptedStringValueDeserialize( + Id id, + IsarReader reader, List offsets, Map> allOffsets, ) { @@ -95,9 +91,8 @@ EncryptedStringValue _encryptedStringValueDeserializeNative( return object; } -P _encryptedStringValueDeserializePropNative

( - Id id, - IsarBinaryReader reader, +P _encryptedStringValueDeserializeProp

( + IsarReader reader, int propertyId, int offset, Map> allOffsets, @@ -112,33 +107,8 @@ P _encryptedStringValueDeserializePropNative

( } } -Object _encryptedStringValueSerializeWeb( - IsarCollection collection, - EncryptedStringValue object) { - /*final jsObj = IsarNative.newJsObject();*/ throw UnimplementedError(); -} - -EncryptedStringValue _encryptedStringValueDeserializeWeb( - IsarCollection collection, Object jsObj) { - /*final object = EncryptedStringValue();object.id = IsarNative.jsObjectGet(jsObj, r'id') ?? (double.negativeInfinity as int);object.key = IsarNative.jsObjectGet(jsObj, r'key') ?? '';object.value = IsarNative.jsObjectGet(jsObj, r'value') ?? '';*/ - //return object; - throw UnimplementedError(); -} - -P _encryptedStringValueDeserializePropWeb

( - Object jsObj, String propertyName) { - switch (propertyName) { - default: - throw IsarError('Illegal propertyName'); - } -} - -int? _encryptedStringValueGetId(EncryptedStringValue object) { - if (object.id == Isar.autoIncrement) { - return null; - } else { - return object.id; - } +Id _encryptedStringValueGetId(EncryptedStringValue object) { + return object.id; } List> _encryptedStringValueGetLinks( @@ -188,19 +158,19 @@ extension EncryptedStringValueByIndex on IsarCollection { return deleteAllByIndexSync(r'key', values); } - Future putByKey(EncryptedStringValue object) { + Future putByKey(EncryptedStringValue object) { return putByIndex(r'key', object); } - int putByKeySync(EncryptedStringValue object, {bool saveLinks = true}) { + Id putByKeySync(EncryptedStringValue object, {bool saveLinks = true}) { return putByIndexSync(r'key', object, saveLinks: saveLinks); } - Future> putAllByKey(List objects) { + Future> putAllByKey(List objects) { return putAllByIndex(r'key', objects); } - List putAllByKeySync(List objects, + List putAllByKeySync(List objects, {bool saveLinks = true}) { return putAllByIndexSync(r'key', objects, saveLinks: saveLinks); } @@ -219,7 +189,7 @@ extension EncryptedStringValueQueryWhereSort extension EncryptedStringValueQueryWhere on QueryBuilder { QueryBuilder - idEqualTo(int id) { + idEqualTo(Id id) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IdWhereClause.between( lower: id, @@ -229,7 +199,7 @@ extension EncryptedStringValueQueryWhere } QueryBuilder - idNotEqualTo(int id) { + idNotEqualTo(Id id) { return QueryBuilder.apply(this, (query) { if (query.whereSort == Sort.asc) { return query @@ -252,7 +222,7 @@ extension EncryptedStringValueQueryWhere } QueryBuilder - idGreaterThan(int id, {bool include = false}) { + idGreaterThan(Id id, {bool include = false}) { return QueryBuilder.apply(this, (query) { return query.addWhereClause( IdWhereClause.greaterThan(lower: id, includeLower: include), @@ -261,7 +231,7 @@ extension EncryptedStringValueQueryWhere } QueryBuilder - idLessThan(int id, {bool include = false}) { + idLessThan(Id id, {bool include = false}) { return QueryBuilder.apply(this, (query) { return query.addWhereClause( IdWhereClause.lessThan(upper: id, includeUpper: include), @@ -271,8 +241,8 @@ extension EncryptedStringValueQueryWhere QueryBuilder idBetween( - int lowerId, - int upperId, { + Id lowerId, + Id upperId, { bool includeLower = true, bool includeUpper = true, }) { @@ -335,7 +305,7 @@ extension EncryptedStringValueQueryWhere extension EncryptedStringValueQueryFilter on QueryBuilder { QueryBuilder idEqualTo(int value) { + QAfterFilterCondition> idEqualTo(Id value) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'id', @@ -346,7 +316,7 @@ extension EncryptedStringValueQueryFilter on QueryBuilder idGreaterThan( - int value, { + Id value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { @@ -360,7 +330,7 @@ extension EncryptedStringValueQueryFilter on QueryBuilder idLessThan( - int value, { + Id value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { @@ -374,8 +344,8 @@ extension EncryptedStringValueQueryFilter on QueryBuilder idBetween( - int lower, - int upper, { + Id lower, + Id upper, { bool includeLower = true, bool includeUpper = true, }) { @@ -508,6 +478,26 @@ extension EncryptedStringValueQueryFilter on QueryBuilder keyIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'key', + value: '', + )); + }); + } + + QueryBuilder keyIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'key', + value: '', + )); + }); + } + QueryBuilder valueEqualTo( String value, { @@ -625,6 +615,26 @@ extension EncryptedStringValueQueryFilter on QueryBuilder valueIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: '', + )); + }); + } + + QueryBuilder valueIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'value', + value: '', + )); + }); + } } extension EncryptedStringValueQueryObject on QueryBuilder get logs => this.collection(); @@ -21,6 +21,7 @@ const LogSchema = CollectionSchema( id: 0, name: r'logLevel', type: IsarType.string, + enumMap: _LoglogLevelEnumValueMap, ), r'message': PropertySchema( id: 1, @@ -34,12 +35,9 @@ const LogSchema = CollectionSchema( ) }, estimateSize: _logEstimateSize, - serializeNative: _logSerializeNative, - deserializeNative: _logDeserializeNative, - deserializePropNative: _logDeserializePropNative, - serializeWeb: _logSerializeWeb, - deserializeWeb: _logDeserializeWeb, - deserializePropWeb: _logDeserializePropWeb, + serialize: _logSerialize, + deserialize: _logDeserialize, + deserializeProp: _logDeserializeProp, idName: r'id', indexes: { r'timestampInMillisUTC': IndexSchema( @@ -61,7 +59,7 @@ const LogSchema = CollectionSchema( getId: _logGetId, getLinks: _logGetLinks, attach: _logAttach, - version: 5, + version: '3.0.5', ); int _logEstimateSize( @@ -70,49 +68,48 @@ int _logEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; - bytesCount += 3 + object.logLevel.value.length * 3; + bytesCount += 3 + object.logLevel.name.length * 3; bytesCount += 3 + object.message.length * 3; return bytesCount; } -int _logSerializeNative( +void _logSerialize( Log object, - IsarBinaryWriter writer, + IsarWriter writer, List offsets, Map> allOffsets, ) { - writer.writeString(offsets[0], object.logLevel.value); + writer.writeString(offsets[0], object.logLevel.name); writer.writeString(offsets[1], object.message); writer.writeLong(offsets[2], object.timestampInMillisUTC); - return writer.usedBytes; } -Log _logDeserializeNative( - int id, - IsarBinaryReader reader, +Log _logDeserialize( + Id id, + IsarReader reader, List offsets, Map> allOffsets, ) { final object = Log(); object.id = id; object.logLevel = - _LogLogLevelMap[reader.readStringOrNull(offsets[0])] ?? LogLevel.Info; + _LoglogLevelValueEnumMap[reader.readStringOrNull(offsets[0])] ?? + LogLevel.Info; object.message = reader.readString(offsets[1]); object.timestampInMillisUTC = reader.readLong(offsets[2]); return object; } -P _logDeserializePropNative

( - Id id, - IsarBinaryReader reader, +P _logDeserializeProp

( + IsarReader reader, int propertyId, int offset, Map> allOffsets, ) { switch (propertyId) { case 0: - return (_LogLogLevelMap[reader.readStringOrNull(offset)] ?? LogLevel.Info) - as P; + return (_LoglogLevelValueEnumMap[reader.readStringOrNull(offset)] ?? + LogLevel.Info) as P; case 1: return (reader.readString(offset)) as P; case 2: @@ -122,36 +119,21 @@ P _logDeserializePropNative

( } } -Object _logSerializeWeb(IsarCollection collection, Log object) { - /*final jsObj = IsarNative.newJsObject();*/ throw UnimplementedError(); -} - -Log _logDeserializeWeb(IsarCollection collection, Object jsObj) { - /*final object = Log();object.id = IsarNative.jsObjectGet(jsObj, r'id') ?? (double.negativeInfinity as int);object.logLevel = IsarNative.jsObjectGet(jsObj, r'logLevel') ?? LogLevel.Info;object.message = IsarNative.jsObjectGet(jsObj, r'message') ?? '';object.timestampInMillisUTC = IsarNative.jsObjectGet(jsObj, r'timestampInMillisUTC') ?? (double.negativeInfinity as int);*/ - //return object; - throw UnimplementedError(); -} - -P _logDeserializePropWeb

(Object jsObj, String propertyName) { - switch (propertyName) { - default: - throw IsarError('Illegal propertyName'); - } -} - -final _LogLogLevelMap = { - LogLevel.Info.value: LogLevel.Info, - LogLevel.Warning.value: LogLevel.Warning, - LogLevel.Error.value: LogLevel.Error, - LogLevel.Fatal.value: LogLevel.Fatal, +const _LoglogLevelEnumValueMap = { + r'Info': r'Info', + r'Warning': r'Warning', + r'Error': r'Error', + r'Fatal': r'Fatal', +}; +const _LoglogLevelValueEnumMap = { + r'Info': LogLevel.Info, + r'Warning': LogLevel.Warning, + r'Error': LogLevel.Error, + r'Fatal': LogLevel.Fatal, }; -int? _logGetId(Log object) { - if (object.id == Isar.autoIncrement) { - return null; - } else { - return object.id; - } +Id _logGetId(Log object) { + return object.id; } List> _logGetLinks(Log object) { @@ -179,7 +161,7 @@ extension LogQueryWhereSort on QueryBuilder { } extension LogQueryWhere on QueryBuilder { - QueryBuilder idEqualTo(int id) { + QueryBuilder idEqualTo(Id id) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IdWhereClause.between( lower: id, @@ -188,7 +170,7 @@ extension LogQueryWhere on QueryBuilder { }); } - QueryBuilder idNotEqualTo(int id) { + QueryBuilder idNotEqualTo(Id id) { return QueryBuilder.apply(this, (query) { if (query.whereSort == Sort.asc) { return query @@ -210,7 +192,7 @@ extension LogQueryWhere on QueryBuilder { }); } - QueryBuilder idGreaterThan(int id, + QueryBuilder idGreaterThan(Id id, {bool include = false}) { return QueryBuilder.apply(this, (query) { return query.addWhereClause( @@ -219,7 +201,7 @@ extension LogQueryWhere on QueryBuilder { }); } - QueryBuilder idLessThan(int id, + QueryBuilder idLessThan(Id id, {bool include = false}) { return QueryBuilder.apply(this, (query) { return query.addWhereClause( @@ -229,8 +211,8 @@ extension LogQueryWhere on QueryBuilder { } QueryBuilder idBetween( - int lowerId, - int upperId, { + Id lowerId, + Id upperId, { bool includeLower = true, bool includeUpper = true, }) { @@ -336,7 +318,7 @@ extension LogQueryWhere on QueryBuilder { } extension LogQueryFilter on QueryBuilder { - QueryBuilder idEqualTo(int value) { + QueryBuilder idEqualTo(Id value) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'id', @@ -346,7 +328,7 @@ extension LogQueryFilter on QueryBuilder { } QueryBuilder idGreaterThan( - int value, { + Id value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { @@ -359,7 +341,7 @@ extension LogQueryFilter on QueryBuilder { } QueryBuilder idLessThan( - int value, { + Id value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { @@ -372,8 +354,8 @@ extension LogQueryFilter on QueryBuilder { } QueryBuilder idBetween( - int lower, - int upper, { + Id lower, + Id upper, { bool includeLower = true, bool includeUpper = true, }) { @@ -498,6 +480,24 @@ extension LogQueryFilter on QueryBuilder { }); } + QueryBuilder logLevelIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'logLevel', + value: '', + )); + }); + } + + QueryBuilder logLevelIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'logLevel', + value: '', + )); + }); + } + QueryBuilder messageEqualTo( String value, { bool caseSensitive = true, @@ -608,6 +608,24 @@ extension LogQueryFilter on QueryBuilder { }); } + QueryBuilder messageIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'message', + value: '', + )); + }); + } + + QueryBuilder messageIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'message', + value: '', + )); + }); + } + QueryBuilder timestampInMillisUTCEqualTo( int value) { return QueryBuilder.apply(this, (query) { diff --git a/lib/models/isar/models/transaction_note.dart b/lib/models/isar/models/transaction_note.dart index 3dbd53e81..21faba2ee 100644 --- a/lib/models/isar/models/transaction_note.dart +++ b/lib/models/isar/models/transaction_note.dart @@ -1,6 +1,8 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; +part 'transaction_note.g.dart'; + @Collection() class TransactionNote { Id id = Isar.autoIncrement; diff --git a/lib/models/isar/models/transaction_note.g.dart b/lib/models/isar/models/transaction_note.g.dart new file mode 100644 index 000000000..57ada578d --- /dev/null +++ b/lib/models/isar/models/transaction_note.g.dart @@ -0,0 +1,470 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'transaction_note.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetTransactionNoteCollection on Isar { + IsarCollection get transactionNotes => this.collection(); +} + +const TransactionNoteSchema = CollectionSchema( + name: r'TransactionNote', + id: 5128348263878806765, + properties: { + r'value': PropertySchema( + id: 0, + name: r'value', + type: IsarType.string, + ) + }, + estimateSize: _transactionNoteEstimateSize, + serialize: _transactionNoteSerialize, + deserialize: _transactionNoteDeserialize, + deserializeProp: _transactionNoteDeserializeProp, + idName: r'id', + indexes: {}, + links: { + r'transaction': LinkSchema( + id: -3227504867737807188, + name: r'transaction', + target: r'Transaction', + single: true, + linkName: r'note', + ) + }, + embeddedSchemas: {}, + getId: _transactionNoteGetId, + getLinks: _transactionNoteGetLinks, + attach: _transactionNoteAttach, + version: '3.0.5', +); + +int _transactionNoteEstimateSize( + TransactionNote object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.value.length * 3; + return bytesCount; +} + +void _transactionNoteSerialize( + TransactionNote object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.value); +} + +TransactionNote _transactionNoteDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = TransactionNote(); + object.id = id; + object.value = reader.readString(offsets[0]); + return object; +} + +P _transactionNoteDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +Id _transactionNoteGetId(TransactionNote object) { + return object.id; +} + +List> _transactionNoteGetLinks(TransactionNote object) { + return [object.transaction]; +} + +void _transactionNoteAttach( + IsarCollection col, Id id, TransactionNote object) { + object.id = id; + object.transaction + .attach(col, col.isar.collection(), r'transaction', id); +} + +extension TransactionNoteQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension TransactionNoteQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder + idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder + idGreaterThan(Id id, {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan( + Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } +} + +extension TransactionNoteQueryFilter + on QueryBuilder { + QueryBuilder + idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder + idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder + valueEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'value', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'value', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + valueIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: '', + )); + }); + } + + QueryBuilder + valueIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'value', + value: '', + )); + }); + } +} + +extension TransactionNoteQueryObject + on QueryBuilder {} + +extension TransactionNoteQueryLinks + on QueryBuilder { + QueryBuilder + transaction(FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'transaction'); + }); + } + + QueryBuilder + transactionIsNull() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', 0, true, 0, true); + }); + } +} + +extension TransactionNoteQuerySortBy + on QueryBuilder { + QueryBuilder sortByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder + sortByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } +} + +extension TransactionNoteQuerySortThenBy + on QueryBuilder { + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder + thenByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } +} + +extension TransactionNoteQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByValue( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'value', caseSensitive: caseSensitive); + }); + } +} + +extension TransactionNoteQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder valueProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'value'); + }); + } +} diff --git a/lib/utilities/enums/log_level_enum.dart b/lib/utilities/enums/log_level_enum.dart index d426adc3d..b9b5fd69f 100644 --- a/lib/utilities/enums/log_level_enum.dart +++ b/lib/utilities/enums/log_level_enum.dart @@ -1,13 +1,8 @@ -import 'package:isar/isar.dart'; - // Used in Isar db and stored there as int indexes so adding/removing values // in this definition should be done extremely carefully in production -enum LogLevel with IsarEnum { +enum LogLevel { Info, Warning, Error, Fatal; - - @override - String get value => name; } diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index b5a3e4e63..e83a5e292 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -281,6 +281,16 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i15.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( diff --git a/test/screen_tests/exchange/exchange_view_test.mocks.dart b/test/screen_tests/exchange/exchange_view_test.mocks.dart index 8c0d72f55..1133911a9 100644 --- a/test/screen_tests/exchange/exchange_view_test.mocks.dart +++ b/test/screen_tests/exchange/exchange_view_test.mocks.dart @@ -423,6 +423,11 @@ class MockTradesService extends _i1.Mock implements _i9.TradesService { returnValue: false, ) as bool); @override + _i10.Trade? get(String? tradeId) => (super.noSuchMethod(Invocation.method( + #get, + [tradeId], + )) as _i10.Trade?); + @override _i7.Future add({ required _i10.Trade? trade, required bool? shouldNotifyListeners, diff --git a/test/services/wallets_service_test.mocks.dart b/test/services/wallets_service_test.mocks.dart index 19d525196..bb3f74934 100644 --- a/test/services/wallets_service_test.mocks.dart +++ b/test/services/wallets_service_test.mocks.dart @@ -112,4 +112,29 @@ class MockSecureStorageWrapper extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override + _i3.Future deleteAll({ + _i4.IOSOptions? iOptions, + _i4.AndroidOptions? aOptions, + _i4.LinuxOptions? lOptions, + _i4.WebOptions? webOptions, + _i4.MacOsOptions? mOptions, + _i4.WindowsOptions? wOptions, + }) => + (super.noSuchMethod( + Invocation.method( + #deleteAll, + [], + { + #iOptions: iOptions, + #aOptions: aOptions, + #lOptions: lOptions, + #webOptions: webOptions, + #mOptions: mOptions, + #wOptions: wOptions, + }, + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); } diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 117a810cf..2bdd631ba 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -277,6 +277,16 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i15.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( diff --git a/test/widget_tests/node_options_sheet_test.mocks.dart b/test/widget_tests/node_options_sheet_test.mocks.dart index 7e3e3a92d..23810fd96 100644 --- a/test/widget_tests/node_options_sheet_test.mocks.dart +++ b/test/widget_tests/node_options_sheet_test.mocks.dart @@ -177,6 +177,16 @@ class MockWallets extends _i1.Mock implements _i8.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i9.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i9.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( diff --git a/test/widget_tests/table_view/table_view_row_test.mocks.dart b/test/widget_tests/table_view/table_view_row_test.mocks.dart index 5a47436ff..48bcb2e2c 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 @@ -262,6 +262,16 @@ class MockWallets extends _i1.Mock implements _i13.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i14.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i14.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 2aa2e1dcb..3519f9080 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -280,6 +280,16 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i15.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index e323911d4..722ad681b 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -251,6 +251,16 @@ class MockWallets extends _i1.Mock implements _i12.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i13.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i13.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart index fe5e0e8a2..e1dcf3c76 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 @@ -276,6 +276,16 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i15.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart index 7f370eb9a..95d600267 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 @@ -276,6 +276,16 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override + List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( + _i15.Coin? coin) => + (super.noSuchMethod( + Invocation.method( + #getManagerProvidersForCoin, + [coin], + ), + returnValue: <_i5.ChangeNotifierProvider<_i6.Manager>>[], + ) as List<_i5.ChangeNotifierProvider<_i6.Manager>>); + @override _i5.ChangeNotifierProvider<_i6.Manager> getManagerProvider( String? walletId) => (super.noSuchMethod( From 86956b3fad37c514a8f3bd778ee3343f36c784dd Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 10:05:22 -0600 Subject: [PATCH 073/192] update dogecoin test --- test/services/coins/dogecoin/dogecoin_wallet_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index e04eb5cdd..ac863bd2a 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -28,7 +28,7 @@ import 'dogecoin_wallet_test_parameters.dart'; void main() { group("dogecoin constants", () { test("dogecoin minimum confirmations", () async { - expect(MINIMUM_CONFIRMATIONS, 3); + expect(MINIMUM_CONFIRMATIONS, 1); }); test("dogecoin dust limit", () async { expect(DUST_LIMIT, 1000000); From 3de937fe03ff9bd8032f792a418de9e80d2836be Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 11:22:52 -0600 Subject: [PATCH 074/192] switch values that change over time to computed properties --- .../models/blockchain_data/transaction.dart | 17 +- .../models/blockchain_data/transaction.g.dart | 408 ++---------------- .../isar/models/blockchain_data/utxo.dart | 19 +- .../isar/models/blockchain_data/utxo.g.dart | 189 +++----- 4 files changed, 119 insertions(+), 514 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index e5c4abd6a..4dfc72a45 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; @@ -11,10 +13,6 @@ class Transaction { late String txid; - late bool confirmed; - - late int confirmations; - late int timestamp; @enumerated @@ -28,8 +26,6 @@ class Transaction { // TODO: do we need this? // late List aliens; - late String worthAtBlockTimestamp; - late int fee; late String address; @@ -47,6 +43,15 @@ class Transaction { final outputs = IsarLinks(); final note = IsarLink(); + + int getConfirmations(int currentChainHeight) { + return max(0, currentChainHeight - height); + } + + bool isConfirmed(int currentChainHeight, int minimumConfirms) { + final confirmations = getConfirmations(currentChainHeight); + return confirmations >= minimumConfirms; + } } // Used in Isar db and stored there as int indexes so adding/removing values diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 0e968227d..471dd33e3 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -32,62 +32,47 @@ const TransactionSchema = CollectionSchema( name: r'cancelled', type: IsarType.bool, ), - r'confirmations': PropertySchema( - id: 3, - name: r'confirmations', - type: IsarType.long, - ), - r'confirmed': PropertySchema( - id: 4, - name: r'confirmed', - type: IsarType.bool, - ), r'fee': PropertySchema( - id: 5, + id: 3, name: r'fee', type: IsarType.long, ), r'height': PropertySchema( - id: 6, + id: 4, name: r'height', type: IsarType.long, ), r'otherData': PropertySchema( - id: 7, + id: 5, name: r'otherData', type: IsarType.string, ), r'slateId': PropertySchema( - id: 8, + id: 6, name: r'slateId', type: IsarType.string, ), r'subType': PropertySchema( - id: 9, + id: 7, name: r'subType', type: IsarType.byte, enumMap: _TransactionsubTypeEnumValueMap, ), r'timestamp': PropertySchema( - id: 10, + id: 8, name: r'timestamp', type: IsarType.long, ), r'txType': PropertySchema( - id: 11, + id: 9, name: r'txType', type: IsarType.byte, enumMap: _TransactiontxTypeEnumValueMap, ), r'txid': PropertySchema( - id: 12, + id: 10, name: r'txid', type: IsarType.string, - ), - r'worthAtBlockTimestamp': PropertySchema( - id: 13, - name: r'worthAtBlockTimestamp', - type: IsarType.string, ) }, estimateSize: _transactionEstimateSize, @@ -143,7 +128,6 @@ int _transactionEstimateSize( } } bytesCount += 3 + object.txid.length * 3; - bytesCount += 3 + object.worthAtBlockTimestamp.length * 3; return bytesCount; } @@ -156,17 +140,14 @@ void _transactionSerialize( writer.writeString(offsets[0], object.address); writer.writeLong(offsets[1], object.amount); writer.writeBool(offsets[2], object.cancelled); - writer.writeLong(offsets[3], object.confirmations); - writer.writeBool(offsets[4], object.confirmed); - writer.writeLong(offsets[5], object.fee); - writer.writeLong(offsets[6], object.height); - writer.writeString(offsets[7], object.otherData); - writer.writeString(offsets[8], object.slateId); - writer.writeByte(offsets[9], object.subType.index); - writer.writeLong(offsets[10], object.timestamp); - writer.writeByte(offsets[11], object.txType.index); - writer.writeString(offsets[12], object.txid); - writer.writeString(offsets[13], object.worthAtBlockTimestamp); + writer.writeLong(offsets[3], object.fee); + writer.writeLong(offsets[4], object.height); + writer.writeString(offsets[5], object.otherData); + writer.writeString(offsets[6], object.slateId); + writer.writeByte(offsets[7], object.subType.index); + writer.writeLong(offsets[8], object.timestamp); + writer.writeByte(offsets[9], object.txType.index); + writer.writeString(offsets[10], object.txid); } Transaction _transactionDeserialize( @@ -179,22 +160,19 @@ Transaction _transactionDeserialize( object.address = reader.readString(offsets[0]); object.amount = reader.readLong(offsets[1]); object.cancelled = reader.readBool(offsets[2]); - object.confirmations = reader.readLong(offsets[3]); - object.confirmed = reader.readBool(offsets[4]); - object.fee = reader.readLong(offsets[5]); - object.height = reader.readLong(offsets[6]); + object.fee = reader.readLong(offsets[3]); + object.height = reader.readLong(offsets[4]); object.id = id; - object.otherData = reader.readStringOrNull(offsets[7]); - object.slateId = reader.readStringOrNull(offsets[8]); + object.otherData = reader.readStringOrNull(offsets[5]); + object.slateId = reader.readStringOrNull(offsets[6]); object.subType = - _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[9])] ?? + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ?? TransactionSubType.none; - object.timestamp = reader.readLong(offsets[10]); + object.timestamp = reader.readLong(offsets[8]); object.txType = - _TransactiontxTypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? + _TransactiontxTypeValueEnumMap[reader.readByteOrNull(offsets[9])] ?? TransactionType.outgoing; - object.txid = reader.readString(offsets[12]); - object.worthAtBlockTimestamp = reader.readString(offsets[13]); + object.txid = reader.readString(offsets[10]); return object; } @@ -214,26 +192,20 @@ P _transactionDeserializeProp

( case 3: return (reader.readLong(offset)) as P; case 4: - return (reader.readBool(offset)) as P; + return (reader.readLong(offset)) as P; case 5: - return (reader.readLong(offset)) as P; + return (reader.readStringOrNull(offset)) as P; case 6: - return (reader.readLong(offset)) as P; + return (reader.readStringOrNull(offset)) as P; case 7: - return (reader.readStringOrNull(offset)) as P; - case 8: - return (reader.readStringOrNull(offset)) as P; - case 9: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 10: + case 8: return (reader.readLong(offset)) as P; - case 11: + case 9: return (_TransactiontxTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; - case 12: - return (reader.readString(offset)) as P; - case 13: + case 10: return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); @@ -557,72 +529,6 @@ extension TransactionQueryFilter }); } - QueryBuilder - confirmationsEqualTo(int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'confirmations', - value: value, - )); - }); - } - - QueryBuilder - confirmationsGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'confirmations', - value: value, - )); - }); - } - - QueryBuilder - confirmationsLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'confirmations', - value: value, - )); - }); - } - - QueryBuilder - confirmationsBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'confirmations', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder - confirmedEqualTo(bool value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'confirmed', - value: value, - )); - }); - } - QueryBuilder feeEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -1383,143 +1289,6 @@ extension TransactionQueryFilter )); }); } - - QueryBuilder - worthAtBlockTimestampEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'worthAtBlockTimestamp', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'worthAtBlockTimestamp', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'worthAtBlockTimestamp', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'worthAtBlockTimestamp', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'worthAtBlockTimestamp', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'worthAtBlockTimestamp', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampContains(String value, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'worthAtBlockTimestamp', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampMatches(String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'worthAtBlockTimestamp', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - worthAtBlockTimestampIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'worthAtBlockTimestamp', - value: '', - )); - }); - } - - QueryBuilder - worthAtBlockTimestampIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'worthAtBlockTimestamp', - value: '', - )); - }); - } } extension TransactionQueryObject @@ -1701,31 +1470,6 @@ extension TransactionQuerySortBy }); } - QueryBuilder sortByConfirmations() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmations', Sort.asc); - }); - } - - QueryBuilder - sortByConfirmationsDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmations', Sort.desc); - }); - } - - QueryBuilder sortByConfirmed() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmed', Sort.asc); - }); - } - - QueryBuilder sortByConfirmedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmed', Sort.desc); - }); - } - QueryBuilder sortByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -1821,20 +1565,6 @@ extension TransactionQuerySortBy return query.addSortBy(r'txid', Sort.desc); }); } - - QueryBuilder - sortByWorthAtBlockTimestamp() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'worthAtBlockTimestamp', Sort.asc); - }); - } - - QueryBuilder - sortByWorthAtBlockTimestampDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'worthAtBlockTimestamp', Sort.desc); - }); - } } extension TransactionQuerySortThenBy @@ -1875,31 +1605,6 @@ extension TransactionQuerySortThenBy }); } - QueryBuilder thenByConfirmations() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmations', Sort.asc); - }); - } - - QueryBuilder - thenByConfirmationsDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmations', Sort.desc); - }); - } - - QueryBuilder thenByConfirmed() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmed', Sort.asc); - }); - } - - QueryBuilder thenByConfirmedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'confirmed', Sort.desc); - }); - } - QueryBuilder thenByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2007,20 +1712,6 @@ extension TransactionQuerySortThenBy return query.addSortBy(r'txid', Sort.desc); }); } - - QueryBuilder - thenByWorthAtBlockTimestamp() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'worthAtBlockTimestamp', Sort.asc); - }); - } - - QueryBuilder - thenByWorthAtBlockTimestampDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'worthAtBlockTimestamp', Sort.desc); - }); - } } extension TransactionQueryWhereDistinct @@ -2044,18 +1735,6 @@ extension TransactionQueryWhereDistinct }); } - QueryBuilder distinctByConfirmations() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'confirmations'); - }); - } - - QueryBuilder distinctByConfirmed() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'confirmed'); - }); - } - QueryBuilder distinctByFee() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'fee'); @@ -2106,14 +1785,6 @@ extension TransactionQueryWhereDistinct return query.addDistinctBy(r'txid', caseSensitive: caseSensitive); }); } - - QueryBuilder - distinctByWorthAtBlockTimestamp({bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'worthAtBlockTimestamp', - caseSensitive: caseSensitive); - }); - } } extension TransactionQueryProperty @@ -2142,18 +1813,6 @@ extension TransactionQueryProperty }); } - QueryBuilder confirmationsProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'confirmations'); - }); - } - - QueryBuilder confirmedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'confirmed'); - }); - } - QueryBuilder feeProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'fee'); @@ -2203,11 +1862,4 @@ extension TransactionQueryProperty return query.addPropertyName(r'txid'); }); } - - QueryBuilder - worthAtBlockTimestampProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'worthAtBlockTimestamp'); - }); - } } diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index 5882d0b61..47701f4db 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:isar/isar.dart'; part 'utxo.g.dart'; @@ -14,24 +16,29 @@ class UTXO { late int value; - late String fiatWorth; - late String txName; late bool blocked; + late String? blockedReason; + late bool isCoinbase; } @Embedded() class Status { - late bool confirmed; - - late int confirmations; - late String blockHash; late int blockHeight; late int blockTime; + + int getConfirmations(int currentChainHeight) { + return max(0, currentChainHeight - blockHeight); + } + + bool isConfirmed(int currentChainHeight, int minimumConfirms) { + final confirmations = getConfirmations(currentChainHeight); + return confirmations >= minimumConfirms; + } } diff --git a/lib/models/isar/models/blockchain_data/utxo.g.dart b/lib/models/isar/models/blockchain_data/utxo.g.dart index 7511b11df..b86822039 100644 --- a/lib/models/isar/models/blockchain_data/utxo.g.dart +++ b/lib/models/isar/models/blockchain_data/utxo.g.dart @@ -22,9 +22,9 @@ const UTXOSchema = CollectionSchema( name: r'blocked', type: IsarType.bool, ), - r'fiatWorth': PropertySchema( + r'blockedReason': PropertySchema( id: 1, - name: r'fiatWorth', + name: r'blockedReason', type: IsarType.string, ), r'isCoinbase': PropertySchema( @@ -79,7 +79,12 @@ int _uTXOEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; - bytesCount += 3 + object.fiatWorth.length * 3; + { + final value = object.blockedReason; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } bytesCount += 3 + StatusSchema.estimateSize(object.status, allOffsets[Status]!, allOffsets); bytesCount += 3 + object.txName.length * 3; @@ -94,7 +99,7 @@ void _uTXOSerialize( Map> allOffsets, ) { writer.writeBool(offsets[0], object.blocked); - writer.writeString(offsets[1], object.fiatWorth); + writer.writeString(offsets[1], object.blockedReason); writer.writeBool(offsets[2], object.isCoinbase); writer.writeObject( offsets[3], @@ -116,7 +121,7 @@ UTXO _uTXODeserialize( ) { final object = UTXO(); object.blocked = reader.readBool(offsets[0]); - object.fiatWorth = reader.readString(offsets[1]); + object.blockedReason = reader.readStringOrNull(offsets[1]); object.id = id; object.isCoinbase = reader.readBool(offsets[2]); object.status = reader.readObjectOrNull( @@ -142,7 +147,7 @@ P _uTXODeserializeProp

( case 0: return (reader.readBool(offset)) as P; case 1: - return (reader.readString(offset)) as P; + return (reader.readStringOrNull(offset)) as P; case 2: return (reader.readBool(offset)) as P; case 3: @@ -262,59 +267,75 @@ extension UTXOQueryFilter on QueryBuilder { }); } - QueryBuilder fiatWorthEqualTo( - String value, { + QueryBuilder blockedReasonIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'blockedReason', + )); + }); + } + + QueryBuilder blockedReasonIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'blockedReason', + )); + }); + } + + QueryBuilder blockedReasonEqualTo( + String? value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'fiatWorth', + property: r'blockedReason', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder fiatWorthGreaterThan( - String value, { + QueryBuilder blockedReasonGreaterThan( + String? value, { bool include = false, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, - property: r'fiatWorth', + property: r'blockedReason', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder fiatWorthLessThan( - String value, { + QueryBuilder blockedReasonLessThan( + String? value, { bool include = false, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, - property: r'fiatWorth', + property: r'blockedReason', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder fiatWorthBetween( - String lower, - String upper, { + QueryBuilder blockedReasonBetween( + String? lower, + String? upper, { bool includeLower = true, bool includeUpper = true, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( - property: r'fiatWorth', + property: r'blockedReason', lower: lower, includeLower: includeLower, upper: upper, @@ -324,69 +345,69 @@ extension UTXOQueryFilter on QueryBuilder { }); } - QueryBuilder fiatWorthStartsWith( + QueryBuilder blockedReasonStartsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.startsWith( - property: r'fiatWorth', + property: r'blockedReason', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder fiatWorthEndsWith( + QueryBuilder blockedReasonEndsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.endsWith( - property: r'fiatWorth', + property: r'blockedReason', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder fiatWorthContains( + QueryBuilder blockedReasonContains( String value, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.contains( - property: r'fiatWorth', + property: r'blockedReason', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder fiatWorthMatches( + QueryBuilder blockedReasonMatches( String pattern, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.matches( - property: r'fiatWorth', + property: r'blockedReason', wildcard: pattern, caseSensitive: caseSensitive, )); }); } - QueryBuilder fiatWorthIsEmpty() { + QueryBuilder blockedReasonIsEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'fiatWorth', + property: r'blockedReason', value: '', )); }); } - QueryBuilder fiatWorthIsNotEmpty() { + QueryBuilder blockedReasonIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( - property: r'fiatWorth', + property: r'blockedReason', value: '', )); }); @@ -839,15 +860,15 @@ extension UTXOQuerySortBy on QueryBuilder { }); } - QueryBuilder sortByFiatWorth() { + QueryBuilder sortByBlockedReason() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'fiatWorth', Sort.asc); + return query.addSortBy(r'blockedReason', Sort.asc); }); } - QueryBuilder sortByFiatWorthDesc() { + QueryBuilder sortByBlockedReasonDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'fiatWorth', Sort.desc); + return query.addSortBy(r'blockedReason', Sort.desc); }); } @@ -925,15 +946,15 @@ extension UTXOQuerySortThenBy on QueryBuilder { }); } - QueryBuilder thenByFiatWorth() { + QueryBuilder thenByBlockedReason() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'fiatWorth', Sort.asc); + return query.addSortBy(r'blockedReason', Sort.asc); }); } - QueryBuilder thenByFiatWorthDesc() { + QueryBuilder thenByBlockedReasonDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'fiatWorth', Sort.desc); + return query.addSortBy(r'blockedReason', Sort.desc); }); } @@ -1017,10 +1038,11 @@ extension UTXOQueryWhereDistinct on QueryBuilder { }); } - QueryBuilder distinctByFiatWorth( + QueryBuilder distinctByBlockedReason( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'fiatWorth', caseSensitive: caseSensitive); + return query.addDistinctBy(r'blockedReason', + caseSensitive: caseSensitive); }); } @@ -1070,9 +1092,9 @@ extension UTXOQueryProperty on QueryBuilder { }); } - QueryBuilder fiatWorthProperty() { + QueryBuilder blockedReasonProperty() { return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'fiatWorth'); + return query.addPropertyName(r'blockedReason'); }); } @@ -1138,16 +1160,6 @@ const StatusSchema = Schema( id: 2, name: r'blockTime', type: IsarType.long, - ), - r'confirmations': PropertySchema( - id: 3, - name: r'confirmations', - type: IsarType.long, - ), - r'confirmed': PropertySchema( - id: 4, - name: r'confirmed', - type: IsarType.bool, ) }, estimateSize: _statusEstimateSize, @@ -1175,8 +1187,6 @@ void _statusSerialize( writer.writeString(offsets[0], object.blockHash); writer.writeLong(offsets[1], object.blockHeight); writer.writeLong(offsets[2], object.blockTime); - writer.writeLong(offsets[3], object.confirmations); - writer.writeBool(offsets[4], object.confirmed); } Status _statusDeserialize( @@ -1189,8 +1199,6 @@ Status _statusDeserialize( object.blockHash = reader.readString(offsets[0]); object.blockHeight = reader.readLong(offsets[1]); object.blockTime = reader.readLong(offsets[2]); - object.confirmations = reader.readLong(offsets[3]); - object.confirmed = reader.readBool(offsets[4]); return object; } @@ -1207,10 +1215,6 @@ P _statusDeserializeProp

( return (reader.readLong(offset)) as P; case 2: return (reader.readLong(offset)) as P; - case 3: - return (reader.readLong(offset)) as P; - case 4: - return (reader.readBool(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -1452,69 +1456,6 @@ extension StatusQueryFilter on QueryBuilder { )); }); } - - QueryBuilder confirmationsEqualTo( - int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'confirmations', - value: value, - )); - }); - } - - QueryBuilder confirmationsGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'confirmations', - value: value, - )); - }); - } - - QueryBuilder confirmationsLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'confirmations', - value: value, - )); - }); - } - - QueryBuilder confirmationsBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'confirmations', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder confirmedEqualTo( - bool value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'confirmed', - value: value, - )); - }); - } } extension StatusQueryObject on QueryBuilder {} From fedb91f11c974390d25fb62fb77b85307e36bd18 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 11:27:40 -0600 Subject: [PATCH 075/192] WIP isar address class --- lib/models/isar/models/address/address.dart | 56 ++ lib/models/isar/models/address/address.g.dart | 916 ++++++++++++++++++ .../address/crypto_currency_address.dart | 6 + 3 files changed, 978 insertions(+) create mode 100644 lib/models/isar/models/address/address.dart create mode 100644 lib/models/isar/models/address/address.g.dart create mode 100644 lib/models/isar/models/address/crypto_currency_address.dart diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart new file mode 100644 index 000000000..15f09df6f --- /dev/null +++ b/lib/models/isar/models/address/address.dart @@ -0,0 +1,56 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/address/crypto_currency_address.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; + +part 'address.g.dart'; + +class AddressException extends SWException { + AddressException(super.message); +} + +@Collection(inheritance: true) +class Address extends CryptoCurrencyAddress { + Id id = Isar.autoIncrement; + + late List publicKey; + + late int derivationIndex; + + @enumerated + late AddressType type; + + @enumerated + late AddressSubType subType; + + int derivationChain() { + if (subType == AddressSubType.receiving) { + return 0; // 0 for receiving (external) + } else if (subType == AddressSubType.change) { + return 1; // 1 for change (internal) + } else { + throw AddressException("Could not imply derivation chain value"); + } + } + + bool isPaynymAddress() => + subType == AddressSubType.paynymNotification || + subType == AddressSubType.paynymSend || + subType == AddressSubType.paynymReceive; + + @override + String toString() => value; +} + +enum AddressType { + p2pkh, + p2sh, + p2wpkh, +} + +enum AddressSubType { + receiving, + change, + paynymNotification, + paynymSend, + paynymReceive, +} diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart new file mode 100644 index 000000000..6ccd5d95d --- /dev/null +++ b/lib/models/isar/models/address/address.g.dart @@ -0,0 +1,916 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'address.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetAddressCollection on Isar { + IsarCollection

get address => this.collection(); +} + +const AddressSchema = CollectionSchema( + name: r'Address', + id: 3544600503126319553, + properties: { + r'derivationIndex': PropertySchema( + id: 0, + name: r'derivationIndex', + type: IsarType.long, + ), + r'publicKey': PropertySchema( + id: 1, + name: r'publicKey', + type: IsarType.byteList, + ), + r'subType': PropertySchema( + id: 2, + name: r'subType', + type: IsarType.byte, + enumMap: _AddresssubTypeEnumValueMap, + ), + r'type': PropertySchema( + id: 3, + name: r'type', + type: IsarType.byte, + enumMap: _AddresstypeEnumValueMap, + ), + r'value': PropertySchema( + id: 4, + name: r'value', + type: IsarType.string, + ) + }, + estimateSize: _addressEstimateSize, + serialize: _addressSerialize, + deserialize: _addressDeserialize, + deserializeProp: _addressDeserializeProp, + idName: r'id', + indexes: {}, + links: {}, + embeddedSchemas: {}, + getId: _addressGetId, + getLinks: _addressGetLinks, + attach: _addressAttach, + version: '3.0.5', +); + +int _addressEstimateSize( + Address object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + bytesCount += 3 + object.publicKey.length; + bytesCount += 3 + object.value.length * 3; + return bytesCount; +} + +void _addressSerialize( + Address object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeLong(offsets[0], object.derivationIndex); + writer.writeByteList(offsets[1], object.publicKey); + writer.writeByte(offsets[2], object.subType.index); + writer.writeByte(offsets[3], object.type.index); + writer.writeString(offsets[4], object.value); +} + +Address _addressDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = Address(); + object.derivationIndex = reader.readLong(offsets[0]); + object.id = id; + object.publicKey = reader.readByteList(offsets[1]) ?? []; + object.subType = + _AddresssubTypeValueEnumMap[reader.readByteOrNull(offsets[2])] ?? + AddressSubType.receiving; + object.type = _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[3])] ?? + AddressType.p2pkh; + object.value = reader.readString(offsets[4]); + return object; +} + +P _addressDeserializeProp

( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readLong(offset)) as P; + case 1: + return (reader.readByteList(offset) ?? []) as P; + case 2: + return (_AddresssubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? + AddressSubType.receiving) as P; + case 3: + return (_AddresstypeValueEnumMap[reader.readByteOrNull(offset)] ?? + AddressType.p2pkh) as P; + case 4: + return (reader.readString(offset)) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _AddresssubTypeEnumValueMap = { + 'receiving': 0, + 'change': 1, + 'paynymNotification': 2, + 'paynymSend': 3, + 'paynymReceive': 4, +}; +const _AddresssubTypeValueEnumMap = { + 0: AddressSubType.receiving, + 1: AddressSubType.change, + 2: AddressSubType.paynymNotification, + 3: AddressSubType.paynymSend, + 4: AddressSubType.paynymReceive, +}; +const _AddresstypeEnumValueMap = { + 'p2pkh': 0, + 'p2sh': 1, + 'p2wpkh': 2, +}; +const _AddresstypeValueEnumMap = { + 0: AddressType.p2pkh, + 1: AddressType.p2sh, + 2: AddressType.p2wpkh, +}; + +Id _addressGetId(Address object) { + return object.id; +} + +List> _addressGetLinks(Address object) { + return []; +} + +void _addressAttach(IsarCollection col, Id id, Address object) { + object.id = id; +} + +extension AddressQueryWhereSort on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension AddressQueryWhere on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } +} + +extension AddressQueryFilter + on QueryBuilder { + QueryBuilder derivationIndexEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'derivationIndex', + value: value, + )); + }); + } + + QueryBuilder + derivationIndexGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'derivationIndex', + value: value, + )); + }); + } + + QueryBuilder derivationIndexLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'derivationIndex', + value: value, + )); + }); + } + + QueryBuilder derivationIndexBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'derivationIndex', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo(Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder publicKeyElementEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'publicKey', + value: value, + )); + }); + } + + QueryBuilder + publicKeyElementGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'publicKey', + value: value, + )); + }); + } + + QueryBuilder + publicKeyElementLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'publicKey', + value: value, + )); + }); + } + + QueryBuilder publicKeyElementBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'publicKey', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder publicKeyLengthEqualTo( + int length) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'publicKey', + length, + true, + length, + true, + ); + }); + } + + QueryBuilder publicKeyIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'publicKey', + 0, + true, + 0, + true, + ); + }); + } + + QueryBuilder publicKeyIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'publicKey', + 0, + false, + 999999, + true, + ); + }); + } + + QueryBuilder publicKeyLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'publicKey', + 0, + true, + length, + include, + ); + }); + } + + QueryBuilder + publicKeyLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'publicKey', + length, + include, + 999999, + true, + ); + }); + } + + QueryBuilder publicKeyLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.listLength( + r'publicKey', + lower, + includeLower, + upper, + includeUpper, + ); + }); + } + + QueryBuilder subTypeEqualTo( + AddressSubType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'subType', + value: value, + )); + }); + } + + QueryBuilder subTypeGreaterThan( + AddressSubType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'subType', + value: value, + )); + }); + } + + QueryBuilder subTypeLessThan( + AddressSubType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'subType', + value: value, + )); + }); + } + + QueryBuilder subTypeBetween( + AddressSubType lower, + AddressSubType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'subType', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder typeEqualTo( + AddressType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeGreaterThan( + AddressType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeLessThan( + AddressType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeBetween( + AddressType lower, + AddressType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder valueEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'value', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'value', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'value', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder valueIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'value', + value: '', + )); + }); + } + + QueryBuilder valueIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'value', + value: '', + )); + }); + } +} + +extension AddressQueryObject + on QueryBuilder {} + +extension AddressQueryLinks + on QueryBuilder {} + +extension AddressQuerySortBy on QueryBuilder { + QueryBuilder sortByDerivationIndex() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'derivationIndex', Sort.asc); + }); + } + + QueryBuilder sortByDerivationIndexDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'derivationIndex', Sort.desc); + }); + } + + QueryBuilder sortBySubType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.asc); + }); + } + + QueryBuilder sortBySubTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.desc); + }); + } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } + + QueryBuilder sortByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder sortByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } +} + +extension AddressQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByDerivationIndex() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'derivationIndex', Sort.asc); + }); + } + + QueryBuilder thenByDerivationIndexDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'derivationIndex', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenBySubType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.asc); + }); + } + + QueryBuilder thenBySubTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'subType', Sort.desc); + }); + } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } + + QueryBuilder thenByValue() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.asc); + }); + } + + QueryBuilder thenByValueDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'value', Sort.desc); + }); + } +} + +extension AddressQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByDerivationIndex() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'derivationIndex'); + }); + } + + QueryBuilder distinctByPublicKey() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'publicKey'); + }); + } + + QueryBuilder distinctBySubType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'subType'); + }); + } + + QueryBuilder distinctByType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type'); + }); + } + + QueryBuilder distinctByValue( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'value', caseSensitive: caseSensitive); + }); + } +} + +extension AddressQueryProperty + on QueryBuilder { + QueryBuilder idProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'id'); + }); + } + + QueryBuilder derivationIndexProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'derivationIndex'); + }); + } + + QueryBuilder, QQueryOperations> publicKeyProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'publicKey'); + }); + } + + QueryBuilder subTypeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'subType'); + }); + } + + QueryBuilder typeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'type'); + }); + } + + QueryBuilder valueProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'value'); + }); + } +} diff --git a/lib/models/isar/models/address/crypto_currency_address.dart b/lib/models/isar/models/address/crypto_currency_address.dart new file mode 100644 index 000000000..30b725024 --- /dev/null +++ b/lib/models/isar/models/address/crypto_currency_address.dart @@ -0,0 +1,6 @@ +abstract class CryptoCurrencyAddress { + late String value; + + @override + String toString() => value; +} From 279d7f37bd33bcb618b2d0457fbfb06f260b4c39 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 11:51:38 -0600 Subject: [PATCH 076/192] clean up --- .../models/blockchain_data/transaction.dart | 3 +- .../models/blockchain_data/transaction.g.dart | 220 +++++++++--------- lib/models/isar/models/log.dart | 1 - 3 files changed, 112 insertions(+), 112 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 4dfc72a45..93fe56316 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -16,7 +16,7 @@ class Transaction { late int timestamp; @enumerated - late TransactionType txType; + late TransactionType type; @enumerated late TransactionSubType subType; @@ -61,6 +61,7 @@ enum TransactionType { outgoing, incoming, sendToSelf, // should we keep this? + unknown, anonymize; // firo specific } diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 471dd33e3..5d7107f9f 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -63,16 +63,16 @@ const TransactionSchema = CollectionSchema( name: r'timestamp', type: IsarType.long, ), - r'txType': PropertySchema( - id: 9, - name: r'txType', - type: IsarType.byte, - enumMap: _TransactiontxTypeEnumValueMap, - ), r'txid': PropertySchema( - id: 10, + id: 9, name: r'txid', type: IsarType.string, + ), + r'type': PropertySchema( + id: 10, + name: r'type', + type: IsarType.byte, + enumMap: _TransactiontypeEnumValueMap, ) }, estimateSize: _transactionEstimateSize, @@ -146,8 +146,8 @@ void _transactionSerialize( writer.writeString(offsets[6], object.slateId); writer.writeByte(offsets[7], object.subType.index); writer.writeLong(offsets[8], object.timestamp); - writer.writeByte(offsets[9], object.txType.index); - writer.writeString(offsets[10], object.txid); + writer.writeString(offsets[9], object.txid); + writer.writeByte(offsets[10], object.type.index); } Transaction _transactionDeserialize( @@ -169,10 +169,10 @@ Transaction _transactionDeserialize( _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ?? TransactionSubType.none; object.timestamp = reader.readLong(offsets[8]); - object.txType = - _TransactiontxTypeValueEnumMap[reader.readByteOrNull(offsets[9])] ?? + object.txid = reader.readString(offsets[9]); + object.type = + _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ?? TransactionType.outgoing; - object.txid = reader.readString(offsets[10]); return object; } @@ -203,10 +203,10 @@ P _transactionDeserializeProp

( case 8: return (reader.readLong(offset)) as P; case 9: - return (_TransactiontxTypeValueEnumMap[reader.readByteOrNull(offset)] ?? - TransactionType.outgoing) as P; - case 10: return (reader.readString(offset)) as P; + case 10: + return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? + TransactionType.outgoing) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -222,17 +222,19 @@ const _TransactionsubTypeValueEnumMap = { 1: TransactionSubType.bip47Notification, 2: TransactionSubType.mint, }; -const _TransactiontxTypeEnumValueMap = { +const _TransactiontypeEnumValueMap = { 'outgoing': 0, 'incoming': 1, 'sendToSelf': 2, - 'anonymize': 3, + 'unknown': 3, + 'anonymize': 4, }; -const _TransactiontxTypeValueEnumMap = { +const _TransactiontypeValueEnumMap = { 0: TransactionType.outgoing, 1: TransactionType.incoming, 2: TransactionType.sendToSelf, - 3: TransactionType.anonymize, + 3: TransactionType.unknown, + 4: TransactionType.anonymize, }; Id _transactionGetId(Transaction object) { @@ -1105,60 +1107,6 @@ extension TransactionQueryFilter }); } - QueryBuilder txTypeEqualTo( - TransactionType value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'txType', - value: value, - )); - }); - } - - QueryBuilder - txTypeGreaterThan( - TransactionType value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'txType', - value: value, - )); - }); - } - - QueryBuilder txTypeLessThan( - TransactionType value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'txType', - value: value, - )); - }); - } - - QueryBuilder txTypeBetween( - TransactionType lower, - TransactionType upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'txType', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - QueryBuilder txidEqualTo( String value, { bool caseSensitive = true, @@ -1289,6 +1237,59 @@ extension TransactionQueryFilter )); }); } + + QueryBuilder typeEqualTo( + TransactionType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeGreaterThan( + TransactionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeLessThan( + TransactionType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeBetween( + TransactionType lower, + TransactionType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } } extension TransactionQueryObject @@ -1542,18 +1543,6 @@ extension TransactionQuerySortBy }); } - QueryBuilder sortByTxType() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txType', Sort.asc); - }); - } - - QueryBuilder sortByTxTypeDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txType', Sort.desc); - }); - } - QueryBuilder sortByTxid() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'txid', Sort.asc); @@ -1565,6 +1554,18 @@ extension TransactionQuerySortBy return query.addSortBy(r'txid', Sort.desc); }); } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } } extension TransactionQuerySortThenBy @@ -1689,18 +1690,6 @@ extension TransactionQuerySortThenBy }); } - QueryBuilder thenByTxType() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txType', Sort.asc); - }); - } - - QueryBuilder thenByTxTypeDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txType', Sort.desc); - }); - } - QueryBuilder thenByTxid() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'txid', Sort.asc); @@ -1712,6 +1701,18 @@ extension TransactionQuerySortThenBy return query.addSortBy(r'txid', Sort.desc); }); } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } } extension TransactionQueryWhereDistinct @@ -1773,18 +1774,18 @@ extension TransactionQueryWhereDistinct }); } - QueryBuilder distinctByTxType() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'txType'); - }); - } - QueryBuilder distinctByTxid( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'txid', caseSensitive: caseSensitive); }); } + + QueryBuilder distinctByType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type'); + }); + } } extension TransactionQueryProperty @@ -1850,16 +1851,15 @@ extension TransactionQueryProperty }); } - QueryBuilder - txTypeProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'txType'); - }); - } - QueryBuilder txidProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'txid'); }); } + + QueryBuilder typeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'type'); + }); + } } diff --git a/lib/models/isar/models/log.dart b/lib/models/isar/models/log.dart index ff8576224..f89fba253 100644 --- a/lib/models/isar/models/log.dart +++ b/lib/models/isar/models/log.dart @@ -13,7 +13,6 @@ class Log { @Index() late int timestampInMillisUTC; - // ignore: undefined_name @Enumerated(EnumType.name) late LogLevel logLevel; From 064421cfbaa28b25304f0a7d329e54e2337c7641 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 14:40:09 -0600 Subject: [PATCH 077/192] models modification and simple export --- lib/models/isar/models/blockchain_data/transaction.dart | 1 + lib/models/isar/models/isar_models.dart | 7 +++++++ lib/models/isar/models/transaction_note.dart | 1 - lib/models/isar/models/transaction_note.g.dart | 3 +-- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 lib/models/isar/models/isar_models.dart diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 93fe56316..32f9f224f 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -42,6 +42,7 @@ class Transaction { final outputs = IsarLinks(); + @Backlink(to: "transaction") final note = IsarLink(); int getConfirmations(int currentChainHeight) { diff --git a/lib/models/isar/models/isar_models.dart b/lib/models/isar/models/isar_models.dart new file mode 100644 index 000000000..1d947db32 --- /dev/null +++ b/lib/models/isar/models/isar_models.dart @@ -0,0 +1,7 @@ +export 'address/address.dart'; +export 'blockchain_data/input.dart'; +export 'blockchain_data/output.dart'; +export 'blockchain_data/transaction.dart'; +export 'blockchain_data/utxo.dart'; +export 'log.dart'; +export 'transaction_note.dart'; diff --git a/lib/models/isar/models/transaction_note.dart b/lib/models/isar/models/transaction_note.dart index 21faba2ee..95686bbbe 100644 --- a/lib/models/isar/models/transaction_note.dart +++ b/lib/models/isar/models/transaction_note.dart @@ -9,6 +9,5 @@ class TransactionNote { late String value; - @Backlink(to: 'note') final transaction = IsarLink(); } diff --git a/lib/models/isar/models/transaction_note.g.dart b/lib/models/isar/models/transaction_note.g.dart index 57ada578d..be64f4919 100644 --- a/lib/models/isar/models/transaction_note.g.dart +++ b/lib/models/isar/models/transaction_note.g.dart @@ -31,11 +31,10 @@ const TransactionNoteSchema = CollectionSchema( indexes: {}, links: { r'transaction': LinkSchema( - id: -3227504867737807188, + id: -2827073548125040615, name: r'transaction', target: r'Transaction', single: true, - linkName: r'note', ) }, embeddedSchemas: {}, From 3e2edde640f4132ebfcfd3ea8983792aea942b6c Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:45:58 -0600 Subject: [PATCH 078/192] simple current chain height provider --- .../blockchain/dogecoin/current_height_provider.dart | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lib/providers/blockchain/dogecoin/current_height_provider.dart diff --git a/lib/providers/blockchain/dogecoin/current_height_provider.dart b/lib/providers/blockchain/dogecoin/current_height_provider.dart new file mode 100644 index 000000000..22b6711db --- /dev/null +++ b/lib/providers/blockchain/dogecoin/current_height_provider.dart @@ -0,0 +1,6 @@ +import 'package:dart_numerics/dart_numerics.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +final currentHeightProvider = + StateProvider.family((ref, coin) => int64MaxValue); From 15258314cd5df780750eb9e75ba5c99094a13d3b Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:48:55 -0600 Subject: [PATCH 079/192] update test mocks --- test/pages/send_view/send_view_test.mocks.dart | 10 ++++++++++ .../add_address_book_view_screen_test.mocks.dart | 5 +++++ ...book_entry_details_view_screen_test.mocks.dart | 5 +++++ ...address_book_entry_view_screen_test.mocks.dart | 5 +++++ .../lockscreen_view_screen_test.mocks.dart | 5 +++++ .../main_view_screen_testA_test.mocks.dart | 5 +++++ .../main_view_screen_testB_test.mocks.dart | 5 +++++ .../main_view_screen_testC_test.mocks.dart | 5 +++++ .../backup_key_view_screen_test.mocks.dart | 5 +++++ ...backup_key_warning_view_screen_test.mocks.dart | 5 +++++ .../create_pin_view_screen_test.mocks.dart | 5 +++++ .../restore_wallet_view_screen_test.mocks.dart | 5 +++++ .../verify_backup_key_view_screen_test.mocks.dart | 5 +++++ .../currency_view_screen_test.mocks.dart | 5 +++++ .../add_custom_node_view_screen_test.mocks.dart | 5 +++++ .../node_details_view_screen_test.mocks.dart | 5 +++++ .../wallet_backup_view_screen_test.mocks.dart | 5 +++++ .../rescan_warning_view_screen_test.mocks.dart | 5 +++++ ...et_delete_mnemonic_view_screen_test.mocks.dart | 5 +++++ .../wallet_settings_view_screen_test.mocks.dart | 5 +++++ .../settings_view_screen_test.mocks.dart | 5 +++++ ...ion_search_results_view_screen_test.mocks.dart | 5 +++++ .../confirm_send_view_screen_test.mocks.dart | 5 +++++ .../receive_view_screen_test.mocks.dart | 5 +++++ .../wallet_view/send_view_screen_test.mocks.dart | 5 +++++ .../wallet_view_screen_test.mocks.dart | 5 +++++ test/services/coins/manager_test.mocks.dart | 5 +++++ .../widget_tests/managed_favorite_test.mocks.dart | 10 ++++++++++ .../table_view/table_view_row_test.mocks.dart | 10 ++++++++++ .../widget_tests/transaction_card_test.mocks.dart | 15 +++++++++++++++ ...wallet_info_row_balance_future_test.mocks.dart | 10 ++++++++++ .../wallet_info_row_test.mocks.dart | 10 ++++++++++ 32 files changed, 195 insertions(+) diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index e83a5e292..4d5793cc4 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -2137,6 +2137,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2504,6 +2509,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 c1f322a08..c282d1f38 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 @@ -416,6 +416,11 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 d86533c22..dd8112508 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 @@ -377,6 +377,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 403d3523f..0e4253f6e 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 @@ -375,6 +375,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index 2ea9822b6..7218d6530 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -684,6 +684,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 b2168f408..27a456307 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 @@ -471,6 +471,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 fdc326e3c..13419efd9 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 @@ -471,6 +471,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 b3b16f4cb..5545ef110 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 @@ -471,6 +471,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 1e3c575cf..ab9fb86ad 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 @@ -246,6 +246,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 5bb48aadd..c699077c2 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 @@ -469,6 +469,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 c891911ae..96ac903a7 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 @@ -684,6 +684,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 ee326b1d8..bdc823d5c 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 @@ -525,6 +525,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 775326480..708252b7a 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 @@ -246,6 +246,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 dc2ff6257..a2c356b3f 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 @@ -246,6 +246,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 9cdd45a2a..908a7291c 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 @@ -461,6 +461,11 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 984287655..aed7f5032 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 @@ -461,6 +461,11 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 3241ca931..59197ddc3 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 @@ -246,6 +246,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 67a0b598b..cf1a42d6a 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 @@ -246,6 +246,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 a036896f1..f52602c9b 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 @@ -469,6 +469,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 7eb0853dd..f1ba7d2cb 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 @@ -726,6 +726,11 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 ddfdcc387..1552fb249 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 @@ -469,6 +469,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 fda23c162..308d6a2fa 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 @@ -248,6 +248,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 108b77901..024c8a8f4 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 @@ -247,6 +247,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 760c1d754..180a8f21a 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 @@ -246,6 +246,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 dbcc2eef1..3441563f9 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 @@ -288,6 +288,11 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, 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 a75e0d23c..a6391eb84 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 @@ -248,6 +248,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index 9a958702f..86e18418c 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -366,6 +366,11 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 2bdd631ba..c5fef27dc 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -1784,6 +1784,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2151,6 +2156,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 48bcb2e2c..e60f39244 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 @@ -1507,6 +1507,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -1874,6 +1879,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override _i15.Future> prepareSend({ required String? address, required int? satoshiAmount, diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 3519f9080..85e921d41 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -580,6 +580,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -951,6 +956,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, @@ -1397,6 +1407,11 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( 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 e1dcf3c76..ad27dd693 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 @@ -1721,6 +1721,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2088,6 +2093,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 95d600267..e11e4bb51 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 @@ -1721,6 +1721,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override + int get currentHeight => (super.noSuchMethod( + Invocation.getter(#currentHeight), + returnValue: 0, + ) as int); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2088,6 +2093,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override + int get storedChainHeight => (super.noSuchMethod( + Invocation.getter(#storedChainHeight), + returnValue: 0, + ) as int); + @override _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, From ce05a647f0fac663839ae76cb6cbf2c933cbeec7 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:49:31 -0600 Subject: [PATCH 080/192] update isar address class --- lib/models/isar/models/address/address.dart | 6 +++++- lib/models/isar/models/address/crypto_currency_address.dart | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 15f09df6f..054e620b3 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -8,12 +8,16 @@ class AddressException extends SWException { AddressException(super.message); } -@Collection(inheritance: true) +@collection class Address extends CryptoCurrencyAddress { Id id = Isar.autoIncrement; + @Index(unique: true, replace: true) + late String value; + late List publicKey; + @Index() late int derivationIndex; @enumerated diff --git a/lib/models/isar/models/address/crypto_currency_address.dart b/lib/models/isar/models/address/crypto_currency_address.dart index 30b725024..4c8670a30 100644 --- a/lib/models/isar/models/address/crypto_currency_address.dart +++ b/lib/models/isar/models/address/crypto_currency_address.dart @@ -1,6 +1,3 @@ abstract class CryptoCurrencyAddress { - late String value; - - @override - String toString() => value; +// future use? } From 8ee94287589db1a8965f8dd753f693e624bad60f Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:50:22 -0600 Subject: [PATCH 081/192] add currentHeight getter --- .../coins/bitcoincash/bitcoincash_wallet.dart | 6 ++++-- lib/services/coins/coin_service.dart | 2 ++ lib/services/coins/firo/firo_wallet.dart | 19 ++++++++++++++----- lib/services/coins/manager.dart | 2 ++ lib/services/coins/monero/monero_wallet.dart | 4 ++++ .../coins/wownero/wownero_wallet.dart | 4 ++++ 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index b18a97186..743822e2f 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -253,7 +253,8 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - Future get storedChainHeight async { + @override + int get storedChainHeight { final storedHeight = DB.instance .get(boxName: walletId, key: "storedChainHeight") as int?; return storedHeight ?? 0; @@ -1174,7 +1175,8 @@ class BitcoinCashWallet extends CoinServiceAPI { final priceData = await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; final String worthNow = Format.localizedStringAsFixed( value: ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index a690157ee..ff953708f 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -307,4 +307,6 @@ abstract class CoinServiceAPI { // used for electrumx coins Future updateSentCachedTxData(Map txData); + + int get storedChainHeight; } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 5d29bd0a9..adf259a32 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -883,7 +883,8 @@ class FiroWallet extends CoinServiceAPI { @override Future updateSentCachedTxData(Map txData) async { final currentPrice = await firoPrice; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; final String worthNow = Format.localizedStringAsFixed( value: ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / @@ -2756,7 +2757,8 @@ class FiroWallet extends CoinServiceAPI { var price = await firoPrice; var builtHex = txb.build(); // return builtHex; - final locale =Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; return { "transaction": builtHex, "txid": txId, @@ -2810,7 +2812,8 @@ class FiroWallet extends CoinServiceAPI { final currentPrice = await firoPrice; // Grab the most recent information on all the joinsplits - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; final updatedJSplit = await getJMintTransactions(cachedElectrumXClient, joinsplits, _prefs.currency, coin, currentPrice, locale!); @@ -3249,7 +3252,8 @@ class FiroWallet extends CoinServiceAPI { final currentPrice = await firoPrice; final List> midSortedArray = []; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; Logging.instance.log("refresh the txs", level: LogLevel.Info); for (final txObject in allTransactions) { @@ -4375,7 +4379,8 @@ class FiroWallet extends CoinServiceAPI { final lelantusEntry = await _getLelantusEntry(); final anonymitySets = await fetchAnonymitySets(); final locktime = await getBlockHead(electrumXClient); - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + final locale = + Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; ReceivePort receivePort = await getIsolate({ "function": "createJoinSplit", @@ -4806,4 +4811,8 @@ class FiroWallet extends CoinServiceAPI { Future availablePublicBalance() async { return (await balances)[4]; } + + @override + // TODO: implement storedChainHeight + int get storedChainHeight => throw UnimplementedError(); } diff --git a/lib/services/coins/manager.dart b/lib/services/coins/manager.dart index c850358eb..1c2163c04 100644 --- a/lib/services/coins/manager.dart +++ b/lib/services/coins/manager.dart @@ -278,4 +278,6 @@ class Manager with ChangeNotifier { } return success; } + + int get currentHeight => _currentWallet.storedChainHeight; } diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index d9c6ae42b..7b073e63f 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1334,4 +1334,8 @@ class MoneroWallet extends CoinServiceAPI { key: "highestPercentCached", value: value, ); + + @override + // TODO: implement storedChainHeight + int get storedChainHeight => throw UnimplementedError(); } diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 7abd64f48..fad3fc8ba 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1378,4 +1378,8 @@ class WowneroWallet extends CoinServiceAPI { key: "highestPercentCached", value: value, ); + + @override + // TODO: implement storedChainHeight + int get storedChainHeight => throw UnimplementedError(); } From fdaa3f7d9da761558b118d42b53ed88b425ced41 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:51:34 -0600 Subject: [PATCH 082/192] update isar transaction model --- .../models/blockchain_data/transaction.dart | 7 +- .../models/blockchain_data/transaction.g.dart | 264 +++++++++++++++++- 2 files changed, 259 insertions(+), 12 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 32f9f224f..7733cfe66 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -11,8 +11,10 @@ part 'transaction.g.dart'; class Transaction { Id id = Isar.autoIncrement; + @Index(unique: true, replace: true) late String txid; + @Index() late int timestamp; @enumerated @@ -30,7 +32,7 @@ class Transaction { late String address; - late int height; + late int? height; late bool cancelled; @@ -46,7 +48,8 @@ class Transaction { final note = IsarLink(); int getConfirmations(int currentChainHeight) { - return max(0, currentChainHeight - height); + if (height == null) return 0; + return max(0, currentChainHeight - height!); } bool isConfirmed(int currentChainHeight, int minimumConfirms) { diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 5d7107f9f..242c818b9 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -80,7 +80,34 @@ const TransactionSchema = CollectionSchema( deserialize: _transactionDeserialize, deserializeProp: _transactionDeserializeProp, idName: r'id', - indexes: {}, + indexes: { + r'txid': IndexSchema( + id: 7339874292043634331, + name: r'txid', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'txid', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'timestamp': IndexSchema( + id: 1852253767416892198, + name: r'timestamp', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'timestamp', + type: IndexType.value, + caseSensitive: false, + ) + ], + ) + }, links: { r'inputs': LinkSchema( id: 4634425919890543640, @@ -95,10 +122,11 @@ const TransactionSchema = CollectionSchema( single: false, ), r'note': LinkSchema( - id: 1009915346265072213, + id: -7669541085246698630, name: r'note', target: r'TransactionNote', single: true, + linkName: r'transaction', ) }, embeddedSchemas: {}, @@ -161,7 +189,7 @@ Transaction _transactionDeserialize( object.amount = reader.readLong(offsets[1]); object.cancelled = reader.readBool(offsets[2]); object.fee = reader.readLong(offsets[3]); - object.height = reader.readLong(offsets[4]); + object.height = reader.readLongOrNull(offsets[4]); object.id = id; object.otherData = reader.readStringOrNull(offsets[5]); object.slateId = reader.readStringOrNull(offsets[6]); @@ -192,7 +220,7 @@ P _transactionDeserializeProp

( case 3: return (reader.readLong(offset)) as P; case 4: - return (reader.readLong(offset)) as P; + return (reader.readLongOrNull(offset)) as P; case 5: return (reader.readStringOrNull(offset)) as P; case 6: @@ -253,6 +281,61 @@ void _transactionAttach( object.note.attach(col, col.isar.collection(), r'note', id); } +extension TransactionByIndex on IsarCollection { + Future getByTxid(String txid) { + return getByIndex(r'txid', [txid]); + } + + Transaction? getByTxidSync(String txid) { + return getByIndexSync(r'txid', [txid]); + } + + Future deleteByTxid(String txid) { + return deleteByIndex(r'txid', [txid]); + } + + bool deleteByTxidSync(String txid) { + return deleteByIndexSync(r'txid', [txid]); + } + + Future> getAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndex(r'txid', values); + } + + List getAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'txid', values); + } + + Future deleteAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'txid', values); + } + + int deleteAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'txid', values); + } + + Future putByTxid(Transaction object) { + return putByIndex(r'txid', object); + } + + Id putByTxidSync(Transaction object, {bool saveLinks = true}) { + return putByIndexSync(r'txid', object, saveLinks: saveLinks); + } + + Future> putAllByTxid(List objects) { + return putAllByIndex(r'txid', objects); + } + + List putAllByTxidSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'txid', objects, saveLinks: saveLinks); + } +} + extension TransactionQueryWhereSort on QueryBuilder { QueryBuilder anyId() { @@ -260,6 +343,14 @@ extension TransactionQueryWhereSort return query.addWhereClause(const IdWhereClause.any()); }); } + + QueryBuilder anyTimestamp() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'timestamp'), + ); + }); + } } extension TransactionQueryWhere @@ -329,6 +420,142 @@ extension TransactionQueryWhere )); }); } + + QueryBuilder txidEqualTo( + String txid) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid', + value: [txid], + )); + }); + } + + QueryBuilder txidNotEqualTo( + String txid) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )); + } + }); + } + + QueryBuilder timestampEqualTo( + int timestamp) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'timestamp', + value: [timestamp], + )); + }); + } + + QueryBuilder timestampNotEqualTo( + int timestamp) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'timestamp', + lower: [], + upper: [timestamp], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'timestamp', + lower: [timestamp], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'timestamp', + lower: [timestamp], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'timestamp', + lower: [], + upper: [timestamp], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + timestampGreaterThan( + int timestamp, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'timestamp', + lower: [timestamp], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder timestampLessThan( + int timestamp, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'timestamp', + lower: [], + upper: [timestamp], + includeUpper: include, + )); + }); + } + + QueryBuilder timestampBetween( + int lowerTimestamp, + int upperTimestamp, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'timestamp', + lower: [lowerTimestamp], + includeLower: includeLower, + upper: [upperTimestamp], + includeUpper: includeUpper, + )); + }); + } } extension TransactionQueryFilter @@ -584,8 +811,25 @@ extension TransactionQueryFilter }); } + QueryBuilder heightIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'height', + )); + }); + } + + QueryBuilder + heightIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'height', + )); + }); + } + QueryBuilder heightEqualTo( - int value) { + int? value) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'height', @@ -596,7 +840,7 @@ extension TransactionQueryFilter QueryBuilder heightGreaterThan( - int value, { + int? value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { @@ -609,7 +853,7 @@ extension TransactionQueryFilter } QueryBuilder heightLessThan( - int value, { + int? value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { @@ -622,8 +866,8 @@ extension TransactionQueryFilter } QueryBuilder heightBetween( - int lower, - int upper, { + int? lower, + int? upper, { bool includeLower = true, bool includeUpper = true, }) { @@ -1820,7 +2064,7 @@ extension TransactionQueryProperty }); } - QueryBuilder heightProperty() { + QueryBuilder heightProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'height'); }); From 9d6e2d0a0dd271e32ad5c052bf00fc12e2b65735 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:52:27 -0600 Subject: [PATCH 083/192] update dogecoin to use isar for addresses and transactions --- .../coins/dogecoin/dogecoin_wallet.dart | 937 +++++++----------- 1 file changed, 345 insertions(+), 592 deletions(-) diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 457dc5c8c..895689e09 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -7,15 +7,18 @@ import 'package:bech32/bech32.dart'; import 'package:bip32/bip32.dart' as bip32; import 'package:bip39/bip39.dart' as bip39; import 'package:bitcoindart/bitcoindart.dart'; +import 'package:bitcoindart/bitcoindart.dart' as btc_dart; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/isar/models/address/address.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/models.dart' as models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/models/paymint/transactions_model.dart'; @@ -40,6 +43,7 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -154,8 +158,9 @@ class DogecoinWallet extends CoinServiceAPI { @override Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - Future>? _allOwnAddresses; + throw Exception("doeg all own address exception!!"); + // _allOwnAddresses ??= _fetchAllOwnAddresses(); + // Future>? _allOwnAddresses; Future? _utxoData; Future get utxoData => _utxoData ??= _fetchUtxoData(); @@ -202,11 +207,28 @@ class DogecoinWallet extends CoinServiceAPI { } @override - Future get currentReceivingAddress => - _currentReceivingAddressP2PKH ??= - getCurrentAddressForChain(0, DerivePathType.bip44); + Future get currentReceivingAddress async => + (await _currentReceivingAddress).value; - Future? _currentReceivingAddressP2PKH; + Future get _currentReceivingAddress async => + (await isar.address + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; + + // @override + Future get currentChangeAddress async => + (await _currentChangeAddress).value; + + Future get _currentChangeAddress async => + (await isar.address + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -214,6 +236,7 @@ class DogecoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); + await isar.close(); } bool _hasCalledExit = false; @@ -247,7 +270,8 @@ class DogecoinWallet extends CoinServiceAPI { } } - Future get storedChainHeight async { + @override + int get storedChainHeight { final storedHeight = DB.instance .get(boxName: walletId, key: "storedChainHeight") as int?; return storedHeight ?? 0; @@ -355,8 +379,8 @@ class DogecoinWallet extends CoinServiceAPI { int txCountBatchSize, bip32.BIP32 root, DerivePathType type, - int account) async { - List addressArray = []; + int chain) async { + List addressArray = []; int returningIndex = -1; Map> derivations = {}; int gapCounter = 0; @@ -365,7 +389,7 @@ class DogecoinWallet extends CoinServiceAPI { index += txCountBatchSize) { List iterationsAddressArray = []; Logging.instance.log( - "index: $index, \t GapCounter $account ${type.name}: $gapCounter", + "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", level: LogLevel.Info); final _id = "k_$index"; @@ -376,19 +400,27 @@ class DogecoinWallet extends CoinServiceAPI { final node = await compute( getBip32NodeFromRootWrapper, Tuple4( - account, + chain, index + j, root, type, ), ); - String? address; + isar_models.Address address; switch (type) { case DerivePathType.bip44: - address = P2PKH( + final addressString = P2PKH( data: PaymentData(pubkey: node.publicKey), network: network) .data .address!; + address = isar_models.Address() + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = isar_models.AddressType.p2pkh + ..publicKey = node.publicKey + ..value = addressString + ..derivationIndex = index + j; break; default: throw Exception("No Path type $type exists"); @@ -400,7 +432,7 @@ class DogecoinWallet extends CoinServiceAPI { } }); txCountCallArgs.addAll({ - "${_id}_$j": address, + "${_id}_$j": address.value, }); } @@ -412,15 +444,16 @@ class DogecoinWallet extends CoinServiceAPI { int count = counts["${_id}_$k"]!; if (count > 0) { final node = receivingNodes["${_id}_$k"]; + final address = node["address"] as isar_models.Address; // add address to array - addressArray.add(node["address"] as String); - iterationsAddressArray.add(node["address"] as String); + addressArray.add(address); + iterationsAddressArray.add(address.value); // set current index returningIndex = index + k; // reset counter gapCounter = 0; // add info to derivations - derivations[node["address"] as String] = { + derivations[address.value] = { "pubKey": Format.uint8listToString( (node["node"] as bip32.BIP32).publicKey), "wif": (node["node"] as bip32.BIP32).toWIF(), @@ -474,10 +507,10 @@ class DogecoinWallet extends CoinServiceAPI { final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, network)); - List p2pkhReceiveAddressArray = []; + List p2pkhReceiveAddressArray = []; int p2pkhReceiveIndex = -1; - List p2pkhChangeAddressArray = []; + List p2pkhChangeAddressArray = []; int p2pkhChangeIndex = -1; // actual size is 12 due to p2pkh so 12x1 @@ -502,13 +535,13 @@ class DogecoinWallet extends CoinServiceAPI { ]); p2pkhReceiveAddressArray = - (await resultReceive44)['addressArray'] as List; + (await resultReceive44)['addressArray'] as List; p2pkhReceiveIndex = (await resultReceive44)['index'] as int; p2pkhReceiveDerivations = (await resultReceive44)['derivations'] as Map>; p2pkhChangeAddressArray = - (await resultChange44)['addressArray'] as List; + (await resultChange44)['addressArray'] as List; p2pkhChangeIndex = (await resultChange44)['index'] as int; p2pkhChangeDerivations = (await resultChange44)['derivations'] as Map>; @@ -545,20 +578,13 @@ class DogecoinWallet extends CoinServiceAPI { p2pkhChangeIndex = 0; } - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: p2pkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: p2pkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: p2pkhReceiveIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2PKH', value: p2pkhChangeIndex); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.address.putAll(p2pkhChangeAddressArray); + await isar.address.putAll(p2pkhReceiveAddressArray); + }); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); await DB.instance @@ -606,11 +632,15 @@ class DogecoinWallet extends CoinServiceAPI { } if (!needsRefresh) { var allOwnAddresses = await _fetchAllOwnAddresses(); - List> allTxs = - await _fetchHistory(allOwnAddresses); - final txData = await transactionData; + List> allTxs = await _fetchHistory( + allOwnAddresses.map((e) => e.value).toList(growable: false)); + // final txData = await transactionData; for (Map transaction in allTxs) { - if (txData.findTransaction(transaction['tx_hash'] as String) == + final txid = transaction['tx_hash'] as String; + if ((await isar.transactions + .filter() + .txidMatches(txid) + .findFirst()) == null) { Logging.instance.log( " txid not found in address history already ${transaction['tx_hash']}", @@ -629,17 +659,26 @@ class DogecoinWallet extends CoinServiceAPI { } } - Future getAllTxsToWatch( - TransactionData txData, - ) async { + Future getAllTxsToWatch() async { if (_hasCalledExit) return; - List unconfirmedTxnsToNotifyPending = []; - List unconfirmedTxnsToNotifyConfirmed = []; + List unconfirmedTxnsToNotifyPending = []; + List unconfirmedTxnsToNotifyConfirmed = []; - // Get all unconfirmed incoming transactions - for (final chunk in txData.txChunks) { - for (final tx in chunk.transactions) { - if (tx.confirmedStatus) { + final currentChainHeight = + (await electrumXClient.getBlockHeadTip())["height"] as int; + + final txCount = await isar.transactions.count(); + + const paginateLimit = 50; + + for (int i = 0; i < txCount; i += paginateLimit) { + final transactions = await isar.transactions + .where() + .offset(i) + .limit(paginateLimit) + .findAll(); + for (final tx in transactions) { + if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { if (txTracker.wasNotifiedPending(tx.txid) && !txTracker.wasNotifiedConfirmed(tx.txid)) { unconfirmedTxnsToNotifyConfirmed.add(tx); @@ -652,33 +691,51 @@ class DogecoinWallet extends CoinServiceAPI { } } + // // Get all unconfirmed incoming transactions + // for (final chunk in txData.txChunks) { + // for (final tx in chunk.transactions) { + // if (tx.confirmedStatus) { + // if (txTracker.wasNotifiedPending(tx.txid) && + // !txTracker.wasNotifiedConfirmed(tx.txid)) { + // unconfirmedTxnsToNotifyConfirmed.add(tx); + // } + // } else { + // if (!txTracker.wasNotifiedPending(tx.txid)) { + // unconfirmedTxnsToNotifyPending.add(tx); + // } + // } + // } + // } + // notify on new incoming transaction for (final tx in unconfirmedTxnsToNotifyPending) { - if (tx.txType == "Received") { + final confirmations = tx.getConfirmations(currentChainHeight); + + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.now(), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Sending transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); @@ -687,7 +744,7 @@ class DogecoinWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { - if (tx.txType == "Received") { + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction confirmed", body: walletName, @@ -699,7 +756,7 @@ class DogecoinWallet extends CoinServiceAPI { )); await txTracker.addNotifiedConfirmed(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Outgoing transaction confirmed", body: walletName, @@ -776,12 +833,12 @@ class DogecoinWallet extends CoinServiceAPI { } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - await checkChangeAddressForTransactions(DerivePathType.bip44); + await checkChangeAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); await _checkCurrentReceivingAddressesForTransactions(); - final newTxData = _fetchTransactionData(); + final fetchFuture = _fetchTransactionData(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); @@ -790,8 +847,6 @@ class DogecoinWallet extends CoinServiceAPI { GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.60, walletId)); - _transactionData = Future(() => newTxData); - GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.70, walletId)); _feeObject = Future(() => feeObj); @@ -799,7 +854,8 @@ class DogecoinWallet extends CoinServiceAPI { GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); - await getAllTxsToWatch(await newTxData); + await fetchFuture; + await getAllTxsToWatch(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.90, walletId)); } @@ -1031,28 +1087,36 @@ class DogecoinWallet extends CoinServiceAPI { ]); } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { - throw Exception( - "Attempted to initialize an existing wallet using an unknown wallet ID!"); - } await _prefs.init(); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); } @override Future get transactionData => - _transactionData ??= _fetchTransactionData(); - Future? _transactionData; + throw Exception("dogecoin transactionData attempt"); + // _transactionData ??= _fetchTransactionData(); + // Future? _transactionData; TransactionData? cachedTxData; @@ -1061,51 +1125,51 @@ class DogecoinWallet extends CoinServiceAPI { // transactions locally in a good way @override Future updateSentCachedTxData(Map txData) async { - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = - Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final String worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - - final tx = models.Transaction( - txid: txData["txid"] as String, - confirmedStatus: false, - timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, - txType: "Sent", - amount: txData["recipientAmt"] as int, - worthNow: worthNow, - worthAtBlockTimestamp: worthNow, - fees: txData["fee"] as int, - inputSize: 0, - outputSize: 0, - inputs: [], - outputs: [], - address: txData["address"] as String, - height: -1, - confirmations: 0, - ); - - if (cachedTxData == null) { - final data = await _fetchTransactionData(); - _transactionData = Future(() => data); - } - - final transactions = cachedTxData!.getAllTransactions(); - transactions[tx.txid] = tx; - cachedTxData = models.TransactionData.fromMap(transactions); - _transactionData = Future(() => cachedTxData!); + // final priceData = + // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); + // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final String worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // + // final tx = models.Transaction( + // txid: txData["txid"] as String, + // confirmedStatus: false, + // timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // txType: "Sent", + // amount: txData["recipientAmt"] as int, + // worthNow: worthNow, + // worthAtBlockTimestamp: worthNow, + // fees: txData["fee"] as int, + // inputSize: 0, + // outputSize: 0, + // inputs: [], + // outputs: [], + // address: txData["address"] as String, + // height: -1, + // confirmations: 0, + // ); + // + // if (cachedTxData == null) { + // final data = await _fetchTransactionData(); + // _transactionData = Future(() => data); + // } + // + // final transactions = cachedTxData!.getAllTransactions(); + // transactions[tx.txid] = tx; + // cachedTxData = models.TransactionData.fromMap(transactions); + // _transactionData = Future(() => cachedTxData!); } @override bool validateAddress(String address) { - return Address.validateAddress(address, network); + return btc_dart.Address.validateAddress(address, network); } @override @@ -1132,6 +1196,8 @@ class DogecoinWallet extends CoinServiceAPI { late PriceAPI _priceAPI; + late Isar isar; + DogecoinWallet({ required String walletId, required String walletName, @@ -1206,35 +1272,41 @@ class DogecoinWallet extends CoinServiceAPI { ); } - Future> _fetchAllOwnAddresses() async { - final List allAddresses = []; - - final receivingAddressesP2PKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2PKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - - // for (var i = 0; i < receivingAddresses.length; i++) { - // if (!allAddresses.contains(receivingAddresses[i])) { - // allAddresses.add(receivingAddresses[i]); + Future> _fetchAllOwnAddresses() async { + final allAddresses = await isar.address + .filter() + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change) + .findAll(); + // final List allAddresses = []; + // + // final receivingAddressesP2PKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2PKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // + // // for (var i = 0; i < receivingAddresses.length; i++) { + // // if (!allAddresses.contains(receivingAddresses[i])) { + // // allAddresses.add(receivingAddresses[i]); + // // } + // // } + // // for (var i = 0; i < changeAddresses.length; i++) { + // // if (!allAddresses.contains(changeAddresses[i])) { + // // allAddresses.add(changeAddresses[i]); + // // } + // // } + // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2PKH[i])) { + // allAddresses.add(receivingAddressesP2PKH[i] as String); // } // } - // for (var i = 0; i < changeAddresses.length; i++) { - // if (!allAddresses.contains(changeAddresses[i])) { - // allAddresses.add(changeAddresses[i]); + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2PKH[i])) { + // allAddresses.add(changeAddressesP2PKH[i] as String); // } // } - for (var i = 0; i < receivingAddressesP2PKH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2PKH[i])) { - allAddresses.add(receivingAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - if (!allAddresses.contains(changeAddressesP2PKH[i])) { - allAddresses.add(changeAddressesP2PKH[i] as String); - } - } return allAddresses; } @@ -1303,43 +1375,36 @@ class DogecoinWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet + // // Set relevant indexes + // await DB.instance + // .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); + // await DB.instance + // .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); + // await DB.instance.put( + // boxName: walletId, + // key: 'blocked_tx_hashes', + // value: ["0xdefault"], + // ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, key: 'addressBookEntries', value: {}); - // Generate and add addresses to relevant arrays - // final initialReceivingAddress = - // await _generateAddressForChain(0, 0, DerivePathType.bip44); - // final initialChangeAddress = - // await _generateAddressForChain(1, 0, DerivePathType.bip44); + // Generate and add addresses final initialReceivingAddressP2PKH = await _generateAddressForChain(0, 0, DerivePathType.bip44); final initialChangeAddressP2PKH = await _generateAddressForChain(1, 0, DerivePathType.bip44); - // await _addToAddressesArrayForChain( - // initialReceivingAddress, 0, DerivePathType.bip44); - // await _addToAddressesArrayForChain( - // initialChangeAddress, 1, DerivePathType.bip44); - await _addToAddressesArrayForChain( - initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - await _addToAddressesArrayForChain( - initialChangeAddressP2PKH, 1, DerivePathType.bip44); + await _isarInit(); - // this._currentReceivingAddress = Future(() => initialReceivingAddress); - _currentReceivingAddressP2PKH = Future(() => initialReceivingAddressP2PKH); + await isar.writeTxn(() async { + await isar.address.putAll([ + initialReceivingAddressP2PKH, + initialChangeAddressP2PKH, + ]); + }); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1347,7 +1412,7 @@ class DogecoinWallet extends CoinServiceAPI { /// Generates a new internal or external chain address for the wallet using a BIP44 derivation path. /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! /// [index] - This can be any integer >= 0 - Future _generateAddressForChain( + Future _generateAddressForChain( int chain, int index, DerivePathType derivePathType, @@ -1384,63 +1449,14 @@ class DogecoinWallet extends CoinServiceAPI { derivePathType: derivePathType, ); - return address; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain( - int chain, DerivePathType derivePathType) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - } - - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain( - String address, int chain, DerivePathType derivePathType) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - switch (derivePathType) { - case DerivePathType.bip44: - chainArray += "P2PKH"; - break; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = node.publicKey + ..type = isar_models.AddressType.p2pkh + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] @@ -1448,16 +1464,20 @@ class DogecoinWallet extends CoinServiceAPI { /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! Future getCurrentAddressForChain( int chain, DerivePathType derivePathType) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; + isar_models.Address? address; switch (derivePathType) { case DerivePathType.bip44: - arrayKey += "P2PKH"; + address = await isar.address + .filter() + .subTypeEqualTo( + chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst(); break; } - final internalChainArray = - DB.instance.get(boxName: walletId, key: arrayKey); - return internalChainArray.last as String; + return address!.value; } String _buildDerivationStorageKey( @@ -1590,7 +1610,7 @@ class DogecoinWallet extends CoinServiceAPI { } Future _fetchUtxoData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + final allAddresses = await _fetchAllOwnAddresses(); try { final fetchedUtxoList = >>[]; @@ -1602,7 +1622,7 @@ class DogecoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], network); + final scripthash = _convertToScriptHash(allAddresses[i].value, network); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -1797,93 +1817,64 @@ class DogecoinWallet extends CoinServiceAPI { } } - Future _checkReceivingAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkReceivingAddressForTransactions() async { try { - final String currentExternalAddr = - await getCurrentAddressForChain(0, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentReceiving = await _currentReceivingAddress; + + final int txCount = await getTxCount(address: currentReceiving.value); Logging.instance.log( - 'Number of txs for current receiving address $currentExternalAddr: $txCount', + 'Number of txs for current receiving address $currentReceiving: $txCount', level: LogLevel.Info); if (txCount >= 1) { - // First increment the receiving index - await _incrementAddressIndexForChain(0, derivePathType); - - // Check the new receiving index - String indexKey = "receivingIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - } - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = currentReceiving.derivationIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, newReceivingIndex, derivePathType); + 0, newReceivingIndex, DerivePathType.bip44); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain( - newReceivingAddress, 0, derivePathType); - - // Set the new receiving address that the service - - switch (derivePathType) { - case DerivePathType.bip44: - _currentReceivingAddressP2PKH = Future(() => newReceivingAddress); - break; - } + // Add that new receiving address + await isar.writeTxn(() async { + await isar.address.put(newReceivingAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( - "SocketException caught in _checkReceivingAddressForTransactions($derivePathType): $se\n$s", + "SocketException caught in _checkReceivingAddressForTransactions($DerivePathType.bip44): $se\n$s", level: LogLevel.Error); return; } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions($DerivePathType.bip44): $e\n$s", level: LogLevel.Error); rethrow; } } - Future checkChangeAddressForTransactions( - DerivePathType derivePathType) async { + Future checkChangeAddressForTransactions() async { try { - final String currentExternalAddr = - await getCurrentAddressForChain(1, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentChange = await _currentChangeAddress; + final int txCount = await getTxCount(address: currentChange.value); Logging.instance.log( - 'Number of txs for current change address $currentExternalAddr: $txCount', + 'Number of txs for current change address $currentChange: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the change index - await _incrementAddressIndexForChain(1, derivePathType); - - // Check the new change index - String indexKey = "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - } - final newChangeIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newChangeIndex = currentChange.derivationIndex + 1; // Use new index to derive a new change address - final newChangeAddress = - await _generateAddressForChain(1, newChangeIndex, derivePathType); + final newChangeAddress = await _generateAddressForChain( + 1, newChangeIndex, DerivePathType.bip44); - // Add that new receiving address to the array of change addresses - await _addToAddressesArrayForChain(newChangeAddress, 1, derivePathType); + // Add that new change address + await isar.writeTxn(() async { + await isar.address.put(newChangeAddress); + }); } } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkChangeAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkChangeAddressForTransactions($DerivePathType.bip44): $e\n$s", level: LogLevel.Error); rethrow; } @@ -1892,7 +1883,7 @@ class DogecoinWallet extends CoinServiceAPI { Future _checkCurrentReceivingAddressesForTransactions() async { try { for (final type in DerivePathType.values) { - await _checkReceivingAddressForTransactions(type); + await _checkReceivingAddressForTransactions(); } } catch (e, s) { Logging.instance.log( @@ -1916,7 +1907,7 @@ class DogecoinWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { for (final type in DerivePathType.values) { - await checkChangeAddressForTransactions(type); + await checkChangeAddressForTransactions(); } } catch (e, s) { Logging.instance.log( @@ -1942,7 +1933,10 @@ class DogecoinWallet extends CoinServiceAPI { /// Returns the scripthash or throws an exception on invalid dogecoin address String _convertToScriptHash(String dogecoinAddress, NetworkType network) { try { - final output = Address.addressToOutputScript(dogecoinAddress, network); + final output = btc_dart.Address.addressToOutputScript( + dogecoinAddress, + network, + ); final hash = sha256.convert(output.toList(growable: false)).toString(); final chars = hash.split(""); @@ -2013,45 +2007,53 @@ class DogecoinWallet extends CoinServiceAPI { return false; } - Future _fetchTransactionData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + // Future migrate() async { + // final receivingAddressesP2PKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2PKH') as List; + // + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // + // await isar.writeTxn(() async { + // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { + // await isar.address.put( + // isar_models.Address() + // ..type = isar_models.AddressType.p2pkh + // ..subType = isar_models.AddressSubType.receiving + // ..publicKey = [] + // ..derivationIndex = i + // ..value = receivingAddressesP2PKH[i] as String, + // ); + // } + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // await isar.address.put( + // isar_models.Address() + // ..type = isar_models.AddressType.p2pkh + // ..subType = isar_models.AddressSubType.change + // ..publicKey = [] + // ..derivationIndex = i + // ..value = changeAddressesP2PKH[i] as String, + // ); + // } + // }); + // + // await DB.instance.put( + // boxName: walletId, key: "receivingAddressesP2PKH", value: []); + // await DB.instance.put( + // boxName: walletId, key: "changeAddressesP2PKH", value: []); + // } - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; + Future _fetchTransactionData() async { + final List allAddresses = + await _fetchAllOwnAddresses(); final List> allTxHashes = - await _fetchHistory(allAddresses); + await _fetchHistory(allAddresses.map((e) => e.value).toList()); - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as TransactionData?; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; + List hashes = + allTxHashes.map((e) => e['tx_hash'] as String).toList(growable: false); - final unconfirmedCachedTransactions = - cachedTransactions?.getAllTransactions() ?? {}; - unconfirmedCachedTransactions - .removeWhere((key, value) => value.confirmedStatus); - - if (cachedTransactions != null) { - for (final tx in allTxHashes.toList(growable: false)) { - final txHeight = tx["height"] as int; - if (txHeight > 0 && - txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - allTxHashes.remove(tx); - } - } - } - } - - List hashes = []; - for (var element in allTxHashes) { - hashes.add(element['tx_hash'] as String); - } await fastFetch(hashes); List> allTransactions = []; @@ -2063,7 +2065,6 @@ class DogecoinWallet extends CoinServiceAPI { ); // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - // TODO fix this for sent to self transactions? if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { tx["address"] = txHash["address"]; tx["height"] = txHash["height"]; @@ -2071,17 +2072,6 @@ class DogecoinWallet extends CoinServiceAPI { } } - Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); - Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); - - Logging.instance.log("allTransactions length: ${allTransactions.length}", - level: LogLevel.Info); - - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; - Set vHashes = {}; for (final txObject in allTransactions) { for (int i = 0; i < (txObject["vin"] as List).length; i++) { @@ -2093,257 +2083,25 @@ class DogecoinWallet extends CoinServiceAPI { await fastFetch(vHashes.toList()); for (final txObject in allTransactions) { - // List sendersArray = []; - // List recipientsArray = []; - // - // // Usually only has value when txType = 'Send' - // int inputAmtSentFromWallet = 0; - // // Usually has value regardless of txType due to change addresses - // int outputAmtAddressedToWallet = 0; - // int fee = 0; - // - // Map midSortedTx = {}; - // - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"][i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, coin: coin); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // final address = out["scriptPubKey"]["addresses"][0] as String?; - // if (address != null) { - // sendersArray.add(address); - // } - // } - // } - // } - // - // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - // - // for (final output in txObject["vout"] as List) { - // final address = output["scriptPubKey"]["addresses"][0] as String?; - // if (address != null) { - // recipientsArray.add(address); - // } - // } - // - // Logging.instance - // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - // - // final foundInSenders = - // allAddresses.any((element) => sendersArray.contains(element)); - // Logging.instance - // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - // - // // If txType = Sent, then calculate inputAmtSentFromWallet - // if (foundInSenders) { - // int totalInput = 0; - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"][i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // inputAmtSentFromWallet += - // (Decimal.parse(out["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // totalInput = inputAmtSentFromWallet; - // int totalOutput = 0; - // - // for (final output in txObject["vout"] as List) { - // final address = output["scriptPubKey"]["addresses"][0]; - // final value = output["value"]; - // final _value = (Decimal.parse(value.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOutput += _value; - // if (changeAddressesP2PKH.contains(address)) { - // inputAmtSentFromWallet -= _value; - // } else { - // // change address from 'sent from' to the 'sent to' address - // txObject["address"] = address; - // } - // } - // // calculate transaction fee - // fee = totalInput - totalOutput; - // // subtract fee from sent to calculate correct value of sent tx - // inputAmtSentFromWallet -= fee; - // } else { - // // counters for fee calculation - // int totalOut = 0; - // int totalIn = 0; - // - // // add up received tx value - // for (final output in txObject["vout"] as List) { - // final address = output["scriptPubKey"]["addresses"][0]; - // if (address != null) { - // final value = (Decimal.parse(output["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOut += value; - // if (allAddresses.contains(address)) { - // outputAmtAddressedToWallet += value; - // } - // } - // } - // - // // calculate fee for received tx - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"][i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // totalIn += (Decimal.parse(out["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // fee = totalIn - totalOut; - // } - // - // // create final tx map - // midSortedTx["txid"] = txObject["txid"]; - // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - // midSortedTx["timestamp"] = txObject["blocktime"] ?? - // (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // - // if (foundInSenders) { - // midSortedTx["txType"] = "Sent"; - // midSortedTx["amount"] = inputAmtSentFromWallet; - // final String worthNow = - // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // midSortedTx["worthAtBlockTimestamp"] = worthNow; - // } else { - // midSortedTx["txType"] = "Received"; - // midSortedTx["amount"] = outputAmtAddressedToWallet; - // final worthNow = - // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // } - // midSortedTx["aliens"] = []; - // midSortedTx["fees"] = fee; - // midSortedTx["address"] = txObject["address"]; - // midSortedTx["inputSize"] = txObject["vin"].length; - // midSortedTx["outputSize"] = txObject["vout"].length; - // midSortedTx["inputs"] = txObject["vin"]; - // midSortedTx["outputs"] = txObject["vout"]; - // - // final int height = txObject["height"] as int; - // midSortedTx["height"] = height; - // - // if (height >= latestTxnBlockHeight) { - // latestTxnBlockHeight = height; - // } - final midSortedTx = await parseTransaction( txObject, cachedElectrumXClient, - allAddresses.toSet(), - (changeAddressesP2PKH as List).toSet(), + allAddresses, coin, MINIMUM_CONFIRMATIONS, - currentPrice, ); - midSortedArray.add(midSortedTx); - } - - // sort by date ---- //TODO not sure if needed - // shouldn't be any issues with a null timestamp but I got one at some point? - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // { - // final aT = a["timestamp"]; - // final bT = b["timestamp"]; - // - // if (aT == null && bT == null) { - // return 0; - // } else if (aT == null) { - // return -1; - // } else if (bT == null) { - // return 1; - // } else { - // return bT - aT; - // } - // }); - - // buildDateTimeChunks - 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); - } + final tx = await isar.transactions + .filter() + .txidMatches(midSortedTx.txid) + .findFirst(); + // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar + if (tx == null) { + await isar.writeTxn(() async { + await isar.transactions.put(midSortedTx); }); - } else { - dateArray.add(txTimeArray[1]); - final chunk = { - "timestamp": txTimeArray[0], - "transactions": [txObject], - }; - result["dateTimeChunks"].add(chunk); } } - - final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); - - 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); - - cachedTxData = txModel; - return txModel; } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2532,7 +2290,7 @@ class DogecoinWallet extends CoinServiceAPI { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize == feeForTwoOutputs) { // generate new change address if current change address has been used - await checkChangeAddressForTransactions(DerivePathType.bip44); + await checkChangeAddressForTransactions(); final String newChangeAddress = await getCurrentAddressForChain(1, DerivePathType.bip44); @@ -3138,23 +2896,18 @@ class DogecoinWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - await _incrementAddressIndexForChain( - 0, DerivePathType.bip44); // First increment the receiving index - final newReceivingIndex = DB.instance.get( - boxName: walletId, - key: 'receivingIndexP2PKH') as int; // Check the new receiving index + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, - newReceivingIndex, - DerivePathType - .bip44); // Use new index to derive a new receiving address - await _addToAddressesArrayForChain( - newReceivingAddress, - 0, - DerivePathType - .bip44); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddressP2PKH = Future(() => - newReceivingAddress); // Set the new receiving address that the service + 0, newReceivingIndex, DerivePathType.bip44); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.address.put(newReceivingAddress); + }); return true; } catch (e, s) { From e7877358daf9160bf90efed73ee09e6df90f6509 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:53:09 -0600 Subject: [PATCH 084/192] temp. branching of transaction model type for dogecoin wallets --- .../sub_widgets/transactions_list.dart | 416 ++++++++++++++---- .../wallet_view/sub_widgets/tx_icon.dart | 79 +++- lib/widgets/transaction_card.dart | 280 +++++++++++- 3 files changed, 678 insertions(+), 97 deletions(-) diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index 667d46aae..ea78984b9 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -2,14 +2,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; +import 'package:stackwallet/models/paymint/transactions_model.dart' as old; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; +import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; import 'package:stackwallet/providers/global/trades_service_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/route_generator.dart'; +import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/manager.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/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -37,11 +42,12 @@ class TransactionsList extends ConsumerStatefulWidget { class _TransactionsListState extends ConsumerState { // bool _hasLoaded = false; - Map _transactions = {}; + Map _transactions = {}; + List _transactions2 = []; late final ChangeNotifierProvider managerProvider; - void updateTransactions(TransactionData newData) { + void updateTransactions(old.TransactionData newData) { _transactions = {}; final newTransactions = newData.txChunks.expand((element) => element.transactions); @@ -73,7 +79,10 @@ class _TransactionsListState extends ConsumerState { } Widget itemBuilder( - BuildContext context, Transaction tx, BorderRadius? radius) { + BuildContext context, + old.Transaction tx, + BorderRadius? radius, + ) { final matchingTrades = ref .read(tradesServiceProvider) .trades @@ -190,6 +199,134 @@ class _TransactionsListState extends ConsumerState { } } + Widget itemBuilder2( + BuildContext context, + Transaction tx, + BorderRadius? radius, + ) { + final matchingTrades = ref + .read(tradesServiceProvider) + .trades + .where((e) => e.payInTxid == tx.txid || e.payOutTxid == tx.txid); + if (tx.type == TransactionType.outgoing && matchingTrades.isNotEmpty) { + final trade = matchingTrades.first; + return Container( + decoration: BoxDecoration( + color: Theme.of(context).extension()!.popupBG, + borderRadius: radius, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TransactionCard2( + // this may mess with combined firo transactions + key: Key(tx.toString()), // + transaction: tx, + walletId: widget.walletId, + ), + TradeCard( + // this may mess with combined firo transactions + key: Key(tx.toString() + trade.uuid), // + trade: trade, + onTap: () async { + if (Util.isDesktop) { + // await showDialog( + // context: context, + // builder: (context) => Navigator( + // initialRoute: TradeDetailsView.routeName, + // onGenerateRoute: RouteGenerator.generateRoute, + // onGenerateInitialRoutes: (_, __) { + // return [ + // FadePageRoute( + // DesktopDialog( + // maxHeight: null, + // maxWidth: 580, + // child: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Padding( + // padding: const EdgeInsets.only( + // left: 32, + // bottom: 16, + // ), + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // "Trade details", + // style: STextStyles.desktopH3(context), + // ), + // DesktopDialogCloseButton( + // onPressedOverride: Navigator.of( + // context, + // rootNavigator: true, + // ).pop, + // ), + // ], + // ), + // ), + // Flexible( + // child: TradeDetailsView( + // tradeId: trade.tradeId, + // transactionIfSentFromStack: tx, + // walletName: + // ref.read(managerProvider).walletName, + // walletId: widget.walletId, + // ), + // ), + // ], + // ), + // ), + // const RouteSettings( + // name: TradeDetailsView.routeName, + // ), + // ), + // ]; + // }, + // ), + // ); + } else { + unawaited( + Navigator.of(context).pushNamed( + TradeDetailsView.routeName, + arguments: Tuple4( + trade.tradeId, + tx, + widget.walletId, + ref.read(managerProvider).walletName, + ), + ), + ); + } + }, + ) + ], + ), + ); + } else { + return Container( + decoration: BoxDecoration( + color: Theme.of(context).extension()!.popupBG, + borderRadius: radius, + ), + child: TransactionCard2( + // this may mess with combined firo transactions + key: Key(tx.toString()), // + transaction: tx, + walletId: widget.walletId, + ), + ); + } + } + + void updateHeightProvider(Manager manager) { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + ref.read(currentHeightProvider(manager.coin).state).state = + manager.currentHeight; + }); + } + @override void initState() { managerProvider = widget.managerProvider; @@ -202,94 +339,189 @@ class _TransactionsListState extends ConsumerState { // .watch(walletsChangeNotifierProvider) // .getManagerProvider(widget.walletId); - return FutureBuilder( - future: - ref.watch(managerProvider.select((value) => value.transactionData)), - builder: (fbContext, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - updateTransactions(snapshot.data!); - _hasLoaded = true; - } - if (!_hasLoaded) { - return Column( - children: const [ - Spacer(), - Center( - child: LoadingIndicator( - height: 50, - width: 50, - ), - ), - Spacer( - flex: 4, - ), - ], - ); - } - if (_transactions.isEmpty) { - return const NoTransActionsFound(); - } else { - final list = _transactions.values.toList(growable: false); - list.sort((a, b) => b.timestamp - a.timestamp); - return RefreshIndicator( - onRefresh: () async { - //todo: check if print needed - // debugPrint("pulled down to refresh on transaction list"); - final managerProvider = ref - .read(walletsChangeNotifierProvider) - .getManagerProvider(widget.walletId); - if (!ref.read(managerProvider).isRefreshing) { - unawaited(ref.read(managerProvider).refresh()); - } - }, - child: Util.isDesktop - ? ListView.separated( - itemBuilder: (context, index) { - BorderRadius? radius; - if (list.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == list.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = list[index]; - return itemBuilder(context, tx, radius); - }, - separatorBuilder: (context, index) { - return Container( - width: double.infinity, - height: 2, - color: Theme.of(context) - .extension()! - .background, - ); - }, - itemCount: list.length, - ) - : ListView.builder( - itemCount: list.length, - itemBuilder: (context, index) { - BorderRadius? radius; - if (list.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == list.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = list[index]; - return itemBuilder(context, tx, radius); - }, + final manager = ref.watch(walletsChangeNotifierProvider + .select((value) => value.getManager(widget.walletId))); + + if (manager.coin == Coin.dogecoinTestNet) { + updateHeightProvider(manager); + final wallet = manager.wallet as DogecoinWallet; + return FutureBuilder( + future: wallet.isar.transactions.where().findAll(), + builder: (fbContext, AsyncSnapshot> snapshot) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.hasData) { + _transactions2 = snapshot.data!; + _hasLoaded = true; + } + if (!_hasLoaded) { + return Column( + children: const [ + Spacer(), + Center( + child: LoadingIndicator( + height: 50, + width: 50, ), - ); - } - }, - ); + ), + Spacer( + flex: 4, + ), + ], + ); + } + if (_transactions2.isEmpty) { + return const NoTransActionsFound(); + } else { + _transactions2.sort((a, b) => b.timestamp - a.timestamp); + return RefreshIndicator( + onRefresh: () async { + //todo: check if print needed + // debugPrint("pulled down to refresh on transaction list"); + final managerProvider = ref + .read(walletsChangeNotifierProvider) + .getManagerProvider(widget.walletId); + if (!ref.read(managerProvider).isRefreshing) { + unawaited(ref.read(managerProvider).refresh()); + } + }, + child: Util.isDesktop + ? ListView.separated( + itemBuilder: (context, index) { + BorderRadius? radius; + if (_transactions2.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == _transactions2.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = _transactions2[index]; + return itemBuilder2(context, tx, radius); + }, + separatorBuilder: (context, index) { + return Container( + width: double.infinity, + height: 2, + color: Theme.of(context) + .extension()! + .background, + ); + }, + itemCount: _transactions2.length, + ) + : ListView.builder( + itemCount: _transactions2.length, + itemBuilder: (context, index) { + BorderRadius? radius; + if (_transactions2.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == _transactions2.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = _transactions2[index]; + return itemBuilder2(context, tx, radius); + }, + ), + ); + } + }, + ); + } else { + return FutureBuilder( + future: + ref.watch(managerProvider.select((value) => value.transactionData)), + builder: (fbContext, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.hasData) { + updateTransactions(snapshot.data!); + _hasLoaded = true; + } + if (!_hasLoaded) { + return Column( + children: const [ + Spacer(), + Center( + child: LoadingIndicator( + height: 50, + width: 50, + ), + ), + Spacer( + flex: 4, + ), + ], + ); + } + if (_transactions.isEmpty) { + return const NoTransActionsFound(); + } else { + final list = _transactions.values.toList(growable: false); + list.sort((a, b) => b.timestamp - a.timestamp); + return RefreshIndicator( + onRefresh: () async { + //todo: check if print needed + // debugPrint("pulled down to refresh on transaction list"); + final managerProvider = ref + .read(walletsChangeNotifierProvider) + .getManagerProvider(widget.walletId); + if (!ref.read(managerProvider).isRefreshing) { + unawaited(ref.read(managerProvider).refresh()); + } + }, + child: Util.isDesktop + ? ListView.separated( + itemBuilder: (context, index) { + BorderRadius? radius; + if (list.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == list.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = list[index]; + return itemBuilder(context, tx, radius); + }, + separatorBuilder: (context, index) { + return Container( + width: double.infinity, + height: 2, + color: Theme.of(context) + .extension()! + .background, + ); + }, + itemCount: list.length, + ) + : ListView.builder( + itemCount: list.length, + itemBuilder: (context, index) { + BorderRadius? radius; + if (list.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == list.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = list[index]; + return itemBuilder(context, tx, radius); + }, + ), + ); + } + }, + ); + } } } diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index 6222301a6..6d96cb279 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -1,11 +1,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; +import 'package:stackwallet/models/paymint/transactions_model.dart' as old; import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; class TxIcon extends StatelessWidget { const TxIcon({Key? key, required this.transaction}) : super(key: key); - final Transaction transaction; + final old.Transaction transaction; static const Size size = Size(32, 32); @@ -62,3 +64,76 @@ class TxIcon extends StatelessWidget { ); } } + +class TxIcon2 extends StatelessWidget { + const TxIcon2({ + Key? key, + required this.transaction, + required this.currentHeight, + required this.coin, + }) : super(key: key); + + final isar_models.Transaction transaction; + final int currentHeight; + final Coin coin; + + static const Size size = Size(32, 32); + + String _getAssetName( + bool isCancelled, bool isReceived, bool isPending, BuildContext context) { + if (!isReceived && + transaction.subType == isar_models.TransactionSubType.mint) { + if (isCancelled) { + return Assets.svg.anonymizeFailed; + } + if (isPending) { + return Assets.svg.anonymizePending; + } + return Assets.svg.anonymize; + } + + if (isReceived) { + if (isCancelled) { + return Assets.svg.receiveCancelled(context); + } + if (isPending) { + return Assets.svg.receivePending(context); + } + return Assets.svg.receive(context); + } else { + if (isCancelled) { + return Assets.svg.sendCancelled(context); + } + if (isPending) { + return Assets.svg.sendPending(context); + } + return Assets.svg.send(context); + } + } + + @override + Widget build(BuildContext context) { + final txIsReceived = + transaction.type == isar_models.TransactionType.incoming; + + return SizedBox( + width: size.width, + height: size.height, + child: Center( + child: SvgPicture.asset( + _getAssetName( + transaction.cancelled, + txIsReceived, + !transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ), + context, + ), + width: size.width, + height: size.height, + ), + ), + ); + } +} diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index 4389573c3..29139a5a7 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -2,7 +2,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; +import 'package:stackwallet/models/paymint/transactions_model.dart' as old; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; @@ -16,6 +17,8 @@ import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:tuple/tuple.dart'; +import '../providers/blockchain/dogecoin/current_height_provider.dart'; + class TransactionCard extends ConsumerStatefulWidget { const TransactionCard({ Key? key, @@ -23,7 +26,7 @@ class TransactionCard extends ConsumerStatefulWidget { required this.walletId, }) : super(key: key); - final Transaction transaction; + final old.Transaction transaction; final String walletId; @override @@ -31,7 +34,7 @@ class TransactionCard extends ConsumerStatefulWidget { } class _TransactionCardState extends ConsumerState { - late final Transaction _transaction; + late final old.Transaction _transaction; late final String walletId; String whatIsIt(String type, Coin coin) { @@ -266,3 +269,274 @@ class _TransactionCardState extends ConsumerState { ); } } + +class TransactionCard2 extends ConsumerStatefulWidget { + const TransactionCard2({ + Key? key, + required this.transaction, + required this.walletId, + }) : super(key: key); + + final isar_models.Transaction transaction; + final String walletId; + + @override + ConsumerState createState() => _TransactionCardState2(); +} + +class _TransactionCardState2 extends ConsumerState { + late final isar_models.Transaction _transaction; + late final String walletId; + + String whatIsIt( + isar_models.TransactionType type, + Coin coin, + int currentHeight, + ) { + if (coin == Coin.epicCash && _transaction.slateId == null) { + return "Restored Funds"; + } + + final confirmedStatus = _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ); + + if (_transaction.subType == isar_models.TransactionSubType.mint) { + // if (type == "Received") { + if (confirmedStatus) { + return "Anonymized"; + } else { + return "Anonymizing"; + } + // } else if (type == "Sent") { + // if (_transaction.confirmedStatus) { + // return "Sent MINT"; + // } else { + // return "Sending MINT"; + // } + // } else { + // return type; + // } + } + + if (type == isar_models.TransactionType.incoming) { + // if (_transaction.isMinting) { + // return "Minting"; + // } else + if (confirmedStatus) { + return "Received"; + } else { + return "Receiving"; + } + } else if (type == isar_models.TransactionType.outgoing) { + if (confirmedStatus) { + return "Sent"; + } else { + return "Sending"; + } + } else { + return type.name; + } + } + + @override + void initState() { + walletId = widget.walletId; + _transaction = widget.transaction; + super.initState(); + } + + @override + Widget build(BuildContext context) { + final locale = ref.watch( + localeServiceChangeNotifierProvider.select((value) => value.locale)); + final manager = ref.watch(walletsChangeNotifierProvider + .select((value) => value.getManager(walletId))); + + final baseCurrency = ref + .watch(prefsChangeNotifierProvider.select((value) => value.currency)); + + final coin = manager.coin; + + final price = ref + .watch(priceAnd24hChangeNotifierProvider + .select((value) => value.getPrice(coin))) + .item1; + + String prefix = ""; + if (Util.isDesktop) { + if (_transaction.type == isar_models.TransactionType.outgoing) { + prefix = "-"; + } else if (_transaction.type == isar_models.TransactionType.incoming) { + prefix = "+"; + } + } + + final currentHeight = ref.watch(currentHeightProvider(coin).state).state; + + return Material( + color: Theme.of(context).extension()!.popupBG, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(Constants.size.circularBorderRadius), + ), + child: Padding( + padding: const EdgeInsets.all(6), + child: RawMaterialButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + onPressed: () async { + if (coin == Coin.epicCash && _transaction.slateId == null) { + unawaited(showFloatingFlushBar( + context: context, + message: + "Restored Epic funds from your Seed have no Data.\nUse Stack Backup to keep your transaction history.", + type: FlushBarType.warning, + duration: const Duration(seconds: 5), + )); + return; + } + if (Util.isDesktop) { + // await showDialog( + // context: context, + // builder: (context) => DesktopDialog( + // maxHeight: MediaQuery.of(context).size.height - 64, + // maxWidth: 580, + // child: TransactionDetailsView( + // transaction: _transaction, + // coin: coin, + // walletId: walletId, + // ), + // ), + // ); + } else { + unawaited( + Navigator.of(context).pushNamed( + TransactionDetailsView.routeName, + arguments: Tuple3( + _transaction, + coin, + walletId, + ), + ), + ); + } + }, + child: Padding( + padding: const EdgeInsets.all(8), + child: Row( + children: [ + TxIcon2( + transaction: _transaction, + coin: ref.watch(walletsChangeNotifierProvider.select( + (value) => value.getManager(widget.walletId).coin)), + currentHeight: currentHeight, + ), + const SizedBox( + width: 14, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + _transaction.cancelled + ? "Cancelled" + : whatIsIt( + _transaction.type, + coin, + currentHeight, + ), + style: STextStyles.itemSubtitle12(context), + ), + ), + ), + const SizedBox( + width: 10, + ), + Flexible( + child: FittedBox( + fit: BoxFit.scaleDown, + child: Builder( + builder: (_) { + final amount = _transaction.amount; + return Text( + "$prefix${Format.satoshiAmountToPrettyString(amount, locale, coin)} ${coin.ticker}", + style: + STextStyles.itemSubtitle12_600(context), + ); + }, + ), + ), + ), + ], + ), + const SizedBox( + height: 4, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Flexible( + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + Format.extractDateFrom(_transaction.timestamp), + style: STextStyles.label(context), + ), + ), + ), + if (ref.watch(prefsChangeNotifierProvider + .select((value) => value.externalCalls))) + const SizedBox( + width: 10, + ), + if (ref.watch(prefsChangeNotifierProvider + .select((value) => value.externalCalls))) + Flexible( + child: FittedBox( + fit: BoxFit.scaleDown, + child: Builder( + builder: (_) { + int value = _transaction.amount; + + return Text( + "$prefix${Format.localizedStringAsFixed( + value: Format.satoshisToAmount(value, + coin: coin) * + price, + locale: locale, + decimalPlaces: 2, + )} $baseCurrency", + style: STextStyles.label(context), + ); + }, + ), + ), + ), + ], + ), + ], + ), + ), + ], + ), + ), + ), + ), + ); + } +} From d27af7243c08d51f48795621a4e3952c04cade75 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:55:19 -0600 Subject: [PATCH 085/192] modify experimental parseTransaction function to return the new Isar Transaction model --- lib/services/coins/coin_paynym_extension.dart | 135 +++++++++++------- 1 file changed, 86 insertions(+), 49 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index b64c7dbfa..50675698c 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -3,12 +3,14 @@ import 'dart:typed_data'; import 'package:bip47/bip47.dart'; import 'package:bip47/src/util.dart'; -import 'package:bitcoindart/bitcoindart.dart'; +import 'package:bitcoindart/bitcoindart.dart' as btc_dart; import 'package:bitcoindart/src/utils/constants/op.dart' as op; import 'package:bitcoindart/src/utils/script.dart' as bscript; +import 'package:dart_numerics/dart_numerics.dart'; import 'package:decimal/decimal.dart'; import 'package:pointycastle/digests/sha256.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/models.dart' as models; import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; @@ -59,7 +61,8 @@ extension PayNym on DogecoinWallet { Future signWithNotificationKey(Uint8List data) async { final node = getBip32Root((await mnemonic).join(" "), network) .derivePath("m/47'/0'/0'"); - final pair = ECPair.fromPrivateKey(node.privateKey!, network: network); + final pair = + btc_dart.ECPair.fromPrivateKey(node.privateKey!, network: network); final signed = pair.sign(SHA256Digest().process(data)); return signed; } @@ -420,7 +423,7 @@ extension PayNym on DogecoinWallet { final buffer = rev.buffer.asByteData(); buffer.setUint32(txPoint.length, txPointIndex, Endian.little); - final myKeyPair = utxoSigningData[utxo.txid]["keyPair"] as ECPair; + final myKeyPair = utxoSigningData[utxo.txid]["keyPair"] as btc_dart.ECPair; final S = SecretPoint( myKeyPair.privateKey!, @@ -440,7 +443,7 @@ extension PayNym on DogecoinWallet { ]); // build a notification tx - final txb = TransactionBuilder(network: network); + final txb = btc_dart.TransactionBuilder(network: network); txb.setVersion(1); txb.addInput( @@ -454,7 +457,7 @@ extension PayNym on DogecoinWallet { // TODO: add possible change output and mark output as dangerous if (change > 0) { // generate new change address if current change address has been used - await checkChangeAddressForTransactions(DerivePathType.bip44); + await checkChangeAddressForTransactions(); final String changeAddress = await getCurrentAddressForChain(1, DerivePathType.bip44); txb.addOutput(changeAddress, change); @@ -470,7 +473,7 @@ extension PayNym on DogecoinWallet { final txid = utxosToUse[i].txid; txb.sign( vin: i, - keyPair: utxoSigningData[txid]["keyPair"] as ECPair, + keyPair: utxoSigningData[txid]["keyPair"] as btc_dart.ECPair, // witnessValue: utxosToUse[i].value, ); } @@ -563,15 +566,22 @@ extension PayNym on DogecoinWallet { } } -Future> parseTransaction( +Future parseTransaction( Map txData, dynamic electrumxClient, - Set myAddresses, - Set myChangeAddresses, + List

myAddresses, Coin coin, int minConfirms, - Decimal currentPrice, ) async { + Set receivingAddresses = myAddresses + .where((e) => e.subType == AddressSubType.receiving) + .map((e) => e.value) + .toSet(); + Set changeAddresses = myAddresses + .where((e) => e.subType == AddressSubType.change) + .map((e) => e.value) + .toSet(); + Set inputAddresses = {}; Set outputAddresses = {}; @@ -580,6 +590,7 @@ Future> parseTransaction( int amountSentFromWallet = 0; int amountReceivedInWallet = 0; + int changeAmount = 0; // parse inputs for (final input in txData["vin"] as List) { @@ -612,7 +623,8 @@ Future> parseTransaction( inputAddresses.add(address); // if input was from my wallet, add value to amount sent - if (myAddresses.contains(address)) { + if (receivingAddresses.contains(address) || + changeAddresses.contains(address)) { amountSentFromWallet += value; } } @@ -637,61 +649,86 @@ Future> parseTransaction( if (address != null) { outputAddresses.add(address); - // if output was from my wallet, add value to amount received - if (myAddresses.contains(address)) { + // if output was to my wallet, add value to amount received + if (receivingAddresses.contains(address)) { amountReceivedInWallet += value; + } else if (changeAddresses.contains(address)) { + changeAmount += value; } } } - final mySentFromAddresses = myAddresses.intersection(inputAddresses); - final myReceivedOnAddresses = myAddresses.intersection(outputAddresses); + final mySentFromAddresses = [ + ...receivingAddresses.intersection(inputAddresses), + ...changeAddresses.intersection(inputAddresses) + ]; + final myReceivedOnAddresses = + receivingAddresses.intersection(outputAddresses); + final myChangeReceivedOnAddresses = + changeAddresses.intersection(outputAddresses); final fee = totalInputValue - totalOutputValue; - // create normalized tx data map - Map normalizedTx = {}; - - final int confirms = txData["confirmations"] as int? ?? 0; - - normalizedTx["txid"] = txData["txid"] as String; - normalizedTx["confirmed_status"] = confirms >= minConfirms; - normalizedTx["confirmations"] = confirms; - normalizedTx["timestamp"] = txData["blocktime"] as int? ?? + final tx = Transaction(); + tx.txid = txData["txid"] as String; + tx.timestamp = txData["blocktime"] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); - normalizedTx["aliens"] = []; - normalizedTx["fees"] = fee; - normalizedTx["address"] = txData["address"] as String; - normalizedTx["inputSize"] = txData["vin"].length; - normalizedTx["outputSize"] = txData["vout"].length; - normalizedTx["inputs"] = txData["vin"]; - normalizedTx["outputs"] = txData["vout"]; - normalizedTx["height"] = txData["height"] as int; - int amount; - String type; if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self - type = "Sent to self"; - amount = amountSentFromWallet - amountReceivedInWallet - fee; + tx.type = TransactionType.sendToSelf; + tx.amount = + amountSentFromWallet - amountReceivedInWallet - fee - changeAmount; } else if (mySentFromAddresses.isNotEmpty) { // outgoing tx - type = "Sent"; - amount = amountSentFromWallet; + tx.type = TransactionType.outgoing; + tx.amount = amountSentFromWallet - changeAmount - fee; } else { // incoming tx - type = "Received"; - amount = amountReceivedInWallet; + tx.type = TransactionType.incoming; + tx.amount = amountReceivedInWallet; } - normalizedTx["txType"] = type; - normalizedTx["amount"] = amount; - normalizedTx["worthNow"] = (Format.satoshisToAmount( - amount, - coin: coin, - ) * - currentPrice) - .toStringAsFixed(2); + // TODO: other subtypes + tx.subType = TransactionSubType.none; - return normalizedTx; + tx.fee = fee; + tx.address = txData["address"] as String; + + for (final json in txData["vin"] as List) { + bool isCoinBase = json['coinbase'] != null; + final input = Input(); + input.txid = json['txid'] as String; + input.vout = json['vout'] as int? ?? -1; + input.scriptSig = json['scriptSig']?['hex'] as String?; + input.scriptSigAsm = json['scriptSig']?['asm'] as String?; + input.isCoinbase = isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; + input.sequence = json['sequence'] as int?; + input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; + tx.inputs.add(input); + } + + for (final json in txData["vout"] as List) { + final output = Output(); + output.scriptPubKey = json['scriptPubKey']?['hex'] as String?; + output.scriptPubKeyAsm = json['scriptPubKey']?['asm'] as String?; + output.scriptPubKeyType = json['scriptPubKey']?['type'] as String?; + output.scriptPubKeyAddress = + json["scriptPubKey"]?["addresses"]?[0] as String? ?? + json['scriptPubKey']['type'] as String; + output.value = Format.decimalAmountToSatoshis( + Decimal.parse(json["value"].toString()), + coin, + ); + tx.outputs.add(output); + } + + tx.height = txData["height"] as int? ?? int64MaxValue; + + //TODO: change these for epic (or other coins that need it) + tx.cancelled = false; + tx.slateId = null; + tx.otherData = null; + + return tx; } From b0c62015a17f7cea21c83b8ec54678c5d1e5c2c2 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 17:57:00 -0600 Subject: [PATCH 086/192] update enum value name --- lib/models/isar/models/blockchain_data/transaction.dart | 2 +- lib/models/isar/models/blockchain_data/transaction.g.dart | 2 +- lib/services/coins/coin_paynym_extension.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 7733cfe66..f19bc2224 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -64,7 +64,7 @@ enum TransactionType { // TODO: add more types before prod release? outgoing, incoming, - sendToSelf, // should we keep this? + sentToSelf, // should we keep this? unknown, anonymize; // firo specific diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 242c818b9..c59c19b06 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -260,7 +260,7 @@ const _TransactiontypeEnumValueMap = { const _TransactiontypeValueEnumMap = { 0: TransactionType.outgoing, 1: TransactionType.incoming, - 2: TransactionType.sendToSelf, + 2: TransactionType.sentToSelf, 3: TransactionType.unknown, 4: TransactionType.anonymize, }; diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 50675698c..7214d7111 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -676,7 +676,7 @@ Future parseTransaction( if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self - tx.type = TransactionType.sendToSelf; + tx.type = TransactionType.sentToSelf; tx.amount = amountSentFromWallet - amountReceivedInWallet - fee - changeAmount; } else if (mySentFromAddresses.isNotEmpty) { From f1131e3d61e0a23b3b7d37cd8d3d3745d52dceb9 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 10 Jan 2023 18:13:37 -0600 Subject: [PATCH 087/192] missing updated address generated file --- lib/models/isar/models/address/address.g.dart | 225 +++++++++++++++++- 1 file changed, 224 insertions(+), 1 deletion(-) diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 6ccd5d95d..349c7a852 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -50,7 +50,34 @@ const AddressSchema = CollectionSchema( deserialize: _addressDeserialize, deserializeProp: _addressDeserializeProp, idName: r'id', - indexes: {}, + indexes: { + r'value': IndexSchema( + id: -8658876004265234192, + name: r'value', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'value', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'derivationIndex': IndexSchema( + id: -6950711977521998012, + name: r'derivationIndex', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'derivationIndex', + type: IndexType.value, + caseSensitive: false, + ) + ], + ) + }, links: {}, embeddedSchemas: {}, getId: _addressGetId, @@ -163,12 +190,74 @@ void _addressAttach(IsarCollection col, Id id, Address object) { object.id = id; } +extension AddressByIndex on IsarCollection
{ + Future getByValue(String value) { + return getByIndex(r'value', [value]); + } + + Address? getByValueSync(String value) { + return getByIndexSync(r'value', [value]); + } + + Future deleteByValue(String value) { + return deleteByIndex(r'value', [value]); + } + + bool deleteByValueSync(String value) { + return deleteByIndexSync(r'value', [value]); + } + + Future> getAllByValue(List valueValues) { + final values = valueValues.map((e) => [e]).toList(); + return getAllByIndex(r'value', values); + } + + List getAllByValueSync(List valueValues) { + final values = valueValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'value', values); + } + + Future deleteAllByValue(List valueValues) { + final values = valueValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'value', values); + } + + int deleteAllByValueSync(List valueValues) { + final values = valueValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'value', values); + } + + Future putByValue(Address object) { + return putByIndex(r'value', object); + } + + Id putByValueSync(Address object, {bool saveLinks = true}) { + return putByIndexSync(r'value', object, saveLinks: saveLinks); + } + + Future> putAllByValue(List
objects) { + return putAllByIndex(r'value', objects); + } + + List putAllByValueSync(List
objects, {bool saveLinks = true}) { + return putAllByIndexSync(r'value', objects, saveLinks: saveLinks); + } +} + extension AddressQueryWhereSort on QueryBuilder { QueryBuilder anyId() { return QueryBuilder.apply(this, (query) { return query.addWhereClause(const IdWhereClause.any()); }); } + + QueryBuilder anyDerivationIndex() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'derivationIndex'), + ); + }); + } } extension AddressQueryWhere on QueryBuilder { @@ -236,6 +325,140 @@ extension AddressQueryWhere on QueryBuilder { )); }); } + + QueryBuilder valueEqualTo(String value) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'value', + value: [value], + )); + }); + } + + QueryBuilder valueNotEqualTo( + String value) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'value', + lower: [], + upper: [value], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'value', + lower: [value], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'value', + lower: [value], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'value', + lower: [], + upper: [value], + includeUpper: false, + )); + } + }); + } + + QueryBuilder derivationIndexEqualTo( + int derivationIndex) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'derivationIndex', + value: [derivationIndex], + )); + }); + } + + QueryBuilder derivationIndexNotEqualTo( + int derivationIndex) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'derivationIndex', + lower: [], + upper: [derivationIndex], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'derivationIndex', + lower: [derivationIndex], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'derivationIndex', + lower: [derivationIndex], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'derivationIndex', + lower: [], + upper: [derivationIndex], + includeUpper: false, + )); + } + }); + } + + QueryBuilder derivationIndexGreaterThan( + int derivationIndex, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'derivationIndex', + lower: [derivationIndex], + includeLower: include, + upper: [], + )); + }); + } + + QueryBuilder derivationIndexLessThan( + int derivationIndex, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'derivationIndex', + lower: [], + upper: [derivationIndex], + includeUpper: include, + )); + }); + } + + QueryBuilder derivationIndexBetween( + int lowerDerivationIndex, + int upperDerivationIndex, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.between( + indexName: r'derivationIndex', + lower: [lowerDerivationIndex], + includeLower: includeLower, + upper: [upperDerivationIndex], + includeUpper: includeUpper, + )); + }); + } } extension AddressQueryFilter From 822bb219b61256d279a03a4a3b9bd8ffb5768f33 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 08:24:30 -0600 Subject: [PATCH 088/192] migrate prep comment --- lib/utilities/db_version_migration.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index 1320fab25..57c53f385 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -169,6 +169,17 @@ class DbVersionMigrator { // try to continue migrating return await migrate(4, secureStore: secureStore); + // case 4: + // // TODO: once isar migration is ready + // // 1. Address arrays + // + // // update version + // await DB.instance.put( + // boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 5); + // + // // try to continue migrating + // return await migrate(5, secureStore: secureStore); + default: // finally return return; From 5937d92aee5a5da47c241ca9ff33fe188b9ee82e Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 12:16:52 -0600 Subject: [PATCH 089/192] update isar models --- lib/models/isar/models/address/address.dart | 2 +- lib/models/isar/models/address/address.g.dart | 2 +- .../models/blockchain_data/transaction.g.dart | 2 +- .../isar/models/blockchain_data/utxo.dart | 22 +- .../isar/models/blockchain_data/utxo.g.dart | 1128 ++++++++++------- 5 files changed, 695 insertions(+), 461 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 054e620b3..367a3fab4 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -8,7 +8,7 @@ class AddressException extends SWException { AddressException(super.message); } -@collection +@Collection(accessor: "addresses") class Address extends CryptoCurrencyAddress { Id id = Isar.autoIncrement; diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 349c7a852..44d5c1d71 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -10,7 +10,7 @@ part of 'address.dart'; // ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters extension GetAddressCollection on Isar { - IsarCollection
get address => this.collection(); + IsarCollection
get addresses => this.collection(); } const AddressSchema = CollectionSchema( diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index c59c19b06..9a6849146 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -253,7 +253,7 @@ const _TransactionsubTypeValueEnumMap = { const _TransactiontypeEnumValueMap = { 'outgoing': 0, 'incoming': 1, - 'sendToSelf': 2, + 'sentToSelf': 2, 'unknown': 3, 'anonymize': 4, }; diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index 47701f4db..eda4c06ff 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -4,37 +4,35 @@ import 'package:isar/isar.dart'; part 'utxo.g.dart'; -@Collection() +@Collection(accessor: "utxos") class UTXO { Id id = Isar.autoIncrement; + @Index(unique: true, replace: true) late String txid; late int vout; - late Status status; - late int value; - late String txName; + late String name; - late bool blocked; + @Index() + late bool isBlocked; late String? blockedReason; late bool isCoinbase; -} -@Embedded() -class Status { - late String blockHash; + late String? blockHash; - late int blockHeight; + late int? blockHeight; - late int blockTime; + late int? blockTime; int getConfirmations(int currentChainHeight) { - return max(0, currentChainHeight - blockHeight); + if (blockHeight == null) return 0; + return max(0, currentChainHeight - blockHeight!); } bool isConfirmed(int currentChainHeight, int minimumConfirms) { diff --git a/lib/models/isar/models/blockchain_data/utxo.g.dart b/lib/models/isar/models/blockchain_data/utxo.g.dart index b86822039..9c0772968 100644 --- a/lib/models/isar/models/blockchain_data/utxo.g.dart +++ b/lib/models/isar/models/blockchain_data/utxo.g.dart @@ -10,51 +10,60 @@ part of 'utxo.dart'; // ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters extension GetUTXOCollection on Isar { - IsarCollection get uTXOs => this.collection(); + IsarCollection get utxos => this.collection(); } const UTXOSchema = CollectionSchema( name: r'UTXO', id: 5934032492047519621, properties: { - r'blocked': PropertySchema( + r'blockHash': PropertySchema( id: 0, - name: r'blocked', - type: IsarType.bool, + name: r'blockHash', + type: IsarType.string, + ), + r'blockHeight': PropertySchema( + id: 1, + name: r'blockHeight', + type: IsarType.long, + ), + r'blockTime': PropertySchema( + id: 2, + name: r'blockTime', + type: IsarType.long, ), r'blockedReason': PropertySchema( - id: 1, + id: 3, name: r'blockedReason', type: IsarType.string, ), + r'isBlocked': PropertySchema( + id: 4, + name: r'isBlocked', + type: IsarType.bool, + ), r'isCoinbase': PropertySchema( - id: 2, + id: 5, name: r'isCoinbase', type: IsarType.bool, ), - r'status': PropertySchema( - id: 3, - name: r'status', - type: IsarType.object, - target: r'Status', - ), - r'txName': PropertySchema( - id: 4, - name: r'txName', + r'name': PropertySchema( + id: 6, + name: r'name', type: IsarType.string, ), r'txid': PropertySchema( - id: 5, + id: 7, name: r'txid', type: IsarType.string, ), r'value': PropertySchema( - id: 6, + id: 8, name: r'value', type: IsarType.long, ), r'vout': PropertySchema( - id: 7, + id: 9, name: r'vout', type: IsarType.long, ) @@ -64,9 +73,36 @@ const UTXOSchema = CollectionSchema( deserialize: _uTXODeserialize, deserializeProp: _uTXODeserializeProp, idName: r'id', - indexes: {}, + indexes: { + r'txid': IndexSchema( + id: 7339874292043634331, + name: r'txid', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'txid', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'isBlocked': IndexSchema( + id: 4270553749242334751, + name: r'isBlocked', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'isBlocked', + type: IndexType.value, + caseSensitive: false, + ) + ], + ) + }, links: {}, - embeddedSchemas: {r'Status': StatusSchema}, + embeddedSchemas: {}, getId: _uTXOGetId, getLinks: _uTXOGetLinks, attach: _uTXOAttach, @@ -79,15 +115,19 @@ int _uTXOEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; + { + final value = object.blockHash; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } { final value = object.blockedReason; if (value != null) { bytesCount += 3 + value.length * 3; } } - bytesCount += 3 + - StatusSchema.estimateSize(object.status, allOffsets[Status]!, allOffsets); - bytesCount += 3 + object.txName.length * 3; + bytesCount += 3 + object.name.length * 3; bytesCount += 3 + object.txid.length * 3; return bytesCount; } @@ -98,19 +138,16 @@ void _uTXOSerialize( List offsets, Map> allOffsets, ) { - writer.writeBool(offsets[0], object.blocked); - writer.writeString(offsets[1], object.blockedReason); - writer.writeBool(offsets[2], object.isCoinbase); - writer.writeObject( - offsets[3], - allOffsets, - StatusSchema.serialize, - object.status, - ); - writer.writeString(offsets[4], object.txName); - writer.writeString(offsets[5], object.txid); - writer.writeLong(offsets[6], object.value); - writer.writeLong(offsets[7], object.vout); + writer.writeString(offsets[0], object.blockHash); + writer.writeLong(offsets[1], object.blockHeight); + writer.writeLong(offsets[2], object.blockTime); + writer.writeString(offsets[3], object.blockedReason); + writer.writeBool(offsets[4], object.isBlocked); + writer.writeBool(offsets[5], object.isCoinbase); + writer.writeString(offsets[6], object.name); + writer.writeString(offsets[7], object.txid); + writer.writeLong(offsets[8], object.value); + writer.writeLong(offsets[9], object.vout); } UTXO _uTXODeserialize( @@ -120,20 +157,17 @@ UTXO _uTXODeserialize( Map> allOffsets, ) { final object = UTXO(); - object.blocked = reader.readBool(offsets[0]); - object.blockedReason = reader.readStringOrNull(offsets[1]); + object.blockHash = reader.readStringOrNull(offsets[0]); + object.blockHeight = reader.readLongOrNull(offsets[1]); + object.blockTime = reader.readLongOrNull(offsets[2]); + object.blockedReason = reader.readStringOrNull(offsets[3]); object.id = id; - object.isCoinbase = reader.readBool(offsets[2]); - object.status = reader.readObjectOrNull( - offsets[3], - StatusSchema.deserialize, - allOffsets, - ) ?? - Status(); - object.txName = reader.readString(offsets[4]); - object.txid = reader.readString(offsets[5]); - object.value = reader.readLong(offsets[6]); - object.vout = reader.readLong(offsets[7]); + object.isBlocked = reader.readBool(offsets[4]); + object.isCoinbase = reader.readBool(offsets[5]); + object.name = reader.readString(offsets[6]); + object.txid = reader.readString(offsets[7]); + object.value = reader.readLong(offsets[8]); + object.vout = reader.readLong(offsets[9]); return object; } @@ -145,25 +179,24 @@ P _uTXODeserializeProp

( ) { switch (propertyId) { case 0: - return (reader.readBool(offset)) as P; - case 1: return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readLongOrNull(offset)) as P; case 2: - return (reader.readBool(offset)) as P; + return (reader.readLongOrNull(offset)) as P; case 3: - return (reader.readObjectOrNull( - offset, - StatusSchema.deserialize, - allOffsets, - ) ?? - Status()) as P; + return (reader.readStringOrNull(offset)) as P; case 4: - return (reader.readString(offset)) as P; + return (reader.readBool(offset)) as P; case 5: - return (reader.readString(offset)) as P; + return (reader.readBool(offset)) as P; case 6: - return (reader.readLong(offset)) as P; + return (reader.readString(offset)) as P; case 7: + return (reader.readString(offset)) as P; + case 8: + return (reader.readLong(offset)) as P; + case 9: return (reader.readLong(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); @@ -182,12 +215,74 @@ void _uTXOAttach(IsarCollection col, Id id, UTXO object) { object.id = id; } +extension UTXOByIndex on IsarCollection { + Future getByTxid(String txid) { + return getByIndex(r'txid', [txid]); + } + + UTXO? getByTxidSync(String txid) { + return getByIndexSync(r'txid', [txid]); + } + + Future deleteByTxid(String txid) { + return deleteByIndex(r'txid', [txid]); + } + + bool deleteByTxidSync(String txid) { + return deleteByIndexSync(r'txid', [txid]); + } + + Future> getAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndex(r'txid', values); + } + + List getAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'txid', values); + } + + Future deleteAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'txid', values); + } + + int deleteAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'txid', values); + } + + Future putByTxid(UTXO object) { + return putByIndex(r'txid', object); + } + + Id putByTxidSync(UTXO object, {bool saveLinks = true}) { + return putByIndexSync(r'txid', object, saveLinks: saveLinks); + } + + Future> putAllByTxid(List objects) { + return putAllByIndex(r'txid', objects); + } + + List putAllByTxidSync(List objects, {bool saveLinks = true}) { + return putAllByIndexSync(r'txid', objects, saveLinks: saveLinks); + } +} + extension UTXOQueryWhereSort on QueryBuilder { QueryBuilder anyId() { return QueryBuilder.apply(this, (query) { return query.addWhereClause(const IdWhereClause.any()); }); } + + QueryBuilder anyIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'isBlocked'), + ); + }); + } } extension UTXOQueryWhere on QueryBuilder { @@ -255,14 +350,375 @@ extension UTXOQueryWhere on QueryBuilder { )); }); } + + QueryBuilder txidEqualTo(String txid) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid', + value: [txid], + )); + }); + } + + QueryBuilder txidNotEqualTo(String txid) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )); + } + }); + } + + QueryBuilder isBlockedEqualTo(bool isBlocked) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'isBlocked', + value: [isBlocked], + )); + }); + } + + QueryBuilder isBlockedNotEqualTo( + bool isBlocked) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [], + upper: [isBlocked], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [isBlocked], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [isBlocked], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [], + upper: [isBlocked], + includeUpper: false, + )); + } + }); + } } extension UTXOQueryFilter on QueryBuilder { - QueryBuilder blockedEqualTo(bool value) { + QueryBuilder blockHashIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'blockHash', + )); + }); + } + + QueryBuilder blockHashIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'blockHash', + )); + }); + } + + QueryBuilder blockHashEqualTo( + String? value, { + bool caseSensitive = true, + }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'blocked', + property: r'blockHash', value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockHash', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'blockHash', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockHash', + value: '', + )); + }); + } + + QueryBuilder blockHashIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'blockHash', + value: '', + )); + }); + } + + QueryBuilder blockHeightIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'blockHeight', + )); + }); + } + + QueryBuilder blockHeightIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'blockHeight', + )); + }); + } + + QueryBuilder blockHeightEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockHeight', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder blockTimeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'blockTime', + )); + }); + } + + QueryBuilder blockTimeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'blockTime', + )); + }); + } + + QueryBuilder blockTimeEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockTime', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, )); }); } @@ -465,6 +921,15 @@ extension UTXOQueryFilter on QueryBuilder { }); } + QueryBuilder isBlockedEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isBlocked', + value: value, + )); + }); + } + QueryBuilder isCoinbaseEqualTo( bool value) { return QueryBuilder.apply(this, (query) { @@ -475,20 +940,20 @@ extension UTXOQueryFilter on QueryBuilder { }); } - QueryBuilder txNameEqualTo( + QueryBuilder nameEqualTo( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameGreaterThan( + QueryBuilder nameGreaterThan( String value, { bool include = false, bool caseSensitive = true, @@ -496,14 +961,14 @@ extension UTXOQueryFilter on QueryBuilder { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameLessThan( + QueryBuilder nameLessThan( String value, { bool include = false, bool caseSensitive = true, @@ -511,14 +976,14 @@ extension UTXOQueryFilter on QueryBuilder { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameBetween( + QueryBuilder nameBetween( String lower, String upper, { bool includeLower = true, @@ -527,7 +992,7 @@ extension UTXOQueryFilter on QueryBuilder { }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( - property: r'txName', + property: r'name', lower: lower, includeLower: includeLower, upper: upper, @@ -537,67 +1002,67 @@ extension UTXOQueryFilter on QueryBuilder { }); } - QueryBuilder txNameStartsWith( + QueryBuilder nameStartsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.startsWith( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameEndsWith( + QueryBuilder nameEndsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.endsWith( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameContains(String value, + QueryBuilder nameContains(String value, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.contains( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameMatches(String pattern, + QueryBuilder nameMatches(String pattern, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.matches( - property: r'txName', + property: r'name', wildcard: pattern, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameIsEmpty() { + QueryBuilder nameIsEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'txName', + property: r'name', value: '', )); }); } - QueryBuilder txNameIsNotEmpty() { + QueryBuilder nameIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( - property: r'txName', + property: r'name', value: '', )); }); @@ -836,27 +1301,44 @@ extension UTXOQueryFilter on QueryBuilder { } } -extension UTXOQueryObject on QueryBuilder { - QueryBuilder status( - FilterQuery q) { - return QueryBuilder.apply(this, (query) { - return query.object(q, r'status'); - }); - } -} +extension UTXOQueryObject on QueryBuilder {} extension UTXOQueryLinks on QueryBuilder {} extension UTXOQuerySortBy on QueryBuilder { - QueryBuilder sortByBlocked() { + QueryBuilder sortByBlockHash() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.asc); + return query.addSortBy(r'blockHash', Sort.asc); }); } - QueryBuilder sortByBlockedDesc() { + QueryBuilder sortByBlockHashDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.desc); + return query.addSortBy(r'blockHash', Sort.desc); + }); + } + + QueryBuilder sortByBlockHeight() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.asc); + }); + } + + QueryBuilder sortByBlockHeightDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.desc); + }); + } + + QueryBuilder sortByBlockTime() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.asc); + }); + } + + QueryBuilder sortByBlockTimeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.desc); }); } @@ -872,6 +1354,18 @@ extension UTXOQuerySortBy on QueryBuilder { }); } + QueryBuilder sortByIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.asc); + }); + } + + QueryBuilder sortByIsBlockedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.desc); + }); + } + QueryBuilder sortByIsCoinbase() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'isCoinbase', Sort.asc); @@ -884,15 +1378,15 @@ extension UTXOQuerySortBy on QueryBuilder { }); } - QueryBuilder sortByTxName() { + QueryBuilder sortByName() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.asc); + return query.addSortBy(r'name', Sort.asc); }); } - QueryBuilder sortByTxNameDesc() { + QueryBuilder sortByNameDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.desc); + return query.addSortBy(r'name', Sort.desc); }); } @@ -934,15 +1428,39 @@ extension UTXOQuerySortBy on QueryBuilder { } extension UTXOQuerySortThenBy on QueryBuilder { - QueryBuilder thenByBlocked() { + QueryBuilder thenByBlockHash() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.asc); + return query.addSortBy(r'blockHash', Sort.asc); }); } - QueryBuilder thenByBlockedDesc() { + QueryBuilder thenByBlockHashDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.desc); + return query.addSortBy(r'blockHash', Sort.desc); + }); + } + + QueryBuilder thenByBlockHeight() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.asc); + }); + } + + QueryBuilder thenByBlockHeightDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.desc); + }); + } + + QueryBuilder thenByBlockTime() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.asc); + }); + } + + QueryBuilder thenByBlockTimeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.desc); }); } @@ -970,6 +1488,18 @@ extension UTXOQuerySortThenBy on QueryBuilder { }); } + QueryBuilder thenByIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.asc); + }); + } + + QueryBuilder thenByIsBlockedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.desc); + }); + } + QueryBuilder thenByIsCoinbase() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'isCoinbase', Sort.asc); @@ -982,15 +1512,15 @@ extension UTXOQuerySortThenBy on QueryBuilder { }); } - QueryBuilder thenByTxName() { + QueryBuilder thenByName() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.asc); + return query.addSortBy(r'name', Sort.asc); }); } - QueryBuilder thenByTxNameDesc() { + QueryBuilder thenByNameDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.desc); + return query.addSortBy(r'name', Sort.desc); }); } @@ -1032,9 +1562,22 @@ extension UTXOQuerySortThenBy on QueryBuilder { } extension UTXOQueryWhereDistinct on QueryBuilder { - QueryBuilder distinctByBlocked() { + QueryBuilder distinctByBlockHash( + {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'blocked'); + return query.addDistinctBy(r'blockHash', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByBlockHeight() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'blockHeight'); + }); + } + + QueryBuilder distinctByBlockTime() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'blockTime'); }); } @@ -1046,16 +1589,22 @@ extension UTXOQueryWhereDistinct on QueryBuilder { }); } + QueryBuilder distinctByIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isBlocked'); + }); + } + QueryBuilder distinctByIsCoinbase() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'isCoinbase'); }); } - QueryBuilder distinctByTxName( + QueryBuilder distinctByName( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'txName', caseSensitive: caseSensitive); + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); }); } @@ -1086,9 +1635,21 @@ extension UTXOQueryProperty on QueryBuilder { }); } - QueryBuilder blockedProperty() { + QueryBuilder blockHashProperty() { return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'blocked'); + return query.addPropertyName(r'blockHash'); + }); + } + + QueryBuilder blockHeightProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'blockHeight'); + }); + } + + QueryBuilder blockTimeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'blockTime'); }); } @@ -1098,21 +1659,21 @@ extension UTXOQueryProperty on QueryBuilder { }); } + QueryBuilder isBlockedProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isBlocked'); + }); + } + QueryBuilder isCoinbaseProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'isCoinbase'); }); } - QueryBuilder statusProperty() { + QueryBuilder nameProperty() { return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'status'); - }); - } - - QueryBuilder txNameProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'txName'); + return query.addPropertyName(r'name'); }); } @@ -1134,328 +1695,3 @@ extension UTXOQueryProperty on QueryBuilder { }); } } - -// ************************************************************************** -// IsarEmbeddedGenerator -// ************************************************************************** - -// coverage:ignore-file -// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters - -const StatusSchema = Schema( - name: r'Status', - id: -8158262482337811485, - properties: { - r'blockHash': PropertySchema( - id: 0, - name: r'blockHash', - type: IsarType.string, - ), - r'blockHeight': PropertySchema( - id: 1, - name: r'blockHeight', - type: IsarType.long, - ), - r'blockTime': PropertySchema( - id: 2, - name: r'blockTime', - type: IsarType.long, - ) - }, - estimateSize: _statusEstimateSize, - serialize: _statusSerialize, - deserialize: _statusDeserialize, - deserializeProp: _statusDeserializeProp, -); - -int _statusEstimateSize( - Status object, - List offsets, - Map> allOffsets, -) { - var bytesCount = offsets.last; - bytesCount += 3 + object.blockHash.length * 3; - return bytesCount; -} - -void _statusSerialize( - Status object, - IsarWriter writer, - List offsets, - Map> allOffsets, -) { - writer.writeString(offsets[0], object.blockHash); - writer.writeLong(offsets[1], object.blockHeight); - writer.writeLong(offsets[2], object.blockTime); -} - -Status _statusDeserialize( - Id id, - IsarReader reader, - List offsets, - Map> allOffsets, -) { - final object = Status(); - object.blockHash = reader.readString(offsets[0]); - object.blockHeight = reader.readLong(offsets[1]); - object.blockTime = reader.readLong(offsets[2]); - return object; -} - -P _statusDeserializeProp

( - IsarReader reader, - int propertyId, - int offset, - Map> allOffsets, -) { - switch (propertyId) { - case 0: - return (reader.readString(offset)) as P; - case 1: - return (reader.readLong(offset)) as P; - case 2: - return (reader.readLong(offset)) as P; - default: - throw IsarError('Unknown property with id $propertyId'); - } -} - -extension StatusQueryFilter on QueryBuilder { - QueryBuilder blockHashEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'blockHash', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashContains( - String value, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashMatches( - String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'blockHash', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockHash', - value: '', - )); - }); - } - - QueryBuilder blockHashIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'blockHash', - value: '', - )); - }); - } - - QueryBuilder blockHeightEqualTo( - int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockHeight', - value: value, - )); - }); - } - - QueryBuilder blockHeightGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'blockHeight', - value: value, - )); - }); - } - - QueryBuilder blockHeightLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'blockHeight', - value: value, - )); - }); - } - - QueryBuilder blockHeightBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'blockHeight', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder blockTimeEqualTo( - int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockTime', - value: value, - )); - }); - } - - QueryBuilder blockTimeGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'blockTime', - value: value, - )); - }); - } - - QueryBuilder blockTimeLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'blockTime', - value: value, - )); - }); - } - - QueryBuilder blockTimeBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'blockTime', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } -} - -extension StatusQueryObject on QueryBuilder {} From e203da866de3fc38bca861da282106c954bd75f8 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 12:17:29 -0600 Subject: [PATCH 090/192] add general balance model to reduce clutter --- lib/models/balance.dart | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/models/balance.dart diff --git a/lib/models/balance.dart b/lib/models/balance.dart new file mode 100644 index 000000000..2caa6353f --- /dev/null +++ b/lib/models/balance.dart @@ -0,0 +1,39 @@ +import 'package:decimal/decimal.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/format.dart'; + +class Balance { + final Coin coin; + final int total; + final int spendable; + final int blockedTotal; + final int pendingSpendable; + + Balance({ + required this.coin, + required this.total, + required this.spendable, + required this.blockedTotal, + required this.pendingSpendable, + }); + + Decimal getTotal({bool includeBlocked = false}) => Format.satoshisToAmount( + includeBlocked ? total : total - blockedTotal, + coin: coin, + ); + + Decimal getSpendable() => Format.satoshisToAmount( + spendable, + coin: coin, + ); + + Decimal getPending() => Format.satoshisToAmount( + pendingSpendable, + coin: coin, + ); + + Decimal getBlocked() => Format.satoshisToAmount( + blockedTotal, + coin: coin, + ); +} From 78db152ff4fe2b4b53dbd86c8830ffae0cbaa681 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 12:21:11 -0600 Subject: [PATCH 091/192] clean up coinservice and manager classes to handle new isar models and balance model --- lib/services/coins/coin_service.dart | 29 +++-------- lib/services/coins/manager.dart | 78 +++------------------------- 2 files changed, 13 insertions(+), 94 deletions(-) diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index ff953708f..fb433466c 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -1,13 +1,15 @@ -import 'package:decimal/decimal.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/models/models.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/node_model.dart'; +import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; +import 'package:stackwallet/services/coins/litecoin/litecoin_wallet.dart'; import 'package:stackwallet/services/coins/monero/monero_wallet.dart'; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; import 'package:stackwallet/services/coins/particl/particl_wallet.dart'; @@ -17,8 +19,6 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/prefs.dart'; -import 'litecoin/litecoin_wallet.dart'; - abstract class CoinServiceAPI { CoinServiceAPI(); @@ -240,30 +240,15 @@ abstract class CoinServiceAPI { Future confirmSend({required Map txData}); - /// create and submit tx to network - /// - /// Returns the txid of the sent tx - /// will throw exceptions on failure - Future send( - {required String toAddress, - required int amount, - Map args}); - Future get fees; Future get maxFee; Future get currentReceivingAddress; - // Future get currentLegacyReceivingAddress; - Future get availableBalance; - Future get pendingBalance; - Future get totalBalance; - Future get balanceMinusMaxFee; + Balance get balance; - Future> get allOwnAddresses; - - Future get transactionData; - Future> get unspentOutputs; + Future> get transactions; + Future> get utxos; Future refresh(); diff --git a/lib/services/coins/manager.dart b/lib/services/coins/manager.dart index 1c2163c04..a590752e0 100644 --- a/lib/services/coins/manager.dart +++ b/lib/services/coins/manager.dart @@ -1,8 +1,9 @@ import 'dart:async'; -import 'package:decimal/decimal.dart'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/models.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; @@ -59,7 +60,6 @@ class Manager with ChangeNotifier { Future updateNode(bool shouldRefresh) async { await _currentWallet.updateNode(shouldRefresh); } - // Function(bool isActive)? onIsActiveWalletChanged; CoinServiceAPI get wallet => _currentWallet; @@ -120,73 +120,17 @@ class Manager with ChangeNotifier { } } - /// create and submit tx to network - /// - /// Returns the txid of the sent tx - /// will throw exceptions on failure - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - final txid = await _currentWallet.send( - toAddress: toAddress, - amount: amount, - args: args, - ); - notifyListeners(); - return txid; - } catch (e, s) { - Logging.instance.log("$e\n $s", level: LogLevel.Error); - // rethrow to pass error in alert - rethrow; - } - } - Future get fees => _currentWallet.fees; Future get maxFee => _currentWallet.maxFee; Future get currentReceivingAddress => _currentWallet.currentReceivingAddress; - // Future get currentLegacyReceivingAddress => - // _currentWallet.currentLegacyReceivingAddress; - Future get availableBalance async { - _cachedAvailableBalance = await _currentWallet.availableBalance; - return _cachedAvailableBalance; - } + Balance get balance => _currentWallet.balance; - Decimal _cachedAvailableBalance = Decimal.zero; - Decimal get cachedAvailableBalance => _cachedAvailableBalance; - - Future get pendingBalance => _currentWallet.pendingBalance; - Future get balanceMinusMaxFee => _currentWallet.balanceMinusMaxFee; - - Future get totalBalance async { - _cachedTotalBalance = await _currentWallet.totalBalance; - return _cachedTotalBalance; - } - - Decimal _cachedTotalBalance = Decimal.zero; - Decimal get cachedTotalBalance => _cachedTotalBalance; - - // Future get fiatBalance async { - // final balance = await _currentWallet.availableBalance; - // final price = await _currentWallet.basePrice; - // return balance * price; - // } - // - // Future get fiatTotalBalance async { - // final balance = await _currentWallet.totalBalance; - // final price = await _currentWallet.basePrice; - // return balance * price; - // } - - Future> get allOwnAddresses => _currentWallet.allOwnAddresses; - - Future get transactionData => _currentWallet.transactionData; - Future> get unspentOutputs => _currentWallet.unspentOutputs; + Future> get transactions => + _currentWallet.transactions; + Future> get utxos => _currentWallet.utxos; Future refresh() async { await _currentWallet.refresh(); @@ -233,11 +177,6 @@ class Manager with ChangeNotifier { } } - // Future initializeWallet() async { - // final success = await _currentWallet.initializeWallet(); - // return success; - // } - Future exitCurrentWallet() async { final name = _currentWallet.walletName; final id = _currentWallet.walletId; @@ -260,11 +199,6 @@ class Manager with ChangeNotifier { } } - Future isOwnAddress(String address) async { - final allOwnAddresses = await this.allOwnAddresses; - return allOwnAddresses.contains(address); - } - bool get isConnected => _currentWallet.isConnected; Future estimateFeeFor(int satoshiAmount, int feeRate) async { From 90964b83c6bbd46a0ed881d11c40be692bcdec70 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 12:23:49 -0600 Subject: [PATCH 092/192] migrate dogecoin_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/dogecoin/dogecoin_wallet.dart | 560 ++++++------------ 1 file changed, 196 insertions(+), 364 deletions(-) diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 895689e09..8c5535172 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; import 'package:bech32/bech32.dart'; import 'package:bip32/bip32.dart' as bip32; @@ -9,20 +8,15 @@ import 'package:bip39/bip39.dart' as bip39; import 'package:bitcoindart/bitcoindart.dart'; import 'package:bitcoindart/bitcoindart.dart' as btc_dart; import 'package:bs58check/bs58check.dart' as bs58check; -import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/isar/models/address/address.dart'; +import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; -import 'package:stackwallet/models/models.dart' as models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; @@ -32,8 +26,8 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; +import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; @@ -151,70 +145,25 @@ class DogecoinWallet extends CoinServiceAPI { } } - List outputsList = []; + @override + Future> get utxos => isar.utxos.where().findAll(); + + @override + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); @override Coin get coin => _coin; - @override - Future> get allOwnAddresses => - throw Exception("doeg all own address exception!!"); - // _allOwnAddresses ??= _fetchAllOwnAddresses(); - // Future>? _allOwnAddresses; - - Future? _utxoData; - Future get utxoData => _utxoData ??= _fetchUtxoData(); - - @override - Future> get unspentOutputs async => - (await utxoData).unspentOutputArray; - - @override - Future get availableBalance async { - final data = await utxoData; - return Format.satoshisToAmount( - data.satoshiBalance - data.satoshiBalanceUnconfirmed, - coin: coin); - } - - @override - Future get pendingBalance async { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalanceUnconfirmed, coin: coin); - } - - @override - Future get balanceMinusMaxFee async => - (await availableBalance) - - (Decimal.fromInt((await maxFee)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(); - - @override - Future get totalBalance async { - if (!isActive) { - final totalBalance = DB.instance - .get(boxName: walletId, key: 'totalBalance') as int?; - if (totalBalance == null) { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } else { - return Format.satoshisToAmount(totalBalance, coin: coin); - } - } - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } - @override Future get currentReceivingAddress async => (await _currentReceivingAddress).value; Future get _currentReceivingAddress async => - (await isar.address + (await isar.addresses .filter() .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(AddressSubType.receiving) + .subTypeEqualTo(isar_models.AddressSubType.receiving) .sortByDerivationIndexDesc() .findFirst())!; @@ -223,10 +172,10 @@ class DogecoinWallet extends CoinServiceAPI { (await _currentChangeAddress).value; Future get _currentChangeAddress async => - (await isar.address + (await isar.addresses .filter() .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(AddressSubType.change) + .subTypeEqualTo(isar_models.AddressSubType.change) .sortByDerivationIndexDesc() .findFirst())!; @@ -566,7 +515,6 @@ class DogecoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(0, 0, DerivePathType.bip44); p2pkhReceiveAddressArray.add(address); - p2pkhReceiveIndex = 0; } // If restoring a wallet that never sent any funds with change, then set changeArray @@ -575,16 +523,17 @@ class DogecoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(1, 0, DerivePathType.bip44); p2pkhChangeAddressArray.add(address); - p2pkhChangeIndex = 0; } await _isarInit(); await isar.writeTxn(() async { - await isar.address.putAll(p2pkhChangeAddressArray); - await isar.address.putAll(p2pkhReceiveAddressArray); + await isar.addresses.putAll(p2pkhChangeAddressArray); + await isar.addresses.putAll(p2pkhReceiveAddressArray); }); + await _updateUTXOs(); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); await DB.instance @@ -621,8 +570,7 @@ class DogecoinWallet extends CoinServiceAPI { for (String txid in txnsToCheck) { final txn = await electrumXClient.getTransaction(txHash: txid); - var confirmations = txn["confirmations"]; - if (confirmations is! int) continue; + int confirmations = txn["confirmations"] as int? ?? 0; bool isUnconfirmed = confirmations < MINIMUM_CONFIRMATIONS; if (!isUnconfirmed) { // unconfirmedTxs = {}; @@ -631,10 +579,9 @@ class DogecoinWallet extends CoinServiceAPI { } } if (!needsRefresh) { - var allOwnAddresses = await _fetchAllOwnAddresses(); + final allOwnAddresses = await _fetchAllOwnAddresses(); List> allTxs = await _fetchHistory( allOwnAddresses.map((e) => e.value).toList(growable: false)); - // final txData = await transactionData; for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; if ((await isar.transactions @@ -664,8 +611,7 @@ class DogecoinWallet extends CoinServiceAPI { List unconfirmedTxnsToNotifyPending = []; List unconfirmedTxnsToNotifyConfirmed = []; - final currentChainHeight = - (await electrumXClient.getBlockHeadTip())["height"] as int; + final currentChainHeight = await chainHeight; final txCount = await isar.transactions.count(); @@ -691,22 +637,6 @@ class DogecoinWallet extends CoinServiceAPI { } } - // // Get all unconfirmed incoming transactions - // for (final chunk in txData.txChunks) { - // for (final tx in chunk.transactions) { - // if (tx.confirmedStatus) { - // if (txTracker.wasNotifiedPending(tx.txid) && - // !txTracker.wasNotifiedConfirmed(tx.txid)) { - // unconfirmedTxnsToNotifyConfirmed.add(tx); - // } - // } else { - // if (!txTracker.wasNotifiedPending(tx.txid)) { - // unconfirmedTxnsToNotifyPending.add(tx); - // } - // } - // } - // } - // notify on new incoming transaction for (final tx in unconfirmedTxnsToNotifyPending) { final confirmations = tx.getConfirmations(currentChainHeight); @@ -838,11 +768,11 @@ class DogecoinWallet extends CoinServiceAPI { GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); await _checkCurrentReceivingAddressesForTransactions(); - final fetchFuture = _fetchTransactionData(); + final fetchFuture = _refreshTransactions(); + final utxosRefreshFuture = _updateUTXOs(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); - final newUtxoData = _fetchUtxoData(); final feeObj = _getFees(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.60, walletId)); @@ -850,7 +780,8 @@ class DogecoinWallet extends CoinServiceAPI { GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.70, walletId)); _feeObject = Future(() => feeObj); - _utxoData = Future(() => newUtxoData); + + await utxosRefreshFuture; GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); @@ -936,9 +867,7 @@ class DogecoinWallet extends CoinServiceAPI { } // check for send all bool isSendAll = false; - final balance = - Format.decimalAmountToSatoshis(await availableBalance, coin); - if (satoshiAmount == balance) { + if (satoshiAmount == balance.spendable) { isSendAll = true; } @@ -998,24 +927,6 @@ class DogecoinWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - final txData = await prepareSend( - address: toAddress, satoshiAmount: amount, args: args); - final txHash = await confirmSend(txData: txData); - return txHash; - } catch (e, s) { - Logging.instance - .log("Exception rethrown from send(): $e\n$s", level: LogLevel.Error); - rethrow; - } - } - @override Future testNetworkConnection() async { try { @@ -1108,18 +1019,15 @@ class DogecoinWallet extends CoinServiceAPI { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); + if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + throw Exception( + "Attempted to initialize an existing wallet using an unknown wallet ID!"); + } + await _prefs.init(); await _isarInit(); } - @override - Future get transactionData => - throw Exception("dogecoin transactionData attempt"); - // _transactionData ??= _fetchTransactionData(); - // Future? _transactionData; - - TransactionData? cachedTxData; - // hack to add tx to txData before refresh completes // required based on current app architecture where we don't properly store // transactions locally in a good way @@ -1194,8 +1102,6 @@ class DogecoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; - late Isar isar; DogecoinWallet({ @@ -1205,7 +1111,6 @@ class DogecoinWallet extends CoinServiceAPI { required ElectrumX client, required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, - PriceAPI? priceAPI, required SecureStorageInterface secureStore, }) { txTracker = tracker; @@ -1214,8 +1119,6 @@ class DogecoinWallet extends CoinServiceAPI { _coin = coin; _electrumXClient = client; _cachedElectrumXClient = cachedClient; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; } @@ -1273,40 +1176,12 @@ class DogecoinWallet extends CoinServiceAPI { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.address + final allAddresses = await isar.addresses .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() .subTypeEqualTo(isar_models.AddressSubType.change) .findAll(); - // final List allAddresses = []; - // - // final receivingAddressesP2PKH = DB.instance.get( - // boxName: walletId, key: 'receivingAddressesP2PKH') as List; - // final changeAddressesP2PKH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - // as List; - // - // // for (var i = 0; i < receivingAddresses.length; i++) { - // // if (!allAddresses.contains(receivingAddresses[i])) { - // // allAddresses.add(receivingAddresses[i]); - // // } - // // } - // // for (var i = 0; i < changeAddresses.length; i++) { - // // if (!allAddresses.contains(changeAddresses[i])) { - // // allAddresses.add(changeAddresses[i]); - // // } - // // } - // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { - // if (!allAddresses.contains(receivingAddressesP2PKH[i])) { - // allAddresses.add(receivingAddressesP2PKH[i] as String); - // } - // } - // for (var i = 0; i < changeAddressesP2PKH.length; i++) { - // if (!allAddresses.contains(changeAddressesP2PKH[i])) { - // allAddresses.add(changeAddressesP2PKH[i] as String); - // } - // } return allAddresses; } @@ -1375,16 +1250,6 @@ class DogecoinWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // // Set relevant indexes - // await DB.instance - // .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); - // await DB.instance - // .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); - // await DB.instance.put( - // boxName: walletId, - // key: 'blocked_tx_hashes', - // value: ["0xdefault"], - // ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -1400,7 +1265,7 @@ class DogecoinWallet extends CoinServiceAPI { await _isarInit(); await isar.writeTxn(() async { - await isar.address.putAll([ + await isar.addresses.putAll([ initialReceivingAddressP2PKH, initialChangeAddressP2PKH, ]); @@ -1462,17 +1327,21 @@ class DogecoinWallet extends CoinServiceAPI { /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// and /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future getCurrentAddressForChain( - int chain, DerivePathType derivePathType) async { + Future _getCurrentAddressForChain( + int chain, + DerivePathType derivePathType, + ) async { + final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; + isar_models.Address? address; switch (derivePathType) { case DerivePathType.bip44: - address = await isar.address + address = await isar.addresses .filter() - .subTypeEqualTo( - chain == 0 // Here, we assume that chain == 1 if it isn't 0 - ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change) + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(subType) .sortByDerivationIndexDesc() .findFirst(); break; @@ -1609,7 +1478,7 @@ class DogecoinWallet extends CoinServiceAPI { return allTransactions; } - Future _fetchUtxoData() async { + Future _updateUTXOs() async { final allAddresses = await _fetchAllOwnAddresses(); try { @@ -1622,7 +1491,8 @@ class DogecoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i].value, network); + final scripthash = + AddressUtils.convertToScriptHash(allAddresses[i].value, network); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -1641,148 +1511,123 @@ class DogecoinWallet extends CoinServiceAPI { } } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> outputArray = []; - int satoshiBalance = 0; + final currentChainHeight = await chainHeight; + + final List outputArray = []; + int satoshiBalanceTotal = 0; int satoshiBalancePending = 0; + int satoshiBalanceSpendable = 0; + int satoshiBalanceBlocked = 0; for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - int value = fetchedUtxoList[i][j]["value"] as int; - satoshiBalance += value; - final txn = await cachedElectrumXClient.getTransaction( txHash: fetchedUtxoList[i][j]["tx_hash"] as String, verbose: true, coin: coin, ); - final Map utxo = {}; - final int confirmations = txn["confirmations"] as int? ?? 0; - final bool confirmed = txn["confirmations"] == null - ? false - : txn["confirmations"] as int >= MINIMUM_CONFIRMATIONS; - if (!confirmed) { - satoshiBalancePending += value; + final utxo = isar_models.UTXO(); + + utxo.txid = txn["txid"] as String; + utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; + utxo.value = fetchedUtxoList[i][j]["value"] as int; + utxo.name = ""; + + // todo check here if we should mark as blocked + utxo.isBlocked = false; + utxo.blockedReason = null; + + utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; + utxo.blockHash = txn["blockhash"] as String?; + utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; + utxo.blockTime = txn["blocktime"] as int?; + + satoshiBalanceTotal += utxo.value; + + if (utxo.isBlocked) { + satoshiBalanceBlocked += utxo.value; + } else { + if (utxo.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + satoshiBalanceSpendable += utxo.value; + } else { + satoshiBalancePending += utxo.value; + } } - utxo["txid"] = txn["txid"]; - utxo["vout"] = fetchedUtxoList[i][j]["tx_pos"]; - utxo["value"] = value; - - utxo["status"] = {}; - utxo["status"]["confirmed"] = confirmed; - utxo["status"]["confirmations"] = confirmations; - utxo["status"]["block_height"] = fetchedUtxoList[i][j]["height"]; - utxo["status"]["block_hash"] = txn["blockhash"]; - utxo["status"]["block_time"] = txn["blocktime"]; - - final fiatValue = ((Decimal.fromInt(value) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - utxo["rawWorth"] = fiatValue; - utxo["fiatWorth"] = fiatValue.toString(); outputArray.add(utxo); } } - Decimal currencyBalanceRaw = - ((Decimal.fromInt(satoshiBalance) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - - final Map result = { - "total_user_currency": currencyBalanceRaw.toString(), - "total_sats": satoshiBalance, - "total_btc": (Decimal.fromInt(satoshiBalance) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal( - scaleOnInfinitePrecision: Constants.decimalPlacesForCoin(coin)) - .toString(), - "outputArray": outputArray, - "unconfirmed": satoshiBalancePending, - }; - - final dataModel = UtxoData.fromJson(result); - - final List allOutputs = dataModel.unspentOutputArray; Logging.instance - .log('Outputs fetched: $allOutputs', level: LogLevel.Info); - await _sortOutputs(allOutputs); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: dataModel); - await DB.instance.put( - boxName: walletId, - key: 'totalBalance', - value: dataModel.satoshiBalance); - return dataModel; + .log('Outputs fetched: $outputArray', level: LogLevel.Info); + + await isar.writeTxn(() async { + await isar.utxos.clear(); + await isar.utxos.putAll(outputArray); + }); + + // finally update balance + _balance = Balance( + coin: coin, + total: satoshiBalanceTotal, + spendable: satoshiBalanceSpendable, + blockedTotal: satoshiBalanceBlocked, + pendingSpendable: satoshiBalancePending, + ); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); - final latestTxModel = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - - if (latestTxModel == null) { - final emptyModel = { - "total_user_currency": "0.00", - "total_sats": 0, - "total_btc": "0", - "outputArray": [] - }; - return UtxoData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old output model located", level: LogLevel.Warning); - return latestTxModel as models.UtxoData; - } } } - /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - /// Now also checks for output labeling. - Future _sortOutputs(List utxos) async { - final blockedHashArray = - DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - as List?; - final List lst = []; - if (blockedHashArray != null) { - for (var hash in blockedHashArray) { - lst.add(hash as String); - } - } - final labels = - DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - {}; + @override + Balance get balance => _balance!; + Balance? _balance; - outputsList = []; - - for (var i = 0; i < utxos.length; i++) { - if (labels[utxos[i].txid] != null) { - utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - } else { - utxos[i].txName = 'Output #$i'; - } - - if (utxos[i].status.confirmed == false) { - outputsList.add(utxos[i]); - } else { - if (lst.contains(utxos[i].txid)) { - utxos[i].blocked = true; - outputsList.add(utxos[i]); - } else if (!lst.contains(utxos[i].txid)) { - outputsList.add(utxos[i]); - } - } - } - } + // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) + // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. + // /// Now also checks for output labeling. + // Future _sortOutputs(List utxos) async { + // final blockedHashArray = + // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') + // as List?; + // final List lst = []; + // if (blockedHashArray != null) { + // for (var hash in blockedHashArray) { + // lst.add(hash as String); + // } + // } + // final labels = + // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? + // {}; + // + // outputsList = []; + // + // for (var i = 0; i < utxos.length; i++) { + // if (labels[utxos[i].txid] != null) { + // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; + // } else { + // utxos[i].txName = 'Output #$i'; + // } + // + // if (utxos[i].status.confirmed == false) { + // outputsList.add(utxos[i]); + // } else { + // if (lst.contains(utxos[i].txid)) { + // utxos[i].blocked = true; + // outputsList.add(utxos[i]); + // } else if (!lst.contains(utxos[i].txid)) { + // outputsList.add(utxos[i]); + // } + // } + // } + // } Future getTxCount({required String address}) async { String? scripthash; try { - scripthash = _convertToScriptHash(address, network); + scripthash = AddressUtils.convertToScriptHash(address, network); final transactions = await electrumXClient.getHistory(scripthash: scripthash); return transactions.length; @@ -1800,7 +1645,9 @@ class DogecoinWallet extends CoinServiceAPI { try { final Map> args = {}; for (final entry in addresses.entries) { - args[entry.key] = [_convertToScriptHash(entry.value, network)]; + args[entry.key] = [ + AddressUtils.convertToScriptHash(entry.value, network) + ]; } final response = await electrumXClient.getBatchHistory(args: args); @@ -1827,6 +1674,7 @@ class DogecoinWallet extends CoinServiceAPI { level: LogLevel.Info); if (txCount >= 1) { + // First increment the receiving index final newReceivingIndex = currentReceiving.derivationIndex + 1; // Use new index to derive a new receiving address @@ -1835,7 +1683,7 @@ class DogecoinWallet extends CoinServiceAPI { // Add that new receiving address await isar.writeTxn(() async { - await isar.address.put(newReceivingAddress); + await isar.addresses.put(newReceivingAddress); }); } } on SocketException catch (se, s) { @@ -1869,12 +1717,12 @@ class DogecoinWallet extends CoinServiceAPI { // Add that new change address await isar.writeTxn(() async { - await isar.address.put(newChangeAddress); + await isar.addresses.put(newChangeAddress); }); } } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkChangeAddressForTransactions($DerivePathType.bip44): $e\n$s", + "Exception rethrown from _checkChangeAddressForTransactions(${DerivePathType.bip44}): $e\n$s", level: LogLevel.Error); rethrow; } @@ -1882,9 +1730,9 @@ class DogecoinWallet extends CoinServiceAPI { Future _checkCurrentReceivingAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkReceivingAddressForTransactions(); - } + // for (final type in DerivePathType.values) { + await _checkReceivingAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentReceivingAddressesForTransactions(): $e\n$s", @@ -1906,9 +1754,9 @@ class DogecoinWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await checkChangeAddressForTransactions(); - } + // for (final type in DerivePathType.values) { + await checkChangeAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentChangeAddressesForTransactions(): $e\n$s", @@ -1928,31 +1776,6 @@ class DogecoinWallet extends CoinServiceAPI { } } - /// attempts to convert a string to a valid scripthash - /// - /// Returns the scripthash or throws an exception on invalid dogecoin address - String _convertToScriptHash(String dogecoinAddress, NetworkType network) { - try { - final output = btc_dart.Address.addressToOutputScript( - dogecoinAddress, - network, - ); - final hash = sha256.convert(output.toList(growable: false)).toString(); - - final chars = hash.split(""); - final reversedPairs = []; - var i = chars.length - 1; - while (i > 0) { - reversedPairs.add(chars[i - 1]); - reversedPairs.add(chars[i]); - i -= 2; - } - return reversedPairs.join(""); - } catch (e) { - rethrow; - } - } - Future>> _fetchHistory( List allAddresses) async { try { @@ -1966,7 +1789,8 @@ class DogecoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], network); + final scripthash = + AddressUtils.convertToScriptHash(allAddresses[i], network); final id = Logger.isTestEnv ? "$i" : const Uuid().v1(); requestIdToAddressMap[id] = allAddresses[i]; batches[batchNumber]!.addAll({ @@ -2044,7 +1868,7 @@ class DogecoinWallet extends CoinServiceAPI { // boxName: walletId, key: "changeAddressesP2PKH", value: []); // } - Future _fetchTransactionData() async { + Future _refreshTransactions() async { final List allAddresses = await _fetchAllOwnAddresses(); @@ -2064,7 +1888,6 @@ class DogecoinWallet extends CoinServiceAPI { coin: coin, ); - // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { tx["address"] = txHash["address"]; tx["height"] = txHash["height"]; @@ -2083,7 +1906,7 @@ class DogecoinWallet extends CoinServiceAPI { await fastFetch(vHashes.toList()); for (final txObject in allTransactions) { - final midSortedTx = await parseTransaction( + final txn = await parseTransaction( txObject, cachedElectrumXClient, allAddresses, @@ -2091,16 +1914,16 @@ class DogecoinWallet extends CoinServiceAPI { MINIMUM_CONFIRMATIONS, ); - final tx = await isar.transactions - .filter() - .txidMatches(midSortedTx.txid) - .findFirst(); - // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar - if (tx == null) { - await isar.writeTxn(() async { - await isar.transactions.put(midSortedTx); - }); - } + // final tx = await isar.transactions + // .filter() + // .txidMatches(midSortedTx.txid) + // .findFirst(); + // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar + // if (tx == null) { + await isar.writeTxn(() async { + await isar.transactions.put(txn); + }); + // } } } @@ -2112,27 +1935,34 @@ class DogecoinWallet extends CoinServiceAPI { /// with [satoshiAmountToSend] and [selectedTxFeeRate]. If so, it will call buildTrasaction() and return /// a map containing the tx hex along with other important information. If not, then it will return /// an integer (1 or 2) - dynamic coinSelection(int satoshiAmountToSend, int selectedTxFeeRate, - String _recipientAddress, bool isSendAll, - {int additionalOutputs = 0, List? utxos}) async { + dynamic coinSelection( + int satoshiAmountToSend, + int selectedTxFeeRate, + String _recipientAddress, + bool isSendAll, { + int additionalOutputs = 0, + List? utxos, + }) async { Logging.instance .log("Starting coinSelection ----------", level: LogLevel.Info); - final List availableOutputs = utxos ?? outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final currentChainHeight = await chainHeight; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", level: LogLevel.Info); @@ -2159,7 +1989,7 @@ class DogecoinWallet extends CoinServiceAPI { // Possible situation right here int satoshisBeingUsed = 0; int inputsBeingConsumed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; satoshisBeingUsed < satoshiAmountToSend && i < spendableOutputs.length; @@ -2238,7 +2068,7 @@ class DogecoinWallet extends CoinServiceAPI { utxoSigningData: utxoSigningData, recipients: [ _recipientAddress, - await getCurrentAddressForChain(1, DerivePathType.bip44), + await _getCurrentAddressForChain(1, DerivePathType.bip44), ], satoshiAmounts: [ satoshiAmountToSend, @@ -2292,7 +2122,7 @@ class DogecoinWallet extends CoinServiceAPI { // generate new change address if current change address has been used await checkChangeAddressForTransactions(); final String newChangeAddress = - await getCurrentAddressForChain(1, DerivePathType.bip44); + await _getCurrentAddressForChain(1, DerivePathType.bip44); int feeBeingPaid = satoshisBeingUsed - satoshiAmountToSend - changeOutputSize; @@ -2460,7 +2290,7 @@ class DogecoinWallet extends CoinServiceAPI { } Future> fetchBuildTxData( - List utxosToUse, + List utxosToUse, ) async { // return data Map results = {}; @@ -2563,7 +2393,7 @@ class DogecoinWallet extends CoinServiceAPI { /// Builds and signs a transaction Future> buildTransaction({ - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required List recipients, required List satoshiAmounts, @@ -2830,22 +2660,23 @@ class DogecoinWallet extends CoinServiceAPI { @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { - final available = - Format.decimalAmountToSatoshis(await availableBalance, coin); + final available = balance.spendable; if (available == satoshiAmount) { - return satoshiAmount - sweepAllEstimate(feeRate); + return satoshiAmount - (await sweepAllEstimate(feeRate)); } else if (satoshiAmount <= 0 || satoshiAmount > available) { return roughFeeEstimate(1, 2, feeRate); } int runningBalance = 0; int inputCount = 0; - for (final output in outputsList) { - runningBalance += output.value; - inputCount++; - if (runningBalance > satoshiAmount) { - break; + for (final output in (await utxos)) { + if (!output.isBlocked) { + runningBalance += output.value; + inputCount++; + if (runningBalance > satoshiAmount) { + break; + } } } @@ -2877,11 +2708,12 @@ class DogecoinWallet extends CoinServiceAPI { (feeRatePerKB / 1000).ceil(); } - int sweepAllEstimate(int feeRate) { + Future sweepAllEstimate(int feeRate) async { int available = 0; int inputCount = 0; - for (final output in outputsList) { - if (output.status.confirmed) { + for (final output in (await utxos)) { + if (!output.isBlocked && + output.isConfirmed(storedChainHeight, MINIMUM_CONFIRMATIONS)) { available += output.value; inputCount++; } @@ -2906,7 +2738,7 @@ class DogecoinWallet extends CoinServiceAPI { // Add that new receiving address await isar.writeTxn(() async { - await isar.address.put(newReceivingAddress); + await isar.addresses.put(newReceivingAddress); }); return true; From 493bf095781abee702d4f831056dd69f0423686a Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 12:24:16 -0600 Subject: [PATCH 093/192] migrate bitcoin_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/bitcoin/bitcoin_wallet.dart | 1874 +++++++---------- 1 file changed, 795 insertions(+), 1079 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 1ed87681b..c3f446c23 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1,25 +1,22 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; import 'package:bech32/bech32.dart'; import 'package:bip32/bip32.dart' as bip32; import 'package:bip39/bip39.dart' as bip39; import 'package:bitcoindart/bitcoindart.dart'; import 'package:bs58check/bs58check.dart' as bs58check; -import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/models.dart' as models; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.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/refresh_percent_changed_event.dart'; @@ -30,6 +27,7 @@ import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; +import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; @@ -39,11 +37,13 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 294; +const int DUST_LIMIT_P2PKH = 546; const String GENESIS_HASH_MAINNET = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; @@ -160,8 +160,6 @@ class BitcoinWallet extends CoinServiceAPI { } } - List outputsList = []; - @override set isFavorite(bool markFavorite) { DB.instance.put( @@ -185,68 +183,34 @@ class BitcoinWallet extends CoinServiceAPI { Coin get coin => _coin; @override - Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - Future>? _allOwnAddresses; - - Future? _utxoData; - Future get utxoData => _utxoData ??= _fetchUtxoData(); + Future> get utxos => isar.utxos.where().findAll(); @override - Future> get unspentOutputs async => - (await utxoData).unspentOutputArray; + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); @override - Future get availableBalance async { - final data = await utxoData; - return Format.satoshisToAmount( - data.satoshiBalance - data.satoshiBalanceUnconfirmed, - coin: coin); - } + Future get currentReceivingAddress async => + (await _currentReceivingAddress).value; - @override - Future get pendingBalance async { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalanceUnconfirmed, coin: coin); - } + Future get _currentReceivingAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; - @override - Future get balanceMinusMaxFee async => - (await availableBalance) - - (Decimal.fromInt((await maxFee)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(); + Future get currentChangeAddress async => + (await _currentChangeAddress).value; - @override - Future get totalBalance async { - if (!isActive) { - final totalBalance = DB.instance - .get(boxName: walletId, key: 'totalBalance') as int?; - if (totalBalance == null) { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } else { - return Format.satoshisToAmount(totalBalance, coin: coin); - } - } - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } - - @override - Future get currentReceivingAddress => _currentReceivingAddress ??= - _getCurrentAddressForChain(0, DerivePathType.bip84); - Future? _currentReceivingAddress; - - Future get currentLegacyReceivingAddress => - _currentReceivingAddressP2PKH ??= - _getCurrentAddressForChain(0, DerivePathType.bip44); - Future? _currentReceivingAddressP2PKH; - - Future get currentReceivingAddressP2SH => - _currentReceivingAddressP2SH ??= - _getCurrentAddressForChain(0, DerivePathType.bip49); - Future? _currentReceivingAddressP2SH; + Future get _currentChangeAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -254,6 +218,7 @@ class BitcoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); + await isar.close(); } bool _hasCalledExit = false; @@ -287,6 +252,7 @@ class BitcoinWallet extends CoinServiceAPI { } } + @override int get storedChainHeight { final storedHeight = DB.instance .get(boxName: walletId, key: "storedChainHeight") as int?; @@ -365,15 +331,6 @@ class BitcoinWallet extends CoinServiceAPI { throw Exception( "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}"); } - // if (_networkType == BasicNetworkType.main) { - // if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { - // throw Exception("genesis hash does not match main net!"); - // } - // } else if (_networkType == BasicNetworkType.test) { - // if (features['genesis_hash'] != GENESIS_HASH_TESTNET) { - // throw Exception("genesis hash does not match test net!"); - // } - // } } // check to make sure we aren't overwriting a mnemonic // this should never fail @@ -409,8 +366,8 @@ class BitcoinWallet extends CoinServiceAPI { int txCountBatchSize, bip32.BIP32 root, DerivePathType type, - int account) async { - List addressArray = []; + int chain) async { + List addressArray = []; int returningIndex = -1; Map> derivations = {}; int gapCounter = 0; @@ -419,7 +376,7 @@ class BitcoinWallet extends CoinServiceAPI { index += txCountBatchSize) { List iterationsAddressArray = []; Logging.instance.log( - "index: $index, \t GapCounter $account ${type.name}: $gapCounter", + "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", level: LogLevel.Info); final _id = "k_$index"; @@ -430,42 +387,46 @@ class BitcoinWallet extends CoinServiceAPI { final node = await compute( getBip32NodeFromRootWrapper, Tuple4( - account, + chain, index + j, root, type, ), ); - String? address; + String addressString; + final data = PaymentData(pubkey: node.publicKey); + isar_models.AddressType addrType; switch (type) { case DerivePathType.bip44: - address = P2PKH( - data: PaymentData(pubkey: node.publicKey), - network: _network) - .data - .address!; + addressString = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - address = P2SH( + addressString = P2SH( data: PaymentData( - redeem: P2WPKH( - data: PaymentData(pubkey: node.publicKey), - network: _network) - .data), + redeem: P2WPKH(data: data, network: _network).data), network: _network) .data .address!; + addrType = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: - address = P2WPKH( - network: _network, - data: PaymentData(pubkey: node.publicKey)) - .data - .address!; + addressString = P2WPKH(network: _network, data: data).data.address!; + addrType = isar_models.AddressType.p2wpkh; break; default: throw Exception("No Path type $type exists"); } + + final address = isar_models.Address() + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = addrType + ..publicKey = node.publicKey + ..value = addressString + ..derivationIndex = index + j; + receivingNodes.addAll({ "${_id}_$j": { "node": node, @@ -473,7 +434,7 @@ class BitcoinWallet extends CoinServiceAPI { } }); txCountCallArgs.addAll({ - "${_id}_$j": address, + "${_id}_$j": addressString, }); } @@ -485,9 +446,10 @@ class BitcoinWallet extends CoinServiceAPI { int count = counts["${_id}_$k"]!; if (count > 0) { final node = receivingNodes["${_id}_$k"]; + final address = node["address"] as isar_models.Address; // add address to array - addressArray.add(node["address"] as String); - iterationsAddressArray.add(node["address"] as String); + addressArray.add(address); + iterationsAddressArray.add(address.value); // set current index returningIndex = index + k; // reset counter @@ -551,16 +513,16 @@ class BitcoinWallet extends CoinServiceAPI { final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, _network)); - List p2pkhReceiveAddressArray = []; - List p2shReceiveAddressArray = []; - List p2wpkhReceiveAddressArray = []; + List p2pkhReceiveAddressArray = []; + List p2shReceiveAddressArray = []; + List p2wpkhReceiveAddressArray = []; int p2pkhReceiveIndex = -1; int p2shReceiveIndex = -1; int p2wpkhReceiveIndex = -1; - List p2pkhChangeAddressArray = []; - List p2shChangeAddressArray = []; - List p2wpkhChangeAddressArray = []; + List p2pkhChangeAddressArray = []; + List p2shChangeAddressArray = []; + List p2wpkhChangeAddressArray = []; int p2pkhChangeIndex = -1; int p2shChangeIndex = -1; int p2wpkhChangeIndex = -1; @@ -603,37 +565,37 @@ class BitcoinWallet extends CoinServiceAPI { ]); p2pkhReceiveAddressArray = - (await resultReceive44)['addressArray'] as List; + (await resultReceive44)['addressArray'] as List; p2pkhReceiveIndex = (await resultReceive44)['index'] as int; p2pkhReceiveDerivations = (await resultReceive44)['derivations'] as Map>; p2shReceiveAddressArray = - (await resultReceive49)['addressArray'] as List; + (await resultReceive49)['addressArray'] as List; p2shReceiveIndex = (await resultReceive49)['index'] as int; p2shReceiveDerivations = (await resultReceive49)['derivations'] as Map>; p2wpkhReceiveAddressArray = - (await resultReceive84)['addressArray'] as List; + (await resultReceive84)['addressArray'] as List; p2wpkhReceiveIndex = (await resultReceive84)['index'] as int; p2wpkhReceiveDerivations = (await resultReceive84)['derivations'] as Map>; p2pkhChangeAddressArray = - (await resultChange44)['addressArray'] as List; + (await resultChange44)['addressArray'] as List; p2pkhChangeIndex = (await resultChange44)['index'] as int; p2pkhChangeDerivations = (await resultChange44)['derivations'] as Map>; p2shChangeAddressArray = - (await resultChange49)['addressArray'] as List; + (await resultChange49)['addressArray'] as List; p2shChangeIndex = (await resultChange49)['index'] as int; p2shChangeDerivations = (await resultChange49)['derivations'] as Map>; p2wpkhChangeAddressArray = - (await resultChange84)['addressArray'] as List; + (await resultChange84)['addressArray'] as List; p2wpkhChangeIndex = (await resultChange84)['index'] as int; p2wpkhChangeDerivations = (await resultChange84)['derivations'] as Map>; @@ -682,19 +644,16 @@ class BitcoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(0, 0, DerivePathType.bip44); p2pkhReceiveAddressArray.add(address); - p2pkhReceiveIndex = 0; } if (p2shReceiveIndex == -1) { final address = await _generateAddressForChain(0, 0, DerivePathType.bip49); p2shReceiveAddressArray.add(address); - p2shReceiveIndex = 0; } if (p2wpkhReceiveIndex == -1) { final address = await _generateAddressForChain(0, 0, DerivePathType.bip84); p2wpkhReceiveAddressArray.add(address); - p2wpkhReceiveIndex = 0; } // If restoring a wallet that never sent any funds with change, then set changeArray @@ -703,65 +662,31 @@ class BitcoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(1, 0, DerivePathType.bip44); p2pkhChangeAddressArray.add(address); - p2pkhChangeIndex = 0; } if (p2shChangeIndex == -1) { final address = await _generateAddressForChain(1, 0, DerivePathType.bip49); p2shChangeAddressArray.add(address); - p2shChangeIndex = 0; } if (p2wpkhChangeIndex == -1) { final address = await _generateAddressForChain(1, 0, DerivePathType.bip84); p2wpkhChangeAddressArray.add(address); - p2wpkhChangeIndex = 0; } - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: p2wpkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: p2wpkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: p2pkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: p2pkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: p2shReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: p2shChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: p2wpkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: p2wpkhChangeIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2PKH', value: p2pkhChangeIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: p2pkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: p2shReceiveIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: p2shChangeIndex); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(p2wpkhReceiveAddressArray); + await isar.addresses.putAll(p2wpkhChangeAddressArray); + await isar.addresses.putAll(p2pkhReceiveAddressArray); + await isar.addresses.putAll(p2pkhChangeAddressArray); + await isar.addresses.putAll(p2shReceiveAddressArray); + await isar.addresses.putAll(p2shChangeAddressArray); + }); + + await _updateUTXOs(); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); await DB.instance @@ -804,12 +729,15 @@ class BitcoinWallet extends CoinServiceAPI { } } if (!needsRefresh) { - var allOwnAddresses = await _fetchAllOwnAddresses(); - List> allTxs = - await _fetchHistory(allOwnAddresses); - final txData = await transactionData; + final allOwnAddresses = await _fetchAllOwnAddresses(); + List> allTxs = await _fetchHistory( + allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { - if (txData.findTransaction(transaction['tx_hash'] as String) == + final txid = transaction['tx_hash'] as String; + if ((await isar.transactions + .filter() + .txidMatches(txid) + .findFirst()) == null) { Logging.instance.log( " txid not found in address history already ${transaction['tx_hash']}", @@ -828,16 +756,25 @@ class BitcoinWallet extends CoinServiceAPI { } } - Future getAllTxsToWatch( - TransactionData txData, - ) async { + Future getAllTxsToWatch() async { if (_hasCalledExit) return; - List unconfirmedTxnsToNotifyPending = []; - List unconfirmedTxnsToNotifyConfirmed = []; + List unconfirmedTxnsToNotifyPending = []; + List unconfirmedTxnsToNotifyConfirmed = []; - for (final chunk in txData.txChunks) { - for (final tx in chunk.transactions) { - if (tx.confirmedStatus) { + final currentChainHeight = await chainHeight; + + final txCount = await isar.transactions.count(); + + const paginateLimit = 50; + + for (int i = 0; i < txCount; i += paginateLimit) { + final transactions = await isar.transactions + .where() + .offset(i) + .limit(paginateLimit) + .findAll(); + for (final tx in transactions) { + if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { // get all transactions that were notified as pending but not as confirmed if (txTracker.wasNotifiedPending(tx.txid) && !txTracker.wasNotifiedConfirmed(tx.txid)) { @@ -854,31 +791,33 @@ class BitcoinWallet extends CoinServiceAPI { // notify on unconfirmed transactions for (final tx in unconfirmedTxnsToNotifyPending) { - if (tx.txType == "Received") { + final confirmations = tx.getConfirmations(currentChainHeight); + + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Sending transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); @@ -887,7 +826,7 @@ class BitcoinWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { - if (tx.txType == "Received") { + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction confirmed", body: walletName, @@ -898,7 +837,7 @@ class BitcoinWallet extends CoinServiceAPI { coinName: coin.name, )); await txTracker.addNotifiedConfirmed(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Outgoing transaction confirmed", body: walletName, @@ -978,40 +917,30 @@ class BitcoinWallet extends CoinServiceAPI { } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - final changeAddressForTransactions = - _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); - final currentReceivingAddressesForTransactions = - _checkCurrentReceivingAddressesForTransactions(); + await _checkCurrentReceivingAddressesForTransactions(); - final newTxData = _fetchTransactionData(); + final fetchFuture = _refreshTransactions(); + final utxosRefreshFuture = _updateUTXOs(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); - final newUtxoData = _fetchUtxoData(); final feeObj = _getFees(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.60, walletId)); - _transactionData = Future(() => newTxData); - GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.70, walletId)); _feeObject = Future(() => feeObj); - _utxoData = Future(() => newUtxoData); + + await utxosRefreshFuture; GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); - final allTxsToWatch = getAllTxsToWatch(await newTxData); - await Future.wait([ - newTxData, - changeAddressForTransactions, - currentReceivingAddressesForTransactions, - newUtxoData, - feeObj, - allTxsToWatch, - ]); + await fetchFuture; + await getAllTxsToWatch(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.90, walletId)); } @@ -1096,9 +1025,7 @@ class BitcoinWallet extends CoinServiceAPI { // check for send all bool isSendAll = false; - final balance = - Format.decimalAmountToSatoshis(await availableBalance, coin); - if (satoshiAmount == balance) { + if (satoshiAmount == balance.spendable) { isSendAll = true; } @@ -1174,24 +1101,6 @@ class BitcoinWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - final txData = await prepareSend( - address: toAddress, satoshiAmount: amount, args: args); - final txHash = await confirmSend(txData: txData); - return txHash; - } catch (e, s) { - Logging.instance - .log("Exception rethrown from send(): $e\n$s", level: LogLevel.Error); - rethrow; - } - } - @override Future testNetworkConnection() async { try { @@ -1264,6 +1173,22 @@ class BitcoinWallet extends CoinServiceAPI { ]); } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1273,66 +1198,56 @@ class BitcoinWallet extends CoinServiceAPI { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } + await _prefs.init(); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); } - @override - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - Future? _transactionData; - - TransactionData? cachedTxData; - // hack to add tx to txData before refresh completes // required based on current app architecture where we don't properly store // transactions locally in a good way @override Future updateSentCachedTxData(Map txData) async { - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final String worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - - final tx = models.Transaction( - txid: txData["txid"] as String, - confirmedStatus: false, - timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, - txType: "Sent", - amount: txData["recipientAmt"] as int, - worthNow: worthNow, - worthAtBlockTimestamp: worthNow, - fees: txData["fee"] as int, - inputSize: 0, - outputSize: 0, - inputs: [], - outputs: [], - address: txData["address"] as String, - height: -1, - confirmations: 0, - ); - - if (cachedTxData == null) { - final data = await _fetchTransactionData(); - _transactionData = Future(() => data); - } - - final transactions = cachedTxData!.getAllTransactions(); - transactions[tx.txid] = tx; - cachedTxData = models.TransactionData.fromMap(transactions); - _transactionData = Future(() => cachedTxData!); + // final priceData = + // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); + // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final String worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // + // final tx = models.Transaction( + // txid: txData["txid"] as String, + // confirmedStatus: false, + // timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // txType: "Sent", + // amount: txData["recipientAmt"] as int, + // worthNow: worthNow, + // worthAtBlockTimestamp: worthNow, + // fees: txData["fee"] as int, + // inputSize: 0, + // outputSize: 0, + // inputs: [], + // outputs: [], + // address: txData["address"] as String, + // height: -1, + // confirmations: 0, + // ); + // + // if (cachedTxData == null) { + // final data = await _fetchTransactionData(); + // _transactionData = Future(() => data); + // } + // + // final transactions = cachedTxData!.getAllTransactions(); + // transactions[tx.txid] = tx; + // cachedTxData = models.TransactionData.fromMap(transactions); + // _transactionData = Future(() => cachedTxData!); } @override @@ -1362,7 +1277,7 @@ class BitcoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; + late Isar isar; BitcoinWallet({ required String walletId, @@ -1380,8 +1295,6 @@ class BitcoinWallet extends CoinServiceAPI { _coin = coin; _electrumXClient = client; _cachedElectrumXClient = cachedClient; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; } @@ -1438,53 +1351,59 @@ class BitcoinWallet extends CoinServiceAPI { ); } - Future> _fetchAllOwnAddresses() async { - final List allAddresses = []; - final receivingAddresses = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH') as List; - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final receivingAddressesP2PKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2PKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - final receivingAddressesP2SH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2SH') as List; - final changeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - as List; - - for (var i = 0; i < receivingAddresses.length; i++) { - if (!allAddresses.contains(receivingAddresses[i])) { - allAddresses.add(receivingAddresses[i] as String); - } - } - for (var i = 0; i < changeAddresses.length; i++) { - if (!allAddresses.contains(changeAddresses[i])) { - allAddresses.add(changeAddresses[i] as String); - } - } - for (var i = 0; i < receivingAddressesP2PKH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2PKH[i])) { - allAddresses.add(receivingAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - if (!allAddresses.contains(changeAddressesP2PKH[i])) { - allAddresses.add(changeAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < receivingAddressesP2SH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2SH[i])) { - allAddresses.add(receivingAddressesP2SH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2SH.length; i++) { - if (!allAddresses.contains(changeAddressesP2SH[i])) { - allAddresses.add(changeAddressesP2SH[i] as String); - } - } + Future> _fetchAllOwnAddresses() async { + final allAddresses = await isar.addresses + .filter() + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change) + .findAll(); + // final List allAddresses = []; + // final receivingAddresses = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH') as List; + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final receivingAddressesP2PKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2PKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // final receivingAddressesP2SH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2SH') as List; + // final changeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') + // as List; + // + // for (var i = 0; i < receivingAddresses.length; i++) { + // if (!allAddresses.contains(receivingAddresses[i])) { + // allAddresses.add(receivingAddresses[i] as String); + // } + // } + // for (var i = 0; i < changeAddresses.length; i++) { + // if (!allAddresses.contains(changeAddresses[i])) { + // allAddresses.add(changeAddresses[i] as String); + // } + // } + // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2PKH[i])) { + // allAddresses.add(receivingAddressesP2PKH[i] as String); + // } + // } + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2PKH[i])) { + // allAddresses.add(changeAddressesP2PKH[i] as String); + // } + // } + // for (var i = 0; i < receivingAddressesP2SH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2SH[i])) { + // allAddresses.add(receivingAddressesP2SH[i] as String); + // } + // } + // for (var i = 0; i < changeAddressesP2SH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2SH[i])) { + // allAddresses.add(changeAddressesP2SH[i] as String); + // } + // } return allAddresses; } @@ -1553,24 +1472,6 @@ class BitcoinWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2SH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2SH", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -1578,90 +1479,25 @@ class BitcoinWallet extends CoinServiceAPI { value: {}); // Generate and add addresses to relevant arrays - await Future.wait([ + final initialAddresses = await Future.wait([ // P2WPKH - _generateAddressForChain(0, 0, DerivePathType.bip84).then( - (initialReceivingAddressP2WPKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2WPKH, 0, DerivePathType.bip84); - _currentReceivingAddress = - Future(() => initialReceivingAddressP2WPKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip84).then( - (initialChangeAddressP2WPKH) => _addToAddressesArrayForChain( - initialChangeAddressP2WPKH, - 1, - DerivePathType.bip84, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip84), + _generateAddressForChain(1, 0, DerivePathType.bip84), // P2PKH - _generateAddressForChain(0, 0, DerivePathType.bip44).then( - (initialReceivingAddressP2PKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - _currentReceivingAddressP2PKH = - Future(() => initialReceivingAddressP2PKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip44).then( - (initialChangeAddressP2PKH) => _addToAddressesArrayForChain( - initialChangeAddressP2PKH, - 1, - DerivePathType.bip44, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip44), + _generateAddressForChain(1, 0, DerivePathType.bip44), // P2SH - _generateAddressForChain(0, 0, DerivePathType.bip49).then( - (initialReceivingAddressP2SH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2SH, 0, DerivePathType.bip49); - _currentReceivingAddressP2SH = - Future(() => initialReceivingAddressP2SH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip49).then( - (initialChangeAddressP2SH) => _addToAddressesArrayForChain( - initialChangeAddressP2SH, - 1, - DerivePathType.bip49, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip49), + _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - // // P2PKH - // _generateAddressForChain(0, 0, DerivePathType.bip44).then( - // (initialReceivingAddressP2PKH) { - // _addToAddressesArrayForChain( - // initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - // this._currentReceivingAddressP2PKH = - // Future(() => initialReceivingAddressP2PKH); - // }, - // ); - // _generateAddressForChain(1, 0, DerivePathType.bip44) - // .then((initialChangeAddressP2PKH) => _addToAddressesArrayForChain( - // initialChangeAddressP2PKH, - // 1, - // DerivePathType.bip44, - // )); - // - // // P2SH - // _generateAddressForChain(0, 0, DerivePathType.bip49).then( - // (initialReceivingAddressP2SH) { - // _addToAddressesArrayForChain( - // initialReceivingAddressP2SH, 0, DerivePathType.bip49); - // this._currentReceivingAddressP2SH = - // Future(() => initialReceivingAddressP2SH); - // }, - // ); - // _generateAddressForChain(1, 0, DerivePathType.bip49) - // .then((initialChangeAddressP2SH) => _addToAddressesArrayForChain( - // initialChangeAddressP2SH, - // 1, - // DerivePathType.bip49, - // )); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(initialAddresses); + }); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1669,7 +1505,7 @@ class BitcoinWallet extends CoinServiceAPI { /// Generates a new internal or external chain address for the wallet using a BIP84, BIP44, or BIP49 derivation path. /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! /// [index] - This can be any integer >= 0 - Future _generateAddressForChain( + Future _generateAddressForChain( int chain, int index, DerivePathType derivePathType, @@ -1687,10 +1523,12 @@ class BitcoinWallet extends CoinServiceAPI { ); final data = PaymentData(pubkey: node.publicKey); String address; + isar_models.AddressType addrType; switch (derivePathType) { case DerivePathType.bip44: address = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: address = P2SH( @@ -1699,9 +1537,11 @@ class BitcoinWallet extends CoinServiceAPI { network: _network) .data .address!; + addrType = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: address = P2WPKH(network: _network, data: data).data.address!; + addrType = isar_models.AddressType.p2wpkh; break; } @@ -1714,98 +1554,47 @@ class BitcoinWallet extends CoinServiceAPI { derivePathType: derivePathType, ); - return address; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain( - int chain, DerivePathType derivePathType) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain( - String address, int chain, DerivePathType derivePathType) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - switch (derivePathType) { - case DerivePathType.bip44: - chainArray += "P2PKH"; - break; - case DerivePathType.bip49: - chainArray += "P2SH"; - break; - case DerivePathType.bip84: - chainArray += "P2WPKH"; - break; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = node.publicKey + ..type = addrType + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// and /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! Future _getCurrentAddressForChain( - int chain, DerivePathType derivePathType) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; + int chain, + DerivePathType derivePathType, + ) async { + final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; + + isar_models.AddressType type; + isar_models.Address? address; switch (derivePathType) { case DerivePathType.bip44: - arrayKey += "P2PKH"; + type = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - arrayKey += "P2SH"; + type = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: - arrayKey += "P2WPKH"; + type = isar_models.AddressType.p2wpkh; break; } - final internalChainArray = - DB.instance.get(boxName: walletId, key: arrayKey); - return internalChainArray.last as String; + address = await isar.addresses + .filter() + .typeEqualTo(type) + .subTypeEqualTo(subType) + .sortByDerivationIndexDesc() + .findFirst(); + return address!.value; } String _buildDerivationStorageKey({ @@ -1910,8 +1699,45 @@ class BitcoinWallet extends CoinServiceAPI { await _secureStore.write(key: key, value: newReceiveDerivationsString); } - Future _fetchUtxoData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future>> fastFetch(List allTxHashes) async { + List> allTransactions = []; + + const futureLimit = 30; + List>> transactionFutures = []; + int currentFutureCount = 0; + for (final txHash in allTxHashes) { + Future> transactionFuture = + cachedElectrumXClient.getTransaction( + txHash: txHash, + verbose: true, + coin: coin, + ); + transactionFutures.add(transactionFuture); + currentFutureCount++; + if (currentFutureCount > futureLimit) { + currentFutureCount = 0; + await Future.wait(transactionFutures); + for (final fTx in transactionFutures) { + final tx = await fTx; + + allTransactions.add(tx); + } + } + } + if (currentFutureCount != 0) { + currentFutureCount = 0; + await Future.wait(transactionFutures); + for (final fTx in transactionFutures) { + final tx = await fTx; + + allTransactions.add(tx); + } + } + return allTransactions; + } + + Future _updateUTXOs() async { + final allAddresses = await _fetchAllOwnAddresses(); try { final fetchedUtxoList = >>[]; @@ -1923,7 +1749,8 @@ class BitcoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = + AddressUtils.convertToScriptHash(allAddresses[i].value, _network); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -1941,147 +1768,124 @@ class BitcoinWallet extends CoinServiceAPI { } } } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> outputArray = []; - int satoshiBalance = 0; + + final currentChainHeight = await chainHeight; + + final List outputArray = []; + int satoshiBalanceTotal = 0; int satoshiBalancePending = 0; + int satoshiBalanceSpendable = 0; + int satoshiBalanceBlocked = 0; for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - int value = fetchedUtxoList[i][j]["value"] as int; - satoshiBalance += value; - final txn = await cachedElectrumXClient.getTransaction( txHash: fetchedUtxoList[i][j]["tx_hash"] as String, verbose: true, coin: coin, ); - final Map utxo = {}; - final int confirmations = txn["confirmations"] as int? ?? 0; - final bool confirmed = confirmations >= MINIMUM_CONFIRMATIONS; - if (!confirmed) { - satoshiBalancePending += value; + final utxo = isar_models.UTXO(); + + utxo.txid = txn["txid"] as String; + utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; + utxo.value = fetchedUtxoList[i][j]["value"] as int; + utxo.name = ""; + + // todo check here if we should mark as blocked + utxo.isBlocked = false; + utxo.blockedReason = null; + + utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; + utxo.blockHash = txn["blockhash"] as String?; + utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; + utxo.blockTime = txn["blocktime"] as int?; + + satoshiBalanceTotal += utxo.value; + + if (utxo.isBlocked) { + satoshiBalanceBlocked += utxo.value; + } else { + if (utxo.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + satoshiBalanceSpendable += utxo.value; + } else { + satoshiBalancePending += utxo.value; + } } - utxo["txid"] = txn["txid"]; - utxo["vout"] = fetchedUtxoList[i][j]["tx_pos"]; - utxo["value"] = value; - - utxo["status"] = {}; - utxo["status"]["confirmed"] = confirmed; - utxo["status"]["confirmations"] = confirmations; - utxo["status"]["block_height"] = fetchedUtxoList[i][j]["height"]; - utxo["status"]["block_hash"] = txn["blockhash"]; - utxo["status"]["block_time"] = txn["blocktime"]; - - final fiatValue = ((Decimal.fromInt(value) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - utxo["rawWorth"] = fiatValue; - utxo["fiatWorth"] = fiatValue.toString(); outputArray.add(utxo); } } - Decimal currencyBalanceRaw = - ((Decimal.fromInt(satoshiBalance) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - - final Map result = { - "total_user_currency": currencyBalanceRaw.toString(), - "total_sats": satoshiBalance, - "total_btc": (Decimal.fromInt(satoshiBalance) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal( - scaleOnInfinitePrecision: Constants.decimalPlacesForCoin(coin)) - .toString(), - "outputArray": outputArray, - "unconfirmed": satoshiBalancePending, - }; - - final dataModel = UtxoData.fromJson(result); - - final List allOutputs = dataModel.unspentOutputArray; Logging.instance - .log('Outputs fetched: $allOutputs', level: LogLevel.Info); - await _sortOutputs(allOutputs); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: dataModel); - await DB.instance.put( - boxName: walletId, - key: 'totalBalance', - value: dataModel.satoshiBalance); - return dataModel; + .log('Outputs fetched: $outputArray', level: LogLevel.Info); + + await isar.writeTxn(() async { + await isar.utxos.clear(); + await isar.utxos.putAll(outputArray); + }); + + // finally update balance + _balance = Balance( + coin: coin, + total: satoshiBalanceTotal, + spendable: satoshiBalanceSpendable, + blockedTotal: satoshiBalanceBlocked, + pendingSpendable: satoshiBalancePending, + ); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); - final latestTxModel = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model') - as models.UtxoData?; - - if (latestTxModel == null) { - final emptyModel = { - "total_user_currency": "0.00", - "total_sats": 0, - "total_btc": "0", - "outputArray": [] - }; - return UtxoData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old output model located", level: LogLevel.Warning); - return latestTxModel; - } } } - /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - /// Now also checks for output labeling. - Future _sortOutputs(List utxos) async { - final blockedHashArray = - DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - as List?; - final List lst = []; - if (blockedHashArray != null) { - for (var hash in blockedHashArray) { - lst.add(hash as String); - } - } - final labels = - DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - {}; + @override + Balance get balance => _balance!; + Balance? _balance; - outputsList = []; - - for (var i = 0; i < utxos.length; i++) { - if (labels[utxos[i].txid] != null) { - utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - } else { - utxos[i].txName = 'Output #$i'; - } - - if (utxos[i].status.confirmed == false) { - outputsList.add(utxos[i]); - } else { - if (lst.contains(utxos[i].txid)) { - utxos[i].blocked = true; - outputsList.add(utxos[i]); - } else if (!lst.contains(utxos[i].txid)) { - outputsList.add(utxos[i]); - } - } - } - } + // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) + // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. + // /// Now also checks for output labeling. + // Future _sortOutputs(List utxos) async { + // final blockedHashArray = + // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') + // as List?; + // final List lst = []; + // if (blockedHashArray != null) { + // for (var hash in blockedHashArray) { + // lst.add(hash as String); + // } + // } + // final labels = + // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? + // {}; + // + // outputsList = []; + // + // for (var i = 0; i < utxos.length; i++) { + // if (labels[utxos[i].txid] != null) { + // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; + // } else { + // utxos[i].txName = 'Output #$i'; + // } + // + // if (utxos[i].status.confirmed == false) { + // outputsList.add(utxos[i]); + // } else { + // if (lst.contains(utxos[i].txid)) { + // utxos[i].blocked = true; + // outputsList.add(utxos[i]); + // } else if (!lst.contains(utxos[i].txid)) { + // outputsList.add(utxos[i]); + // } + // } + // } + // } Future getTxCount({required String address}) async { String? scripthash; try { - scripthash = _convertToScriptHash(address, _network); + scripthash = AddressUtils.convertToScriptHash(address, _network); final transactions = await electrumXClient.getHistory(scripthash: scripthash); return transactions.length; @@ -2099,7 +1903,9 @@ class BitcoinWallet extends CoinServiceAPI { try { final Map> args = {}; for (final entry in addresses.entries) { - args[entry.key] = [_convertToScriptHash(entry.value, _network)]; + args[entry.key] = [ + AddressUtils.convertToScriptHash(entry.value, _network) + ]; } final response = await electrumXClient.getBatchHistory(args: args); @@ -2116,111 +1922,65 @@ class BitcoinWallet extends CoinServiceAPI { } } - Future _checkReceivingAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkReceivingAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(0, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentReceiving = await _currentReceivingAddress; + + final int txCount = await getTxCount(address: currentReceiving.value); Logging.instance.log( - 'Number of txs for current receiving address $currentExternalAddr: $txCount', + 'Number of txs for current receiving address $currentReceiving: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the receiving index - await _incrementAddressIndexForChain(0, derivePathType); - - // Check the new receiving index - String indexKey = "receivingIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = currentReceiving.derivationIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, newReceivingIndex, derivePathType); + 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain( - newReceivingAddress, 0, derivePathType); - - // Set the new receiving address that the service - - switch (derivePathType) { - case DerivePathType.bip44: - _currentReceivingAddressP2PKH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip49: - _currentReceivingAddressP2SH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip84: - _currentReceivingAddress = Future(() => newReceivingAddress); - break; - } + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } } - Future _checkChangeAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkChangeAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(1, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentChange = await _currentChangeAddress; + final int txCount = await getTxCount(address: currentChange.value); Logging.instance.log( - 'Number of txs for current change address $currentExternalAddr: $txCount', + 'Number of txs for current change address $currentChange: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the change index - await _incrementAddressIndexForChain(1, derivePathType); - - // Check the new change index - String indexKey = "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newChangeIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newChangeIndex = currentChange.derivationIndex + 1; // Use new index to derive a new change address - final newChangeAddress = - await _generateAddressForChain(1, newChangeIndex, derivePathType); + final newChangeAddress = await _generateAddressForChain( + 1, newChangeIndex, DerivePathType.bip84); - // Add that new receiving address to the array of change addresses - await _addToAddressesArrayForChain(newChangeAddress, 1, derivePathType); + // Add that new change address + await isar.writeTxn(() async { + await isar.addresses.put(newChangeAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( - "SocketException caught in _checkReceivingAddressForTransactions($derivePathType): $se\n$s", + "SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s", level: LogLevel.Error); return; } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } @@ -2228,9 +1988,9 @@ class BitcoinWallet extends CoinServiceAPI { Future _checkCurrentReceivingAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkReceivingAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkReceivingAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentReceivingAddressesForTransactions(): $e\n$s", @@ -2252,9 +2012,9 @@ class BitcoinWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkChangeAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkChangeAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentChangeAddressesForTransactions(): $e\n$s", @@ -2274,28 +2034,6 @@ class BitcoinWallet extends CoinServiceAPI { } } - /// attempts to convert a string to a valid scripthash - /// - /// Returns the scripthash or throws an exception on invalid bitcoin address - String _convertToScriptHash(String bitcoinAddress, NetworkType network) { - try { - final output = Address.addressToOutputScript(bitcoinAddress, network); - final hash = sha256.convert(output.toList(growable: false)).toString(); - - final chars = hash.split(""); - final reversedPairs = []; - var i = chars.length - 1; - while (i > 0) { - reversedPairs.add(chars[i - 1]); - reversedPairs.add(chars[i]); - i -= 2; - } - return reversedPairs.join(""); - } catch (e) { - rethrow; - } - } - Future>> _fetchHistory( List allAddresses) async { try { @@ -2309,7 +2047,8 @@ class BitcoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = + AddressUtils.convertToScriptHash(allAddresses[i], _network); final id = Logger.isTestEnv ? "$i" : const Uuid().v1(); requestIdToAddressMap[id] = allAddresses[i]; batches[batchNumber]!.addAll({ @@ -2350,94 +2089,60 @@ class BitcoinWallet extends CoinServiceAPI { return false; } - Future>> fastFetch(List allTxHashes) async { - List> allTransactions = []; + Future _refreshTransactions() async { + final List allAddresses = + await _fetchAllOwnAddresses(); - const futureLimit = 30; - List>> transactionFutures = []; - int currentFutureCount = 0; - for (final txHash in allTxHashes) { - Future> transactionFuture = - cachedElectrumXClient.getTransaction( - txHash: txHash, - verbose: true, - coin: coin, - ); - transactionFutures.add(transactionFuture); - currentFutureCount++; - if (currentFutureCount > futureLimit) { - currentFutureCount = 0; - await Future.wait(transactionFutures); - for (final fTx in transactionFutures) { - final tx = await fTx; - - allTransactions.add(tx); - } - } - } - if (currentFutureCount != 0) { - currentFutureCount = 0; - await Future.wait(transactionFutures); - for (final fTx in transactionFutures) { - final tx = await fTx; - - allTransactions.add(tx); - } - } - return allTransactions; - } - - Future _fetchTransactionData() async { - final List allAddresses = await _fetchAllOwnAddresses(); - - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - final changeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - as List; - - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - changeAddresses.add(changeAddressesP2PKH[i] as String); - } - for (var i = 0; i < changeAddressesP2SH.length; i++) { - changeAddresses.add(changeAddressesP2SH[i] as String); - } + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // final changeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') + // as List; + // + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // changeAddresses.add(changeAddressesP2PKH[i] as String); + // } + // for (var i = 0; i < changeAddressesP2SH.length; i++) { + // changeAddresses.add(changeAddressesP2SH[i] as String); + // } final List> allTxHashes = - await _fetchHistory(allAddresses); + await _fetchHistory(allAddresses.map((e) => e.value).toList()); - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as TransactionData?; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; + // final cachedTransactions = + // DB.instance.get(boxName: walletId, key: 'latest_tx_model') + // as TransactionData?; + // int latestTxnBlockHeight = + // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") + // as int? ?? + // 0; - final unconfirmedCachedTransactions = - cachedTransactions?.getAllTransactions() ?? {}; - unconfirmedCachedTransactions - .removeWhere((key, value) => value.confirmedStatus); - - if (cachedTransactions != null) { - for (final tx in allTxHashes.toList(growable: false)) { - final txHeight = tx["height"] as int; - if (txHeight > 0 && - txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - allTxHashes.remove(tx); - } - } - } - } - - Set hashes = {}; - for (var element in allTxHashes) { - hashes.add(element['tx_hash'] as String); - } + // final unconfirmedCachedTransactions = + // cachedTransactions?.getAllTransactions() ?? {}; + // unconfirmedCachedTransactions + // .removeWhere((key, value) => value.confirmedStatus); + // + // if (cachedTransactions != null) { + // for (final tx in allTxHashes.toList(growable: false)) { + // final txHeight = tx["height"] as int; + // if (txHeight > 0 && + // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { + // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { + // allTxHashes.remove(tx); + // } + // } + // } + // } + // + // Set hashes = {}; + // for (var element in allTxHashes) { + // hashes.add(element['tx_hash'] as String); + // } + List hashes = + allTxHashes.map((e) => e['tx_hash'] as String).toList(growable: false); await fastFetch(hashes.toList()); List> allTransactions = []; @@ -2448,8 +2153,6 @@ class BitcoinWallet extends CoinServiceAPI { coin: coin, ); - // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - // TODO fix this for sent to self transactions? if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { tx["address"] = txHash["address"]; tx["height"] = txHash["height"]; @@ -2457,16 +2160,11 @@ class BitcoinWallet extends CoinServiceAPI { } } - Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); - Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); + // Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); + // Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); - Logging.instance.log("allTransactions length: ${allTransactions.length}", - level: LogLevel.Info); - - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + // Logging.instance.log("allTransactions length: ${allTransactions.length}", + // level: LogLevel.Info); Set vHashes = {}; for (final txObject in allTransactions) { @@ -2479,249 +2177,268 @@ class BitcoinWallet extends CoinServiceAPI { await fastFetch(vHashes.toList()); for (final txObject in allTransactions) { - List sendersArray = []; - List recipientsArray = []; + final txn = await parseTransaction( + txObject, + cachedElectrumXClient, + allAddresses, + coin, + MINIMUM_CONFIRMATIONS, + ); - // Usually only has value when txType = 'Send' - int inputAmtSentFromWallet = 0; - // Usually has value regardless of txType due to change addresses - int outputAmtAddressedToWallet = 0; - int fee = 0; + // final tx = await isar.transactions + // .filter() + // .txidMatches(midSortedTx.txid) + // .findFirst(); + // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar + // if (tx == null) { + await isar.writeTxn(() async { + await isar.transactions.put(txn); + }); + // } - Map midSortedTx = {}; - - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"]![i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - final address = out["scriptPubKey"]["address"] as String?; - if (address != null) { - sendersArray.add(address); - } - } - } - } - - Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["address"] as String?; - if (address != null) { - recipientsArray.add(address); - } - } - - Logging.instance - .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - - final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)); - Logging.instance - .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - - // If txType = Sent, then calculate inputAmtSentFromWallet - if (foundInSenders) { - int totalInput = 0; - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"]![i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - inputAmtSentFromWallet += - (Decimal.parse(out["value"]!.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - totalInput = inputAmtSentFromWallet; - int totalOutput = 0; - - for (final output in txObject["vout"] as List) { - final String address = output["scriptPubKey"]!["address"] as String; - final value = output["value"]!; - final _value = (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOutput += _value; - if (changeAddresses.contains(address)) { - inputAmtSentFromWallet -= _value; - } else { - // change address from 'sent from' to the 'sent to' address - txObject["address"] = address; - } - } - // calculate transaction fee - fee = totalInput - totalOutput; - // subtract fee from sent to calculate correct value of sent tx - inputAmtSentFromWallet -= fee; - } else { - // counters for fee calculation - int totalOut = 0; - int totalIn = 0; - - // add up received tx value - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["address"]; - if (address != null) { - final value = (Decimal.parse(output["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOut += value; - if (allAddresses.contains(address)) { - outputAmtAddressedToWallet += value; - } - } - } - - // calculate fee for received tx - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - totalIn += (Decimal.parse(out["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - fee = totalIn - totalOut; - } - - // create final tx map - midSortedTx["txid"] = txObject["txid"]; - midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - midSortedTx["timestamp"] = txObject["blocktime"] ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000); - - if (foundInSenders) { - midSortedTx["txType"] = "Sent"; - midSortedTx["amount"] = inputAmtSentFromWallet; - final String worthNow = - ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - } else { - midSortedTx["txType"] = "Received"; - midSortedTx["amount"] = outputAmtAddressedToWallet; - final worthNow = - ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - } - midSortedTx["aliens"] = []; - midSortedTx["fees"] = fee; - midSortedTx["address"] = txObject["address"]; - midSortedTx["inputSize"] = txObject["vin"].length; - midSortedTx["outputSize"] = txObject["vout"].length; - midSortedTx["inputs"] = txObject["vin"]; - midSortedTx["outputs"] = txObject["vout"]; - - final int height = txObject["height"] as int; - midSortedTx["height"] = height; - - if (height >= latestTxnBlockHeight) { - latestTxnBlockHeight = height; - } - - midSortedArray.add(midSortedTx); + // List sendersArray = []; + // List recipientsArray = []; + // + // // Usually only has value when txType = 'Send' + // int inputAmtSentFromWallet = 0; + // // Usually has value regardless of txType due to change addresses + // int outputAmtAddressedToWallet = 0; + // int fee = 0; + // + // Map midSortedTx = {}; + // + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"]![i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // final address = out["scriptPubKey"]["address"] as String?; + // if (address != null) { + // sendersArray.add(address); + // } + // } + // } + // } + // + // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); + // + // for (final output in txObject["vout"] as List) { + // final address = output["scriptPubKey"]["address"] as String?; + // if (address != null) { + // recipientsArray.add(address); + // } + // } + // + // Logging.instance + // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); + // + // final foundInSenders = + // allAddresses.any((element) => sendersArray.contains(element)); + // Logging.instance + // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); + // + // // If txType = Sent, then calculate inputAmtSentFromWallet + // if (foundInSenders) { + // int totalInput = 0; + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"]![i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // inputAmtSentFromWallet += + // (Decimal.parse(out["value"]!.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // totalInput = inputAmtSentFromWallet; + // int totalOutput = 0; + // + // for (final output in txObject["vout"] as List) { + // final String address = output["scriptPubKey"]!["address"] as String; + // final value = output["value"]!; + // final _value = (Decimal.parse(value.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOutput += _value; + // if (changeAddresses.contains(address)) { + // inputAmtSentFromWallet -= _value; + // } else { + // // change address from 'sent from' to the 'sent to' address + // txObject["address"] = address; + // } + // } + // // calculate transaction fee + // fee = totalInput - totalOutput; + // // subtract fee from sent to calculate correct value of sent tx + // inputAmtSentFromWallet -= fee; + // } else { + // // counters for fee calculation + // int totalOut = 0; + // int totalIn = 0; + // + // // add up received tx value + // for (final output in txObject["vout"] as List) { + // final address = output["scriptPubKey"]["address"]; + // if (address != null) { + // final value = (Decimal.parse(output["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOut += value; + // if (allAddresses.contains(address)) { + // outputAmtAddressedToWallet += value; + // } + // } + // } + // + // // calculate fee for received tx + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"][i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // totalIn += (Decimal.parse(out["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // fee = totalIn - totalOut; + // } + // + // // create final tx map + // midSortedTx["txid"] = txObject["txid"]; + // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && + // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); + // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; + // midSortedTx["timestamp"] = txObject["blocktime"] ?? + // (DateTime.now().millisecondsSinceEpoch ~/ 1000); + // + // if (foundInSenders) { + // midSortedTx["txType"] = "Sent"; + // midSortedTx["amount"] = inputAmtSentFromWallet; + // final String worthNow = + // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // midSortedTx["worthAtBlockTimestamp"] = worthNow; + // } else { + // midSortedTx["txType"] = "Received"; + // midSortedTx["amount"] = outputAmtAddressedToWallet; + // final worthNow = + // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // } + // midSortedTx["aliens"] = []; + // midSortedTx["fees"] = fee; + // midSortedTx["address"] = txObject["address"]; + // midSortedTx["inputSize"] = txObject["vin"].length; + // midSortedTx["outputSize"] = txObject["vout"].length; + // midSortedTx["inputs"] = txObject["vin"]; + // midSortedTx["outputs"] = txObject["vout"]; + // + // final int height = txObject["height"] as int; + // midSortedTx["height"] = height; + // + // if (height >= latestTxnBlockHeight) { + // latestTxnBlockHeight = height; + // } + // + // midSortedArray.add(midSortedTx); } - // sort by date ---- //TODO not sure if needed - // shouldn't be any issues with a null timestamp but I got one at some point? - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // { - // final aT = a["timestamp"]; - // final bT = b["timestamp"]; + // // sort by date ---- //TODO not sure if needed + // // shouldn't be any issues with a null timestamp but I got one at some point? + // midSortedArray + // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); + // // { + // // final aT = a["timestamp"]; + // // final bT = b["timestamp"]; + // // + // // if (aT == null && bT == null) { + // // return 0; + // // } else if (aT == null) { + // // return -1; + // // } else if (bT == null) { + // // return 1; + // // } else { + // // return bT - aT; + // // } + // // }); // - // if (aT == null && bT == null) { - // return 0; - // } else if (aT == null) { - // return -1; - // } else if (bT == null) { - // return 1; + // // buildDateTimeChunks + // 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 { - // return bT - aT; + // dateArray.add(txTimeArray[1]); + // final chunk = { + // "timestamp": txTimeArray[0], + // "transactions": [txObject], + // }; + // result["dateTimeChunks"].add(chunk); // } - // }); - - // buildDateTimeChunks - 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], - }; - result["dateTimeChunks"].add(chunk); - } - } - - final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); - - 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); - - cachedTxData = txModel; - return txModel; + // } + // + // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; + // transactionsMap + // .addAll(TransactionData.fromJson(result).getAllTransactions()); + // + // 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); + // + // cachedTxData = txModel; + // return txModel; } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2738,26 +2455,28 @@ class BitcoinWallet extends CoinServiceAPI { String _recipientAddress, bool isSendAll, { int additionalOutputs = 0, - List? utxos, + List? utxos, }) async { Logging.instance .log("Starting coinSelection ----------", level: LogLevel.Info); - final List availableOutputs = utxos ?? outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final currentChainHeight = await chainHeight; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", level: LogLevel.Info); @@ -2784,7 +2503,7 @@ class BitcoinWallet extends CoinServiceAPI { // Possible situation right here int satoshisBeingUsed = 0; int inputsBeingConsumed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; satoshisBeingUsed < satoshiAmountToSend && i < spendableOutputs.length; @@ -2902,7 +2621,7 @@ class BitcoinWallet extends CoinServiceAPI { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize == feeForTwoOutputs) { // generate new change address if current change address has been used - await _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); final String newChangeAddress = await _getCurrentAddressForChain(1, DerivePathType.bip84); @@ -3072,7 +2791,7 @@ class BitcoinWallet extends CoinServiceAPI { } Future> fetchBuildTxData( - List utxosToUse, + List utxosToUse, ) async { // return data Map results = {}; @@ -3313,7 +3032,7 @@ class BitcoinWallet extends CoinServiceAPI { /// Builds and signs a transaction Future> buildTransaction({ - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required List recipients, required List satoshiAmounts, @@ -3764,22 +3483,23 @@ class BitcoinWallet extends CoinServiceAPI { @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { - final available = - Format.decimalAmountToSatoshis(await availableBalance, coin); + final available = balance.spendable; if (available == satoshiAmount) { - return satoshiAmount - sweepAllEstimate(feeRate); + return satoshiAmount - (await sweepAllEstimate(feeRate)); } else if (satoshiAmount <= 0 || satoshiAmount > available) { return roughFeeEstimate(1, 2, feeRate); } int runningBalance = 0; int inputCount = 0; - for (final output in outputsList) { - runningBalance += output.value; - inputCount++; - if (runningBalance > satoshiAmount) { - break; + for (final output in (await utxos)) { + if (!output.isBlocked) { + runningBalance += output.value; + inputCount++; + if (runningBalance > satoshiAmount) { + break; + } } } @@ -3810,11 +3530,12 @@ class BitcoinWallet extends CoinServiceAPI { (feeRatePerKB / 1000).ceil(); } - int sweepAllEstimate(int feeRate) { + Future sweepAllEstimate(int feeRate) async { int available = 0; int inputCount = 0; - for (final output in outputsList) { - if (output.status.confirmed) { + for (final output in (await utxos)) { + if (!output.isBlocked && + output.isConfirmed(storedChainHeight, MINIMUM_CONFIRMATIONS)) { available += output.value; inputCount++; } @@ -3829,23 +3550,18 @@ class BitcoinWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - await _incrementAddressIndexForChain( - 0, DerivePathType.bip84); // First increment the receiving index - final newReceivingIndex = DB.instance.get( - boxName: walletId, - key: 'receivingIndexP2WPKH') as int; // Check the new receiving index + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, - newReceivingIndex, - DerivePathType - .bip84); // Use new index to derive a new receiving address - await _addToAddressesArrayForChain( - newReceivingAddress, - 0, - DerivePathType - .bip84); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddress = Future(() => - newReceivingAddress); // Set the new receiving address that the service + 0, newReceivingIndex, DerivePathType.bip84); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { From 25a60920dd46bf8755ffaa39c775f89b434a0f17 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 13:30:03 -0600 Subject: [PATCH 094/192] migrate bitcoincash_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/bitcoincash/bitcoincash_wallet.dart | 1786 +++++++---------- 1 file changed, 749 insertions(+), 1037 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 743822e2f..15fbca2a1 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; import 'package:bech32/bech32.dart'; import 'package:bip32/bip32.dart' as bip32; @@ -9,18 +8,16 @@ import 'package:bip39/bip39.dart' as bip39; import 'package:bitbox/bitbox.dart' as bitbox; import 'package:bitcoindart/bitcoindart.dart'; import 'package:bs58check/bs58check.dart' as bs58check; -import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/models.dart' as models; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/address/address.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; @@ -29,8 +26,8 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; +import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; @@ -43,6 +40,8 @@ import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; +import '../../../utilities/stack_file_system.dart'; + const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 546; @@ -149,70 +148,38 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - List outputsList = []; + @override + Future> get utxos => isar.utxos.where().findAll(); + + @override + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); @override Coin get coin => _coin; @override - Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - Future>? _allOwnAddresses; + Future get currentReceivingAddress async => + (await _currentReceivingAddress).value; - Future? _utxoData; - Future get utxoData => _utxoData ??= _fetchUtxoData(); + Future get _currentReceivingAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; - @override - Future> get unspentOutputs async => - (await utxoData).unspentOutputArray; + Future get currentChangeAddress async => + (await _currentChangeAddress).value; - @override - Future get availableBalance async { - final data = await utxoData; - return Format.satoshisToAmount( - data.satoshiBalance - data.satoshiBalanceUnconfirmed, - coin: coin); - } - - @override - Future get pendingBalance async { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalanceUnconfirmed, coin: coin); - } - - @override - Future get balanceMinusMaxFee async => - (await availableBalance) - - (Decimal.fromInt((await maxFee)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(); - - @override - Future get totalBalance async { - if (!isActive) { - final totalBalance = DB.instance - .get(boxName: walletId, key: 'totalBalance') as int?; - if (totalBalance == null) { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } else { - return Format.satoshisToAmount(totalBalance, coin: coin); - } - } - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } - - @override - Future get currentReceivingAddress => - _currentReceivingAddressP2PKH ??= - _getCurrentAddressForChain(0, DerivePathType.bip44); - Future? _currentReceivingAddressP2PKH; - - // Future get currentReceivingAddressP2SH => - // _currentReceivingAddressP2SH ??= - // _getCurrentAddressForChain(0, DerivePathType.bip49); - Future? _currentReceivingAddressP2SH; + Future get _currentChangeAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -220,6 +187,7 @@ class BitcoinCashWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); + await isar.close(); } bool _hasCalledExit = false; @@ -374,191 +342,14 @@ class BitcoinCashWallet extends CoinServiceAPI { level: LogLevel.Info); } - Future _recoverWalletFromBIP32SeedPhrase({ - required String mnemonic, - int maxUnusedAddressGap = 20, - int maxNumberOfIndexesToCheck = 1000, - }) async { - longMutex = true; - - Map> p2pkhReceiveDerivations = {}; - Map> p2shReceiveDerivations = {}; - Map> p2pkhChangeDerivations = {}; - Map> p2shChangeDerivations = {}; - - final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, _network)); - - List p2pkhReceiveAddressArray = []; - List p2shReceiveAddressArray = []; - int p2pkhReceiveIndex = -1; - int p2shReceiveIndex = -1; - - List p2pkhChangeAddressArray = []; - List p2shChangeAddressArray = []; - int p2pkhChangeIndex = -1; - int p2shChangeIndex = -1; - - // The gap limit will be capped at [maxUnusedAddressGap] - // int receivingGapCounter = 0; - // int changeGapCounter = 0; - - // actual size is 24 due to p2pkh and p2sh so 12x2 - const txCountBatchSize = 12; - - try { - // receiving addresses - Logging.instance - .log("checking receiving addresses...", level: LogLevel.Info); - final resultReceive44 = _checkGaps(maxNumberOfIndexesToCheck, - maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 0); - - final resultReceive49 = _checkGaps(maxNumberOfIndexesToCheck, - maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip49, 0); - - Logging.instance - .log("checking change addresses...", level: LogLevel.Info); - // change addresses - final resultChange44 = _checkGaps(maxNumberOfIndexesToCheck, - maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 1); - - final resultChange49 = _checkGaps(maxNumberOfIndexesToCheck, - maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip49, 1); - - await Future.wait( - [resultReceive44, resultReceive49, resultChange44, resultChange49]); - - p2pkhReceiveAddressArray = - (await resultReceive44)['addressArray'] as List; - p2pkhReceiveIndex = (await resultReceive44)['index'] as int; - p2pkhReceiveDerivations = (await resultReceive44)['derivations'] - as Map>; - - p2shReceiveAddressArray = - (await resultReceive49)['addressArray'] as List; - p2shReceiveIndex = (await resultReceive49)['index'] as int; - p2shReceiveDerivations = (await resultReceive49)['derivations'] - as Map>; - - p2pkhChangeAddressArray = - (await resultChange44)['addressArray'] as List; - p2pkhChangeIndex = (await resultChange44)['index'] as int; - p2pkhChangeDerivations = (await resultChange44)['derivations'] - as Map>; - - p2shChangeAddressArray = - (await resultChange49)['addressArray'] as List; - p2shChangeIndex = (await resultChange49)['index'] as int; - p2shChangeDerivations = (await resultChange49)['derivations'] - as Map>; - - // save the derivations (if any) - if (p2pkhReceiveDerivations.isNotEmpty) { - await addDerivations( - chain: 0, - derivePathType: DerivePathType.bip44, - derivationsToAdd: p2pkhReceiveDerivations); - } - if (p2shReceiveDerivations.isNotEmpty) { - await addDerivations( - chain: 0, - derivePathType: DerivePathType.bip49, - derivationsToAdd: p2shReceiveDerivations); - } - if (p2pkhChangeDerivations.isNotEmpty) { - await addDerivations( - chain: 1, - derivePathType: DerivePathType.bip44, - derivationsToAdd: p2pkhChangeDerivations); - } - if (p2shChangeDerivations.isNotEmpty) { - await addDerivations( - chain: 1, - derivePathType: DerivePathType.bip49, - derivationsToAdd: p2shChangeDerivations); - } - - // If restoring a wallet that never received any funds, then set receivingArray manually - // If we didn't do this, it'd store an empty array - if (p2pkhReceiveIndex == -1) { - final address = - await _generateAddressForChain(0, 0, DerivePathType.bip44); - p2pkhReceiveAddressArray.add(address); - p2pkhReceiveIndex = 0; - } - if (p2shReceiveIndex == -1) { - final address = - await _generateAddressForChain(0, 0, DerivePathType.bip49); - p2shReceiveAddressArray.add(address); - p2shReceiveIndex = 0; - } - - // If restoring a wallet that never sent any funds with change, then set changeArray - // manually. If we didn't do this, it'd store an empty array. - if (p2pkhChangeIndex == -1) { - final address = - await _generateAddressForChain(1, 0, DerivePathType.bip44); - p2pkhChangeAddressArray.add(address); - p2pkhChangeIndex = 0; - } - if (p2shChangeIndex == -1) { - final address = - await _generateAddressForChain(1, 0, DerivePathType.bip49); - p2shChangeAddressArray.add(address); - p2shChangeIndex = 0; - } - - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: p2pkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: p2pkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: p2shReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: p2shChangeAddressArray); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2PKH', value: p2pkhChangeIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: p2pkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: p2shReceiveIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: p2shChangeIndex); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); - - longMutex = false; - } catch (e, s) { - Logging.instance.log( - "Exception rethrown from _recoverWalletFromBIP32SeedPhrase(): $e\n$s", - level: LogLevel.Info); - - longMutex = false; - rethrow; - } - } - Future> _checkGaps( int maxNumberOfIndexesToCheck, int maxUnusedAddressGap, int txCountBatchSize, bip32.BIP32 root, DerivePathType type, - int account) async { - List addressArray = []; + int chain) async { + List addressArray = []; int returningIndex = -1; Map> derivations = {}; int gapCounter = 0; @@ -567,7 +358,7 @@ class BitcoinCashWallet extends CoinServiceAPI { index += txCountBatchSize) { List iterationsAddressArray = []; Logging.instance.log( - "index: $index, \t GapCounter $account ${type.name}: $gapCounter", + "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", level: LogLevel.Info); final _id = "k_$index"; @@ -578,35 +369,42 @@ class BitcoinCashWallet extends CoinServiceAPI { final node = await compute( getBip32NodeFromRootWrapper, Tuple4( - account, + chain, index + j, root, type, ), ); - String? address; + String addressString; + final data = PaymentData(pubkey: node.publicKey); + isar_models.AddressType addrType; switch (type) { case DerivePathType.bip44: - address = P2PKH( - data: PaymentData(pubkey: node.publicKey), - network: _network) - .data - .address!; + addressString = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - address = P2SH( + addressString = P2SH( data: PaymentData( - redeem: P2WPKH( - data: PaymentData(pubkey: node.publicKey), - network: _network) - .data), + redeem: P2WPKH(data: data, network: _network).data), network: _network) .data .address!; + addrType = isar_models.AddressType.p2sh; break; default: throw Exception("No Path type $type exists"); } + + final address = isar_models.Address() + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = addrType + ..publicKey = node.publicKey + ..value = addressString + ..derivationIndex = index + j; + receivingNodes.addAll({ "${_id}_$j": { "node": node, @@ -614,7 +412,7 @@ class BitcoinCashWallet extends CoinServiceAPI { } }); txCountCallArgs.addAll({ - "${_id}_$j": address, + "${_id}_$j": addressString, }); } @@ -628,9 +426,10 @@ class BitcoinCashWallet extends CoinServiceAPI { int count = counts["${_id}_$k"]!; if (count > 0) { final node = receivingNodes["${_id}_$k"]; + final address = node["address"] as isar_models.Address; // add address to array - addressArray.add(node["address"] as String); - iterationsAddressArray.add(node["address"] as String); + addressArray.add(address); + iterationsAddressArray.add(address.value); // set current index returningIndex = index + k; // reset counter @@ -678,6 +477,166 @@ class BitcoinCashWallet extends CoinServiceAPI { } } + Future _recoverWalletFromBIP32SeedPhrase({ + required String mnemonic, + int maxUnusedAddressGap = 20, + int maxNumberOfIndexesToCheck = 1000, + }) async { + longMutex = true; + + Map> p2pkhReceiveDerivations = {}; + Map> p2shReceiveDerivations = {}; + Map> p2pkhChangeDerivations = {}; + Map> p2shChangeDerivations = {}; + + final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, _network)); + + List p2pkhReceiveAddressArray = []; + List p2shReceiveAddressArray = []; + int p2pkhReceiveIndex = -1; + int p2shReceiveIndex = -1; + + List p2pkhChangeAddressArray = []; + List p2shChangeAddressArray = []; + int p2pkhChangeIndex = -1; + int p2shChangeIndex = -1; + + // The gap limit will be capped at [maxUnusedAddressGap] + // int receivingGapCounter = 0; + // int changeGapCounter = 0; + + // actual size is 24 due to p2pkh and p2sh so 12x2 + const txCountBatchSize = 12; + + try { + // receiving addresses + Logging.instance + .log("checking receiving addresses...", level: LogLevel.Info); + final resultReceive44 = _checkGaps(maxNumberOfIndexesToCheck, + maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 0); + + final resultReceive49 = _checkGaps(maxNumberOfIndexesToCheck, + maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip49, 0); + + Logging.instance + .log("checking change addresses...", level: LogLevel.Info); + // change addresses + final resultChange44 = _checkGaps(maxNumberOfIndexesToCheck, + maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 1); + + final resultChange49 = _checkGaps(maxNumberOfIndexesToCheck, + maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip49, 1); + + await Future.wait([ + resultReceive44, + resultReceive49, + resultChange44, + resultChange49, + ]); + + p2pkhReceiveAddressArray = + (await resultReceive44)['addressArray'] as List; + p2pkhReceiveIndex = (await resultReceive44)['index'] as int; + p2pkhReceiveDerivations = (await resultReceive44)['derivations'] + as Map>; + + p2shReceiveAddressArray = + (await resultReceive49)['addressArray'] as List; + p2shReceiveIndex = (await resultReceive49)['index'] as int; + p2shReceiveDerivations = (await resultReceive49)['derivations'] + as Map>; + + p2pkhChangeAddressArray = + (await resultChange44)['addressArray'] as List; + p2pkhChangeIndex = (await resultChange44)['index'] as int; + p2pkhChangeDerivations = (await resultChange44)['derivations'] + as Map>; + + p2shChangeAddressArray = + (await resultChange49)['addressArray'] as List; + p2shChangeIndex = (await resultChange49)['index'] as int; + p2shChangeDerivations = (await resultChange49)['derivations'] + as Map>; + + // save the derivations (if any) + if (p2pkhReceiveDerivations.isNotEmpty) { + await addDerivations( + chain: 0, + derivePathType: DerivePathType.bip44, + derivationsToAdd: p2pkhReceiveDerivations); + } + if (p2shReceiveDerivations.isNotEmpty) { + await addDerivations( + chain: 0, + derivePathType: DerivePathType.bip49, + derivationsToAdd: p2shReceiveDerivations); + } + if (p2pkhChangeDerivations.isNotEmpty) { + await addDerivations( + chain: 1, + derivePathType: DerivePathType.bip44, + derivationsToAdd: p2pkhChangeDerivations); + } + if (p2shChangeDerivations.isNotEmpty) { + await addDerivations( + chain: 1, + derivePathType: DerivePathType.bip49, + derivationsToAdd: p2shChangeDerivations); + } + + // If restoring a wallet that never received any funds, then set receivingArray manually + // If we didn't do this, it'd store an empty array + if (p2pkhReceiveIndex == -1) { + final address = + await _generateAddressForChain(0, 0, DerivePathType.bip44); + p2pkhReceiveAddressArray.add(address); + } + if (p2shReceiveIndex == -1) { + final address = + await _generateAddressForChain(0, 0, DerivePathType.bip49); + p2shReceiveAddressArray.add(address); + } + + // If restoring a wallet that never sent any funds with change, then set changeArray + // manually. If we didn't do this, it'd store an empty array. + if (p2pkhChangeIndex == -1) { + final address = + await _generateAddressForChain(1, 0, DerivePathType.bip44); + p2pkhChangeAddressArray.add(address); + } + if (p2shChangeIndex == -1) { + final address = + await _generateAddressForChain(1, 0, DerivePathType.bip49); + p2shChangeAddressArray.add(address); + } + + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(p2pkhReceiveAddressArray); + await isar.addresses.putAll(p2pkhChangeAddressArray); + await isar.addresses.putAll(p2shReceiveAddressArray); + await isar.addresses.putAll(p2shChangeAddressArray); + }); + + await _updateUTXOs(); + + await DB.instance + .put(boxName: walletId, key: "id", value: _walletId); + await DB.instance + .put(boxName: walletId, key: "isFavorite", value: false); + + longMutex = false; + } catch (e, s) { + Logging.instance.log( + "Exception rethrown from _recoverWalletFromBIP32SeedPhrase(): $e\n$s", + level: LogLevel.Info); + + longMutex = false; + rethrow; + } + } + Future refreshIfThereIsNewData() async { if (longMutex) return false; if (_hasCalledExit) return false; @@ -709,11 +668,14 @@ class BitcoinCashWallet extends CoinServiceAPI { } if (!needsRefresh) { var allOwnAddresses = await _fetchAllOwnAddresses(); - List> allTxs = - await _fetchHistory(allOwnAddresses); - final txData = await transactionData; + List> allTxs = await _fetchHistory( + allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { - if (txData.findTransaction(transaction['tx_hash'] as String) == + final txid = transaction['tx_hash'] as String; + if ((await isar.transactions + .filter() + .txidMatches(txid) + .findFirst()) == null) { Logging.instance.log( " txid not found in address history already ${transaction['tx_hash']}", @@ -732,17 +694,25 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - Future getAllTxsToWatch( - TransactionData txData, - ) async { + Future getAllTxsToWatch() async { if (_hasCalledExit) return; - List unconfirmedTxnsToNotifyPending = []; - List unconfirmedTxnsToNotifyConfirmed = []; + List unconfirmedTxnsToNotifyPending = []; + List unconfirmedTxnsToNotifyConfirmed = []; - // Get all unconfirmed incoming transactions - for (final chunk in txData.txChunks) { - for (final tx in chunk.transactions) { - if (tx.confirmedStatus) { + final currentChainHeight = await chainHeight; + + final txCount = await isar.transactions.count(); + + const paginateLimit = 50; + + for (int i = 0; i < txCount; i += paginateLimit) { + final transactions = await isar.transactions + .where() + .offset(i) + .limit(paginateLimit) + .findAll(); + for (final tx in transactions) { + if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { if (txTracker.wasNotifiedPending(tx.txid) && !txTracker.wasNotifiedConfirmed(tx.txid)) { unconfirmedTxnsToNotifyConfirmed.add(tx); @@ -757,7 +727,9 @@ class BitcoinCashWallet extends CoinServiceAPI { // notify on new incoming transaction for (final tx in unconfirmedTxnsToNotifyPending) { - if (tx.txType == "Received") { + final confirmations = tx.getConfirmations(currentChainHeight); + + if (tx.type == isar_models.TransactionType.incoming) { unawaited( NotificationApi.showNotification( title: "Incoming transaction", @@ -765,15 +737,15 @@ class BitcoinCashWallet extends CoinServiceAPI { walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.now(), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, ), ); await txTracker.addNotifiedPending(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited( NotificationApi.showNotification( title: "Sending transaction", @@ -781,10 +753,10 @@ class BitcoinCashWallet extends CoinServiceAPI { walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, ), ); @@ -794,7 +766,7 @@ class BitcoinCashWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { - if (tx.txType == "Received") { + if (tx.type == isar_models.TransactionType.incoming) { unawaited( NotificationApi.showNotification( title: "Incoming transaction confirmed", @@ -808,7 +780,7 @@ class BitcoinCashWallet extends CoinServiceAPI { ); await txTracker.addNotifiedConfirmed(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited( NotificationApi.showNotification( title: "Outgoing transaction confirmed", @@ -887,30 +859,30 @@ class BitcoinCashWallet extends CoinServiceAPI { } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - await _checkChangeAddressForTransactions(DerivePathType.bip44); + await _checkChangeAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); await _checkCurrentReceivingAddressesForTransactions(); - final newTxData = _fetchTransactionData(); + final fetchFuture = _refreshTransactions(); + final utxosRefreshFuture = _updateUTXOs(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); - final newUtxoData = _fetchUtxoData(); final feeObj = _getFees(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.60, walletId)); - _transactionData = Future(() => newTxData); - GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.70, walletId)); _feeObject = Future(() => feeObj); - _utxoData = Future(() => newUtxoData); + + await utxosRefreshFuture; GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); - await getAllTxsToWatch(await newTxData); + await fetchFuture; + await getAllTxsToWatch(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.90, walletId)); } @@ -991,9 +963,7 @@ class BitcoinCashWallet extends CoinServiceAPI { } // check for send all bool isSendAll = false; - final balance = - Format.decimalAmountToSatoshis(await availableBalance, coin); - if (satoshiAmount == balance) { + if (satoshiAmount == balance.spendable) { isSendAll = true; } @@ -1053,24 +1023,6 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - final txData = await prepareSend( - address: toAddress, satoshiAmount: amount, args: args); - final txHash = await confirmSend(txData: txData); - return txHash; - } catch (e, s) { - Logging.instance - .log("Exception rethrown from send(): $e\n$s", level: LogLevel.Error); - rethrow; - } - } - @override Future testNetworkConnection() async { try { @@ -1142,6 +1094,22 @@ class BitcoinCashWallet extends CoinServiceAPI { ]); } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1151,67 +1119,56 @@ class BitcoinCashWallet extends CoinServiceAPI { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } + await _prefs.init(); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); } - @override - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - Future? _transactionData; - - TransactionData? cachedTxData; - // hack to add tx to txData before refresh completes // required based on current app architecture where we don't properly store // transactions locally in a good way @override Future updateSentCachedTxData(Map txData) async { - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = - Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final String worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - - final tx = models.Transaction( - txid: txData["txid"] as String, - confirmedStatus: false, - timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, - txType: "Sent", - amount: txData["recipientAmt"] as int, - worthNow: worthNow, - worthAtBlockTimestamp: worthNow, - fees: txData["fee"] as int, - inputSize: 0, - outputSize: 0, - inputs: [], - outputs: [], - address: txData["address"] as String, - height: -1, - confirmations: 0, - ); - - if (cachedTxData == null) { - final data = await _fetchTransactionData(); - _transactionData = Future(() => data); - } - - final transactions = cachedTxData!.getAllTransactions(); - transactions[tx.txid] = tx; - cachedTxData = models.TransactionData.fromMap(transactions); - _transactionData = Future(() => cachedTxData!); + // final priceData = + // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); + // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final String worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // + // final tx = models.Transaction( + // txid: txData["txid"] as String, + // confirmedStatus: false, + // timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // txType: "Sent", + // amount: txData["recipientAmt"] as int, + // worthNow: worthNow, + // worthAtBlockTimestamp: worthNow, + // fees: txData["fee"] as int, + // inputSize: 0, + // outputSize: 0, + // inputs: [], + // outputs: [], + // address: txData["address"] as String, + // height: -1, + // confirmations: 0, + // ); + // + // if (cachedTxData == null) { + // final data = await _fetchTransactionData(); + // _transactionData = Future(() => data); + // } + // + // final transactions = cachedTxData!.getAllTransactions(); + // transactions[tx.txid] = tx; + // cachedTxData = models.TransactionData.fromMap(transactions); + // _transactionData = Future(() => cachedTxData!); } bool validateCashAddr(String cashAddr) { @@ -1268,7 +1225,7 @@ class BitcoinCashWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; + late Isar isar; BitcoinCashWallet({ required String walletId, @@ -1277,7 +1234,6 @@ class BitcoinCashWallet extends CoinServiceAPI { required ElectrumX client, required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, - PriceAPI? priceAPI, required SecureStorageInterface secureStore, }) { txTracker = tracker; @@ -1286,8 +1242,6 @@ class BitcoinCashWallet extends CoinServiceAPI { _coin = coin; _electrumXClient = client; _cachedElectrumXClient = cachedClient; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; } @@ -1344,35 +1298,24 @@ class BitcoinCashWallet extends CoinServiceAPI { ); } - Future> _fetchAllOwnAddresses() async { - final List allAddresses = []; + Future> _fetchAllOwnAddresses() async { + final allAddresses = await isar.addresses + .filter() + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change) + .findAll(); - final receivingAddressesP2PKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2PKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - - // for (var i = 0; i < receivingAddresses.length; i++) { - // if (!allAddresses.contains(receivingAddresses[i])) { - // allAddresses.add(receivingAddresses[i]); + // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2PKH[i])) { + // allAddresses.add(receivingAddressesP2PKH[i] as String); // } // } - // for (var i = 0; i < changeAddresses.length; i++) { - // if (!allAddresses.contains(changeAddresses[i])) { - // allAddresses.add(changeAddresses[i]); + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2PKH[i])) { + // allAddresses.add(changeAddressesP2PKH[i] as String); // } // } - for (var i = 0; i < receivingAddressesP2PKH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2PKH[i])) { - allAddresses.add(receivingAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - if (!allAddresses.contains(changeAddressesP2PKH[i])) { - allAddresses.add(changeAddressesP2PKH[i] as String); - } - } return allAddresses; } @@ -1441,20 +1384,6 @@ class BitcoinCashWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2SH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2SH", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -1462,31 +1391,21 @@ class BitcoinCashWallet extends CoinServiceAPI { value: {}); // Generate and add addresses to relevant arrays - final initialReceivingAddressP2PKH = - await _generateAddressForChain(0, 0, DerivePathType.bip44); - final initialChangeAddressP2PKH = - await _generateAddressForChain(1, 0, DerivePathType.bip44); + final initialAddresses = await Future.wait([ + // P2PKH + _generateAddressForChain(0, 0, DerivePathType.bip44), + _generateAddressForChain(1, 0, DerivePathType.bip44), - final initialReceivingAddressP2SH = - await _generateAddressForChain(0, 0, DerivePathType.bip49); - final initialChangeAddressP2SH = - await _generateAddressForChain(1, 0, DerivePathType.bip49); + // P2SH + _generateAddressForChain(0, 0, DerivePathType.bip49), + _generateAddressForChain(1, 0, DerivePathType.bip49), + ]); - await _addToAddressesArrayForChain( - initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - await _addToAddressesArrayForChain( - initialChangeAddressP2PKH, 1, DerivePathType.bip44); + await _isarInit(); - await _addToAddressesArrayForChain( - initialReceivingAddressP2SH, 0, DerivePathType.bip49); - await _addToAddressesArrayForChain( - initialChangeAddressP2SH, 1, DerivePathType.bip49); - - // this._currentReceivingAddress = Future(() => initialReceivingAddress); - - var newaddr = await _getCurrentAddressForChain(0, DerivePathType.bip44); - _currentReceivingAddressP2PKH = Future(() => newaddr); - _currentReceivingAddressP2SH = Future(() => initialReceivingAddressP2SH); + await isar.writeTxn(() async { + await isar.addresses.putAll(initialAddresses); + }); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1494,7 +1413,7 @@ class BitcoinCashWallet extends CoinServiceAPI { /// Generates a new internal or external chain address for the wallet using a BIP44 or BIP49 derivation path. /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! /// [index] - This can be any integer >= 0 - Future _generateAddressForChain( + Future _generateAddressForChain( int chain, int index, DerivePathType derivePathType, @@ -1511,18 +1430,20 @@ class BitcoinCashWallet extends CoinServiceAPI { ), ); final data = PaymentData(pubkey: node.publicKey); - final p2shData = PaymentData( - redeem: - P2WPKH(data: PaymentData(pubkey: node.publicKey), network: _network) - .data); + final p2shData = + PaymentData(redeem: P2WPKH(data: data, network: _network).data); + String address; + isar_models.AddressType addrType; switch (derivePathType) { case DerivePathType.bip44: address = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: address = P2SH(data: p2shData, network: _network).data.address!; + addrType = isar_models.AddressType.p2sh; break; // default: // // should never hit this due to all enum cases handled @@ -1538,103 +1459,50 @@ class BitcoinCashWallet extends CoinServiceAPI { derivePathType: derivePathType, ); - return address; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain( - int chain, DerivePathType derivePathType) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - } - - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain( - String address, int chain, DerivePathType derivePathType) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - switch (derivePathType) { - case DerivePathType.bip44: - chainArray += "P2PKH"; - break; - case DerivePathType.bip49: - chainArray += "P2SH"; - break; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = node.publicKey + ..type = addrType + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// and /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! Future _getCurrentAddressForChain( - int chain, DerivePathType derivePathType) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; + int chain, + DerivePathType derivePathType, + ) async { + final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; + + isar_models.AddressType type; switch (derivePathType) { case DerivePathType.bip44: - arrayKey += "P2PKH"; + type = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - arrayKey += "P2SH"; + type = isar_models.AddressType.p2sh; break; } - if (kDebugMode) { - print("Array key is ${jsonEncode(arrayKey)}"); - } - final internalChainArray = - DB.instance.get(boxName: walletId, key: arrayKey); - if (derivePathType == DerivePathType.bip44) { - if (bitbox.Address.detectFormat(internalChainArray.last as String) == - bitbox.Address.formatLegacy) { - return bitbox.Address.toCashAddress(internalChainArray.last as String); - } - } - return internalChainArray.last as String; + final address = await isar.addresses + .filter() + .typeEqualTo(type) + .subTypeEqualTo(subType) + .sortByDerivationIndexDesc() + .findFirst(); + return address!.value; } - String _buildDerivationStorageKey( - {required int chain, required DerivePathType derivePathType}) { + String _buildDerivationStorageKey({ + required int chain, + required DerivePathType derivePathType, + }) { String key; String chainId = chain == 0 ? "receive" : "change"; switch (derivePathType) { @@ -1728,8 +1596,8 @@ class BitcoinCashWallet extends CoinServiceAPI { await _secureStore.write(key: key, value: newReceiveDerivationsString); } - Future _fetchUtxoData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future _updateUTXOs() async { + final allAddresses = await _fetchAllOwnAddresses(); try { final fetchedUtxoList = >>[]; @@ -1741,7 +1609,8 @@ class BitcoinCashWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = + _convertToScriptHash(allAddresses[i].value, _network); if (kDebugMode) { print("SCRIPT_HASH_FOR_ADDRESS ${allAddresses[i]} IS $scripthash"); } @@ -1763,143 +1632,118 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> outputArray = []; - int satoshiBalance = 0; + final currentChainHeight = await chainHeight; + + final List outputArray = []; + int satoshiBalanceTotal = 0; int satoshiBalancePending = 0; + int satoshiBalanceSpendable = 0; + int satoshiBalanceBlocked = 0; for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - int value = fetchedUtxoList[i][j]["value"] as int; - satoshiBalance += value; - final txn = await cachedElectrumXClient.getTransaction( txHash: fetchedUtxoList[i][j]["tx_hash"] as String, verbose: true, coin: coin, ); - final Map utxo = {}; - final int confirmations = txn["confirmations"] as int? ?? 0; - final bool confirmed = txn["confirmations"] == null - ? false - : txn["confirmations"] as int >= MINIMUM_CONFIRMATIONS; - if (!confirmed) { - satoshiBalancePending += value; + final utxo = isar_models.UTXO(); + + utxo.txid = txn["txid"] as String; + utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; + utxo.value = fetchedUtxoList[i][j]["value"] as int; + utxo.name = ""; + + // todo check here if we should mark as blocked + utxo.isBlocked = false; + utxo.blockedReason = null; + + utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; + utxo.blockHash = txn["blockhash"] as String?; + utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; + utxo.blockTime = txn["blocktime"] as int?; + + satoshiBalanceTotal += utxo.value; + + if (utxo.isBlocked) { + satoshiBalanceBlocked += utxo.value; + } else { + if (utxo.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + satoshiBalanceSpendable += utxo.value; + } else { + satoshiBalancePending += utxo.value; + } } - utxo["txid"] = txn["txid"]; - utxo["vout"] = fetchedUtxoList[i][j]["tx_pos"]; - utxo["value"] = value; - - utxo["status"] = {}; - utxo["status"]["confirmed"] = confirmed; - utxo["status"]["confirmations"] = confirmations; - utxo["status"]["block_height"] = fetchedUtxoList[i][j]["height"]; - utxo["status"]["block_hash"] = txn["blockhash"]; - utxo["status"]["block_time"] = txn["blocktime"]; - - final fiatValue = ((Decimal.fromInt(value) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - utxo["rawWorth"] = fiatValue; - utxo["fiatWorth"] = fiatValue.toString(); outputArray.add(utxo); } } - Decimal currencyBalanceRaw = - ((Decimal.fromInt(satoshiBalance) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - - final Map result = { - "total_user_currency": currencyBalanceRaw.toString(), - "total_sats": satoshiBalance, - "total_btc": (Decimal.fromInt(satoshiBalance) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal( - scaleOnInfinitePrecision: Constants.decimalPlacesForCoin(coin)) - .toString(), - "outputArray": outputArray, - "unconfirmed": satoshiBalancePending, - }; - - final dataModel = UtxoData.fromJson(result); - - final List allOutputs = dataModel.unspentOutputArray; Logging.instance - .log('Outputs fetched: $allOutputs', level: LogLevel.Info); - await _sortOutputs(allOutputs); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: dataModel); - await DB.instance.put( - boxName: walletId, - key: 'totalBalance', - value: dataModel.satoshiBalance); - return dataModel; + .log('Outputs fetched: $outputArray', level: LogLevel.Info); + + await isar.writeTxn(() async { + await isar.utxos.clear(); + await isar.utxos.putAll(outputArray); + }); + + // finally update balance + _balance = Balance( + coin: coin, + total: satoshiBalanceTotal, + spendable: satoshiBalanceSpendable, + blockedTotal: satoshiBalanceBlocked, + pendingSpendable: satoshiBalancePending, + ); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); - final latestTxModel = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - - if (latestTxModel == null) { - final emptyModel = { - "total_user_currency": "0.00", - "total_sats": 0, - "total_btc": "0", - "outputArray": [] - }; - return UtxoData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old output model located", level: LogLevel.Warning); - return latestTxModel as models.UtxoData; - } } } - /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - /// Now also checks for output labeling. - Future _sortOutputs(List utxos) async { - final blockedHashArray = - DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - as List?; - final List lst = []; - if (blockedHashArray != null) { - for (var hash in blockedHashArray) { - lst.add(hash as String); - } - } - final labels = - DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - {}; + @override + Balance get balance => _balance!; + Balance? _balance; - outputsList = []; - - for (var i = 0; i < utxos.length; i++) { - if (labels[utxos[i].txid] != null) { - utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - } else { - utxos[i].txName = 'Output #$i'; - } - - if (utxos[i].status.confirmed == false) { - outputsList.add(utxos[i]); - } else { - if (lst.contains(utxos[i].txid)) { - utxos[i].blocked = true; - outputsList.add(utxos[i]); - } else if (!lst.contains(utxos[i].txid)) { - outputsList.add(utxos[i]); - } - } - } - } + // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) + // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. + // /// Now also checks for output labeling. + // Future _sortOutputs(List utxos) async { + // final blockedHashArray = + // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') + // as List?; + // final List lst = []; + // if (blockedHashArray != null) { + // for (var hash in blockedHashArray) { + // lst.add(hash as String); + // } + // } + // final labels = + // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? + // {}; + // + // outputsList = []; + // + // for (var i = 0; i < utxos.length; i++) { + // if (labels[utxos[i].txid] != null) { + // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; + // } else { + // utxos[i].txName = 'Output #$i'; + // } + // + // if (utxos[i].status.confirmed == false) { + // outputsList.add(utxos[i]); + // } else { + // if (lst.contains(utxos[i].txid)) { + // utxos[i].blocked = true; + // outputsList.add(utxos[i]); + // } else if (!lst.contains(utxos[i].txid)) { + // outputsList.add(utxos[i]); + // } + // } + // } + // } Future getTxCount({required String address}) async { String? scripthash; @@ -1952,102 +1796,70 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - Future _checkReceivingAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkReceivingAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(0, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentReceiving = await _currentReceivingAddress; + + final int txCount = await getTxCount(address: currentReceiving.value); Logging.instance.log( - 'Number of txs for current receiving address $currentExternalAddr: $txCount', + 'Number of txs for current receiving address $currentReceiving: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the receiving index - await _incrementAddressIndexForChain(0, derivePathType); - - // Check the new receiving index - String indexKey = "receivingIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - } - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = currentReceiving.derivationIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, newReceivingIndex, derivePathType); + 0, newReceivingIndex, DerivePathType.bip44); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain( - newReceivingAddress, 0, derivePathType); - - // Set the new receiving address that the service - - switch (derivePathType) { - case DerivePathType.bip44: - _currentReceivingAddressP2PKH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip49: - _currentReceivingAddressP2SH = Future(() => newReceivingAddress); - break; - } + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( - "SocketException caught in _checkReceivingAddressForTransactions($derivePathType): $se\n$s", + "SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $se\n$s", level: LogLevel.Error); return; } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $e\n$s", level: LogLevel.Error); rethrow; } } - Future _checkChangeAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkChangeAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(1, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentChange = await _currentChangeAddress; + final int txCount = await getTxCount(address: currentChange.value); Logging.instance.log( - 'Number of txs for current change address $currentExternalAddr: $txCount', + 'Number of txs for current change address $currentChange: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the change index - await _incrementAddressIndexForChain(1, derivePathType); - - // Check the new change index - String indexKey = "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - } - final newChangeIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newChangeIndex = currentChange.derivationIndex + 1; // Use new index to derive a new change address - final newChangeAddress = - await _generateAddressForChain(1, newChangeIndex, derivePathType); + final newChangeAddress = await _generateAddressForChain( + 1, newChangeIndex, DerivePathType.bip44); - // Add that new receiving address to the array of change addresses - await _addToAddressesArrayForChain(newChangeAddress, 1, derivePathType); + // Add that new change address + await isar.writeTxn(() async { + await isar.addresses.put(newChangeAddress); + }); } + } on SocketException catch (se, s) { + Logging.instance.log( + "SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $se\n$s", + level: LogLevel.Error); + return; } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkChangeAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip44}): $e\n$s", level: LogLevel.Error); rethrow; } @@ -2055,9 +1867,9 @@ class BitcoinCashWallet extends CoinServiceAPI { Future _checkCurrentReceivingAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkReceivingAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkReceivingAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentReceivingAddressesForTransactions(): $e\n$s", @@ -2079,9 +1891,9 @@ class BitcoinCashWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkChangeAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkChangeAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentChangeAddressesForTransactions(): $e\n$s", @@ -2111,18 +1923,7 @@ class BitcoinCashWallet extends CoinServiceAPI { validateCashAddr(bchAddress)) { bchAddress = bitbox.Address.toLegacyAddress(bchAddress); } - final output = Address.addressToOutputScript(bchAddress, network); - final hash = sha256.convert(output.toList(growable: false)).toString(); - - final chars = hash.split(""); - final reversedPairs = []; - var i = chars.length - 1; - while (i > 0) { - reversedPairs.add(chars[i - 1]); - reversedPairs.add(chars[i]); - i -= 2; - } - return reversedPairs.join(""); + return AddressUtils.convertToScriptHash(bchAddress, network); } catch (e) { rethrow; } @@ -2182,74 +1983,74 @@ class BitcoinCashWallet extends CoinServiceAPI { return false; } - Future _fetchTransactionData() async { - List allAddressesOld = await _fetchAllOwnAddresses(); - List allAddresses = []; - for (String address in allAddressesOld) { - if (bitbox.Address.detectFormat(address) == bitbox.Address.formatLegacy && - addressType(address: address) == DerivePathType.bip44) { - allAddresses.add(bitbox.Address.toCashAddress(address)); - } else { - allAddresses.add(address); - } - } + Future _refreshTransactions() async { + List allAddressesOld = await _fetchAllOwnAddresses(); - var changeAddressesP2PKHOld = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - List changeAddressesP2PKH = []; - for (var address in changeAddressesP2PKHOld) { - if (bitbox.Address.detectFormat(address as String) == - bitbox.Address.formatLegacy) { - changeAddressesP2PKH.add(bitbox.Address.toCashAddress(address)); + Set receivingAddresses = allAddressesOld + .where((e) => e.subType == isar_models.AddressSubType.receiving) + .map((e) { + if (bitbox.Address.detectFormat(e.value) == bitbox.Address.formatLegacy && + addressType(address: e.value) == DerivePathType.bip44) { + return bitbox.Address.toCashAddress(e.value); } else { - changeAddressesP2PKH.add(address); + return e.value; } - } + }).toSet(); + + Set changeAddresses = allAddressesOld + .where((e) => e.subType == isar_models.AddressSubType.change) + .map((e) { + if (bitbox.Address.detectFormat(e.value) == bitbox.Address.formatLegacy && + addressType(address: e.value) == DerivePathType.bip44) { + return bitbox.Address.toCashAddress(e.value); + } else { + return e.value; + } + }).toSet(); final List> allTxHashes = - await _fetchHistory(allAddresses); + await _fetchHistory([...receivingAddresses, ...changeAddresses]); - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as TransactionData?; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; + // final cachedTransactions = + // DB.instance.get(boxName: walletId, key: 'latest_tx_model') + // as TransactionData?; + // int latestTxnBlockHeight = + // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") + // as int? ?? + // 0; - final unconfirmedCachedTransactions = - cachedTransactions?.getAllTransactions() ?? {}; - unconfirmedCachedTransactions - .removeWhere((key, value) => value.confirmedStatus); + // final unconfirmedCachedTransactions = + // cachedTransactions?.getAllTransactions() ?? {}; + // unconfirmedCachedTransactions + // .removeWhere((key, value) => value.confirmedStatus); - if (kDebugMode) { - print("CACHED_TRANSACTIONS_IS $cachedTransactions"); - } - if (cachedTransactions != null) { - for (final tx in allTxHashes.toList(growable: false)) { - final txHeight = tx["height"] as int; - if (txHeight > 0 && - txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - if (kDebugMode) { - print( - cachedTransactions.findTransaction(tx["tx_hash"] as String)); - print(unconfirmedCachedTransactions[tx["tx_hash"] as String]); - } - final cachedTx = - cachedTransactions.findTransaction(tx["tx_hash"] as String); - if (!(cachedTx != null && - addressType(address: cachedTx.address) == - DerivePathType.bip44 && - bitbox.Address.detectFormat(cachedTx.address) == - bitbox.Address.formatLegacy)) { - allTxHashes.remove(tx); - } - } - } - } - } + // if (kDebugMode) { + // print("CACHED_TRANSACTIONS_IS $cachedTransactions"); + // } + // if (cachedTransactions != null) { + // for (final tx in allTxHashes.toList(growable: false)) { + // final txHeight = tx["height"] as int; + // if (txHeight > 0 && + // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { + // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { + // if (kDebugMode) { + // print( + // cachedTransactions.findTransaction(tx["tx_hash"] as String)); + // print(unconfirmedCachedTransactions[tx["tx_hash"] as String]); + // } + // final cachedTx = + // cachedTransactions.findTransaction(tx["tx_hash"] as String); + // if (!(cachedTx != null && + // addressType(address: cachedTx.address) == + // DerivePathType.bip44 && + // bitbox.Address.detectFormat(cachedTx.address) == + // bitbox.Address.formatLegacy)) { + // allTxHashes.remove(tx); + // } + // } + // } + // } + // } List> allTransactions = []; @@ -2261,269 +2062,177 @@ class BitcoinCashWallet extends CoinServiceAPI { ); // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - // TODO fix this for sent to self transactions? if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { tx["address"] = txHash["address"]; tx["height"] = txHash["height"]; allTransactions.add(tx); } } + // + // Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); + // Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); + // + // Logging.instance.log("allTransactions length: ${allTransactions.length}", + // level: LogLevel.Info); - Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); - Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); + final List txns = []; - Logging.instance.log("allTransactions length: ${allTransactions.length}", - level: LogLevel.Info); + for (final txData in allTransactions) { + Set inputAddresses = {}; + Set outputAddresses = {}; - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + int totalInputValue = 0; + int totalOutputValue = 0; - for (final txObject in allTransactions) { - List sendersArray = []; - List recipientsArray = []; + int amountSentFromWallet = 0; + int amountReceivedInWallet = 0; + int changeAmount = 0; - // Usually only has value when txType = 'Send' - int inputAmtSentFromWallet = 0; - // Usually has value regardless of txType due to change addresses - int outputAmtAddressedToWallet = 0; - int fee = 0; - - Map midSortedTx = {}; - - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; + // parse inputs + for (final input in txData["vin"] as List) { final prevTxid = input["txid"] as String; final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, coin: coin); + // fetch input tx to get address + final inputTx = await cachedElectrumXClient.getTransaction( + txHash: prevTxid, + coin: coin, + ); + + for (final output in inputTx["vout"] as List) { + // check matching output + if (prevOut == output["n"]) { + // get value + final value = Format.decimalAmountToSatoshis( + Decimal.parse(output["value"].toString()), + coin, + ); + + // add value to total + totalInputValue += value; + + // get input(prevOut) address + final address = + output["scriptPubKey"]?["addresses"]?[0] as String? ?? + output["scriptPubKey"]?["address"] as String?; - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - final address = out["scriptPubKey"]["addresses"][0] as String?; if (address != null) { - sendersArray.add(address); + inputAddresses.add(address); + + // if input was from my wallet, add value to amount sent + if (receivingAddresses.contains(address) || + changeAddresses.contains(address)) { + amountSentFromWallet += value; + } } } } } - Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); + // parse outputs + for (final output in txData["vout"] as List) { + // get value + final value = Format.decimalAmountToSatoshis( + Decimal.parse(output["value"].toString()), + coin, + ); - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0] as String?; + // add value to total + totalOutputValue += value; + + // get output address + final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? + output["scriptPubKey"]?["address"] as String?; if (address != null) { - recipientsArray.add(address); + outputAddresses.add(address); + + // if output was to my wallet, add value to amount received + if (receivingAddresses.contains(address)) { + amountReceivedInWallet += value; + } else if (changeAddresses.contains(address)) { + changeAmount += value; + } } } - Logging.instance - .log("recipientsArray: $recipientsArray", level: LogLevel.Info); + final mySentFromAddresses = [ + ...receivingAddresses.intersection(inputAddresses), + ...changeAddresses.intersection(inputAddresses) + ]; + final myReceivedOnAddresses = + receivingAddresses.intersection(outputAddresses); + final myChangeReceivedOnAddresses = + changeAddresses.intersection(outputAddresses); - final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)) || - allAddressesOld.any((element) => sendersArray.contains(element)); - Logging.instance - .log("foundInSenders: $foundInSenders", level: LogLevel.Info); + final fee = totalInputValue - totalOutputValue; - // If txType = Sent, then calculate inputAmtSentFromWallet - if (foundInSenders) { - int totalInput = 0; - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - inputAmtSentFromWallet += - (Decimal.parse(out["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - totalInput = inputAmtSentFromWallet; - int totalOutput = 0; - - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0]; - final value = output["value"]; - final _value = (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOutput += _value; - if (changeAddressesP2PKH.contains(address)) { - inputAmtSentFromWallet -= _value; - } else { - // change address from 'sent from' to the 'sent to' address - txObject["address"] = address; - } - } - // calculate transaction fee - fee = totalInput - totalOutput; - // subtract fee from sent to calculate correct value of sent tx - inputAmtSentFromWallet -= fee; - } else { - // counters for fee calculation - int totalOut = 0; - int totalIn = 0; - - // add up received tx value - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0]; - if (address != null) { - final value = (Decimal.parse(output["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOut += value; - if (allAddresses.contains(address) || - allAddressesOld.contains(address)) { - outputAmtAddressedToWallet += value; - } - } - } - - // calculate fee for received tx - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - totalIn += (Decimal.parse(out["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - fee = totalIn - totalOut; - } - - // create final tx map - midSortedTx["txid"] = txObject["txid"]; - midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - midSortedTx["timestamp"] = txObject["blocktime"] ?? + final tx = isar_models.Transaction(); + tx.txid = txData["txid"] as String; + tx.timestamp = txData["blocktime"] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); - if (foundInSenders) { - midSortedTx["txType"] = "Sent"; - midSortedTx["amount"] = inputAmtSentFromWallet; - final String worthNow = - ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; + if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { + // tx is sent to self + tx.type = isar_models.TransactionType.sentToSelf; + tx.amount = + amountSentFromWallet - amountReceivedInWallet - fee - changeAmount; + } else if (mySentFromAddresses.isNotEmpty) { + // outgoing tx + tx.type = isar_models.TransactionType.outgoing; + tx.amount = amountSentFromWallet - changeAmount - fee; } else { - midSortedTx["txType"] = "Received"; - midSortedTx["amount"] = outputAmtAddressedToWallet; - final worthNow = - ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - } - midSortedTx["aliens"] = []; - midSortedTx["fees"] = fee; - midSortedTx["address"] = txObject["address"]; - midSortedTx["inputSize"] = txObject["vin"].length; - midSortedTx["outputSize"] = txObject["vout"].length; - midSortedTx["inputs"] = txObject["vin"]; - midSortedTx["outputs"] = txObject["vout"]; - - final int height = txObject["height"] as int; - midSortedTx["height"] = height; - - if (height >= latestTxnBlockHeight) { - latestTxnBlockHeight = height; + // incoming tx + tx.type = isar_models.TransactionType.incoming; + tx.amount = amountReceivedInWallet; } - midSortedArray.add(midSortedTx); + // TODO: other subtypes + tx.subType = isar_models.TransactionSubType.none; + + tx.fee = fee; + tx.address = txData["address"] as String; + + for (final json in txData["vin"] as List) { + bool isCoinBase = json['coinbase'] != null; + final input = isar_models.Input(); + input.txid = json['txid'] as String; + input.vout = json['vout'] as int? ?? -1; + input.scriptSig = json['scriptSig']?['hex'] as String?; + input.scriptSigAsm = json['scriptSig']?['asm'] as String?; + input.isCoinbase = + isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; + input.sequence = json['sequence'] as int?; + input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; + tx.inputs.add(input); + } + + for (final json in txData["vout"] as List) { + final output = isar_models.Output(); + output.scriptPubKey = json['scriptPubKey']?['hex'] as String?; + output.scriptPubKeyAsm = json['scriptPubKey']?['asm'] as String?; + output.scriptPubKeyType = json['scriptPubKey']?['type'] as String?; + output.scriptPubKeyAddress = + json["scriptPubKey"]?["addresses"]?[0] as String? ?? + json['scriptPubKey']['type'] as String; + output.value = Format.decimalAmountToSatoshis( + Decimal.parse(json["value"].toString()), + coin, + ); + tx.outputs.add(output); + } + + tx.height = txData["height"] as int?; + + tx.cancelled = false; + tx.slateId = null; + tx.otherData = null; + + txns.add(tx); } - // sort by date ---- //TODO not sure if needed - // shouldn't be any issues with a null timestamp but I got one at some point? - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // { - // final aT = a["timestamp"]; - // final bT = b["timestamp"]; - // - // if (aT == null && bT == null) { - // return 0; - // } else if (aT == null) { - // return -1; - // } else if (bT == null) { - // return 1; - // } else { - // return bT - aT; - // } - // }); - - // buildDateTimeChunks - 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], - }; - result["dateTimeChunks"].add(chunk); - } - } - - final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); - - 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); - - cachedTxData = txModel; - return txModel; + await isar.writeTxn(() async { + await isar.transactions.putAll(txns); + }); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2534,27 +2243,34 @@ class BitcoinCashWallet extends CoinServiceAPI { /// with [satoshiAmountToSend] and [selectedTxFeeRate]. If so, it will call buildTrasaction() and return /// a map containing the tx hex along with other important information. If not, then it will return /// an integer (1 or 2) - dynamic coinSelection(int satoshiAmountToSend, int selectedTxFeeRate, - String _recipientAddress, bool isSendAll, - {int additionalOutputs = 0, List? utxos}) async { + dynamic coinSelection( + int satoshiAmountToSend, + int selectedTxFeeRate, + String _recipientAddress, + bool isSendAll, { + int additionalOutputs = 0, + List? utxos, + }) async { Logging.instance .log("Starting coinSelection ----------", level: LogLevel.Info); - final List availableOutputs = utxos ?? outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final currentChainHeight = await chainHeight; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", level: LogLevel.Info); @@ -2581,7 +2297,7 @@ class BitcoinCashWallet extends CoinServiceAPI { // Possible situation right here int satoshisBeingUsed = 0; int inputsBeingConsumed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; satoshisBeingUsed < satoshiAmountToSend && i < spendableOutputs.length; @@ -2712,7 +2428,7 @@ class BitcoinCashWallet extends CoinServiceAPI { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize == feeForTwoOutputs) { // generate new change address if current change address has been used - await _checkChangeAddressForTransactions(DerivePathType.bip44); + await _checkChangeAddressForTransactions(); final String newChangeAddress = await _getCurrentAddressForChain(1, DerivePathType.bip44); @@ -2882,7 +2598,7 @@ class BitcoinCashWallet extends CoinServiceAPI { } Future> fetchBuildTxData( - List utxosToUse, + List utxosToUse, ) async { // return data Map results = {}; @@ -3071,7 +2787,7 @@ class BitcoinCashWallet extends CoinServiceAPI { /// Builds and signs a transaction Future> buildTransaction({ - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required List recipients, required List satoshiAmounts, @@ -3471,22 +3187,23 @@ class BitcoinCashWallet extends CoinServiceAPI { @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { - final available = - Format.decimalAmountToSatoshis(await availableBalance, coin); + final available = balance.spendable; if (available == satoshiAmount) { - return satoshiAmount - sweepAllEstimate(feeRate); + return satoshiAmount - (await sweepAllEstimate(feeRate)); } else if (satoshiAmount <= 0 || satoshiAmount > available) { return roughFeeEstimate(1, 2, feeRate); } int runningBalance = 0; int inputCount = 0; - for (final output in outputsList) { - runningBalance += output.value; - inputCount++; - if (runningBalance > satoshiAmount) { - break; + for (final output in (await utxos)) { + if (!output.isBlocked) { + runningBalance += output.value; + inputCount++; + if (runningBalance > satoshiAmount) { + break; + } } } @@ -3518,11 +3235,12 @@ class BitcoinCashWallet extends CoinServiceAPI { (feeRatePerKB / 1000).ceil(); } - int sweepAllEstimate(int feeRate) { + Future sweepAllEstimate(int feeRate) async { int available = 0; int inputCount = 0; - for (final output in outputsList) { - if (output.status.confirmed) { + for (final output in (await utxos)) { + if (!output.isBlocked && + output.isConfirmed(storedChainHeight, MINIMUM_CONFIRMATIONS)) { available += output.value; inputCount++; } @@ -3537,24 +3255,18 @@ class BitcoinCashWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - await _incrementAddressIndexForChain( - 0, DerivePathType.bip44); // First increment the receiving index - final newReceivingIndex = DB.instance.get( - boxName: walletId, - key: 'receivingIndexP2PKH') as int; // Check the new receiving index + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, - newReceivingIndex, - DerivePathType - .bip44); // Use new index to derive a new receiving address - await _addToAddressesArrayForChain( - newReceivingAddress, - 0, - DerivePathType - .bip44); // Add that new receiving address to the array of receiving addresses - var newaddr = await _getCurrentAddressForChain(0, DerivePathType.bip44); - _currentReceivingAddressP2PKH = Future( - () => newaddr); // Set the new receiving address that the service + 0, newReceivingIndex, DerivePathType.bip44); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { From 30d8f8b810b8ba76fdbb2975e861186a002894c0 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 14:47:27 -0600 Subject: [PATCH 095/192] update isCancelled flag name to be consistent with other isar model bool values --- .../models/blockchain_data/transaction.dart | 2 +- .../models/blockchain_data/transaction.g.dart | 124 +++++++++--------- .../wallet_view/sub_widgets/tx_icon.dart | 2 +- .../coins/bitcoincash/bitcoincash_wallet.dart | 2 +- lib/widgets/transaction_card.dart | 2 +- 5 files changed, 66 insertions(+), 66 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index f19bc2224..7c984b96a 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -34,7 +34,7 @@ class Transaction { late int? height; - late bool cancelled; + late bool isCancelled; late String? slateId; diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 9a6849146..42261d9e0 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -27,21 +27,21 @@ const TransactionSchema = CollectionSchema( name: r'amount', type: IsarType.long, ), - r'cancelled': PropertySchema( - id: 2, - name: r'cancelled', - type: IsarType.bool, - ), r'fee': PropertySchema( - id: 3, + id: 2, name: r'fee', type: IsarType.long, ), r'height': PropertySchema( - id: 4, + id: 3, name: r'height', type: IsarType.long, ), + r'isCancelled': PropertySchema( + id: 4, + name: r'isCancelled', + type: IsarType.bool, + ), r'otherData': PropertySchema( id: 5, name: r'otherData', @@ -167,9 +167,9 @@ void _transactionSerialize( ) { writer.writeString(offsets[0], object.address); writer.writeLong(offsets[1], object.amount); - writer.writeBool(offsets[2], object.cancelled); - writer.writeLong(offsets[3], object.fee); - writer.writeLong(offsets[4], object.height); + writer.writeLong(offsets[2], object.fee); + writer.writeLong(offsets[3], object.height); + writer.writeBool(offsets[4], object.isCancelled); writer.writeString(offsets[5], object.otherData); writer.writeString(offsets[6], object.slateId); writer.writeByte(offsets[7], object.subType.index); @@ -187,10 +187,10 @@ Transaction _transactionDeserialize( final object = Transaction(); object.address = reader.readString(offsets[0]); object.amount = reader.readLong(offsets[1]); - object.cancelled = reader.readBool(offsets[2]); - object.fee = reader.readLong(offsets[3]); - object.height = reader.readLongOrNull(offsets[4]); + object.fee = reader.readLong(offsets[2]); + object.height = reader.readLongOrNull(offsets[3]); object.id = id; + object.isCancelled = reader.readBool(offsets[4]); object.otherData = reader.readStringOrNull(offsets[5]); object.slateId = reader.readStringOrNull(offsets[6]); object.subType = @@ -216,11 +216,11 @@ P _transactionDeserializeProp

( case 1: return (reader.readLong(offset)) as P; case 2: - return (reader.readBool(offset)) as P; - case 3: return (reader.readLong(offset)) as P; - case 4: + case 3: return (reader.readLongOrNull(offset)) as P; + case 4: + return (reader.readBool(offset)) as P; case 5: return (reader.readStringOrNull(offset)) as P; case 6: @@ -748,16 +748,6 @@ extension TransactionQueryFilter }); } - QueryBuilder - cancelledEqualTo(bool value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'cancelled', - value: value, - )); - }); - } - QueryBuilder feeEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -935,6 +925,16 @@ extension TransactionQueryFilter }); } + QueryBuilder + isCancelledEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isCancelled', + value: value, + )); + }); + } + QueryBuilder otherDataIsNull() { return QueryBuilder.apply(this, (query) { @@ -1703,18 +1703,6 @@ extension TransactionQuerySortBy }); } - QueryBuilder sortByCancelled() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'cancelled', Sort.asc); - }); - } - - QueryBuilder sortByCancelledDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'cancelled', Sort.desc); - }); - } - QueryBuilder sortByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -1739,6 +1727,18 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByIsCancelled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCancelled', Sort.asc); + }); + } + + QueryBuilder sortByIsCancelledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCancelled', Sort.desc); + }); + } + QueryBuilder sortByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -1838,18 +1838,6 @@ extension TransactionQuerySortThenBy }); } - QueryBuilder thenByCancelled() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'cancelled', Sort.asc); - }); - } - - QueryBuilder thenByCancelledDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'cancelled', Sort.desc); - }); - } - QueryBuilder thenByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -1886,6 +1874,18 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByIsCancelled() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCancelled', Sort.asc); + }); + } + + QueryBuilder thenByIsCancelledDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isCancelled', Sort.desc); + }); + } + QueryBuilder thenByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -1974,12 +1974,6 @@ extension TransactionQueryWhereDistinct }); } - QueryBuilder distinctByCancelled() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'cancelled'); - }); - } - QueryBuilder distinctByFee() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'fee'); @@ -1992,6 +1986,12 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByIsCancelled() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isCancelled'); + }); + } + QueryBuilder distinctByOtherData( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2052,12 +2052,6 @@ extension TransactionQueryProperty }); } - QueryBuilder cancelledProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'cancelled'); - }); - } - QueryBuilder feeProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'fee'); @@ -2070,6 +2064,12 @@ extension TransactionQueryProperty }); } + QueryBuilder isCancelledProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isCancelled'); + }); + } + QueryBuilder otherDataProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'otherData'); diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index 6d96cb279..e0983bd47 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -122,7 +122,7 @@ class TxIcon2 extends StatelessWidget { child: Center( child: SvgPicture.asset( _getAssetName( - transaction.cancelled, + transaction.isCancelled, txIsReceived, !transaction.isConfirmed( currentHeight, diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 15fbca2a1..bd0033614 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2223,7 +2223,7 @@ class BitcoinCashWallet extends CoinServiceAPI { tx.height = txData["height"] as int?; - tx.cancelled = false; + tx.isCancelled = false; tx.slateId = null; tx.otherData = null; diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index 29139a5a7..531d7abb9 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -452,7 +452,7 @@ class _TransactionCardState2 extends ConsumerState { child: FittedBox( fit: BoxFit.scaleDown, child: Text( - _transaction.cancelled + _transaction.isCancelled ? "Cancelled" : whatIsIt( _transaction.type, From f551927603290e813a38b0b1359ed87390ceb413 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 14:52:06 -0600 Subject: [PATCH 096/192] migrate epiccash_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/epiccash/epiccash_wallet.dart | 444 ++++++++---------- 1 file changed, 204 insertions(+), 240 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index c5bae8bb7..fa2d3aa49 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -6,15 +6,15 @@ import 'dart:isolate'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_libepiccash/epic_cash.dart'; -import 'package:hive/hive.dart'; import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:stack_wallet_backup/generate_password.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart'; @@ -24,11 +24,11 @@ import 'package:stackwallet/services/event_bus/events/global/updated_in_backgrou 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/node_service.dart'; -import 'package:stackwallet/services/price.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/flutter_secure_storage_interface.dart'; +import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/stack_file_system.dart'; @@ -383,8 +383,8 @@ Future getSlates(String receiveAddress, String signature) async { } } -Future postCancel( - String receiveAddress, String slate_id, signature, sendersAddress) async { +Future postCancel(String receiveAddress, String slateId, + String? signature, String sendersAddress) async { Logging.instance.log("postCancel", level: LogLevel.Info); final Client client = Client(); try { @@ -395,18 +395,18 @@ Future postCancel( "id": "0", 'receivingAddress': receiveAddress, "signature": signature, - 'slate': slate_id, + 'slate': slateId, "sendersAddress": sendersAddress, }); - final epicpost = await client.post( + final epicPost = await client.post( uri, headers: {'Content-Type': 'application/json'}, body: body, ); // TODO: should the following be removed for security reasons in production? - Logging.instance.log(epicpost.statusCode.toString(), level: LogLevel.Info); - Logging.instance.log(epicpost.body.toString(), level: LogLevel.Info); - final response = jsonDecode(epicpost.body.toString()); + Logging.instance.log(epicPost.statusCode.toString(), level: LogLevel.Info); + Logging.instance.log(epicPost.body.toString(), level: LogLevel.Info); + final response = jsonDecode(epicPost.body.toString()); if (response['status'] == 'success') { return true; } else { @@ -525,17 +525,16 @@ class EpicCashWallet extends CoinServiceAPI { NodeModel? _epicNode; + late Isar isar; + EpicCashWallet( {required String walletId, required String walletName, required Coin coin, - PriceAPI? priceAPI, required SecureStorageInterface secureStore}) { _walletId = walletId; _walletName = walletName; _coin = coin; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; Logging.instance.log("$walletName isolate length: ${isolates.length}", @@ -580,18 +579,6 @@ class EpicCashWallet extends CoinServiceAPI { } } - @override - Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - Future>? _allOwnAddresses; - - Future> _fetchAllOwnAddresses() async { - List addresses = []; - final ownAddress = await _getCurrentAddressForChain(0); - addresses.add(ownAddress); - return addresses; - } - late ReceivePort receivePort; Future startSync() async { @@ -655,19 +642,6 @@ class EpicCashWallet extends CoinServiceAPI { return walletBalances; } - @override - Future get availableBalance async { - String walletBalances = await allWalletBalances(); - var jsonBalances = json.decode(walletBalances); - final double spendable = - jsonBalances['amount_currently_spendable'] as double; - return Decimal.parse(spendable.toString()); - } - - @override - // TODO: implement balanceMinusMaxFee - Future get balanceMinusMaxFee => throw UnimplementedError(); - Timer? timer; late Coin _coin; @@ -676,9 +650,7 @@ class EpicCashWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; - - Future cancelPendingTransactionAndPost(String tx_slate_id) async { + Future cancelPendingTransactionAndPost(String txSlateId) async { final wallet = await _secureStore.read(key: '${_walletId}_wallet'); final int? receivingIndex = DB.instance .get(boxName: walletId, key: "receivingIndex") as int?; @@ -686,8 +658,8 @@ class EpicCashWallet extends CoinServiceAPI { await _secureStore.read(key: '${_walletId}_epicboxConfig'); final slatesToCommits = await getSlatesToCommits(); - final receiveAddress = slatesToCommits[tx_slate_id]['to'] as String; - final sendersAddress = slatesToCommits[tx_slate_id]['from'] as String; + final receiveAddress = slatesToCommits[txSlateId]['to'] as String; + final sendersAddress = slatesToCommits[txSlateId]['from'] as String; int? currentReceivingIndex; for (int i = 0; i <= receivingIndex!; i++) { @@ -722,11 +694,10 @@ class EpicCashWallet extends CoinServiceAPI { String? signature = subscribeRequest['signature'] as String?; String? result; try { - result = await cancelPendingTransaction(tx_slate_id); + result = await cancelPendingTransaction(txSlateId); Logging.instance.log("result?: $result", level: LogLevel.Info); if (!(result.toLowerCase().contains("error"))) { - await postCancel( - receiveAddress, tx_slate_id, signature, sendersAddress); + await postCancel(receiveAddress, txSlateId, signature, sendersAddress); } } catch (e, s) { Logging.instance.log("$e, $s", level: LogLevel.Error); @@ -736,7 +707,7 @@ class EpicCashWallet extends CoinServiceAPI { // /// returns an empty String on success, error message on failure - Future cancelPendingTransaction(String tx_slate_id) async { + Future cancelPendingTransaction(String txSlateId) async { final String wallet = (await _secureStore.read(key: '${_walletId}_wallet'))!; @@ -746,7 +717,7 @@ class EpicCashWallet extends CoinServiceAPI { _cancelTransactionWrapper, Tuple2( wallet, - tx_slate_id, + txSlateId, ), ); }); @@ -847,12 +818,18 @@ class EpicCashWallet extends CoinServiceAPI { final txLogEntry = json.decode(tx as String); final txLogEntryFirst = txLogEntry[0]; Logger.print("TX_LOG_ENTRY_IS $txLogEntryFirst"); - final wallet = await Hive.openBox(_walletId); - final slateToAddresses = - (await wallet.get("slate_to_address")) as Map? ?? {}; + final slateToAddresses = DB.instance.get( + boxName: walletId, + key: "slate_to_address", + ) as Map? ?? + {}; final slateId = txLogEntryFirst['tx_slate_id'] as String; slateToAddresses[slateId] = txData['addresss']; - await wallet.put('slate_to_address', slateToAddresses); + await DB.instance.put( + boxName: walletId, + key: "slate_to_address", + value: slateToAddresses, + ); final slatesToCommits = await getSlatesToCommits(); String? commitId = slatesToCommits[slateId]?['commitId'] as String?; Logging.instance.log("sent commitId: $commitId", level: LogLevel.Info); @@ -979,6 +956,22 @@ class EpicCashWallet extends CoinServiceAPI { return; } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet", @@ -998,12 +991,8 @@ class EpicCashWallet extends CoinServiceAPI { } await _prefs.init(); await updateNode(false); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); + await _refreshBalance(); // TODO: is there anything else that should be set up here whenever this wallet is first loaded again? } @@ -1148,15 +1137,6 @@ class EpicCashWallet extends CoinServiceAPI { @override Future> get mnemonic => _getMnemonicList(); - @override - Future get pendingBalance async { - String walletBalances = await allWalletBalances(); - final jsonBalances = json.decode(walletBalances); - final double pending = - jsonBalances['amount_awaiting_confirmation'] as double; - return Decimal.parse(pending.toString()); - } - @override Future> prepareSend( {required String address, @@ -1494,6 +1474,7 @@ class EpicCashWallet extends CoinServiceAPI { return latestHeight!; } + @override int get storedChainHeight { return DB.instance.get(boxName: walletId, key: "storedChainHeight") as int? ?? @@ -1676,7 +1657,7 @@ class EpicCashWallet extends CoinServiceAPI { currentAddress, subscribeRequest['signature'] as String); if (unprocessedSlates == null || unprocessedSlates is! List) { Logging.instance.log( - "index $currentReceivingIndex at $currentReceivingAddress does not have any slates", + "index $currentReceivingIndex at ${await currentReceivingAddress} does not have any slates", level: LogLevel.Info); continue; } @@ -1814,7 +1795,7 @@ class EpicCashWallet extends CoinServiceAPI { await _secureStore.read(key: '${_walletId}_epicboxConfig'); final int? receivingIndex = DB.instance .get(boxName: walletId, key: "receivingIndex") as int?; - final tData = await _transactionData; + for (int currentReceivingIndex = 0; receivingIndex != null && currentReceivingIndex <= receivingIndex; currentReceivingIndex++) { @@ -1847,16 +1828,16 @@ class EpicCashWallet extends CoinServiceAPI { final slatesToCommits = await getSlatesToCommits(); for (final cancel in cancels as List) { - final tx_slate_id = cancel.keys.first as String; - if (slatesToCommits[tx_slate_id] == null) { + final txSlateId = cancel.keys.first as String; + if (slatesToCommits[txSlateId] == null) { continue; } final cancelRequestSender = ((cancel as Map).values.first) as String; final receiveAddressFromMap = - slatesToCommits[tx_slate_id]['to'] as String; + slatesToCommits[txSlateId]['to'] as String; final sendersAddressFromMap = - slatesToCommits[tx_slate_id]['from'] as String; - final commitId = slatesToCommits[tx_slate_id]['commitId'] as String; + slatesToCommits[txSlateId]['from'] as String; + final commitId = slatesToCommits[txSlateId]['commitId'] as String; if (sendersAddressFromMap != cancelRequestSender) { Logging.instance.log("this was not signed by the correct address", @@ -1864,11 +1845,12 @@ class EpicCashWallet extends CoinServiceAPI { continue; } - String? result; try { - result = await cancelPendingTransaction(tx_slate_id); - if (tData?.findTransaction(commitId)?.isCancelled ?? false == true) { - await deleteCancels(receiveAddressFromMap, signature, tx_slate_id); + await cancelPendingTransaction(txSlateId); + final tx = + await isar.transactions.where().txidEqualTo(commitId).findFirst(); + if ((tx?.isCancelled ?? false) == true) { + await deleteCancels(receiveAddressFromMap, signature, txSlateId); } } catch (e, s) { Logging.instance.log("$e, $s", level: LogLevel.Error); @@ -1933,7 +1915,7 @@ class EpicCashWallet extends CoinServiceAPI { await processAllSlates(); await processAllCancels(); - startSync(); + unawaited(startSync()); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.0, walletId)); @@ -1955,16 +1937,16 @@ class EpicCashWallet extends CoinServiceAPI { unawaited(updateStoredChainHeight(newHeight: currentHeight)); } - final newTxData = _fetchTransactionData(); + await _refreshTransactions(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); - _transactionData = Future(() => newTxData); - GlobalEventBus.instance.fire(UpdatedInBackgroundEvent( "New data found in $walletName in background!", walletId)); } + await _refreshBalance(); + GlobalEventBus.instance.fire(RefreshPercentChangedEvent(1.0, walletId)); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( @@ -2020,15 +2002,6 @@ class EpicCashWallet extends CoinServiceAPI { // TODO: do a quick check to see if there is any new data that would require a refresh } - @override - Future send( - {required String toAddress, - required int amount, - Map args = const {}}) { - // TODO: implement send - throw UnimplementedError(); - } - @override Future testNetworkConnection() async { try { @@ -2084,18 +2057,8 @@ class EpicCashWallet extends CoinServiceAPI { @override bool get isConnected => _isConnected; - @override - Future get totalBalance async { - String walletBalances = await allWalletBalances(); - var jsonBalances = json.decode(walletBalances); - double total = jsonBalances['total'] as double; - double awaiting = jsonBalances['amount_awaiting_finalization'] as double; - total = total + awaiting; - return Decimal.parse(total.toString()); - } - - Future _fetchTransactionData() async { - final currentChainHeight = await chainHeight; + Future _refreshTransactions() async { + // final currentChainHeight = await chainHeight; final wallet = await _secureStore.read(key: '${_walletId}_wallet'); const refreshFromNode = 0; @@ -2121,38 +2084,28 @@ class EpicCashWallet extends CoinServiceAPI { // return message; final String transactions = message['result'] as String; final jsonTransactions = json.decode(transactions) as List; - // for (var el in jsonTransactions) { - // Logging.instance.log("gettran: $el", - // normalLength: false, addToDebugMessagesDB: true); - // } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + final List midSortedArray = []; int latestTxnBlockHeight = DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") as int? ?? 0; final slatesToCommits = await getSlatesToCommits(); - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as TransactionData?; - var cachedMap = cachedTransactions?.getAllTransactions(); + for (var tx in jsonTransactions) { Logging.instance.log("tx: $tx", level: LogLevel.Info); final txHeight = tx["kernel_lookup_min_height"] as int? ?? 0; - // 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; - } + // // 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; @@ -2165,20 +2118,18 @@ class EpicCashWallet extends CoinServiceAPI { int fee = int.parse((tx['fee'] ?? "0") as String); amt = debit - credit - fee; } - final String worthNow = - (currentPrice * Decimal.parse(amt.toString())).toStringAsFixed(2); DateTime dt = DateTime.parse(tx["creation_ts"] as String); - Map midSortedTx = {}; - midSortedTx["txType"] = (tx["tx_type"] == "TxReceived" || + final txn = isar_models.Transaction(); + txn.type = (tx["tx_type"] == "TxReceived" || tx["tx_type"] == "TxReceivedCancelled") - ? "Received" - : "Sent"; + ? isar_models.TransactionType.incoming + : isar_models.TransactionType.outgoing; + String? slateId = tx['tx_slate_id'] as String?; String? address = slatesToCommits[slateId] - ?[midSortedTx["txType"] == "TxReceived" ? "from" : "to"] - as String? ?? + ?[tx["tx_type"] == "TxReceived" ? "from" : "to"] as String? ?? ""; String? commitId = slatesToCommits[slateId]?['commitId'] as String?; Logging.instance.log( @@ -2188,116 +2139,99 @@ class EpicCashWallet extends CoinServiceAPI { bool isCancelled = tx["tx_type"] == "TxSentCancelled" || tx["tx_type"] == "TxReceivedCancelled"; - midSortedTx["slateId"] = slateId; - midSortedTx["isCancelled"] = isCancelled; - midSortedTx["txid"] = commitId ?? tx["id"].toString(); - midSortedTx["confirmed_status"] = isConfirmed; - midSortedTx["timestamp"] = (dt.millisecondsSinceEpoch ~/ 1000); - midSortedTx["amount"] = amt; - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - midSortedTx["fees"] = - (tx["fee"] == null) ? 0 : int.parse(tx["fee"] as String); - midSortedTx["address"] = + txn.slateId = slateId; + txn.isCancelled = isCancelled; + txn.txid = commitId ?? tx["id"].toString(); + txn.timestamp = (dt.millisecondsSinceEpoch ~/ 1000); + txn.amount = amt; + txn.fee = (tx["fee"] == null) ? 0 : int.parse(tx["fee"] as String); + txn.address = ""; // for this when you send a transaction you will just need to save in a hashmap in hive with the key being the txid, and the value being the address it was sent to. then you can look this value up right here in your hashmap. - midSortedTx["address"] = address; - midSortedTx["height"] = txHeight; - int confirmations = 0; - try { - confirmations = currentChainHeight - txHeight; - } catch (e, s) { - //todo: come back to this - debugPrint("$e $s"); - } - midSortedTx["confirmations"] = confirmations; + txn.address = address; + txn.height = txHeight; - midSortedTx["inputSize"] = tx["num_inputs"]; - midSortedTx["outputSize"] = tx["num_outputs"]; - midSortedTx["aliens"] = []; - midSortedTx["inputs"] = []; - midSortedTx["outputs"] = []; - midSortedTx["tx_slate_id"] = tx["tx_slate_id"]; - midSortedTx["key_id"] = tx["parent_key_id"]; - midSortedTx["otherData"] = tx["id"].toString(); + // + // 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"]; + + txn.otherData = tx["id"].toString(); if (txHeight >= latestTxnBlockHeight) { latestTxnBlockHeight = txHeight; } - midSortedArray.add(midSortedTx); - cachedMap?.remove(tx["id"].toString()); - cachedMap?.remove(commitId); - Logging.instance.log("cmap: $cachedMap", level: LogLevel.Info); + midSortedArray.add(txn); + // cachedMap?.remove(tx["id"].toString()); + // cachedMap?.remove(commitId); + // Logging.instance.log("cmap: $cachedMap", level: LogLevel.Info); } - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); + await isar + .writeTxn(() async => await isar.transactions.putAll(midSortedArray)); - 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], - }; - - // 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; + // 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], + // }; + // + // // 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 - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - Future? _transactionData; - - // not used in epic - TransactionData? cachedTxData; - @override Future updateSentCachedTxData(Map txData) async { // not used in epic } - @override - Future> get unspentOutputs => throw UnimplementedError(); - @override bool validateAddress(String address) { if (address.startsWith("http://") || address.startsWith("https://")) { @@ -2345,7 +2279,6 @@ class EpicCashWallet extends CoinServiceAPI { @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { int currentFee = await nativeFee(satoshiAmount, ifErrorEstimateFee: true); - // TODO: implement this return currentFee; } @@ -2353,18 +2286,6 @@ class EpicCashWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - // await incrementAddressIndexForChain( - // 0); // First increment the receiving index - // final newReceivingIndex = - // DB.instance.get(boxName: walletId, key: 'receivingIndex') - // as int; // Check the new receiving index - // final newReceivingAddress = await _generateAddressForChain(0, - // newReceivingIndex); // Use new index to derive a new receiving address - // await addToAddressesArrayForChain(newReceivingAddress, - // 0); // Add that new receiving address to the array of receiving addresses - // _currentReceivingAddress = Future(() => - // newReceivingAddress); // Set the new receiving address that the service - return true; } catch (e, s) { Logging.instance.log( @@ -2373,4 +2294,47 @@ class EpicCashWallet extends CoinServiceAPI { return false; } } + + Future _refreshBalance() async { + String walletBalances = await allWalletBalances(); + var jsonBalances = json.decode(walletBalances); + + final spendable = + (jsonBalances['amount_currently_spendable'] as double).toString(); + + final pending = + (jsonBalances['amount_awaiting_confirmation'] as double).toString(); + + final total = (jsonBalances['total'] as double).toString(); + final awaiting = + (jsonBalances['amount_awaiting_finalization'] as double).toString(); + + _balance = Balance( + coin: coin, + total: Format.decimalAmountToSatoshis( + Decimal.parse(total) + Decimal.parse(awaiting), + coin, + ), + spendable: Format.decimalAmountToSatoshis( + Decimal.parse(spendable), + coin, + ), + blockedTotal: 0, + pendingSpendable: Format.decimalAmountToSatoshis( + Decimal.parse(pending), + coin, + ), + ); + } + + @override + Balance get balance => _balance!; + Balance? _balance; + + @override + Future> get utxos => throw UnimplementedError(); + + @override + Future> get transactions => + isar.transactions.where().findAll(); } From 90bf6a2bb2d1862e276b8fc9127a7e91d7cf23c7 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 18:16:17 -0600 Subject: [PATCH 097/192] migrate firo_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- lib/services/coins/firo/firo_wallet.dart | 2223 +++++++++++----------- 1 file changed, 1144 insertions(+), 1079 deletions(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index adf259a32..9c8ec32be 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3,24 +3,23 @@ import 'dart:convert'; import 'dart:io'; import 'dart:isolate'; import 'dart:math'; -import 'dart:typed_data'; import 'package:bip32/bip32.dart' as bip32; import 'package:bip39/bip39.dart' as bip39; import 'package:bitcoindart/bitcoindart.dart'; import 'package:decimal/decimal.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:lelantus/lelantus.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/lelantus_coin.dart'; import 'package:stackwallet/models/lelantus_fee_data.dart'; -import 'package:stackwallet/models/models.dart' as models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.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/refresh_percent_changed_event.dart'; @@ -29,7 +28,6 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -41,6 +39,7 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -369,8 +368,9 @@ Future> isolateRestore( } Future> staticProcessRestore( - models.TransactionData data, + List txns, Map result, + int currentHeight, ) async { List? _l = result['_lelantus_coins'] as List?; final List> lelantusCoins = []; @@ -379,19 +379,30 @@ Future> staticProcessRestore( } // Edit the receive transactions with the mint fees. - Map editedTransactions = - {}; + Map editedTransactions = + {}; for (var item in lelantusCoins) { item.forEach((key, value) { String txid = value.txId; - var tx = data.findTransaction(txid); + isar_models.Transaction? tx; + try { + tx = txns.firstWhere((e) => e.txid == txid); + } catch (_) { + tx = null; + } + if (tx == null) { // This is a jmint. return; } - List inputs = []; + List inputs = []; for (var element in tx.inputs) { - var input = data.findTransaction(element.txid); + isar_models.Transaction? input; + try { + input = txns.firstWhere((e) => e.txid == element.txid); + } catch (_) { + input = null; + } if (input != null) { inputs.add(input); } @@ -401,35 +412,32 @@ Future> staticProcessRestore( return; } - int mintfee = tx.fees; - int sharedfee = mintfee ~/ inputs.length; + int mintFee = tx.fee; + int sharedFee = mintFee ~/ inputs.length; for (var element in inputs) { - editedTransactions[element.txid] = models.Transaction( - txid: element.txid, - confirmedStatus: element.confirmedStatus, - timestamp: element.timestamp, - txType: element.txType, - amount: element.amount, - aliens: element.aliens, - worthNow: element.worthNow, - worthAtBlockTimestamp: element.worthAtBlockTimestamp, - fees: sharedfee, - inputSize: element.inputSize, - outputSize: element.outputSize, - inputs: element.inputs, - outputs: element.outputs, - address: element.address, - height: element.height, - confirmations: element.confirmations, - subType: "mint", - otherData: txid, - ); + editedTransactions[element.txid] = isar_models.Transaction() + ..txid = element.txid + ..timestamp = element.timestamp + ..type = element.type + ..amount = element.amount + ..fee = sharedFee + ..inputs.addAll(element.inputs) + ..outputs.addAll(element.outputs) + ..address = element.address + ..height = element.height + ..subType = isar_models.TransactionSubType.mint + ..otherData = txid + ..isLelantus = true + ..isCancelled = false; } }); } // Logging.instance.log(editedTransactions, addToDebugMessagesDB: false); - Map transactionMap = data.getAllTransactions(); + Map transactionMap = {}; + for (final e in txns) { + transactionMap[e.txid] = e; + } // Logging.instance.log(transactionMap, addToDebugMessagesDB: false); editedTransactions.forEach((key, value) { @@ -438,7 +446,8 @@ Future> staticProcessRestore( transactionMap.removeWhere((key, value) => lelantusCoins.any((element) => element.containsKey(key)) || - (value.height == -1 && !value.confirmedStatus)); + ((value.height == -1 || value.height == null) && + !value.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS))); result['newTxMap'] = transactionMap; return result; @@ -798,169 +807,106 @@ class FiroWallet extends CoinServiceAPI { @override Coin get coin => _coin; - // @override - // String get coinName => - // networkType == BasicNetworkType.main ? "Firo" : "tFiro"; - // - // @override - // String get coinTicker => - // networkType == BasicNetworkType.main ? "FIRO" : "tFIRO"; - @override Future> get mnemonic => _getMnemonicList(); - // index 0 and 1 for the funds available to spend. - // index 2 and 3 for all the funds in the wallet (including the undependable ones) - @override - Future get availableBalance async { - final balances = await this.balances; - return balances[0]; - } - - // index 0 and 1 for the funds available to spend. - // index 2 and 3 for all the funds in the wallet (including the undependable ones) - @override - Future get pendingBalance async { - final balances = await this.balances; - return balances[2] - balances[0]; - } - - // index 0 and 1 for the funds available to spend. - // index 2 and 3 for all the funds in the wallet (including the undependable ones) - @override - Future get totalBalance async { - if (!isActive) { - final totalBalance = DB.instance - .get(boxName: walletId, key: 'totalBalance') as String?; - if (totalBalance == null) { - final balances = await this.balances; - return balances[2]; - } else { - return Decimal.parse(totalBalance); - // the following caused a crash as it seems totalBalance here - // is a string. Gotta love dynamics - // return Format.satoshisToAmount(totalBalance); - } - } - final balances = await this.balances; - return balances[2]; - } - - /// return spendable balance minus the maximum tx fee - @override - Future get balanceMinusMaxFee async { - final balances = await this.balances; - final maxFee = await this.maxFee; - return balances[0] - Format.satoshisToAmount(maxFee, coin: coin); - } - - @override - Future get transactionData => lelantusTransactionData; - @override bool validateAddress(String address) { return Address.validateAddress(address, _network); } - /// Holds final balances, all utxos under control - Future? _utxoData; - Future get utxoData => _utxoData ??= _fetchUtxoData(); - - @override - Future> get unspentOutputs async => - (await utxoData).unspentOutputArray; - /// Holds wallet transaction data - Future? _transactionData; - Future get _txnData => - _transactionData ??= _fetchTransactionData(); + Future> get _txnData => isar.transactions + .filter() + .isLelantusIsNull() + .or() + .isLelantusEqualTo(false) + .findAll(); + // _transactionData ??= _refreshTransactions(); - models.TransactionData? cachedTxData; + // models.TransactionData? cachedTxData; // hack to add tx to txData before refresh completes // required based on current app architecture where we don't properly store // transactions locally in a good way @override Future updateSentCachedTxData(Map txData) async { - final currentPrice = await firoPrice; - final locale = - Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final String worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - - final tx = models.Transaction( - txid: txData["txid"] as String, - confirmedStatus: false, - timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, - txType: "Sent", - amount: txData["recipientAmt"] as int, - worthNow: worthNow, - worthAtBlockTimestamp: worthNow, - fees: txData["fee"] as int, - inputSize: 0, - outputSize: 0, - inputs: [], - outputs: [], - address: txData["address"] as String, - height: -1, - confirmations: 0, - ); - - if (cachedTxData == null) { - final data = await _fetchTransactionData(); - _transactionData = Future(() => data); - } - - final transactions = cachedTxData!.getAllTransactions(); - transactions[tx.txid] = tx; - cachedTxData = models.TransactionData.fromMap(transactions); - _transactionData = Future(() => cachedTxData!); + // final currentPrice = await firoPrice; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final String worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // + // final tx = models.Transaction( + // txid: txData["txid"] as String, + // confirmedStatus: false, + // timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // txType: "Sent", + // amount: txData["recipientAmt"] as int, + // worthNow: worthNow, + // worthAtBlockTimestamp: worthNow, + // fees: txData["fee"] as int, + // inputSize: 0, + // outputSize: 0, + // inputs: [], + // outputs: [], + // address: txData["address"] as String, + // height: -1, + // confirmations: 0, + // ); + // + // if (cachedTxData == null) { + // final data = await _fetchTransactionData(); + // _transactionData = Future(() => data); + // } + // + // final transactions = cachedTxData!.getAllTransactions(); + // transactions[tx.txid] = tx; + // cachedTxData = models.TransactionData.fromMap(transactions); + // _transactionData = Future(() => cachedTxData!); } /// Holds wallet lelantus transaction data - Future? _lelantusTransactionData; - Future get lelantusTransactionData => - _lelantusTransactionData ??= _getLelantusTransactionData(); + Future> get lelantusTransactionData => + isar.transactions.filter().isLelantusEqualTo(true).findAll(); + // _lelantusTransactionData ??= _getLelantusTransactionData(); /// Holds the max fee that can be sent Future? _maxFee; @override Future get maxFee => _maxFee ??= _fetchMaxFee(); - /// Holds the current balance data - Future>? _balances; - Future> get balances => _balances ??= _getFullBalance(); - - /// Holds all outputs for wallet, used for displaying utxos in app security view - List _outputsList = []; - - Future get firoPrice async { - final data = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - if (coin == Coin.firoTestNet) { - return data[Coin.firo]!.item1; - } - return data[coin]!.item1; - } - - // currently isn't used but required due to abstract parent class Future? _feeObject; @override Future get fees => _feeObject ??= _getFees(); - /// Holds updated receiving address - Future? _currentReceivingAddress; @override - Future get currentReceivingAddress => - _currentReceivingAddress ??= _getCurrentAddressForChain(0); + Future get currentReceivingAddress async => + (await _currentReceivingAddress).value; - // @override - // Future get currentLegacyReceivingAddress => null; + Future get _currentReceivingAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; + + Future get currentChangeAddress async => + (await _currentChangeAddress).value; + + Future get _currentChangeAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; late String _walletName; @override @@ -975,11 +921,6 @@ class FiroWallet extends CoinServiceAPI { @override String get walletId => _walletId; - Future>? _allOwnAddresses; - @override - Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - @override Future testNetworkConnection() async { try { @@ -1058,8 +999,8 @@ class FiroWallet extends CoinServiceAPI { // check for send all bool isSendAll = false; - final balance = Format.decimalAmountToSatoshis( - await availablePublicBalance(), coin); + final balance = + Format.decimalAmountToSatoshis(availablePublicBalance(), coin); if (satoshiAmount == balance) { isSendAll = true; } @@ -1145,7 +1086,7 @@ class FiroWallet extends CoinServiceAPI { // check for send all bool isSendAll = false; final balance = - Format.decimalAmountToSatoshis(await availablePrivateBalance(), coin); + Format.decimalAmountToSatoshis(availablePrivateBalance(), coin); if (satoshiAmount == balance) { // print("is send all"); isSendAll = true; @@ -1191,12 +1132,14 @@ class FiroWallet extends CoinServiceAPI { // temporarily update apdate available balance until a full refresh is done // TODO: something here causes an exception to be thrown giving user false info that the tx failed - Decimal sendTotal = - Format.satoshisToAmount(txData["value"] as int, coin: coin); - sendTotal += Decimal.parse(txData["fees"].toString()); - final bals = await balances; - bals[0] -= sendTotal; - _balances = Future(() => bals); + // Decimal sendTotal = + // Format.satoshisToAmount(txData["value"] as int, coin: coin); + // sendTotal += Decimal.parse(txData["fees"].toString()); + + // TODO: is this needed? + // final bals = await balances; + // bals[0] -= sendTotal; + // _balances = Future(() => bals); return txid; } catch (e, s) { @@ -1213,52 +1156,52 @@ class FiroWallet extends CoinServiceAPI { } } - /// returns txid on successful send - /// - /// can throw - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - dynamic txHexOrError = - await _createJoinSplitTransaction(amount, toAddress, false); - Logging.instance.log("txHexOrError $txHexOrError", level: LogLevel.Error); - if (txHexOrError is int) { - // Here, we assume that transaction crafting returned an error - switch (txHexOrError) { - case 1: - throw Exception("Insufficient balance!"); - default: - throw Exception("Error Creating Transaction!"); - } - } else { - if (await _submitLelantusToNetwork( - txHexOrError as Map)) { - final txid = txHexOrError["txid"] as String; - - // temporarily update apdate available balance until a full refresh is done - Decimal sendTotal = - Format.satoshisToAmount(txHexOrError["value"] as int, coin: coin); - sendTotal += Decimal.parse(txHexOrError["fees"].toString()); - final bals = await balances; - bals[0] -= sendTotal; - _balances = Future(() => bals); - - return txid; - } else { - //TODO provide more info - throw Exception("Transaction failed."); - } - } - } catch (e, s) { - Logging.instance.log("Exception rethrown in firo send(): $e\n$s", - level: LogLevel.Error); - rethrow; - } - } + // /// returns txid on successful send + // /// + // /// can throw + // @override + // Future send({ + // required String toAddress, + // required int amount, + // Map args = const {}, + // }) async { + // try { + // dynamic txHexOrError = + // await _createJoinSplitTransaction(amount, toAddress, false); + // Logging.instance.log("txHexOrError $txHexOrError", level: LogLevel.Error); + // if (txHexOrError is int) { + // // Here, we assume that transaction crafting returned an error + // switch (txHexOrError) { + // case 1: + // throw Exception("Insufficient balance!"); + // default: + // throw Exception("Error Creating Transaction!"); + // } + // } else { + // if (await _submitLelantusToNetwork( + // txHexOrError as Map)) { + // final txid = txHexOrError["txid"] as String; + // + // // temporarily update apdate available balance until a full refresh is done + // Decimal sendTotal = + // Format.satoshisToAmount(txHexOrError["value"] as int, coin: coin); + // sendTotal += Decimal.parse(txHexOrError["fees"].toString()); + // final bals = await balances; + // bals[0] -= sendTotal; + // _balances = Future(() => bals); + // + // return txid; + // } else { + // //TODO provide more info + // throw Exception("Transaction failed."); + // } + // } + // } catch (e, s) { + // Logging.instance.log("Exception rethrown in firo send(): $e\n$s", + // level: LogLevel.Error); + // rethrow; + // } + // } Future> _getMnemonicList() async { final mnemonicString = @@ -1278,7 +1221,7 @@ class FiroWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; + late Isar isar; late TransactionNotificationTracker txTracker; @@ -1290,7 +1233,6 @@ class FiroWallet extends CoinServiceAPI { required ElectrumX client, required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, - PriceAPI? priceAPI, required SecureStorageInterface secureStore, }) { txTracker = tracker; @@ -1299,8 +1241,6 @@ class FiroWallet extends CoinServiceAPI { _coin = coin; _electrumXClient = client; _cachedElectrumXClient = cachedClient; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; Logging.instance.log("$walletName isolates length: ${isolates.length}", @@ -1326,26 +1266,28 @@ class FiroWallet extends CoinServiceAPI { String _recipientAddress, bool isSendAll, { int additionalOutputs = 0, - List? utxos, + List? utxos, }) async { Logging.instance .log("Starting coinSelection ----------", level: LogLevel.Info); - final List availableOutputs = utxos ?? _outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final currentChainHeight = await chainHeight; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", level: LogLevel.Info); @@ -1372,7 +1314,7 @@ class FiroWallet extends CoinServiceAPI { // Possible situation right here int satoshisBeingUsed = 0; int inputsBeingConsumed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; satoshisBeingUsed <= satoshiAmountToSend && i < spendableOutputs.length; @@ -1671,7 +1613,7 @@ class FiroWallet extends CoinServiceAPI { } Future> fetchBuildTxData( - List utxosToUse, + List utxosToUse, ) async { // return data Map results = {}; @@ -1792,7 +1734,7 @@ class FiroWallet extends CoinServiceAPI { /// Builds and signs a transaction Future> buildTransaction({ - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required List recipients, required List satoshiAmounts, @@ -1890,13 +1832,27 @@ class FiroWallet extends CoinServiceAPI { await Future.wait([ DB.instance.put(boxName: walletId, key: "id", value: _walletId), - _getLelantusTransactionData().then((lelantusTxData) => - _lelantusTransactionData = Future(() => lelantusTxData)), DB.instance .put(boxName: walletId, key: "isFavorite", value: false), ]); } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log( @@ -1909,12 +1865,7 @@ class FiroWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as models.TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); } Future refreshIfThereIsNewData() async { @@ -1943,12 +1894,15 @@ class FiroWallet extends CoinServiceAPI { } } if (!needsRefresh) { - var allOwnAddresses = await this.allOwnAddresses; - List> allTxs = - await _fetchHistory(allOwnAddresses); - models.TransactionData txData = await _txnData; + final allOwnAddresses = await _fetchAllOwnAddresses(); + List> allTxs = await _fetchHistory( + allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { - if (txData.findTransaction(transaction['tx_hash'] as String) == + final txid = transaction['tx_hash'] as String; + if ((await isar.transactions + .filter() + .txidMatches(txid) + .findFirst()) == null) { Logging.instance.log( " txid not found in address history already ${transaction['tx_hash']}", @@ -1967,71 +1921,88 @@ class FiroWallet extends CoinServiceAPI { } } - Future getAllTxsToWatch( - models.TransactionData txData, - models.TransactionData lTxData, - ) async { + Future getAllTxsToWatch() async { if (_hasCalledExit) return; Logging.instance.log("$walletName periodic", level: LogLevel.Info); - List unconfirmedTxnsToNotifyPending = []; - List unconfirmedTxnsToNotifyConfirmed = []; + List unconfirmedTxnsToNotifyPending = []; + List unconfirmedTxnsToNotifyConfirmed = []; - for (models.TransactionChunk chunk in txData.txChunks) { - for (models.Transaction tx in chunk.transactions) { - models.Transaction? lTx = lTxData.findTransaction(tx.txid); + final currentChainHeight = await chainHeight; - if (tx.confirmedStatus) { - if (txTracker.wasNotifiedPending(tx.txid) && - !txTracker.wasNotifiedConfirmed(tx.txid)) { - // get all transactions that were notified as pending but not as confirmed - unconfirmedTxnsToNotifyConfirmed.add(tx); - } - if (lTx != null && - (lTx.inputs.isEmpty || lTx.inputs[0].txid.isEmpty) && - lTx.confirmedStatus == false && - tx.txType == "Received") { - // If this is a received that is past 1 or more confirmations and has not been minted, - if (!txTracker.wasNotifiedPending(tx.txid)) { - unconfirmedTxnsToNotifyPending.add(tx); - } - } - } else { + final txTxns = await isar.transactions + .filter() + .isLelantusIsNull() + .or() + .isLelantusEqualTo(false) + .findAll(); + final ltxTxns = + await isar.transactions.filter().isLelantusEqualTo(true).findAll(); + + for (isar_models.Transaction tx in txTxns) { + isar_models.Transaction? lTx; + try { + lTx = ltxTxns.firstWhere((e) => e.txid == tx.txid); + } catch (_) { + lTx = null; + } + + if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + if (txTracker.wasNotifiedPending(tx.txid) && + !txTracker.wasNotifiedConfirmed(tx.txid)) { + // get all transactions that were notified as pending but not as confirmed + unconfirmedTxnsToNotifyConfirmed.add(tx); + } + if (lTx != null && + (lTx.inputs.isEmpty || lTx.inputs.first.txid.isEmpty) && + lTx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + false && + tx.type == isar_models.TransactionType.incoming) { + // If this is a received that is past 1 or more confirmations and has not been minted, if (!txTracker.wasNotifiedPending(tx.txid)) { - // get all transactions that were not notified as pending yet unconfirmedTxnsToNotifyPending.add(tx); } } - } - } - - for (models.TransactionChunk chunk in txData.txChunks) { - for (models.Transaction tx in chunk.transactions) { - if (!tx.confirmedStatus && tx.inputs[0].txid.isNotEmpty) { - // Get all normal txs that are at 0 confirmations - unconfirmedTxnsToNotifyPending - .removeWhere((e) => e.txid == tx.inputs[0].txid); - Logging.instance.log("removed tx: ${tx.txid}", level: LogLevel.Info); + } else { + if (!txTracker.wasNotifiedPending(tx.txid)) { + // get all transactions that were not notified as pending yet + unconfirmedTxnsToNotifyPending.add(tx); } } } - for (models.TransactionChunk chunk in lTxData.txChunks) { - for (models.Transaction lTX in chunk.transactions) { - models.Transaction? tx = txData.findTransaction(lTX.txid); - if (tx == null) { - // if this is a ltx transaction that is unconfirmed and not represented in the normal transaction set. - if (!lTX.confirmedStatus) { - if (!txTracker.wasNotifiedPending(lTX.txid)) { - unconfirmedTxnsToNotifyPending.add(lTX); - } - } else { - if (txTracker.wasNotifiedPending(lTX.txid) && - !txTracker.wasNotifiedConfirmed(lTX.txid)) { - unconfirmedTxnsToNotifyConfirmed.add(lTX); - } + + for (isar_models.Transaction tx in txTxns) { + if (!tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) && + tx.inputs.first.txid.isNotEmpty) { + // Get all normal txs that are at 0 confirmations + unconfirmedTxnsToNotifyPending + .removeWhere((e) => e.txid == tx.inputs.first.txid); + Logging.instance.log("removed tx: ${tx.txid}", level: LogLevel.Info); + } + } + + for (isar_models.Transaction lTX in ltxTxns) { + isar_models.Transaction? tx; + try { + tx = ltxTxns.firstWhere((e) => e.txid == lTX.txid); + } catch (_) { + tx = null; + } + + if (tx == null) { + // if this is a ltx transaction that is unconfirmed and not represented in the normal transaction set. + if (!lTX.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + if (!txTracker.wasNotifiedPending(lTX.txid)) { + unconfirmedTxnsToNotifyPending.add(lTX); + } + } else { + if (txTracker.wasNotifiedPending(lTX.txid) && + !txTracker.wasNotifiedConfirmed(lTX.txid)) { + unconfirmedTxnsToNotifyConfirmed.add(lTX); } } } } + Logging.instance.log( "unconfirmedTxnsToNotifyPending $unconfirmedTxnsToNotifyPending", level: LogLevel.Info); @@ -2040,8 +2011,10 @@ class FiroWallet extends CoinServiceAPI { level: LogLevel.Info); for (final tx in unconfirmedTxnsToNotifyPending) { - switch (tx.txType) { - case "Received": + final confirmations = tx.getConfirmations(currentChainHeight); + + switch (tx.type) { + case isar_models.TransactionType.incoming: unawaited( NotificationApi.showNotification( title: "Incoming transaction", @@ -2049,28 +2022,29 @@ class FiroWallet extends CoinServiceAPI { walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, ), ); await txTracker.addNotifiedPending(tx.txid); break; - case "Sent": + case isar_models.TransactionType.outgoing: unawaited( NotificationApi.showNotification( - title: - tx.subType == "mint" ? "Anonymizing" : "Outgoing transaction", + title: tx.subType == isar_models.TransactionSubType.mint + ? "Anonymizing" + : "Outgoing transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, ), ); @@ -2082,7 +2056,7 @@ class FiroWallet extends CoinServiceAPI { } for (final tx in unconfirmedTxnsToNotifyConfirmed) { - if (tx.txType == "Received") { + if (tx.type == isar_models.TransactionType.incoming) { unawaited( NotificationApi.showNotification( title: "Incoming transaction confirmed", @@ -2095,10 +2069,12 @@ class FiroWallet extends CoinServiceAPI { ), ); await txTracker.addNotifiedConfirmed(tx.txid); - } else if (tx.txType == "Sent" && tx.subType == "join") { + } else if (tx.type == isar_models.TransactionType.outgoing && + tx.subType == isar_models.TransactionSubType.join) { unawaited( NotificationApi.showNotification( - title: tx.subType == "mint" + title: tx.subType == + isar_models.TransactionSubType.mint // redundant check? ? "Anonymized" : "Outgoing transaction confirmed", body: walletName, @@ -2150,19 +2126,6 @@ class FiroWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: 'receivingIndex', value: 0); - await DB.instance - .put(boxName: walletId, key: 'changeIndex', value: 0); - await DB.instance - .put(boxName: walletId, key: 'mintIndex', value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: [ - "0xdefault" - ]); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -2174,9 +2137,15 @@ class FiroWallet extends CoinServiceAPI { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); final initialChangeAddress = await _generateAddressForChain(1, 0); - await addToAddressesArrayForChain(initialReceivingAddress, 0); - await addToAddressesArrayForChain(initialChangeAddress, 1); - _currentReceivingAddress = Future(() => initialReceivingAddress); + + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll([ + initialReceivingAddress, + initialChangeAddress, + ]); + }); } bool refreshMutex = false; @@ -2220,19 +2189,17 @@ class FiroWallet extends CoinServiceAPI { await checkReceivingAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.1, walletId)); - final newUtxoData = _fetchUtxoData(); + await _refreshUTXOs(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.25, walletId)); - final newTxData = _fetchTransactionData(); + await _refreshTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.35, walletId)); final feeObj = _getFees(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.50, walletId)); - _utxoData = Future(() => newUtxoData); - _transactionData = Future(() => newTxData); _feeObject = Future(() => feeObj); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.60, walletId)); @@ -2244,17 +2211,13 @@ class FiroWallet extends CoinServiceAPI { await _refreshLelantusData(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.80, walletId)); - // await autoMint(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId)); - var balance = await _getFullBalance(); - _balances = Future(() => balance); + await _refreshBalance(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.95, walletId)); - var txData = (await _txnData); - var lTxData = (await lelantusTransactionData); - await getAllTxsToWatch(txData, lTxData); + await getAllTxsToWatch(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(1.0, walletId)); @@ -2301,7 +2264,7 @@ class FiroWallet extends CoinServiceAPI { } Future _fetchMaxFee() async { - final balance = await availableBalance; + final balance = availablePrivateBalance(); int spendAmount = (balance * Decimal.fromInt(Constants.satsPerCoin(coin))) .toBigInt() .toInt(); @@ -2364,8 +2327,9 @@ class FiroWallet extends CoinServiceAPI { } final jindexes = DB.instance.get(boxName: walletId, key: 'jindex') as List?; - final data = await _txnData; - final lelantusData = await lelantusTransactionData; + final transactions = await _txnData; + final lelantusTransactionsd = await lelantusTransactionData; + List coins = []; List lelantusCoinsList = @@ -2373,6 +2337,9 @@ class FiroWallet extends CoinServiceAPI { previousValue.add(element.values.first); return previousValue; }); + + final currentChainHeight = await chainHeight; + for (int i = 0; i < lelantusCoinsList.length; i++) { // Logging.instance.log("lelantusCoinsList[$i]: ${lelantusCoinsList[i]}"); final txn = await cachedElectrumXClient.getTransaction( @@ -2383,17 +2350,27 @@ class FiroWallet extends CoinServiceAPI { final confirmations = txn["confirmations"]; bool isUnconfirmed = confirmations is int && confirmations < 1; if (!jindexes!.contains(lelantusCoinsList[i].index) && - data.findTransaction(lelantusCoinsList[i].txId) == null) { + transactions + .where((e) => e.txid == lelantusCoinsList[i].txId) + .isEmpty) { isUnconfirmed = true; } - if ((data.findTransaction(lelantusCoinsList[i].txId) != null && - !data - .findTransaction(lelantusCoinsList[i].txId)! - .confirmedStatus) || - (lelantusData.findTransaction(lelantusCoinsList[i].txId) != null && - !lelantusData - .findTransaction(lelantusCoinsList[i].txId)! - .confirmedStatus)) { + + // TODO: optimize the following + if ((transactions + .where((e) => e.txid == lelantusCoinsList[i].txId) + .isNotEmpty && + !transactions + .where((e) => e.txid == lelantusCoinsList[i].txId) + .first + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) || + (lelantusTransactionsd + .where((e) => e.txid == lelantusCoinsList[i].txId) + .isNotEmpty && + !lelantusTransactionsd + .where((e) => e.txid == lelantusCoinsList[i].txId) + .first + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS))) { continue; } if (!lelantusCoinsList[i].isUsed && @@ -2407,18 +2384,19 @@ class FiroWallet extends CoinServiceAPI { // index 0 and 1 for the funds available to spend. // index 2 and 3 for all the funds in the wallet (including the undependable ones) - Future> _getFullBalance() async { + // Future> _refreshBalance() async { + Future _refreshBalance() async { try { + final utxosUpdateFuture = _refreshUTXOs(); final List> lelantusCoins = getLelantusCoinMap(); if (lelantusCoins.isNotEmpty) { lelantusCoins.removeWhere((element) => element.values.any((elementCoin) => elementCoin.value == 0)); } - final utxos = await utxoData; - final Decimal price = await firoPrice; final data = await _txnData; final lData = await lelantusTransactionData; + final currentChainHeight = await chainHeight; final jindexes = DB.instance.get(boxName: walletId, key: 'jindex') as List?; int intLelantusBalance = 0; @@ -2426,9 +2404,20 @@ class FiroWallet extends CoinServiceAPI { for (var element in lelantusCoins) { element.forEach((key, value) { - final tx = data.findTransaction(value.txId); - models.Transaction? ltx; - ltx = lData.findTransaction(value.txId); + isar_models.Transaction? tx; + try { + tx == data.firstWhere((e) => e.txid == value.txId); + } catch (_) { + tx = null; + } + + isar_models.Transaction? ltx; + try { + ltx = lData.firstWhere((e) => e.txid == value.txId); + } catch (_) { + ltx = null; + } + // Logging.instance.log("$value $tx $ltx"); if (!jindexes!.contains(value.index) && tx == null) { // This coin is not confirmed and may be replaced @@ -2436,53 +2425,77 @@ class FiroWallet extends CoinServiceAPI { tx == null && !value.isUsed && ltx != null && - !ltx.confirmedStatus) { + !ltx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { unconfirmedLelantusBalance += value.value; } else if (jindexes.contains(value.index) && !value.isUsed) { intLelantusBalance += value.value; } else if (!value.isUsed && - (tx == null ? true : tx.confirmedStatus != false)) { + (tx == null + ? true + : tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) != + false)) { intLelantusBalance += value.value; - } else if (tx != null && tx.confirmedStatus == false) { + } else if (tx != null && + tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + false) { unconfirmedLelantusBalance += value.value; } }); } - final int utxosIntValue = utxos.satoshiBalance; - final Decimal utxosValue = - Format.satoshisToAmount(utxosIntValue, coin: coin); + // final int utxosIntValue = utxos.satoshiBalance; + // final Decimal utxosValue = + // Format.satoshisToAmount(utxosIntValue, coin: coin); - List balances = List.empty(growable: true); + // List balances = List.empty(growable: true); + // + // Decimal lelantusBalance = + // Format.satoshisToAmount(intLelantusBalance, coin: coin); - Decimal lelantusBalance = - Format.satoshisToAmount(intLelantusBalance, coin: coin); + // balances.add(lelantusBalance); 0 + // + // balances.add(lelantusBalance * price); 1 - balances.add(lelantusBalance); + // Decimal _unconfirmedLelantusBalance = + // Format.satoshisToAmount(unconfirmedLelantusBalance, coin: coin); - balances.add(lelantusBalance * price); + // balances.add(lelantusBalance + utxosValue + _unconfirmedLelantusBalance); 2 + // + // balances.add( + // (lelantusBalance + utxosValue + _unconfirmedLelantusBalance) * price); 3 - Decimal _unconfirmedLelantusBalance = - Format.satoshisToAmount(unconfirmedLelantusBalance, coin: coin); + // int availableSats = + // utxos.satoshiBalance - utxos.satoshiBalanceUnconfirmed; + // if (availableSats < 0) { + // availableSats = 0; + // } + // balances.add(Format.satoshisToAmount(availableSats, coin: coin)); 4 - balances.add(lelantusBalance + utxosValue + _unconfirmedLelantusBalance); + // wait for updated uxtos to get updated public balance + await utxosUpdateFuture; - balances.add( - (lelantusBalance + utxosValue + _unconfirmedLelantusBalance) * price); + // todo: shared total between private and public balances? + _balancePrivate = Balance( + coin: coin, + total: intLelantusBalance + unconfirmedLelantusBalance + balance.total, + spendable: intLelantusBalance, + blockedTotal: 0, + pendingSpendable: unconfirmedLelantusBalance + balance.total, + ); + // _balance = Balance( + // coin: coin, + // total: utxos.satoshiBalance, + // spendable: availableSats, + // blockedTotal: 0, + // pendingSpendable: utxos.satoshiBalanceUnconfirmed, + // ); - int availableSats = - utxos.satoshiBalance - utxos.satoshiBalanceUnconfirmed; - if (availableSats < 0) { - availableSats = 0; - } - balances.add(Format.satoshisToAmount(availableSats, coin: coin)); - - Logging.instance.log("balances $balances", level: LogLevel.Info); - await DB.instance.put( - boxName: walletId, - key: 'totalBalance', - value: balances[2].toString()); - return balances; + // Logging.instance.log("balances $balances", level: LogLevel.Info); + // await DB.instance.put( + // boxName: walletId, + // key: 'totalBalance', + // value: balances[2].toString()); + // return balances; } catch (e, s) { Logging.instance.log("Exception rethrown in getFullBalance(): $e\n$s", level: LogLevel.Error); @@ -2509,15 +2522,19 @@ class FiroWallet extends CoinServiceAPI { /// Returns the mint transaction hex to mint all of the available funds. Future> _mintSelection() async { - final List availableOutputs = _outputsList; - final List spendableOutputs = []; + final currentChainHeight = await chainHeight; + final List availableOutputs = await utxos; + final List spendableOutputs = []; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true && + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true && !(availableOutputs[i].isCoinbase && - availableOutputs[i].status.confirmations <= 101)) { + availableOutputs[i].getConfirmations(currentChainHeight) <= + 101)) { spendableOutputs.add(availableOutputs[i]); } } @@ -2528,8 +2545,7 @@ class FiroWallet extends CoinServiceAPI { element.values.any((elementCoin) => elementCoin.value == 0)); } final data = await _txnData; - final dataMap = data.getAllTransactions(); - dataMap.forEach((key, value) { + for (final value in data) { if (value.inputs.isNotEmpty) { for (var element in value.inputs) { if (lelantusCoins @@ -2543,7 +2559,7 @@ class FiroWallet extends CoinServiceAPI { } } } - }); + } // If there is no Utxos to mint then stop the function. if (spendableOutputs.isEmpty) { @@ -2553,7 +2569,7 @@ class FiroWallet extends CoinServiceAPI { } int satoshisBeingUsed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; i < spendableOutputs.length; i++) { final spendable = spendableOutputs[i]; @@ -2568,19 +2584,19 @@ class FiroWallet extends CoinServiceAPI { var tmpTx = await buildMintTransaction( utxoObjectsToUse, satoshisBeingUsed, mintsWithoutFee); - int vsize = (tmpTx['transaction'] as Transaction).virtualSize(); - final Decimal dvsize = Decimal.fromInt(vsize); + int vSize = (tmpTx['transaction'] as Transaction).virtualSize(); + final Decimal dvSize = Decimal.fromInt(vSize); final feesObject = await fees; final Decimal fastFee = Format.satoshisToAmount(feesObject.fast, coin: coin); int firoFee = - (dvsize * fastFee * Decimal.fromInt(100000)).toDouble().ceil(); - // int firoFee = (vsize * feesObject.fast * (1 / 1000.0) * 100000000).ceil(); + (dvSize * fastFee * Decimal.fromInt(100000)).toDouble().ceil(); + // int firoFee = (vSize * feesObject.fast * (1 / 1000.0) * 100000000).ceil(); - if (firoFee < vsize) { - firoFee = vsize + 1; + if (firoFee < vSize) { + firoFee = vSize + 1; } firoFee = firoFee + 10; int satoshiAmountToSend = satoshisBeingUsed - firoFee; @@ -2635,8 +2651,10 @@ class FiroWallet extends CoinServiceAPI { } /// Builds and signs a transaction - Future> buildMintTransaction(List utxosToUse, - int satoshisPerRecipient, List> mintsMap) async { + Future> buildMintTransaction( + List utxosToUse, + int satoshisPerRecipient, + List> mintsMap) async { //todo: check if print needed // debugPrint(utxosToUse.toString()); List addressesToDerive = []; @@ -2754,11 +2772,10 @@ class FiroWallet extends CoinServiceAPI { var txHex = incomplete.toHex(); int fee = amount - incomplete.outs[0].value!; - var price = await firoPrice; var builtHex = txb.build(); // return builtHex; - final locale = - Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; return { "transaction": builtHex, "txid": txId, @@ -2770,30 +2787,23 @@ class FiroWallet extends CoinServiceAPI { "txType": "Sent", "confirmed_status": false, "amount": Format.satoshisToAmount(amount, coin: coin).toDouble(), - "worthNow": Format.localizedStringAsFixed( - value: ((Decimal.fromInt(amount) * price) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!), "timestamp": DateTime.now().millisecondsSinceEpoch ~/ 1000, "subType": "mint", "mintsMap": mintsMap, }; } - Future _refreshLelantusData() async { + Future _refreshLelantusData() async { final List> lelantusCoins = getLelantusCoinMap(); final jindexes = DB.instance.get(boxName: walletId, key: 'jindex') as List?; // Get all joinsplit transaction ids - final lelantusTxData = await lelantusTransactionData; - final listLelantusTxData = lelantusTxData.getAllTransactions(); + final listLelantusTxData = await lelantusTransactionData; List joinsplits = []; - for (final tx in listLelantusTxData.values) { - if (tx.subType == "join") { + for (final tx in listLelantusTxData) { + if (tx.subType == isar_models.TransactionSubType.join) { joinsplits.add(tx.txid); } } @@ -2809,32 +2819,43 @@ class FiroWallet extends CoinServiceAPI { } } - final currentPrice = await firoPrice; // Grab the most recent information on all the joinsplits - final locale = - Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final updatedJSplit = await getJMintTransactions(cachedElectrumXClient, - joinsplits, _prefs.currency, coin, currentPrice, locale!); + final updatedJSplit = await getJMintTransactions( + cachedElectrumXClient, + joinsplits, + coin, + ); + + final currentChainHeight = await chainHeight; // update all of joinsplits that are now confirmed. for (final tx in updatedJSplit) { - final currentTx = listLelantusTxData[tx.txid]; + isar_models.Transaction? currentTx; + + try { + currentTx = listLelantusTxData.firstWhere((e) => e.txid == tx.txid); + } catch (_) { + currentTx = null; + } + if (currentTx == null) { // this send was accidentally not included in the list - listLelantusTxData[tx.txid] = tx; + tx.isLelantus = true; + listLelantusTxData.add(tx); continue; } - if (currentTx.confirmedStatus != tx.confirmedStatus) { - listLelantusTxData[tx.txid] = tx; + if (currentTx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) != + tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + listLelantusTxData.removeWhere((e) => e.txid == tx.txid); + tx.isLelantus = true; + listLelantusTxData.add(tx); } } - final txData = await _txnData; - // Logging.instance.log(txData.txChunks); - final listTxData = txData.getAllTransactions(); - listTxData.forEach((key, value) { + final listTxData = await _txnData; + for (final value in listTxData) { // ignore change addresses // bool hasAtLeastOneReceive = false; // int howManyReceiveInputs = 0; @@ -2849,23 +2870,32 @@ class FiroWallet extends CoinServiceAPI { // } // } - if (value.txType == "Received" && value.subType != "mint") { + if (value.type == isar_models.TransactionType.incoming && + value.subType != isar_models.TransactionSubType.mint) { // Every receive other than a mint should be shown. Mints will be collected and shown from the send side - listLelantusTxData[value.txid] = value; - } else if (value.txType == "Sent") { + listLelantusTxData.removeWhere((e) => e.txid == value.txid); + value.isLelantus = true; + listLelantusTxData.add(value); + } else if (value.type == isar_models.TransactionType.outgoing) { // all sends should be shown, mints will be displayed correctly in the ui - listLelantusTxData[value.txid] = value; + listLelantusTxData.removeWhere((e) => e.txid == value.txid); + value.isLelantus = true; + listLelantusTxData.add(value); } - }); + } - // update the _lelantusTransactionData - final models.TransactionData newTxData = - models.TransactionData.fromMap(listLelantusTxData); - // Logging.instance.log(newTxData.txChunks); - _lelantusTransactionData = Future(() => newTxData); - await DB.instance.put( - boxName: walletId, key: 'latest_lelantus_tx_model', value: newTxData); - return newTxData; + // TODO: optimize this whole lelantus process + await isar.writeTxn( + () async => isar.transactions.putAllByTxid(listLelantusTxData)); + + // // update the _lelantusTransactionData + // final models.TransactionData newTxData = + // models.TransactionData.fromMap(listLelantusTxData); + // // Logging.instance.log(newTxData.txChunks); + // _lelantusTransactionData = Future(() => newTxData); + // await DB.instance.put( + // boxName: walletId, key: 'latest_lelantus_tx_model', value: newTxData); + // return newTxData; } Future _getMintHex(int amount, int index) async { @@ -2955,21 +2985,42 @@ class FiroWallet extends CoinServiceAPI { boxName: walletId, key: '_lelantus_coins', value: coins); // add the send transaction - models.TransactionData data = await lelantusTransactionData; - Map transactions = - data.getAllTransactions(); - transactions[transactionInfo['txid'] as String] = - models.Transaction.fromLelantusJson(transactionInfo); - final models.TransactionData newTxData = - models.TransactionData.fromMap(transactions); - await DB.instance.put( - boxName: walletId, - key: 'latest_lelantus_tx_model', - value: newTxData); - final ldata = DB.instance.get( - boxName: walletId, - key: 'latest_lelantus_tx_model') as models.TransactionData; - _lelantusTransactionData = Future(() => ldata); + final transaction = isar_models.Transaction() + ..txid = transactionInfo['txid'] as String + ..timestamp = transactionInfo['timestamp'] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000) + ..type = transactionInfo['txType'] == "Received" + ? isar_models.TransactionType.incoming + : isar_models.TransactionType.outgoing + ..amount = Format.decimalAmountToSatoshis( + Decimal.parse(transactionInfo["amount"].toString()), coin) + ..fee = Format.decimalAmountToSatoshis( + Decimal.parse(transactionInfo["fees"].toString()), coin) + ..address = transactionInfo["address"] as String + ..height = transactionInfo["height"] as int? + ..subType = transactionInfo["subType"] == "mint" + ? isar_models.TransactionSubType.mint + : transactionInfo["subType"] == "join" + ? isar_models.TransactionSubType.join + : isar_models.TransactionSubType.none + ..otherData = transactionInfo["otherData"] as String? + ..isLelantus = true + ..isCancelled = false; + + await isar.writeTxn(() async { + await isar.transactions.put(transaction); + }); + + // final models.TransactionData newTxData = + // models.TransactionData.fromMap(transactions); + // await DB.instance.put( + // boxName: walletId, + // key: 'latest_lelantus_tx_model', + // value: newTxData); + // final ldata = DB.instance.get( + // boxName: walletId, + // key: 'latest_lelantus_tx_model') as models.TransactionData; + // _lelantusTransactionData = Future(() => ldata); } else { // This is a mint Logging.instance.log("this is a mint", level: LogLevel.Info); @@ -3075,25 +3126,28 @@ class FiroWallet extends CoinServiceAPI { Future checkReceivingAddressForTransactions() async { try { - final String currentExternalAddr = await _getCurrentAddressForChain(0); - final int numtxs = - await _getReceivedTxCount(address: currentExternalAddr); + final currentReceiving = await _currentReceivingAddress; + + final int txCount = + await _getReceivedTxCount(address: currentReceiving.value); Logging.instance.log( - 'Number of txs for current receiving: $currentExternalAddr: $numtxs', + 'Number of txs for current receiving address $currentReceiving: $txCount', level: LogLevel.Info); - if (numtxs >= 1) { - await incrementAddressIndexForChain( - 0); // First increment the receiving index - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: 'receivingIndex') - as int; // Check the new receiving index - final newReceivingAddress = await _generateAddressForChain(0, - newReceivingIndex); // Use new index to derive a new receiving address - await addToAddressesArrayForChain(newReceivingAddress, - 0); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddress = Future(() => - newReceivingAddress); // Set the new receiving address that the service + if (txCount >= 1) { + // First increment the receiving index + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address + final newReceivingAddress = await _generateAddressForChain( + 0, + newReceivingIndex, + ); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( @@ -3110,23 +3164,27 @@ class FiroWallet extends CoinServiceAPI { Future checkChangeAddressForTransactions() async { try { - final String currentExternalAddr = await _getCurrentAddressForChain(1); - final int numtxs = - await _getReceivedTxCount(address: currentExternalAddr); + final currentChange = await _currentChangeAddress; + final int txCount = + await _getReceivedTxCount(address: currentChange.value); Logging.instance.log( - 'Number of txs for current change address: $currentExternalAddr: $numtxs', + 'Number of txs for current change address: $currentChange: $txCount', level: LogLevel.Info); - if (numtxs >= 1) { - await incrementAddressIndexForChain( - 0); // First increment the change index - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: 'changeIndex') - as int; // Check the new change index - final newReceivingAddress = await _generateAddressForChain(0, - newReceivingIndex); // Use new index to derive a new change address - await addToAddressesArrayForChain(newReceivingAddress, - 0); // Add that new receiving address to the array of change addresses + if (txCount >= 1) { + // First increment the change index + final newChangeIndex = currentChange.derivationIndex + 1; + + // Use new index to derive a new change address + final newChangeAddress = await _generateAddressForChain( + 1, + newChangeIndex, + ); + + // Add that new change address + await isar.writeTxn(() async { + await isar.addresses.put(newChangeAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( @@ -3141,21 +3199,27 @@ class FiroWallet extends CoinServiceAPI { } } - Future> _fetchAllOwnAddresses() async { - final List allAddresses = []; - final receivingAddresses = - DB.instance.get(boxName: walletId, key: 'receivingAddresses') - as List; - final changeAddresses = - DB.instance.get(boxName: walletId, key: 'changeAddresses') - as List; - - for (var i = 0; i < receivingAddresses.length; i++) { - allAddresses.add(receivingAddresses[i] as String); - } - for (var i = 0; i < changeAddresses.length; i++) { - allAddresses.add(changeAddresses[i] as String); - } + Future> _fetchAllOwnAddresses() async { + final allAddresses = await isar.addresses + .filter() + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change) + .findAll(); + // final List allAddresses = []; + // final receivingAddresses = + // DB.instance.get(boxName: walletId, key: 'receivingAddresses') + // as List; + // final changeAddresses = + // DB.instance.get(boxName: walletId, key: 'changeAddresses') + // as List; + // + // for (var i = 0; i < receivingAddresses.length; i++) { + // allAddresses.add(receivingAddresses[i] as String); + // } + // for (var i = 0; i < changeAddresses.length; i++) { + // allAddresses.add(changeAddresses[i] as String); + // } return allAddresses; } @@ -3204,298 +3268,326 @@ class FiroWallet extends CoinServiceAPI { } } - Future _fetchTransactionData() async { - final changeAddresses = - DB.instance.get(boxName: walletId, key: 'changeAddresses') - as List; - final List allAddresses = await _fetchAllOwnAddresses(); - // Logging.instance.log("receiving addresses: $receivingAddresses"); - // Logging.instance.log("change addresses: $changeAddresses"); + Future _refreshTransactions() async { + // final changeAddresses = + // DB.instance.get(boxName: walletId, key: 'changeAddresses') + // as List; + // final List allAddresses = await _fetchAllOwnAddresses(); + // // Logging.instance.log("receiving addresses: $receivingAddresses"); + // // Logging.instance.log("change addresses: $changeAddresses"); + // + // List> allTxHashes = await _fetchHistory(allAddresses); + // + // final cachedTransactions = + // DB.instance.get(boxName: walletId, key: 'latest_tx_model') + // as models.TransactionData?; + // int latestTxnBlockHeight = + // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") + // as int? ?? + // 0; + // + // final unconfirmedCachedTransactions = + // cachedTransactions?.getAllTransactions() ?? {}; + // unconfirmedCachedTransactions + // .removeWhere((key, value) => value.confirmedStatus); + // + // if (cachedTransactions != null) { + // for (final tx in allTxHashes.toList(growable: false)) { + // final txHeight = tx["height"] as int; + // if (txHeight > 0 && + // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { + // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { + // allTxHashes.remove(tx); + // } + // } + // } + // } + // + // List hashes = []; + // for (var element in allTxHashes) { + // hashes.add(element['tx_hash'] as String); + // } + final List allAddresses = + await _fetchAllOwnAddresses(); - List> allTxHashes = await _fetchHistory(allAddresses); + final List> allTxHashes = + await _fetchHistory(allAddresses.map((e) => e.value).toList()); - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as models.TransactionData?; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; + List hashes = + allTxHashes.map((e) => e['tx_hash'] as String).toList(growable: false); - final unconfirmedCachedTransactions = - cachedTransactions?.getAllTransactions() ?? {}; - unconfirmedCachedTransactions - .removeWhere((key, value) => value.confirmedStatus); - - if (cachedTransactions != null) { - for (final tx in allTxHashes.toList(growable: false)) { - final txHeight = tx["height"] as int; - if (txHeight > 0 && - txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - allTxHashes.remove(tx); - } - } - } - } - - List hashes = []; - for (var element in allTxHashes) { - hashes.add(element['tx_hash'] as String); - } List> allTransactions = await fastFetch(hashes); Logging.instance.log("allTransactions length: ${allTransactions.length}", level: LogLevel.Info); - // sort thing stuff - final currentPrice = await firoPrice; - final List> midSortedArray = []; - - final locale = - Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - - Logging.instance.log("refresh the txs", level: LogLevel.Info); + // // sort thing stuff + // final currentPrice = await firoPrice; + // final List> midSortedArray = []; + // + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // + // Logging.instance.log("refresh the txs", level: LogLevel.Info); for (final txObject in allTransactions) { - // Logging.instance.log(txObject); - List sendersArray = []; - List recipientsArray = []; + // // Logging.instance.log(txObject); + // List sendersArray = []; + // List recipientsArray = []; + // + // // Usually only has value when txType = 'Send' + // int inputAmtSentFromWallet = 0; + // // Usually has value regardless of txType due to change addresses + // int outputAmtAddressedToWallet = 0; + // + // Map midSortedTx = {}; + // List aliens = []; + // + // for (final input in txObject["vin"] as List) { + // final address = input["address"] as String?; + // if (address != null) { + // sendersArray.add(address); + // } + // } + // + // // Logging.instance.log("sendersArray: $sendersArray"); + // + // for (final output in txObject["vout"] as List) { + // final addresses = output["scriptPubKey"]["addresses"] as List?; + // if (addresses != null && addresses.isNotEmpty) { + // recipientsArray.add(addresses[0] as String); + // } + // } + // // Logging.instance.log("recipientsArray: $recipientsArray"); + // + // final foundInSenders = + // allAddresses.any((element) => sendersArray.contains(element)); + // // Logging.instance.log("foundInSenders: $foundInSenders"); + // + // String outAddress = ""; + // + // int fees = 0; + // + // // If txType = Sent, then calculate inputAmtSentFromWallet, calculate who received how much in aliens array (check outputs) + // if (foundInSenders) { + // int outAmount = 0; + // int inAmount = 0; + // bool nFeesUsed = false; + // + // for (final input in txObject["vin"] as List) { + // final nFees = input["nFees"]; + // if (nFees != null) { + // nFeesUsed = true; + // fees = (Decimal.parse(nFees.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // final address = input["address"]; + // final value = input["valueSat"]; + // if (address != null && value != null) { + // if (allAddresses.contains(address)) { + // inputAmtSentFromWallet += value as int; + // } + // } + // + // if (value != null) { + // inAmount += value as int; + // } + // } + // + // for (final output in txObject["vout"] as List) { + // final addresses = output["scriptPubKey"]["addresses"] as List?; + // final value = output["value"]; + // if (addresses != null && addresses.isNotEmpty) { + // final address = addresses[0] as String; + // if (value != null) { + // if (changeAddresses.contains(address)) { + // inputAmtSentFromWallet -= (Decimal.parse(value.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } else { + // outAddress = address; + // } + // } + // } + // if (value != null) { + // outAmount += (Decimal.parse(value.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // + // fees = nFeesUsed ? fees : inAmount - outAmount; + // inputAmtSentFromWallet -= inAmount - outAmount; + // } else { + // for (final input in txObject["vin"] as List) { + // final nFees = input["nFees"]; + // if (nFees != null) { + // fees += (Decimal.parse(nFees.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // + // for (final output in txObject["vout"] as List) { + // final addresses = output["scriptPubKey"]["addresses"] as List?; + // if (addresses != null && addresses.isNotEmpty) { + // final address = addresses[0] as String; + // final value = output["value"]; + // // Logging.instance.log(address + value.toString()); + // + // if (allAddresses.contains(address)) { + // outputAmtAddressedToWallet += (Decimal.parse(value.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // outAddress = address; + // } + // } + // } + // } + // + // final int confirms = txObject["confirmations"] as int? ?? 0; + // + // // create final tx map + // midSortedTx["txid"] = txObject["txid"]; + // midSortedTx["confirmed_status"] = confirms >= MINIMUM_CONFIRMATIONS; + // midSortedTx["confirmations"] = confirms; + // midSortedTx["timestamp"] = txObject["blocktime"] ?? + // (DateTime.now().millisecondsSinceEpoch ~/ 1000); + // if (foundInSenders) { + // midSortedTx["txType"] = "Sent"; + // midSortedTx["amount"] = inputAmtSentFromWallet; + // final String worthNow = Format.localizedStringAsFixed( + // value: ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // midSortedTx["worthNow"] = worthNow; + // midSortedTx["worthAtBlockTimestamp"] = worthNow; + // if (txObject["vout"][0]["scriptPubKey"]["type"] == "lelantusmint") { + // midSortedTx["subType"] = "mint"; + // } + // } else { + // midSortedTx["txType"] = "Received"; + // midSortedTx["amount"] = outputAmtAddressedToWallet; + // final worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // midSortedTx["worthNow"] = worthNow; + // midSortedTx["worthAtBlockTimestamp"] = worthNow; + // } + // midSortedTx["aliens"] = aliens; + // midSortedTx["fees"] = fees; + // midSortedTx["address"] = outAddress; + // midSortedTx["inputSize"] = txObject["vin"].length; + // midSortedTx["outputSize"] = txObject["vout"].length; + // midSortedTx["inputs"] = txObject["vin"]; + // midSortedTx["outputs"] = txObject["vout"]; + // + // final int height = txObject["height"] as int? ?? 0; + // midSortedTx["height"] = height; + // + // if (height >= latestTxnBlockHeight) { + // latestTxnBlockHeight = height; + // } + // + // midSortedArray.add(midSortedTx); - // Usually only has value when txType = 'Send' - int inputAmtSentFromWallet = 0; - // Usually has value regardless of txType due to change addresses - int outputAmtAddressedToWallet = 0; + final txn = await parseTransaction( + txObject, + cachedElectrumXClient, + allAddresses, + coin, + MINIMUM_CONFIRMATIONS, + ); - Map midSortedTx = {}; - List aliens = []; - - for (final input in txObject["vin"] as List) { - final address = input["address"] as String?; - if (address != null) { - sendersArray.add(address); - } - } - - // Logging.instance.log("sendersArray: $sendersArray"); - - for (final output in txObject["vout"] as List) { - final addresses = output["scriptPubKey"]["addresses"] as List?; - if (addresses != null && addresses.isNotEmpty) { - recipientsArray.add(addresses[0] as String); - } - } - // Logging.instance.log("recipientsArray: $recipientsArray"); - - final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)); - // Logging.instance.log("foundInSenders: $foundInSenders"); - - String outAddress = ""; - - int fees = 0; - - // If txType = Sent, then calculate inputAmtSentFromWallet, calculate who received how much in aliens array (check outputs) - if (foundInSenders) { - int outAmount = 0; - int inAmount = 0; - bool nFeesUsed = false; - - for (final input in txObject["vin"] as List) { - final nFees = input["nFees"]; - if (nFees != null) { - nFeesUsed = true; - fees = (Decimal.parse(nFees.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - final address = input["address"]; - final value = input["valueSat"]; - if (address != null && value != null) { - if (allAddresses.contains(address)) { - inputAmtSentFromWallet += value as int; - } - } - - if (value != null) { - inAmount += value as int; - } - } - - for (final output in txObject["vout"] as List) { - final addresses = output["scriptPubKey"]["addresses"] as List?; - final value = output["value"]; - if (addresses != null && addresses.isNotEmpty) { - final address = addresses[0] as String; - if (value != null) { - if (changeAddresses.contains(address)) { - inputAmtSentFromWallet -= (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } else { - outAddress = address; - } - } - } - if (value != null) { - outAmount += (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - - fees = nFeesUsed ? fees : inAmount - outAmount; - inputAmtSentFromWallet -= inAmount - outAmount; - } else { - for (final input in txObject["vin"] as List) { - final nFees = input["nFees"]; - if (nFees != null) { - fees += (Decimal.parse(nFees.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - - for (final output in txObject["vout"] as List) { - final addresses = output["scriptPubKey"]["addresses"] as List?; - if (addresses != null && addresses.isNotEmpty) { - final address = addresses[0] as String; - final value = output["value"]; - // Logging.instance.log(address + value.toString()); - - if (allAddresses.contains(address)) { - outputAmtAddressedToWallet += (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - outAddress = address; - } - } - } - } - - final int confirms = txObject["confirmations"] as int? ?? 0; - - // create final tx map - midSortedTx["txid"] = txObject["txid"]; - midSortedTx["confirmed_status"] = confirms >= MINIMUM_CONFIRMATIONS; - midSortedTx["confirmations"] = confirms; - midSortedTx["timestamp"] = txObject["blocktime"] ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000); - if (foundInSenders) { - midSortedTx["txType"] = "Sent"; - midSortedTx["amount"] = inputAmtSentFromWallet; - final String worthNow = Format.localizedStringAsFixed( - value: ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - if (txObject["vout"][0]["scriptPubKey"]["type"] == "lelantusmint") { - midSortedTx["subType"] = "mint"; - } - } else { - midSortedTx["txType"] = "Received"; - midSortedTx["amount"] = outputAmtAddressedToWallet; - final worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - } - midSortedTx["aliens"] = aliens; - midSortedTx["fees"] = fees; - midSortedTx["address"] = outAddress; - midSortedTx["inputSize"] = txObject["vin"].length; - midSortedTx["outputSize"] = txObject["vout"].length; - midSortedTx["inputs"] = txObject["vin"]; - midSortedTx["outputs"] = txObject["vout"]; - - final int height = txObject["height"] as int? ?? 0; - midSortedTx["height"] = height; - - if (height >= latestTxnBlockHeight) { - latestTxnBlockHeight = height; - } - - midSortedArray.add(midSortedTx); + // final tx = await isar.transactions + // .filter() + // .txidMatches(midSortedTx.txid) + // .findFirst(); + // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar + // if (tx == null) { + await isar.writeTxn(() async { + await isar.transactions.put(txn); + }); + // } } - - // sort by date ---- //TODO not sure if needed - // shouldn't be any issues with a null timestamp but I got one at some point? - midSortedArray.sort((a, b) { - final aT = a["timestamp"]; - final bT = b["timestamp"]; - - if (aT == null && bT == null) { - return 0; - } else if (aT == null) { - return -1; - } else if (bT == null) { - return 1; - } else { - return (bT as int) - (aT as int); - } - }); - - // buildDateTimeChunks - final Map result = {"dateTimeChunks": []}; - final dateArray = []; - - for (int i = 0; i < midSortedArray.length; i++) { - final txObject = midSortedArray[i]; - final date = - models.extractDateFromTimestamp(txObject["timestamp"] as int); - final txTimeArray = [txObject["timestamp"], date]; - - if (dateArray.contains(txTimeArray[1])) { - result["dateTimeChunks"].forEach((dynamic chunk) { - if (models.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], - }; - result["dateTimeChunks"].add(chunk); - } - } - - final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - transactionsMap - .addAll(models.TransactionData.fromJson(result).getAllTransactions()); - - final txModel = models.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); - - cachedTxData = txModel; - return txModel; + // + // // sort by date ---- //TODO not sure if needed + // // shouldn't be any issues with a null timestamp but I got one at some point? + // midSortedArray.sort((a, b) { + // final aT = a["timestamp"]; + // final bT = b["timestamp"]; + // + // if (aT == null && bT == null) { + // return 0; + // } else if (aT == null) { + // return -1; + // } else if (bT == null) { + // return 1; + // } else { + // return (bT as int) - (aT as int); + // } + // }); + // + // // buildDateTimeChunks + // final Map result = {"dateTimeChunks": []}; + // final dateArray = []; + // + // for (int i = 0; i < midSortedArray.length; i++) { + // final txObject = midSortedArray[i]; + // final date = + // models.extractDateFromTimestamp(txObject["timestamp"] as int); + // final txTimeArray = [txObject["timestamp"], date]; + // + // if (dateArray.contains(txTimeArray[1])) { + // result["dateTimeChunks"].forEach((dynamic chunk) { + // if (models.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], + // }; + // result["dateTimeChunks"].add(chunk); + // } + // } + // + // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; + // transactionsMap + // .addAll(models.TransactionData.fromJson(result).getAllTransactions()); + // + // final txModel = models.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); + // + // cachedTxData = txModel; + // return txModel; } - Future _fetchUtxoData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future _refreshUTXOs() async { + final allAddresses = await _fetchAllOwnAddresses(); try { final fetchedUtxoList = >>[]; @@ -3508,7 +3600,7 @@ class FiroWallet extends CoinServiceAPI { batches[batchNumber] = {}; } final scripthash = - AddressUtils.convertToScriptHash(allAddresses[i], _network); + AddressUtils.convertToScriptHash(allAddresses[i].value, _network); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -3526,137 +3618,92 @@ class FiroWallet extends CoinServiceAPI { } } } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> outputArray = []; - int satoshiBalance = 0; + + final currentChainHeight = await chainHeight; + + final List outputArray = []; + int satoshiBalanceTotal = 0; int satoshiBalancePending = 0; + int satoshiBalanceSpendable = 0; + int satoshiBalanceBlocked = 0; for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - int value = fetchedUtxoList[i][j]["value"] as int; - satoshiBalance += value; - final txn = await cachedElectrumXClient.getTransaction( txHash: fetchedUtxoList[i][j]["tx_hash"] as String, verbose: true, coin: coin, ); - final Map utxo = {}; - final int confirmations = txn["confirmations"] as int? ?? 0; - final bool confirmed = confirmations >= MINIMUM_CONFIRMATIONS; - if (!confirmed) { - satoshiBalancePending += value; + final utxo = isar_models.UTXO(); + + utxo.txid = txn["txid"] as String; + utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; + utxo.value = fetchedUtxoList[i][j]["value"] as int; + utxo.name = ""; + + // todo check here if we should mark as blocked + utxo.isBlocked = false; + utxo.blockedReason = null; + + utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; + utxo.blockHash = txn["blockhash"] as String?; + utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; + utxo.blockTime = txn["blocktime"] as int?; + + satoshiBalanceTotal += utxo.value; + + if (utxo.isBlocked) { + satoshiBalanceBlocked += utxo.value; + } else { + if (utxo.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + satoshiBalanceSpendable += utxo.value; + } else { + satoshiBalancePending += utxo.value; + } } - utxo["txid"] = txn["txid"]; - utxo["vout"] = fetchedUtxoList[i][j]["tx_pos"]; - utxo["value"] = value; - - utxo["status"] = {}; - utxo["status"]["confirmed"] = confirmed; - utxo["status"]["confirmations"] = confirmations; - utxo["status"]["confirmed"] = - txn["confirmations"] == null ? false : txn["confirmations"] > 0; - - utxo["status"]["block_height"] = fetchedUtxoList[i][j]["height"]; - utxo["status"]["block_hash"] = txn["blockhash"]; - utxo["status"]["block_time"] = txn["blocktime"]; - - final fiatValue = ((Decimal.fromInt(value) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - utxo["rawWorth"] = fiatValue; - utxo["fiatWorth"] = fiatValue.toString(); - utxo["is_coinbase"] = txn['vin'][0]['coinbase'] != null; outputArray.add(utxo); } } - Decimal currencyBalanceRaw = - ((Decimal.fromInt(satoshiBalance) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - - final Map result = { - "total_user_currency": currencyBalanceRaw.toString(), - "total_sats": satoshiBalance, - "total_btc": (Decimal.fromInt(satoshiBalance) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal( - scaleOnInfinitePrecision: Constants.decimalPlacesForCoin(coin)) - .toString(), - "outputArray": outputArray, - "unconfirmed": satoshiBalancePending, - }; - - final dataModel = UtxoData.fromJson(result); - - final List allOutputs = dataModel.unspentOutputArray; Logging.instance - .log('Outputs fetched: $allOutputs', level: LogLevel.Info); - await _sortOutputs(allOutputs); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: dataModel); - // await DB.instance.put( - // boxName: walletId, - // key: 'totalBalance', - // value: dataModel.satoshiBalance); - return dataModel; + .log('Outputs fetched: $outputArray', level: LogLevel.Info); + + await isar.writeTxn(() async { + await isar.utxos.clear(); + await isar.utxos.putAll(outputArray); + }); + + // finally update public balance + _balance = Balance( + coin: coin, + total: satoshiBalanceTotal, + spendable: satoshiBalanceSpendable, + blockedTotal: satoshiBalanceBlocked, + pendingSpendable: satoshiBalancePending, + ); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); - final latestTxModel = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model') - as models.UtxoData?; - - if (latestTxModel == null) { - final emptyModel = { - "total_user_currency": "0.00", - "total_sats": 0, - "total_btc": "0", - "outputArray": [] - }; - return UtxoData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old output model located", level: LogLevel.Warning); - return latestTxModel; - } - } - } - - Future _getLelantusTransactionData() async { - final latestModel = DB.instance.get( - boxName: walletId, - key: 'latest_lelantus_tx_model') as models.TransactionData?; - - if (latestModel == null) { - final emptyModel = {"dateTimeChunks": []}; - return models.TransactionData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old transaction model located", level: LogLevel.Warning); - return latestModel; } } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! Future _getCurrentAddressForChain(int chain) async { - if (chain == 0) { - final externalChainArray = (DB.instance.get( - boxName: walletId, key: 'receivingAddresses')) as List; - return externalChainArray.last as String; - } else { - // Here, we assume that chain == 1 - final internalChainArray = - (DB.instance.get(boxName: walletId, key: 'changeAddresses')) - as List; - return internalChainArray.last as String; - } + final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; + + isar_models.Address? address = await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(subType) + .sortByDerivationIndexDesc() + .findFirst(); + + return address!.value; } Future fillAddresses(String suppliedMnemonic, @@ -3723,7 +3770,8 @@ class FiroWallet extends CoinServiceAPI { /// Generates a new internal or external chain address for the wallet using a BIP84 derivation path. /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! /// [index] - This can be any integer >= 0 - Future _generateAddressForChain(int chain, int index) async { + Future _generateAddressForChain( + int chain, int index) async { // final wallet = await Hive.openBox(this._walletId); final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); Map? derivations; @@ -3747,104 +3795,72 @@ class FiroWallet extends CoinServiceAPI { level: LogLevel.Info); return _generateAddressForChain(chain, index); } - return derivations["$index"]['address'] as String; + return isar_models.Address() + ..value = derivations["$index"]['address'] as String + ..publicKey = Format.stringToUint8List( + derivations["$index"]['publicKey'] as String) + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = isar_models.AddressType.p2pkh + ..derivationIndex = index; } else { final node = await compute( getBip32NodeWrapper, Tuple4(chain, index, mnemonic!, _network)); - return P2PKH(network: _network, data: PaymentData(pubkey: node.publicKey)) - .data - .address!; + final address = + P2PKH(network: _network, data: PaymentData(pubkey: node.publicKey)) + .data + .address!; + + return isar_models.Address() + ..value = address + ..publicKey = node.publicKey + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = isar_models.AddressType.p2pkh + ..derivationIndex = index; } } - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future incrementAddressIndexForChain(int chain) async { - if (chain == 0) { - final newIndex = - DB.instance.get(boxName: walletId, key: 'receivingIndex') + - 1; - await DB.instance.put( - boxName: walletId, key: 'receivingIndex', value: newIndex); - } else { - // Here we assume chain == 1 since it can only be either 0 or 1 - final newIndex = - DB.instance.get(boxName: walletId, key: 'changeIndex') + 1; - await DB.instance - .put(boxName: walletId, key: 'changeIndex', value: newIndex); - } - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future addToAddressesArrayForChain(String address, int chain) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } - } - - /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - /// Now also checks for output labeling. - Future _sortOutputs(List utxos) async { - final blockedHashArray = - DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - as List?; - final List lst = []; - if (blockedHashArray != null) { - for (var hash in blockedHashArray) { - lst.add(hash as String); - } - } - final labels = - DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - {}; - - _outputsList = []; - - for (var i = 0; i < utxos.length; i++) { - if (labels[utxos[i].txid] != null) { - utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - } else { - utxos[i].txName = 'Output #$i'; - } - - if (utxos[i].status.confirmed == false) { - _outputsList.add(utxos[i]); - } else { - if (lst.contains(utxos[i].txid)) { - utxos[i].blocked = true; - _outputsList.add(utxos[i]); - } else if (!lst.contains(utxos[i].txid)) { - _outputsList.add(utxos[i]); - } - } - } - } + // /// Takes in a list of isar_models.UTXOs and adds a name (dependent on object index within list) + // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. + // /// Now also checks for output labeling. + // Future _sortOutputs(List utxos) async { + // final blockedHashArray = + // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') + // as List?; + // final List lst = []; + // if (blockedHashArray != null) { + // for (var hash in blockedHashArray) { + // lst.add(hash as String); + // } + // } + // final labels = + // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? + // {}; + // + // _outputsList = []; + // + // for (var i = 0; i < utxos.length; i++) { + // if (labels[utxos[i].txid] != null) { + // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; + // } else { + // utxos[i].txName = 'Output #$i'; + // } + // + // if (utxos[i].status.confirmed == false) { + // _outputsList.add(utxos[i]); + // } else { + // if (lst.contains(utxos[i].txid)) { + // utxos[i].blocked = true; + // _outputsList.add(utxos[i]); + // } else if (!lst.contains(utxos[i].txid)) { + // _outputsList.add(utxos[i]); + // } + // } + // } + // } @override Future fullRescan( @@ -4134,9 +4150,11 @@ class FiroWallet extends CoinServiceAPI { } Future _makeDerivations( - String suppliedMnemonic, int maxUnusedAddressGap) async { - List receivingAddressArray = []; - List changeAddressArray = []; + String suppliedMnemonic, + int maxUnusedAddressGap, + ) async { + List receivingAddressArray = []; + List changeAddressArray = []; int receivingIndex = -1; int changeIndex = -1; @@ -4188,7 +4206,14 @@ class FiroWallet extends CoinServiceAPI { int numTxs = await futureNumTxs; if (numTxs >= 1) { receivingIndex = i; - receivingAddressArray.add(address); + final addr = isar_models.Address() + ..value = address + ..type = isar_models.AddressType.p2pkh + ..subType = isar_models.AddressSubType.receiving + ..derivationIndex = i + ..publicKey = Format.stringToUint8List( + receiveDerivation['publicKey'] as String); + receivingAddressArray.add(addr); } else if (numTxs == 0) { receivingGapCounter += 1; } @@ -4205,7 +4230,14 @@ class FiroWallet extends CoinServiceAPI { int numTxs = await _futureNumTxs; if (numTxs >= 1) { changeIndex = i; - changeAddressArray.add(_address); + final addr = isar_models.Address() + ..value = address + ..type = isar_models.AddressType.p2pkh + ..subType = isar_models.AddressSubType.change + ..derivationIndex = i + ..publicKey = Format.stringToUint8List( + changeDerivation['publicKey'] as String); + changeAddressArray.add(addr); } else if (numTxs == 0) { changeGapCounter += 1; } @@ -4221,31 +4253,23 @@ class FiroWallet extends CoinServiceAPI { // If restoring a wallet that never received any funds, then set receivingArray manually // If we didn't do this, it'd store an empty array if (receivingIndex == -1) { - final String receivingAddress = await _generateAddressForChain(0, 0); + final receivingAddress = await _generateAddressForChain(0, 0); receivingAddressArray.add(receivingAddress); } // If restoring a wallet that never sent any funds with change, then set changeArray // manually. If we didn't do this, it'd store an empty array. if (changeIndex == -1) { - final String changeAddress = await _generateAddressForChain(1, 0); + final changeAddress = await _generateAddressForChain(1, 0); changeAddressArray.add(changeAddress); } - await DB.instance.put( - boxName: walletId, - key: 'receivingAddresses', - value: receivingAddressArray); - await DB.instance.put( - boxName: walletId, key: 'changeAddresses', value: changeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndex', - value: receivingIndex == -1 ? 0 : receivingIndex); - await DB.instance.put( - boxName: walletId, - key: 'changeIndex', - value: changeIndex == -1 ? 0 : changeIndex); + await isar.writeTxn(() async { + await isar.addresses.putAll([ + ...receivingAddressArray, + ...changeAddressArray, + ]); + }); } /// Recovers wallet from [suppliedMnemonic]. Expects a valid mnemonic. @@ -4255,6 +4279,8 @@ class FiroWallet extends CoinServiceAPI { Logging.instance .log("PROCESSORS ${Platform.numberOfProcessors}", level: LogLevel.Info); try { + await _isarInit(); + final latestSetId = await getLatestSetId(); final setDataMap = getSetDataMap(latestSetId); final usedSerialNumbers = getUsedCoinSerials(); @@ -4283,8 +4309,6 @@ class FiroWallet extends CoinServiceAPI { dynamic usedSerialNumbers) async { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final dataFuture = _txnData; - final String currency = _prefs.currency; - final Decimal currentPrice = await firoPrice; ReceivePort receivePort = await getIsolate({ "function": "restore", @@ -4307,7 +4331,10 @@ class FiroWallet extends CoinServiceAPI { stop(receivePort); final message = await staticProcessRestore( - (await dataFuture), result as Map); + (await dataFuture), + result as Map, + await chainHeight, + ); await DB.instance.put( boxName: walletId, key: 'mintIndex', value: message['mintIndex']); @@ -4319,28 +4346,30 @@ class FiroWallet extends CoinServiceAPI { boxName: walletId, key: 'jindex', value: message['jindex']); final transactionMap = - message["newTxMap"] as Map; + message["newTxMap"] as Map; // Create the joinsplit transactions. final spendTxs = await getJMintTransactions( - _cachedElectrumXClient, - message["spendTxIds"] as List, - currency, - coin, - currentPrice, - (Platform.isWindows ? "en_US" : await Devicelocale.currentLocale)!); + _cachedElectrumXClient, + message["spendTxIds"] as List, + coin, + ); Logging.instance.log(spendTxs, level: LogLevel.Info); for (var element in spendTxs) { transactionMap[element.txid] = element; } - final models.TransactionData newTxData = - models.TransactionData.fromMap(transactionMap); + await isar.writeTxn(() async { + await isar.transactions.putAllByTxid(transactionMap.values.toList()); + }); - _lelantusTransactionData = Future(() => newTxData); - - await DB.instance.put( - boxName: walletId, key: 'latest_lelantus_tx_model', value: newTxData); + // final models.TransactionData newTxData = + // models.TransactionData.fromMap(transactionMap); + // + // _lelantusTransactionData = Future(() => newTxData); + // + // await DB.instance.put( + // boxName: walletId, key: 'latest_lelantus_tx_model', value: newTxData); } Future>> fetchAnonymitySets() async { @@ -4373,14 +4402,14 @@ class FiroWallet extends CoinServiceAPI { Future _createJoinSplitTransaction( int spendAmount, String address, bool subtractFeeFromAmount) async { - final price = await firoPrice; + // final price = await firoPrice; final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); final index = DB.instance.get(boxName: walletId, key: 'mintIndex'); final lelantusEntry = await _getLelantusEntry(); final anonymitySets = await fetchAnonymitySets(); final locktime = await getBlockHead(electrumXClient); - final locale = - Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; ReceivePort receivePort = await getIsolate({ "function": "createJoinSplit", @@ -4389,13 +4418,13 @@ class FiroWallet extends CoinServiceAPI { "subtractFeeFromAmount": subtractFeeFromAmount, "mnemonic": mnemonic, "index": index, - "price": price, + // "price": price, "lelantusEntries": lelantusEntry, "locktime": locktime, "coin": coin, "network": _network, "_anonymity_sets": anonymitySets, - "locale": locale, + // "locale": locale, }); var message = await receivePort.first; if (message is String) { @@ -4549,7 +4578,7 @@ class FiroWallet extends CoinServiceAPI { int spendAmount, ) async { var lelantusEntry = await _getLelantusEntry(); - final balance = await availableBalance; + final balance = availablePrivateBalance(); int spendAmount = (balance * Decimal.fromInt(Constants.satsPerCoin(coin))) .toBigInt() .toInt(); @@ -4612,22 +4641,23 @@ class FiroWallet extends CoinServiceAPI { } Future estimateFeeForPublic(int satoshiAmount, int feeRate) async { - final available = - Format.decimalAmountToSatoshis(await availablePublicBalance(), coin); + final available = balance.spendable; if (available == satoshiAmount) { - return satoshiAmount - sweepAllEstimate(feeRate); + return satoshiAmount - (await sweepAllEstimate(feeRate)); } else if (satoshiAmount <= 0 || satoshiAmount > available) { return roughFeeEstimate(1, 2, feeRate); } int runningBalance = 0; int inputCount = 0; - for (final output in _outputsList) { - runningBalance += output.value; - inputCount++; - if (runningBalance > satoshiAmount) { - break; + for (final output in (await utxos)) { + if (!output.isBlocked) { + runningBalance += output.value; + inputCount++; + if (runningBalance > satoshiAmount) { + break; + } } } @@ -4659,11 +4689,12 @@ class FiroWallet extends CoinServiceAPI { (feeRatePerKB / 1000).ceil(); } - int sweepAllEstimate(int feeRate) { + Future sweepAllEstimate(int feeRate) async { int available = 0; int inputCount = 0; - for (final output in _outputsList) { - if (output.status.confirmed) { + for (final output in (await utxos)) { + if (!output.isBlocked && + output.isConfirmed(storedChainHeight, MINIMUM_CONFIRMATIONS)) { available += output.value; inputCount++; } @@ -4718,16 +4749,16 @@ class FiroWallet extends CoinServiceAPI { return allTransactions; } - Future> getJMintTransactions( + Future> getJMintTransactions( CachedElectrumX cachedClient, List transactions, - String currency, + // String currency, Coin coin, - Decimal currentPrice, - String locale, + // Decimal currentPrice, + // String locale, ) async { try { - List txs = []; + List txs = []; List> allTransactions = await fastFetch(transactions); @@ -4735,35 +4766,31 @@ class FiroWallet extends CoinServiceAPI { try { final tx = allTransactions[i]; - tx["confirmed_status"] = - tx["confirmations"] != null && tx["confirmations"] as int > 0; - tx["timestamp"] = tx["time"]; - tx["txType"] = "Sent"; - var sendIndex = 1; if (tx["vout"][0]["value"] != null && Decimal.parse(tx["vout"][0]["value"].toString()) > Decimal.zero) { sendIndex = 0; } tx["amount"] = tx["vout"][sendIndex]["value"]; - tx["address"] = tx["vout"][sendIndex]["scriptPubKey"]["addresses"][0]; - tx["fees"] = tx["vin"][0]["nFees"]; - tx["inputSize"] = tx["vin"].length; - tx["outputSize"] = tx["vout"].length; - final decimalAmount = Decimal.parse(tx["amount"].toString()); + final txn = isar_models.Transaction() + ..isLelantus = true + ..txid = tx["txid"] as String + ..timestamp = tx["time"] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000) + ..type = isar_models.TransactionType.outgoing + ..subType = isar_models.TransactionSubType.join + ..fee = Format.decimalAmountToSatoshis( + Decimal.parse(tx["fees"].toString()), coin) + ..address = tx["address"] as String + ..amount = Format.decimalAmountToSatoshis( + Decimal.parse(tx["amount"].toString()), coin) + ..isCancelled = false + ..height = tx["height"] as int?; - tx["worthNow"] = Format.localizedStringAsFixed( - value: currentPrice * decimalAmount, - locale: locale, - decimalPlaces: 2, - ); - tx["worthAtBlockTimestamp"] = tx["worthNow"]; - - tx["subType"] = "join"; - txs.add(models.Transaction.fromLelantusJson(tx)); + txs.add(txn); } catch (e, s) { Logging.instance.log( "Exception caught in getJMintTransactions(): $e\n$s", @@ -4783,17 +4810,20 @@ class FiroWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - await incrementAddressIndexForChain( - 0); // First increment the receiving index - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: 'receivingIndex') - as int; // Check the new receiving index - final newReceivingAddress = await _generateAddressForChain(0, - newReceivingIndex); // Use new index to derive a new receiving address - await addToAddressesArrayForChain(newReceivingAddress, - 0); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddress = Future(() => - newReceivingAddress); // Set the new receiving address that the service + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address + final newReceivingAddress = await _generateAddressForChain( + 0, + newReceivingIndex, + ); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { @@ -4804,15 +4834,50 @@ class FiroWallet extends CoinServiceAPI { } } - Future availablePrivateBalance() async { - return (await balances)[0]; + Decimal availablePrivateBalance() { + return balancePrivate.getSpendable(); } - Future availablePublicBalance() async { - return (await balances)[4]; + Decimal availablePublicBalance() { + return balance.getSpendable(); + } + + Future get chainHeight async { + try { + final result = await _electrumXClient.getBlockHeadTip(); + return result["height"] as int; + } catch (e, s) { + Logging.instance.log("Exception caught in chainHeight: $e\n$s", + level: LogLevel.Error); + return -1; + } } @override - // TODO: implement storedChainHeight - int get storedChainHeight => throw UnimplementedError(); + int get storedChainHeight { + final storedHeight = DB.instance + .get(boxName: walletId, key: "storedChainHeight") as int?; + return storedHeight ?? 0; + } + + Future updateStoredChainHeight({required int newHeight}) async { + await DB.instance.put( + boxName: walletId, key: "storedChainHeight", value: newHeight); + } + + @override + Balance get balance => _balance!; + Balance? _balance; + + Balance get balancePrivate => _balancePrivate!; + Balance? _balancePrivate; + + @override + // TODO: implement utxos + Future> get utxos => isar.utxos.where().findAll(); + + @override + // TODO: implement transactions + Future> get transactions => + isar.transactions.where().findAll(); } From c36d73f255e7fc4efc01d8cf36a2330d58e551fd Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 18:59:01 -0600 Subject: [PATCH 098/192] migrate litecoin_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/litecoin/litecoin_wallet.dart | 1778 +++++++---------- 1 file changed, 765 insertions(+), 1013 deletions(-) diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 269f59610..cd32ee605 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; import 'package:bech32/bech32.dart'; import 'package:bip32/bip32.dart' as bip32; @@ -10,16 +9,15 @@ import 'package:bitcoindart/bitcoindart.dart'; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/models.dart' as models; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.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/refresh_percent_changed_event.dart'; @@ -28,7 +26,6 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -39,11 +36,13 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 294; +const int DUST_LIMIT_P2PKH = 546; const String GENESIS_HASH_MAINNET = "12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2"; @@ -160,8 +159,6 @@ class LitecoinWallet extends CoinServiceAPI { } } - List outputsList = []; - @override set isFavorite(bool markFavorite) { DB.instance.put( @@ -185,68 +182,34 @@ class LitecoinWallet extends CoinServiceAPI { Coin get coin => _coin; @override - Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - Future>? _allOwnAddresses; - - Future? _utxoData; - Future get utxoData => _utxoData ??= _fetchUtxoData(); + Future> get utxos => isar.utxos.where().findAll(); @override - Future> get unspentOutputs async => - (await utxoData).unspentOutputArray; + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); @override - Future get availableBalance async { - final data = await utxoData; - return Format.satoshisToAmount( - data.satoshiBalance - data.satoshiBalanceUnconfirmed, - coin: coin); - } + Future get currentReceivingAddress async => + (await _currentReceivingAddress).value; - @override - Future get pendingBalance async { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalanceUnconfirmed, coin: coin); - } + Future get _currentReceivingAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; - @override - Future get balanceMinusMaxFee async => - (await availableBalance) - - (Decimal.fromInt((await maxFee)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(); + Future get currentChangeAddress async => + (await _currentChangeAddress).value; - @override - Future get totalBalance async { - if (!isActive) { - final totalBalance = DB.instance - .get(boxName: walletId, key: 'totalBalance') as int?; - if (totalBalance == null) { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } else { - return Format.satoshisToAmount(totalBalance, coin: coin); - } - } - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } - - @override - Future get currentReceivingAddress => _currentReceivingAddress ??= - _getCurrentAddressForChain(0, DerivePathType.bip84); - Future? _currentReceivingAddress; - - Future get currentLegacyReceivingAddress => - _currentReceivingAddressP2PKH ??= - _getCurrentAddressForChain(0, DerivePathType.bip44); - Future? _currentReceivingAddressP2PKH; - - Future get currentReceivingAddressP2SH => - _currentReceivingAddressP2SH ??= - _getCurrentAddressForChain(0, DerivePathType.bip49); - Future? _currentReceivingAddressP2SH; + Future get _currentChangeAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -254,6 +217,7 @@ class LitecoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); + await isar.close(); } bool _hasCalledExit = false; @@ -287,6 +251,7 @@ class LitecoinWallet extends CoinServiceAPI { } } + @override int get storedChainHeight { final storedHeight = DB.instance .get(boxName: walletId, key: "storedChainHeight") as int?; @@ -409,8 +374,8 @@ class LitecoinWallet extends CoinServiceAPI { int txCountBatchSize, bip32.BIP32 root, DerivePathType type, - int account) async { - List addressArray = []; + int chain) async { + List addressArray = []; int returningIndex = -1; Map> derivations = {}; int gapCounter = 0; @@ -419,7 +384,7 @@ class LitecoinWallet extends CoinServiceAPI { index += txCountBatchSize) { List iterationsAddressArray = []; Logging.instance.log( - "index: $index, \t GapCounter $account ${type.name}: $gapCounter", + "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", level: LogLevel.Info); final _id = "k_$index"; @@ -430,44 +395,55 @@ class LitecoinWallet extends CoinServiceAPI { final node = await compute( getBip32NodeFromRootWrapper, Tuple4( - account, + chain, index + j, root, type, ), ); - String? address; + String addressString; + final data = PaymentData(pubkey: node.publicKey); + isar_models.AddressType addrType; switch (type) { case DerivePathType.bip44: - address = P2PKH( - data: PaymentData(pubkey: node.publicKey), - network: _network) - .data - .address!; + addressString = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - address = P2SH( + addressString = P2SH( data: PaymentData( redeem: P2WPKH( - data: PaymentData(pubkey: node.publicKey), + data: data, network: _network, overridePrefix: _network.bech32!) .data), network: _network) .data .address!; + addrType = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: - address = P2WPKH( + addressString = P2WPKH( network: _network, - data: PaymentData(pubkey: node.publicKey), + data: data, overridePrefix: _network.bech32!) .data .address!; + addrType = isar_models.AddressType.p2wpkh; break; default: throw Exception("No Path type $type exists"); } + + final address = isar_models.Address() + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = addrType + ..publicKey = node.publicKey + ..value = addressString + ..derivationIndex = index + j; + receivingNodes.addAll({ "${_id}_$j": { "node": node, @@ -475,7 +451,7 @@ class LitecoinWallet extends CoinServiceAPI { } }); txCountCallArgs.addAll({ - "${_id}_$j": address, + "${_id}_$j": addressString, }); } @@ -487,9 +463,10 @@ class LitecoinWallet extends CoinServiceAPI { int count = counts["${_id}_$k"]!; if (count > 0) { final node = receivingNodes["${_id}_$k"]; + final address = node["address"] as isar_models.Address; // add address to array - addressArray.add(node["address"] as String); - iterationsAddressArray.add(node["address"] as String); + addressArray.add(address); + iterationsAddressArray.add(address.value); // set current index returningIndex = index + k; // reset counter @@ -553,16 +530,16 @@ class LitecoinWallet extends CoinServiceAPI { final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, _network)); - List p2pkhReceiveAddressArray = []; - List p2shReceiveAddressArray = []; - List p2wpkhReceiveAddressArray = []; + List p2pkhReceiveAddressArray = []; + List p2shReceiveAddressArray = []; + List p2wpkhReceiveAddressArray = []; int p2pkhReceiveIndex = -1; int p2shReceiveIndex = -1; int p2wpkhReceiveIndex = -1; - List p2pkhChangeAddressArray = []; - List p2shChangeAddressArray = []; - List p2wpkhChangeAddressArray = []; + List p2pkhChangeAddressArray = []; + List p2shChangeAddressArray = []; + List p2wpkhChangeAddressArray = []; int p2pkhChangeIndex = -1; int p2shChangeIndex = -1; int p2wpkhChangeIndex = -1; @@ -605,37 +582,37 @@ class LitecoinWallet extends CoinServiceAPI { ]); p2pkhReceiveAddressArray = - (await resultReceive44)['addressArray'] as List; + (await resultReceive44)['addressArray'] as List; p2pkhReceiveIndex = (await resultReceive44)['index'] as int; p2pkhReceiveDerivations = (await resultReceive44)['derivations'] as Map>; p2shReceiveAddressArray = - (await resultReceive49)['addressArray'] as List; + (await resultReceive49)['addressArray'] as List; p2shReceiveIndex = (await resultReceive49)['index'] as int; p2shReceiveDerivations = (await resultReceive49)['derivations'] as Map>; p2wpkhReceiveAddressArray = - (await resultReceive84)['addressArray'] as List; + (await resultReceive84)['addressArray'] as List; p2wpkhReceiveIndex = (await resultReceive84)['index'] as int; p2wpkhReceiveDerivations = (await resultReceive84)['derivations'] as Map>; p2pkhChangeAddressArray = - (await resultChange44)['addressArray'] as List; + (await resultChange44)['addressArray'] as List; p2pkhChangeIndex = (await resultChange44)['index'] as int; p2pkhChangeDerivations = (await resultChange44)['derivations'] as Map>; p2shChangeAddressArray = - (await resultChange49)['addressArray'] as List; + (await resultChange49)['addressArray'] as List; p2shChangeIndex = (await resultChange49)['index'] as int; p2shChangeDerivations = (await resultChange49)['derivations'] as Map>; p2wpkhChangeAddressArray = - (await resultChange84)['addressArray'] as List; + (await resultChange84)['addressArray'] as List; p2wpkhChangeIndex = (await resultChange84)['index'] as int; p2wpkhChangeDerivations = (await resultChange84)['derivations'] as Map>; @@ -684,19 +661,16 @@ class LitecoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(0, 0, DerivePathType.bip44); p2pkhReceiveAddressArray.add(address); - p2pkhReceiveIndex = 0; } if (p2shReceiveIndex == -1) { final address = await _generateAddressForChain(0, 0, DerivePathType.bip49); p2shReceiveAddressArray.add(address); - p2shReceiveIndex = 0; } if (p2wpkhReceiveIndex == -1) { final address = await _generateAddressForChain(0, 0, DerivePathType.bip84); p2wpkhReceiveAddressArray.add(address); - p2wpkhReceiveIndex = 0; } // If restoring a wallet that never sent any funds with change, then set changeArray @@ -705,65 +679,31 @@ class LitecoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(1, 0, DerivePathType.bip44); p2pkhChangeAddressArray.add(address); - p2pkhChangeIndex = 0; } if (p2shChangeIndex == -1) { final address = await _generateAddressForChain(1, 0, DerivePathType.bip49); p2shChangeAddressArray.add(address); - p2shChangeIndex = 0; } if (p2wpkhChangeIndex == -1) { final address = await _generateAddressForChain(1, 0, DerivePathType.bip84); p2wpkhChangeAddressArray.add(address); - p2wpkhChangeIndex = 0; } - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: p2wpkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: p2wpkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: p2pkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: p2pkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: p2shReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: p2shChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: p2wpkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: p2wpkhChangeIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2PKH', value: p2pkhChangeIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: p2pkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: p2shReceiveIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: p2shChangeIndex); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(p2wpkhReceiveAddressArray); + await isar.addresses.putAll(p2wpkhChangeAddressArray); + await isar.addresses.putAll(p2pkhReceiveAddressArray); + await isar.addresses.putAll(p2pkhChangeAddressArray); + await isar.addresses.putAll(p2shReceiveAddressArray); + await isar.addresses.putAll(p2shChangeAddressArray); + }); + + await _updateUTXOs(); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); await DB.instance @@ -807,11 +747,14 @@ class LitecoinWallet extends CoinServiceAPI { } if (!needsRefresh) { var allOwnAddresses = await _fetchAllOwnAddresses(); - List> allTxs = - await _fetchHistory(allOwnAddresses); - final txData = await transactionData; + List> allTxs = await _fetchHistory( + allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { - if (txData.findTransaction(transaction['tx_hash'] as String) == + final txid = transaction['tx_hash'] as String; + if ((await isar.transactions + .filter() + .txidMatches(txid) + .findFirst()) == null) { Logging.instance.log( " txid not found in address history already ${transaction['tx_hash']}", @@ -830,16 +773,25 @@ class LitecoinWallet extends CoinServiceAPI { } } - Future getAllTxsToWatch( - TransactionData txData, - ) async { + Future getAllTxsToWatch() async { if (_hasCalledExit) return; - List unconfirmedTxnsToNotifyPending = []; - List unconfirmedTxnsToNotifyConfirmed = []; + List unconfirmedTxnsToNotifyPending = []; + List unconfirmedTxnsToNotifyConfirmed = []; - for (final chunk in txData.txChunks) { - for (final tx in chunk.transactions) { - if (tx.confirmedStatus) { + final currentChainHeight = await chainHeight; + + final txCount = await isar.transactions.count(); + + const paginateLimit = 50; + + for (int i = 0; i < txCount; i += paginateLimit) { + final transactions = await isar.transactions + .where() + .offset(i) + .limit(paginateLimit) + .findAll(); + for (final tx in transactions) { + if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { // get all transactions that were notified as pending but not as confirmed if (txTracker.wasNotifiedPending(tx.txid) && !txTracker.wasNotifiedConfirmed(tx.txid)) { @@ -856,31 +808,33 @@ class LitecoinWallet extends CoinServiceAPI { // notify on unconfirmed transactions for (final tx in unconfirmedTxnsToNotifyPending) { - if (tx.txType == "Received") { + final confirmations = tx.getConfirmations(currentChainHeight); + + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Sending transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); @@ -889,7 +843,7 @@ class LitecoinWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { - if (tx.txType == "Received") { + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction confirmed", body: walletName, @@ -900,7 +854,7 @@ class LitecoinWallet extends CoinServiceAPI { coinName: coin.name, )); await txTracker.addNotifiedConfirmed(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Outgoing transaction confirmed", body: walletName, @@ -980,40 +934,30 @@ class LitecoinWallet extends CoinServiceAPI { } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - final changeAddressForTransactions = - _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); - final currentReceivingAddressesForTransactions = - _checkCurrentReceivingAddressesForTransactions(); + await _checkCurrentReceivingAddressesForTransactions(); - final newTxData = _fetchTransactionData(); + final fetchFuture = _refreshTransactions(); + final utxosRefreshFuture = _updateUTXOs(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); - final newUtxoData = _fetchUtxoData(); final feeObj = _getFees(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.60, walletId)); - _transactionData = Future(() => newTxData); - GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.70, walletId)); _feeObject = Future(() => feeObj); - _utxoData = Future(() => newUtxoData); + + await utxosRefreshFuture; GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); - final allTxsToWatch = getAllTxsToWatch(await newTxData); - await Future.wait([ - newTxData, - changeAddressForTransactions, - currentReceivingAddressesForTransactions, - newUtxoData, - feeObj, - allTxsToWatch, - ]); + await fetchFuture; + await getAllTxsToWatch(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.90, walletId)); } @@ -1098,9 +1042,7 @@ class LitecoinWallet extends CoinServiceAPI { // check for send all bool isSendAll = false; - final balance = - Format.decimalAmountToSatoshis(await availableBalance, coin); - if (satoshiAmount == balance) { + if (satoshiAmount == balance.spendable) { isSendAll = true; } @@ -1176,24 +1118,6 @@ class LitecoinWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - final txData = await prepareSend( - address: toAddress, satoshiAmount: amount, args: args); - final txHash = await confirmSend(txData: txData); - return txHash; - } catch (e, s) { - Logging.instance - .log("Exception rethrown from send(): $e\n$s", level: LogLevel.Error); - rethrow; - } - } - @override Future testNetworkConnection() async { try { @@ -1266,6 +1190,22 @@ class LitecoinWallet extends CoinServiceAPI { ]); } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1276,65 +1216,54 @@ class LitecoinWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); } - @override - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - Future? _transactionData; - - TransactionData? cachedTxData; - // hack to add tx to txData before refresh completes // required based on current app architecture where we don't properly store // transactions locally in a good way @override Future updateSentCachedTxData(Map txData) async { - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final String worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - - final tx = models.Transaction( - txid: txData["txid"] as String, - confirmedStatus: false, - timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, - txType: "Sent", - amount: txData["recipientAmt"] as int, - worthNow: worthNow, - worthAtBlockTimestamp: worthNow, - fees: txData["fee"] as int, - inputSize: 0, - outputSize: 0, - inputs: [], - outputs: [], - address: txData["address"] as String, - height: -1, - confirmations: 0, - ); - - if (cachedTxData == null) { - final data = await _fetchTransactionData(); - _transactionData = Future(() => data); - } - - final transactions = cachedTxData!.getAllTransactions(); - transactions[tx.txid] = tx; - cachedTxData = models.TransactionData.fromMap(transactions); - _transactionData = Future(() => cachedTxData!); + // final priceData = + // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); + // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final String worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // + // final tx = models.Transaction( + // txid: txData["txid"] as String, + // confirmedStatus: false, + // timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // txType: "Sent", + // amount: txData["recipientAmt"] as int, + // worthNow: worthNow, + // worthAtBlockTimestamp: worthNow, + // fees: txData["fee"] as int, + // inputSize: 0, + // outputSize: 0, + // inputs: [], + // outputs: [], + // address: txData["address"] as String, + // height: -1, + // confirmations: 0, + // ); + // + // if (cachedTxData == null) { + // final data = await _refreshTransactions(); + // _transactionData = Future(() => data); + // } + // + // final transactions = cachedTxData!.getAllTransactions(); + // transactions[tx.txid] = tx; + // cachedTxData = models.TransactionData.fromMap(transactions); + // _transactionData = Future(() => cachedTxData!); } @override @@ -1364,7 +1293,7 @@ class LitecoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; + late Isar isar; LitecoinWallet({ required String walletId, @@ -1373,7 +1302,6 @@ class LitecoinWallet extends CoinServiceAPI { required ElectrumX client, required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, - PriceAPI? priceAPI, required SecureStorageInterface secureStore, }) { txTracker = tracker; @@ -1382,8 +1310,6 @@ class LitecoinWallet extends CoinServiceAPI { _coin = coin; _electrumXClient = client; _cachedElectrumXClient = cachedClient; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; } @@ -1440,53 +1366,59 @@ class LitecoinWallet extends CoinServiceAPI { ); } - Future> _fetchAllOwnAddresses() async { - final List allAddresses = []; - final receivingAddresses = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH') as List; - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final receivingAddressesP2PKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2PKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - final receivingAddressesP2SH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2SH') as List; - final changeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - as List; - - for (var i = 0; i < receivingAddresses.length; i++) { - if (!allAddresses.contains(receivingAddresses[i])) { - allAddresses.add(receivingAddresses[i] as String); - } - } - for (var i = 0; i < changeAddresses.length; i++) { - if (!allAddresses.contains(changeAddresses[i])) { - allAddresses.add(changeAddresses[i] as String); - } - } - for (var i = 0; i < receivingAddressesP2PKH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2PKH[i])) { - allAddresses.add(receivingAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - if (!allAddresses.contains(changeAddressesP2PKH[i])) { - allAddresses.add(changeAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < receivingAddressesP2SH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2SH[i])) { - allAddresses.add(receivingAddressesP2SH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2SH.length; i++) { - if (!allAddresses.contains(changeAddressesP2SH[i])) { - allAddresses.add(changeAddressesP2SH[i] as String); - } - } + Future> _fetchAllOwnAddresses() async { + final allAddresses = await isar.addresses + .filter() + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change) + .findAll(); + // final List allAddresses = []; + // final receivingAddresses = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH') as List; + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final receivingAddressesP2PKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2PKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // final receivingAddressesP2SH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2SH') as List; + // final changeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') + // as List; + // + // for (var i = 0; i < receivingAddresses.length; i++) { + // if (!allAddresses.contains(receivingAddresses[i])) { + // allAddresses.add(receivingAddresses[i] as String); + // } + // } + // for (var i = 0; i < changeAddresses.length; i++) { + // if (!allAddresses.contains(changeAddresses[i])) { + // allAddresses.add(changeAddresses[i] as String); + // } + // } + // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2PKH[i])) { + // allAddresses.add(receivingAddressesP2PKH[i] as String); + // } + // } + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2PKH[i])) { + // allAddresses.add(changeAddressesP2PKH[i] as String); + // } + // } + // for (var i = 0; i < receivingAddressesP2SH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2SH[i])) { + // allAddresses.add(receivingAddressesP2SH[i] as String); + // } + // } + // for (var i = 0; i < changeAddressesP2SH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2SH[i])) { + // allAddresses.add(changeAddressesP2SH[i] as String); + // } + // } return allAddresses; } @@ -1529,7 +1461,7 @@ class LitecoinWallet extends CoinServiceAPI { switch (coin) { case Coin.litecoin: if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { - print(features['genesis_hash']); + // print(features['genesis_hash']); throw Exception("genesis hash does not match main net!"); } break; @@ -1556,24 +1488,6 @@ class LitecoinWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2SH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2SH", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -1581,90 +1495,25 @@ class LitecoinWallet extends CoinServiceAPI { value: {}); // Generate and add addresses to relevant arrays - await Future.wait([ + final initialAddresses = await Future.wait([ // P2WPKH - _generateAddressForChain(0, 0, DerivePathType.bip84).then( - (initialReceivingAddressP2WPKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2WPKH, 0, DerivePathType.bip84); - _currentReceivingAddress = - Future(() => initialReceivingAddressP2WPKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip84).then( - (initialChangeAddressP2WPKH) => _addToAddressesArrayForChain( - initialChangeAddressP2WPKH, - 1, - DerivePathType.bip84, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip84), + _generateAddressForChain(1, 0, DerivePathType.bip84), // P2PKH - _generateAddressForChain(0, 0, DerivePathType.bip44).then( - (initialReceivingAddressP2PKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - _currentReceivingAddressP2PKH = - Future(() => initialReceivingAddressP2PKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip44).then( - (initialChangeAddressP2PKH) => _addToAddressesArrayForChain( - initialChangeAddressP2PKH, - 1, - DerivePathType.bip44, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip44), + _generateAddressForChain(1, 0, DerivePathType.bip44), // P2SH - _generateAddressForChain(0, 0, DerivePathType.bip49).then( - (initialReceivingAddressP2SH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2SH, 0, DerivePathType.bip49); - _currentReceivingAddressP2SH = - Future(() => initialReceivingAddressP2SH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip49).then( - (initialChangeAddressP2SH) => _addToAddressesArrayForChain( - initialChangeAddressP2SH, - 1, - DerivePathType.bip49, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip49), + _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - // // P2PKH - // _generateAddressForChain(0, 0, DerivePathType.bip44).then( - // (initialReceivingAddressP2PKH) { - // _addToAddressesArrayForChain( - // initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - // this._currentReceivingAddressP2PKH = - // Future(() => initialReceivingAddressP2PKH); - // }, - // ); - // _generateAddressForChain(1, 0, DerivePathType.bip44) - // .then((initialChangeAddressP2PKH) => _addToAddressesArrayForChain( - // initialChangeAddressP2PKH, - // 1, - // DerivePathType.bip44, - // )); - // - // // P2SH - // _generateAddressForChain(0, 0, DerivePathType.bip49).then( - // (initialReceivingAddressP2SH) { - // _addToAddressesArrayForChain( - // initialReceivingAddressP2SH, 0, DerivePathType.bip49); - // this._currentReceivingAddressP2SH = - // Future(() => initialReceivingAddressP2SH); - // }, - // ); - // _generateAddressForChain(1, 0, DerivePathType.bip49) - // .then((initialChangeAddressP2SH) => _addToAddressesArrayForChain( - // initialChangeAddressP2SH, - // 1, - // DerivePathType.bip49, - // )); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(initialAddresses); + }); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1672,7 +1521,7 @@ class LitecoinWallet extends CoinServiceAPI { /// Generates a new internal or external chain address for the wallet using a BIP84, BIP44, or BIP49 derivation path. /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! /// [index] - This can be any integer >= 0 - Future _generateAddressForChain( + Future _generateAddressForChain( int chain, int index, DerivePathType derivePathType, @@ -1690,10 +1539,12 @@ class LitecoinWallet extends CoinServiceAPI { ); final data = PaymentData(pubkey: node.publicKey); String address; + isar_models.AddressType addrType; switch (derivePathType) { case DerivePathType.bip44: address = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: address = P2SH( @@ -1706,12 +1557,14 @@ class LitecoinWallet extends CoinServiceAPI { network: _network) .data .address!; + addrType = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: address = P2WPKH( network: _network, data: data, overridePrefix: _network.bech32!) .data .address!; + addrType = isar_models.AddressType.p2wpkh; break; } @@ -1724,98 +1577,47 @@ class LitecoinWallet extends CoinServiceAPI { derivePathType: derivePathType, ); - return address; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain( - int chain, DerivePathType derivePathType) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain( - String address, int chain, DerivePathType derivePathType) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - switch (derivePathType) { - case DerivePathType.bip44: - chainArray += "P2PKH"; - break; - case DerivePathType.bip49: - chainArray += "P2SH"; - break; - case DerivePathType.bip84: - chainArray += "P2WPKH"; - break; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = node.publicKey + ..type = addrType + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// and /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! Future _getCurrentAddressForChain( - int chain, DerivePathType derivePathType) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; + int chain, + DerivePathType derivePathType, + ) async { + final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; + + isar_models.AddressType type; + isar_models.Address? address; switch (derivePathType) { case DerivePathType.bip44: - arrayKey += "P2PKH"; + type = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - arrayKey += "P2SH"; + type = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: - arrayKey += "P2WPKH"; + type = isar_models.AddressType.p2wpkh; break; } - final internalChainArray = - DB.instance.get(boxName: walletId, key: arrayKey); - return internalChainArray.last as String; + address = await isar.addresses + .filter() + .typeEqualTo(type) + .subTypeEqualTo(subType) + .sortByDerivationIndexDesc() + .findFirst(); + return address!.value; } String _buildDerivationStorageKey({ @@ -1920,8 +1722,8 @@ class LitecoinWallet extends CoinServiceAPI { await _secureStore.write(key: key, value: newReceiveDerivationsString); } - Future _fetchUtxoData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future _updateUTXOs() async { + final allAddresses = await _fetchAllOwnAddresses(); try { final fetchedUtxoList = >>[]; @@ -1933,7 +1735,8 @@ class LitecoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = + _convertToScriptHash(allAddresses[i].value, _network); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -1951,142 +1754,119 @@ class LitecoinWallet extends CoinServiceAPI { } } } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> outputArray = []; - int satoshiBalance = 0; + + final currentChainHeight = await chainHeight; + + final List outputArray = []; + int satoshiBalanceTotal = 0; int satoshiBalancePending = 0; + int satoshiBalanceSpendable = 0; + int satoshiBalanceBlocked = 0; for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - int value = fetchedUtxoList[i][j]["value"] as int; - satoshiBalance += value; - final txn = await cachedElectrumXClient.getTransaction( txHash: fetchedUtxoList[i][j]["tx_hash"] as String, verbose: true, coin: coin, ); - final Map utxo = {}; - final int confirmations = txn["confirmations"] as int? ?? 0; - final bool confirmed = confirmations >= MINIMUM_CONFIRMATIONS; - if (!confirmed) { - satoshiBalancePending += value; + final utxo = isar_models.UTXO(); + + utxo.txid = txn["txid"] as String; + utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; + utxo.value = fetchedUtxoList[i][j]["value"] as int; + utxo.name = ""; + + // todo check here if we should mark as blocked + utxo.isBlocked = false; + utxo.blockedReason = null; + + utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; + utxo.blockHash = txn["blockhash"] as String?; + utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; + utxo.blockTime = txn["blocktime"] as int?; + + satoshiBalanceTotal += utxo.value; + + if (utxo.isBlocked) { + satoshiBalanceBlocked += utxo.value; + } else { + if (utxo.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + satoshiBalanceSpendable += utxo.value; + } else { + satoshiBalancePending += utxo.value; + } } - utxo["txid"] = txn["txid"]; - utxo["vout"] = fetchedUtxoList[i][j]["tx_pos"]; - utxo["value"] = value; - - utxo["status"] = {}; - utxo["status"]["confirmed"] = confirmed; - utxo["status"]["confirmations"] = confirmations; - utxo["status"]["block_height"] = fetchedUtxoList[i][j]["height"]; - utxo["status"]["block_hash"] = txn["blockhash"]; - utxo["status"]["block_time"] = txn["blocktime"]; - - final fiatValue = ((Decimal.fromInt(value) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - utxo["rawWorth"] = fiatValue; - utxo["fiatWorth"] = fiatValue.toString(); outputArray.add(utxo); } } - Decimal currencyBalanceRaw = - ((Decimal.fromInt(satoshiBalance) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - - final Map result = { - "total_user_currency": currencyBalanceRaw.toString(), - "total_sats": satoshiBalance, - "total_btc": (Decimal.fromInt(satoshiBalance) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal( - scaleOnInfinitePrecision: Constants.decimalPlacesForCoin(coin)) - .toString(), - "outputArray": outputArray, - "unconfirmed": satoshiBalancePending, - }; - - final dataModel = UtxoData.fromJson(result); - - final List allOutputs = dataModel.unspentOutputArray; Logging.instance - .log('Outputs fetched: $allOutputs', level: LogLevel.Info); - await _sortOutputs(allOutputs); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: dataModel); - await DB.instance.put( - boxName: walletId, - key: 'totalBalance', - value: dataModel.satoshiBalance); - return dataModel; + .log('Outputs fetched: $outputArray', level: LogLevel.Info); + + await isar.writeTxn(() async { + await isar.utxos.clear(); + await isar.utxos.putAll(outputArray); + }); + + // finally update balance + _balance = Balance( + coin: coin, + total: satoshiBalanceTotal, + spendable: satoshiBalanceSpendable, + blockedTotal: satoshiBalanceBlocked, + pendingSpendable: satoshiBalancePending, + ); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); - final latestTxModel = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model') - as models.UtxoData?; - - if (latestTxModel == null) { - final emptyModel = { - "total_user_currency": "0.00", - "total_sats": 0, - "total_btc": "0", - "outputArray": [] - }; - return UtxoData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old output model located", level: LogLevel.Warning); - return latestTxModel; - } } } - /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - /// Now also checks for output labeling. - Future _sortOutputs(List utxos) async { - final blockedHashArray = - DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - as List?; - final List lst = []; - if (blockedHashArray != null) { - for (var hash in blockedHashArray) { - lst.add(hash as String); - } - } - final labels = - DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - {}; + @override + Balance get balance => _balance!; + Balance? _balance; - outputsList = []; - - for (var i = 0; i < utxos.length; i++) { - if (labels[utxos[i].txid] != null) { - utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - } else { - utxos[i].txName = 'Output #$i'; - } - - if (utxos[i].status.confirmed == false) { - outputsList.add(utxos[i]); - } else { - if (lst.contains(utxos[i].txid)) { - utxos[i].blocked = true; - outputsList.add(utxos[i]); - } else if (!lst.contains(utxos[i].txid)) { - outputsList.add(utxos[i]); - } - } - } - } + // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) + // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. + // /// Now also checks for output labeling. + // Future _sortOutputs(List utxos) async { + // final blockedHashArray = + // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') + // as List?; + // final List lst = []; + // if (blockedHashArray != null) { + // for (var hash in blockedHashArray) { + // lst.add(hash as String); + // } + // } + // final labels = + // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? + // {}; + // + // outputsList = []; + // + // for (var i = 0; i < utxos.length; i++) { + // if (labels[utxos[i].txid] != null) { + // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; + // } else { + // utxos[i].txName = 'Output #$i'; + // } + // + // if (utxos[i].status.confirmed == false) { + // outputsList.add(utxos[i]); + // } else { + // if (lst.contains(utxos[i].txid)) { + // utxos[i].blocked = true; + // outputsList.add(utxos[i]); + // } else if (!lst.contains(utxos[i].txid)) { + // outputsList.add(utxos[i]); + // } + // } + // } + // } Future getTxCount({required String address}) async { String? scripthash; @@ -2126,111 +1906,65 @@ class LitecoinWallet extends CoinServiceAPI { } } - Future _checkReceivingAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkReceivingAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(0, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentReceiving = await _currentReceivingAddress; + + final int txCount = await getTxCount(address: currentReceiving.value); Logging.instance.log( - 'Number of txs for current receiving address $currentExternalAddr: $txCount', + 'Number of txs for current receiving address $currentReceiving: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the receiving index - await _incrementAddressIndexForChain(0, derivePathType); - - // Check the new receiving index - String indexKey = "receivingIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = currentReceiving.derivationIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, newReceivingIndex, derivePathType); + 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain( - newReceivingAddress, 0, derivePathType); - - // Set the new receiving address that the service - - switch (derivePathType) { - case DerivePathType.bip44: - _currentReceivingAddressP2PKH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip49: - _currentReceivingAddressP2SH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip84: - _currentReceivingAddress = Future(() => newReceivingAddress); - break; - } + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } } - Future _checkChangeAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkChangeAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(1, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentChange = await _currentChangeAddress; + final int txCount = await getTxCount(address: currentChange.value); Logging.instance.log( - 'Number of txs for current change address $currentExternalAddr: $txCount', + 'Number of txs for current change address $currentChange: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the change index - await _incrementAddressIndexForChain(1, derivePathType); - - // Check the new change index - String indexKey = "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newChangeIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newChangeIndex = currentChange.derivationIndex + 1; // Use new index to derive a new change address - final newChangeAddress = - await _generateAddressForChain(1, newChangeIndex, derivePathType); + final newChangeAddress = await _generateAddressForChain( + 1, newChangeIndex, DerivePathType.bip84); - // Add that new receiving address to the array of change addresses - await _addToAddressesArrayForChain(newChangeAddress, 1, derivePathType); + // Add that new change address + await isar.writeTxn(() async { + await isar.addresses.put(newChangeAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( - "SocketException caught in _checkReceivingAddressForTransactions($derivePathType): $se\n$s", + "SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s", level: LogLevel.Error); return; } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } @@ -2238,9 +1972,9 @@ class LitecoinWallet extends CoinServiceAPI { Future _checkCurrentReceivingAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkReceivingAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkReceivingAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentReceivingAddressesForTransactions(): $e\n$s", @@ -2262,9 +1996,9 @@ class LitecoinWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkChangeAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkChangeAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentChangeAddressesForTransactions(): $e\n$s", @@ -2351,16 +2085,6 @@ class LitecoinWallet extends CoinServiceAPI { } } - bool _duplicateTxCheck( - List> allTransactions, String txid) { - for (int i = 0; i < allTransactions.length; i++) { - if (allTransactions[i]["txid"] == txid) { - return true; - } - } - return false; - } - Future>> fastFetch(List allTxHashes) async { List> allTransactions = []; @@ -2398,52 +2122,63 @@ class LitecoinWallet extends CoinServiceAPI { return allTransactions; } - Future _fetchTransactionData() async { - final List allAddresses = await _fetchAllOwnAddresses(); - - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - final changeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - as List; - - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - changeAddresses.add(changeAddressesP2PKH[i] as String); - } - for (var i = 0; i < changeAddressesP2SH.length; i++) { - changeAddresses.add(changeAddressesP2SH[i] as String); - } - - final List> allTxHashes = - await _fetchHistory(allAddresses); - - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as TransactionData?; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; - - final unconfirmedCachedTransactions = - cachedTransactions?.getAllTransactions() ?? {}; - unconfirmedCachedTransactions - .removeWhere((key, value) => value.confirmedStatus); - - if (cachedTransactions != null) { - for (final tx in allTxHashes.toList(growable: false)) { - final txHeight = tx["height"] as int; - if (txHeight > 0 && - txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - allTxHashes.remove(tx); - } - } + bool _duplicateTxCheck( + List> allTransactions, String txid) { + for (int i = 0; i < allTransactions.length; i++) { + if (allTransactions[i]["txid"] == txid) { + return true; } } + return false; + } + + Future _refreshTransactions() async { + final List allAddresses = + await _fetchAllOwnAddresses(); + + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // final changeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') + // as List; + // + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // changeAddresses.add(changeAddressesP2PKH[i] as String); + // } + // for (var i = 0; i < changeAddressesP2SH.length; i++) { + // changeAddresses.add(changeAddressesP2SH[i] as String); + // } + + final List> allTxHashes = + await _fetchHistory(allAddresses.map((e) => e.value).toList()); + + // final cachedTransactions = + // DB.instance.get(boxName: walletId, key: 'latest_tx_model') + // as TransactionData?; + // int latestTxnBlockHeight = + // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") + // as int? ?? + // 0; + // + // final unconfirmedCachedTransactions = + // cachedTransactions?.getAllTransactions() ?? {}; + // unconfirmedCachedTransactions + // .removeWhere((key, value) => value.confirmedStatus); + // + // if (cachedTransactions != null) { + // for (final tx in allTxHashes.toList(growable: false)) { + // final txHeight = tx["height"] as int; + // if (txHeight > 0 && + // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { + // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { + // allTxHashes.remove(tx); + // } + // } + // } + // } Set hashes = {}; for (var element in allTxHashes) { @@ -2460,7 +2195,6 @@ class LitecoinWallet extends CoinServiceAPI { ); // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - // TODO fix this for sent to self transactions? if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { tx["address"] = txHash["address"]; tx["height"] = txHash["height"]; @@ -2468,16 +2202,16 @@ class LitecoinWallet extends CoinServiceAPI { } } - Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); - Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); - - Logging.instance.log("allTransactions length: ${allTransactions.length}", - level: LogLevel.Info); - - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + // Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); + // Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); + // + // Logging.instance.log("allTransactions length: ${allTransactions.length}", + // level: LogLevel.Info); + // + // final priceData = + // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); + // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; + // final List> midSortedArray = []; Set vHashes = {}; for (final txObject in allTransactions) { @@ -2490,250 +2224,269 @@ class LitecoinWallet extends CoinServiceAPI { await fastFetch(vHashes.toList()); for (final txObject in allTransactions) { - List sendersArray = []; - List recipientsArray = []; + final txn = await parseTransaction( + txObject, + cachedElectrumXClient, + allAddresses, + coin, + MINIMUM_CONFIRMATIONS, + ); - // Usually only has value when txType = 'Send' - int inputAmtSentFromWallet = 0; - // Usually has value regardless of txType due to change addresses - int outputAmtAddressedToWallet = 0; - int fee = 0; + // final tx = await isar.transactions + // .filter() + // .txidMatches(midSortedTx.txid) + // .findFirst(); + // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar + // if (tx == null) { + await isar.writeTxn(() async { + await isar.transactions.put(txn); + }); + // } - Map midSortedTx = {}; - - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"]![i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - final address = out["scriptPubKey"]["addresses"][0] as String?; - if (address != null) { - sendersArray.add(address); - } - } - } - } - - Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0] as String?; - if (address != null) { - recipientsArray.add(address); - } - } - - Logging.instance - .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - - final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)); - Logging.instance - .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - - // If txType = Sent, then calculate inputAmtSentFromWallet - if (foundInSenders) { - int totalInput = 0; - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"]![i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - inputAmtSentFromWallet += - (Decimal.parse(out["value"]!.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - totalInput = inputAmtSentFromWallet; - int totalOutput = 0; - - for (final output in txObject["vout"] as List) { - final String address = - output["scriptPubKey"]!["addresses"][0] as String; - final value = output["value"]!; - final _value = (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOutput += _value; - if (changeAddresses.contains(address)) { - inputAmtSentFromWallet -= _value; - } else { - // change address from 'sent from' to the 'sent to' address - txObject["address"] = address; - } - } - // calculate transaction fee - fee = totalInput - totalOutput; - // subtract fee from sent to calculate correct value of sent tx - inputAmtSentFromWallet -= fee; - } else { - // counters for fee calculation - int totalOut = 0; - int totalIn = 0; - - // add up received tx value - for (final output in txObject["vout"] as List) { - final address = output["scriptPubKey"]["addresses"][0]; - if (address != null) { - final value = (Decimal.parse(output["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOut += value; - if (allAddresses.contains(address)) { - outputAmtAddressedToWallet += value; - } - } - } - - // calculate fee for received tx - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - totalIn += (Decimal.parse(out["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - fee = totalIn - totalOut; - } - - // create final tx map - midSortedTx["txid"] = txObject["txid"]; - midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - midSortedTx["timestamp"] = txObject["blocktime"] ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000); - - if (foundInSenders) { - midSortedTx["txType"] = "Sent"; - midSortedTx["amount"] = inputAmtSentFromWallet; - final String worthNow = - ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - } else { - midSortedTx["txType"] = "Received"; - midSortedTx["amount"] = outputAmtAddressedToWallet; - final worthNow = - ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - } - midSortedTx["aliens"] = []; - midSortedTx["fees"] = fee; - midSortedTx["address"] = txObject["address"]; - midSortedTx["inputSize"] = txObject["vin"].length; - midSortedTx["outputSize"] = txObject["vout"].length; - midSortedTx["inputs"] = txObject["vin"]; - midSortedTx["outputs"] = txObject["vout"]; - - final int height = txObject["height"] as int; - midSortedTx["height"] = height; - - if (height >= latestTxnBlockHeight) { - latestTxnBlockHeight = height; - } - - midSortedArray.add(midSortedTx); + // List sendersArray = []; + // List recipientsArray = []; + // + // // Usually only has value when txType = 'Send' + // int inputAmtSentFromWallet = 0; + // // Usually has value regardless of txType due to change addresses + // int outputAmtAddressedToWallet = 0; + // int fee = 0; + // + // Map midSortedTx = {}; + // + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"]![i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // final address = out["scriptPubKey"]["addresses"][0] as String?; + // if (address != null) { + // sendersArray.add(address); + // } + // } + // } + // } + // + // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); + // + // for (final output in txObject["vout"] as List) { + // final address = output["scriptPubKey"]["addresses"][0] as String?; + // if (address != null) { + // recipientsArray.add(address); + // } + // } + // + // Logging.instance + // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); + // + // final foundInSenders = + // allAddresses.any((element) => sendersArray.contains(element)); + // Logging.instance + // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); + // + // // If txType = Sent, then calculate inputAmtSentFromWallet + // if (foundInSenders) { + // int totalInput = 0; + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"]![i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // inputAmtSentFromWallet += + // (Decimal.parse(out["value"]!.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // totalInput = inputAmtSentFromWallet; + // int totalOutput = 0; + // + // for (final output in txObject["vout"] as List) { + // final String address = + // output["scriptPubKey"]!["addresses"][0] as String; + // final value = output["value"]!; + // final _value = (Decimal.parse(value.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOutput += _value; + // if (changeAddresses.contains(address)) { + // inputAmtSentFromWallet -= _value; + // } else { + // // change address from 'sent from' to the 'sent to' address + // txObject["address"] = address; + // } + // } + // // calculate transaction fee + // fee = totalInput - totalOutput; + // // subtract fee from sent to calculate correct value of sent tx + // inputAmtSentFromWallet -= fee; + // } else { + // // counters for fee calculation + // int totalOut = 0; + // int totalIn = 0; + // + // // add up received tx value + // for (final output in txObject["vout"] as List) { + // final address = output["scriptPubKey"]["addresses"][0]; + // if (address != null) { + // final value = (Decimal.parse(output["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOut += value; + // if (allAddresses.contains(address)) { + // outputAmtAddressedToWallet += value; + // } + // } + // } + // + // // calculate fee for received tx + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"][i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // totalIn += (Decimal.parse(out["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // fee = totalIn - totalOut; + // } + // + // // create final tx map + // midSortedTx["txid"] = txObject["txid"]; + // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && + // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); + // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; + // midSortedTx["timestamp"] = txObject["blocktime"] ?? + // (DateTime.now().millisecondsSinceEpoch ~/ 1000); + // + // if (foundInSenders) { + // midSortedTx["txType"] = "Sent"; + // midSortedTx["amount"] = inputAmtSentFromWallet; + // final String worthNow = + // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // midSortedTx["worthAtBlockTimestamp"] = worthNow; + // } else { + // midSortedTx["txType"] = "Received"; + // midSortedTx["amount"] = outputAmtAddressedToWallet; + // final worthNow = + // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // } + // midSortedTx["aliens"] = []; + // midSortedTx["fees"] = fee; + // midSortedTx["address"] = txObject["address"]; + // midSortedTx["inputSize"] = txObject["vin"].length; + // midSortedTx["outputSize"] = txObject["vout"].length; + // midSortedTx["inputs"] = txObject["vin"]; + // midSortedTx["outputs"] = txObject["vout"]; + // + // final int height = txObject["height"] as int; + // midSortedTx["height"] = height; + // + // if (height >= latestTxnBlockHeight) { + // latestTxnBlockHeight = height; + // } + // + // midSortedArray.add(midSortedTx); } - - // sort by date ---- //TODO not sure if needed - // shouldn't be any issues with a null timestamp but I got one at some point? - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // { - // final aT = a["timestamp"]; - // final bT = b["timestamp"]; // - // if (aT == null && bT == null) { - // return 0; - // } else if (aT == null) { - // return -1; - // } else if (bT == null) { - // return 1; + // // sort by date ---- //TODO not sure if needed + // // shouldn't be any issues with a null timestamp but I got one at some point? + // midSortedArray + // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); + // // { + // // final aT = a["timestamp"]; + // // final bT = b["timestamp"]; + // // + // // if (aT == null && bT == null) { + // // return 0; + // // } else if (aT == null) { + // // return -1; + // // } else if (bT == null) { + // // return 1; + // // } else { + // // return bT - aT; + // // } + // // }); + // + // // buildDateTimeChunks + // 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 { - // return bT - aT; + // dateArray.add(txTimeArray[1]); + // final chunk = { + // "timestamp": txTimeArray[0], + // "transactions": [txObject], + // }; + // result["dateTimeChunks"].add(chunk); // } - // }); - - // buildDateTimeChunks - 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], - }; - result["dateTimeChunks"].add(chunk); - } - } - - final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); - - 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); - - cachedTxData = txModel; - return txModel; + // } + // + // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; + // transactionsMap + // .addAll(TransactionData.fromJson(result).getAllTransactions()); + // + // 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); + // + // cachedTxData = txModel; + // return txModel; } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2750,26 +2503,28 @@ class LitecoinWallet extends CoinServiceAPI { String _recipientAddress, bool isSendAll, { int additionalOutputs = 0, - List? utxos, + List? utxos, }) async { Logging.instance .log("Starting coinSelection ----------", level: LogLevel.Info); - final List availableOutputs = utxos ?? outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final currentChainHeight = await chainHeight; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", level: LogLevel.Info); @@ -2796,7 +2551,7 @@ class LitecoinWallet extends CoinServiceAPI { // Possible situation right here int satoshisBeingUsed = 0; int inputsBeingConsumed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; satoshisBeingUsed < satoshiAmountToSend && i < spendableOutputs.length; @@ -2914,7 +2669,7 @@ class LitecoinWallet extends CoinServiceAPI { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize == feeForTwoOutputs) { // generate new change address if current change address has been used - await _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); final String newChangeAddress = await _getCurrentAddressForChain(1, DerivePathType.bip84); @@ -3084,7 +2839,7 @@ class LitecoinWallet extends CoinServiceAPI { } Future> fetchBuildTxData( - List utxosToUse, + List utxosToUse, ) async { // return data Map results = {}; @@ -3329,7 +3084,7 @@ class LitecoinWallet extends CoinServiceAPI { /// Builds and signs a transaction Future> buildTransaction({ - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required List recipients, required List satoshiAmounts, @@ -3780,22 +3535,23 @@ class LitecoinWallet extends CoinServiceAPI { @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { - final available = - Format.decimalAmountToSatoshis(await availableBalance, coin); + final available = balance.spendable; if (available == satoshiAmount) { - return satoshiAmount - sweepAllEstimate(feeRate); + return satoshiAmount - (await sweepAllEstimate(feeRate)); } else if (satoshiAmount <= 0 || satoshiAmount > available) { return roughFeeEstimate(1, 2, feeRate); } int runningBalance = 0; int inputCount = 0; - for (final output in outputsList) { - runningBalance += output.value; - inputCount++; - if (runningBalance > satoshiAmount) { - break; + for (final output in (await utxos)) { + if (!output.isBlocked) { + runningBalance += output.value; + inputCount++; + if (runningBalance > satoshiAmount) { + break; + } } } @@ -3826,11 +3582,12 @@ class LitecoinWallet extends CoinServiceAPI { (feeRatePerKB / 1000).ceil(); } - int sweepAllEstimate(int feeRate) { + Future sweepAllEstimate(int feeRate) async { int available = 0; int inputCount = 0; - for (final output in outputsList) { - if (output.status.confirmed) { + for (final output in (await utxos)) { + if (!output.isBlocked && + output.isConfirmed(storedChainHeight, MINIMUM_CONFIRMATIONS)) { available += output.value; inputCount++; } @@ -3845,23 +3602,18 @@ class LitecoinWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - await _incrementAddressIndexForChain( - 0, DerivePathType.bip84); // First increment the receiving index - final newReceivingIndex = DB.instance.get( - boxName: walletId, - key: 'receivingIndexP2WPKH') as int; // Check the new receiving index + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, - newReceivingIndex, - DerivePathType - .bip84); // Use new index to derive a new receiving address - await _addToAddressesArrayForChain( - newReceivingAddress, - 0, - DerivePathType - .bip84); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddress = Future(() => - newReceivingAddress); // Set the new receiving address that the service + 0, newReceivingIndex, DerivePathType.bip84); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { From 21f3d80d3aeb2aa4b358bad2826f3226d30c68bb Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 19:22:44 -0600 Subject: [PATCH 099/192] migrate namecoin_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/namecoin/namecoin_wallet.dart | 1765 +++++++---------- 1 file changed, 757 insertions(+), 1008 deletions(-) diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 85fea61ad..1177e9057 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; import 'package:bech32/bech32.dart'; import 'package:bip32/bip32.dart' as bip32; @@ -10,16 +9,15 @@ import 'package:bitcoindart/bitcoindart.dart'; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/models.dart' as models; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; +import 'package:stackwallet/services/coins/coin_paynym_extension.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/refresh_percent_changed_event.dart'; @@ -28,7 +26,6 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -39,6 +36,7 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -156,8 +154,6 @@ class NamecoinWallet extends CoinServiceAPI { } } - List outputsList = []; - @override set isFavorite(bool markFavorite) { DB.instance.put( @@ -181,68 +177,34 @@ class NamecoinWallet extends CoinServiceAPI { Coin get coin => _coin; @override - Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - Future>? _allOwnAddresses; - - Future? _utxoData; - Future get utxoData => _utxoData ??= _fetchUtxoData(); + Future> get utxos => isar.utxos.where().findAll(); @override - Future> get unspentOutputs async => - (await utxoData).unspentOutputArray; + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); @override - Future get availableBalance async { - final data = await utxoData; - return Format.satoshisToAmount( - data.satoshiBalance - data.satoshiBalanceUnconfirmed, - coin: coin); - } + Future get currentReceivingAddress async => + (await _currentReceivingAddress).value; - @override - Future get pendingBalance async { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalanceUnconfirmed, coin: coin); - } + Future get _currentReceivingAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; - @override - Future get balanceMinusMaxFee async => - (await availableBalance) - - (Decimal.fromInt((await maxFee)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(); + Future get currentChangeAddress async => + (await _currentChangeAddress).value; - @override - Future get totalBalance async { - if (!isActive) { - final totalBalance = DB.instance - .get(boxName: walletId, key: 'totalBalance') as int?; - if (totalBalance == null) { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } else { - return Format.satoshisToAmount(totalBalance, coin: coin); - } - } - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } - - @override - Future get currentReceivingAddress => _currentReceivingAddress ??= - _getCurrentAddressForChain(0, DerivePathType.bip84); - Future? _currentReceivingAddress; - - Future get currentLegacyReceivingAddress => - _currentReceivingAddressP2PKH ??= - _getCurrentAddressForChain(0, DerivePathType.bip44); - Future? _currentReceivingAddressP2PKH; - - Future get currentReceivingAddressP2SH => - _currentReceivingAddressP2SH ??= - _getCurrentAddressForChain(0, DerivePathType.bip49); - Future? _currentReceivingAddressP2SH; + Future get _currentChangeAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -250,6 +212,7 @@ class NamecoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); + await isar.close(); } bool _hasCalledExit = false; @@ -283,6 +246,7 @@ class NamecoinWallet extends CoinServiceAPI { } } + @override int get storedChainHeight { final storedHeight = DB.instance .get(boxName: walletId, key: "storedChainHeight") as int?; @@ -397,8 +361,8 @@ class NamecoinWallet extends CoinServiceAPI { int txCountBatchSize, bip32.BIP32 root, DerivePathType type, - int account) async { - List addressArray = []; + int chain) async { + List addressArray = []; int returningIndex = -1; Map> derivations = {}; int gapCounter = 0; @@ -407,7 +371,7 @@ class NamecoinWallet extends CoinServiceAPI { index += txCountBatchSize) { List iterationsAddressArray = []; Logging.instance.log( - "index: $index, \t GapCounter $account ${type.name}: $gapCounter", + "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", level: LogLevel.Info); final _id = "k_$index"; @@ -418,23 +382,25 @@ class NamecoinWallet extends CoinServiceAPI { final node = await compute( getBip32NodeFromRootWrapper, Tuple4( - account, + chain, index + j, root, type, ), ); - String? address; + String addressString; + isar_models.AddressType addrType; switch (type) { case DerivePathType.bip44: - address = P2PKH( + addressString = P2PKH( data: PaymentData(pubkey: node.publicKey), network: _network) .data .address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - address = P2SH( + addressString = P2SH( data: PaymentData( redeem: P2WPKH( data: PaymentData(pubkey: node.publicKey), @@ -444,18 +410,30 @@ class NamecoinWallet extends CoinServiceAPI { network: _network) .data .address!; + addrType = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: - address = P2WPKH( + addressString = P2WPKH( network: _network, data: PaymentData(pubkey: node.publicKey), overridePrefix: namecoin.bech32!) .data .address!; + addrType = isar_models.AddressType.p2wpkh; break; default: throw Exception("No Path type $type exists"); } + + final address = isar_models.Address() + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = addrType + ..publicKey = node.publicKey + ..value = addressString + ..derivationIndex = index + j; + receivingNodes.addAll({ "${_id}_$j": { "node": node, @@ -463,7 +441,7 @@ class NamecoinWallet extends CoinServiceAPI { } }); txCountCallArgs.addAll({ - "${_id}_$j": address, + "${_id}_$j": addressString, }); } @@ -475,9 +453,10 @@ class NamecoinWallet extends CoinServiceAPI { int count = counts["${_id}_$k"]!; if (count > 0) { final node = receivingNodes["${_id}_$k"]; + final address = node["address"] as isar_models.Address; // add address to array - addressArray.add(node["address"] as String); - iterationsAddressArray.add(node["address"] as String); + addressArray.add(address); + iterationsAddressArray.add(address.value); // set current index returningIndex = index + k; // reset counter @@ -541,16 +520,16 @@ class NamecoinWallet extends CoinServiceAPI { final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, _network)); - List p2pkhReceiveAddressArray = []; - List p2shReceiveAddressArray = []; - List p2wpkhReceiveAddressArray = []; + List p2pkhReceiveAddressArray = []; + List p2shReceiveAddressArray = []; + List p2wpkhReceiveAddressArray = []; int p2pkhReceiveIndex = -1; int p2shReceiveIndex = -1; int p2wpkhReceiveIndex = -1; - List p2pkhChangeAddressArray = []; - List p2shChangeAddressArray = []; - List p2wpkhChangeAddressArray = []; + List p2pkhChangeAddressArray = []; + List p2shChangeAddressArray = []; + List p2wpkhChangeAddressArray = []; int p2pkhChangeIndex = -1; int p2shChangeIndex = -1; int p2wpkhChangeIndex = -1; @@ -593,37 +572,37 @@ class NamecoinWallet extends CoinServiceAPI { ]); p2pkhReceiveAddressArray = - (await resultReceive44)['addressArray'] as List; + (await resultReceive44)['addressArray'] as List; p2pkhReceiveIndex = (await resultReceive44)['index'] as int; p2pkhReceiveDerivations = (await resultReceive44)['derivations'] as Map>; p2shReceiveAddressArray = - (await resultReceive49)['addressArray'] as List; + (await resultReceive49)['addressArray'] as List; p2shReceiveIndex = (await resultReceive49)['index'] as int; p2shReceiveDerivations = (await resultReceive49)['derivations'] as Map>; p2wpkhReceiveAddressArray = - (await resultReceive84)['addressArray'] as List; + (await resultReceive84)['addressArray'] as List; p2wpkhReceiveIndex = (await resultReceive84)['index'] as int; p2wpkhReceiveDerivations = (await resultReceive84)['derivations'] as Map>; p2pkhChangeAddressArray = - (await resultChange44)['addressArray'] as List; + (await resultChange44)['addressArray'] as List; p2pkhChangeIndex = (await resultChange44)['index'] as int; p2pkhChangeDerivations = (await resultChange44)['derivations'] as Map>; p2shChangeAddressArray = - (await resultChange49)['addressArray'] as List; + (await resultChange49)['addressArray'] as List; p2shChangeIndex = (await resultChange49)['index'] as int; p2shChangeDerivations = (await resultChange49)['derivations'] as Map>; p2wpkhChangeAddressArray = - (await resultChange84)['addressArray'] as List; + (await resultChange84)['addressArray'] as List; p2wpkhChangeIndex = (await resultChange84)['index'] as int; p2wpkhChangeDerivations = (await resultChange84)['derivations'] as Map>; @@ -672,19 +651,16 @@ class NamecoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(0, 0, DerivePathType.bip44); p2pkhReceiveAddressArray.add(address); - p2pkhReceiveIndex = 0; } if (p2shReceiveIndex == -1) { final address = await _generateAddressForChain(0, 0, DerivePathType.bip49); p2shReceiveAddressArray.add(address); - p2shReceiveIndex = 0; } if (p2wpkhReceiveIndex == -1) { final address = await _generateAddressForChain(0, 0, DerivePathType.bip84); p2wpkhReceiveAddressArray.add(address); - p2wpkhReceiveIndex = 0; } // If restoring a wallet that never sent any funds with change, then set changeArray @@ -693,65 +669,31 @@ class NamecoinWallet extends CoinServiceAPI { final address = await _generateAddressForChain(1, 0, DerivePathType.bip44); p2pkhChangeAddressArray.add(address); - p2pkhChangeIndex = 0; } if (p2shChangeIndex == -1) { final address = await _generateAddressForChain(1, 0, DerivePathType.bip49); p2shChangeAddressArray.add(address); - p2shChangeIndex = 0; } if (p2wpkhChangeIndex == -1) { final address = await _generateAddressForChain(1, 0, DerivePathType.bip84); p2wpkhChangeAddressArray.add(address); - p2wpkhChangeIndex = 0; } - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: p2wpkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: p2wpkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: p2pkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: p2pkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: p2shReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: p2shChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: p2wpkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: p2wpkhChangeIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2PKH', value: p2pkhChangeIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: p2pkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: p2shReceiveIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: p2shChangeIndex); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(p2wpkhReceiveAddressArray); + await isar.addresses.putAll(p2wpkhChangeAddressArray); + await isar.addresses.putAll(p2pkhReceiveAddressArray); + await isar.addresses.putAll(p2pkhChangeAddressArray); + await isar.addresses.putAll(p2shReceiveAddressArray); + await isar.addresses.putAll(p2shChangeAddressArray); + }); + + await _updateUTXOs(); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); await DB.instance @@ -795,11 +737,14 @@ class NamecoinWallet extends CoinServiceAPI { } if (!needsRefresh) { var allOwnAddresses = await _fetchAllOwnAddresses(); - List> allTxs = - await _fetchHistory(allOwnAddresses); - final txData = await transactionData; + List> allTxs = await _fetchHistory( + allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { - if (txData.findTransaction(transaction['tx_hash'] as String) == + final txid = transaction['tx_hash'] as String; + if ((await isar.transactions + .filter() + .txidMatches(txid) + .findFirst()) == null) { Logging.instance.log( " txid not found in address history already ${transaction['tx_hash']}", @@ -818,16 +763,25 @@ class NamecoinWallet extends CoinServiceAPI { } } - Future getAllTxsToWatch( - TransactionData txData, - ) async { + Future getAllTxsToWatch() async { if (_hasCalledExit) return; - List unconfirmedTxnsToNotifyPending = []; - List unconfirmedTxnsToNotifyConfirmed = []; + List unconfirmedTxnsToNotifyPending = []; + List unconfirmedTxnsToNotifyConfirmed = []; - for (final chunk in txData.txChunks) { - for (final tx in chunk.transactions) { - if (tx.confirmedStatus) { + final currentChainHeight = await chainHeight; + + final txCount = await isar.transactions.count(); + + const paginateLimit = 50; + + for (int i = 0; i < txCount; i += paginateLimit) { + final transactions = await isar.transactions + .where() + .offset(i) + .limit(paginateLimit) + .findAll(); + for (final tx in transactions) { + if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { // get all transactions that were notified as pending but not as confirmed if (txTracker.wasNotifiedPending(tx.txid) && !txTracker.wasNotifiedConfirmed(tx.txid)) { @@ -844,31 +798,33 @@ class NamecoinWallet extends CoinServiceAPI { // notify on unconfirmed transactions for (final tx in unconfirmedTxnsToNotifyPending) { - if (tx.txType == "Received") { + final confirmations = tx.getConfirmations(currentChainHeight); + + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Sending transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); @@ -877,7 +833,7 @@ class NamecoinWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { - if (tx.txType == "Received") { + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction confirmed", body: walletName, @@ -888,7 +844,7 @@ class NamecoinWallet extends CoinServiceAPI { coinName: coin.name, )); await txTracker.addNotifiedConfirmed(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Outgoing transaction confirmed", body: walletName, @@ -968,40 +924,30 @@ class NamecoinWallet extends CoinServiceAPI { } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - final changeAddressForTransactions = - _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); - final currentReceivingAddressesForTransactions = - _checkCurrentReceivingAddressesForTransactions(); + await _checkCurrentReceivingAddressesForTransactions(); - final newTxData = _fetchTransactionData(); + final fetchFuture = _refreshTransactions(); + final utxosRefreshFuture = _updateUTXOs(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); - final newUtxoData = _fetchUtxoData(); final feeObj = _getFees(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.60, walletId)); - _transactionData = Future(() => newTxData); - GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.70, walletId)); _feeObject = Future(() => feeObj); - _utxoData = Future(() => newUtxoData); + + await utxosRefreshFuture; GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); - final allTxsToWatch = getAllTxsToWatch(await newTxData); - await Future.wait([ - newTxData, - changeAddressForTransactions, - currentReceivingAddressesForTransactions, - newUtxoData, - feeObj, - allTxsToWatch, - ]); + await fetchFuture; + await getAllTxsToWatch(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.90, walletId)); } @@ -1086,9 +1032,7 @@ class NamecoinWallet extends CoinServiceAPI { // check for send all bool isSendAll = false; - final balance = - Format.decimalAmountToSatoshis(await availableBalance, coin); - if (satoshiAmount == balance) { + if (satoshiAmount == balance.spendable) { isSendAll = true; } @@ -1164,24 +1108,6 @@ class NamecoinWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - final txData = await prepareSend( - address: toAddress, satoshiAmount: amount, args: args); - final txHash = await confirmSend(txData: txData); - return txHash; - } catch (e, s) { - Logging.instance - .log("Exception rethrown from send(): $e\n$s", level: LogLevel.Error); - rethrow; - } - } - @override Future testNetworkConnection() async { try { @@ -1254,6 +1180,22 @@ class NamecoinWallet extends CoinServiceAPI { ]); } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1264,65 +1206,54 @@ class NamecoinWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); } - @override - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - Future? _transactionData; - - TransactionData? cachedTxData; - // hack to add tx to txData before refresh completes // required based on current app architecture where we don't properly store // transactions locally in a good way @override Future updateSentCachedTxData(Map txData) async { - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final String worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - - final tx = models.Transaction( - txid: txData["txid"] as String, - confirmedStatus: false, - timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, - txType: "Sent", - amount: txData["recipientAmt"] as int, - worthNow: worthNow, - worthAtBlockTimestamp: worthNow, - fees: txData["fee"] as int, - inputSize: 0, - outputSize: 0, - inputs: [], - outputs: [], - address: txData["address"] as String, - height: -1, - confirmations: 0, - ); - - if (cachedTxData == null) { - final data = await _fetchTransactionData(); - _transactionData = Future(() => data); - } - - final transactions = cachedTxData!.getAllTransactions(); - transactions[tx.txid] = tx; - cachedTxData = models.TransactionData.fromMap(transactions); - _transactionData = Future(() => cachedTxData!); + // final priceData = + // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); + // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final String worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // + // final tx = models.Transaction( + // txid: txData["txid"] as String, + // confirmedStatus: false, + // timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // txType: "Sent", + // amount: txData["recipientAmt"] as int, + // worthNow: worthNow, + // worthAtBlockTimestamp: worthNow, + // fees: txData["fee"] as int, + // inputSize: 0, + // outputSize: 0, + // inputs: [], + // outputs: [], + // address: txData["address"] as String, + // height: -1, + // confirmations: 0, + // ); + // + // if (cachedTxData == null) { + // final data = await _refreshTransactions(); + // _transactionData = Future(() => data); + // } + // + // final transactions = cachedTxData!.getAllTransactions(); + // transactions[tx.txid] = tx; + // cachedTxData = models.TransactionData.fromMap(transactions); + // _transactionData = Future(() => cachedTxData!); } @override @@ -1352,7 +1283,7 @@ class NamecoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; + late Isar isar; NamecoinWallet({ required String walletId, @@ -1361,7 +1292,6 @@ class NamecoinWallet extends CoinServiceAPI { required ElectrumX client, required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, - PriceAPI? priceAPI, required SecureStorageInterface secureStore, }) { txTracker = tracker; @@ -1370,8 +1300,6 @@ class NamecoinWallet extends CoinServiceAPI { _coin = coin; _electrumXClient = client; _cachedElectrumXClient = cachedClient; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; } @@ -1428,53 +1356,59 @@ class NamecoinWallet extends CoinServiceAPI { ); } - Future> _fetchAllOwnAddresses() async { - final List allAddresses = []; - final receivingAddresses = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH') as List; - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final receivingAddressesP2PKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2PKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - final receivingAddressesP2SH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2SH') as List; - final changeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - as List; - - for (var i = 0; i < receivingAddresses.length; i++) { - if (!allAddresses.contains(receivingAddresses[i])) { - allAddresses.add(receivingAddresses[i] as String); - } - } - for (var i = 0; i < changeAddresses.length; i++) { - if (!allAddresses.contains(changeAddresses[i])) { - allAddresses.add(changeAddresses[i] as String); - } - } - for (var i = 0; i < receivingAddressesP2PKH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2PKH[i])) { - allAddresses.add(receivingAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - if (!allAddresses.contains(changeAddressesP2PKH[i])) { - allAddresses.add(changeAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < receivingAddressesP2SH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2SH[i])) { - allAddresses.add(receivingAddressesP2SH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2SH.length; i++) { - if (!allAddresses.contains(changeAddressesP2SH[i])) { - allAddresses.add(changeAddressesP2SH[i] as String); - } - } + Future> _fetchAllOwnAddresses() async { + final allAddresses = await isar.addresses + .filter() + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change) + .findAll(); + // final List allAddresses = []; + // final receivingAddresses = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH') as List; + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final receivingAddressesP2PKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2PKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // final receivingAddressesP2SH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2SH') as List; + // final changeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') + // as List; + // + // for (var i = 0; i < receivingAddresses.length; i++) { + // if (!allAddresses.contains(receivingAddresses[i])) { + // allAddresses.add(receivingAddresses[i] as String); + // } + // } + // for (var i = 0; i < changeAddresses.length; i++) { + // if (!allAddresses.contains(changeAddresses[i])) { + // allAddresses.add(changeAddresses[i] as String); + // } + // } + // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2PKH[i])) { + // allAddresses.add(receivingAddressesP2PKH[i] as String); + // } + // } + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2PKH[i])) { + // allAddresses.add(changeAddressesP2PKH[i] as String); + // } + // } + // for (var i = 0; i < receivingAddressesP2SH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2SH[i])) { + // allAddresses.add(receivingAddressesP2SH[i] as String); + // } + // } + // for (var i = 0; i < changeAddressesP2SH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2SH[i])) { + // allAddresses.add(changeAddressesP2SH[i] as String); + // } + // } return allAddresses; } @@ -1532,24 +1466,6 @@ class NamecoinWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2SH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2SH", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -1557,90 +1473,25 @@ class NamecoinWallet extends CoinServiceAPI { value: {}); // Generate and add addresses to relevant arrays - await Future.wait([ + final initialAddresses = await Future.wait([ // P2WPKH - _generateAddressForChain(0, 0, DerivePathType.bip84).then( - (initialReceivingAddressP2WPKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2WPKH, 0, DerivePathType.bip84); - _currentReceivingAddress = - Future(() => initialReceivingAddressP2WPKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip84).then( - (initialChangeAddressP2WPKH) => _addToAddressesArrayForChain( - initialChangeAddressP2WPKH, - 1, - DerivePathType.bip84, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip84), + _generateAddressForChain(1, 0, DerivePathType.bip84), // P2PKH - _generateAddressForChain(0, 0, DerivePathType.bip44).then( - (initialReceivingAddressP2PKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - _currentReceivingAddressP2PKH = - Future(() => initialReceivingAddressP2PKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip44).then( - (initialChangeAddressP2PKH) => _addToAddressesArrayForChain( - initialChangeAddressP2PKH, - 1, - DerivePathType.bip44, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip44), + _generateAddressForChain(1, 0, DerivePathType.bip44), // P2SH - _generateAddressForChain(0, 0, DerivePathType.bip49).then( - (initialReceivingAddressP2SH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2SH, 0, DerivePathType.bip49); - _currentReceivingAddressP2SH = - Future(() => initialReceivingAddressP2SH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip49).then( - (initialChangeAddressP2SH) => _addToAddressesArrayForChain( - initialChangeAddressP2SH, - 1, - DerivePathType.bip49, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip49), + _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - // // P2PKH - // _generateAddressForChain(0, 0, DerivePathType.bip44).then( - // (initialReceivingAddressP2PKH) { - // _addToAddressesArrayForChain( - // initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - // this._currentReceivingAddressP2PKH = - // Future(() => initialReceivingAddressP2PKH); - // }, - // ); - // _generateAddressForChain(1, 0, DerivePathType.bip44) - // .then((initialChangeAddressP2PKH) => _addToAddressesArrayForChain( - // initialChangeAddressP2PKH, - // 1, - // DerivePathType.bip44, - // )); - // - // // P2SH - // _generateAddressForChain(0, 0, DerivePathType.bip49).then( - // (initialReceivingAddressP2SH) { - // _addToAddressesArrayForChain( - // initialReceivingAddressP2SH, 0, DerivePathType.bip49); - // this._currentReceivingAddressP2SH = - // Future(() => initialReceivingAddressP2SH); - // }, - // ); - // _generateAddressForChain(1, 0, DerivePathType.bip49) - // .then((initialChangeAddressP2SH) => _addToAddressesArrayForChain( - // initialChangeAddressP2SH, - // 1, - // DerivePathType.bip49, - // )); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(initialAddresses); + }); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1648,7 +1499,7 @@ class NamecoinWallet extends CoinServiceAPI { /// Generates a new internal or external chain address for the wallet using a BIP84, BIP44, or BIP49 derivation path. /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! /// [index] - This can be any integer >= 0 - Future _generateAddressForChain( + Future _generateAddressForChain( int chain, int index, DerivePathType derivePathType, @@ -1666,10 +1517,12 @@ class NamecoinWallet extends CoinServiceAPI { ); final data = PaymentData(pubkey: node.publicKey); String address; + isar_models.AddressType addrType; switch (derivePathType) { case DerivePathType.bip44: address = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: address = P2SH( @@ -1682,12 +1535,14 @@ class NamecoinWallet extends CoinServiceAPI { network: _network) .data .address!; + addrType = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: address = P2WPKH( network: _network, data: data, overridePrefix: namecoin.bech32!) .data .address!; + addrType = isar_models.AddressType.p2wpkh; break; } @@ -1700,98 +1555,47 @@ class NamecoinWallet extends CoinServiceAPI { derivePathType: derivePathType, ); - return address; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain( - int chain, DerivePathType derivePathType) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain( - String address, int chain, DerivePathType derivePathType) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - switch (derivePathType) { - case DerivePathType.bip44: - chainArray += "P2PKH"; - break; - case DerivePathType.bip49: - chainArray += "P2SH"; - break; - case DerivePathType.bip84: - chainArray += "P2WPKH"; - break; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = node.publicKey + ..type = addrType + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// and /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! Future _getCurrentAddressForChain( - int chain, DerivePathType derivePathType) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; + int chain, + DerivePathType derivePathType, + ) async { + final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; + + isar_models.AddressType type; + isar_models.Address? address; switch (derivePathType) { case DerivePathType.bip44: - arrayKey += "P2PKH"; + type = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - arrayKey += "P2SH"; + type = isar_models.AddressType.p2sh; break; case DerivePathType.bip84: - arrayKey += "P2WPKH"; + type = isar_models.AddressType.p2wpkh; break; } - final internalChainArray = - DB.instance.get(boxName: walletId, key: arrayKey); - return internalChainArray.last as String; + address = await isar.addresses + .filter() + .typeEqualTo(type) + .subTypeEqualTo(subType) + .sortByDerivationIndexDesc() + .findFirst(); + return address!.value; } String _buildDerivationStorageKey({ @@ -1896,8 +1700,8 @@ class NamecoinWallet extends CoinServiceAPI { await _secureStore.write(key: key, value: newReceiveDerivationsString); } - Future _fetchUtxoData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future _updateUTXOs() async { + final allAddresses = await _fetchAllOwnAddresses(); try { final fetchedUtxoList = >>[]; @@ -1909,9 +1713,10 @@ class NamecoinWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = + _convertToScriptHash(allAddresses[i].value, _network); - print("SCRIPT_HASH_FOR_ADDRESS ${allAddresses[i]} IS $scripthash"); + // print("SCRIPT_HASH_FOR_ADDRESS ${allAddresses[i]} IS $scripthash"); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -1929,142 +1734,119 @@ class NamecoinWallet extends CoinServiceAPI { } } } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> outputArray = []; - int satoshiBalance = 0; + + final currentChainHeight = await chainHeight; + + final List outputArray = []; + int satoshiBalanceTotal = 0; int satoshiBalancePending = 0; + int satoshiBalanceSpendable = 0; + int satoshiBalanceBlocked = 0; for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - int value = fetchedUtxoList[i][j]["value"] as int; - satoshiBalance += value; - final txn = await cachedElectrumXClient.getTransaction( txHash: fetchedUtxoList[i][j]["tx_hash"] as String, verbose: true, coin: coin, ); - final Map utxo = {}; - final int confirmations = txn["confirmations"] as int? ?? 0; - final bool confirmed = confirmations >= MINIMUM_CONFIRMATIONS; - if (!confirmed) { - satoshiBalancePending += value; + final utxo = isar_models.UTXO(); + + utxo.txid = txn["txid"] as String; + utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; + utxo.value = fetchedUtxoList[i][j]["value"] as int; + utxo.name = ""; + + // todo check here if we should mark as blocked + utxo.isBlocked = false; + utxo.blockedReason = null; + + utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; + utxo.blockHash = txn["blockhash"] as String?; + utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; + utxo.blockTime = txn["blocktime"] as int?; + + satoshiBalanceTotal += utxo.value; + + if (utxo.isBlocked) { + satoshiBalanceBlocked += utxo.value; + } else { + if (utxo.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + satoshiBalanceSpendable += utxo.value; + } else { + satoshiBalancePending += utxo.value; + } } - utxo["txid"] = txn["txid"]; - utxo["vout"] = fetchedUtxoList[i][j]["tx_pos"]; - utxo["value"] = value; - - utxo["status"] = {}; - utxo["status"]["confirmed"] = confirmed; - utxo["status"]["confirmations"] = confirmations; - utxo["status"]["block_height"] = fetchedUtxoList[i][j]["height"]; - utxo["status"]["block_hash"] = txn["blockhash"]; - utxo["status"]["block_time"] = txn["blocktime"]; - - final fiatValue = ((Decimal.fromInt(value) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - utxo["rawWorth"] = fiatValue; - utxo["fiatWorth"] = fiatValue.toString(); outputArray.add(utxo); } } - Decimal currencyBalanceRaw = - ((Decimal.fromInt(satoshiBalance) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - - final Map result = { - "total_user_currency": currencyBalanceRaw.toString(), - "total_sats": satoshiBalance, - "total_btc": (Decimal.fromInt(satoshiBalance) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal( - scaleOnInfinitePrecision: Constants.decimalPlacesForCoin(coin)) - .toString(), - "outputArray": outputArray, - "unconfirmed": satoshiBalancePending, - }; - - final dataModel = UtxoData.fromJson(result); - - final List allOutputs = dataModel.unspentOutputArray; Logging.instance - .log('Outputs fetched: $allOutputs', level: LogLevel.Info); - await _sortOutputs(allOutputs); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: dataModel); - await DB.instance.put( - boxName: walletId, - key: 'totalBalance', - value: dataModel.satoshiBalance); - return dataModel; + .log('Outputs fetched: $outputArray', level: LogLevel.Info); + + await isar.writeTxn(() async { + await isar.utxos.clear(); + await isar.utxos.putAll(outputArray); + }); + + // finally update balance + _balance = Balance( + coin: coin, + total: satoshiBalanceTotal, + spendable: satoshiBalanceSpendable, + blockedTotal: satoshiBalanceBlocked, + pendingSpendable: satoshiBalancePending, + ); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); - final latestTxModel = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model') - as models.UtxoData?; - - if (latestTxModel == null) { - final emptyModel = { - "total_user_currency": "0.00", - "total_sats": 0, - "total_btc": "0", - "outputArray": [] - }; - return UtxoData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old output model located", level: LogLevel.Warning); - return latestTxModel; - } } } - /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - /// Now also checks for output labeling. - Future _sortOutputs(List utxos) async { - final blockedHashArray = - DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - as List?; - final List lst = []; - if (blockedHashArray != null) { - for (var hash in blockedHashArray) { - lst.add(hash as String); - } - } - final labels = - DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - {}; + @override + Balance get balance => _balance!; + Balance? _balance; - outputsList = []; - - for (var i = 0; i < utxos.length; i++) { - if (labels[utxos[i].txid] != null) { - utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - } else { - utxos[i].txName = 'Output #$i'; - } - - if (utxos[i].status.confirmed == false) { - outputsList.add(utxos[i]); - } else { - if (lst.contains(utxos[i].txid)) { - utxos[i].blocked = true; - outputsList.add(utxos[i]); - } else if (!lst.contains(utxos[i].txid)) { - outputsList.add(utxos[i]); - } - } - } - } + // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) + // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. + // /// Now also checks for output labeling. + // Future _sortOutputs(List utxos) async { + // final blockedHashArray = + // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') + // as List?; + // final List lst = []; + // if (blockedHashArray != null) { + // for (var hash in blockedHashArray) { + // lst.add(hash as String); + // } + // } + // final labels = + // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? + // {}; + // + // outputsList = []; + // + // for (var i = 0; i < utxos.length; i++) { + // if (labels[utxos[i].txid] != null) { + // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; + // } else { + // utxos[i].txName = 'Output #$i'; + // } + // + // if (utxos[i].status.confirmed == false) { + // outputsList.add(utxos[i]); + // } else { + // if (lst.contains(utxos[i].txid)) { + // utxos[i].blocked = true; + // outputsList.add(utxos[i]); + // } else if (!lst.contains(utxos[i].txid)) { + // outputsList.add(utxos[i]); + // } + // } + // } + // } Future getTxCount({required String address}) async { String? scripthash; @@ -2086,13 +1868,13 @@ class NamecoinWallet extends CoinServiceAPI { }) async { try { final Map> args = {}; - print("Address $addresses"); + // print("Address $addresses"); for (final entry in addresses.entries) { args[entry.key] = [_convertToScriptHash(entry.value, _network)]; } - print("Args ${jsonEncode(args)}"); + // print("Args ${jsonEncode(args)}"); final response = await electrumXClient.getBatchHistory(args: args); - print("Response ${jsonEncode(response)}"); + // print("Response ${jsonEncode(response)}"); final Map result = {}; for (final entry in response.entries) { result[entry.key] = entry.value.length; @@ -2107,111 +1889,65 @@ class NamecoinWallet extends CoinServiceAPI { } } - Future _checkReceivingAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkReceivingAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(0, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentReceiving = await _currentReceivingAddress; + + final int txCount = await getTxCount(address: currentReceiving.value); Logging.instance.log( - 'Number of txs for current receiving address $currentExternalAddr: $txCount', + 'Number of txs for current receiving address $currentReceiving: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the receiving index - await _incrementAddressIndexForChain(0, derivePathType); - - // Check the new receiving index - String indexKey = "receivingIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = currentReceiving.derivationIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, newReceivingIndex, derivePathType); + 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain( - newReceivingAddress, 0, derivePathType); - - // Set the new receiving address that the service - - switch (derivePathType) { - case DerivePathType.bip44: - _currentReceivingAddressP2PKH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip49: - _currentReceivingAddressP2SH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip84: - _currentReceivingAddress = Future(() => newReceivingAddress); - break; - } + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } } - Future _checkChangeAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkChangeAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(1, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentChange = await _currentChangeAddress; + final int txCount = await getTxCount(address: currentChange.value); Logging.instance.log( - 'Number of txs for current change address $currentExternalAddr: $txCount', + 'Number of txs for current change address $currentChange: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the change index - await _incrementAddressIndexForChain(1, derivePathType); - - // Check the new change index - String indexKey = "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip49: - indexKey += "P2SH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newChangeIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newChangeIndex = currentChange.derivationIndex + 1; // Use new index to derive a new change address - final newChangeAddress = - await _generateAddressForChain(1, newChangeIndex, derivePathType); + final newChangeAddress = await _generateAddressForChain( + 1, newChangeIndex, DerivePathType.bip84); - // Add that new receiving address to the array of change addresses - await _addToAddressesArrayForChain(newChangeAddress, 1, derivePathType); + // Add that new change address + await isar.writeTxn(() async { + await isar.addresses.put(newChangeAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( - "SocketException caught in _checkReceivingAddressForTransactions($derivePathType): $se\n$s", + "SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s", level: LogLevel.Error); return; } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } @@ -2219,9 +1955,9 @@ class NamecoinWallet extends CoinServiceAPI { Future _checkCurrentReceivingAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkReceivingAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkReceivingAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentReceivingAddressesForTransactions(): $e\n$s", @@ -2243,9 +1979,9 @@ class NamecoinWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkChangeAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkChangeAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentChangeAddressesForTransactions(): $e\n$s", @@ -2379,52 +2115,53 @@ class NamecoinWallet extends CoinServiceAPI { return allTransactions; } - Future _fetchTransactionData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future _refreshTransactions() async { + final List allAddresses = + await _fetchAllOwnAddresses(); - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - final changeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - as List; - - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - changeAddresses.add(changeAddressesP2PKH[i] as String); - } - for (var i = 0; i < changeAddressesP2SH.length; i++) { - changeAddresses.add(changeAddressesP2SH[i] as String); - } + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // final changeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') + // as List; + // + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // changeAddresses.add(changeAddressesP2PKH[i] as String); + // } + // for (var i = 0; i < changeAddressesP2SH.length; i++) { + // changeAddresses.add(changeAddressesP2SH[i] as String); + // } final List> allTxHashes = - await _fetchHistory(allAddresses); + await _fetchHistory(allAddresses.map((e) => e.value).toList()); - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as TransactionData?; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; - - final unconfirmedCachedTransactions = - cachedTransactions?.getAllTransactions() ?? {}; - unconfirmedCachedTransactions - .removeWhere((key, value) => value.confirmedStatus); - - if (cachedTransactions != null) { - for (final tx in allTxHashes.toList(growable: false)) { - final txHeight = tx["height"] as int; - if (txHeight > 0 && - txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - allTxHashes.remove(tx); - } - } - } - } + // final cachedTransactions = + // DB.instance.get(boxName: walletId, key: 'latest_tx_model') + // as TransactionData?; + // int latestTxnBlockHeight = + // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") + // as int? ?? + // 0; + // + // final unconfirmedCachedTransactions = + // cachedTransactions?.getAllTransactions() ?? {}; + // unconfirmedCachedTransactions + // .removeWhere((key, value) => value.confirmedStatus); + // + // if (cachedTransactions != null) { + // for (final tx in allTxHashes.toList(growable: false)) { + // final txHeight = tx["height"] as int; + // if (txHeight > 0 && + // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { + // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { + // allTxHashes.remove(tx); + // } + // } + // } + // } Set hashes = {}; for (var element in allTxHashes) { @@ -2441,7 +2178,6 @@ class NamecoinWallet extends CoinServiceAPI { ); // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - // TODO fix this for sent to self transactions? if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { tx["address"] = txHash["address"]; tx["height"] = txHash["height"]; @@ -2449,16 +2185,11 @@ class NamecoinWallet extends CoinServiceAPI { } } - Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); - Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); - - Logging.instance.log("allTransactions length: ${allTransactions.length}", - level: LogLevel.Info); - - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + // Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); + // Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); + // + // Logging.instance.log("allTransactions length: ${allTransactions.length}", + // level: LogLevel.Info); Set vHashes = {}; for (final txObject in allTransactions) { @@ -2471,260 +2202,279 @@ class NamecoinWallet extends CoinServiceAPI { await fastFetch(vHashes.toList()); for (final txObject in allTransactions) { - List sendersArray = []; - List recipientsArray = []; + final txn = await parseTransaction( + txObject, + cachedElectrumXClient, + allAddresses, + coin, + MINIMUM_CONFIRMATIONS, + ); - // Usually only has value when txType = 'Send' - int inputAmtSentFromWallet = 0; - // Usually has value regardless of txType due to change addresses - int outputAmtAddressedToWallet = 0; - int fee = 0; + // final tx = await isar.transactions + // .filter() + // .txidMatches(midSortedTx.txid) + // .findFirst(); + // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar + // if (tx == null) { + await isar.writeTxn(() async { + await isar.transactions.put(txn); + }); + // } - Map midSortedTx = {}; - - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"]![i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - String? address = out["scriptPubKey"]["address"] as String?; - if (address == null && out["scriptPubKey"]["address"] != null) { - address = out["scriptPubKey"]["address"] as String?; - } - - if (address != null) { - sendersArray.add(address); - } - } - } - } - - Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - - for (final output in txObject["vout"] as List) { - String? address = output["scriptPubKey"]["address"] as String?; - if (address == null && output["scriptPubKey"]["address"] != null) { - address = output["scriptPubKey"]["address"] as String?; - } - if (address != null) { - recipientsArray.add(address); - } - } - - Logging.instance - .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - - final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)); - Logging.instance - .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - - // If txType = Sent, then calculate inputAmtSentFromWallet - if (foundInSenders) { - int totalInput = 0; - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"]![i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - inputAmtSentFromWallet += - (Decimal.parse(out["value"]!.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - totalInput = inputAmtSentFromWallet; - int totalOutput = 0; - - for (final output in txObject["vout"] as List) { - Logging.instance.log(output, level: LogLevel.Info); - final address = output["scriptPubKey"]["address"]; - final value = output["value"]; - final _value = (Decimal.parse(value.toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOutput += _value; - if (changeAddresses.contains(address)) { - inputAmtSentFromWallet -= _value; - } else { - // change address from 'sent from' to the 'sent to' address - txObject["address"] = address; - } - } - // calculate transaction fee - fee = totalInput - totalOutput; - // subtract fee from sent to calculate correct value of sent tx - inputAmtSentFromWallet -= fee; - } else { - // counters for fee calculation - int totalOut = 0; - int totalIn = 0; - - // add up received tx value - for (final output in txObject["vout"] as List) { - String? address = output["scriptPubKey"]["address"] as String?; - if (address == null && output["scriptPubKey"]["address"] != null) { - address = output["scriptPubKey"]["address"] as String?; - } - if (address != null) { - final value = (Decimal.parse(output["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - totalOut += value; - if (allAddresses.contains(address)) { - outputAmtAddressedToWallet += value; - } - } - } - - // calculate fee for received tx - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"][i] as Map; - final prevTxid = input["txid"] as String; - final prevOut = input["vout"] as int; - final tx = await _cachedElectrumXClient.getTransaction( - txHash: prevTxid, - coin: coin, - ); - - for (final out in tx["vout"] as List) { - if (prevOut == out["n"]) { - totalIn += (Decimal.parse(out["value"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toBigInt() - .toInt(); - } - } - } - fee = totalIn - totalOut; - } - - // create final tx map - midSortedTx["txid"] = txObject["txid"]; - midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - midSortedTx["timestamp"] = txObject["blocktime"] ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000); - - if (foundInSenders) { - midSortedTx["txType"] = "Sent"; - midSortedTx["amount"] = inputAmtSentFromWallet; - final String worthNow = - ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - } else { - midSortedTx["txType"] = "Received"; - midSortedTx["amount"] = outputAmtAddressedToWallet; - final worthNow = - ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - } - midSortedTx["aliens"] = []; - midSortedTx["fees"] = fee; - midSortedTx["address"] = txObject["address"]; - midSortedTx["inputSize"] = txObject["vin"].length; - midSortedTx["outputSize"] = txObject["vout"].length; - midSortedTx["inputs"] = txObject["vin"]; - midSortedTx["outputs"] = txObject["vout"]; - - final int height = txObject["height"] as int; - midSortedTx["height"] = height; - - if (height >= latestTxnBlockHeight) { - latestTxnBlockHeight = height; - } - - midSortedArray.add(midSortedTx); + // List sendersArray = []; + // List recipientsArray = []; + // + // // Usually only has value when txType = 'Send' + // int inputAmtSentFromWallet = 0; + // // Usually has value regardless of txType due to change addresses + // int outputAmtAddressedToWallet = 0; + // int fee = 0; + // + // Map midSortedTx = {}; + // + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"]![i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // String? address = out["scriptPubKey"]["address"] as String?; + // if (address == null && out["scriptPubKey"]["address"] != null) { + // address = out["scriptPubKey"]["address"] as String?; + // } + // + // if (address != null) { + // sendersArray.add(address); + // } + // } + // } + // } + // + // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); + // + // for (final output in txObject["vout"] as List) { + // String? address = output["scriptPubKey"]["address"] as String?; + // if (address == null && output["scriptPubKey"]["address"] != null) { + // address = output["scriptPubKey"]["address"] as String?; + // } + // if (address != null) { + // recipientsArray.add(address); + // } + // } + // + // Logging.instance + // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); + // + // final foundInSenders = + // allAddresses.any((element) => sendersArray.contains(element)); + // Logging.instance + // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); + // + // // If txType = Sent, then calculate inputAmtSentFromWallet + // if (foundInSenders) { + // int totalInput = 0; + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"]![i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // inputAmtSentFromWallet += + // (Decimal.parse(out["value"]!.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // totalInput = inputAmtSentFromWallet; + // int totalOutput = 0; + // + // for (final output in txObject["vout"] as List) { + // Logging.instance.log(output, level: LogLevel.Info); + // final address = output["scriptPubKey"]["address"]; + // final value = output["value"]; + // final _value = (Decimal.parse(value.toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOutput += _value; + // if (changeAddresses.contains(address)) { + // inputAmtSentFromWallet -= _value; + // } else { + // // change address from 'sent from' to the 'sent to' address + // txObject["address"] = address; + // } + // } + // // calculate transaction fee + // fee = totalInput - totalOutput; + // // subtract fee from sent to calculate correct value of sent tx + // inputAmtSentFromWallet -= fee; + // } else { + // // counters for fee calculation + // int totalOut = 0; + // int totalIn = 0; + // + // // add up received tx value + // for (final output in txObject["vout"] as List) { + // String? address = output["scriptPubKey"]["address"] as String?; + // if (address == null && output["scriptPubKey"]["address"] != null) { + // address = output["scriptPubKey"]["address"] as String?; + // } + // if (address != null) { + // final value = (Decimal.parse(output["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // totalOut += value; + // if (allAddresses.contains(address)) { + // outputAmtAddressedToWallet += value; + // } + // } + // } + // + // // calculate fee for received tx + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"][i] as Map; + // final prevTxid = input["txid"] as String; + // final prevOut = input["vout"] as int; + // final tx = await _cachedElectrumXClient.getTransaction( + // txHash: prevTxid, + // coin: coin, + // ); + // + // for (final out in tx["vout"] as List) { + // if (prevOut == out["n"]) { + // totalIn += (Decimal.parse(out["value"].toString()) * + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toBigInt() + // .toInt(); + // } + // } + // } + // fee = totalIn - totalOut; + // } + // + // // create final tx map + // midSortedTx["txid"] = txObject["txid"]; + // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && + // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); + // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; + // midSortedTx["timestamp"] = txObject["blocktime"] ?? + // (DateTime.now().millisecondsSinceEpoch ~/ 1000); + // + // if (foundInSenders) { + // midSortedTx["txType"] = "Sent"; + // midSortedTx["amount"] = inputAmtSentFromWallet; + // final String worthNow = + // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // midSortedTx["worthAtBlockTimestamp"] = worthNow; + // } else { + // midSortedTx["txType"] = "Received"; + // midSortedTx["amount"] = outputAmtAddressedToWallet; + // final worthNow = + // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2) + // .toStringAsFixed(2); + // midSortedTx["worthNow"] = worthNow; + // } + // midSortedTx["aliens"] = []; + // midSortedTx["fees"] = fee; + // midSortedTx["address"] = txObject["address"]; + // midSortedTx["inputSize"] = txObject["vin"].length; + // midSortedTx["outputSize"] = txObject["vout"].length; + // midSortedTx["inputs"] = txObject["vin"]; + // midSortedTx["outputs"] = txObject["vout"]; + // + // final int height = txObject["height"] as int; + // midSortedTx["height"] = height; + // + // if (height >= latestTxnBlockHeight) { + // latestTxnBlockHeight = height; + // } + // + // midSortedArray.add(midSortedTx); } - - // sort by date ---- //TODO not sure if needed - // shouldn't be any issues with a null timestamp but I got one at some point? - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // { - // final aT = a["timestamp"]; - // final bT = b["timestamp"]; // - // if (aT == null && bT == null) { - // return 0; - // } else if (aT == null) { - // return -1; - // } else if (bT == null) { - // return 1; + // // sort by date ---- //TODO not sure if needed + // // shouldn't be any issues with a null timestamp but I got one at some point? + // midSortedArray + // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); + // // { + // // final aT = a["timestamp"]; + // // final bT = b["timestamp"]; + // // + // // if (aT == null && bT == null) { + // // return 0; + // // } else if (aT == null) { + // // return -1; + // // } else if (bT == null) { + // // return 1; + // // } else { + // // return bT - aT; + // // } + // // }); + // + // // buildDateTimeChunks + // 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 { - // return bT - aT; + // dateArray.add(txTimeArray[1]); + // final chunk = { + // "timestamp": txTimeArray[0], + // "transactions": [txObject], + // }; + // result["dateTimeChunks"].add(chunk); // } - // }); - - // buildDateTimeChunks - 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], - }; - result["dateTimeChunks"].add(chunk); - } - } - - final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); - - 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); - - cachedTxData = txModel; - return txModel; + // } + // + // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; + // transactionsMap + // .addAll(TransactionData.fromJson(result).getAllTransactions()); + // + // 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); + // + // cachedTxData = txModel; + // return txModel; } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2741,26 +2491,28 @@ class NamecoinWallet extends CoinServiceAPI { String _recipientAddress, bool isSendAll, { int additionalOutputs = 0, - List? utxos, + List? utxos, }) async { Logging.instance .log("Starting coinSelection ----------", level: LogLevel.Info); - final List availableOutputs = utxos ?? outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final currentChainHeight = await chainHeight; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", level: LogLevel.Info); @@ -2787,7 +2539,7 @@ class NamecoinWallet extends CoinServiceAPI { // Possible situation right here int satoshisBeingUsed = 0; int inputsBeingConsumed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; satoshisBeingUsed < satoshiAmountToSend && i < spendableOutputs.length; @@ -2905,7 +2657,7 @@ class NamecoinWallet extends CoinServiceAPI { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize == feeForTwoOutputs) { // generate new change address if current change address has been used - await _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); final String newChangeAddress = await _getCurrentAddressForChain(1, DerivePathType.bip84); @@ -3075,7 +2827,7 @@ class NamecoinWallet extends CoinServiceAPI { } Future> fetchBuildTxData( - List utxosToUse, + List utxosToUse, ) async { // return data Map results = {}; @@ -3323,7 +3075,7 @@ class NamecoinWallet extends CoinServiceAPI { /// Builds and signs a transaction Future> buildTransaction({ - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required List recipients, required List satoshiAmounts, @@ -3774,22 +3526,23 @@ class NamecoinWallet extends CoinServiceAPI { @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { - final available = - Format.decimalAmountToSatoshis(await availableBalance, coin); + final available = balance.spendable; if (available == satoshiAmount) { - return satoshiAmount - sweepAllEstimate(feeRate); + return satoshiAmount - (await sweepAllEstimate(feeRate)); } else if (satoshiAmount <= 0 || satoshiAmount > available) { return roughFeeEstimate(1, 2, feeRate); } int runningBalance = 0; int inputCount = 0; - for (final output in outputsList) { - runningBalance += output.value; - inputCount++; - if (runningBalance > satoshiAmount) { - break; + for (final output in (await utxos)) { + if (!output.isBlocked) { + runningBalance += output.value; + inputCount++; + if (runningBalance > satoshiAmount) { + break; + } } } @@ -3821,11 +3574,12 @@ class NamecoinWallet extends CoinServiceAPI { (feeRatePerKB / 1000).ceil(); } - int sweepAllEstimate(int feeRate) { + Future sweepAllEstimate(int feeRate) async { int available = 0; int inputCount = 0; - for (final output in outputsList) { - if (output.status.confirmed) { + for (final output in (await utxos)) { + if (!output.isBlocked && + output.isConfirmed(storedChainHeight, MINIMUM_CONFIRMATIONS)) { available += output.value; inputCount++; } @@ -3840,23 +3594,18 @@ class NamecoinWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - await _incrementAddressIndexForChain( - 0, DerivePathType.bip84); // First increment the receiving index - final newReceivingIndex = DB.instance.get( - boxName: walletId, - key: 'receivingIndexP2WPKH') as int; // Check the new receiving index + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, - newReceivingIndex, - DerivePathType - .bip84); // Use new index to derive a new receiving address - await _addToAddressesArrayForChain( - newReceivingAddress, - 0, - DerivePathType - .bip84); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddress = Future(() => - newReceivingAddress); // Set the new receiving address that the service + 0, newReceivingIndex, DerivePathType.bip84); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { From 275e3ab4cb2df0b70e1e9e1e61b55f99c94848c7 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 20:09:08 -0600 Subject: [PATCH 100/192] WIP migrate particl_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/particl/particl_wallet.dart | 1307 ++++++++--------- 1 file changed, 578 insertions(+), 729 deletions(-) diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index fe535dbf0..b95c6d567 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:typed_data'; import 'package:bech32/bech32.dart'; import 'package:bip32/bip32.dart' as bip32; @@ -10,16 +9,14 @@ import 'package:bitcoindart/bitcoindart.dart'; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; -import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/models.dart' as models; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; @@ -28,7 +25,6 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -39,6 +35,7 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -153,8 +150,6 @@ class ParticlWallet extends CoinServiceAPI { } } - List outputsList = []; - @override set isFavorite(bool markFavorite) { DB.instance.put( @@ -177,63 +172,34 @@ class ParticlWallet extends CoinServiceAPI { Coin get coin => _coin; @override - Future> get allOwnAddresses => - _allOwnAddresses ??= _fetchAllOwnAddresses(); - Future>? _allOwnAddresses; - - Future? _utxoData; - Future get utxoData => _utxoData ??= _fetchUtxoData(); + Future> get utxos => isar.utxos.where().findAll(); @override - Future> get unspentOutputs async => - (await utxoData).unspentOutputArray; + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); @override - Future get availableBalance async { - final data = await utxoData; - return Format.satoshisToAmount( - data.satoshiBalance - data.satoshiBalanceUnconfirmed, - coin: coin); - } + Future get currentReceivingAddress async => + (await _currentReceivingAddress).value; - @override - Future get pendingBalance async { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalanceUnconfirmed, coin: coin); - } + Future get _currentReceivingAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; - @override - Future get balanceMinusMaxFee async => - (await availableBalance) - - (Decimal.fromInt((await maxFee)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(); + Future get currentChangeAddress async => + (await _currentChangeAddress).value; - @override - Future get totalBalance async { - if (!isActive) { - final totalBalance = DB.instance - .get(boxName: walletId, key: 'totalBalance') as int?; - if (totalBalance == null) { - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } else { - return Format.satoshisToAmount(totalBalance, coin: coin); - } - } - final data = await utxoData; - return Format.satoshisToAmount(data.satoshiBalance, coin: coin); - } - - @override - Future get currentReceivingAddress => _currentReceivingAddress ??= - _getCurrentAddressForChain(0, DerivePathType.bip84); - Future? _currentReceivingAddress; - - Future get currentLegacyReceivingAddress => - _currentReceivingAddressP2PKH ??= - _getCurrentAddressForChain(0, DerivePathType.bip44); - Future? _currentReceivingAddressP2PKH; + Future get _currentChangeAddress async => + (await isar.addresses + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -241,6 +207,7 @@ class ParticlWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); + await isar.close(); } bool _hasCalledExit = false; @@ -274,6 +241,7 @@ class ParticlWallet extends CoinServiceAPI { } } + @override int get storedChainHeight { final storedHeight = DB.instance .get(boxName: walletId, key: "storedChainHeight") as int?; @@ -389,8 +357,8 @@ class ParticlWallet extends CoinServiceAPI { int txCountBatchSize, bip32.BIP32 root, DerivePathType type, - int account) async { - List addressArray = []; + int chain) async { + List addressArray = []; int returningIndex = -1; Map> derivations = {}; int gapCounter = 0; @@ -399,7 +367,7 @@ class ParticlWallet extends CoinServiceAPI { index += txCountBatchSize) { List iterationsAddressArray = []; Logging.instance.log( - "index: $index, \t GapCounter $account ${type.name}: $gapCounter", + "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", level: LogLevel.Info); final _id = "k_$index"; @@ -410,31 +378,44 @@ class ParticlWallet extends CoinServiceAPI { final node = await compute( getBip32NodeFromRootWrapper, Tuple4( - account, + chain, index + j, root, type, ), ); - String? address; + String addressString; + isar_models.AddressType addrType; switch (type) { case DerivePathType.bip44: - address = P2PKH( + addressString = P2PKH( data: PaymentData(pubkey: node.publicKey), network: _network) .data .address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip84: - address = P2WPKH( + addressString = P2WPKH( network: _network, data: PaymentData(pubkey: node.publicKey)) .data .address!; + addrType = isar_models.AddressType.p2wpkh; break; default: throw Exception("No Path type $type exists"); } + + final address = isar_models.Address() + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change + ..type = addrType + ..publicKey = node.publicKey + ..value = addressString + ..derivationIndex = index + j; + receivingNodes.addAll({ "${_id}_$j": { "node": node, @@ -442,7 +423,7 @@ class ParticlWallet extends CoinServiceAPI { } }); txCountCallArgs.addAll({ - "${_id}_$j": address, + "${_id}_$j": addressString, }); } @@ -454,9 +435,10 @@ class ParticlWallet extends CoinServiceAPI { int count = counts["${_id}_$k"]!; if (count > 0) { final node = receivingNodes["${_id}_$k"]; + final address = node["address"] as isar_models.Address; // add address to array - addressArray.add(node["address"] as String); - iterationsAddressArray.add(node["address"] as String); + addressArray.add(address); + iterationsAddressArray.add(address.value); // set current index returningIndex = index + k; // reset counter @@ -518,13 +500,13 @@ class ParticlWallet extends CoinServiceAPI { final root = await compute(getBip32RootWrapper, Tuple2(mnemonic, _network)); - List p2pkhReceiveAddressArray = []; - List p2wpkhReceiveAddressArray = []; + List p2pkhReceiveAddressArray = []; + List p2wpkhReceiveAddressArray = []; int p2pkhReceiveIndex = -1; int p2wpkhReceiveIndex = -1; - List p2pkhChangeAddressArray = []; - List p2wpkhChangeAddressArray = []; + List p2pkhChangeAddressArray = []; + List p2wpkhChangeAddressArray = []; int p2pkhChangeIndex = -1; int p2wpkhChangeIndex = -1; @@ -554,25 +536,25 @@ class ParticlWallet extends CoinServiceAPI { [resultReceive44, resultReceive84, resultChange44, resultChange84]); p2pkhReceiveAddressArray = - (await resultReceive44)['addressArray'] as List; + (await resultReceive44)['addressArray'] as List; p2pkhReceiveIndex = (await resultReceive44)['index'] as int; p2pkhReceiveDerivations = (await resultReceive44)['derivations'] as Map>; p2wpkhReceiveAddressArray = - (await resultReceive84)['addressArray'] as List; + (await resultReceive84)['addressArray'] as List; p2wpkhReceiveIndex = (await resultReceive84)['index'] as int; p2wpkhReceiveDerivations = (await resultReceive84)['derivations'] as Map>; p2pkhChangeAddressArray = - (await resultChange44)['addressArray'] as List; + (await resultChange44)['addressArray'] as List; p2pkhChangeIndex = (await resultChange44)['index'] as int; p2pkhChangeDerivations = (await resultChange44)['derivations'] as Map>; p2wpkhChangeAddressArray = - (await resultChange84)['addressArray'] as List; + (await resultChange84)['addressArray'] as List; p2wpkhChangeIndex = (await resultChange84)['index'] as int; p2wpkhChangeDerivations = (await resultChange84)['derivations'] as Map>; @@ -611,14 +593,12 @@ class ParticlWallet extends CoinServiceAPI { final address = await _generateAddressForChain(0, 0, DerivePathType.bip44); p2pkhReceiveAddressArray.add(address); - p2pkhReceiveIndex = 0; } if (p2wpkhReceiveIndex == -1) { final address = await _generateAddressForChain(0, 0, DerivePathType.bip84); p2wpkhReceiveAddressArray.add(address); - p2wpkhReceiveIndex = 0; } // If restoring a wallet that never sent any funds with change, then set changeArray @@ -627,46 +607,25 @@ class ParticlWallet extends CoinServiceAPI { final address = await _generateAddressForChain(1, 0, DerivePathType.bip44); p2pkhChangeAddressArray.add(address); - p2pkhChangeIndex = 0; } if (p2wpkhChangeIndex == -1) { final address = await _generateAddressForChain(1, 0, DerivePathType.bip84); p2wpkhChangeAddressArray.add(address); - p2wpkhChangeIndex = 0; } - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: p2wpkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: p2wpkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: p2pkhReceiveAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: p2pkhChangeAddressArray); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: p2wpkhReceiveIndex); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: p2wpkhChangeIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2PKH', value: p2pkhChangeIndex); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: p2pkhReceiveIndex); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(p2wpkhReceiveAddressArray); + await isar.addresses.putAll(p2wpkhChangeAddressArray); + await isar.addresses.putAll(p2pkhReceiveAddressArray); + await isar.addresses.putAll(p2pkhChangeAddressArray); + }); + + await _updateUTXOs(); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); await DB.instance @@ -710,11 +669,14 @@ class ParticlWallet extends CoinServiceAPI { } if (!needsRefresh) { var allOwnAddresses = await _fetchAllOwnAddresses(); - List> allTxs = - await _fetchHistory(allOwnAddresses); - final txData = await transactionData; + List> allTxs = await _fetchHistory( + allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { - if (txData.findTransaction(transaction['tx_hash'] as String) == + final txid = transaction['tx_hash'] as String; + if ((await isar.transactions + .filter() + .txidMatches(txid) + .findFirst()) == null) { Logging.instance.log( " txid not found in address history already ${transaction['tx_hash']}", @@ -733,16 +695,25 @@ class ParticlWallet extends CoinServiceAPI { } } - Future getAllTxsToWatch( - TransactionData txData, - ) async { + Future getAllTxsToWatch() async { if (_hasCalledExit) return; - List unconfirmedTxnsToNotifyPending = []; - List unconfirmedTxnsToNotifyConfirmed = []; + List unconfirmedTxnsToNotifyPending = []; + List unconfirmedTxnsToNotifyConfirmed = []; - for (final chunk in txData.txChunks) { - for (final tx in chunk.transactions) { - if (tx.confirmedStatus) { + final currentChainHeight = await chainHeight; + + final txCount = await isar.transactions.count(); + + const paginateLimit = 50; + + for (int i = 0; i < txCount; i += paginateLimit) { + final transactions = await isar.transactions + .where() + .offset(i) + .limit(paginateLimit) + .findAll(); + for (final tx in transactions) { + if (tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { // get all transactions that were notified as pending but not as confirmed if (txTracker.wasNotifiedPending(tx.txid) && !txTracker.wasNotifiedConfirmed(tx.txid)) { @@ -759,31 +730,33 @@ class ParticlWallet extends CoinServiceAPI { // notify on unconfirmed transactions for (final tx in unconfirmedTxnsToNotifyPending) { - if (tx.txType == "Received") { + final confirmations = tx.getConfirmations(currentChainHeight); + + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Sending transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), - shouldWatchForUpdates: tx.confirmations < MINIMUM_CONFIRMATIONS, + shouldWatchForUpdates: confirmations < MINIMUM_CONFIRMATIONS, coinName: coin.name, txid: tx.txid, - confirmations: tx.confirmations, + confirmations: confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, )); await txTracker.addNotifiedPending(tx.txid); @@ -792,7 +765,7 @@ class ParticlWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { - if (tx.txType == "Received") { + if (tx.type == isar_models.TransactionType.incoming) { unawaited(NotificationApi.showNotification( title: "Incoming transaction confirmed", body: walletName, @@ -803,7 +776,7 @@ class ParticlWallet extends CoinServiceAPI { coinName: coin.name, )); await txTracker.addNotifiedConfirmed(tx.txid); - } else if (tx.txType == "Sent") { + } else if (tx.type == isar_models.TransactionType.outgoing) { unawaited(NotificationApi.showNotification( title: "Outgoing transaction confirmed", body: walletName, @@ -883,40 +856,30 @@ class ParticlWallet extends CoinServiceAPI { } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - final changeAddressForTransactions = - _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); - final currentReceivingAddressesForTransactions = - _checkCurrentReceivingAddressesForTransactions(); + await _checkCurrentReceivingAddressesForTransactions(); - final newTxData = _fetchTransactionData(); + final fetchFuture = _refreshTransactions(); + final utxosRefreshFuture = _updateUTXOs(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); - final newUtxoData = _fetchUtxoData(); final feeObj = _getFees(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.60, walletId)); - _transactionData = Future(() => newTxData); - GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.70, walletId)); _feeObject = Future(() => feeObj); - _utxoData = Future(() => newUtxoData); + + await utxosRefreshFuture; GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); - final allTxsToWatch = getAllTxsToWatch(await newTxData); - await Future.wait([ - newTxData, - changeAddressForTransactions, - currentReceivingAddressesForTransactions, - newUtxoData, - feeObj, - allTxsToWatch, - ]); + await fetchFuture; + await getAllTxsToWatch(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.90, walletId)); } @@ -998,9 +961,7 @@ class ParticlWallet extends CoinServiceAPI { // check for send all bool isSendAll = false; - final balance = - Format.decimalAmountToSatoshis(await availableBalance, coin); - if (satoshiAmount == balance) { + if (satoshiAmount == balance.spendable) { isSendAll = true; } @@ -1076,24 +1037,6 @@ class ParticlWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) async { - try { - final txData = await prepareSend( - address: toAddress, satoshiAmount: amount, args: args); - final txHash = await confirmSend(txData: txData); - return txHash; - } catch (e, s) { - Logging.instance - .log("Exception rethrown from send(): $e\n$s", level: LogLevel.Error); - rethrow; - } - } - @override Future testNetworkConnection() async { try { @@ -1166,6 +1109,22 @@ class ParticlWallet extends CoinServiceAPI { ]); } + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1176,66 +1135,55 @@ class ParticlWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - final data = - DB.instance.get(boxName: walletId, key: "latest_tx_model") - as TransactionData?; - if (data != null) { - _transactionData = Future(() => data); - } + await _isarInit(); } - @override - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - Future? _transactionData; - - TransactionData? cachedTxData; - // TODO make sure this copied implementation from bitcoin_wallet.dart applies for particl just as well--or import it // hack to add tx to txData before refresh completes // required based on current app architecture where we don't properly store // transactions locally in a good way @override Future updateSentCachedTxData(Map txData) async { - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final locale = Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - final String worthNow = Format.localizedStringAsFixed( - value: - ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale!); - - final tx = models.Transaction( - txid: txData["txid"] as String, - confirmedStatus: false, - timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, - txType: "Sent", - amount: txData["recipientAmt"] as int, - worthNow: worthNow, - worthAtBlockTimestamp: worthNow, - fees: txData["fee"] as int, - inputSize: 0, - outputSize: 0, - inputs: [], - outputs: [], - address: txData["address"] as String, - height: -1, - confirmations: 0, - ); - - if (cachedTxData == null) { - final data = await _fetchTransactionData(); - _transactionData = Future(() => data); - } else { - final transactions = cachedTxData!.getAllTransactions(); - transactions[tx.txid] = tx; - cachedTxData = models.TransactionData.fromMap(transactions); - _transactionData = Future(() => cachedTxData!); - } + // final priceData = + // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); + // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; + // final locale = + // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; + // final String worthNow = Format.localizedStringAsFixed( + // value: + // ((currentPrice * Decimal.fromInt(txData["recipientAmt"] as int)) / + // Decimal.fromInt(Constants.satsPerCoin(coin))) + // .toDecimal(scaleOnInfinitePrecision: 2), + // decimalPlaces: 2, + // locale: locale!); + // + // final tx = models.Transaction( + // txid: txData["txid"] as String, + // confirmedStatus: false, + // timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, + // txType: "Sent", + // amount: txData["recipientAmt"] as int, + // worthNow: worthNow, + // worthAtBlockTimestamp: worthNow, + // fees: txData["fee"] as int, + // inputSize: 0, + // outputSize: 0, + // inputs: [], + // outputs: [], + // address: txData["address"] as String, + // height: -1, + // confirmations: 0, + // ); + // + // if (cachedTxData == null) { + // final data = await _refreshTransactions(); + // _transactionData = Future(() => data); + // } else { + // final transactions = cachedTxData!.getAllTransactions(); + // transactions[tx.txid] = tx; + // cachedTxData = models.TransactionData.fromMap(transactions); + // _transactionData = Future(() => cachedTxData!); + // } } @override @@ -1265,7 +1213,7 @@ class ParticlWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late PriceAPI _priceAPI; + late Isar isar; ParticlWallet({ required String walletId, @@ -1274,7 +1222,6 @@ class ParticlWallet extends CoinServiceAPI { required ElectrumX client, required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, - PriceAPI? priceAPI, required SecureStorageInterface secureStore, }) { txTracker = tracker; @@ -1283,8 +1230,6 @@ class ParticlWallet extends CoinServiceAPI { _coin = coin; _electrumXClient = client; _cachedElectrumXClient = cachedClient; - - _priceAPI = priceAPI ?? PriceAPI(Client()); _secureStore = secureStore; } @@ -1341,38 +1286,44 @@ class ParticlWallet extends CoinServiceAPI { ); } - Future> _fetchAllOwnAddresses() async { - final List allAddresses = []; - final receivingAddresses = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH') as List; - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final receivingAddressesP2PKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2PKH') as List; - final changeAddressesP2PKH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - as List; - - for (var i = 0; i < receivingAddresses.length; i++) { - if (!allAddresses.contains(receivingAddresses[i])) { - allAddresses.add(receivingAddresses[i] as String); - } - } - for (var i = 0; i < changeAddresses.length; i++) { - if (!allAddresses.contains(changeAddresses[i])) { - allAddresses.add(changeAddresses[i] as String); - } - } - for (var i = 0; i < receivingAddressesP2PKH.length; i++) { - if (!allAddresses.contains(receivingAddressesP2PKH[i])) { - allAddresses.add(receivingAddressesP2PKH[i] as String); - } - } - for (var i = 0; i < changeAddressesP2PKH.length; i++) { - if (!allAddresses.contains(changeAddressesP2PKH[i])) { - allAddresses.add(changeAddressesP2PKH[i] as String); - } - } + Future> _fetchAllOwnAddresses() async { + final allAddresses = await isar.addresses + .filter() + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change) + .findAll(); + // final List allAddresses = []; + // final receivingAddresses = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH') as List; + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final receivingAddressesP2PKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2PKH') as List; + // final changeAddressesP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') + // as List; + // + // for (var i = 0; i < receivingAddresses.length; i++) { + // if (!allAddresses.contains(receivingAddresses[i])) { + // allAddresses.add(receivingAddresses[i] as String); + // } + // } + // for (var i = 0; i < changeAddresses.length; i++) { + // if (!allAddresses.contains(changeAddresses[i])) { + // allAddresses.add(changeAddresses[i] as String); + // } + // } + // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(receivingAddressesP2PKH[i])) { + // allAddresses.add(receivingAddressesP2PKH[i] as String); + // } + // } + // for (var i = 0; i < changeAddressesP2PKH.length; i++) { + // if (!allAddresses.contains(changeAddressesP2PKH[i])) { + // allAddresses.add(changeAddressesP2PKH[i] as String); + // } + // } return allAddresses; } @@ -1431,20 +1382,6 @@ class ParticlWallet extends CoinServiceAPI { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2WPKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "receivingIndexP2PKH", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndexP2PKH", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -1452,49 +1389,29 @@ class ParticlWallet extends CoinServiceAPI { value: {}); // Generate and add addresses to relevant arrays - await Future.wait([ + final initialAddresses = await Future.wait([ // P2WPKH - _generateAddressForChain(0, 0, DerivePathType.bip84).then( - (initialReceivingAddressP2WPKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2WPKH, 0, DerivePathType.bip84); - _currentReceivingAddress = - Future(() => initialReceivingAddressP2WPKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip84).then( - (initialChangeAddressP2WPKH) => _addToAddressesArrayForChain( - initialChangeAddressP2WPKH, - 1, - DerivePathType.bip84, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip84), + _generateAddressForChain(1, 0, DerivePathType.bip84), // P2PKH - _generateAddressForChain(0, 0, DerivePathType.bip44).then( - (initialReceivingAddressP2PKH) { - _addToAddressesArrayForChain( - initialReceivingAddressP2PKH, 0, DerivePathType.bip44); - _currentReceivingAddressP2PKH = - Future(() => initialReceivingAddressP2PKH); - }, - ), - _generateAddressForChain(1, 0, DerivePathType.bip44).then( - (initialChangeAddressP2PKH) => _addToAddressesArrayForChain( - initialChangeAddressP2PKH, - 1, - DerivePathType.bip44, - ), - ), + _generateAddressForChain(0, 0, DerivePathType.bip44), + _generateAddressForChain(1, 0, DerivePathType.bip44), ]); + await _isarInit(); + + await isar.writeTxn(() async { + await isar.addresses.putAll(initialAddresses); + }); + Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } /// Generates a new internal or external chain address for the wallet using a BIP84, BIP44, or BIP49 derivation path. /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! /// [index] - This can be any integer >= 0 - Future _generateAddressForChain( + Future _generateAddressForChain( int chain, int index, DerivePathType derivePathType, @@ -1512,13 +1429,16 @@ class ParticlWallet extends CoinServiceAPI { ); final data = PaymentData(pubkey: node.publicKey); String address; + isar_models.AddressType addrType; switch (derivePathType) { case DerivePathType.bip44: address = P2PKH(data: data, network: _network).data.address!; + addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip84: address = P2WPKH(network: _network, data: data).data.address!; + addrType = isar_models.AddressType.p2wpkh; break; } @@ -1531,88 +1451,44 @@ class ParticlWallet extends CoinServiceAPI { derivePathType: derivePathType, ); - return address; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain( - int chain, DerivePathType derivePathType) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain( - String address, int chain, DerivePathType derivePathType) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - switch (derivePathType) { - case DerivePathType.bip44: - chainArray += "P2PKH"; - break; - case DerivePathType.bip84: - chainArray += "P2WPKH"; - break; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = node.publicKey + ..type = addrType + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] /// and /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! Future _getCurrentAddressForChain( - int chain, DerivePathType derivePathType) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; + int chain, + DerivePathType derivePathType, + ) async { + final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; + + isar_models.AddressType type; + isar_models.Address? address; switch (derivePathType) { case DerivePathType.bip44: - arrayKey += "P2PKH"; + type = isar_models.AddressType.p2pkh; break; case DerivePathType.bip84: - arrayKey += "P2WPKH"; + type = isar_models.AddressType.p2wpkh; break; } - final internalChainArray = - DB.instance.get(boxName: walletId, key: arrayKey); - return internalChainArray.last as String; + address = await isar.addresses + .filter() + .typeEqualTo(type) + .subTypeEqualTo(subType) + .sortByDerivationIndexDesc() + .findFirst(); + return address!.value; } String _buildDerivationStorageKey({ @@ -1715,8 +1591,8 @@ class ParticlWallet extends CoinServiceAPI { await _secureStore.write(key: key, value: newReceiveDerivationsString); } - Future _fetchUtxoData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future _updateUTXOs() async { + final allAddresses = await _fetchAllOwnAddresses(); try { final fetchedUtxoList = >>[]; @@ -1728,7 +1604,8 @@ class ParticlWallet extends CoinServiceAPI { if (batches[batchNumber] == null) { batches[batchNumber] = {}; } - final scripthash = _convertToScriptHash(allAddresses[i], _network); + final scripthash = + _convertToScriptHash(allAddresses[i].value, _network); batches[batchNumber]!.addAll({ scripthash: [scripthash] }); @@ -1746,142 +1623,119 @@ class ParticlWallet extends CoinServiceAPI { } } } - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> outputArray = []; - int satoshiBalance = 0; + + final currentChainHeight = await chainHeight; + + final List outputArray = []; + int satoshiBalanceTotal = 0; int satoshiBalancePending = 0; + int satoshiBalanceSpendable = 0; + int satoshiBalanceBlocked = 0; for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - int value = fetchedUtxoList[i][j]["value"] as int; - satoshiBalance += value; - final txn = await cachedElectrumXClient.getTransaction( txHash: fetchedUtxoList[i][j]["tx_hash"] as String, verbose: true, coin: coin, ); - final Map utxo = {}; - final int confirmations = txn["confirmations"] as int? ?? 0; - final bool confirmed = confirmations >= MINIMUM_CONFIRMATIONS; - if (!confirmed) { - satoshiBalancePending += value; + final utxo = isar_models.UTXO(); + + utxo.txid = txn["txid"] as String; + utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; + utxo.value = fetchedUtxoList[i][j]["value"] as int; + utxo.name = ""; + + // todo check here if we should mark as blocked + utxo.isBlocked = false; + utxo.blockedReason = null; + + utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; + utxo.blockHash = txn["blockhash"] as String?; + utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; + utxo.blockTime = txn["blocktime"] as int?; + + satoshiBalanceTotal += utxo.value; + + if (utxo.isBlocked) { + satoshiBalanceBlocked += utxo.value; + } else { + if (utxo.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + satoshiBalanceSpendable += utxo.value; + } else { + satoshiBalancePending += utxo.value; + } } - utxo["txid"] = txn["txid"]; - utxo["vout"] = fetchedUtxoList[i][j]["tx_pos"]; - utxo["value"] = value; - - utxo["status"] = {}; - utxo["status"]["confirmed"] = confirmed; - utxo["status"]["confirmations"] = confirmations; - utxo["status"]["block_height"] = fetchedUtxoList[i][j]["height"]; - utxo["status"]["block_hash"] = txn["blockhash"]; - utxo["status"]["block_time"] = txn["blocktime"]; - - final fiatValue = ((Decimal.fromInt(value) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - utxo["rawWorth"] = fiatValue; - utxo["fiatWorth"] = fiatValue.toString(); outputArray.add(utxo); } } - Decimal currencyBalanceRaw = - ((Decimal.fromInt(satoshiBalance) * currentPrice) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2); - - final Map result = { - "total_user_currency": currencyBalanceRaw.toString(), - "total_sats": satoshiBalance, - "total_btc": (Decimal.fromInt(satoshiBalance) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal( - scaleOnInfinitePrecision: Constants.decimalPlacesForCoin(coin)) - .toString(), - "outputArray": outputArray, - "unconfirmed": satoshiBalancePending, - }; - - final dataModel = UtxoData.fromJson(result); - - final List allOutputs = dataModel.unspentOutputArray; Logging.instance - .log('Outputs fetched: $allOutputs', level: LogLevel.Info); - await _sortOutputs(allOutputs); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: dataModel); - await DB.instance.put( - boxName: walletId, - key: 'totalBalance', - value: dataModel.satoshiBalance); - return dataModel; + .log('Outputs fetched: $outputArray', level: LogLevel.Info); + + await isar.writeTxn(() async { + await isar.utxos.clear(); + await isar.utxos.putAll(outputArray); + }); + + // finally update balance + _balance = Balance( + coin: coin, + total: satoshiBalanceTotal, + spendable: satoshiBalanceSpendable, + blockedTotal: satoshiBalanceBlocked, + pendingSpendable: satoshiBalancePending, + ); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); - final latestTxModel = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model') - as models.UtxoData?; - - if (latestTxModel == null) { - final emptyModel = { - "total_user_currency": "0.00", - "total_sats": 0, - "total_btc": "0", - "outputArray": [] - }; - return UtxoData.fromJson(emptyModel); - } else { - Logging.instance - .log("Old output model located", level: LogLevel.Warning); - return latestTxModel; - } } } - /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - /// Now also checks for output labeling. - Future _sortOutputs(List utxos) async { - final blockedHashArray = - DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - as List?; - final List lst = []; - if (blockedHashArray != null) { - for (var hash in blockedHashArray) { - lst.add(hash as String); - } - } - final labels = - DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - {}; + @override + Balance get balance => _balance!; + Balance? _balance; - outputsList = []; - - for (var i = 0; i < utxos.length; i++) { - if (labels[utxos[i].txid] != null) { - utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - } else { - utxos[i].txName = 'Output #$i'; - } - - if (utxos[i].status.confirmed == false) { - outputsList.add(utxos[i]); - } else { - if (lst.contains(utxos[i].txid)) { - utxos[i].blocked = true; - outputsList.add(utxos[i]); - } else if (!lst.contains(utxos[i].txid)) { - outputsList.add(utxos[i]); - } - } - } - } + // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) + // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. + // /// Now also checks for output labeling. + // Future _sortOutputs(List utxos) async { + // final blockedHashArray = + // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') + // as List?; + // final List lst = []; + // if (blockedHashArray != null) { + // for (var hash in blockedHashArray) { + // lst.add(hash as String); + // } + // } + // final labels = + // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? + // {}; + // + // outputsList = []; + // + // for (var i = 0; i < utxos.length; i++) { + // if (labels[utxos[i].txid] != null) { + // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; + // } else { + // utxos[i].txName = 'Output #$i'; + // } + // + // if (utxos[i].status.confirmed == false) { + // outputsList.add(utxos[i]); + // } else { + // if (lst.contains(utxos[i].txid)) { + // utxos[i].blocked = true; + // outputsList.add(utxos[i]); + // } else if (!lst.contains(utxos[i].txid)) { + // outputsList.add(utxos[i]); + // } + // } + // } + // } Future getTxCount({required String address}) async { String? scripthash; @@ -1921,102 +1775,65 @@ class ParticlWallet extends CoinServiceAPI { } } - Future _checkReceivingAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkReceivingAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(0, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentReceiving = await _currentReceivingAddress; + + final int txCount = await getTxCount(address: currentReceiving.value); Logging.instance.log( - 'Number of txs for current receiving address $currentExternalAddr: $txCount', + 'Number of txs for current receiving address $currentReceiving: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the receiving index - await _incrementAddressIndexForChain(0, derivePathType); - - // Check the new receiving index - String indexKey = "receivingIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = currentReceiving.derivationIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, newReceivingIndex, derivePathType); + 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain( - newReceivingAddress, 0, derivePathType); - - // Set the new receiving address that the service - - switch (derivePathType) { - case DerivePathType.bip44: - _currentReceivingAddressP2PKH = Future(() => newReceivingAddress); - break; - case DerivePathType.bip84: - _currentReceivingAddress = Future(() => newReceivingAddress); - break; - } + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } } - Future _checkChangeAddressForTransactions( - DerivePathType derivePathType) async { + Future _checkChangeAddressForTransactions() async { try { - final String currentExternalAddr = - await _getCurrentAddressForChain(1, derivePathType); - final int txCount = await getTxCount(address: currentExternalAddr); + final currentChange = await _currentChangeAddress; + final int txCount = await getTxCount(address: currentChange.value); Logging.instance.log( - 'Number of txs for current change address $currentExternalAddr: $txCount', + 'Number of txs for current change address $currentChange: $txCount', level: LogLevel.Info); if (txCount >= 1) { // First increment the change index - await _incrementAddressIndexForChain(1, derivePathType); - - // Check the new change index - String indexKey = "changeIndex"; - switch (derivePathType) { - case DerivePathType.bip44: - indexKey += "P2PKH"; - break; - case DerivePathType.bip84: - indexKey += "P2WPKH"; - break; - } - final newChangeIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newChangeIndex = currentChange.derivationIndex + 1; // Use new index to derive a new change address - final newChangeAddress = - await _generateAddressForChain(1, newChangeIndex, derivePathType); + final newChangeAddress = await _generateAddressForChain( + 1, newChangeIndex, DerivePathType.bip84); - // Add that new receiving address to the array of change addresses - await _addToAddressesArrayForChain(newChangeAddress, 1, derivePathType); + // Add that new change address + await isar.writeTxn(() async { + await isar.addresses.put(newChangeAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( - "SocketException caught in _checkReceivingAddressForTransactions($derivePathType): $se\n$s", + "SocketException caught in _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $se\n$s", level: LogLevel.Error); return; } catch (e, s) { Logging.instance.log( - "Exception rethrown from _checkReceivingAddressForTransactions($derivePathType): $e\n$s", + "Exception rethrown from _checkReceivingAddressForTransactions(${DerivePathType.bip84}): $e\n$s", level: LogLevel.Error); rethrow; } @@ -2024,9 +1841,9 @@ class ParticlWallet extends CoinServiceAPI { Future _checkCurrentReceivingAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkReceivingAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkReceivingAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentReceivingAddressesForTransactions(): $e\n$s", @@ -2048,9 +1865,9 @@ class ParticlWallet extends CoinServiceAPI { Future _checkCurrentChangeAddressesForTransactions() async { try { - for (final type in DerivePathType.values) { - await _checkChangeAddressForTransactions(type); - } + // for (final type in DerivePathType.values) { + await _checkChangeAddressForTransactions(); + // } } catch (e, s) { Logging.instance.log( "Exception rethrown from _checkCurrentChangeAddressesForTransactions(): $e\n$s", @@ -2184,39 +2001,44 @@ class ParticlWallet extends CoinServiceAPI { return allTransactions; } - Future _fetchTransactionData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + Future _refreshTransactions() async { + final allAddresses = await _fetchAllOwnAddresses(); - final changeAddresses = DB.instance.get( - boxName: walletId, key: 'changeAddressesP2WPKH') as List; + // final changeAddresses = DB.instance.get( + // boxName: walletId, key: 'changeAddressesP2WPKH') as List; - final List> allTxHashes = - await _fetchHistory(allAddresses); + List changeAddresses = allAddresses + .where((e) => e.subType == isar_models.AddressSubType.change) + .map((e) => e.value) + .toList(); - final cachedTransactions = - DB.instance.get(boxName: walletId, key: 'latest_tx_model') - as TransactionData?; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; + final List> allTxHashes = await _fetchHistory( + allAddresses.map((e) => e.value).toList(growable: false)); - final unconfirmedCachedTransactions = - cachedTransactions?.getAllTransactions() ?? {}; - unconfirmedCachedTransactions - .removeWhere((key, value) => value.confirmedStatus); - - if (cachedTransactions != null) { - for (final tx in allTxHashes.toList(growable: false)) { - final txHeight = tx["height"] as int; - if (txHeight > 0 && - txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - allTxHashes.remove(tx); - } - } - } - } + // final cachedTransactions = + // DB.instance.get(boxName: walletId, key: 'latest_tx_model') + // as TransactionData?; + // int latestTxnBlockHeight = + // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") + // as int? ?? + // 0; + // + // final unconfirmedCachedTransactions = + // cachedTransactions?.getAllTransactions() ?? {}; + // unconfirmedCachedTransactions + // .removeWhere((key, value) => value.confirmedStatus); + // + // if (cachedTransactions != null) { + // for (final tx in allTxHashes.toList(growable: false)) { + // final txHeight = tx["height"] as int; + // if (txHeight > 0 && + // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { + // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { + // allTxHashes.remove(tx); + // } + // } + // } + // } Set hashes = {}; for (var element in allTxHashes) { @@ -2249,10 +2071,7 @@ class ParticlWallet extends CoinServiceAPI { Logging.instance.log("allTransactions length: ${allTransactions.length}", level: LogLevel.Info); - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + // final List> midSortedArray = []; Set vHashes = {}; for (final txObject in allTransactions) { @@ -2264,6 +2083,8 @@ class ParticlWallet extends CoinServiceAPI { } await fastFetch(vHashes.toList()); + final List txns = []; + for (final txObject in allTransactions) { List sendersArray = []; List recipientsArray = []; @@ -2315,7 +2136,7 @@ class ParticlWallet extends CoinServiceAPI { .log("output is private (RingCT)", level: LogLevel.Info); } else { // TODO detect staking - Logging.instance.log("output type not detected; output: ${output}", + Logging.instance.log("output type not detected; output: $output", level: LogLevel.Info); } } @@ -2324,7 +2145,7 @@ class ParticlWallet extends CoinServiceAPI { .log("recipientsArray: $recipientsArray", level: LogLevel.Info); final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)); + allAddresses.any((element) => sendersArray.contains(element.value)); Logging.instance .log("foundInSenders: $foundInSenders", level: LogLevel.Info); @@ -2353,7 +2174,7 @@ class ParticlWallet extends CoinServiceAPI { totalInput = inputAmtSentFromWallet; int totalOutput = 0; - Logging.instance.log("txObject: ${txObject}", level: LogLevel.Info); + Logging.instance.log("txObject: $txObject", level: LogLevel.Info); for (final output in txObject["vout"] as List) { // Particl has different tx types that need to be detected and handled here @@ -2373,7 +2194,7 @@ class ParticlWallet extends CoinServiceAPI { // change address from 'sent from' to the 'sent to' address txObject["address"] = address; } - } catch (s, e) { + } catch (s) { Logging.instance.log(s.toString(), level: LogLevel.Warning); } // Logging.instance.log("output is transparent", level: LogLevel.Info); @@ -2384,15 +2205,15 @@ class ParticlWallet extends CoinServiceAPI { Logging.instance.log( "output is blinded (CT); cannot parse output values", level: LogLevel.Info); - final ct_fee = output["ct_fee"]!; - final fee_value = (Decimal.parse(ct_fee.toString()) * + final ctFee = output["ct_fee"]!; + final feeValue = (Decimal.parse(ctFee.toString()) * Decimal.fromInt(Constants.satsPerCoin(coin))) .toBigInt() .toInt(); Logging.instance.log( - "ct_fee ${ct_fee} subtracted from inputAmtSentFromWallet ${inputAmtSentFromWallet}", + "ct_fee $ctFee subtracted from inputAmtSentFromWallet $inputAmtSentFromWallet", level: LogLevel.Info); - inputAmtSentFromWallet += fee_value; + inputAmtSentFromWallet += feeValue; } else if (output.containsKey('rangeproof') as bool) { // or valueCommitment or type: anon // TODO handle RingCT tx @@ -2401,7 +2222,7 @@ class ParticlWallet extends CoinServiceAPI { level: LogLevel.Info); } else { // TODO detect staking - Logging.instance.log("output type not detected; output: ${output}", + Logging.instance.log("output type not detected; output: $output", level: LogLevel.Info); } } @@ -2428,7 +2249,7 @@ class ParticlWallet extends CoinServiceAPI { outputAmtAddressedToWallet += value; } } - } catch (s, e) { + } catch (s) { Logging.instance.log(s.toString(), level: LogLevel.Info); } } @@ -2457,112 +2278,141 @@ class ParticlWallet extends CoinServiceAPI { // create final tx map midSortedTx["txid"] = txObject["txid"]; - midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; + midSortedTx["timestamp"] = txObject["blocktime"] ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); - if (foundInSenders) { - midSortedTx["txType"] = "Sent"; - midSortedTx["amount"] = inputAmtSentFromWallet; - final String worthNow = - ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - } else { - midSortedTx["txType"] = "Received"; - midSortedTx["amount"] = outputAmtAddressedToWallet; - final worthNow = - ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2) - .toStringAsFixed(2); - midSortedTx["worthNow"] = worthNow; - } - midSortedTx["aliens"] = []; - midSortedTx["fees"] = fee; midSortedTx["address"] = txObject["address"]; - midSortedTx["inputSize"] = txObject["vin"].length; - midSortedTx["outputSize"] = txObject["vout"].length; midSortedTx["inputs"] = txObject["vin"]; midSortedTx["outputs"] = txObject["vout"]; final int height = txObject["height"] as int; - midSortedTx["height"] = height; - if (height >= latestTxnBlockHeight) { - latestTxnBlockHeight = height; - } + // midSortedArray.add(midSortedTx); + final tx = isar_models.Transaction(); + tx.txid = midSortedTx["txid"] as String; + tx.timestamp = midSortedTx["timestamp"] as int; - midSortedArray.add(midSortedTx); - } - - // sort by date ---- //TODO not sure if needed - // shouldn't be any issues with a null timestamp but I got one at some point? - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // { - // final aT = a["timestamp"]; - // final bT = b["timestamp"]; - // - // if (aT == null && bT == null) { - // return 0; - // } else if (aT == null) { - // return -1; - // } else if (bT == null) { - // return 1; - // } else { - // return bT - aT; - // } - // }); - - // buildDateTimeChunks - 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); - } - }); + if (foundInSenders) { + tx.type = isar_models.TransactionType.outgoing; + tx.amount = inputAmtSentFromWallet; } else { - dateArray.add(txTimeArray[1]); - final chunk = { - "timestamp": txTimeArray[0], - "transactions": [txObject], - }; - result["dateTimeChunks"].add(chunk); + tx.type = isar_models.TransactionType.incoming; + tx.amount = outputAmtAddressedToWallet; } + + // TODO: other subtypes + tx.subType = isar_models.TransactionSubType.none; + + tx.fee = fee; + tx.address = midSortedTx["address"] as String; + + for (final json in midSortedTx["vin"] as List) { + bool isCoinBase = json['coinbase'] != null; + final input = isar_models.Input(); + input.txid = json['txid'] as String? ?? ""; + input.vout = json['vout'] as int? ?? -1; + input.scriptSig = json['scriptSig']?['hex'] as String?; + input.scriptSigAsm = json['scriptSig']?['asm'] as String?; + input.isCoinbase = + isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; + input.sequence = json['sequence'] as int?; + input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; + tx.inputs.add(input); + } + + for (final json in midSortedTx["vout"] as List) { + final output = isar_models.Output(); + output.scriptPubKey = json['scriptPubKey']?['hex'] as String?; + output.scriptPubKeyAsm = json['scriptPubKey']?['asm'] as String?; + output.scriptPubKeyType = json['scriptPubKey']?['type'] as String?; + output.scriptPubKeyAddress = + json["scriptPubKey"]?["addresses"]?[0] as String? ?? + json['scriptPubKey']?['type'] as String? ?? + ""; + output.value = Format.decimalAmountToSatoshis( + Decimal.tryParse(json["value"].toString()) ?? Decimal.zero, + coin, + ); + tx.outputs.add(output); + } + + tx.height = height; + + tx.isCancelled = false; + tx.slateId = null; + tx.otherData = null; + + txns.add(tx); } - final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); + await isar.writeTxn(() async { + await isar.transactions.putAll(txns); + }); - 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; + // + // // sort by date ---- //TODO not sure if needed + // // shouldn't be any issues with a null timestamp but I got one at some point? + // midSortedArray + // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); + // // { + // // final aT = a["timestamp"]; + // // final bT = b["timestamp"]; + // // + // // if (aT == null && bT == null) { + // // return 0; + // // } else if (aT == null) { + // // return -1; + // // } else if (bT == null) { + // // return 1; + // // } else { + // // return bT - aT; + // // } + // // }); + // + // // buildDateTimeChunks + // 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], + // }; + // result["dateTimeChunks"].add(chunk); + // } + // } + // + // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; + // transactionsMap + // .addAll(TransactionData.fromJson(result).getAllTransactions()); + // + // 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; } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2579,25 +2429,27 @@ class ParticlWallet extends CoinServiceAPI { String _recipientAddress, bool isSendAll, { int additionalOutputs = 0, - List? utxos, + List? utxos, }) async { Logging.instance .log("Starting coinSelection ----------", level: LogLevel.Info); - final List availableOutputs = utxos ?? outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final currentChainHeight = await chainHeight; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", level: LogLevel.Info); @@ -2624,7 +2476,7 @@ class ParticlWallet extends CoinServiceAPI { // Possible situation right here int satoshisBeingUsed = 0; int inputsBeingConsumed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (var i = 0; satoshisBeingUsed < satoshiAmountToSend && i < spendableOutputs.length; @@ -2742,7 +2594,7 @@ class ParticlWallet extends CoinServiceAPI { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize == feeForTwoOutputs) { // generate new change address if current change address has been used - await _checkChangeAddressForTransactions(DerivePathType.bip84); + await _checkChangeAddressForTransactions(); final String newChangeAddress = await _getCurrentAddressForChain(1, DerivePathType.bip84); @@ -2912,7 +2764,7 @@ class ParticlWallet extends CoinServiceAPI { } Future> fetchBuildTxData( - List utxosToUse, + List utxosToUse, ) async { // return data Map results = {}; @@ -3079,7 +2931,7 @@ class ParticlWallet extends CoinServiceAPI { /// Builds and signs a transaction Future> buildTransaction({ - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required List recipients, required List satoshiAmounts, @@ -3444,22 +3296,23 @@ class ParticlWallet extends CoinServiceAPI { @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { - final available = - Format.decimalAmountToSatoshis(await availableBalance, coin); + final available = balance.spendable; if (available == satoshiAmount) { - return satoshiAmount - sweepAllEstimate(feeRate); + return satoshiAmount - (await sweepAllEstimate(feeRate)); } else if (satoshiAmount <= 0 || satoshiAmount > available) { return roughFeeEstimate(1, 2, feeRate); } int runningBalance = 0; int inputCount = 0; - for (final output in outputsList) { - runningBalance += output.value; - inputCount++; - if (runningBalance > satoshiAmount) { - break; + for (final output in (await utxos)) { + if (!output.isBlocked) { + runningBalance += output.value; + inputCount++; + if (runningBalance > satoshiAmount) { + break; + } } } @@ -3490,11 +3343,12 @@ class ParticlWallet extends CoinServiceAPI { (feeRatePerKB / 1000).ceil(); } - int sweepAllEstimate(int feeRate) { + Future sweepAllEstimate(int feeRate) async { int available = 0; int inputCount = 0; - for (final output in outputsList) { - if (output.status.confirmed) { + for (final output in (await utxos)) { + if (!output.isBlocked && + output.isConfirmed(storedChainHeight, MINIMUM_CONFIRMATIONS)) { available += output.value; inputCount++; } @@ -3509,23 +3363,18 @@ class ParticlWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - await _incrementAddressIndexForChain( - 0, DerivePathType.bip84); // First increment the receiving index - final newReceivingIndex = DB.instance.get( - boxName: walletId, - key: 'receivingIndexP2WPKH') as int; // Check the new receiving index + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving.derivationIndex + 1; + + // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain( - 0, - newReceivingIndex, - DerivePathType - .bip84); // Use new index to derive a new receiving address - await _addToAddressesArrayForChain( - newReceivingAddress, - 0, - DerivePathType - .bip84); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddress = Future(() => - newReceivingAddress); // Set the new receiving address that the service + 0, newReceivingIndex, DerivePathType.bip84); + + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { From c83ec074de0e1b3b000d7148064e539c419d38bb Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:09:08 -0600 Subject: [PATCH 101/192] migrate monero_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- lib/services/coins/monero/monero_wallet.dart | 491 ++++++++----------- 1 file changed, 212 insertions(+), 279 deletions(-) diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 7b073e63f..017e5de81 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -21,13 +21,13 @@ import 'package:flutter_libmonero/core/key_service.dart'; import 'package:flutter_libmonero/core/wallet_creation_service.dart'; import 'package:flutter_libmonero/monero/monero.dart'; import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart'; import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; @@ -35,7 +35,6 @@ import 'package:stackwallet/services/event_bus/events/global/updated_in_backgrou 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/node_service.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -51,10 +50,11 @@ const int MINIMUM_CONFIRMATIONS = 10; class MoneroWallet extends CoinServiceAPI { final String _walletId; final Coin _coin; - final PriceAPI _priceAPI; final SecureStorageInterface _secureStorage; final Prefs _prefs; + late Isar isar; + String _walletName; bool _shouldAutoSync = false; bool _isConnected = false; @@ -68,9 +68,9 @@ class MoneroWallet extends CoinServiceAPI { WalletCreationService? _walletCreationService; Timer? _autoSaveTimer; - Future? _currentReceivingAddress; + Future get _currentReceivingAddress => + isar.addresses.where().sortByDerivationIndexDesc().findFirst(); Future? _feeObject; - Future? _transactionData; Mutex prepareSendMutex = Mutex(); Mutex estimateFeeMutex = Mutex(); @@ -80,15 +80,29 @@ class MoneroWallet extends CoinServiceAPI { required String walletName, required Coin coin, required SecureStorageInterface secureStorage, - PriceAPI? priceAPI, Prefs? prefs, }) : _walletId = walletId, _walletName = walletName, _coin = coin, - _priceAPI = priceAPI ?? PriceAPI(Client()), _secureStorage = secureStorage, _prefs = prefs ?? Prefs.instance; + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override bool get isFavorite { try { @@ -139,23 +153,6 @@ class MoneroWallet extends CoinServiceAPI { @override set walletName(String newName) => _walletName = newName; - @override - // not used for monero - Future> get allOwnAddresses async => []; - - @override - Future get availableBalance async { - int runningBalance = 0; - for (final entry in walletBase!.balance!.entries) { - runningBalance += entry.value.unlockedBalance; - } - return Format.satoshisToAmount(runningBalance, coin: coin); - } - - @override - // not used - Future get balanceMinusMaxFee => throw UnimplementedError(); - @override Coin get coin => _coin; @@ -184,8 +181,8 @@ class MoneroWallet extends CoinServiceAPI { } @override - Future get currentReceivingAddress => - _currentReceivingAddress ??= _getCurrentAddressForChain(0); + Future get currentReceivingAddress async => + (await _currentReceivingAddress)!.value; @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { @@ -225,6 +222,7 @@ class MoneroWallet extends CoinServiceAPI { _autoSaveTimer?.cancel(); await walletBase?.save(prioritySave: true); walletBase?.close(); + await isar.close(); } } @@ -244,22 +242,20 @@ class MoneroWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - const String indexKey = "receivingIndex"; - // First increment the receiving index - await _incrementAddressIndexForChain(0); - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving!.derivationIndex + 1; // Use new index to derive a new receiving address - final newReceivingAddress = - await _generateAddressForChain(0, newReceivingIndex); + final newReceivingAddress = await _generateAddressForChain( + 0, + newReceivingIndex, + ); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain(newReceivingAddress, 0); - - // Set the new receiving address that the service - - _currentReceivingAddress = Future(() => newReceivingAddress); + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { @@ -290,6 +286,7 @@ class MoneroWallet extends CoinServiceAPI { keysStorage = KeyService(_secureStorage); await _prefs.init(); + await _isarInit(); // final data = // DB.instance.get(boxName: walletId, key: "latest_tx_model") // as TransactionData?; @@ -314,14 +311,14 @@ class MoneroWallet extends CoinServiceAPI { ); // Wallet already exists, triggers for a returning user - String indexKey = "receivingIndex"; - final curIndex = - await DB.instance.get(boxName: walletId, key: indexKey) as int; - // Use new index to derive a new receiving address - final newReceivingAddress = await _generateAddressForChain(0, curIndex); - Logging.instance.log("xmr address in init existing: $newReceivingAddress", - level: LogLevel.Info); - _currentReceivingAddress = Future(() => newReceivingAddress); + // String indexKey = "receivingIndex"; + // final curIndex = + // await DB.instance.get(boxName: walletId, key: indexKey) as int; + // // Use new index to derive a new receiving address + // final newReceivingAddress = await _generateAddressForChain(0, curIndex); + // Logging.instance.log("xmr address in init existing: $newReceivingAddress", + // level: LogLevel.Info); + // _currentReceivingAddress = Future(() => newReceivingAddress); } @override @@ -424,18 +421,12 @@ class MoneroWallet extends CoinServiceAPI { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); + await _isarInit(); - await _addToAddressesArrayForChain(initialReceivingAddress, 0); - // await _addToAddressesArrayForChain(initialChangeAddress, 1); + await isar.writeTxn(() async { + await isar.addresses.put(initialReceivingAddress); + }); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddresses', - value: [initialReceivingAddress]); - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); - - _currentReceivingAddress = Future(() => initialReceivingAddress); walletBase?.close(); Logging.instance .log("initializeNew for $walletName $walletId", level: LogLevel.Info); @@ -462,10 +453,6 @@ class MoneroWallet extends CoinServiceAPI { return data; } - @override - // not used in xmr - Future get pendingBalance => throw UnimplementedError(); - @override Future> prepareSend({ required String address, @@ -493,16 +480,15 @@ class MoneroWallet extends CoinServiceAPI { try { // check for send all bool isSendAll = false; - final balance = await availableBalance; - final satInDecimal = - Format.satoshisToAmount(satoshiAmount, coin: coin); - if (satInDecimal == balance) { + final balance = await _availableBalance; + if (satoshiAmount == balance) { isSendAll = true; } Logging.instance .log("$toAddress $satoshiAmount $args", level: LogLevel.Info); - String amountToSend = satInDecimal - .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); + String amountToSend = + Format.satoshisToAmount(satoshiAmount, coin: coin) + .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); Logging.instance .log("$satoshiAmount $amountToSend", level: LogLevel.Info); @@ -702,22 +688,10 @@ class MoneroWallet extends CoinServiceAPI { ), ); - final newTxData = await _fetchTransactionData(); - _transactionData = Future(() => newTxData); + await _refreshTransactions(); + await _updateBalance(); await _checkCurrentReceivingAddressesForTransactions(); - String indexKey = "receivingIndex"; - final curIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; - // Use new index to derive a new receiving address - try { - final newReceivingAddress = await _generateAddressForChain(0, curIndex); - _currentReceivingAddress = Future(() => newReceivingAddress); - } catch (e, s) { - Logging.instance.log( - "Failed to call _generateAddressForChain(0, $curIndex): $e\n$s", - level: LogLevel.Error); - } if (walletBase?.syncStatus is SyncedSyncStatus) { refreshMutex = false; @@ -731,16 +705,6 @@ class MoneroWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) { - // not used for xmr - throw UnimplementedError(); - } - @override Future testNetworkConnection() async { return await walletBase?.isConnected() ?? false; @@ -807,8 +771,31 @@ class MoneroWallet extends CoinServiceAPI { ) as int? ?? 0; - @override - Future get totalBalance async { + Future _updateBalance() async { + final total = await _totalBalance; + final available = await _availableBalance; + _balance = Balance( + coin: coin, + total: total, + spendable: available, + blockedTotal: 0, + pendingSpendable: total - available, + ); + } + + Future get _availableBalance async { + try { + int runningBalance = 0; + for (final entry in walletBase!.balance!.entries) { + runningBalance += entry.value.unlockedBalance; + } + return runningBalance; + } catch (_) { + return 0; + } + } + + Future get _totalBalance async { try { final balanceEntries = walletBase?.balance?.entries; if (balanceEntries != null) { @@ -817,7 +804,7 @@ class MoneroWallet extends CoinServiceAPI { bal = bal + element.value.fullBalance; } await _updateCachedBalance(bal); - return Format.satoshisToAmount(bal, coin: coin); + return bal; } else { final transactions = walletBase!.transactionHistory!.transactions; int transactionBalance = 0; @@ -830,21 +817,13 @@ class MoneroWallet extends CoinServiceAPI { } await _updateCachedBalance(transactionBalance); - return Format.satoshisToAmount(transactionBalance, coin: coin); + return transactionBalance; } } catch (_) { - return Format.satoshisToAmount(_getCachedBalance(), coin: coin); + return _getCachedBalance(); } } - @override - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - - @override - // not used for xmr - Future> get unspentOutputs => throw UnimplementedError(); - @override Future updateNode(bool shouldRefresh) async { final node = await _getCurrentNode(); @@ -873,66 +852,21 @@ class MoneroWallet extends CoinServiceAPI { @override String get walletId => _walletId; - /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] - /// and - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _getCurrentAddressForChain(int chain) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; - final internalChainArray = (DB.instance - .get(boxName: walletId, key: arrayKey)) as List; - return internalChainArray.last as String; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain(int chain) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - Future _generateAddressForChain(int chain, int index) async { + Future _generateAddressForChain( + int chain, + int index, + ) async { // String address = walletBase!.getTransactionAddress(chain, index); - return address; - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain(String address, int chain) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = [] + ..type = isar_models.AddressType.cryptonote + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } Future _getFees() async { @@ -947,7 +881,7 @@ class MoneroWallet extends CoinServiceAPI { ); } - Future _fetchTransactionData() async { + Future _refreshTransactions() async { await walletBase!.updateTransactions(); final transactions = walletBase?.transactionHistory!.transactions; @@ -965,123 +899,112 @@ class MoneroWallet extends CoinServiceAPI { // // final Set cachedTxids = Set.from(txidsList); - // sort thing stuff - // change to get Monero price - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + final List txns = []; if (transactions != null) { for (var tx in transactions.entries) { // cachedTxids.add(tx.value.id); - Logging.instance.log( - "${tx.value.accountIndex} ${tx.value.addressIndex} ${tx.value.amount} ${tx.value.date} " - "${tx.value.direction} ${tx.value.fee} ${tx.value.height} ${tx.value.id} ${tx.value.isPending} ${tx.value.key} " - "${tx.value.recipientAddress}, ${tx.value.additionalInfo} con:${tx.value.confirmations}" - " ${tx.value.keyIndex}", - level: LogLevel.Info); - final worthNow = (currentPrice * - Format.satoshisToAmount( - tx.value.amount!, - coin: coin, - )) - .toStringAsFixed(2); - Map midSortedTx = {}; - // // create final tx map - midSortedTx["txid"] = tx.value.id; - midSortedTx["confirmed_status"] = !tx.value.isPending && - tx.value.confirmations! >= MINIMUM_CONFIRMATIONS; - midSortedTx["confirmations"] = tx.value.confirmations ?? 0; - midSortedTx["timestamp"] = - (tx.value.date.millisecondsSinceEpoch ~/ 1000); - midSortedTx["txType"] = - tx.value.direction == TransactionDirection.incoming - ? "Received" - : "Sent"; - midSortedTx["amount"] = tx.value.amount; - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - midSortedTx["fees"] = tx.value.fee; + // Logging.instance.log( + // "${tx.value.accountIndex} ${tx.value.addressIndex} ${tx.value.amount} ${tx.value.date} " + // "${tx.value.direction} ${tx.value.fee} ${tx.value.height} ${tx.value.id} ${tx.value.isPending} ${tx.value.key} " + // "${tx.value.recipientAddress}, ${tx.value.additionalInfo} con:${tx.value.confirmations}" + // " ${tx.value.keyIndex}", + // level: LogLevel.Info); + + final int txHeight = tx.value.height ?? 0; + final txn = isar_models.Transaction(); + txn.txid = tx.value.id; + txn.timestamp = (tx.value.date.millisecondsSinceEpoch ~/ 1000); + if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; - midSortedTx["address"] = walletBase?.getTransactionAddress( - addressInfo!['accountIndex'] as int, - addressInfo['addressIndex'] as int, - ); + txn.address = walletBase?.getTransactionAddress( + addressInfo!['accountIndex'] as int, + addressInfo['addressIndex'] as int, + ) ?? + ""; + + txn.type = isar_models.TransactionType.incoming; } else { - midSortedTx["address"] = ""; + txn.address = ""; + txn.type = isar_models.TransactionType.outgoing; } - final int txHeight = tx.value.height ?? 0; - midSortedTx["height"] = txHeight; - // if (txHeight >= latestTxnBlockHeight) { - // latestTxnBlockHeight = txHeight; - // } + txn.amount = tx.value.amount ?? 0; - midSortedTx["aliens"] = []; - midSortedTx["inputSize"] = 0; - midSortedTx["outputSize"] = 0; - midSortedTx["inputs"] = []; - midSortedTx["outputs"] = []; - midSortedArray.add(midSortedTx); + // TODO: other subtypes + txn.subType = isar_models.TransactionSubType.none; + + txn.fee = tx.value.fee ?? 0; + + txn.height = txHeight; + + txn.isCancelled = false; + txn.slateId = null; + txn.otherData = null; + + txns.add(txn); } } - // sort by date ---- - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - Logging.instance.log(midSortedArray, level: LogLevel.Info); + await isar.writeTxn(() async { + await isar.transactions.putAll(txns); + }); - // buildDateTimeChunks - 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], - }; - result["dateTimeChunks"].add(chunk); - } - } - - // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - final Map transactionsMap = {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); - - 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); - // await DB.instance.put( - // boxName: walletId, - // key: 'cachedTxids', - // value: cachedTxids.toList(growable: false)); - - return txModel; + // // sort by date ---- + // midSortedArray + // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); + // Logging.instance.log(midSortedArray, level: LogLevel.Info); + // + // // buildDateTimeChunks + // 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], + // }; + // result["dateTimeChunks"].add(chunk); + // } + // } + // + // // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; + // final Map transactionsMap = {}; + // transactionsMap + // .addAll(TransactionData.fromJson(result).getAllTransactions()); + // + // 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); + // // await DB.instance.put( + // // boxName: walletId, + // // key: 'cachedTxids', + // // value: cachedTxids.toList(growable: false)); + // + // return txModel; } Future _pathForWalletDir({ @@ -1164,12 +1087,12 @@ class MoneroWallet extends CoinServiceAPI { } Future _refreshTxData() async { - final txnData = await _fetchTransactionData(); - final count = txnData.getAllTransactions().length; + await _refreshTransactions(); + final count = await isar.transactions.count(); if (count > _txCount) { _txCount = count; - _transactionData = Future(() => txnData); + await _updateBalance(); GlobalEventBus.instance.fire( UpdatedInBackgroundEvent( "New transaction data found in $walletId $walletName!", @@ -1293,23 +1216,21 @@ class MoneroWallet extends CoinServiceAPI { } // Check the new receiving index - String indexKey = "receivingIndex"; - final curIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final currentReceiving = await _currentReceivingAddress; + final curIndex = currentReceiving!.derivationIndex; + if (highestIndex >= curIndex) { // First increment the receiving index - await _incrementAddressIndexForChain(0); - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = curIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain(0, newReceivingIndex); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain(newReceivingAddress, 0); - - _currentReceivingAddress = Future(() => newReceivingAddress); + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1338,4 +1259,16 @@ class MoneroWallet extends CoinServiceAPI { @override // TODO: implement storedChainHeight int get storedChainHeight => throw UnimplementedError(); + + @override + Balance get balance => _balance!; + Balance? _balance; + + @override + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); + + @override + // TODO: implement utxos + Future> get utxos => throw UnimplementedError(); } From a989a26f6252ed8a9ea12ada3691df9e072b2c5c Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:09:18 -0600 Subject: [PATCH 102/192] migrate wownero_wallet.dart to isar transactions, addresses, and utxos, as well as the cleaner balance model --- .../coins/wownero/wownero_wallet.dart | 543 ++++++++---------- 1 file changed, 254 insertions(+), 289 deletions(-) diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index fad3fc8ba..43c04d80a 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -15,7 +15,6 @@ import 'package:cw_core/wallet_type.dart'; import 'package:cw_wownero/api/exceptions/creation_transaction_exception.dart'; import 'package:cw_wownero/api/wallet.dart'; import 'package:cw_wownero/pending_wownero_transaction.dart'; -import 'package:cw_wownero/wownero_amount_format.dart'; import 'package:cw_wownero/wownero_wallet.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; @@ -24,13 +23,13 @@ import 'package:flutter_libmonero/core/wallet_creation_service.dart'; import 'package:flutter_libmonero/view_model/send/output.dart' as wownero_output; import 'package:flutter_libmonero/wownero/wownero.dart'; -import 'package:http/http.dart'; +import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart'; import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; @@ -38,7 +37,6 @@ import 'package:stackwallet/services/event_bus/events/global/updated_in_backgrou 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/node_service.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -54,10 +52,11 @@ const int MINIMUM_CONFIRMATIONS = 10; class WowneroWallet extends CoinServiceAPI { final String _walletId; final Coin _coin; - final PriceAPI _priceAPI; final SecureStorageInterface _secureStorage; final Prefs _prefs; + late Isar isar; + String _walletName; bool _shouldAutoSync = false; bool _isConnected = false; @@ -71,9 +70,9 @@ class WowneroWallet extends CoinServiceAPI { WalletCreationService? _walletCreationService; Timer? _autoSaveTimer; - Future? _currentReceivingAddress; + Future get _currentReceivingAddress => + isar.addresses.where().sortByDerivationIndexDesc().findFirst(); Future? _feeObject; - Future? _transactionData; Mutex prepareSendMutex = Mutex(); Mutex estimateFeeMutex = Mutex(); @@ -83,15 +82,29 @@ class WowneroWallet extends CoinServiceAPI { required String walletName, required Coin coin, required SecureStorageInterface secureStorage, - PriceAPI? priceAPI, Prefs? prefs, }) : _walletId = walletId, _walletName = walletName, _coin = coin, - _priceAPI = priceAPI ?? PriceAPI(Client()), _secureStorage = secureStorage, _prefs = prefs ?? Prefs.instance; + Future _isarInit() async { + isar = await Isar.open( + [ + isar_models.TransactionSchema, + isar_models.TransactionNoteSchema, + isar_models.InputSchema, + isar_models.OutputSchema, + isar_models.UTXOSchema, + isar_models.AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + } + @override bool get isFavorite { try { @@ -142,23 +155,6 @@ class WowneroWallet extends CoinServiceAPI { @override set walletName(String newName) => _walletName = newName; - @override - // not really used for wownero - Future> get allOwnAddresses async => []; - - @override - Future get availableBalance async { - int runningBalance = 0; - for (final entry in walletBase!.balance!.entries) { - runningBalance += entry.value.unlockedBalance; - } - return Format.satoshisToAmount(runningBalance, coin: coin); - } - - @override - // not used - Future get balanceMinusMaxFee => throw UnimplementedError(); - @override Coin get coin => _coin; @@ -187,8 +183,8 @@ class WowneroWallet extends CoinServiceAPI { } @override - Future get currentReceivingAddress => - _currentReceivingAddress ??= _getCurrentAddressForChain(0); + Future get currentReceivingAddress async => + (await _currentReceivingAddress)!.value; @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { @@ -249,6 +245,7 @@ class WowneroWallet extends CoinServiceAPI { _autoSaveTimer?.cancel(); await walletBase?.save(prioritySave: true); walletBase?.close(); + await isar.close(); } } @@ -268,22 +265,20 @@ class WowneroWallet extends CoinServiceAPI { @override Future generateNewAddress() async { try { - const String indexKey = "receivingIndex"; - // First increment the receiving index - await _incrementAddressIndexForChain(0); - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final currentReceiving = await _currentReceivingAddress; + + final newReceivingIndex = currentReceiving!.derivationIndex + 1; // Use new index to derive a new receiving address - final newReceivingAddress = - await _generateAddressForChain(0, newReceivingIndex); + final newReceivingAddress = await _generateAddressForChain( + 0, + newReceivingIndex, + ); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain(newReceivingAddress, 0); - - // Set the new receiving address that the service - - _currentReceivingAddress = Future(() => newReceivingAddress); + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); return true; } catch (e, s) { @@ -315,6 +310,7 @@ class WowneroWallet extends CoinServiceAPI { keysStorage = KeyService(_secureStorage); await _prefs.init(); + await _isarInit(); // final data = // DB.instance.get(boxName: walletId, key: "latest_tx_model") // as TransactionData?; @@ -336,16 +332,15 @@ class WowneroWallet extends CoinServiceAPI { level: LogLevel.Info, ); // Wallet already exists, triggers for a returning user - - String indexKey = "receivingIndex"; - final curIndex = - await DB.instance.get(boxName: walletId, key: indexKey) as int; - // Use new index to derive a new receiving address - final newReceivingAddress = await _generateAddressForChain(0, curIndex); - Logging.instance.log( - "wownero address in init existing: $newReceivingAddress", - level: LogLevel.Info); - _currentReceivingAddress = Future(() => newReceivingAddress); + // + // String indexKey = "receivingIndex"; + // final curIndex = + // await DB.instance.get(boxName: walletId, key: indexKey) as int; + // // Use new index to derive a new receiving address + // final newReceivingAddress = await _generateAddressForChain(0, curIndex); + // Logging.instance.log( + // "wownero address in init existing: $newReceivingAddress", + // level: LogLevel.Info); } @override @@ -430,16 +425,6 @@ class WowneroWallet extends CoinServiceAPI { await DB.instance .put(boxName: walletId, key: "id", value: _walletId); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndex", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -451,18 +436,13 @@ class WowneroWallet extends CoinServiceAPI { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); + await _isarInit(); - await _addToAddressesArrayForChain(initialReceivingAddress, 0); - // await _addToAddressesArrayForChain(initialChangeAddress, 1); + await isar.writeTxn(() async { + await isar.addresses.put(initialReceivingAddress); + }); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddresses', - value: [initialReceivingAddress]); - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); walletBase?.close(); - _currentReceivingAddress = Future(() => initialReceivingAddress); Logging.instance .log("initializeNew for $walletName $walletId", level: LogLevel.Info); @@ -489,10 +469,6 @@ class WowneroWallet extends CoinServiceAPI { return data; } - @override - // not used in wow - Future get pendingBalance => throw UnimplementedError(); - @override Future> prepareSend({ required String address, @@ -519,17 +495,15 @@ class WowneroWallet extends CoinServiceAPI { try { // check for send all bool isSendAll = false; - final balance = await availableBalance; - final satInDecimal = - Format.satoshisToAmount(satoshiAmount, coin: coin); - - if (satInDecimal == balance) { + final balance = await _availableBalance; + if (satoshiAmount == balance) { isSendAll = true; } Logging.instance .log("$address $satoshiAmount $args", level: LogLevel.Info); - String amountToSend = satInDecimal - .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); + String amountToSend = + Format.satoshisToAmount(satoshiAmount, coin: coin) + .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); Logging.instance .log("$satoshiAmount $amountToSend", level: LogLevel.Info); @@ -733,22 +707,10 @@ class WowneroWallet extends CoinServiceAPI { ), ); - final newTxData = await _fetchTransactionData(); - _transactionData = Future(() => newTxData); + await _refreshTransactions(); + await _updateBalance(); await _checkCurrentReceivingAddressesForTransactions(); - String indexKey = "receivingIndex"; - final curIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; - // Use new index to derive a new receiving address - try { - final newReceivingAddress = await _generateAddressForChain(0, curIndex); - _currentReceivingAddress = Future(() => newReceivingAddress); - } catch (e, s) { - Logging.instance.log( - "Failed to call _generateAddressForChain(0, $curIndex): $e\n$s", - level: LogLevel.Error); - } if (walletBase?.syncStatus is SyncedSyncStatus) { refreshMutex = false; @@ -762,16 +724,6 @@ class WowneroWallet extends CoinServiceAPI { } } - @override - Future send({ - required String toAddress, - required int amount, - Map args = const {}, - }) { - // not used for xmr - throw UnimplementedError(); - } - @override Future testNetworkConnection() async { return await walletBase?.isConnected() ?? false; @@ -835,8 +787,31 @@ class WowneroWallet extends CoinServiceAPI { ) as int? ?? 0; - @override - Future get totalBalance async { + Future _updateBalance() async { + final total = await _totalBalance; + final available = await _availableBalance; + _balance = Balance( + coin: coin, + total: total, + spendable: available, + blockedTotal: 0, + pendingSpendable: total - available, + ); + } + + Future get _availableBalance async { + try { + int runningBalance = 0; + for (final entry in walletBase!.balance!.entries) { + runningBalance += entry.value.unlockedBalance; + } + return runningBalance; + } catch (_) { + return 0; + } + } + + Future get _totalBalance async { try { final balanceEntries = walletBase?.balance?.entries; if (balanceEntries != null) { @@ -845,7 +820,7 @@ class WowneroWallet extends CoinServiceAPI { bal = bal + element.value.fullBalance; } await _updateCachedBalance(bal); - return Format.satoshisToAmount(bal, coin: coin); + return bal; } else { final transactions = walletBase!.transactionHistory!.transactions; int transactionBalance = 0; @@ -858,21 +833,13 @@ class WowneroWallet extends CoinServiceAPI { } await _updateCachedBalance(transactionBalance); - return Format.satoshisToAmount(transactionBalance, coin: coin); + return transactionBalance; } } catch (_) { - return Format.satoshisToAmount(_getCachedBalance(), coin: coin); + return _getCachedBalance(); } } - @override - Future get transactionData => - _transactionData ??= _fetchTransactionData(); - - @override - // not used for xmr - Future> get unspentOutputs => throw UnimplementedError(); - @override Future updateNode(bool shouldRefresh) async { final node = await _getCurrentNode(); @@ -901,66 +868,21 @@ class WowneroWallet extends CoinServiceAPI { @override String get walletId => _walletId; - /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] - /// and - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _getCurrentAddressForChain(int chain) async { - // Here, we assume that chain == 1 if it isn't 0 - String arrayKey = chain == 0 ? "receivingAddresses" : "changeAddresses"; - final internalChainArray = (DB.instance - .get(boxName: walletId, key: arrayKey)) as List; - return internalChainArray.last as String; - } - - /// Increases the index for either the internal or external chain, depending on [chain]. - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _incrementAddressIndexForChain(int chain) async { - // Here we assume chain == 1 if it isn't 0 - String indexKey = chain == 0 ? "receivingIndex" : "changeIndex"; - - final newIndex = - (DB.instance.get(boxName: walletId, key: indexKey)) + 1; - await DB.instance - .put(boxName: walletId, key: indexKey, value: newIndex); - } - - Future _generateAddressForChain(int chain, int index) async { + Future _generateAddressForChain( + int chain, + int index, + ) async { // String address = walletBase!.getTransactionAddress(chain, index); - return address; - } - - /// Adds [address] to the relevant chain's address array, which is determined by [chain]. - /// [address] - Expects a standard native segwit address - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _addToAddressesArrayForChain(String address, int chain) async { - String chainArray = ''; - if (chain == 0) { - chainArray = 'receivingAddresses'; - } else { - chainArray = 'changeAddresses'; - } - - final addressArray = - DB.instance.get(boxName: walletId, key: chainArray); - if (addressArray == null) { - Logging.instance.log( - 'Attempting to add the following to $chainArray array for chain $chain:${[ - address - ]}', - level: LogLevel.Info); - await DB.instance - .put(boxName: walletId, key: chainArray, value: [address]); - } else { - // Make a deep copy of the existing list - final List newArray = []; - addressArray - .forEach((dynamic _address) => newArray.add(_address as String)); - newArray.add(address); // Add the address passed into the method - await DB.instance - .put(boxName: walletId, key: chainArray, value: newArray); - } + return isar_models.Address() + ..derivationIndex = index + ..value = address + ..publicKey = [] + ..type = isar_models.AddressType.cryptonote + ..subType = chain == 0 + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change; } Future _getFees() async { @@ -975,7 +897,7 @@ class WowneroWallet extends CoinServiceAPI { ); } - Future _fetchTransactionData() async { + Future _refreshTransactions() async { await walletBase!.updateTransactions(); final transactions = walletBase?.transactionHistory!.transactions; @@ -1011,121 +933,154 @@ class WowneroWallet extends CoinServiceAPI { // } // } - // sort thing stuff - // change to get Wownero price - final priceData = - await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - final List> midSortedArray = []; + final List txns = []; if (transactions != null) { for (var tx in transactions.entries) { // cachedTxids.add(tx.value.id); - Logging.instance.log( - "${tx.value.accountIndex} ${tx.value.addressIndex} ${tx.value.amount} ${tx.value.date} " - "${tx.value.direction} ${tx.value.fee} ${tx.value.height} ${tx.value.id} ${tx.value.isPending} ${tx.value.key} " - "${tx.value.recipientAddress}, ${tx.value.additionalInfo} con:${tx.value.confirmations}" - " ${tx.value.keyIndex}", - level: LogLevel.Info); - String am = wowneroAmountToString(amount: tx.value.amount!); - final worthNow = (currentPrice * Decimal.parse(am)).toStringAsFixed(2); - Map midSortedTx = {}; - // // create final tx map - midSortedTx["txid"] = tx.value.id; - midSortedTx["confirmed_status"] = !tx.value.isPending && - tx.value.confirmations != null && - tx.value.confirmations! >= MINIMUM_CONFIRMATIONS; - midSortedTx["confirmations"] = tx.value.confirmations ?? 0; - midSortedTx["timestamp"] = - (tx.value.date.millisecondsSinceEpoch ~/ 1000); - midSortedTx["txType"] = - tx.value.direction == TransactionDirection.incoming - ? "Received" - : "Sent"; - midSortedTx["amount"] = tx.value.amount; - midSortedTx["worthNow"] = worthNow; - midSortedTx["worthAtBlockTimestamp"] = worthNow; - midSortedTx["fees"] = tx.value.fee; - // TODO: shouldn't wownero have an address I can grab + // Logging.instance.log( + // "${tx.value.accountIndex} ${tx.value.addressIndex} ${tx.value.amount} ${tx.value.date} " + // "${tx.value.direction} ${tx.value.fee} ${tx.value.height} ${tx.value.id} ${tx.value.isPending} ${tx.value.key} " + // "${tx.value.recipientAddress}, ${tx.value.additionalInfo} con:${tx.value.confirmations}" + // " ${tx.value.keyIndex}", + // level: LogLevel.Info); + // String am = wowneroAmountToString(amount: tx.value.amount!); + // final worthNow = (currentPrice * Decimal.parse(am)).toStringAsFixed(2); + // Map midSortedTx = {}; + // // // create final tx map + // midSortedTx["txid"] = tx.value.id; + // midSortedTx["confirmed_status"] = !tx.value.isPending && + // tx.value.confirmations != null && + // tx.value.confirmations! >= MINIMUM_CONFIRMATIONS; + // midSortedTx["confirmations"] = tx.value.confirmations ?? 0; + // midSortedTx["timestamp"] = + // (tx.value.date.millisecondsSinceEpoch ~/ 1000); + // midSortedTx["txType"] = + // tx.value.direction == TransactionDirection.incoming + // ? "Received" + // : "Sent"; + // midSortedTx["amount"] = tx.value.amount; + // midSortedTx["worthNow"] = worthNow; + // midSortedTx["worthAtBlockTimestamp"] = worthNow; + // midSortedTx["fees"] = tx.value.fee; + // if (tx.value.direction == TransactionDirection.incoming) { + // final addressInfo = tx.value.additionalInfo; + // + // midSortedTx["address"] = walletBase?.getTransactionAddress( + // addressInfo!['accountIndex'] as int, + // addressInfo['addressIndex'] as int, + // ); + // } else { + // midSortedTx["address"] = ""; + // } + // + // final int txHeight = tx.value.height ?? 0; + // midSortedTx["height"] = txHeight; + // // if (txHeight >= latestTxnBlockHeight) { + // // latestTxnBlockHeight = txHeight; + // // } + // + // midSortedTx["aliens"] = []; + // midSortedTx["inputSize"] = 0; + // midSortedTx["outputSize"] = 0; + // midSortedTx["inputs"] = []; + // midSortedTx["outputs"] = []; + // midSortedArray.add(midSortedTx); + + final int txHeight = tx.value.height ?? 0; + final txn = isar_models.Transaction(); + txn.txid = tx.value.id; + txn.timestamp = (tx.value.date.millisecondsSinceEpoch ~/ 1000); + if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; - midSortedTx["address"] = walletBase?.getTransactionAddress( - addressInfo!['accountIndex'] as int, - addressInfo['addressIndex'] as int, - ); + txn.address = walletBase?.getTransactionAddress( + addressInfo!['accountIndex'] as int, + addressInfo['addressIndex'] as int, + ) ?? + ""; + + txn.type = isar_models.TransactionType.incoming; } else { - midSortedTx["address"] = ""; + txn.address = ""; + txn.type = isar_models.TransactionType.outgoing; } - final int txHeight = tx.value.height ?? 0; - midSortedTx["height"] = txHeight; - // if (txHeight >= latestTxnBlockHeight) { - // latestTxnBlockHeight = txHeight; - // } + txn.amount = tx.value.amount ?? 0; - midSortedTx["aliens"] = []; - midSortedTx["inputSize"] = 0; - midSortedTx["outputSize"] = 0; - midSortedTx["inputs"] = []; - midSortedTx["outputs"] = []; - midSortedArray.add(midSortedTx); + // TODO: other subtypes + txn.subType = isar_models.TransactionSubType.none; + + txn.fee = tx.value.fee ?? 0; + + txn.height = txHeight; + + txn.isCancelled = false; + txn.slateId = null; + txn.otherData = null; + + txns.add(txn); } } - // sort by date ---- - midSortedArray - .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - Logging.instance.log(midSortedArray, level: LogLevel.Info); + await isar.writeTxn(() async { + await isar.transactions.putAll(txns); + }); - // buildDateTimeChunks - 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], - }; - result["dateTimeChunks"].add(chunk); - } - } - - // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - final Map transactionsMap = {}; - transactionsMap - .addAll(TransactionData.fromJson(result).getAllTransactions()); - - final txModel = TransactionData.fromMap(transactionsMap); + // // sort by date ---- + // midSortedArray + // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); + // Logging.instance.log(midSortedArray, level: LogLevel.Info); // - // await DB.instance.put( - // boxName: walletId, - // key: 'storedTxnDataHeight', - // value: latestTxnBlockHeight); - // await DB.instance.put( - // boxName: walletId, key: 'latest_tx_model', value: txModel); - // await DB.instance.put( - // boxName: walletId, - // key: 'cachedTxids', - // value: cachedTxids.toList(growable: false)); - - return txModel; + // // buildDateTimeChunks + // 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], + // }; + // result["dateTimeChunks"].add(chunk); + // } + // } + // + // // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; + // final Map transactionsMap = {}; + // transactionsMap + // .addAll(TransactionData.fromJson(result).getAllTransactions()); + // + // 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); + // // await DB.instance.put( + // // boxName: walletId, + // // key: 'cachedTxids', + // // value: cachedTxids.toList(growable: false)); + // + // return txModel; } Future _pathForWalletDir({ @@ -1193,12 +1148,12 @@ class WowneroWallet extends CoinServiceAPI { } Future _refreshTxData() async { - final txnData = await _fetchTransactionData(); - final count = txnData.getAllTransactions().length; + await _refreshTransactions(); + final count = await isar.transactions.count(); if (count > _txCount) { _txCount = count; - _transactionData = Future(() => txnData); + await _updateBalance(); GlobalEventBus.instance.fire( UpdatedInBackgroundEvent( "New transaction data found in $walletId $walletName!", @@ -1337,23 +1292,21 @@ class WowneroWallet extends CoinServiceAPI { } // Check the new receiving index - String indexKey = "receivingIndex"; - final curIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final currentReceiving = await _currentReceivingAddress; + final curIndex = currentReceiving!.derivationIndex; + if (highestIndex >= curIndex) { // First increment the receiving index - await _incrementAddressIndexForChain(0); - final newReceivingIndex = - DB.instance.get(boxName: walletId, key: indexKey) as int; + final newReceivingIndex = curIndex + 1; // Use new index to derive a new receiving address final newReceivingAddress = await _generateAddressForChain(0, newReceivingIndex); - // Add that new receiving address to the array of receiving addresses - await _addToAddressesArrayForChain(newReceivingAddress, 0); - - _currentReceivingAddress = Future(() => newReceivingAddress); + // Add that new receiving address + await isar.writeTxn(() async { + await isar.addresses.put(newReceivingAddress); + }); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1382,4 +1335,16 @@ class WowneroWallet extends CoinServiceAPI { @override // TODO: implement storedChainHeight int get storedChainHeight => throw UnimplementedError(); + + @override + Balance get balance => _balance!; + Balance? _balance; + + @override + Future> get transactions => + isar.transactions.where().sortByTimestampDesc().findAll(); + + @override + // TODO: implement utxos + Future> get utxos => throw UnimplementedError(); } From 3a185ead9a5a2c24128ea9875d71cbd9ed5b278e Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:14:04 -0600 Subject: [PATCH 103/192] WIP paynym model parsing updates --- lib/services/coins/coin_paynym_extension.dart | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 7214d7111..303fac44f 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -6,13 +6,11 @@ import 'package:bip47/src/util.dart'; import 'package:bitcoindart/bitcoindart.dart' as btc_dart; import 'package:bitcoindart/src/utils/constants/op.dart' as op; import 'package:bitcoindart/src/utils/script.dart' as bscript; -import 'package:dart_numerics/dart_numerics.dart'; import 'package:decimal/decimal.dart'; +import 'package:isar/isar.dart'; import 'package:pointycastle/digests/sha256.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/models.dart' as models; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -133,24 +131,21 @@ extension PayNym on DogecoinWallet { } /// return the notification tx sent from my wallet if it exists - Future hasSentNotificationTx(PaymentCode pCode) async { - final txData = await transactionData; - - for (final tx in txData.getAllTransactions().values) { - if (tx.address == pCode.notificationAddress()) { - return tx; - } - } - - return null; + Future hasSentNotificationTx(PaymentCode pCode) async { + final tx = await isar.transactions + .filter() + .addressEqualTo(pCode.notificationAddress()) + .findFirst(); + return tx; } void preparePaymentCodeSend(PaymentCode pCode) async { final notifTx = await hasSentNotificationTx(pCode); + final currentHeight = await chainHeight; if (notifTx == null) { throw PaynymSendException("No notification transaction sent to $pCode"); - } else if (!notifTx.confirmedStatus) { + } else if (!notifTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { throw PaynymSendException( "Notification transaction sent to $pCode has not confirmed yet"); } else { @@ -233,17 +228,19 @@ extension PayNym on DogecoinWallet { required int selectedTxFeeRate, required String targetPaymentCodeString, int additionalOutputs = 0, - List? utxos, + List? utxos, }) async { const amountToSend = DUST_LIMIT; - final List availableOutputs = utxos ?? outputsList; - final List spendableOutputs = []; + final List availableOutputs = utxos ?? await this.utxos; + final List spendableOutputs = []; int spendableSatoshiValue = 0; // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].blocked == false && - availableOutputs[i].status.confirmed == true) { + if (availableOutputs[i].isBlocked == false && + availableOutputs[i] + .isConfirmed(await chainHeight, MINIMUM_CONFIRMATIONS) == + true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += availableOutputs[i].value; } @@ -260,12 +257,11 @@ extension PayNym on DogecoinWallet { } // sort spendable by age (oldest first) - spendableOutputs.sort( - (a, b) => b.status.confirmations.compareTo(a.status.confirmations)); + spendableOutputs.sort((a, b) => b.blockTime!.compareTo(a.blockTime!)); int satoshisBeingUsed = 0; int outputsBeingUsed = 0; - List utxoObjectsToUse = []; + List utxoObjectsToUse = []; for (int i = 0; satoshisBeingUsed < amountToSend && i < spendableOutputs.length; @@ -406,7 +402,7 @@ extension PayNym on DogecoinWallet { // equal to its vSize Future> _createNotificationTx({ required String targetPaymentCodeString, - required List utxosToUse, + required List utxosToUse, required Map utxoSigningData, required int change, }) async { @@ -458,8 +454,7 @@ extension PayNym on DogecoinWallet { if (change > 0) { // generate new change address if current change address has been used await checkChangeAddressForTransactions(); - final String changeAddress = - await getCurrentAddressForChain(1, DerivePathType.bip44); + final String changeAddress = await currentChangeAddress; txb.addOutput(changeAddress, change); } @@ -723,10 +718,10 @@ Future parseTransaction( tx.outputs.add(output); } - tx.height = txData["height"] as int? ?? int64MaxValue; + tx.height = txData["height"] as int?; //TODO: change these for epic (or other coins that need it) - tx.cancelled = false; + tx.isCancelled = false; tx.slateId = null; tx.otherData = null; From 1a7439f6a60f5657f224688abbf4ec8cbe773254 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:16:45 -0600 Subject: [PATCH 104/192] isar model updates --- lib/models/isar/models/address/address.dart | 1 + lib/models/isar/models/address/address.g.dart | 2 + .../models/blockchain_data/transaction.dart | 10 +- .../models/blockchain_data/transaction.g.dart | 121 ++++++++++++++---- 4 files changed, 105 insertions(+), 29 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 367a3fab4..d40305be9 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -49,6 +49,7 @@ enum AddressType { p2pkh, p2sh, p2wpkh, + cryptonote, } enum AddressSubType { diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 44d5c1d71..808b182f9 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -171,11 +171,13 @@ const _AddresstypeEnumValueMap = { 'p2pkh': 0, 'p2sh': 1, 'p2wpkh': 2, + 'cryptonote': 3, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, 1: AddressType.p2sh, 2: AddressType.p2wpkh, + 3: AddressType.cryptonote, }; Id _addressGetId(Address object) { diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 7c984b96a..4c87f8302 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -36,6 +36,8 @@ class Transaction { late bool isCancelled; + late bool? isLelantus; + late String? slateId; late String? otherData; @@ -65,9 +67,7 @@ enum TransactionType { outgoing, incoming, sentToSelf, // should we keep this? - unknown, - anonymize; // firo specific - + unknown; } // Used in Isar db and stored there as int indexes so adding/removing values @@ -76,6 +76,6 @@ enum TransactionSubType { // TODO: add more types before prod release? none, bip47Notification, // bip47 payment code notification transaction flag - mint; // firo specific - + mint, // firo specific + join; // firo specific } diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 42261d9e0..b12911d1d 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -42,34 +42,39 @@ const TransactionSchema = CollectionSchema( name: r'isCancelled', type: IsarType.bool, ), - r'otherData': PropertySchema( + r'isLelantus': PropertySchema( id: 5, + name: r'isLelantus', + type: IsarType.bool, + ), + r'otherData': PropertySchema( + id: 6, name: r'otherData', type: IsarType.string, ), r'slateId': PropertySchema( - id: 6, + id: 7, name: r'slateId', type: IsarType.string, ), r'subType': PropertySchema( - id: 7, + id: 8, name: r'subType', type: IsarType.byte, enumMap: _TransactionsubTypeEnumValueMap, ), r'timestamp': PropertySchema( - id: 8, + id: 9, name: r'timestamp', type: IsarType.long, ), r'txid': PropertySchema( - id: 9, + id: 10, name: r'txid', type: IsarType.string, ), r'type': PropertySchema( - id: 10, + id: 11, name: r'type', type: IsarType.byte, enumMap: _TransactiontypeEnumValueMap, @@ -170,12 +175,13 @@ void _transactionSerialize( writer.writeLong(offsets[2], object.fee); writer.writeLong(offsets[3], object.height); writer.writeBool(offsets[4], object.isCancelled); - writer.writeString(offsets[5], object.otherData); - writer.writeString(offsets[6], object.slateId); - writer.writeByte(offsets[7], object.subType.index); - writer.writeLong(offsets[8], object.timestamp); - writer.writeString(offsets[9], object.txid); - writer.writeByte(offsets[10], object.type.index); + writer.writeBool(offsets[5], object.isLelantus); + writer.writeString(offsets[6], object.otherData); + writer.writeString(offsets[7], object.slateId); + writer.writeByte(offsets[8], object.subType.index); + writer.writeLong(offsets[9], object.timestamp); + writer.writeString(offsets[10], object.txid); + writer.writeByte(offsets[11], object.type.index); } Transaction _transactionDeserialize( @@ -191,15 +197,16 @@ Transaction _transactionDeserialize( object.height = reader.readLongOrNull(offsets[3]); object.id = id; object.isCancelled = reader.readBool(offsets[4]); - object.otherData = reader.readStringOrNull(offsets[5]); - object.slateId = reader.readStringOrNull(offsets[6]); + object.isLelantus = reader.readBoolOrNull(offsets[5]); + object.otherData = reader.readStringOrNull(offsets[6]); + object.slateId = reader.readStringOrNull(offsets[7]); object.subType = - _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ?? + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[8])] ?? TransactionSubType.none; - object.timestamp = reader.readLong(offsets[8]); - object.txid = reader.readString(offsets[9]); + object.timestamp = reader.readLong(offsets[9]); + object.txid = reader.readString(offsets[10]); object.type = - _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ?? + _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? TransactionType.outgoing; return object; } @@ -222,17 +229,19 @@ P _transactionDeserializeProp

( case 4: return (reader.readBool(offset)) as P; case 5: - return (reader.readStringOrNull(offset)) as P; + return (reader.readBoolOrNull(offset)) as P; case 6: return (reader.readStringOrNull(offset)) as P; case 7: + return (reader.readStringOrNull(offset)) as P; + case 8: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 8: - return (reader.readLong(offset)) as P; case 9: - return (reader.readString(offset)) as P; + return (reader.readLong(offset)) as P; case 10: + return (reader.readString(offset)) as P; + case 11: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; default: @@ -244,25 +253,25 @@ const _TransactionsubTypeEnumValueMap = { 'none': 0, 'bip47Notification': 1, 'mint': 2, + 'join': 3, }; const _TransactionsubTypeValueEnumMap = { 0: TransactionSubType.none, 1: TransactionSubType.bip47Notification, 2: TransactionSubType.mint, + 3: TransactionSubType.join, }; const _TransactiontypeEnumValueMap = { 'outgoing': 0, 'incoming': 1, 'sentToSelf': 2, 'unknown': 3, - 'anonymize': 4, }; const _TransactiontypeValueEnumMap = { 0: TransactionType.outgoing, 1: TransactionType.incoming, 2: TransactionType.sentToSelf, 3: TransactionType.unknown, - 4: TransactionType.anonymize, }; Id _transactionGetId(Transaction object) { @@ -935,6 +944,34 @@ extension TransactionQueryFilter }); } + QueryBuilder + isLelantusIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isLelantus', + )); + }); + } + + QueryBuilder + isLelantusIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isLelantus', + )); + }); + } + + QueryBuilder + isLelantusEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isLelantus', + value: value, + )); + }); + } + QueryBuilder otherDataIsNull() { return QueryBuilder.apply(this, (query) { @@ -1739,6 +1776,18 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByIsLelantus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.asc); + }); + } + + QueryBuilder sortByIsLelantusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.desc); + }); + } + QueryBuilder sortByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -1886,6 +1935,18 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByIsLelantus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.asc); + }); + } + + QueryBuilder thenByIsLelantusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.desc); + }); + } + QueryBuilder thenByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -1992,6 +2053,12 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByIsLelantus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isLelantus'); + }); + } + QueryBuilder distinctByOtherData( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2070,6 +2137,12 @@ extension TransactionQueryProperty }); } + QueryBuilder isLelantusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isLelantus'); + }); + } + QueryBuilder otherDataProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'otherData'); From 6adf1d314871bcc1b46092b33bf6994dffc55c77 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:17:12 -0600 Subject: [PATCH 105/192] generated test mocks updates --- .../pages/send_view/send_view_test.mocks.dart | 1255 +++++++---------- ...d_address_book_view_screen_test.mocks.dart | 118 +- ..._entry_details_view_screen_test.mocks.dart | 126 +- ...ess_book_entry_view_screen_test.mocks.dart | 118 +- .../lockscreen_view_screen_test.mocks.dart | 118 +- .../main_view_screen_testA_test.mocks.dart | 126 +- .../main_view_screen_testB_test.mocks.dart | 126 +- .../main_view_screen_testC_test.mocks.dart | 126 +- .../backup_key_view_screen_test.mocks.dart | 124 +- ...up_key_warning_view_screen_test.mocks.dart | 118 +- .../create_pin_view_screen_test.mocks.dart | 118 +- ...restore_wallet_view_screen_test.mocks.dart | 168 +-- ...ify_backup_key_view_screen_test.mocks.dart | 124 +- .../currency_view_screen_test.mocks.dart | 124 +- ...dd_custom_node_view_screen_test.mocks.dart | 118 +- .../node_details_view_screen_test.mocks.dart | 118 +- .../wallet_backup_view_screen_test.mocks.dart | 124 +- ...rescan_warning_view_screen_test.mocks.dart | 124 +- ...elete_mnemonic_view_screen_test.mocks.dart | 118 +- ...allet_settings_view_screen_test.mocks.dart | 118 +- .../settings_view_screen_test.mocks.dart | 118 +- ...search_results_view_screen_test.mocks.dart | 140 +- .../confirm_send_view_screen_test.mocks.dart | 132 +- .../receive_view_screen_test.mocks.dart | 124 +- .../send_view_screen_test.mocks.dart | 132 +- .../wallet_view_screen_test.mocks.dart | 140 +- test/services/coins/manager_test.mocks.dart | 720 +++++----- .../managed_favorite_test.mocks.dart | 1211 +++++++--------- .../table_view/table_view_row_test.mocks.dart | 1079 ++++++-------- .../transaction_card_test.mocks.dart | 1173 +++++++-------- test/widget_tests/wallet_card_test.mocks.dart | 543 +++---- ...et_info_row_balance_future_test.mocks.dart | 1195 +++++++--------- .../wallet_info_row_test.mocks.dart | 1195 +++++++--------- 33 files changed, 4018 insertions(+), 7493 deletions(-) diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 4d5793cc4..1b4d831f2 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -3,34 +3,36 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i16; -import 'dart:ui' as _i18; +import 'dart:async' as _i17; +import 'dart:ui' as _i19; -import 'package:decimal/decimal.dart' as _i10; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i9; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i12; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i11; -import 'package:stackwallet/models/models.dart' as _i9; -import 'package:stackwallet/models/node_model.dart' as _i19; +import 'package:stackwallet/models/balance.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i22; +import 'package:stackwallet/models/node_model.dart' as _i20; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i10; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart' - as _i23; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; -import 'package:stackwallet/services/coins/coin_service.dart' as _i13; + as _i25; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i21; +import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i21; +import 'package:stackwallet/services/locale_service.dart' as _i23; 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 _i14; +import 'package:stackwallet/services/wallets.dart' as _i15; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i24; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i22; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i26; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i24; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; -import 'package:stackwallet/utilities/prefs.dart' as _i17; +import 'package:stackwallet/utilities/prefs.dart' as _i18; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -107,8 +109,8 @@ class _FakeTransactionNotificationTracker_5 extends _i1.SmartFake ); } -class _FakeUtxoData_6 extends _i1.SmartFake implements _i9.UtxoData { - _FakeUtxoData_6( +class _FakeIsar_6 extends _i1.SmartFake implements _i9.Isar { + _FakeIsar_6( Object parent, Invocation parentInvocation, ) : super( @@ -117,8 +119,8 @@ class _FakeUtxoData_6 extends _i1.SmartFake implements _i9.UtxoData { ); } -class _FakeDecimal_7 extends _i1.SmartFake implements _i10.Decimal { - _FakeDecimal_7( +class _FakeFeeObject_7 extends _i1.SmartFake implements _i10.FeeObject { + _FakeFeeObject_7( Object parent, Invocation parentInvocation, ) : super( @@ -127,8 +129,8 @@ class _FakeDecimal_7 extends _i1.SmartFake implements _i10.Decimal { ); } -class _FakeFeeObject_8 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_8( +class _FakeElectrumX_8 extends _i1.SmartFake implements _i11.ElectrumX { + _FakeElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -137,30 +139,9 @@ class _FakeFeeObject_8 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeTransactionData_9 extends _i1.SmartFake - implements _i9.TransactionData { - _FakeTransactionData_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeElectrumX_10 extends _i1.SmartFake implements _i11.ElectrumX { - _FakeElectrumX_10( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeCachedElectrumX_11 extends _i1.SmartFake +class _FakeCachedElectrumX_9 extends _i1.SmartFake implements _i12.CachedElectrumX { - _FakeCachedElectrumX_11( + _FakeCachedElectrumX_9( Object parent, Invocation parentInvocation, ) : super( @@ -169,9 +150,19 @@ class _FakeCachedElectrumX_11 extends _i1.SmartFake ); } -class _FakeElectrumXNode_12 extends _i1.SmartFake +class _FakeBalance_10 extends _i1.SmartFake implements _i13.Balance { + _FakeBalance_10( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXNode_11 extends _i1.SmartFake implements _i11.ElectrumXNode { - _FakeElectrumXNode_12( + _FakeElectrumXNode_11( Object parent, Invocation parentInvocation, ) : super( @@ -180,9 +171,9 @@ class _FakeElectrumXNode_12 extends _i1.SmartFake ); } -class _FakeCoinServiceAPI_13 extends _i1.SmartFake - implements _i13.CoinServiceAPI { - _FakeCoinServiceAPI_13( +class _FakeCoinServiceAPI_12 extends _i1.SmartFake + implements _i14.CoinServiceAPI { + _FakeCoinServiceAPI_12( Object parent, Invocation parentInvocation, ) : super( @@ -194,7 +185,7 @@ class _FakeCoinServiceAPI_13 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 _i14.Wallets { +class MockWallets extends _i1.Mock implements _i15.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -261,7 +252,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i15.Coin? coin}) => + List getWalletIdsFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -271,18 +262,18 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValue: [], ) as List); @override - Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> + Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Coin, + returnValue: <_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, - ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); + ) as Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i15.Coin? coin) => + _i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -346,17 +337,17 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - _i16.Future load(_i17.Prefs? prefs) => (super.noSuchMethod( + _i17.Future load(_i18.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future loadAfterStackRestore( - _i17.Prefs? prefs, + _i17.Future loadAfterStackRestore( + _i18.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -367,11 +358,11 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { managers, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -379,7 +370,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -405,19 +396,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i16.Future> get walletNames => + _i17.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i16.Future>.value( + returnValue: _i17.Future>.value( {}), - ) as _i16.Future>); + ) as _i17.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future renameWallet({ + _i17.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -432,13 +423,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future addExistingStackWallet({ + _i17.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -452,13 +443,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addNewWallet({ + _i17.Future addNewWallet({ required String? name, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -471,46 +462,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i17.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future saveFavoriteWalletIds(List? walletIds) => + _i17.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future moveFavorite({ + _i17.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -523,48 +514,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i17.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i17.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isMnemonicVerified({required String? walletId}) => + _i17.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future setMnemonicVerified({required String? walletId}) => + _i17.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future deleteWallet( + _i17.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -576,20 +567,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future refreshWallets(bool? shouldNotifyListeners) => + _i17.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -597,7 +588,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -639,33 +630,33 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i7.SecureStorageInterface); @override - List<_i19.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i20.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i19.NodeModel>[], - ) as List<_i19.NodeModel>); + returnValue: <_i20.NodeModel>[], + ) as List<_i20.NodeModel>); @override - List<_i19.NodeModel> get nodes => (super.noSuchMethod( + List<_i20.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i19.NodeModel>[], - ) as List<_i19.NodeModel>); + returnValue: <_i20.NodeModel>[], + ) as List<_i20.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future updateDefaults() => (super.noSuchMethod( + _i17.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setPrimaryNodeFor({ - required _i15.Coin? coin, - required _i19.NodeModel? node, + _i17.Future setPrimaryNodeFor({ + required _i16.Coin? coin, + required _i20.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -678,44 +669,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i19.NodeModel? getPrimaryNodeFor({required _i15.Coin? coin}) => + _i20.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i19.NodeModel?); + )) as _i20.NodeModel?); @override - List<_i19.NodeModel> getNodesFor(_i15.Coin? coin) => (super.noSuchMethod( + List<_i20.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i19.NodeModel>[], - ) as List<_i19.NodeModel>); + returnValue: <_i20.NodeModel>[], + ) as List<_i20.NodeModel>); @override - _i19.NodeModel? getNodeById({required String? id}) => + _i20.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i19.NodeModel?); + )) as _i20.NodeModel?); @override - List<_i19.NodeModel> failoverNodesFor({required _i15.Coin? coin}) => + List<_i20.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i19.NodeModel>[], - ) as List<_i19.NodeModel>); + returnValue: <_i20.NodeModel>[], + ) as List<_i20.NodeModel>); @override - _i16.Future add( - _i19.NodeModel? node, + _i17.Future add( + _i20.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -728,11 +719,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future delete( + _i17.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -744,11 +735,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setEnabledState( + _i17.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -762,12 +753,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future edit( - _i19.NodeModel? editedNode, + _i17.Future edit( + _i20.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -780,20 +771,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateCommunityNodes() => (super.noSuchMethod( + _i17.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -801,7 +792,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -829,13 +820,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 _i20.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i16.Timer? _timer) => super.noSuchMethod( + set timer(_i17.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -860,19 +851,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - List<_i9.UtxoObject> get outputsList => (super.noSuchMethod( - Invocation.getter(#outputsList), - returnValue: <_i9.UtxoObject>[], - ) as List<_i9.UtxoObject>); - @override - set outputsList(List<_i9.UtxoObject>? _outputsList) => super.noSuchMethod( - Invocation.setter( - #outputsList, - _outputsList, - ), - returnValueForMissingStub: null, - ); - @override bool get longMutex => (super.noSuchMethod( Invocation.getter(#longMutex), returnValue: false, @@ -899,10 +877,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i9.TransactionData? _cachedTxData) => super.noSuchMethod( + _i9.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_6( + this, + Invocation.getter(#isar), + ), + ) as _i9.Isar); + @override + set isar(_i9.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @@ -933,104 +919,59 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i22.UTXO>[]), + ) as _i17.Future>); @override - _i16.Future<_i9.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i16.Future<_i9.UtxoData>.value(_FakeUtxoData_6( - this, - Invocation.getter(#utxoData), - )), - ) as _i16.Future<_i9.UtxoData>); - @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future>.value(<_i9.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future>.value(<_i22.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future<_i10.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future<_i10.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future<_i10.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future<_i10.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future get currentLegacyReceivingAddress => (super.noSuchMethod( - Invocation.getter(#currentLegacyReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future get currentReceivingAddressP2SH => (super.noSuchMethod( - Invocation.getter(#currentReceivingAddressP2SH), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + _i17.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_8( + returnValue: _i17.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i9.FeeObject>); + ) as _i17.Future<_i10.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future get chainHeight => (super.noSuchMethod( + _i17.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -1060,15 +1001,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future<_i9.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i16.Future<_i9.TransactionData>.value(_FakeTransactionData_9( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i9.TransactionData>); - @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), returnValue: '', @@ -1089,7 +1021,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { @override _i11.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_10( + returnValue: _FakeElectrumX_8( this, Invocation.getter(#electrumXClient), ), @@ -1097,12 +1029,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { @override _i12.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_11( + returnValue: _FakeCachedElectrumX_9( this, Invocation.getter(#cachedElectrumXClient), ), ) as _i12.CachedElectrumX); @override + _i13.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_10( + this, + Invocation.getter(#balance), + ), + ) as _i13.Balance); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -1112,37 +1052,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateStoredChainHeight({required int? newHeight}) => + _i17.Future updateStoredChainHeight({required int? newHeight}) => (super.noSuchMethod( Invocation.method( #updateStoredChainHeight, [], {#newHeight: newHeight}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i20.DerivePathType addressType({required String? address}) => + _i21.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i20.DerivePathType.bip44, - ) as _i20.DerivePathType); + returnValue: _i21.DerivePathType.bip44, + ) as _i21.DerivePathType); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1159,48 +1099,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTransactionCacheEarly(List? allAddresses) => + _i17.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i17.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getAllTxsToWatch(_i9.TransactionData? txData) => - (super.noSuchMethod( + _i17.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [txData], + [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1216,44 +1155,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1271,33 +1192,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1307,36 +1228,36 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future<_i11.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i11.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i16.Future<_i11.ElectrumXNode>.value(_FakeElectrumXNode_12( + _i17.Future<_i11.ElectrumXNode>.value(_FakeElectrumXNode_11( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i16.Future<_i11.ElectrumXNode>); + ) as _i17.Future<_i11.ElectrumXNode>); @override - _i16.Future addDerivation({ + _i17.Future addDerivation({ required int? chain, required String? address, required String? pubKey, required String? wif, - required _i20.DerivePathType? derivePathType, + required _i21.DerivePathType? derivePathType, }) => (super.noSuchMethod( Invocation.method( @@ -1350,13 +1271,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { #derivePathType: derivePathType, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addDerivations({ + _i17.Future addDerivations({ required int? chain, - required _i20.DerivePathType? derivePathType, + required _i21.DerivePathType? derivePathType, required Map? derivationsToAdd, }) => (super.noSuchMethod( @@ -1369,50 +1290,50 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { #derivationsToAdd: derivationsToAdd, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTxCount({required String? address}) => - (super.noSuchMethod( - Invocation.method( - #getTxCount, - [], - {#address: address}, - ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); - @override - _i16.Future checkCurrentReceivingAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentReceivingAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future checkCurrentChangeAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentChangeAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future>> fastFetch( + _i17.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i16.Future>>.value( + returnValue: _i17.Future>>.value( >[]), - ) as _i16.Future>>); + ) as _i17.Future>>); + @override + _i17.Future getTxCount({required String? address}) => + (super.noSuchMethod( + Invocation.method( + #getTxCount, + [], + {#address: address}, + ), + returnValue: _i17.Future.value(0), + ) as _i17.Future); + @override + _i17.Future checkCurrentReceivingAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentReceivingAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future checkCurrentChangeAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentChangeAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override int estimateTxFee({ required int? vSize, @@ -1436,7 +1357,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i9.UtxoObject>? utxos, + List<_i22.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1452,19 +1373,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { }, )); @override - _i16.Future> fetchBuildTxData( - List<_i9.UtxoObject>? utxosToUse) => + _i17.Future> fetchBuildTxData( + List<_i22.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future> buildTransaction({ - required List<_i9.UtxoObject>? utxosToUse, + _i17.Future> buildTransaction({ + required List<_i22.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -1481,10 +1402,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1496,11 +1417,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1512,8 +1433,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int roughFeeEstimate( int? inputCount, @@ -1532,27 +1453,27 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i17.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i21.LocaleService { +class MockLocaleService extends _i1.Mock implements _i23.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1568,17 +1489,17 @@ class MockLocaleService extends _i1.Mock implements _i21.LocaleService { returnValue: false, ) as bool); @override - _i16.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i17.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1586,7 +1507,7 @@ class MockLocaleService extends _i1.Mock implements _i21.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1614,7 +1535,7 @@ class MockLocaleService extends _i1.Mock implements _i21.LocaleService { /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i17.Prefs { +class MockPrefs extends _i1.Mock implements _i18.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -1670,12 +1591,12 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - _i22.SyncingType get syncType => (super.noSuchMethod( + _i24.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i22.SyncingType.currentWalletOnly, - ) as _i22.SyncingType); + returnValue: _i24.SyncingType.currentWalletOnly, + ) as _i24.SyncingType); @override - set syncType(_i22.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i24.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -1735,12 +1656,12 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - _i23.ExchangeRateType get exchangeRateType => (super.noSuchMethod( + _i25.ExchangeRateType get exchangeRateType => (super.noSuchMethod( Invocation.getter(#exchangeRateType), - returnValue: _i23.ExchangeRateType.estimated, - ) as _i23.ExchangeRateType); + returnValue: _i25.ExchangeRateType.estimated, + ) as _i25.ExchangeRateType); @override - set exchangeRateType(_i23.ExchangeRateType? exchangeRateType) => + set exchangeRateType(_i25.ExchangeRateType? exchangeRateType) => super.noSuchMethod( Invocation.setter( #exchangeRateType, @@ -1822,12 +1743,12 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - _i24.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i26.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i24.BackupFrequencyType.everyTenMinutes, - ) as _i24.BackupFrequencyType); + returnValue: _i26.BackupFrequencyType.everyTenMinutes, + ) as _i26.BackupFrequencyType); @override - set backupFrequencyType(_i24.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i26.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -1897,33 +1818,33 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValue: false, ) as bool); @override - _i16.Future init() => (super.noSuchMethod( + _i17.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i17.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isExternalCallsSet() => (super.noSuchMethod( + _i17.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1931,7 +1852,7 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1974,23 +1895,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i13.CoinServiceAPI get wallet => (super.noSuchMethod( + _i14.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_13( + returnValue: _FakeCoinServiceAPI_12( this, Invocation.getter(#wallet), ), - ) as _i13.CoinServiceAPI); + ) as _i14.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2023,91 +1944,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_8( + returnValue: _i17.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i9.FeeObject>); + ) as _i17.Future<_i10.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i10.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( + _i13.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_10( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i10.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_7( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i10.Decimal); + ) as _i13.Balance); @override - _i16.Future<_i10.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future<_i10.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future<_i10.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i10.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_7( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i10.Decimal); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i9.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i9.TransactionData>.value(_FakeTransactionData_9( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i9.TransactionData>); + _i17.Future>.value(<_i22.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i9.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i22.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2127,10 +1999,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -2147,14 +2019,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -2164,7 +2036,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -2180,45 +2052,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2228,33 +2082,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -2271,20 +2125,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exitCurrentWallet() => (super.noSuchMethod( + _i17.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2296,19 +2150,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); - @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -2320,18 +2166,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2339,7 +2185,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2359,7 +2205,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 _i13.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -2370,10 +2216,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2406,75 +2252,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i10.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_8( + returnValue: _i17.Future<_i10.FeeObject>.value(_FakeFeeObject_7( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i9.FeeObject>); + ) as _i17.Future<_i10.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i10.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( + _i13.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_10( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i10.Decimal>); + Invocation.getter(#balance), + ), + ) as _i13.Balance); @override - _i16.Future<_i10.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future<_i10.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future<_i10.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i10.Decimal>.value(_FakeDecimal_7( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i10.Decimal>); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i9.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i9.TransactionData>.value(_FakeTransactionData_9( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i9.TransactionData>); + _i17.Future>.value(<_i22.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i9.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i22.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2494,10 +2307,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -2514,7 +2327,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: 0, ) as int); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -2530,54 +2343,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2587,15 +2382,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -2612,38 +2407,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2655,11 +2450,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -2671,24 +2466,24 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } 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 c282d1f38..bb5c5c408 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 @@ -7,9 +7,10 @@ import 'dart:async' as _i8; import 'dart:ui' as _i10; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; -import 'package:decimal/decimal.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i6; import 'package:stackwallet/models/contact.dart' as _i3; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i5; import 'package:stackwallet/services/address_book_service.dart' as _i9; import 'package:stackwallet/services/coins/coin_service.dart' as _i4; @@ -69,19 +70,8 @@ class _FakeFeeObject_3 extends _i1.SmartFake implements _i5.FeeObject { ); } -class _FakeDecimal_4 extends _i1.SmartFake implements _i6.Decimal { - _FakeDecimal_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_5 extends _i1.SmartFake - implements _i5.TransactionData { - _FakeTransactionData_5( +class _FakeBalance_4 extends _i1.SmartFake implements _i6.Balance { + _FakeBalance_4( Object parent, Invocation parentInvocation, ) : super( @@ -321,72 +311,24 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future<_i6.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i8.Future<_i6.Decimal>.value(_FakeDecimal_4( + _i6.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_4( this, - Invocation.getter(#availableBalance), - )), - ) as _i8.Future<_i6.Decimal>); - @override - _i6.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_4( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i6.Decimal); + ) as _i6.Balance); @override - _i8.Future<_i6.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i8.Future<_i6.Decimal>.value(_FakeDecimal_4( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i8.Future<_i6.Decimal>); - @override - _i8.Future<_i6.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i8.Future<_i6.Decimal>.value(_FakeDecimal_4( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i8.Future<_i6.Decimal>); - @override - _i8.Future<_i6.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i8.Future<_i6.Decimal>.value(_FakeDecimal_4( - this, - Invocation.getter(#totalBalance), - )), - ) as _i8.Future<_i6.Decimal>); - @override - _i6.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_4( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i6.Decimal); - @override - _i8.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); - @override - _i8.Future<_i5.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i8.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i8.Future<_i5.TransactionData>.value(_FakeTransactionData_5( - this, - Invocation.getter(#transactionData), - )), - ) as _i8.Future<_i5.TransactionData>); + _i8.Future>.value(<_i13.Transaction>[]), + ) as _i8.Future>); @override - _i8.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i8.Future>.value(<_i5.UtxoObject>[]), - ) as _i8.Future>); + _i8.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i8.Future>.value(<_i13.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -472,24 +414,6 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); - @override _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -579,14 +503,6 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i8.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); - @override _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 dd8112508..f0c334e7e 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 @@ -6,15 +6,16 @@ import 'dart:async' as _i7; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; import 'package:stackwallet/models/contact.dart' as _i2; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/address_book_service.dart' as _i6; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i12; -import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/services/locale_service.dart' as _i13; +import 'package:stackwallet/services/notes_service.dart' as _i12; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; // ignore_for_file: type=lint @@ -59,19 +60,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -282,72 +272,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i7.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i4.TransactionData>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i4.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -433,24 +375,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -540,14 +464,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -599,7 +515,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i12.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -701,7 +617,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i12.LocaleService { +class MockLocaleService extends _i1.Mock implements _i13.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), 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 0e4253f6e..f0c11b04a 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 @@ -6,9 +6,10 @@ import 'dart:async' as _i7; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; import 'package:stackwallet/models/contact.dart' as _i2; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/address_book_service.dart' as _i6; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; @@ -57,19 +58,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -280,72 +270,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i7.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i4.TransactionData>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i4.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -431,24 +373,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -538,14 +462,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index 7218d6530..6328b6881 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -6,8 +6,9 @@ import 'dart:async' as _i7; import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/models/node_model.dart' as _i11; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; @@ -61,19 +62,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -589,72 +579,24 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i7.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i4.TransactionData>); + _i7.Future>.value(<_i13.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i4.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i13.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -740,24 +682,6 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -847,14 +771,6 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 27a456307..c0c6f6902 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 @@ -6,13 +6,14 @@ import 'dart:async' as _i6; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i11; -import 'package:stackwallet/services/notes_service.dart' as _i10; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; import 'package:stackwallet/services/wallets_service.dart' as _i5; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; @@ -48,19 +49,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -376,72 +366,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i6.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i6.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); - @override - _i6.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i6.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i6.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i6.Future<_i3.TransactionData>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i6.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i6.Future>.value(<_i3.UtxoObject>[]), - ) as _i6.Future>); + _i6.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -527,24 +469,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); - @override _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -634,14 +558,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override - _i6.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -693,7 +609,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i10.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -795,7 +711,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i11.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), 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 13419efd9..aef163b0e 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 @@ -6,13 +6,14 @@ import 'dart:async' as _i6; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i11; -import 'package:stackwallet/services/notes_service.dart' as _i10; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; import 'package:stackwallet/services/wallets_service.dart' as _i5; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; @@ -48,19 +49,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -376,72 +366,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i6.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i6.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); - @override - _i6.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i6.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i6.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i6.Future<_i3.TransactionData>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i6.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i6.Future>.value(<_i3.UtxoObject>[]), - ) as _i6.Future>); + _i6.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -527,24 +469,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); - @override _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -634,14 +558,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override - _i6.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -693,7 +609,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i10.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -795,7 +711,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i11.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), 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 5545ef110..7f31b64c4 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 @@ -6,13 +6,14 @@ import 'dart:async' as _i6; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i11; -import 'package:stackwallet/services/notes_service.dart' as _i10; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; import 'package:stackwallet/services/wallets_service.dart' as _i5; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; @@ -48,19 +49,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -376,72 +366,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i6.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i6.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); - @override - _i6.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i6.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i6.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i6.Future<_i3.TransactionData>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i6.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i6.Future>.value(<_i3.UtxoObject>[]), - ) as _i6.Future>); + _i6.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -527,24 +469,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); - @override _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -634,14 +558,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override - _i6.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -693,7 +609,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i10.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -795,7 +711,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i11.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), 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 ab9fb86ad..56e72d944 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 @@ -4,10 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; @@ -45,19 +46,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -151,72 +141,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -302,24 +244,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -409,14 +333,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -440,7 +356,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -448,7 +364,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 c699077c2..a7467d9be 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 @@ -6,8 +6,9 @@ import 'dart:async' as _i6; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i9; @@ -46,19 +47,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -374,72 +364,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i6.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i6.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); - @override - _i6.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i6.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i6.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i6.Future<_i3.TransactionData>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i6.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i6.Future>.value(<_i3.UtxoObject>[]), - ) as _i6.Future>); + _i6.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -525,24 +467,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); - @override _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -632,14 +556,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override - _i6.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 96ac903a7..9267a9fba 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 @@ -6,8 +6,9 @@ import 'dart:async' as _i7; import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/models/node_model.dart' as _i11; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; @@ -61,19 +62,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -589,72 +579,24 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i7.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i4.TransactionData>); + _i7.Future>.value(<_i13.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i4.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i13.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -740,24 +682,6 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -847,14 +771,6 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 bdc823d5c..13aa6edb8 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 @@ -7,13 +7,14 @@ import 'dart:async' as _i8; import 'dart:ui' as _i11; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i14; +import 'package:stackwallet/models/node_model.dart' as _i15; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; import 'package:stackwallet/services/coins/manager.dart' as _i12; -import 'package:stackwallet/services/node_service.dart' as _i13; +import 'package:stackwallet/services/node_service.dart' as _i14; import 'package:stackwallet/services/wallets_service.dart' as _i9; import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i7; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; @@ -62,8 +63,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -72,20 +73,9 @@ class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { ); } -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeSecureStorageInterface_5 extends _i1.SmartFake +class _FakeSecureStorageInterface_4 extends _i1.SmartFake implements _i6.SecureStorageInterface { - _FakeSecureStorageInterface_5( + _FakeSecureStorageInterface_4( Object parent, Invocation parentInvocation, ) : super( @@ -430,72 +420,24 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i8.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i8.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); - @override - _i8.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i8.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i8.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i8.Future<_i4.TransactionData>); + _i8.Future>.value(<_i13.Transaction>[]), + ) as _i8.Future>); @override - _i8.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i8.Future>.value(<_i4.UtxoObject>[]), - ) as _i8.Future>); + _i8.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i8.Future>.value(<_i13.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -581,24 +523,6 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); - @override _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -688,14 +612,6 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i8.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); - @override _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -747,25 +663,25 @@ class MockManager extends _i1.Mock implements _i12.Manager { /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i13.NodeService { +class MockNodeService extends _i1.Mock implements _i14.NodeService { @override _i6.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_5( + returnValue: _FakeSecureStorageInterface_4( this, Invocation.getter(#secureStorageInterface), ), ) as _i6.SecureStorageInterface); @override - List<_i14.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i15.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i14.NodeModel>[], - ) as List<_i14.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override - List<_i14.NodeModel> get nodes => (super.noSuchMethod( + List<_i15.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i14.NodeModel>[], - ) as List<_i14.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -783,7 +699,7 @@ class MockNodeService extends _i1.Mock implements _i13.NodeService { @override _i8.Future setPrimaryNodeFor({ required _i10.Coin? coin, - required _i14.NodeModel? node, + required _i15.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -800,40 +716,40 @@ class MockNodeService extends _i1.Mock implements _i13.NodeService { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i14.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => + _i15.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i14.NodeModel?); + )) as _i15.NodeModel?); @override - List<_i14.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( + List<_i15.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i14.NodeModel>[], - ) as List<_i14.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override - _i14.NodeModel? getNodeById({required String? id}) => + _i15.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i14.NodeModel?); + )) as _i15.NodeModel?); @override - List<_i14.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => + List<_i15.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i14.NodeModel>[], - ) as List<_i14.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override _i8.Future add( - _i14.NodeModel? node, + _i15.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -885,7 +801,7 @@ class MockNodeService extends _i1.Mock implements _i13.NodeService { ) as _i8.Future); @override _i8.Future edit( - _i14.NodeModel? editedNode, + _i15.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => 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 708252b7a..b8c7f3cbd 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 @@ -4,10 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; @@ -45,19 +46,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -151,72 +141,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -302,24 +244,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -409,14 +333,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -440,7 +356,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -448,7 +364,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 a2c356b3f..68f2eeb10 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 @@ -4,10 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; @@ -45,19 +46,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -151,72 +141,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -302,24 +244,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -409,14 +333,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -440,7 +356,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -448,7 +364,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 908a7291c..8b60863ab 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 @@ -6,8 +6,9 @@ import 'dart:async' as _i8; import 'dart:ui' as _i10; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/models/node_model.dart' as _i7; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; @@ -60,19 +61,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -366,72 +356,24 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i8.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i8.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); - @override - _i8.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i8.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i8.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i8.Future<_i4.TransactionData>); + _i8.Future>.value(<_i12.Transaction>[]), + ) as _i8.Future>); @override - _i8.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i8.Future>.value(<_i4.UtxoObject>[]), - ) as _i8.Future>); + _i8.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i8.Future>.value(<_i12.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -517,24 +459,6 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); - @override _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -624,14 +548,6 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i8.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); - @override _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 aed7f5032..09d59deb2 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 @@ -6,8 +6,9 @@ import 'dart:async' as _i8; import 'dart:ui' as _i10; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/models/node_model.dart' as _i7; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; @@ -60,19 +61,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -366,72 +356,24 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i8.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i8.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); - @override - _i8.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i8.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i8.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i8.Future<_i4.TransactionData>); + _i8.Future>.value(<_i12.Transaction>[]), + ) as _i8.Future>); @override - _i8.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i8.Future>.value(<_i4.UtxoObject>[]), - ) as _i8.Future>); + _i8.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i8.Future>.value(<_i12.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -517,24 +459,6 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); - @override _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -624,14 +548,6 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i8.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); - @override _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 59197ddc3..a958461b8 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 @@ -4,10 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; @@ -45,19 +46,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -151,72 +141,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -302,24 +244,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -409,14 +333,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -440,7 +356,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -448,7 +364,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 cf1a42d6a..284065eba 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 @@ -4,10 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; @@ -45,19 +46,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -151,72 +141,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -302,24 +244,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -409,14 +333,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -440,7 +356,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -448,7 +364,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 f52602c9b..24da7d388 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 @@ -6,8 +6,9 @@ import 'dart:async' as _i6; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i9; @@ -46,19 +47,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -374,72 +364,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i6.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i6.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); - @override - _i6.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i6.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i6.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i6.Future<_i3.TransactionData>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i6.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i6.Future>.value(<_i3.UtxoObject>[]), - ) as _i6.Future>); + _i6.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -525,24 +467,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); - @override _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -632,14 +556,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override - _i6.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 f1ba7d2cb..0bf926563 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 @@ -6,12 +6,13 @@ import 'dart:async' as _i8; import 'dart:ui' as _i14; -import 'package:decimal/decimal.dart' as _i5; import 'package:local_auth/auth_strings.dart' as _i11; import 'package:local_auth/local_auth.dart' as _i10; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i7; +import 'package:stackwallet/models/balance.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; import 'package:stackwallet/services/coins/manager.dart' as _i15; @@ -62,19 +63,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -631,72 +621,24 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i8.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i8.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i8.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i8.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i8.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); - @override - _i8.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i8.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i8.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i8.Future<_i4.TransactionData>); + _i8.Future>.value(<_i16.Transaction>[]), + ) as _i8.Future>); @override - _i8.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i8.Future>.value(<_i4.UtxoObject>[]), - ) as _i8.Future>); + _i8.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i8.Future>.value(<_i16.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -782,24 +724,6 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: _i8.Future.value(''), ) as _i8.Future); @override - _i8.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); - @override _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -889,14 +813,6 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i8.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); - @override _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 1552fb249..487f2f2bf 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 @@ -6,8 +6,9 @@ import 'dart:async' as _i6; import 'dart:ui' as _i8; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i9; @@ -46,19 +47,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -374,72 +364,24 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i6.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i6.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i6.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i6.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i6.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); - @override - _i6.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i6.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i6.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i6.Future<_i3.TransactionData>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i6.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i6.Future>.value(<_i3.UtxoObject>[]), - ) as _i6.Future>); + _i6.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -525,24 +467,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: _i6.Future.value(''), ) as _i6.Future); @override - _i6.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); - @override _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -632,14 +556,6 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override - _i6.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, 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 308d6a2fa..31bda1f65 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 @@ -4,15 +4,16 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/services/locale_service.dart' as _i10; -import 'package:stackwallet/services/notes_service.dart' as _i9; +import 'package:stackwallet/services/locale_service.dart' as _i11; +import 'package:stackwallet/services/notes_service.dart' as _i10; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint @@ -47,19 +48,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -153,72 +143,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -304,24 +246,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -411,14 +335,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -442,7 +358,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -450,7 +366,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -470,7 +386,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i9.NotesService { +class MockNotesService extends _i1.Mock implements _i10.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -536,7 +452,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -544,7 +460,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -572,7 +488,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i10.LocaleService { +class MockLocaleService extends _i1.Mock implements _i11.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -594,7 +510,7 @@ class MockLocaleService extends _i1.Mock implements _i10.LocaleService { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -602,7 +518,7 @@ class MockLocaleService extends _i1.Mock implements _i10.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 024c8a8f4..161b63e1d 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 @@ -4,14 +4,15 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/services/notes_service.dart' as _i9; +import 'package:stackwallet/services/notes_service.dart' as _i10; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint @@ -46,19 +47,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -152,72 +142,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -303,24 +245,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -410,14 +334,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -441,7 +357,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -449,7 +365,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -469,7 +385,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i9.NotesService { +class MockNotesService extends _i1.Mock implements _i10.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -535,7 +451,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -543,7 +459,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 180a8f21a..7172f3e29 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 @@ -4,10 +4,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; @@ -45,19 +46,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -151,72 +141,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -302,24 +244,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -409,14 +333,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -440,7 +356,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -448,7 +364,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 3441563f9..ba206a8c6 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 @@ -4,15 +4,16 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i10; +import 'dart:ui' as _i11; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; -import 'package:decimal/decimal.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; import 'package:stackwallet/services/coins/manager.dart' as _i8; -import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/services/notes_service.dart' as _i12; import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i6; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; @@ -58,19 +59,8 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeDecimal_3 extends _i1.SmartFake implements _i5.Decimal { - _FakeDecimal_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_4 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_4( +class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { + _FakeBalance_3( Object parent, Invocation parentInvocation, ) : super( @@ -193,72 +183,24 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i5.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( + _i5.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_3( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i5.Decimal); + ) as _i5.Balance); @override - _i7.Future<_i5.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i7.Future<_i5.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i5.Decimal>.value(_FakeDecimal_3( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i5.Decimal>); - @override - _i5.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_3( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i5.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i4.TransactionData>.value(_FakeTransactionData_4( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i4.TransactionData>); + _i7.Future>.value(<_i10.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i4.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i10.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -344,24 +286,6 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -451,14 +375,6 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -482,7 +398,7 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -490,7 +406,7 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -510,7 +426,7 @@ class MockManager extends _i1.Mock implements _i8.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i12.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -576,7 +492,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -584,7 +500,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 a6391eb84..ae6a2d1f9 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 @@ -4,15 +4,16 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:ui' as _i9; -import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/models/balance.dart' as _i4; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/services/locale_service.dart' as _i10; -import 'package:stackwallet/services/notes_service.dart' as _i9; +import 'package:stackwallet/services/locale_service.dart' as _i11; +import 'package:stackwallet/services/notes_service.dart' as _i10; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint @@ -47,19 +48,8 @@ class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i4.Decimal { - _FakeDecimal_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeTransactionData_3 extends _i1.SmartFake - implements _i3.TransactionData { - _FakeTransactionData_3( +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { + _FakeBalance_2( Object parent, Invocation parentInvocation, ) : super( @@ -153,72 +143,24 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future<_i4.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( + _i4.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_2( this, - Invocation.getter(#availableBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i4.Decimal); + ) as _i4.Balance); @override - _i7.Future<_i4.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i7.Future<_i4.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i7.Future<_i4.Decimal>.value(_FakeDecimal_2( - this, - Invocation.getter(#totalBalance), - )), - ) as _i7.Future<_i4.Decimal>); - @override - _i4.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_2( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i4.Decimal); - @override - _i7.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); - @override - _i7.Future<_i3.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i7.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i7.Future<_i3.TransactionData>.value(_FakeTransactionData_3( - this, - Invocation.getter(#transactionData), - )), - ) as _i7.Future<_i3.TransactionData>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i7.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i7.Future>.value(<_i3.UtxoObject>[]), - ) as _i7.Future>); + _i7.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -304,24 +246,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(''), ) as _i7.Future); @override - _i7.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); - @override _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, @@ -411,14 +335,6 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - _i7.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); - @override _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, @@ -442,7 +358,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: _i7.Future.value(false), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -450,7 +366,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -470,7 +386,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i9.NotesService { +class MockNotesService extends _i1.Mock implements _i10.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -536,7 +452,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -544,7 +460,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -572,7 +488,7 @@ class MockNotesService extends _i1.Mock implements _i9.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i10.LocaleService { +class MockLocaleService extends _i1.Mock implements _i11.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -594,7 +510,7 @@ class MockLocaleService extends _i1.Mock implements _i10.LocaleService { returnValueForMissingStub: _i7.Future.value(), ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -602,7 +518,7 @@ class MockLocaleService extends _i1.Mock implements _i10.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index 86e18418c..d288b1992 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -3,18 +3,21 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; +import 'dart:async' as _i10; -import 'package:decimal/decimal.dart' as _i3; +import 'package:decimal/decimal.dart' as _i8; +import 'package:isar/isar.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/lelantus_coin.dart' as _i10; -import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i7; +import 'package:stackwallet/models/balance.dart' as _i7; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; +import 'package:stackwallet/models/lelantus_coin.dart' as _i13; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i4; +import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i9; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i2; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; + as _i3; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -27,9 +30,8 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeTransactionNotificationTracker_0 extends _i1.SmartFake - implements _i2.TransactionNotificationTracker { - _FakeTransactionNotificationTracker_0( +class _FakeIsar_0 extends _i1.SmartFake implements _i2.Isar { + _FakeIsar_0( Object parent, Invocation parentInvocation, ) : super( @@ -38,8 +40,9 @@ class _FakeTransactionNotificationTracker_0 extends _i1.SmartFake ); } -class _FakeDecimal_1 extends _i1.SmartFake implements _i3.Decimal { - _FakeDecimal_1( +class _FakeTransactionNotificationTracker_1 extends _i1.SmartFake + implements _i3.TransactionNotificationTracker { + _FakeTransactionNotificationTracker_1( Object parent, Invocation parentInvocation, ) : super( @@ -48,9 +51,8 @@ class _FakeDecimal_1 extends _i1.SmartFake implements _i3.Decimal { ); } -class _FakeTransactionData_2 extends _i1.SmartFake - implements _i4.TransactionData { - _FakeTransactionData_2( +class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { + _FakeFeeObject_2( Object parent, Invocation parentInvocation, ) : super( @@ -59,8 +61,8 @@ class _FakeTransactionData_2 extends _i1.SmartFake ); } -class _FakeUtxoData_3 extends _i1.SmartFake implements _i4.UtxoData { - _FakeUtxoData_3( +class _FakeElectrumX_3 extends _i1.SmartFake implements _i5.ElectrumX { + _FakeElectrumX_3( Object parent, Invocation parentInvocation, ) : super( @@ -69,29 +71,29 @@ class _FakeUtxoData_3 extends _i1.SmartFake implements _i4.UtxoData { ); } -class _FakeFeeObject_4 extends _i1.SmartFake implements _i4.FeeObject { - _FakeFeeObject_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeElectrumX_5 extends _i1.SmartFake implements _i5.ElectrumX { - _FakeElectrumX_5( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeCachedElectrumX_6 extends _i1.SmartFake +class _FakeCachedElectrumX_4 extends _i1.SmartFake implements _i6.CachedElectrumX { - _FakeCachedElectrumX_6( + _FakeCachedElectrumX_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeBalance_5 extends _i1.SmartFake implements _i7.Balance { + _FakeBalance_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeDecimal_6 extends _i1.SmartFake implements _i8.Decimal { + _FakeDecimal_6( Object parent, Invocation parentInvocation, ) : super( @@ -103,13 +105,13 @@ class _FakeCachedElectrumX_6 extends _i1.SmartFake /// A class which mocks [FiroWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { +class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { MockFiroWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i8.Timer? _timer) => super.noSuchMethod( + set timer(_i10.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -117,23 +119,31 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i4.TransactionData? _cachedTxData) => super.noSuchMethod( + _i2.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_0( + this, + Invocation.getter(#isar), + ), + ) as _i2.Isar); + @override + set isar(_i2.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @override - _i2.TransactionNotificationTracker get txTracker => (super.noSuchMethod( + _i3.TransactionNotificationTracker get txTracker => (super.noSuchMethod( Invocation.getter(#txTracker), - returnValue: _FakeTransactionNotificationTracker_0( + returnValue: _FakeTransactionNotificationTracker_1( this, Invocation.getter(#txTracker), ), - ) as _i2.TransactionNotificationTracker); + ) as _i3.TransactionNotificationTracker); @override - set txTracker(_i2.TransactionNotificationTracker? _txTracker) => + set txTracker(_i3.TransactionNotificationTracker? _txTracker) => super.noSuchMethod( Invocation.setter( #txTracker, @@ -207,110 +217,45 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: false, ) as bool); @override - _i9.Coin get coin => (super.noSuchMethod( + _i11.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, - ) as _i9.Coin); + returnValue: _i11.Coin.bitcoin, + ) as _i11.Coin); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i10.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i10.Future>.value([]), + ) as _i10.Future>); @override - _i8.Future<_i3.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( - this, - Invocation.getter(#availableBalance), - )), - ) as _i8.Future<_i3.Decimal>); - @override - _i8.Future<_i3.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i8.Future<_i3.Decimal>); - @override - _i8.Future<_i3.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( - this, - Invocation.getter(#totalBalance), - )), - ) as _i8.Future<_i3.Decimal>); - @override - _i8.Future<_i3.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i8.Future<_i3.Decimal>); - @override - _i8.Future<_i4.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i8.Future<_i4.TransactionData>.value(_FakeTransactionData_2( - this, - Invocation.getter(#transactionData), - )), - ) as _i8.Future<_i4.TransactionData>); - @override - _i8.Future<_i4.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i8.Future<_i4.UtxoData>.value(_FakeUtxoData_3( - this, - Invocation.getter(#utxoData), - )), - ) as _i8.Future<_i4.UtxoData>); - @override - _i8.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: _i8.Future>.value(<_i4.UtxoObject>[]), - ) as _i8.Future>); - @override - _i8.Future<_i4.TransactionData> get lelantusTransactionData => + _i10.Future> get lelantusTransactionData => (super.noSuchMethod( Invocation.getter(#lelantusTransactionData), returnValue: - _i8.Future<_i4.TransactionData>.value(_FakeTransactionData_2( - this, - Invocation.getter(#lelantusTransactionData), - )), - ) as _i8.Future<_i4.TransactionData>); + _i10.Future>.value(<_i12.Transaction>[]), + ) as _i10.Future>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i10.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i8.Future> get balances => (super.noSuchMethod( - Invocation.getter(#balances), - returnValue: _i8.Future>.value(<_i3.Decimal>[]), - ) as _i8.Future>); - @override - _i8.Future<_i3.Decimal> get firoPrice => (super.noSuchMethod( - Invocation.getter(#firoPrice), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( - this, - Invocation.getter(#firoPrice), - )), - ) as _i8.Future<_i3.Decimal>); - @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i10.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_4( + returnValue: _i10.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i10.Future<_i4.FeeObject>); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i10.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i10.Future.value(''), + ) as _i10.Future); + @override + _i10.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i10.Future.value(''), + ) as _i10.Future); @override String get walletName => (super.noSuchMethod( Invocation.getter(#walletName), @@ -330,11 +275,6 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: '', ) as String); @override - _i8.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); - @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), returnValue: false, @@ -342,7 +282,7 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { @override _i5.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_5( + returnValue: _FakeElectrumX_3( this, Invocation.getter(#electrumXClient), ), @@ -350,7 +290,7 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { @override _i6.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_6( + returnValue: _FakeCachedElectrumX_4( this, Invocation.getter(#cachedElectrumXClient), ), @@ -366,11 +306,43 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: false, ) as bool); @override + _i10.Future get chainHeight => (super.noSuchMethod( + Invocation.getter(#chainHeight), + returnValue: _i10.Future.value(0), + ) as _i10.Future); + @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), returnValue: 0, ) as int); @override + _i7.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_5( + this, + Invocation.getter(#balance), + ), + ) as _i7.Balance); + @override + _i7.Balance get balancePrivate => (super.noSuchMethod( + Invocation.getter(#balancePrivate), + returnValue: _FakeBalance_5( + this, + Invocation.getter(#balancePrivate), + ), + ) as _i7.Balance); + @override + _i10.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i10.Future>.value(<_i12.UTXO>[]), + ) as _i10.Future>); + @override + _i10.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), + returnValue: + _i10.Future>.value(<_i12.Transaction>[]), + ) as _i10.Future>); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -388,23 +360,23 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: false, ) as bool); @override - _i8.Future updateSentCachedTxData(Map? txData) => + _i10.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i10.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i10.Future.value(false), + ) as _i10.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -422,7 +394,7 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSendPublic({ + _i10.Future> prepareSendPublic({ required String? address, required int? satoshiAmount, Map? args, @@ -438,19 +410,20 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future confirmSendPublic({dynamic txData}) => (super.noSuchMethod( + _i10.Future confirmSendPublic({dynamic txData}) => + (super.noSuchMethod( Invocation.method( #confirmSendPublic, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i10.Future.value(''), + ) as _i10.Future); @override - _i8.Future> prepareSend({ + _i10.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -466,36 +439,18 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i10.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); - @override - _i8.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i10.Future.value(''), + ) as _i10.Future); @override int estimateTxFee({ required int? vSize, @@ -519,7 +474,7 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i4.UtxoObject>? utxos, + List<_i12.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -535,19 +490,19 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { }, )); @override - _i8.Future> fetchBuildTxData( - List<_i4.UtxoObject>? utxosToUse) => + _i10.Future> fetchBuildTxData( + List<_i12.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future> buildTransaction({ - required List<_i4.UtxoObject>? utxosToUse, + _i10.Future> buildTransaction({ + required List<_i12.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -564,107 +519,100 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i10.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i10.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i10.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i10.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i10.Future.value(false), + ) as _i10.Future); @override - _i8.Future getAllTxsToWatch( - _i4.TransactionData? txData, - _i4.TransactionData? lTxData, - ) => - (super.noSuchMethod( + _i10.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [ - txData, - lTxData, - ], + [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i10.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - List> getLelantusCoinMap() => + List> getLelantusCoinMap() => (super.noSuchMethod( Invocation.method( #getLelantusCoinMap, [], ), - returnValue: >[], - ) as List>); + returnValue: >[], + ) as List>); @override - _i8.Future anonymizeAllPublicFunds() => (super.noSuchMethod( + _i10.Future anonymizeAllPublicFunds() => (super.noSuchMethod( Invocation.method( #anonymizeAllPublicFunds, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future>> createMintsFromAmount(int? total) => + _i10.Future>> createMintsFromAmount(int? total) => (super.noSuchMethod( Invocation.method( #createMintsFromAmount, [total], ), - returnValue: _i8.Future>>.value( + returnValue: _i10.Future>>.value( >[]), - ) as _i8.Future>>); + ) as _i10.Future>>); @override - _i8.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( + _i10.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( Invocation.method( #submitHexToNetwork, [hex], ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i10.Future.value(''), + ) as _i10.Future); @override - _i8.Future> buildMintTransaction( - List<_i4.UtxoObject>? utxosToUse, + _i10.Future> buildMintTransaction( + List<_i12.UTXO>? utxosToUse, int? satoshisPerRecipient, List>? mintsMap, ) => @@ -678,29 +626,29 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { ], ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future checkReceivingAddressForTransactions() => + _i10.Future checkReceivingAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkReceivingAddressForTransactions, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future checkChangeAddressForTransactions() => (super.noSuchMethod( + _i10.Future checkChangeAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkChangeAddressForTransactions, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future fillAddresses( + _i10.Future fillAddresses( String? suppliedMnemonic, { int? perBatch = 50, int? numberOfThreads = 4, @@ -714,37 +662,11 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { #numberOfThreads: numberOfThreads, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future incrementAddressIndexForChain(int? chain) => - (super.noSuchMethod( - Invocation.method( - #incrementAddressIndexForChain, - [chain], - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future addToAddressesArrayForChain( - String? address, - int? chain, - ) => - (super.noSuchMethod( - Invocation.method( - #addToAddressesArrayForChain, - [ - address, - chain, - ], - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future fullRescan( + _i10.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -756,11 +678,11 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future recoverFromMnemonic({ + _i10.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -777,71 +699,73 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future> getSetDataMap(int? latestSetId) => + _i10.Future> getSetDataMap(int? latestSetId) => (super.noSuchMethod( Invocation.method( #getSetDataMap, [latestSetId], ), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future>> fetchAnonymitySets() => + _i10.Future>> fetchAnonymitySets() => (super.noSuchMethod( Invocation.method( #fetchAnonymitySets, [], ), - returnValue: _i8.Future>>.value( + returnValue: _i10.Future>>.value( >[]), - ) as _i8.Future>>); + ) as _i10.Future>>); @override - _i8.Future getLatestSetId() => (super.noSuchMethod( + _i10.Future getLatestSetId() => (super.noSuchMethod( Invocation.method( #getLatestSetId, [], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i8.Future> getUsedCoinSerials() => (super.noSuchMethod( + _i10.Future> getUsedCoinSerials() => (super.noSuchMethod( Invocation.method( #getUsedCoinSerials, [], ), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i10.Future>.value([]), + ) as _i10.Future>); @override - _i8.Future exit() => (super.noSuchMethod( + _i10.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future getCoinsToJoinSplit(int? required) => (super.noSuchMethod( + _i10.Future getCoinsToJoinSplit(int? required) => + (super.noSuchMethod( Invocation.method( #getCoinsToJoinSplit, [required], ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future estimateJoinSplitFee(int? spendAmount) => (super.noSuchMethod( + _i10.Future estimateJoinSplitFee(int? spendAmount) => + (super.noSuchMethod( Invocation.method( #estimateJoinSplitFee, [spendAmount], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i8.Future estimateFeeFor( + _i10.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -853,10 +777,10 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i8.Future estimateFeeForPublic( + _i10.Future estimateFeeForPublic( int? satoshiAmount, int? feeRate, ) => @@ -868,8 +792,8 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override int roughFeeEstimate( int? inputCount, @@ -888,31 +812,29 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i10.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i8.Future>> fastFetch(List? allTxHashes) => + _i10.Future>> fastFetch( + List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i8.Future>>.value( + returnValue: _i10.Future>>.value( >[]), - ) as _i8.Future>>); + ) as _i10.Future>>); @override - _i8.Future> getJMintTransactions( + _i10.Future> getJMintTransactions( _i6.CachedElectrumX? cachedClient, List? transactions, - String? currency, - _i9.Coin? coin, - _i3.Decimal? currentPrice, - String? locale, + _i11.Coin? coin, ) => (super.noSuchMethod( Invocation.method( @@ -920,51 +842,59 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { [ cachedClient, transactions, - currency, coin, - currentPrice, - locale, ], ), returnValue: - _i8.Future>.value(<_i4.Transaction>[]), - ) as _i8.Future>); + _i10.Future>.value(<_i12.Transaction>[]), + ) as _i10.Future>); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i10.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i10.Future.value(false), + ) as _i10.Future); @override - _i8.Future<_i3.Decimal> availablePrivateBalance() => (super.noSuchMethod( + _i8.Decimal availablePrivateBalance() => (super.noSuchMethod( Invocation.method( #availablePrivateBalance, [], ), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( + returnValue: _FakeDecimal_6( this, Invocation.method( #availablePrivateBalance, [], ), - )), - ) as _i8.Future<_i3.Decimal>); + ), + ) as _i8.Decimal); @override - _i8.Future<_i3.Decimal> availablePublicBalance() => (super.noSuchMethod( + _i8.Decimal availablePublicBalance() => (super.noSuchMethod( Invocation.method( #availablePublicBalance, [], ), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( + returnValue: _FakeDecimal_6( this, Invocation.method( #availablePublicBalance, [], ), - )), - ) as _i8.Future<_i3.Decimal>); + ), + ) as _i8.Decimal); + @override + _i10.Future updateStoredChainHeight({required int? newHeight}) => + (super.noSuchMethod( + Invocation.method( + #updateStoredChainHeight, + [], + {#newHeight: newHeight}, + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); } /// A class which mocks [ElectrumX]. @@ -1012,7 +942,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i8.Future request({ + _i10.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -1031,10 +961,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future>> batchRequest({ + _i10.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -1051,11 +981,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i8.Future>>.value( + returnValue: _i10.Future>>.value( >[]), - ) as _i8.Future>>); + ) as _i10.Future>>); @override - _i8.Future ping({ + _i10.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -1068,10 +998,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i10.Future.value(false), + ) as _i10.Future); @override - _i8.Future> getBlockHeadTip({String? requestID}) => + _i10.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -1079,10 +1009,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future> getServerFeatures({String? requestID}) => + _i10.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -1090,10 +1020,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future broadcastTransaction({ + _i10.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -1106,10 +1036,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i10.Future.value(''), + ) as _i10.Future); @override - _i8.Future> getBalance({ + _i10.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -1123,10 +1053,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future>> getHistory({ + _i10.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -1139,11 +1069,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i8.Future>>.value( + returnValue: _i10.Future>>.value( >[]), - ) as _i8.Future>>); + ) as _i10.Future>>); @override - _i8.Future>>> getBatchHistory( + _i10.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -1151,11 +1081,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i8.Future>>>.value( + returnValue: _i10.Future>>>.value( >>{}), - ) as _i8.Future>>>); + ) as _i10.Future>>>); @override - _i8.Future>> getUTXOs({ + _i10.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -1168,11 +1098,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i8.Future>>.value( + returnValue: _i10.Future>>.value( >[]), - ) as _i8.Future>>); + ) as _i10.Future>>); @override - _i8.Future>>> getBatchUTXOs( + _i10.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -1180,11 +1110,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i8.Future>>>.value( + returnValue: _i10.Future>>>.value( >>{}), - ) as _i8.Future>>>); + ) as _i10.Future>>>); @override - _i8.Future> getTransaction({ + _i10.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -1200,10 +1130,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future> getAnonymitySet({ + _i10.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -1219,10 +1149,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future getMintData({ + _i10.Future getMintData({ dynamic mints, String? requestID, }) => @@ -1235,10 +1165,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i10.Future.value(), + ) as _i10.Future); @override - _i8.Future> getUsedCoinSerials({ + _i10.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -1252,19 +1182,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i10.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i8.Future> getFeeRate({String? requestID}) => + _i10.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -1272,10 +1202,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i8.Future<_i3.Decimal> estimateFee({ + _i10.Future<_i8.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -1288,7 +1218,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( + returnValue: _i10.Future<_i8.Decimal>.value(_FakeDecimal_6( this, Invocation.method( #estimateFee, @@ -1299,15 +1229,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i8.Future<_i3.Decimal>); + ) as _i10.Future<_i8.Decimal>); @override - _i8.Future<_i3.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i10.Future<_i8.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i8.Future<_i3.Decimal>.value(_FakeDecimal_1( + returnValue: _i10.Future<_i8.Decimal>.value(_FakeDecimal_6( this, Invocation.method( #relayFee, @@ -1315,5 +1245,5 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i8.Future<_i3.Decimal>); + ) as _i10.Future<_i8.Decimal>); } diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index c5fef27dc..0def83807 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -3,30 +3,32 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i16; -import 'dart:ui' as _i18; +import 'dart:async' as _i17; +import 'dart:ui' as _i19; -import 'package:decimal/decimal.dart' as _i9; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; -import 'package:stackwallet/models/models.dart' as _i8; -import 'package:stackwallet/models/node_model.dart' as _i21; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i19; -import 'package:stackwallet/services/coins/coin_service.dart' as _i13; +import 'package:stackwallet/models/balance.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i21; +import 'package:stackwallet/models/node_model.dart' as _i23; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; +import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i20; +import 'package:stackwallet/services/locale_service.dart' as _i22; 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 _i14; +import 'package:stackwallet/services/wallets.dart' as _i15; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i12; -import 'package:stackwallet/utilities/prefs.dart' as _i17; + as _i13; +import 'package:stackwallet/utilities/prefs.dart' as _i18; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -92,8 +94,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { - _FakeUtxoData_5( +class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { + _FakeIsar_5( Object parent, Invocation parentInvocation, ) : super( @@ -102,8 +104,8 @@ class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { ); } -class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { - _FakeDecimal_6( +class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { + _FakeFeeObject_6( Object parent, Invocation parentInvocation, ) : super( @@ -112,8 +114,8 @@ class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { ); } -class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { - _FakeFeeObject_7( +class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { + _FakeElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -122,30 +124,9 @@ class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { ); } -class _FakeTransactionData_8 extends _i1.SmartFake - implements _i8.TransactionData { - _FakeTransactionData_8( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeElectrumX_9 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeCachedElectrumX_10 extends _i1.SmartFake +class _FakeCachedElectrumX_8 extends _i1.SmartFake implements _i11.CachedElectrumX { - _FakeCachedElectrumX_10( + _FakeCachedElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -154,9 +135,19 @@ class _FakeCachedElectrumX_10 extends _i1.SmartFake ); } -class _FakeElectrumXNode_11 extends _i1.SmartFake +class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { + _FakeBalance_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i10.ElectrumXNode { - _FakeElectrumXNode_11( + _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, ) : super( @@ -165,9 +156,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeSecureStorageInterface_12 extends _i1.SmartFake - implements _i12.SecureStorageInterface { - _FakeSecureStorageInterface_12( +class _FakeSecureStorageInterface_11 extends _i1.SmartFake + implements _i13.SecureStorageInterface { + _FakeSecureStorageInterface_11( Object parent, Invocation parentInvocation, ) : super( @@ -176,9 +167,9 @@ class _FakeSecureStorageInterface_12 extends _i1.SmartFake ); } -class _FakeCoinServiceAPI_13 extends _i1.SmartFake - implements _i13.CoinServiceAPI { - _FakeCoinServiceAPI_13( +class _FakeCoinServiceAPI_12 extends _i1.SmartFake + implements _i14.CoinServiceAPI { + _FakeCoinServiceAPI_12( Object parent, Invocation parentInvocation, ) : super( @@ -190,7 +181,7 @@ class _FakeCoinServiceAPI_13 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 _i14.Wallets { +class MockWallets extends _i1.Mock implements _i15.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -257,7 +248,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i15.Coin? coin}) => + List getWalletIdsFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -267,18 +258,18 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValue: [], ) as List); @override - Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> + Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Coin, + returnValue: <_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, - ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); + ) as Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i15.Coin? coin) => + _i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -342,17 +333,17 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - _i16.Future load(_i17.Prefs? prefs) => (super.noSuchMethod( + _i17.Future load(_i18.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future loadAfterStackRestore( - _i17.Prefs? prefs, + _i17.Future loadAfterStackRestore( + _i18.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -363,11 +354,11 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { managers, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -375,7 +366,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -401,19 +392,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i16.Future> get walletNames => + _i17.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i16.Future>.value( + returnValue: _i17.Future>.value( {}), - ) as _i16.Future>); + ) as _i17.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future renameWallet({ + _i17.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -428,13 +419,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future addExistingStackWallet({ + _i17.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -448,13 +439,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addNewWallet({ + _i17.Future addNewWallet({ required String? name, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -467,46 +458,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i17.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future saveFavoriteWalletIds(List? walletIds) => + _i17.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future moveFavorite({ + _i17.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -519,48 +510,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i17.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i17.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isMnemonicVerified({required String? walletId}) => + _i17.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future setMnemonicVerified({required String? walletId}) => + _i17.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future deleteWallet( + _i17.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -572,20 +563,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future refreshWallets(bool? shouldNotifyListeners) => + _i17.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -593,7 +584,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -621,13 +612,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 _i19.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i16.Timer? _timer) => super.noSuchMethod( + set timer(_i17.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -652,19 +643,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - List<_i8.UtxoObject> get outputsList => (super.noSuchMethod( - Invocation.getter(#outputsList), - returnValue: <_i8.UtxoObject>[], - ) as List<_i8.UtxoObject>); - @override - set outputsList(List<_i8.UtxoObject>? _outputsList) => super.noSuchMethod( - Invocation.setter( - #outputsList, - _outputsList, - ), - returnValueForMissingStub: null, - ); - @override bool get longMutex => (super.noSuchMethod( Invocation.getter(#longMutex), returnValue: false, @@ -691,10 +669,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i8.TransactionData? _cachedTxData) => super.noSuchMethod( + _i8.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#isar), + ), + ) as _i8.Isar); + @override + set isar(_i8.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @@ -725,104 +711,59 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override - _i16.Future<_i8.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i16.Future<_i8.UtxoData>.value(_FakeUtxoData_5( - this, - Invocation.getter(#utxoData), - )), - ) as _i16.Future<_i8.UtxoData>); - @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future get currentLegacyReceivingAddress => (super.noSuchMethod( - Invocation.getter(#currentLegacyReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future get currentReceivingAddressP2SH => (super.noSuchMethod( - Invocation.getter(#currentReceivingAddressP2SH), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + _i17.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future get chainHeight => (super.noSuchMethod( + _i17.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -852,15 +793,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); - @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), returnValue: '', @@ -881,7 +813,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { @override _i10.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_9( + returnValue: _FakeElectrumX_7( this, Invocation.getter(#electrumXClient), ), @@ -889,12 +821,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { @override _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_10( + returnValue: _FakeCachedElectrumX_8( this, Invocation.getter(#cachedElectrumXClient), ), ) as _i11.CachedElectrumX); @override + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( + this, + Invocation.getter(#balance), + ), + ) as _i12.Balance); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -904,37 +844,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateStoredChainHeight({required int? newHeight}) => + _i17.Future updateStoredChainHeight({required int? newHeight}) => (super.noSuchMethod( Invocation.method( #updateStoredChainHeight, [], {#newHeight: newHeight}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i19.DerivePathType addressType({required String? address}) => + _i20.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i19.DerivePathType.bip44, - ) as _i19.DerivePathType); + returnValue: _i20.DerivePathType.bip44, + ) as _i20.DerivePathType); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -951,48 +891,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTransactionCacheEarly(List? allAddresses) => + _i17.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i17.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getAllTxsToWatch(_i8.TransactionData? txData) => - (super.noSuchMethod( + _i17.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [txData], + [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1008,44 +947,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1063,33 +984,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1099,36 +1020,36 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i16.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i17.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i16.Future<_i10.ElectrumXNode>); + ) as _i17.Future<_i10.ElectrumXNode>); @override - _i16.Future addDerivation({ + _i17.Future addDerivation({ required int? chain, required String? address, required String? pubKey, required String? wif, - required _i19.DerivePathType? derivePathType, + required _i20.DerivePathType? derivePathType, }) => (super.noSuchMethod( Invocation.method( @@ -1142,13 +1063,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #derivePathType: derivePathType, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addDerivations({ + _i17.Future addDerivations({ required int? chain, - required _i19.DerivePathType? derivePathType, + required _i20.DerivePathType? derivePathType, required Map? derivationsToAdd, }) => (super.noSuchMethod( @@ -1161,50 +1082,50 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #derivationsToAdd: derivationsToAdd, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTxCount({required String? address}) => - (super.noSuchMethod( - Invocation.method( - #getTxCount, - [], - {#address: address}, - ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); - @override - _i16.Future checkCurrentReceivingAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentReceivingAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future checkCurrentChangeAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentChangeAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future>> fastFetch( + _i17.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i16.Future>>.value( + returnValue: _i17.Future>>.value( >[]), - ) as _i16.Future>>); + ) as _i17.Future>>); + @override + _i17.Future getTxCount({required String? address}) => + (super.noSuchMethod( + Invocation.method( + #getTxCount, + [], + {#address: address}, + ), + returnValue: _i17.Future.value(0), + ) as _i17.Future); + @override + _i17.Future checkCurrentReceivingAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentReceivingAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future checkCurrentChangeAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentChangeAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override int estimateTxFee({ required int? vSize, @@ -1228,7 +1149,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i8.UtxoObject>? utxos, + List<_i21.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1244,19 +1165,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, )); @override - _i16.Future> fetchBuildTxData( - List<_i8.UtxoObject>? utxosToUse) => + _i17.Future> fetchBuildTxData( + List<_i21.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future> buildTransaction({ - required List<_i8.UtxoObject>? utxosToUse, + _i17.Future> buildTransaction({ + required List<_i21.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -1273,10 +1194,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1288,11 +1209,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1304,8 +1225,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int roughFeeEstimate( int? inputCount, @@ -1324,27 +1245,27 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i17.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i20.LocaleService { +class MockLocaleService extends _i1.Mock implements _i22.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1360,17 +1281,17 @@ class MockLocaleService extends _i1.Mock implements _i20.LocaleService { returnValue: false, ) as bool); @override - _i16.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i17.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1378,7 +1299,7 @@ class MockLocaleService extends _i1.Mock implements _i20.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1408,41 +1329,41 @@ class MockLocaleService extends _i1.Mock implements _i20.LocaleService { /// See the documentation for Mockito's code generation for more information. class MockNodeService extends _i1.Mock implements _i3.NodeService { @override - _i12.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( + _i13.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_12( + returnValue: _FakeSecureStorageInterface_11( this, Invocation.getter(#secureStorageInterface), ), - ) as _i12.SecureStorageInterface); + ) as _i13.SecureStorageInterface); @override - List<_i21.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i21.NodeModel>[], - ) as List<_i21.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - List<_i21.NodeModel> get nodes => (super.noSuchMethod( + List<_i23.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i21.NodeModel>[], - ) as List<_i21.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future updateDefaults() => (super.noSuchMethod( + _i17.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setPrimaryNodeFor({ - required _i15.Coin? coin, - required _i21.NodeModel? node, + _i17.Future setPrimaryNodeFor({ + required _i16.Coin? coin, + required _i23.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1455,44 +1376,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i21.NodeModel? getPrimaryNodeFor({required _i15.Coin? coin}) => + _i23.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i21.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i21.NodeModel> getNodesFor(_i15.Coin? coin) => (super.noSuchMethod( + List<_i23.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i21.NodeModel>[], - ) as List<_i21.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - _i21.NodeModel? getNodeById({required String? id}) => + _i23.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i21.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i21.NodeModel> failoverNodesFor({required _i15.Coin? coin}) => + List<_i23.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i21.NodeModel>[], - ) as List<_i21.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - _i16.Future add( - _i21.NodeModel? node, + _i17.Future add( + _i23.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1505,11 +1426,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future delete( + _i17.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -1521,11 +1442,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setEnabledState( + _i17.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -1539,12 +1460,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future edit( - _i21.NodeModel? editedNode, + _i17.Future edit( + _i23.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -1557,20 +1478,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateCommunityNodes() => (super.noSuchMethod( + _i17.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1578,7 +1499,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1621,23 +1542,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i13.CoinServiceAPI get wallet => (super.noSuchMethod( + _i14.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_13( + returnValue: _FakeCoinServiceAPI_12( this, Invocation.getter(#wallet), ), - ) as _i13.CoinServiceAPI); + ) as _i14.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1670,91 +1591,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i9.Decimal); + ) as _i12.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i9.Decimal); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -1774,10 +1646,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -1794,14 +1666,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -1811,7 +1683,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1827,45 +1699,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1875,33 +1729,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1918,20 +1772,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exitCurrentWallet() => (super.noSuchMethod( + _i17.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1943,19 +1797,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); - @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1967,18 +1813,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1986,7 +1832,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2006,7 +1852,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 _i13.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -2017,10 +1863,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -2053,75 +1899,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); + Invocation.getter(#balance), + ), + ) as _i12.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2141,10 +1954,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -2161,7 +1974,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: 0, ) as int); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -2177,54 +1990,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2234,15 +2029,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -2259,38 +2054,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2302,11 +2097,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -2318,24 +2113,24 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } 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 e60f39244..47681f0c0 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,26 +3,28 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i15; -import 'dart:ui' as _i17; +import 'dart:async' as _i16; +import 'dart:ui' as _i18; -import 'package:decimal/decimal.dart' as _i9; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; -import 'package:stackwallet/models/models.dart' as _i8; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i18; -import 'package:stackwallet/services/coins/coin_service.dart' as _i12; +import 'package:stackwallet/models/balance.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i20; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i19; +import 'package:stackwallet/services/coins/coin_service.dart' as _i13; 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 _i7; -import 'package:stackwallet/services/wallets.dart' as _i13; +import 'package:stackwallet/services/wallets.dart' as _i14; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i14; -import 'package:stackwallet/utilities/prefs.dart' as _i16; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; +import 'package:stackwallet/utilities/prefs.dart' as _i17; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -88,8 +90,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { - _FakeUtxoData_5( +class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { + _FakeIsar_5( Object parent, Invocation parentInvocation, ) : super( @@ -98,8 +100,8 @@ class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { ); } -class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { - _FakeDecimal_6( +class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { + _FakeFeeObject_6( Object parent, Invocation parentInvocation, ) : super( @@ -108,8 +110,8 @@ class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { ); } -class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { - _FakeFeeObject_7( +class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { + _FakeElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -118,30 +120,9 @@ class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { ); } -class _FakeTransactionData_8 extends _i1.SmartFake - implements _i8.TransactionData { - _FakeTransactionData_8( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeElectrumX_9 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeCachedElectrumX_10 extends _i1.SmartFake +class _FakeCachedElectrumX_8 extends _i1.SmartFake implements _i11.CachedElectrumX { - _FakeCachedElectrumX_10( + _FakeCachedElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -150,9 +131,19 @@ class _FakeCachedElectrumX_10 extends _i1.SmartFake ); } -class _FakeElectrumXNode_11 extends _i1.SmartFake +class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { + _FakeBalance_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i10.ElectrumXNode { - _FakeElectrumXNode_11( + _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, ) : super( @@ -161,9 +152,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeCoinServiceAPI_12 extends _i1.SmartFake - implements _i12.CoinServiceAPI { - _FakeCoinServiceAPI_12( +class _FakeCoinServiceAPI_11 extends _i1.SmartFake + implements _i13.CoinServiceAPI { + _FakeCoinServiceAPI_11( Object parent, Invocation parentInvocation, ) : super( @@ -175,7 +166,7 @@ class _FakeCoinServiceAPI_12 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 _i13.Wallets { +class MockWallets extends _i1.Mock implements _i14.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -242,7 +233,7 @@ class MockWallets extends _i1.Mock implements _i13.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i14.Coin? coin}) => + List getWalletIdsFor({required _i15.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -252,18 +243,18 @@ class MockWallets extends _i1.Mock implements _i13.Wallets { returnValue: [], ) as List); @override - Map<_i14.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> + Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i14.Coin, + returnValue: <_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, - ) as Map<_i14.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); + ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i14.Coin? coin) => + _i15.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -327,17 +318,17 @@ class MockWallets extends _i1.Mock implements _i13.Wallets { returnValueForMissingStub: null, ); @override - _i15.Future load(_i16.Prefs? prefs) => (super.noSuchMethod( + _i16.Future load(_i17.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future loadAfterStackRestore( - _i16.Prefs? prefs, + _i16.Future loadAfterStackRestore( + _i17.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -348,11 +339,11 @@ class MockWallets extends _i1.Mock implements _i13.Wallets { managers, ], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -360,7 +351,7 @@ class MockWallets extends _i1.Mock implements _i13.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -386,19 +377,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i15.Future> get walletNames => + _i16.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i15.Future>.value( + returnValue: _i16.Future>.value( {}), - ) as _i15.Future>); + ) as _i16.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i15.Future renameWallet({ + _i16.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -413,13 +404,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - _i15.Future addExistingStackWallet({ + _i16.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i14.Coin? coin, + required _i15.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -433,13 +424,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future addNewWallet({ + _i16.Future addNewWallet({ required String? name, - required _i14.Coin? coin, + required _i15.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -452,46 +443,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i16.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i15.Future>.value([]), - ) as _i15.Future>); + returnValue: _i16.Future>.value([]), + ) as _i16.Future>); @override - _i15.Future saveFavoriteWalletIds(List? walletIds) => + _i16.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i16.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i16.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future moveFavorite({ + _i16.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -504,48 +495,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i16.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - _i15.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i16.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future isMnemonicVerified({required String? walletId}) => + _i16.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - _i15.Future setMnemonicVerified({required String? walletId}) => + _i16.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future deleteWallet( + _i16.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -557,20 +548,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override - _i15.Future refreshWallets(bool? shouldNotifyListeners) => + _i16.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -578,7 +569,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -606,13 +597,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 _i18.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i15.Timer? _timer) => super.noSuchMethod( + set timer(_i16.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -637,19 +628,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - List<_i8.UtxoObject> get outputsList => (super.noSuchMethod( - Invocation.getter(#outputsList), - returnValue: <_i8.UtxoObject>[], - ) as List<_i8.UtxoObject>); - @override - set outputsList(List<_i8.UtxoObject>? _outputsList) => super.noSuchMethod( - Invocation.setter( - #outputsList, - _outputsList, - ), - returnValueForMissingStub: null, - ); - @override bool get longMutex => (super.noSuchMethod( Invocation.getter(#longMutex), returnValue: false, @@ -676,10 +654,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i8.TransactionData? _cachedTxData) => super.noSuchMethod( + _i8.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#isar), + ), + ) as _i8.Isar); + @override + set isar(_i8.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @@ -710,104 +696,59 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValue: false, ) as bool); @override - _i14.Coin get coin => (super.noSuchMethod( + _i15.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i14.Coin.bitcoin, - ) as _i14.Coin); + returnValue: _i15.Coin.bitcoin, + ) as _i15.Coin); @override - _i15.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i15.Future>.value([]), - ) as _i15.Future>); + _i16.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i16.Future>.value(<_i20.UTXO>[]), + ) as _i16.Future>); @override - _i15.Future<_i8.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i15.Future<_i8.UtxoData>.value(_FakeUtxoData_5( - this, - Invocation.getter(#utxoData), - )), - ) as _i15.Future<_i8.UtxoData>); - @override - _i15.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), + _i16.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i15.Future>.value(<_i8.UtxoObject>[]), - ) as _i15.Future>); + _i16.Future>.value(<_i20.Transaction>[]), + ) as _i16.Future>); @override - _i15.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#availableBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future get currentReceivingAddress => (super.noSuchMethod( + _i16.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i15.Future.value(''), - ) as _i15.Future); + returnValue: _i16.Future.value(''), + ) as _i16.Future); @override - _i15.Future get currentLegacyReceivingAddress => (super.noSuchMethod( - Invocation.getter(#currentLegacyReceivingAddress), - returnValue: _i15.Future.value(''), - ) as _i15.Future); - @override - _i15.Future get currentReceivingAddressP2SH => (super.noSuchMethod( - Invocation.getter(#currentReceivingAddressP2SH), - returnValue: _i15.Future.value(''), - ) as _i15.Future); + _i16.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i16.Future.value(''), + ) as _i16.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i15.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i15.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i15.Future<_i8.FeeObject>); + ) as _i16.Future<_i9.FeeObject>); @override - _i15.Future get maxFee => (super.noSuchMethod( + _i16.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override - _i15.Future> get mnemonic => (super.noSuchMethod( + _i16.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i15.Future>.value([]), - ) as _i15.Future>); + returnValue: _i16.Future>.value([]), + ) as _i16.Future>); @override - _i15.Future get chainHeight => (super.noSuchMethod( + _i16.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -837,15 +778,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValue: false, ) as bool); @override - _i15.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i15.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i15.Future<_i8.TransactionData>); - @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), returnValue: '', @@ -866,7 +798,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { @override _i10.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_9( + returnValue: _FakeElectrumX_7( this, Invocation.getter(#electrumXClient), ), @@ -874,12 +806,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { @override _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_10( + returnValue: _FakeCachedElectrumX_8( this, Invocation.getter(#cachedElectrumXClient), ), ) as _i11.CachedElectrumX); @override + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( + this, + Invocation.getter(#balance), + ), + ) as _i12.Balance); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -889,37 +829,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i15.Future exit() => (super.noSuchMethod( + _i16.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future updateStoredChainHeight({required int? newHeight}) => + _i16.Future updateStoredChainHeight({required int? newHeight}) => (super.noSuchMethod( Invocation.method( #updateStoredChainHeight, [], {#newHeight: newHeight}, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i18.DerivePathType addressType({required String? address}) => + _i19.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i18.DerivePathType.bip44, - ) as _i18.DerivePathType); + returnValue: _i19.DerivePathType.bip44, + ) as _i19.DerivePathType); @override - _i15.Future recoverFromMnemonic({ + _i16.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -936,48 +876,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { #height: height, }, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future getTransactionCacheEarly(List? allAddresses) => + _i16.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i16.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - _i15.Future getAllTxsToWatch(_i8.TransactionData? txData) => - (super.noSuchMethod( + _i16.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [txData], + [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future refresh() => (super.noSuchMethod( + _i16.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future> prepareSend({ + _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -993,44 +932,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { }, ), returnValue: - _i15.Future>.value({}), - ) as _i15.Future>); + _i16.Future>.value({}), + ) as _i16.Future>); @override - _i15.Future confirmSend({required Map? txData}) => + _i16.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i15.Future.value(''), - ) as _i15.Future); + returnValue: _i16.Future.value(''), + ) as _i16.Future); @override - _i15.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i15.Future.value(''), - ) as _i15.Future); - @override - _i15.Future testNetworkConnection() => (super.noSuchMethod( + _i16.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1048,33 +969,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i15.Future initializeNew() => (super.noSuchMethod( + _i16.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future initializeExisting() => (super.noSuchMethod( + _i16.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future updateSentCachedTxData(Map? txData) => + _i16.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1084,36 +1005,36 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValue: false, ) as bool); @override - _i15.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i16.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i15.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i16.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i15.Future<_i10.ElectrumXNode>); + ) as _i16.Future<_i10.ElectrumXNode>); @override - _i15.Future addDerivation({ + _i16.Future addDerivation({ required int? chain, required String? address, required String? pubKey, required String? wif, - required _i18.DerivePathType? derivePathType, + required _i19.DerivePathType? derivePathType, }) => (super.noSuchMethod( Invocation.method( @@ -1127,13 +1048,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { #derivePathType: derivePathType, }, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future addDerivations({ + _i16.Future addDerivations({ required int? chain, - required _i18.DerivePathType? derivePathType, + required _i19.DerivePathType? derivePathType, required Map? derivationsToAdd, }) => (super.noSuchMethod( @@ -1146,50 +1067,50 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { #derivationsToAdd: derivationsToAdd, }, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future getTxCount({required String? address}) => - (super.noSuchMethod( - Invocation.method( - #getTxCount, - [], - {#address: address}, - ), - returnValue: _i15.Future.value(0), - ) as _i15.Future); - @override - _i15.Future checkCurrentReceivingAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentReceivingAddressesForTransactions, - [], - ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); - @override - _i15.Future checkCurrentChangeAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentChangeAddressesForTransactions, - [], - ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); - @override - _i15.Future>> fastFetch( + _i16.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i15.Future>>.value( + returnValue: _i16.Future>>.value( >[]), - ) as _i15.Future>>); + ) as _i16.Future>>); + @override + _i16.Future getTxCount({required String? address}) => + (super.noSuchMethod( + Invocation.method( + #getTxCount, + [], + {#address: address}, + ), + returnValue: _i16.Future.value(0), + ) as _i16.Future); + @override + _i16.Future checkCurrentReceivingAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentReceivingAddressesForTransactions, + [], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); + @override + _i16.Future checkCurrentChangeAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentChangeAddressesForTransactions, + [], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override int estimateTxFee({ required int? vSize, @@ -1213,7 +1134,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i8.UtxoObject>? utxos, + List<_i20.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1229,19 +1150,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { }, )); @override - _i15.Future> fetchBuildTxData( - List<_i8.UtxoObject>? utxosToUse) => + _i16.Future> fetchBuildTxData( + List<_i20.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i15.Future>.value({}), - ) as _i15.Future>); + _i16.Future>.value({}), + ) as _i16.Future>); @override - _i15.Future> buildTransaction({ - required List<_i8.UtxoObject>? utxosToUse, + _i16.Future> buildTransaction({ + required List<_i20.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -1258,10 +1179,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { }, ), returnValue: - _i15.Future>.value({}), - ) as _i15.Future>); + _i16.Future>.value({}), + ) as _i16.Future>); @override - _i15.Future fullRescan( + _i16.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1273,11 +1194,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future estimateFeeFor( + _i16.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1289,8 +1210,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { feeRate, ], ), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override int roughFeeEstimate( int? inputCount, @@ -1309,21 +1230,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i16.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override - _i15.Future generateNewAddress() => (super.noSuchMethod( + _i16.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); } /// A class which mocks [Manager]. @@ -1344,23 +1265,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i12.CoinServiceAPI get wallet => (super.noSuchMethod( + _i13.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_12( + returnValue: _FakeCoinServiceAPI_11( this, Invocation.getter(#wallet), ), - ) as _i12.CoinServiceAPI); + ) as _i13.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i14.Coin get coin => (super.noSuchMethod( + _i15.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i14.Coin.bitcoin, - ) as _i14.Coin); + returnValue: _i15.Coin.bitcoin, + ) as _i15.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1393,91 +1314,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i15.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i15.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i15.Future<_i8.FeeObject>); + ) as _i16.Future<_i9.FeeObject>); @override - _i15.Future get maxFee => (super.noSuchMethod( + _i16.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override - _i15.Future get currentReceivingAddress => (super.noSuchMethod( + _i16.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i15.Future.value(''), - ) as _i15.Future); + returnValue: _i16.Future.value(''), + ) as _i16.Future); @override - _i15.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i9.Decimal); + ) as _i12.Balance); @override - _i15.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i9.Decimal); - @override - _i15.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i15.Future>.value([]), - ) as _i15.Future>); - @override - _i15.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i16.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i15.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i15.Future<_i8.TransactionData>); + _i16.Future>.value(<_i20.Transaction>[]), + ) as _i16.Future>); @override - _i15.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i15.Future>.value(<_i8.UtxoObject>[]), - ) as _i15.Future>); + _i16.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i16.Future>.value(<_i20.UTXO>[]), + ) as _i16.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -1497,10 +1369,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i15.Future> get mnemonic => (super.noSuchMethod( + _i16.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i15.Future>.value([]), - ) as _i15.Future>); + returnValue: _i16.Future>.value([]), + ) as _i16.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -1517,14 +1389,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i15.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -1534,7 +1406,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i15.Future> prepareSend({ + _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1550,45 +1422,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i15.Future>.value({}), - ) as _i15.Future>); + _i16.Future>.value({}), + ) as _i16.Future>); @override - _i15.Future confirmSend({required Map? txData}) => + _i16.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i15.Future.value(''), - ) as _i15.Future); + returnValue: _i16.Future.value(''), + ) as _i16.Future); @override - _i15.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i15.Future.value(''), - ) as _i15.Future); - @override - _i15.Future refresh() => (super.noSuchMethod( + _i16.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1598,33 +1452,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i15.Future testNetworkConnection() => (super.noSuchMethod( + _i16.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - _i15.Future initializeNew() => (super.noSuchMethod( + _i16.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future initializeExisting() => (super.noSuchMethod( + _i16.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future recoverFromMnemonic({ + _i16.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1641,20 +1495,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future exitCurrentWallet() => (super.noSuchMethod( + _i16.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future fullRescan( + _i16.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1666,19 +1520,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); - @override - _i15.Future estimateFeeFor( + _i16.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1690,18 +1536,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override - _i15.Future generateNewAddress() => (super.noSuchMethod( + _i16.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1709,7 +1555,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1729,7 +1575,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 _i12.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1740,10 +1586,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i14.Coin get coin => (super.noSuchMethod( + _i15.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i14.Coin.bitcoin, - ) as _i14.Coin); + returnValue: _i15.Coin.bitcoin, + ) as _i15.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1776,75 +1622,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i15.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i15.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i15.Future<_i8.FeeObject>); + ) as _i16.Future<_i9.FeeObject>); @override - _i15.Future get maxFee => (super.noSuchMethod( + _i16.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override - _i15.Future get currentReceivingAddress => (super.noSuchMethod( + _i16.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i15.Future.value(''), - ) as _i15.Future); + returnValue: _i16.Future.value(''), + ) as _i16.Future); @override - _i15.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i15.Future<_i9.Decimal>); + Invocation.getter(#balance), + ), + ) as _i12.Balance); @override - _i15.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i15.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i15.Future<_i9.Decimal>); - @override - _i15.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i15.Future>.value([]), - ) as _i15.Future>); - @override - _i15.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i16.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i15.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i15.Future<_i8.TransactionData>); + _i16.Future>.value(<_i20.Transaction>[]), + ) as _i16.Future>); @override - _i15.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i15.Future>.value(<_i8.UtxoObject>[]), - ) as _i15.Future>); + _i16.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i16.Future>.value(<_i20.UTXO>[]), + ) as _i16.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -1864,10 +1677,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { returnValue: '', ) as String); @override - _i15.Future> get mnemonic => (super.noSuchMethod( + _i16.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i15.Future>.value([]), - ) as _i15.Future>); + returnValue: _i16.Future>.value([]), + ) as _i16.Future>); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -1884,7 +1697,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { returnValue: 0, ) as int); @override - _i15.Future> prepareSend({ + _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1900,54 +1713,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { }, ), returnValue: - _i15.Future>.value({}), - ) as _i15.Future>); + _i16.Future>.value({}), + ) as _i16.Future>); @override - _i15.Future confirmSend({required Map? txData}) => + _i16.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i15.Future.value(''), - ) as _i15.Future); + returnValue: _i16.Future.value(''), + ) as _i16.Future); @override - _i15.Future send({ - required String? toAddress, - required int? amount, - Map? args, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i15.Future.value(''), - ) as _i15.Future); - @override - _i15.Future refresh() => (super.noSuchMethod( + _i16.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1957,15 +1752,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { returnValue: false, ) as bool); @override - _i15.Future testNetworkConnection() => (super.noSuchMethod( + _i16.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - _i15.Future recoverFromMnemonic({ + _i16.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1982,38 +1777,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { #height: height, }, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future initializeNew() => (super.noSuchMethod( + _i16.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future initializeExisting() => (super.noSuchMethod( + _i16.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future exit() => (super.noSuchMethod( + _i16.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future fullRescan( + _i16.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2025,11 +1820,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override - _i15.Future estimateFeeFor( + _i16.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -2041,24 +1836,24 @@ class MockCoinServiceAPI extends _i1.Mock implements _i12.CoinServiceAPI { feeRate, ], ), - returnValue: _i15.Future.value(0), - ) as _i15.Future); + returnValue: _i16.Future.value(0), + ) as _i16.Future); @override - _i15.Future generateNewAddress() => (super.noSuchMethod( + _i16.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i16.Future.value(false), + ) as _i16.Future); @override - _i15.Future updateSentCachedTxData(Map? txData) => + _i16.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); } diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 85e921d41..7ac548055 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -3,34 +3,37 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i16; -import 'dart:ui' as _i18; +import 'dart:async' as _i18; +import 'dart:ui' as _i20; -import 'package:decimal/decimal.dart' as _i9; +import 'package:decimal/decimal.dart' as _i14; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i10; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i12; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i11; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i13; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i12; +import 'package:stackwallet/models/balance.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i21; import 'package:stackwallet/models/models.dart' as _i8; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart' - as _i22; + as _i25; import 'package:stackwallet/services/coins/coin_service.dart' as _i7; -import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i19; +import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i22; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i20; +import 'package:stackwallet/services/locale_service.dart' as _i23; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/services/notes_service.dart' as _i25; -import 'package:stackwallet/services/price_service.dart' as _i24; +import 'package:stackwallet/services/notes_service.dart' as _i28; +import 'package:stackwallet/services/price_service.dart' as _i27; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i10; -import 'package:stackwallet/services/wallets.dart' as _i14; + as _i11; +import 'package:stackwallet/services/wallets.dart' as _i16; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i23; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i21; -import 'package:stackwallet/utilities/prefs.dart' as _i17; -import 'package:tuple/tuple.dart' as _i13; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i26; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i17; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i24; +import 'package:stackwallet/utilities/prefs.dart' as _i19; +import 'package:tuple/tuple.dart' as _i15; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -106,8 +109,8 @@ class _FakeFeeObject_5 extends _i1.SmartFake implements _i8.FeeObject { ); } -class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { - _FakeDecimal_6( +class _FakeBalance_6 extends _i1.SmartFake implements _i9.Balance { + _FakeBalance_6( Object parent, Invocation parentInvocation, ) : super( @@ -116,9 +119,8 @@ class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { ); } -class _FakeTransactionData_7 extends _i1.SmartFake - implements _i8.TransactionData { - _FakeTransactionData_7( +class _FakeIsar_7 extends _i1.SmartFake implements _i10.Isar { + _FakeIsar_7( Object parent, Invocation parentInvocation, ) : super( @@ -128,7 +130,7 @@ class _FakeTransactionData_7 extends _i1.SmartFake } class _FakeTransactionNotificationTracker_8 extends _i1.SmartFake - implements _i10.TransactionNotificationTracker { + implements _i11.TransactionNotificationTracker { _FakeTransactionNotificationTracker_8( Object parent, Invocation parentInvocation, @@ -138,8 +140,8 @@ class _FakeTransactionNotificationTracker_8 extends _i1.SmartFake ); } -class _FakeUtxoData_9 extends _i1.SmartFake implements _i8.UtxoData { - _FakeUtxoData_9( +class _FakeElectrumX_9 extends _i1.SmartFake implements _i12.ElectrumX { + _FakeElectrumX_9( Object parent, Invocation parentInvocation, ) : super( @@ -148,8 +150,9 @@ class _FakeUtxoData_9 extends _i1.SmartFake implements _i8.UtxoData { ); } -class _FakeElectrumX_10 extends _i1.SmartFake implements _i11.ElectrumX { - _FakeElectrumX_10( +class _FakeCachedElectrumX_10 extends _i1.SmartFake + implements _i13.CachedElectrumX { + _FakeCachedElectrumX_10( Object parent, Invocation parentInvocation, ) : super( @@ -158,9 +161,8 @@ class _FakeElectrumX_10 extends _i1.SmartFake implements _i11.ElectrumX { ); } -class _FakeCachedElectrumX_11 extends _i1.SmartFake - implements _i12.CachedElectrumX { - _FakeCachedElectrumX_11( +class _FakeDecimal_11 extends _i1.SmartFake implements _i14.Decimal { + _FakeDecimal_11( Object parent, Invocation parentInvocation, ) : super( @@ -180,7 +182,7 @@ class _FakeDuration_12 extends _i1.SmartFake implements Duration { } class _FakeTuple2_13 extends _i1.SmartFake - implements _i13.Tuple2 { + implements _i15.Tuple2 { _FakeTuple2_13( Object parent, Invocation parentInvocation, @@ -193,7 +195,7 @@ class _FakeTuple2_13 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 _i14.Wallets { +class MockWallets extends _i1.Mock implements _i16.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -260,7 +262,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i15.Coin? coin}) => + List getWalletIdsFor({required _i17.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -270,18 +272,18 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValue: [], ) as List); @override - Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> + Map<_i17.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Coin, + returnValue: <_i17.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, - ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); + ) as Map<_i17.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i15.Coin? coin) => + _i17.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -345,17 +347,17 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - _i16.Future load(_i17.Prefs? prefs) => (super.noSuchMethod( + _i18.Future load(_i19.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future loadAfterStackRestore( - _i17.Prefs? prefs, + _i18.Future loadAfterStackRestore( + _i19.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -366,11 +368,11 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { managers, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -378,7 +380,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -430,10 +432,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i17.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i17.Coin.bitcoin, + ) as _i17.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -466,91 +468,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i18.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i18.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i18.Future<_i8.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i18.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i18.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i9.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_6( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i9.Decimal); + ) as _i9.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i9.Decimal); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i18.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_7( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i18.Future>.value(<_i21.Transaction>[]), + ) as _i18.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i18.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i18.Future>.value(<_i21.UTXO>[]), + ) as _i18.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -570,10 +523,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i18.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i18.Future>.value([]), + ) as _i18.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -590,14 +543,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i18.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -607,7 +560,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future> prepareSend({ + _i18.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -623,45 +576,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i18.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i18.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -671,33 +606,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i18.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i18.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i18.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future recoverFromMnemonic({ + _i18.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -714,20 +649,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future exitCurrentWallet() => (super.noSuchMethod( + _i18.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future fullRescan( + _i18.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -739,19 +674,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); - @override - _i16.Future estimateFeeFor( + _i18.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -763,18 +690,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i18.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -782,7 +709,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -817,10 +744,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i15.Coin get coin => (super.noSuchMethod( + _i17.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i17.Coin.bitcoin, + ) as _i17.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -853,75 +780,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i18.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i18.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i18.Future<_i8.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i18.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i18.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i9.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_6( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); + Invocation.getter(#balance), + ), + ) as _i9.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i18.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_7( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i18.Future>.value(<_i21.Transaction>[]), + ) as _i18.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i18.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i18.Future>.value(<_i21.UTXO>[]), + ) as _i18.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -941,10 +835,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i18.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i18.Future>.value([]), + ) as _i18.Future>); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -961,7 +855,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: 0, ) as int); @override - _i16.Future> prepareSend({ + _i18.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -977,54 +871,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i18.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i18.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i18.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1034,15 +910,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i18.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override - _i16.Future recoverFromMnemonic({ + _i18.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1059,38 +935,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i18.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i18.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future exit() => (super.noSuchMethod( + _i18.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future fullRescan( + _i18.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1102,11 +978,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future estimateFeeFor( + _i18.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1118,38 +994,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i18.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i18.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); } /// A class which mocks [FiroWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { +class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { MockFiroWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i16.Timer? _timer) => super.noSuchMethod( + set timer(_i18.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -1157,23 +1033,31 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i8.TransactionData? _cachedTxData) => super.noSuchMethod( + _i10.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_7( + this, + Invocation.getter(#isar), + ), + ) as _i10.Isar); + @override + set isar(_i10.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @override - _i10.TransactionNotificationTracker get txTracker => (super.noSuchMethod( + _i11.TransactionNotificationTracker get txTracker => (super.noSuchMethod( Invocation.getter(#txTracker), returnValue: _FakeTransactionNotificationTracker_8( this, Invocation.getter(#txTracker), ), - ) as _i10.TransactionNotificationTracker); + ) as _i11.TransactionNotificationTracker); @override - set txTracker(_i10.TransactionNotificationTracker? _txTracker) => + set txTracker(_i11.TransactionNotificationTracker? _txTracker) => super.noSuchMethod( Invocation.setter( #txTracker, @@ -1247,111 +1131,45 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i17.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i17.Coin.bitcoin, + ) as _i17.Coin); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i18.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i18.Future>.value([]), + ) as _i18.Future>); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_7( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); - @override - _i16.Future<_i8.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i16.Future<_i8.UtxoData>.value(_FakeUtxoData_9( - this, - Invocation.getter(#utxoData), - )), - ) as _i16.Future<_i8.UtxoData>); - @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get lelantusTransactionData => + _i18.Future> get lelantusTransactionData => (super.noSuchMethod( Invocation.getter(#lelantusTransactionData), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_7( - this, - Invocation.getter(#lelantusTransactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i18.Future>.value(<_i21.Transaction>[]), + ) as _i18.Future>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i18.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future> get balances => (super.noSuchMethod( - Invocation.getter(#balances), - returnValue: _i16.Future>.value(<_i9.Decimal>[]), - ) as _i16.Future>); - @override - _i16.Future<_i9.Decimal> get firoPrice => (super.noSuchMethod( - Invocation.getter(#firoPrice), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#firoPrice), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i18.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_5( + returnValue: _i18.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i18.Future<_i8.FeeObject>); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i18.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); + @override + _i18.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override String get walletName => (super.noSuchMethod( Invocation.getter(#walletName), @@ -1371,31 +1189,26 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValue: '', ) as String); @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), returnValue: false, ) as bool); @override - _i11.ElectrumX get electrumXClient => (super.noSuchMethod( + _i12.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_10( + returnValue: _FakeElectrumX_9( this, Invocation.getter(#electrumXClient), ), - ) as _i11.ElectrumX); + ) as _i12.ElectrumX); @override - _i12.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i13.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_11( + returnValue: _FakeCachedElectrumX_10( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i12.CachedElectrumX); + ) as _i13.CachedElectrumX); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1407,11 +1220,43 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValue: false, ) as bool); @override + _i18.Future get chainHeight => (super.noSuchMethod( + Invocation.getter(#chainHeight), + returnValue: _i18.Future.value(0), + ) as _i18.Future); + @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), returnValue: 0, ) as int); @override + _i9.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_6( + this, + Invocation.getter(#balance), + ), + ) as _i9.Balance); + @override + _i9.Balance get balancePrivate => (super.noSuchMethod( + Invocation.getter(#balancePrivate), + returnValue: _FakeBalance_6( + this, + Invocation.getter(#balancePrivate), + ), + ) as _i9.Balance); + @override + _i18.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i18.Future>.value(<_i21.UTXO>[]), + ) as _i18.Future>); + @override + _i18.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), + returnValue: + _i18.Future>.value(<_i21.Transaction>[]), + ) as _i18.Future>); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -1429,23 +1274,23 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValue: false, ) as bool); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i18.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i18.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1463,7 +1308,7 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValueForMissingStub: null, ); @override - _i16.Future> prepareSendPublic({ + _i18.Future> prepareSendPublic({ required String? address, required int? satoshiAmount, Map? args, @@ -1479,20 +1324,20 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future confirmSendPublic({dynamic txData}) => + _i18.Future confirmSendPublic({dynamic txData}) => (super.noSuchMethod( Invocation.method( #confirmSendPublic, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override - _i16.Future> prepareSend({ + _i18.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1508,36 +1353,18 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i18.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override int estimateTxFee({ required int? vSize, @@ -1561,7 +1388,7 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i8.UtxoObject>? utxos, + List<_i21.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1577,19 +1404,19 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { }, )); @override - _i16.Future> fetchBuildTxData( - List<_i8.UtxoObject>? utxosToUse) => + _i18.Future> fetchBuildTxData( + List<_i21.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future> buildTransaction({ - required List<_i8.UtxoObject>? utxosToUse, + _i18.Future> buildTransaction({ + required List<_i21.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -1606,68 +1433,61 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i18.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i18.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i18.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i18.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override - _i16.Future getAllTxsToWatch( - _i8.TransactionData? txData, - _i8.TransactionData? lTxData, - ) => - (super.noSuchMethod( + _i18.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [ - txData, - lTxData, - ], + [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future refresh() => (super.noSuchMethod( + _i18.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override List> getLelantusCoinMap() => (super.noSuchMethod( @@ -1678,35 +1498,35 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValue: >[], ) as List>); @override - _i16.Future anonymizeAllPublicFunds() => (super.noSuchMethod( + _i18.Future anonymizeAllPublicFunds() => (super.noSuchMethod( Invocation.method( #anonymizeAllPublicFunds, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future>> createMintsFromAmount(int? total) => + _i18.Future>> createMintsFromAmount(int? total) => (super.noSuchMethod( Invocation.method( #createMintsFromAmount, [total], ), - returnValue: _i16.Future>>.value( + returnValue: _i18.Future>>.value( >[]), - ) as _i16.Future>>); + ) as _i18.Future>>); @override - _i16.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( + _i18.Future submitHexToNetwork(String? hex) => (super.noSuchMethod( Invocation.method( #submitHexToNetwork, [hex], ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override - _i16.Future> buildMintTransaction( - List<_i8.UtxoObject>? utxosToUse, + _i18.Future> buildMintTransaction( + List<_i21.UTXO>? utxosToUse, int? satoshisPerRecipient, List>? mintsMap, ) => @@ -1720,29 +1540,29 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { ], ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future checkReceivingAddressForTransactions() => + _i18.Future checkReceivingAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkReceivingAddressForTransactions, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future checkChangeAddressForTransactions() => (super.noSuchMethod( + _i18.Future checkChangeAddressForTransactions() => (super.noSuchMethod( Invocation.method( #checkChangeAddressForTransactions, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future fillAddresses( + _i18.Future fillAddresses( String? suppliedMnemonic, { int? perBatch = 50, int? numberOfThreads = 4, @@ -1756,37 +1576,11 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { #numberOfThreads: numberOfThreads, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future incrementAddressIndexForChain(int? chain) => - (super.noSuchMethod( - Invocation.method( - #incrementAddressIndexForChain, - [chain], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future addToAddressesArrayForChain( - String? address, - int? chain, - ) => - (super.noSuchMethod( - Invocation.method( - #addToAddressesArrayForChain, - [ - address, - chain, - ], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future fullRescan( + _i18.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1798,11 +1592,11 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future recoverFromMnemonic({ + _i18.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1819,73 +1613,73 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future> getSetDataMap(int? latestSetId) => + _i18.Future> getSetDataMap(int? latestSetId) => (super.noSuchMethod( Invocation.method( #getSetDataMap, [latestSetId], ), - returnValue: _i16.Future>.value({}), - ) as _i16.Future>); + returnValue: _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future>> fetchAnonymitySets() => + _i18.Future>> fetchAnonymitySets() => (super.noSuchMethod( Invocation.method( #fetchAnonymitySets, [], ), - returnValue: _i16.Future>>.value( + returnValue: _i18.Future>>.value( >[]), - ) as _i16.Future>>); + ) as _i18.Future>>); @override - _i16.Future getLatestSetId() => (super.noSuchMethod( + _i18.Future getLatestSetId() => (super.noSuchMethod( Invocation.method( #getLatestSetId, [], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future> getUsedCoinSerials() => (super.noSuchMethod( + _i18.Future> getUsedCoinSerials() => (super.noSuchMethod( Invocation.method( #getUsedCoinSerials, [], ), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i18.Future>.value([]), + ) as _i18.Future>); @override - _i16.Future exit() => (super.noSuchMethod( + _i18.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future getCoinsToJoinSplit(int? required) => + _i18.Future getCoinsToJoinSplit(int? required) => (super.noSuchMethod( Invocation.method( #getCoinsToJoinSplit, [required], ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future estimateJoinSplitFee(int? spendAmount) => + _i18.Future estimateJoinSplitFee(int? spendAmount) => (super.noSuchMethod( Invocation.method( #estimateJoinSplitFee, [spendAmount], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future estimateFeeFor( + _i18.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1897,10 +1691,10 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future estimateFeeForPublic( + _i18.Future estimateFeeForPublic( int? satoshiAmount, int? feeRate, ) => @@ -1912,8 +1706,8 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override int roughFeeEstimate( int? inputCount, @@ -1932,32 +1726,29 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i18.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i18.Future.value(0), + ) as _i18.Future); @override - _i16.Future>> fastFetch( + _i18.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i16.Future>>.value( + returnValue: _i18.Future>>.value( >[]), - ) as _i16.Future>>); + ) as _i18.Future>>); @override - _i16.Future> getJMintTransactions( - _i12.CachedElectrumX? cachedClient, + _i18.Future> getJMintTransactions( + _i13.CachedElectrumX? cachedClient, List? transactions, - String? currency, - _i15.Coin? coin, - _i9.Decimal? currentPrice, - String? locale, + _i17.Coin? coin, ) => (super.noSuchMethod( Invocation.method( @@ -1965,57 +1756,65 @@ class MockFiroWallet extends _i1.Mock implements _i19.FiroWallet { [ cachedClient, transactions, - currency, coin, - currentPrice, - locale, ], ), returnValue: - _i16.Future>.value(<_i8.Transaction>[]), - ) as _i16.Future>); + _i18.Future>.value(<_i21.Transaction>[]), + ) as _i18.Future>); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i18.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override - _i16.Future<_i9.Decimal> availablePrivateBalance() => (super.noSuchMethod( + _i14.Decimal availablePrivateBalance() => (super.noSuchMethod( Invocation.method( #availablePrivateBalance, [], ), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + returnValue: _FakeDecimal_11( this, Invocation.method( #availablePrivateBalance, [], ), - )), - ) as _i16.Future<_i9.Decimal>); + ), + ) as _i14.Decimal); @override - _i16.Future<_i9.Decimal> availablePublicBalance() => (super.noSuchMethod( + _i14.Decimal availablePublicBalance() => (super.noSuchMethod( Invocation.method( #availablePublicBalance, [], ), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + returnValue: _FakeDecimal_11( this, Invocation.method( #availablePublicBalance, [], ), - )), - ) as _i16.Future<_i9.Decimal>); + ), + ) as _i14.Decimal); + @override + _i18.Future updateStoredChainHeight({required int? newHeight}) => + (super.noSuchMethod( + Invocation.method( + #updateStoredChainHeight, + [], + {#newHeight: newHeight}, + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i20.LocaleService { +class MockLocaleService extends _i1.Mock implements _i23.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -2031,17 +1830,17 @@ class MockLocaleService extends _i1.Mock implements _i20.LocaleService { returnValue: false, ) as bool); @override - _i16.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i18.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2049,7 +1848,7 @@ class MockLocaleService extends _i1.Mock implements _i20.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2077,7 +1876,7 @@ class MockLocaleService extends _i1.Mock implements _i20.LocaleService { /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i17.Prefs { +class MockPrefs extends _i1.Mock implements _i19.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -2133,12 +1932,12 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - _i21.SyncingType get syncType => (super.noSuchMethod( + _i24.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i21.SyncingType.currentWalletOnly, - ) as _i21.SyncingType); + returnValue: _i24.SyncingType.currentWalletOnly, + ) as _i24.SyncingType); @override - set syncType(_i21.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i24.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -2198,12 +1997,12 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - _i22.ExchangeRateType get exchangeRateType => (super.noSuchMethod( + _i25.ExchangeRateType get exchangeRateType => (super.noSuchMethod( Invocation.getter(#exchangeRateType), - returnValue: _i22.ExchangeRateType.estimated, - ) as _i22.ExchangeRateType); + returnValue: _i25.ExchangeRateType.estimated, + ) as _i25.ExchangeRateType); @override - set exchangeRateType(_i22.ExchangeRateType? exchangeRateType) => + set exchangeRateType(_i25.ExchangeRateType? exchangeRateType) => super.noSuchMethod( Invocation.setter( #exchangeRateType, @@ -2285,12 +2084,12 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - _i23.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i26.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i23.BackupFrequencyType.everyTenMinutes, - ) as _i23.BackupFrequencyType); + returnValue: _i26.BackupFrequencyType.everyTenMinutes, + ) as _i26.BackupFrequencyType); @override - set backupFrequencyType(_i23.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i26.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -2360,33 +2159,33 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValue: false, ) as bool); @override - _i16.Future init() => (super.noSuchMethod( + _i18.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i18.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future isExternalCallsSet() => (super.noSuchMethod( + _i18.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i18.Future.value(false), + ) as _i18.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2394,7 +2193,7 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2422,7 +2221,7 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { /// A class which mocks [PriceService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPriceService extends _i1.Mock implements _i24.PriceService { +class MockPriceService extends _i1.Mock implements _i27.PriceService { MockPriceService() { _i1.throwOnMissingStub(this); } @@ -2454,29 +2253,29 @@ class MockPriceService extends _i1.Mock implements _i24.PriceService { returnValue: false, ) as bool); @override - _i13.Tuple2<_i9.Decimal, double> getPrice(_i15.Coin? coin) => + _i15.Tuple2<_i14.Decimal, double> getPrice(_i17.Coin? coin) => (super.noSuchMethod( Invocation.method( #getPrice, [coin], ), - returnValue: _FakeTuple2_13<_i9.Decimal, double>( + returnValue: _FakeTuple2_13<_i14.Decimal, double>( this, Invocation.method( #getPrice, [coin], ), ), - ) as _i13.Tuple2<_i9.Decimal, double>); + ) as _i15.Tuple2<_i14.Decimal, double>); @override - _i16.Future updatePrice() => (super.noSuchMethod( + _i18.Future updatePrice() => (super.noSuchMethod( Invocation.method( #updatePrice, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override void cancel() => super.noSuchMethod( Invocation.method( @@ -2502,7 +2301,7 @@ class MockPriceService extends _i1.Mock implements _i24.PriceService { returnValueForMissingStub: null, ); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2510,7 +2309,7 @@ class MockPriceService extends _i1.Mock implements _i24.PriceService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -2530,7 +2329,7 @@ class MockPriceService extends _i1.Mock implements _i24.PriceService { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i25.NotesService { +class MockNotesService extends _i1.Mock implements _i28.NotesService { MockNotesService() { _i1.throwOnMissingStub(this); } @@ -2546,35 +2345,35 @@ class MockNotesService extends _i1.Mock implements _i25.NotesService { returnValue: {}, ) as Map); @override - _i16.Future> get notes => (super.noSuchMethod( + _i18.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i16.Future>.value({}), - ) as _i16.Future>); + returnValue: _i18.Future>.value({}), + ) as _i18.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future> search(String? text) => (super.noSuchMethod( + _i18.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i16.Future>.value({}), - ) as _i16.Future>); + returnValue: _i18.Future>.value({}), + ) as _i18.Future>); @override - _i16.Future getNoteFor({required String? txid}) => + _i18.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i18.Future.value(''), + ) as _i18.Future); @override - _i16.Future editOrAddNote({ + _i18.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -2587,21 +2386,21 @@ class MockNotesService extends _i1.Mock implements _i25.NotesService { #note: note, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - _i16.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i18.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -2609,7 +2408,7 @@ class MockNotesService extends _i1.Mock implements _i25.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 722ad681b..1be304d22 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -3,26 +3,28 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i14; -import 'dart:ui' as _i16; +import 'dart:async' as _i15; +import 'dart:ui' as _i17; -import 'package:decimal/decimal.dart' as _i9; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; -import 'package:stackwallet/models/models.dart' as _i8; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i17; +import 'package:stackwallet/models/balance.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i19; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i18; +import 'package:stackwallet/services/locale_service.dart' as _i20; 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 _i12; +import 'package:stackwallet/services/wallets.dart' as _i13; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i13; -import 'package:stackwallet/utilities/prefs.dart' as _i15; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i14; +import 'package:stackwallet/utilities/prefs.dart' as _i16; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -88,8 +90,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { - _FakeUtxoData_5( +class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { + _FakeIsar_5( Object parent, Invocation parentInvocation, ) : super( @@ -98,8 +100,8 @@ class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { ); } -class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { - _FakeDecimal_6( +class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { + _FakeFeeObject_6( Object parent, Invocation parentInvocation, ) : super( @@ -108,8 +110,8 @@ class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { ); } -class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { - _FakeFeeObject_7( +class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { + _FakeElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -118,30 +120,9 @@ class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { ); } -class _FakeTransactionData_8 extends _i1.SmartFake - implements _i8.TransactionData { - _FakeTransactionData_8( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeElectrumX_9 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeCachedElectrumX_10 extends _i1.SmartFake +class _FakeCachedElectrumX_8 extends _i1.SmartFake implements _i11.CachedElectrumX { - _FakeCachedElectrumX_10( + _FakeCachedElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -150,9 +131,19 @@ class _FakeCachedElectrumX_10 extends _i1.SmartFake ); } -class _FakeElectrumXNode_11 extends _i1.SmartFake +class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { + _FakeBalance_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i10.ElectrumXNode { - _FakeElectrumXNode_11( + _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, ) : super( @@ -164,7 +155,7 @@ class _FakeElectrumXNode_11 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 _i12.Wallets { +class MockWallets extends _i1.Mock implements _i13.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -231,7 +222,7 @@ class MockWallets extends _i1.Mock implements _i12.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i13.Coin? coin}) => + List getWalletIdsFor({required _i14.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -241,18 +232,18 @@ class MockWallets extends _i1.Mock implements _i12.Wallets { returnValue: [], ) as List); @override - Map<_i13.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> + Map<_i14.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i13.Coin, + returnValue: <_i14.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, - ) as Map<_i13.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); + ) as Map<_i14.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i13.Coin? coin) => + _i14.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -316,17 +307,17 @@ class MockWallets extends _i1.Mock implements _i12.Wallets { returnValueForMissingStub: null, ); @override - _i14.Future load(_i15.Prefs? prefs) => (super.noSuchMethod( + _i15.Future load(_i16.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future loadAfterStackRestore( - _i15.Prefs? prefs, + _i15.Future loadAfterStackRestore( + _i16.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -337,11 +328,11 @@ class MockWallets extends _i1.Mock implements _i12.Wallets { managers, ], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - void addListener(_i16.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -349,7 +340,7 @@ class MockWallets extends _i1.Mock implements _i12.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -369,13 +360,13 @@ class MockWallets extends _i1.Mock implements _i12.Wallets { /// A class which mocks [BitcoinWallet]. /// /// See the documentation for Mockito's code generation for more information. -class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i14.Timer? _timer) => super.noSuchMethod( + set timer(_i15.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -400,19 +391,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValueForMissingStub: null, ); @override - List<_i8.UtxoObject> get outputsList => (super.noSuchMethod( - Invocation.getter(#outputsList), - returnValue: <_i8.UtxoObject>[], - ) as List<_i8.UtxoObject>); - @override - set outputsList(List<_i8.UtxoObject>? _outputsList) => super.noSuchMethod( - Invocation.setter( - #outputsList, - _outputsList, - ), - returnValueForMissingStub: null, - ); - @override bool get longMutex => (super.noSuchMethod( Invocation.getter(#longMutex), returnValue: false, @@ -439,10 +417,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i8.TransactionData? _cachedTxData) => super.noSuchMethod( + _i8.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#isar), + ), + ) as _i8.Isar); + @override + set isar(_i8.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @@ -473,104 +459,59 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValue: false, ) as bool); @override - _i13.Coin get coin => (super.noSuchMethod( + _i14.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i13.Coin.bitcoin, - ) as _i13.Coin); + returnValue: _i14.Coin.bitcoin, + ) as _i14.Coin); @override - _i14.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i14.Future>.value([]), - ) as _i14.Future>); + _i15.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i15.Future>.value(<_i19.UTXO>[]), + ) as _i15.Future>); @override - _i14.Future<_i8.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i14.Future<_i8.UtxoData>.value(_FakeUtxoData_5( - this, - Invocation.getter(#utxoData), - )), - ) as _i14.Future<_i8.UtxoData>); - @override - _i14.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), + _i15.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i14.Future>.value(<_i8.UtxoObject>[]), - ) as _i14.Future>); + _i15.Future>.value(<_i19.Transaction>[]), + ) as _i15.Future>); @override - _i14.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i14.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#availableBalance), - )), - ) as _i14.Future<_i9.Decimal>); - @override - _i14.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i14.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i14.Future<_i9.Decimal>); - @override - _i14.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i14.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i14.Future<_i9.Decimal>); - @override - _i14.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i14.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i14.Future<_i9.Decimal>); - @override - _i14.Future get currentReceivingAddress => (super.noSuchMethod( + _i15.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i14.Future.value(''), - ) as _i14.Future); + returnValue: _i15.Future.value(''), + ) as _i15.Future); @override - _i14.Future get currentLegacyReceivingAddress => (super.noSuchMethod( - Invocation.getter(#currentLegacyReceivingAddress), - returnValue: _i14.Future.value(''), - ) as _i14.Future); - @override - _i14.Future get currentReceivingAddressP2SH => (super.noSuchMethod( - Invocation.getter(#currentReceivingAddressP2SH), - returnValue: _i14.Future.value(''), - ) as _i14.Future); + _i15.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i15.Future.value(''), + ) as _i15.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i14.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i15.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i14.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i15.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i14.Future<_i8.FeeObject>); + ) as _i15.Future<_i9.FeeObject>); @override - _i14.Future get maxFee => (super.noSuchMethod( + _i15.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i14.Future.value(0), - ) as _i14.Future); + returnValue: _i15.Future.value(0), + ) as _i15.Future); @override - _i14.Future> get mnemonic => (super.noSuchMethod( + _i15.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i14.Future>.value([]), - ) as _i14.Future>); + returnValue: _i15.Future>.value([]), + ) as _i15.Future>); @override - _i14.Future get chainHeight => (super.noSuchMethod( + _i15.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i14.Future.value(0), - ) as _i14.Future); + returnValue: _i15.Future.value(0), + ) as _i15.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -600,15 +541,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValue: false, ) as bool); @override - _i14.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i14.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i14.Future<_i8.TransactionData>); - @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), returnValue: '', @@ -629,7 +561,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { @override _i10.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_9( + returnValue: _FakeElectrumX_7( this, Invocation.getter(#electrumXClient), ), @@ -637,12 +569,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { @override _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_10( + returnValue: _FakeCachedElectrumX_8( this, Invocation.getter(#cachedElectrumXClient), ), ) as _i11.CachedElectrumX); @override + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( + this, + Invocation.getter(#balance), + ), + ) as _i12.Balance); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -652,37 +592,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i14.Future exit() => (super.noSuchMethod( + _i15.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future updateStoredChainHeight({required int? newHeight}) => + _i15.Future updateStoredChainHeight({required int? newHeight}) => (super.noSuchMethod( Invocation.method( #updateStoredChainHeight, [], {#newHeight: newHeight}, ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i17.DerivePathType addressType({required String? address}) => + _i18.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i17.DerivePathType.bip44, - ) as _i17.DerivePathType); + returnValue: _i18.DerivePathType.bip44, + ) as _i18.DerivePathType); @override - _i14.Future recoverFromMnemonic({ + _i15.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -699,48 +639,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { #height: height, }, ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future getTransactionCacheEarly(List? allAddresses) => + _i15.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i15.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i14.Future.value(false), - ) as _i14.Future); + returnValue: _i15.Future.value(false), + ) as _i15.Future); @override - _i14.Future getAllTxsToWatch(_i8.TransactionData? txData) => - (super.noSuchMethod( + _i15.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [txData], + [], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future refresh() => (super.noSuchMethod( + _i15.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future> prepareSend({ + _i15.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -756,44 +695,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { }, ), returnValue: - _i14.Future>.value({}), - ) as _i14.Future>); + _i15.Future>.value({}), + ) as _i15.Future>); @override - _i14.Future confirmSend({required Map? txData}) => + _i15.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i14.Future.value(''), - ) as _i14.Future); + returnValue: _i15.Future.value(''), + ) as _i15.Future); @override - _i14.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i14.Future.value(''), - ) as _i14.Future); - @override - _i14.Future testNetworkConnection() => (super.noSuchMethod( + _i15.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i14.Future.value(false), - ) as _i14.Future); + returnValue: _i15.Future.value(false), + ) as _i15.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -811,33 +732,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i14.Future initializeNew() => (super.noSuchMethod( + _i15.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future initializeExisting() => (super.noSuchMethod( + _i15.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future updateSentCachedTxData(Map? txData) => + _i15.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -847,36 +768,36 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValue: false, ) as bool); @override - _i14.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i15.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i15.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i14.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i15.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i14.Future<_i10.ElectrumXNode>); + ) as _i15.Future<_i10.ElectrumXNode>); @override - _i14.Future addDerivation({ + _i15.Future addDerivation({ required int? chain, required String? address, required String? pubKey, required String? wif, - required _i17.DerivePathType? derivePathType, + required _i18.DerivePathType? derivePathType, }) => (super.noSuchMethod( Invocation.method( @@ -890,13 +811,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { #derivePathType: derivePathType, }, ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future addDerivations({ + _i15.Future addDerivations({ required int? chain, - required _i17.DerivePathType? derivePathType, + required _i18.DerivePathType? derivePathType, required Map? derivationsToAdd, }) => (super.noSuchMethod( @@ -909,50 +830,50 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { #derivationsToAdd: derivationsToAdd, }, ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future getTxCount({required String? address}) => - (super.noSuchMethod( - Invocation.method( - #getTxCount, - [], - {#address: address}, - ), - returnValue: _i14.Future.value(0), - ) as _i14.Future); - @override - _i14.Future checkCurrentReceivingAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentReceivingAddressesForTransactions, - [], - ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); - @override - _i14.Future checkCurrentChangeAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentChangeAddressesForTransactions, - [], - ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); - @override - _i14.Future>> fastFetch( + _i15.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i14.Future>>.value( + returnValue: _i15.Future>>.value( >[]), - ) as _i14.Future>>); + ) as _i15.Future>>); + @override + _i15.Future getTxCount({required String? address}) => + (super.noSuchMethod( + Invocation.method( + #getTxCount, + [], + {#address: address}, + ), + returnValue: _i15.Future.value(0), + ) as _i15.Future); + @override + _i15.Future checkCurrentReceivingAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentReceivingAddressesForTransactions, + [], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); + @override + _i15.Future checkCurrentChangeAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentChangeAddressesForTransactions, + [], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override int estimateTxFee({ required int? vSize, @@ -976,7 +897,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i8.UtxoObject>? utxos, + List<_i19.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -992,19 +913,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { }, )); @override - _i14.Future> fetchBuildTxData( - List<_i8.UtxoObject>? utxosToUse) => + _i15.Future> fetchBuildTxData( + List<_i19.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i14.Future>.value({}), - ) as _i14.Future>); + _i15.Future>.value({}), + ) as _i15.Future>); @override - _i14.Future> buildTransaction({ - required List<_i8.UtxoObject>? utxosToUse, + _i15.Future> buildTransaction({ + required List<_i19.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -1021,10 +942,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { }, ), returnValue: - _i14.Future>.value({}), - ) as _i14.Future>); + _i15.Future>.value({}), + ) as _i15.Future>); @override - _i14.Future fullRescan( + _i15.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1036,11 +957,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - _i14.Future estimateFeeFor( + _i15.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1052,8 +973,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { feeRate, ], ), - returnValue: _i14.Future.value(0), - ) as _i14.Future); + returnValue: _i15.Future.value(0), + ) as _i15.Future); @override int roughFeeEstimate( int? inputCount, @@ -1072,27 +993,27 @@ class MockBitcoinWallet extends _i1.Mock implements _i17.BitcoinWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i15.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i15.Future.value(0), + ) as _i15.Future); @override - _i14.Future generateNewAddress() => (super.noSuchMethod( + _i15.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i14.Future.value(false), - ) as _i14.Future); + returnValue: _i15.Future.value(false), + ) as _i15.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i18.LocaleService { +class MockLocaleService extends _i1.Mock implements _i20.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1108,17 +1029,17 @@ class MockLocaleService extends _i1.Mock implements _i18.LocaleService { returnValue: false, ) as bool); @override - _i14.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i15.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i14.Future.value(), - returnValueForMissingStub: _i14.Future.value(), - ) as _i14.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override - void addListener(_i16.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1126,7 +1047,7 @@ class MockLocaleService extends _i1.Mock implements _i18.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 ad27dd693..0bcdecec2 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 @@ -3,29 +3,31 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i16; -import 'dart:ui' as _i18; +import 'dart:async' as _i17; +import 'dart:ui' as _i19; -import 'package:decimal/decimal.dart' as _i9; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; -import 'package:stackwallet/models/models.dart' as _i8; -import 'package:stackwallet/models/node_model.dart' as _i20; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i19; -import 'package:stackwallet/services/coins/coin_service.dart' as _i13; +import 'package:stackwallet/models/balance.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i21; +import 'package:stackwallet/models/node_model.dart' as _i22; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; +import 'package:stackwallet/services/coins/coin_service.dart' as _i14; 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 _i7; -import 'package:stackwallet/services/wallets.dart' as _i14; +import 'package:stackwallet/services/wallets.dart' as _i15; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i12; -import 'package:stackwallet/utilities/prefs.dart' as _i17; + as _i13; +import 'package:stackwallet/utilities/prefs.dart' as _i18; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -91,8 +93,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { - _FakeUtxoData_5( +class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { + _FakeIsar_5( Object parent, Invocation parentInvocation, ) : super( @@ -101,8 +103,8 @@ class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { ); } -class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { - _FakeDecimal_6( +class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { + _FakeFeeObject_6( Object parent, Invocation parentInvocation, ) : super( @@ -111,8 +113,8 @@ class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { ); } -class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { - _FakeFeeObject_7( +class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { + _FakeElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -121,30 +123,9 @@ class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { ); } -class _FakeTransactionData_8 extends _i1.SmartFake - implements _i8.TransactionData { - _FakeTransactionData_8( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeElectrumX_9 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeCachedElectrumX_10 extends _i1.SmartFake +class _FakeCachedElectrumX_8 extends _i1.SmartFake implements _i11.CachedElectrumX { - _FakeCachedElectrumX_10( + _FakeCachedElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -153,9 +134,19 @@ class _FakeCachedElectrumX_10 extends _i1.SmartFake ); } -class _FakeElectrumXNode_11 extends _i1.SmartFake +class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { + _FakeBalance_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i10.ElectrumXNode { - _FakeElectrumXNode_11( + _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, ) : super( @@ -164,9 +155,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeSecureStorageInterface_12 extends _i1.SmartFake - implements _i12.SecureStorageInterface { - _FakeSecureStorageInterface_12( +class _FakeSecureStorageInterface_11 extends _i1.SmartFake + implements _i13.SecureStorageInterface { + _FakeSecureStorageInterface_11( Object parent, Invocation parentInvocation, ) : super( @@ -175,9 +166,9 @@ class _FakeSecureStorageInterface_12 extends _i1.SmartFake ); } -class _FakeCoinServiceAPI_13 extends _i1.SmartFake - implements _i13.CoinServiceAPI { - _FakeCoinServiceAPI_13( +class _FakeCoinServiceAPI_12 extends _i1.SmartFake + implements _i14.CoinServiceAPI { + _FakeCoinServiceAPI_12( Object parent, Invocation parentInvocation, ) : super( @@ -189,7 +180,7 @@ class _FakeCoinServiceAPI_13 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 _i14.Wallets { +class MockWallets extends _i1.Mock implements _i15.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -256,7 +247,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i15.Coin? coin}) => + List getWalletIdsFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -266,18 +257,18 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValue: [], ) as List); @override - Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> + Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Coin, + returnValue: <_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, - ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); + ) as Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i15.Coin? coin) => + _i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -341,17 +332,17 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - _i16.Future load(_i17.Prefs? prefs) => (super.noSuchMethod( + _i17.Future load(_i18.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future loadAfterStackRestore( - _i17.Prefs? prefs, + _i17.Future loadAfterStackRestore( + _i18.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -362,11 +353,11 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { managers, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -374,7 +365,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -400,19 +391,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i16.Future> get walletNames => + _i17.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i16.Future>.value( + returnValue: _i17.Future>.value( {}), - ) as _i16.Future>); + ) as _i17.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future renameWallet({ + _i17.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -427,13 +418,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future addExistingStackWallet({ + _i17.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -447,13 +438,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addNewWallet({ + _i17.Future addNewWallet({ required String? name, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -466,46 +457,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i17.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future saveFavoriteWalletIds(List? walletIds) => + _i17.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future moveFavorite({ + _i17.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -518,48 +509,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i17.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i17.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isMnemonicVerified({required String? walletId}) => + _i17.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future setMnemonicVerified({required String? walletId}) => + _i17.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future deleteWallet( + _i17.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -571,20 +562,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future refreshWallets(bool? shouldNotifyListeners) => + _i17.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -592,7 +583,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -620,13 +611,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 _i19.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i16.Timer? _timer) => super.noSuchMethod( + set timer(_i17.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -651,19 +642,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - List<_i8.UtxoObject> get outputsList => (super.noSuchMethod( - Invocation.getter(#outputsList), - returnValue: <_i8.UtxoObject>[], - ) as List<_i8.UtxoObject>); - @override - set outputsList(List<_i8.UtxoObject>? _outputsList) => super.noSuchMethod( - Invocation.setter( - #outputsList, - _outputsList, - ), - returnValueForMissingStub: null, - ); - @override bool get longMutex => (super.noSuchMethod( Invocation.getter(#longMutex), returnValue: false, @@ -690,10 +668,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i8.TransactionData? _cachedTxData) => super.noSuchMethod( + _i8.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#isar), + ), + ) as _i8.Isar); + @override + set isar(_i8.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @@ -724,104 +710,59 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override - _i16.Future<_i8.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i16.Future<_i8.UtxoData>.value(_FakeUtxoData_5( - this, - Invocation.getter(#utxoData), - )), - ) as _i16.Future<_i8.UtxoData>); - @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future get currentLegacyReceivingAddress => (super.noSuchMethod( - Invocation.getter(#currentLegacyReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future get currentReceivingAddressP2SH => (super.noSuchMethod( - Invocation.getter(#currentReceivingAddressP2SH), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + _i17.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future get chainHeight => (super.noSuchMethod( + _i17.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -851,15 +792,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); - @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), returnValue: '', @@ -880,7 +812,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { @override _i10.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_9( + returnValue: _FakeElectrumX_7( this, Invocation.getter(#electrumXClient), ), @@ -888,12 +820,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { @override _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_10( + returnValue: _FakeCachedElectrumX_8( this, Invocation.getter(#cachedElectrumXClient), ), ) as _i11.CachedElectrumX); @override + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( + this, + Invocation.getter(#balance), + ), + ) as _i12.Balance); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -903,37 +843,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateStoredChainHeight({required int? newHeight}) => + _i17.Future updateStoredChainHeight({required int? newHeight}) => (super.noSuchMethod( Invocation.method( #updateStoredChainHeight, [], {#newHeight: newHeight}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i19.DerivePathType addressType({required String? address}) => + _i20.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i19.DerivePathType.bip44, - ) as _i19.DerivePathType); + returnValue: _i20.DerivePathType.bip44, + ) as _i20.DerivePathType); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -950,48 +890,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTransactionCacheEarly(List? allAddresses) => + _i17.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i17.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getAllTxsToWatch(_i8.TransactionData? txData) => - (super.noSuchMethod( + _i17.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [txData], + [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1007,44 +946,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1062,33 +983,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1098,36 +1019,36 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i16.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i17.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i16.Future<_i10.ElectrumXNode>); + ) as _i17.Future<_i10.ElectrumXNode>); @override - _i16.Future addDerivation({ + _i17.Future addDerivation({ required int? chain, required String? address, required String? pubKey, required String? wif, - required _i19.DerivePathType? derivePathType, + required _i20.DerivePathType? derivePathType, }) => (super.noSuchMethod( Invocation.method( @@ -1141,13 +1062,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #derivePathType: derivePathType, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addDerivations({ + _i17.Future addDerivations({ required int? chain, - required _i19.DerivePathType? derivePathType, + required _i20.DerivePathType? derivePathType, required Map? derivationsToAdd, }) => (super.noSuchMethod( @@ -1160,50 +1081,50 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #derivationsToAdd: derivationsToAdd, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTxCount({required String? address}) => - (super.noSuchMethod( - Invocation.method( - #getTxCount, - [], - {#address: address}, - ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); - @override - _i16.Future checkCurrentReceivingAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentReceivingAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future checkCurrentChangeAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentChangeAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future>> fastFetch( + _i17.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i16.Future>>.value( + returnValue: _i17.Future>>.value( >[]), - ) as _i16.Future>>); + ) as _i17.Future>>); + @override + _i17.Future getTxCount({required String? address}) => + (super.noSuchMethod( + Invocation.method( + #getTxCount, + [], + {#address: address}, + ), + returnValue: _i17.Future.value(0), + ) as _i17.Future); + @override + _i17.Future checkCurrentReceivingAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentReceivingAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future checkCurrentChangeAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentChangeAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override int estimateTxFee({ required int? vSize, @@ -1227,7 +1148,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i8.UtxoObject>? utxos, + List<_i21.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1243,19 +1164,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, )); @override - _i16.Future> fetchBuildTxData( - List<_i8.UtxoObject>? utxosToUse) => + _i17.Future> fetchBuildTxData( + List<_i21.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future> buildTransaction({ - required List<_i8.UtxoObject>? utxosToUse, + _i17.Future> buildTransaction({ + required List<_i21.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -1272,10 +1193,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1287,11 +1208,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1303,8 +1224,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int roughFeeEstimate( int? inputCount, @@ -1323,21 +1244,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i17.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1345,41 +1266,41 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { /// See the documentation for Mockito's code generation for more information. class MockNodeService extends _i1.Mock implements _i3.NodeService { @override - _i12.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( + _i13.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_12( + returnValue: _FakeSecureStorageInterface_11( this, Invocation.getter(#secureStorageInterface), ), - ) as _i12.SecureStorageInterface); + ) as _i13.SecureStorageInterface); @override - List<_i20.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - List<_i20.NodeModel> get nodes => (super.noSuchMethod( + List<_i22.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future updateDefaults() => (super.noSuchMethod( + _i17.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setPrimaryNodeFor({ - required _i15.Coin? coin, - required _i20.NodeModel? node, + _i17.Future setPrimaryNodeFor({ + required _i16.Coin? coin, + required _i22.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1392,44 +1313,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i20.NodeModel? getPrimaryNodeFor({required _i15.Coin? coin}) => + _i22.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i20.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i20.NodeModel> getNodesFor(_i15.Coin? coin) => (super.noSuchMethod( + List<_i22.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - _i20.NodeModel? getNodeById({required String? id}) => + _i22.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i20.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i20.NodeModel> failoverNodesFor({required _i15.Coin? coin}) => + List<_i22.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - _i16.Future add( - _i20.NodeModel? node, + _i17.Future add( + _i22.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1442,11 +1363,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future delete( + _i17.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -1458,11 +1379,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setEnabledState( + _i17.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -1476,12 +1397,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future edit( - _i20.NodeModel? editedNode, + _i17.Future edit( + _i22.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -1494,20 +1415,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateCommunityNodes() => (super.noSuchMethod( + _i17.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1515,7 +1436,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1558,23 +1479,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i13.CoinServiceAPI get wallet => (super.noSuchMethod( + _i14.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_13( + returnValue: _FakeCoinServiceAPI_12( this, Invocation.getter(#wallet), ), - ) as _i13.CoinServiceAPI); + ) as _i14.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1607,91 +1528,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i9.Decimal); + ) as _i12.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i9.Decimal); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -1711,10 +1583,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -1731,14 +1603,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -1748,7 +1620,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1764,45 +1636,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1812,33 +1666,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1855,20 +1709,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exitCurrentWallet() => (super.noSuchMethod( + _i17.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1880,19 +1734,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); - @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1904,18 +1750,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1923,7 +1769,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1943,7 +1789,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 _i13.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1954,10 +1800,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1990,75 +1836,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); + Invocation.getter(#balance), + ), + ) as _i12.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2078,10 +1891,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -2098,7 +1911,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: 0, ) as int); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -2114,54 +1927,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2171,15 +1966,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -2196,38 +1991,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2239,11 +2034,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -2255,24 +2050,24 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } 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 e11e4bb51..882d4d79d 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,29 +3,31 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i16; -import 'dart:ui' as _i18; +import 'dart:async' as _i17; +import 'dart:ui' as _i19; -import 'package:decimal/decimal.dart' as _i9; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; +import 'package:isar/isar.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; -import 'package:stackwallet/models/models.dart' as _i8; -import 'package:stackwallet/models/node_model.dart' as _i20; -import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i19; -import 'package:stackwallet/services/coins/coin_service.dart' as _i13; +import 'package:stackwallet/models/balance.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i21; +import 'package:stackwallet/models/node_model.dart' as _i22; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; +import 'package:stackwallet/services/coins/coin_service.dart' as _i14; 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 _i7; -import 'package:stackwallet/services/wallets.dart' as _i14; +import 'package:stackwallet/services/wallets.dart' as _i15; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i12; -import 'package:stackwallet/utilities/prefs.dart' as _i17; + as _i13; +import 'package:stackwallet/utilities/prefs.dart' as _i18; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -91,8 +93,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { - _FakeUtxoData_5( +class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { + _FakeIsar_5( Object parent, Invocation parentInvocation, ) : super( @@ -101,8 +103,8 @@ class _FakeUtxoData_5 extends _i1.SmartFake implements _i8.UtxoData { ); } -class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { - _FakeDecimal_6( +class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { + _FakeFeeObject_6( Object parent, Invocation parentInvocation, ) : super( @@ -111,8 +113,8 @@ class _FakeDecimal_6 extends _i1.SmartFake implements _i9.Decimal { ); } -class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { - _FakeFeeObject_7( +class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { + _FakeElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -121,30 +123,9 @@ class _FakeFeeObject_7 extends _i1.SmartFake implements _i8.FeeObject { ); } -class _FakeTransactionData_8 extends _i1.SmartFake - implements _i8.TransactionData { - _FakeTransactionData_8( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeElectrumX_9 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeCachedElectrumX_10 extends _i1.SmartFake +class _FakeCachedElectrumX_8 extends _i1.SmartFake implements _i11.CachedElectrumX { - _FakeCachedElectrumX_10( + _FakeCachedElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -153,9 +134,19 @@ class _FakeCachedElectrumX_10 extends _i1.SmartFake ); } -class _FakeElectrumXNode_11 extends _i1.SmartFake +class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { + _FakeBalance_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i10.ElectrumXNode { - _FakeElectrumXNode_11( + _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, ) : super( @@ -164,9 +155,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeSecureStorageInterface_12 extends _i1.SmartFake - implements _i12.SecureStorageInterface { - _FakeSecureStorageInterface_12( +class _FakeSecureStorageInterface_11 extends _i1.SmartFake + implements _i13.SecureStorageInterface { + _FakeSecureStorageInterface_11( Object parent, Invocation parentInvocation, ) : super( @@ -175,9 +166,9 @@ class _FakeSecureStorageInterface_12 extends _i1.SmartFake ); } -class _FakeCoinServiceAPI_13 extends _i1.SmartFake - implements _i13.CoinServiceAPI { - _FakeCoinServiceAPI_13( +class _FakeCoinServiceAPI_12 extends _i1.SmartFake + implements _i14.CoinServiceAPI { + _FakeCoinServiceAPI_12( Object parent, Invocation parentInvocation, ) : super( @@ -189,7 +180,7 @@ class _FakeCoinServiceAPI_13 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 _i14.Wallets { +class MockWallets extends _i1.Mock implements _i15.Wallets { MockWallets() { _i1.throwOnMissingStub(this); } @@ -256,7 +247,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - List getWalletIdsFor({required _i15.Coin? coin}) => + List getWalletIdsFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #getWalletIdsFor, @@ -266,18 +257,18 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValue: [], ) as List); @override - Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> + Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>> getManagerProvidersByCoin() => (super.noSuchMethod( Invocation.method( #getManagerProvidersByCoin, [], ), - returnValue: <_i15.Coin, + returnValue: <_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>{}, - ) as Map<_i15.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); + ) as Map<_i16.Coin, List<_i5.ChangeNotifierProvider<_i6.Manager>>>); @override List<_i5.ChangeNotifierProvider<_i6.Manager>> getManagerProvidersForCoin( - _i15.Coin? coin) => + _i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getManagerProvidersForCoin, @@ -341,17 +332,17 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - _i16.Future load(_i17.Prefs? prefs) => (super.noSuchMethod( + _i17.Future load(_i18.Prefs? prefs) => (super.noSuchMethod( Invocation.method( #load, [prefs], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future loadAfterStackRestore( - _i17.Prefs? prefs, + _i17.Future loadAfterStackRestore( + _i18.Prefs? prefs, List<_i6.Manager>? managers, ) => (super.noSuchMethod( @@ -362,11 +353,11 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { managers, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -374,7 +365,7 @@ class MockWallets extends _i1.Mock implements _i14.Wallets { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -400,19 +391,19 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { } @override - _i16.Future> get walletNames => + _i17.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i16.Future>.value( + returnValue: _i17.Future>.value( {}), - ) as _i16.Future>); + ) as _i17.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future renameWallet({ + _i17.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -427,13 +418,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future addExistingStackWallet({ + _i17.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -447,13 +438,13 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addNewWallet({ + _i17.Future addNewWallet({ required String? name, - required _i15.Coin? coin, + required _i16.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -466,46 +457,46 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i17.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future saveFavoriteWalletIds(List? walletIds) => + _i17.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i17.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future moveFavorite({ + _i17.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -518,48 +509,48 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i17.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i17.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isMnemonicVerified({required String? walletId}) => + _i17.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future setMnemonicVerified({required String? walletId}) => + _i17.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future deleteWallet( + _i17.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -571,20 +562,20 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future refreshWallets(bool? shouldNotifyListeners) => + _i17.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -592,7 +583,7 @@ class MockWalletsService extends _i1.Mock implements _i2.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -620,13 +611,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 _i19.BitcoinWallet { +class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { MockBitcoinWallet() { _i1.throwOnMissingStub(this); } @override - set timer(_i16.Timer? _timer) => super.noSuchMethod( + set timer(_i17.Timer? _timer) => super.noSuchMethod( Invocation.setter( #timer, _timer, @@ -651,19 +642,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - List<_i8.UtxoObject> get outputsList => (super.noSuchMethod( - Invocation.getter(#outputsList), - returnValue: <_i8.UtxoObject>[], - ) as List<_i8.UtxoObject>); - @override - set outputsList(List<_i8.UtxoObject>? _outputsList) => super.noSuchMethod( - Invocation.setter( - #outputsList, - _outputsList, - ), - returnValueForMissingStub: null, - ); - @override bool get longMutex => (super.noSuchMethod( Invocation.getter(#longMutex), returnValue: false, @@ -690,10 +668,18 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - set cachedTxData(_i8.TransactionData? _cachedTxData) => super.noSuchMethod( + _i8.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#isar), + ), + ) as _i8.Isar); + @override + set isar(_i8.Isar? _isar) => super.noSuchMethod( Invocation.setter( - #cachedTxData, - _cachedTxData, + #isar, + _isar, ), returnValueForMissingStub: null, ); @@ -724,104 +710,59 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override - _i16.Future<_i8.UtxoData> get utxoData => (super.noSuchMethod( - Invocation.getter(#utxoData), - returnValue: _i16.Future<_i8.UtxoData>.value(_FakeUtxoData_5( - this, - Invocation.getter(#utxoData), - )), - ) as _i16.Future<_i8.UtxoData>); - @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future get currentLegacyReceivingAddress => (super.noSuchMethod( - Invocation.getter(#currentLegacyReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future get currentReceivingAddressP2SH => (super.noSuchMethod( - Invocation.getter(#currentReceivingAddressP2SH), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + _i17.Future get currentChangeAddress => (super.noSuchMethod( + Invocation.getter(#currentChangeAddress), + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), returnValue: false, ) as bool); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override - _i16.Future get chainHeight => (super.noSuchMethod( + _i17.Future get chainHeight => (super.noSuchMethod( Invocation.getter(#chainHeight), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int get storedChainHeight => (super.noSuchMethod( Invocation.getter(#storedChainHeight), @@ -851,15 +792,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), - returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); - @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), returnValue: '', @@ -880,7 +812,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { @override _i10.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_9( + returnValue: _FakeElectrumX_7( this, Invocation.getter(#electrumXClient), ), @@ -888,12 +820,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { @override _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_10( + returnValue: _FakeCachedElectrumX_8( this, Invocation.getter(#cachedElectrumXClient), ), ) as _i11.CachedElectrumX); @override + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( + this, + Invocation.getter(#balance), + ), + ) as _i12.Balance); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -903,37 +843,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateStoredChainHeight({required int? newHeight}) => + _i17.Future updateStoredChainHeight({required int? newHeight}) => (super.noSuchMethod( Invocation.method( #updateStoredChainHeight, [], {#newHeight: newHeight}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i19.DerivePathType addressType({required String? address}) => + _i20.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( #addressType, [], {#address: address}, ), - returnValue: _i19.DerivePathType.bip44, - ) as _i19.DerivePathType); + returnValue: _i20.DerivePathType.bip44, + ) as _i20.DerivePathType); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -950,48 +890,47 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTransactionCacheEarly(List? allAddresses) => + _i17.Future getTransactionCacheEarly(List? allAddresses) => (super.noSuchMethod( Invocation.method( #getTransactionCacheEarly, [allAddresses], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refreshIfThereIsNewData() => (super.noSuchMethod( + _i17.Future refreshIfThereIsNewData() => (super.noSuchMethod( Invocation.method( #refreshIfThereIsNewData, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future getAllTxsToWatch(_i8.TransactionData? txData) => - (super.noSuchMethod( + _i17.Future getAllTxsToWatch() => (super.noSuchMethod( Invocation.method( #getAllTxsToWatch, - [txData], + [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1007,44 +946,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override void startNetworkAlivePinging() => super.noSuchMethod( Invocation.method( @@ -1062,33 +983,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1098,36 +1019,36 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i16.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i17.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i16.Future<_i10.ElectrumXNode>); + ) as _i17.Future<_i10.ElectrumXNode>); @override - _i16.Future addDerivation({ + _i17.Future addDerivation({ required int? chain, required String? address, required String? pubKey, required String? wif, - required _i19.DerivePathType? derivePathType, + required _i20.DerivePathType? derivePathType, }) => (super.noSuchMethod( Invocation.method( @@ -1141,13 +1062,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #derivePathType: derivePathType, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future addDerivations({ + _i17.Future addDerivations({ required int? chain, - required _i19.DerivePathType? derivePathType, + required _i20.DerivePathType? derivePathType, required Map? derivationsToAdd, }) => (super.noSuchMethod( @@ -1160,50 +1081,50 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { #derivationsToAdd: derivationsToAdd, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future getTxCount({required String? address}) => - (super.noSuchMethod( - Invocation.method( - #getTxCount, - [], - {#address: address}, - ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); - @override - _i16.Future checkCurrentReceivingAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentReceivingAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future checkCurrentChangeAddressesForTransactions() => - (super.noSuchMethod( - Invocation.method( - #checkCurrentChangeAddressesForTransactions, - [], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override - _i16.Future>> fastFetch( + _i17.Future>> fastFetch( List? allTxHashes) => (super.noSuchMethod( Invocation.method( #fastFetch, [allTxHashes], ), - returnValue: _i16.Future>>.value( + returnValue: _i17.Future>>.value( >[]), - ) as _i16.Future>>); + ) as _i17.Future>>); + @override + _i17.Future getTxCount({required String? address}) => + (super.noSuchMethod( + Invocation.method( + #getTxCount, + [], + {#address: address}, + ), + returnValue: _i17.Future.value(0), + ) as _i17.Future); + @override + _i17.Future checkCurrentReceivingAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentReceivingAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future checkCurrentChangeAddressesForTransactions() => + (super.noSuchMethod( + Invocation.method( + #checkCurrentChangeAddressesForTransactions, + [], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override int estimateTxFee({ required int? vSize, @@ -1227,7 +1148,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { String? _recipientAddress, bool? isSendAll, { int? additionalOutputs = 0, - List<_i8.UtxoObject>? utxos, + List<_i21.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1243,19 +1164,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, )); @override - _i16.Future> fetchBuildTxData( - List<_i8.UtxoObject>? utxosToUse) => + _i17.Future> fetchBuildTxData( + List<_i21.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, [utxosToUse], ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future> buildTransaction({ - required List<_i8.UtxoObject>? utxosToUse, + _i17.Future> buildTransaction({ + required List<_i21.UTXO>? utxosToUse, required Map? utxoSigningData, required List? recipients, required List? satoshiAmounts, @@ -1272,10 +1193,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1287,11 +1208,11 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1303,8 +1224,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override int roughFeeEstimate( int? inputCount, @@ -1323,21 +1244,21 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: 0, ) as int); @override - int sweepAllEstimate(int? feeRate) => (super.noSuchMethod( + _i17.Future sweepAllEstimate(int? feeRate) => (super.noSuchMethod( Invocation.method( #sweepAllEstimate, [feeRate], ), - returnValue: 0, - ) as int); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1345,41 +1266,41 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { /// See the documentation for Mockito's code generation for more information. class MockNodeService extends _i1.Mock implements _i3.NodeService { @override - _i12.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( + _i13.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_12( + returnValue: _FakeSecureStorageInterface_11( this, Invocation.getter(#secureStorageInterface), ), - ) as _i12.SecureStorageInterface); + ) as _i13.SecureStorageInterface); @override - List<_i20.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - List<_i20.NodeModel> get nodes => (super.noSuchMethod( + List<_i22.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i16.Future updateDefaults() => (super.noSuchMethod( + _i17.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setPrimaryNodeFor({ - required _i15.Coin? coin, - required _i20.NodeModel? node, + _i17.Future setPrimaryNodeFor({ + required _i16.Coin? coin, + required _i22.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1392,44 +1313,44 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i20.NodeModel? getPrimaryNodeFor({required _i15.Coin? coin}) => + _i22.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i20.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i20.NodeModel> getNodesFor(_i15.Coin? coin) => (super.noSuchMethod( + List<_i22.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - _i20.NodeModel? getNodeById({required String? id}) => + _i22.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i20.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i20.NodeModel> failoverNodesFor({required _i15.Coin? coin}) => + List<_i22.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i20.NodeModel>[], - ) as List<_i20.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - _i16.Future add( - _i20.NodeModel? node, + _i17.Future add( + _i22.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1442,11 +1363,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future delete( + _i17.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -1458,11 +1379,11 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future setEnabledState( + _i17.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -1476,12 +1397,12 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future edit( - _i20.NodeModel? editedNode, + _i17.Future edit( + _i22.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -1494,20 +1415,20 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { shouldNotifyListeners, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateCommunityNodes() => (super.noSuchMethod( + _i17.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1515,7 +1436,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1558,23 +1479,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i13.CoinServiceAPI get wallet => (super.noSuchMethod( + _i14.CoinServiceAPI get wallet => (super.noSuchMethod( Invocation.getter(#wallet), - returnValue: _FakeCoinServiceAPI_13( + returnValue: _FakeCoinServiceAPI_12( this, Invocation.getter(#wallet), ), - ) as _i13.CoinServiceAPI); + ) as _i14.CoinServiceAPI); @override bool get hasBackgroundRefreshListener => (super.noSuchMethod( Invocation.getter(#hasBackgroundRefreshListener), returnValue: false, ) as bool); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1607,91 +1528,42 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedAvailableBalance => (super.noSuchMethod( - Invocation.getter(#cachedAvailableBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedAvailableBalance), + Invocation.getter(#balance), ), - ) as _i9.Decimal); + ) as _i12.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i9.Decimal get cachedTotalBalance => (super.noSuchMethod( - Invocation.getter(#cachedTotalBalance), - returnValue: _FakeDecimal_6( - this, - Invocation.getter(#cachedTotalBalance), - ), - ) as _i9.Decimal); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -1711,10 +1583,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -1731,14 +1603,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -1748,7 +1620,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -1764,45 +1636,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args = const {}, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1812,33 +1666,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -1855,20 +1709,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exitCurrentWallet() => (super.noSuchMethod( + _i17.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -1880,19 +1734,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future isOwnAddress(String? address) => (super.noSuchMethod( - Invocation.method( - #isOwnAddress, - [address], - ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); - @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -1904,18 +1750,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - void addListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1923,7 +1769,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i18.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -1943,7 +1789,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 _i13.CoinServiceAPI { +class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1954,10 +1800,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i15.Coin get coin => (super.noSuchMethod( + _i16.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i15.Coin.bitcoin, - ) as _i15.Coin); + returnValue: _i16.Coin.bitcoin, + ) as _i16.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1990,75 +1836,42 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i8.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override - _i16.Future get maxFee => (super.noSuchMethod( + _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future get currentReceivingAddress => (super.noSuchMethod( + _i17.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future<_i9.Decimal> get availableBalance => (super.noSuchMethod( - Invocation.getter(#availableBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( + _i12.Balance get balance => (super.noSuchMethod( + Invocation.getter(#balance), + returnValue: _FakeBalance_9( this, - Invocation.getter(#availableBalance), - )), - ) as _i16.Future<_i9.Decimal>); + Invocation.getter(#balance), + ), + ) as _i12.Balance); @override - _i16.Future<_i9.Decimal> get pendingBalance => (super.noSuchMethod( - Invocation.getter(#pendingBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#pendingBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get totalBalance => (super.noSuchMethod( - Invocation.getter(#totalBalance), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#totalBalance), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future<_i9.Decimal> get balanceMinusMaxFee => (super.noSuchMethod( - Invocation.getter(#balanceMinusMaxFee), - returnValue: _i16.Future<_i9.Decimal>.value(_FakeDecimal_6( - this, - Invocation.getter(#balanceMinusMaxFee), - )), - ) as _i16.Future<_i9.Decimal>); - @override - _i16.Future> get allOwnAddresses => (super.noSuchMethod( - Invocation.getter(#allOwnAddresses), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); - @override - _i16.Future<_i8.TransactionData> get transactionData => (super.noSuchMethod( - Invocation.getter(#transactionData), + _i17.Future> get transactions => (super.noSuchMethod( + Invocation.getter(#transactions), returnValue: - _i16.Future<_i8.TransactionData>.value(_FakeTransactionData_8( - this, - Invocation.getter(#transactionData), - )), - ) as _i16.Future<_i8.TransactionData>); + _i17.Future>.value(<_i21.Transaction>[]), + ) as _i17.Future>); @override - _i16.Future> get unspentOutputs => (super.noSuchMethod( - Invocation.getter(#unspentOutputs), - returnValue: - _i16.Future>.value(<_i8.UtxoObject>[]), - ) as _i16.Future>); + _i17.Future> get utxos => (super.noSuchMethod( + Invocation.getter(#utxos), + returnValue: _i17.Future>.value(<_i21.UTXO>[]), + ) as _i17.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2078,10 +1891,10 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: '', ) as String); @override - _i16.Future> get mnemonic => (super.noSuchMethod( + _i17.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i16.Future>.value([]), - ) as _i16.Future>); + returnValue: _i17.Future>.value([]), + ) as _i17.Future>); @override bool get hasCalledExit => (super.noSuchMethod( Invocation.getter(#hasCalledExit), @@ -2098,7 +1911,7 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: 0, ) as int); @override - _i16.Future> prepareSend({ + _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -2114,54 +1927,36 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { }, ), returnValue: - _i16.Future>.value({}), - ) as _i16.Future>); + _i17.Future>.value({}), + ) as _i17.Future>); @override - _i16.Future confirmSend({required Map? txData}) => + _i17.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); + returnValue: _i17.Future.value(''), + ) as _i17.Future); @override - _i16.Future send({ - required String? toAddress, - required int? amount, - Map? args, - }) => - (super.noSuchMethod( - Invocation.method( - #send, - [], - { - #toAddress: toAddress, - #amount: amount, - #args: args, - }, - ), - returnValue: _i16.Future.value(''), - ) as _i16.Future); - @override - _i16.Future refresh() => (super.noSuchMethod( + _i17.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i17.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -2171,15 +1966,15 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: false, ) as bool); @override - _i16.Future testNetworkConnection() => (super.noSuchMethod( + _i17.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future recoverFromMnemonic({ + _i17.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -2196,38 +1991,38 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { #height: height, }, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeNew() => (super.noSuchMethod( + _i17.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future initializeExisting() => (super.noSuchMethod( + _i17.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future exit() => (super.noSuchMethod( + _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, [], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future fullRescan( + _i17.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -2239,11 +2034,11 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { maxNumberOfIndexesToCheck, ], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override - _i16.Future estimateFeeFor( + _i17.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -2255,24 +2050,24 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { feeRate, ], ), - returnValue: _i16.Future.value(0), - ) as _i16.Future); + returnValue: _i17.Future.value(0), + ) as _i17.Future); @override - _i16.Future generateNewAddress() => (super.noSuchMethod( + _i17.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i17.Future.value(false), + ) as _i17.Future); @override - _i16.Future updateSentCachedTxData(Map? txData) => + _i17.Future updateSentCachedTxData(Map? txData) => (super.noSuchMethod( Invocation.method( #updateSentCachedTxData, [txData], ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } From a73e18df75a754ffe0e3546c15dec7d25d528808 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:23:21 -0600 Subject: [PATCH 106/192] expose wallet isar instance to Manager --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 3 +++ lib/services/coins/bitcoincash/bitcoincash_wallet.dart | 3 +++ lib/services/coins/coin_service.dart | 3 +++ lib/services/coins/dogecoin/dogecoin_wallet.dart | 3 +++ lib/services/coins/epiccash/epiccash_wallet.dart | 3 +++ lib/services/coins/firo/firo_wallet.dart | 5 +++-- lib/services/coins/litecoin/litecoin_wallet.dart | 3 +++ lib/services/coins/manager.dart | 3 +++ lib/services/coins/monero/monero_wallet.dart | 3 +++ lib/services/coins/namecoin/namecoin_wallet.dart | 3 +++ lib/services/coins/particl/particl_wallet.dart | 3 +++ lib/services/coins/wownero/wownero_wallet.dart | 3 +++ 12 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index c3f446c23..1e62ea73e 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -3571,4 +3571,7 @@ class BitcoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index bd0033614..079bdce7f 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -3276,6 +3276,9 @@ class BitcoinCashWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Bitcoincash Network diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index fb433466c..e6f5eba5e 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -1,3 +1,4 @@ +import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -294,4 +295,6 @@ abstract class CoinServiceAPI { Future updateSentCachedTxData(Map txData); int get storedChainHeight; + + Isar get isarInstance; } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 8c5535172..200b509c5 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -2749,6 +2749,9 @@ class DogecoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Dogecoin Network diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index fa2d3aa49..8db32c147 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -2337,4 +2337,7 @@ class EpicCashWallet extends CoinServiceAPI { @override Future> get transactions => isar.transactions.where().findAll(); + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 9c8ec32be..452a3c0f5 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -4873,11 +4873,12 @@ class FiroWallet extends CoinServiceAPI { Balance? _balancePrivate; @override - // TODO: implement utxos Future> get utxos => isar.utxos.where().findAll(); @override - // TODO: implement transactions Future> get transactions => isar.transactions.where().findAll(); + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index cd32ee605..199039f02 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -3623,6 +3623,9 @@ class LitecoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } final litecoin = NetworkType( diff --git a/lib/services/coins/manager.dart b/lib/services/coins/manager.dart index a590752e0..90e91ce60 100644 --- a/lib/services/coins/manager.dart +++ b/lib/services/coins/manager.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/models.dart'; @@ -214,4 +215,6 @@ class Manager with ChangeNotifier { } int get currentHeight => _currentWallet.storedChainHeight; + + Isar get db => _currentWallet.isarInstance; } diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 017e5de81..5093d2ff6 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1271,4 +1271,7 @@ class MoneroWallet extends CoinServiceAPI { @override // TODO: implement utxos Future> get utxos => throw UnimplementedError(); + + @override + Isar get isarInstance => isar; } diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 1177e9057..d1901ce7f 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -3615,6 +3615,9 @@ class NamecoinWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Namecoin Network diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index b95c6d567..e5cea378a 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -3384,6 +3384,9 @@ class ParticlWallet extends CoinServiceAPI { return false; } } + + @override + Isar get isarInstance => isar; } // Particl Network diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 43c04d80a..2a0bf0ada 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1347,4 +1347,7 @@ class WowneroWallet extends CoinServiceAPI { @override // TODO: implement utxos Future> get utxos => throw UnimplementedError(); + + @override + Isar get isarInstance => isar; } From eb915a0927e211414a4aee86cec0025762fe25e4 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:35:14 -0600 Subject: [PATCH 107/192] use isar query to fetch contact transactions --- .../subviews/contact_details_view.dart | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/lib/pages/address_book_views/subviews/contact_details_view.dart b/lib/pages/address_book_views/subviews/contact_details_view.dart index 0ab6ebba9..5459f01a1 100644 --- a/lib/pages/address_book_views/subviews/contact_details_view.dart +++ b/lib/pages/address_book_views/subviews/contact_details_view.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/contact.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart'; import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_address_view.dart'; @@ -15,7 +15,6 @@ import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -50,15 +49,6 @@ class _ContactDetailsViewState extends ConsumerState { List> _cachedTransactions = []; - bool _contactHasAddress(String address, Contact contact) { - for (final entry in contact.addresses) { - if (entry.address == address) { - return true; - } - } - return false; - } - Future>> _filteredTransactionsByContact( List managers, ) async { @@ -69,18 +59,17 @@ class _ContactDetailsViewState extends ConsumerState { List> result = []; for (final manager in managers) { - final transactions = (await manager.transactionData) - .getAllTransactions() - .values - .toList() - .where((e) => _contactHasAddress(e.address, contact)); + final transactions = await manager.db.transactions + .filter() + .anyOf(contact.addresses.map((e) => e.address), + (q, String e) => q.addressEqualTo(e)) + .sortByTimestampDesc() + .findAll(); for (final tx in transactions) { result.add(Tuple2(manager.walletId, tx)); } } - // sort by date - result.sort((a, b) => b.item2.timestamp - a.item2.timestamp); return result; } From f8c6a17fa782cd7902c600bbf4172c8ce3c595e3 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 22:26:38 -0600 Subject: [PATCH 108/192] update wallet ui to handle new data models --- .../exchange_view/trade_details_view.dart | 3 +- .../sub_widgets/transactions_list.dart | 401 ++++-------------- .../wallet_view/sub_widgets/tx_icon.dart | 73 +--- .../wallet_balance_toggle_sheet.dart | 11 +- .../sub_widgets/wallet_summary_info.dart | 16 +- .../all_transactions_view.dart | 63 +-- .../transaction_details_view.dart | 88 ++-- .../wallet_view/sub_widgets/desktop_send.dart | 161 ++++--- .../sub_widgets/desktop_wallet_summary.dart | 18 +- lib/widgets/transaction_card.dart | 305 ++----------- 10 files changed, 318 insertions(+), 821 deletions(-) diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index 479600569..b5f2bda6e 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -7,7 +7,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart'; import 'package:stackwallet/pages/exchange_view/send_from_view.dart'; @@ -23,7 +23,6 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index ea78984b9..0834b0d8d 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart' as old; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; @@ -14,7 +13,6 @@ import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/manager.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/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -42,20 +40,10 @@ class TransactionsList extends ConsumerStatefulWidget { class _TransactionsListState extends ConsumerState { // bool _hasLoaded = false; - Map _transactions = {}; List _transactions2 = []; late final ChangeNotifierProvider managerProvider; - void updateTransactions(old.TransactionData newData) { - _transactions = {}; - final newTransactions = - newData.txChunks.expand((element) => element.transactions); - for (final tx in newTransactions) { - _transactions[tx.txid] = tx; - } - } - BorderRadius get _borderRadiusFirst { return BorderRadius.only( topLeft: Radius.circular( @@ -80,14 +68,14 @@ class _TransactionsListState extends ConsumerState { Widget itemBuilder( BuildContext context, - old.Transaction tx, + Transaction tx, BorderRadius? radius, ) { final matchingTrades = ref .read(tradesServiceProvider) .trades .where((e) => e.payInTxid == tx.txid || e.payOutTxid == tx.txid); - if (tx.txType == "Sent" && matchingTrades.isNotEmpty) { + if (tx.type == TransactionType.outgoing && matchingTrades.isNotEmpty) { final trade = matchingTrades.first; return Container( decoration: BoxDecoration( @@ -199,127 +187,6 @@ class _TransactionsListState extends ConsumerState { } } - Widget itemBuilder2( - BuildContext context, - Transaction tx, - BorderRadius? radius, - ) { - final matchingTrades = ref - .read(tradesServiceProvider) - .trades - .where((e) => e.payInTxid == tx.txid || e.payOutTxid == tx.txid); - if (tx.type == TransactionType.outgoing && matchingTrades.isNotEmpty) { - final trade = matchingTrades.first; - return Container( - decoration: BoxDecoration( - color: Theme.of(context).extension()!.popupBG, - borderRadius: radius, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - TransactionCard2( - // this may mess with combined firo transactions - key: Key(tx.toString()), // - transaction: tx, - walletId: widget.walletId, - ), - TradeCard( - // this may mess with combined firo transactions - key: Key(tx.toString() + trade.uuid), // - trade: trade, - onTap: () async { - if (Util.isDesktop) { - // await showDialog( - // context: context, - // builder: (context) => Navigator( - // initialRoute: TradeDetailsView.routeName, - // onGenerateRoute: RouteGenerator.generateRoute, - // onGenerateInitialRoutes: (_, __) { - // return [ - // FadePageRoute( - // DesktopDialog( - // maxHeight: null, - // maxWidth: 580, - // child: Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Padding( - // padding: const EdgeInsets.only( - // left: 32, - // bottom: 16, - // ), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // "Trade details", - // style: STextStyles.desktopH3(context), - // ), - // DesktopDialogCloseButton( - // onPressedOverride: Navigator.of( - // context, - // rootNavigator: true, - // ).pop, - // ), - // ], - // ), - // ), - // Flexible( - // child: TradeDetailsView( - // tradeId: trade.tradeId, - // transactionIfSentFromStack: tx, - // walletName: - // ref.read(managerProvider).walletName, - // walletId: widget.walletId, - // ), - // ), - // ], - // ), - // ), - // const RouteSettings( - // name: TradeDetailsView.routeName, - // ), - // ), - // ]; - // }, - // ), - // ); - } else { - unawaited( - Navigator.of(context).pushNamed( - TradeDetailsView.routeName, - arguments: Tuple4( - trade.tradeId, - tx, - widget.walletId, - ref.read(managerProvider).walletName, - ), - ), - ); - } - }, - ) - ], - ), - ); - } else { - return Container( - decoration: BoxDecoration( - color: Theme.of(context).extension()!.popupBG, - borderRadius: radius, - ), - child: TransactionCard2( - // this may mess with combined firo transactions - key: Key(tx.toString()), // - transaction: tx, - walletId: widget.walletId, - ), - ); - } - } - void updateHeightProvider(Manager manager) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { ref.read(currentHeightProvider(manager.coin).state).state = @@ -342,186 +209,94 @@ class _TransactionsListState extends ConsumerState { final manager = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(widget.walletId))); - if (manager.coin == Coin.dogecoinTestNet) { - updateHeightProvider(manager); - final wallet = manager.wallet as DogecoinWallet; - return FutureBuilder( - future: wallet.isar.transactions.where().findAll(), - builder: (fbContext, AsyncSnapshot> snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - _transactions2 = snapshot.data!; - _hasLoaded = true; - } - if (!_hasLoaded) { - return Column( - children: const [ - Spacer(), - Center( - child: LoadingIndicator( - height: 50, - width: 50, - ), + updateHeightProvider(manager); + final wallet = manager.wallet as DogecoinWallet; + return FutureBuilder( + future: wallet.isar.transactions.where().findAll(), + builder: (fbContext, AsyncSnapshot> snapshot) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.hasData) { + _transactions2 = snapshot.data!; + _hasLoaded = true; + } + if (!_hasLoaded) { + return Column( + children: const [ + Spacer(), + Center( + child: LoadingIndicator( + height: 50, + width: 50, ), - Spacer( - flex: 4, - ), - ], - ); - } - if (_transactions2.isEmpty) { - return const NoTransActionsFound(); - } else { - _transactions2.sort((a, b) => b.timestamp - a.timestamp); - return RefreshIndicator( - onRefresh: () async { - //todo: check if print needed - // debugPrint("pulled down to refresh on transaction list"); - final managerProvider = ref - .read(walletsChangeNotifierProvider) - .getManagerProvider(widget.walletId); - if (!ref.read(managerProvider).isRefreshing) { - unawaited(ref.read(managerProvider).refresh()); - } - }, - child: Util.isDesktop - ? ListView.separated( - itemBuilder: (context, index) { - BorderRadius? radius; - if (_transactions2.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == _transactions2.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = _transactions2[index]; - return itemBuilder2(context, tx, radius); - }, - separatorBuilder: (context, index) { - return Container( - width: double.infinity, - height: 2, - color: Theme.of(context) - .extension()! - .background, + ), + Spacer( + flex: 4, + ), + ], + ); + } + if (_transactions2.isEmpty) { + return const NoTransActionsFound(); + } else { + _transactions2.sort((a, b) => b.timestamp - a.timestamp); + return RefreshIndicator( + onRefresh: () async { + //todo: check if print needed + // debugPrint("pulled down to refresh on transaction list"); + final managerProvider = ref + .read(walletsChangeNotifierProvider) + .getManagerProvider(widget.walletId); + if (!ref.read(managerProvider).isRefreshing) { + unawaited(ref.read(managerProvider).refresh()); + } + }, + child: Util.isDesktop + ? ListView.separated( + itemBuilder: (context, index) { + BorderRadius? radius; + if (_transactions2.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, ); - }, - itemCount: _transactions2.length, - ) - : ListView.builder( - itemCount: _transactions2.length, - itemBuilder: (context, index) { - BorderRadius? radius; - if (_transactions2.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == _transactions2.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = _transactions2[index]; - return itemBuilder2(context, tx, radius); - }, - ), - ); - } - }, - ); - } else { - return FutureBuilder( - future: - ref.watch(managerProvider.select((value) => value.transactionData)), - builder: (fbContext, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - updateTransactions(snapshot.data!); - _hasLoaded = true; - } - if (!_hasLoaded) { - return Column( - children: const [ - Spacer(), - Center( - child: LoadingIndicator( - height: 50, - width: 50, - ), - ), - Spacer( - flex: 4, - ), - ], - ); - } - if (_transactions.isEmpty) { - return const NoTransActionsFound(); - } else { - final list = _transactions.values.toList(growable: false); - list.sort((a, b) => b.timestamp - a.timestamp); - return RefreshIndicator( - onRefresh: () async { - //todo: check if print needed - // debugPrint("pulled down to refresh on transaction list"); - final managerProvider = ref - .read(walletsChangeNotifierProvider) - .getManagerProvider(widget.walletId); - if (!ref.read(managerProvider).isRefreshing) { - unawaited(ref.read(managerProvider).refresh()); - } - }, - child: Util.isDesktop - ? ListView.separated( - itemBuilder: (context, index) { - BorderRadius? radius; - if (list.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == list.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = list[index]; - return itemBuilder(context, tx, radius); - }, - separatorBuilder: (context, index) { - return Container( - width: double.infinity, - height: 2, - color: Theme.of(context) - .extension()! - .background, + } else if (index == _transactions2.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = _transactions2[index]; + return itemBuilder(context, tx, radius); + }, + separatorBuilder: (context, index) { + return Container( + width: double.infinity, + height: 2, + color: Theme.of(context) + .extension()! + .background, + ); + }, + itemCount: _transactions2.length, + ) + : ListView.builder( + itemCount: _transactions2.length, + itemBuilder: (context, index) { + BorderRadius? radius; + if (_transactions2.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, ); - }, - itemCount: list.length, - ) - : ListView.builder( - itemCount: list.length, - itemBuilder: (context, index) { - BorderRadius? radius; - if (list.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == list.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = list[index]; - return itemBuilder(context, tx, radius); - }, - ), - ); - } - }, - ); - } + } else if (index == _transactions2.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = _transactions2[index]; + return itemBuilder(context, tx, radius); + }, + ), + ); + } + }, + ); } } diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index e0983bd47..ee3b1b115 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -1,79 +1,18 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; -import 'package:stackwallet/models/paymint/transactions_model.dart' as old; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; class TxIcon extends StatelessWidget { - const TxIcon({Key? key, required this.transaction}) : super(key: key); - final old.Transaction transaction; - - static const Size size = Size(32, 32); - - String _getAssetName( - bool isCancelled, bool isReceived, bool isPending, BuildContext context) { - if (!isReceived && transaction.subType == "mint") { - if (isCancelled) { - return Assets.svg.anonymizeFailed; - } - if (isPending) { - return Assets.svg.anonymizePending; - } - return Assets.svg.anonymize; - } - - if (isReceived) { - if (isCancelled) { - return Assets.svg.receiveCancelled(context); - } - if (isPending) { - return Assets.svg.receivePending(context); - } - return Assets.svg.receive(context); - } else { - if (isCancelled) { - return Assets.svg.sendCancelled(context); - } - if (isPending) { - return Assets.svg.sendPending(context); - } - return Assets.svg.send(context); - } - } - - @override - Widget build(BuildContext context) { - final txIsReceived = transaction.txType == "Received"; - - return SizedBox( - width: size.width, - height: size.height, - child: Center( - child: SvgPicture.asset( - _getAssetName( - transaction.isCancelled, - txIsReceived, - !transaction.confirmedStatus, - context, - ), - width: size.width, - height: size.height, - ), - ), - ); - } -} - -class TxIcon2 extends StatelessWidget { - const TxIcon2({ + const TxIcon({ Key? key, required this.transaction, required this.currentHeight, required this.coin, }) : super(key: key); - final isar_models.Transaction transaction; + final Transaction transaction; final int currentHeight; final Coin coin; @@ -81,8 +20,7 @@ class TxIcon2 extends StatelessWidget { String _getAssetName( bool isCancelled, bool isReceived, bool isPending, BuildContext context) { - if (!isReceived && - transaction.subType == isar_models.TransactionSubType.mint) { + if (!isReceived && transaction.subType == TransactionSubType.mint) { if (isCancelled) { return Assets.svg.anonymizeFailed; } @@ -113,8 +51,7 @@ class TxIcon2 extends StatelessWidget { @override Widget build(BuildContext context) { - final txIsReceived = - transaction.type == isar_models.TransactionType.incoming; + final txIsReceived = transaction.type == TransactionType.incoming; return SizedBox( width: size.width, diff --git a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart index 74308f2e8..7686bc3ab 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart @@ -32,13 +32,14 @@ class WalletBalanceToggleSheet extends ConsumerWidget { .watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId))) .wallet as FiroWallet; - totalBalanceFuture = firoWallet.availablePublicBalance(); - availableBalanceFuture = firoWallet.availablePrivateBalance(); + totalBalanceFuture = Future(() => firoWallet.balance.getSpendable()); + availableBalanceFuture = + Future(() => firoWallet.balancePrivate.getSpendable()); } else { - final wallet = ref.watch(walletsChangeNotifierProvider + final manager = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId))); - totalBalanceFuture = wallet.totalBalance; - availableBalanceFuture = wallet.availableBalance; + totalBalanceFuture = Future(() => manager.balance.getTotal()); + availableBalanceFuture = Future(() => manager.balance.getSpendable()); } return Container( diff --git a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart index d38e17a6a..66e47440b 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart @@ -79,14 +79,16 @@ class _WalletSummaryInfoState extends State { final firoWallet = ref.watch(managerProvider.select((value) => value.wallet)) as FiroWallet; - totalBalanceFuture = firoWallet.availablePublicBalance(); - availableBalanceFuture = firoWallet.availablePrivateBalance(); + totalBalanceFuture = + Future(() => firoWallet.balance.getSpendable()); + availableBalanceFuture = + Future(() => firoWallet.balancePrivate.getSpendable()); } else { - totalBalanceFuture = ref.watch( - managerProvider.select((value) => value.totalBalance)); - - availableBalanceFuture = ref.watch( - managerProvider.select((value) => value.availableBalance)); + final manager = ref.watch(walletsChangeNotifierProvider + .select((value) => value.getManager(walletId))); + totalBalanceFuture = Future(() => manager.balance.getTotal()); + availableBalanceFuture = + Future(() => manager.balance.getSpendable()); } final locale = ref.watch(localeServiceChangeNotifierProvider diff --git a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart index 27bb36331..4ff070712 100644 --- a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart +++ b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/contact.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; import 'package:stackwallet/models/transaction_filter.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; @@ -34,6 +33,9 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:stackwallet/widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../providers/blockchain/dogecoin/current_height_provider.dart'; + class AllTransactionsView extends ConsumerStatefulWidget { const AllTransactionsView({ Key? key, @@ -89,11 +91,15 @@ class _TransactionDetailsViewState extends ConsumerState { return false; } - if (filter.received && !filter.sent && tx.txType == "Sent") { + if (filter.received && + !filter.sent && + tx.type == TransactionType.outgoing) { return false; } - if (filter.sent && !filter.received && tx.txType == "Received") { + if (filter.sent && + !filter.received && + tx.type == TransactionType.incoming) { return false; } @@ -141,11 +147,10 @@ class _TransactionDetailsViewState extends ConsumerState { contains |= tx.txid.toLowerCase().contains(keyword); // check if subType contains - contains |= - tx.subType.isNotEmpty && tx.subType.toLowerCase().contains(keyword); + contains |= tx.subType.name.toLowerCase().contains(keyword); // check if txType contains - contains |= tx.txType.toLowerCase().contains(keyword); + contains |= tx.type.name.toLowerCase().contains(keyword); // check if date contains contains |= @@ -454,17 +459,13 @@ class _TransactionDetailsViewState extends ConsumerState { // debugPrint("Consumer build called"); return FutureBuilder( - future: ref.watch(managerProvider - .select((value) => value.transactionData)), - builder: (_, AsyncSnapshot snapshot) { + future: ref.watch( + managerProvider.select((value) => value.transactions)), + builder: (_, AsyncSnapshot> snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { final filtered = filter( - transactions: snapshot.data! - .getAllTransactions() - .values - .toList(), - filter: criteria); + transactions: snapshot.data!, filter: criteria); final searched = search(_searchString, filtered); @@ -787,33 +788,33 @@ class _DesktopTransactionCardRowState late final Transaction _transaction; late final String walletId; - String whatIsIt(String type, Coin coin) { + String whatIsIt(TransactionType type, Coin coin, int height) { if (coin == Coin.epicCash && _transaction.slateId == null) { return "Restored Funds"; } - if (_transaction.subType == "mint") { - if (_transaction.confirmedStatus) { + if (_transaction.subType == TransactionSubType.mint) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Anonymized"; } else { return "Anonymizing"; } } - if (type == "Received") { - if (_transaction.confirmedStatus) { + if (type == TransactionType.incoming) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Received"; } else { return "Receiving"; } - } else if (type == "Sent") { - if (_transaction.confirmedStatus) { + } else if (type == TransactionType.outgoing) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Sent"; } else { return "Sending"; } } else { - return type; + return type.name; } } @@ -843,15 +844,17 @@ class _DesktopTransactionCardRowState late final String prefix; if (Util.isDesktop) { - if (_transaction.txType == "Sent") { + if (_transaction.type == TransactionType.outgoing) { prefix = "-"; - } else if (_transaction.txType == "Received") { + } else if (_transaction.type == TransactionType.incoming) { prefix = "+"; } } else { prefix = ""; } + final currentHeight = ref.watch(currentHeightProvider(coin).state).state; + return Material( color: Theme.of(context).extension()!.popupBG, elevation: 0, @@ -911,7 +914,11 @@ class _DesktopTransactionCardRowState ), child: Row( children: [ - TxIcon(transaction: _transaction), + TxIcon( + transaction: _transaction, + currentHeight: currentHeight, + coin: coin, + ), const SizedBox( width: 12, ), @@ -920,7 +927,11 @@ class _DesktopTransactionCardRowState child: Text( _transaction.isCancelled ? "Cancelled" - : whatIsIt(_transaction.txType, coin), + : whatIsIt( + _transaction.type, + coin, + currentHeight, + ), style: STextStyles.desktopTextExtraExtraSmall(context).copyWith( color: Theme.of(context).extension()!.textDark, 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 a5967934a..fec0721d9 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -5,12 +5,13 @@ 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:stackwallet/models/models.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; +import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; import 'package:stackwallet/providers/global/address_book_service_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'; @@ -19,7 +20,6 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/block_explorers.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -80,13 +80,13 @@ class _TransactionDetailsViewState coin = widget.coin; amount = Format.satoshisToAmount(_transaction.amount, coin: coin); - fee = Format.satoshisToAmount(_transaction.fees, coin: coin); + fee = Format.satoshisToAmount(_transaction.fee, coin: coin); if ((coin == Coin.firo || coin == Coin.firoTestNet) && - _transaction.subType == "mint") { + _transaction.subType == TransactionSubType.mint) { amountPrefix = ""; } else { - amountPrefix = _transaction.txType.toLowerCase() == "sent" ? "-" : "+"; + amountPrefix = _transaction.type == TransactionType.outgoing ? "-" : "+"; } // if (coin == Coin.firo || coin == Coin.firoTestNet) { @@ -102,10 +102,10 @@ class _TransactionDetailsViewState super.dispose(); } - String whatIsIt(String type) { + String whatIsIt(TransactionType type, int height) { if (coin == Coin.firo || coin == Coin.firoTestNet) { - if (_transaction.subType == "mint") { - if (_transaction.confirmedStatus) { + if (_transaction.subType == TransactionSubType.mint) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Minted"; } else { return "Minting"; @@ -113,23 +113,23 @@ class _TransactionDetailsViewState } } - if (type == "Received") { + if (type == TransactionType.incoming) { // if (_transaction.isMinting) { // return "Minting"; // } else - if (_transaction.confirmedStatus) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Received"; } else { return "Receiving"; } - } else if (type == "Sent") { - if (_transaction.confirmedStatus) { + } else if (type == TransactionType.outgoing) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Sent"; } else { return "Sending"; } } else { - return type; + return type.name; } } @@ -298,6 +298,8 @@ class _TransactionDetailsViewState @override Widget build(BuildContext context) { + final currentHeight = ref.watch(currentHeightProvider(coin).state).state; + return ConditionalParent( condition: !isDesktop, builder: (child) => Background( @@ -403,6 +405,8 @@ class _TransactionDetailsViewState children: [ TxIcon( transaction: _transaction, + currentHeight: currentHeight, + coin: coin, ), const SizedBox( width: 16, @@ -411,7 +415,9 @@ class _TransactionDetailsViewState _transaction.isCancelled ? "Cancelled" : whatIsIt( - _transaction.txType), + _transaction.type, + currentHeight, + ), style: STextStyles.desktopTextMedium( context), @@ -489,6 +495,8 @@ class _TransactionDetailsViewState if (!isDesktop) TxIcon( transaction: _transaction, + currentHeight: currentHeight, + coin: coin, ), ], ), @@ -523,13 +531,17 @@ class _TransactionDetailsViewState SelectableText( _transaction.isCancelled ? "Cancelled" - : whatIsIt(_transaction.txType), + : whatIsIt( + _transaction.type, + currentHeight, + ), style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( context) .copyWith( - color: _transaction.txType == "Sent" + color: _transaction.type == + TransactionType.outgoing ? Theme.of(context) .extension()! .accentColorOrange @@ -546,11 +558,12 @@ class _TransactionDetailsViewState ), if (!((coin == Coin.monero || coin == Coin.wownero) && - _transaction.txType.toLowerCase() == - "sent") && + _transaction.type == + TransactionType.outgoing) && !((coin == Coin.firo || coin == Coin.firoTestNet) && - _transaction.subType == "mint")) + _transaction.subType == + TransactionSubType.mint)) isDesktop ? const _Divider() : const SizedBox( @@ -558,11 +571,12 @@ class _TransactionDetailsViewState ), if (!((coin == Coin.monero || coin == Coin.wownero) && - _transaction.txType.toLowerCase() == - "sent") && + _transaction.type == + TransactionType.outgoing) && !((coin == Coin.firo || coin == Coin.firoTestNet) && - _transaction.subType == "mint")) + _transaction.subType == + TransactionSubType.mint)) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) @@ -578,8 +592,8 @@ class _TransactionDetailsViewState CrossAxisAlignment.start, children: [ Text( - _transaction.txType.toLowerCase() == - "sent" + _transaction.type == + TransactionType.outgoing ? "Sent to" : "Receiving address", style: isDesktop @@ -592,8 +606,8 @@ class _TransactionDetailsViewState const SizedBox( height: 8, ), - _transaction.txType.toLowerCase() == - "received" + _transaction.type == + TransactionType.incoming ? FutureBuilder( future: fetchContactNameFor( _transaction.address), @@ -855,7 +869,10 @@ class _TransactionDetailsViewState : const EdgeInsets.all(12), child: Builder(builder: (context) { final feeString = showFeePending - ? _transaction.confirmedStatus + ? _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ) ? Format.localizedStringAsFixed( value: fee, locale: ref.watch( @@ -947,9 +964,14 @@ class _TransactionDetailsViewState : const EdgeInsets.all(12), child: Builder(builder: (context) { final height = widget.coin != Coin.epicCash && - _transaction.confirmedStatus + _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ) ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" - : _transaction.confirmations > 0 + : _transaction.getConfirmations( + currentHeight) > + 0 ? "${_transaction.height}" : "Pending"; @@ -1297,9 +1319,13 @@ class _TransactionDetailsViewState ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: (coin == Coin.epicCash && - _transaction.confirmedStatus == false && + _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ) == + false && _transaction.isCancelled == false && - _transaction.txType == "Sent") + _transaction.type == TransactionType.outgoing) ? SizedBox( width: MediaQuery.of(context).size.width - 32, child: TextButton( 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 c5d682c60..c4f7eee34 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,73 +97,73 @@ class _DesktopSendState extends ConsumerState { final manager = ref.read(walletsChangeNotifierProvider).getManager(walletId); - // TODO: remove the need for this!! - final bool isOwnAddress = await manager.isOwnAddress(_address!); - if (isOwnAddress) { - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return DesktopDialog( - maxWidth: 400, - maxHeight: double.infinity, - child: Padding( - padding: const EdgeInsets.only( - left: 32, - bottom: 32, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Transaction failed", - style: STextStyles.desktopH3(context), - ), - const DesktopDialogCloseButton(), - ], - ), - const SizedBox( - height: 12, - ), - Text( - "Sending to self is currently disabled", - textAlign: TextAlign.left, - style: STextStyles.desktopTextExtraExtraSmall(context) - .copyWith( - fontSize: 18, - ), - ), - const SizedBox( - height: 40, - ), - Row( - children: [ - Expanded( - child: SecondaryButton( - buttonHeight: ButtonHeight.l, - label: "Ok", - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - const SizedBox( - width: 32, - ), - ], - ), - ], - ), - ), - ); - }, - ); - return; - } + // // TODO: remove the need for this!! + // final bool isOwnAddress = await manager.isOwnAddress(_address!); + // if (isOwnAddress) { + // await showDialog( + // context: context, + // useSafeArea: false, + // barrierDismissible: true, + // builder: (context) { + // return DesktopDialog( + // maxWidth: 400, + // maxHeight: double.infinity, + // child: Padding( + // padding: const EdgeInsets.only( + // left: 32, + // bottom: 32, + // ), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // "Transaction failed", + // style: STextStyles.desktopH3(context), + // ), + // const DesktopDialogCloseButton(), + // ], + // ), + // const SizedBox( + // height: 12, + // ), + // Text( + // "Sending to self is currently disabled", + // textAlign: TextAlign.left, + // style: STextStyles.desktopTextExtraExtraSmall(context) + // .copyWith( + // fontSize: 18, + // ), + // ), + // const SizedBox( + // height: 40, + // ), + // Row( + // children: [ + // Expanded( + // child: SecondaryButton( + // buttonHeight: ButtonHeight.l, + // label: "Ok", + // onPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ), + // const SizedBox( + // width: 32, + // ), + // ], + // ), + // ], + // ), + // ), + // ); + // }, + // ); + // return; + // } final amount = Format.decimalAmountToSatoshis(_amountToSend!, coin); int availableBalance; @@ -171,16 +171,14 @@ class _DesktopSendState extends ConsumerState { if (ref.read(publicPrivateBalanceStateProvider.state).state == "Private") { availableBalance = Format.decimalAmountToSatoshis( - await (manager.wallet as FiroWallet).availablePrivateBalance(), - coin); + (manager.wallet as FiroWallet).availablePrivateBalance(), coin); } else { availableBalance = Format.decimalAmountToSatoshis( - await (manager.wallet as FiroWallet).availablePublicBalance(), - coin); + (manager.wallet as FiroWallet).availablePublicBalance(), coin); } } else { availableBalance = - Format.decimalAmountToSatoshis(await manager.availableBalance, coin); + Format.decimalAmountToSatoshis(manager.balance.getSpendable(), coin); } // confirm send all @@ -568,9 +566,9 @@ class _DesktopSendState extends ConsumerState { if (wallet != null) { Decimal? balance; if (private) { - balance = await wallet.availablePrivateBalance(); + balance = wallet.availablePrivateBalance(); } else { - balance = await wallet.availablePublicBalance(); + balance = wallet.availablePublicBalance(); } return Format.localizedStringAsFixed( @@ -757,19 +755,18 @@ class _DesktopSendState extends ConsumerState { .wallet as FiroWallet; if (ref.read(publicPrivateBalanceStateProvider.state).state == "Private") { - cryptoAmountController.text = - (await firoWallet.availablePrivateBalance()) - .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); + cryptoAmountController.text = (firoWallet.availablePrivateBalance()) + .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); } else { - cryptoAmountController.text = - (await firoWallet.availablePublicBalance()) - .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); + cryptoAmountController.text = (firoWallet.availablePublicBalance()) + .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); } } else { - cryptoAmountController.text = (await ref + cryptoAmountController.text = (ref .read(walletsChangeNotifierProvider) .getManager(walletId) - .availableBalance) + .balance + .getSpendable()) .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); } } diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart index 8291c35d3..f56e2160a 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart @@ -68,15 +68,17 @@ class _WDesktopWalletSummaryState extends State { final firoWallet = ref.watch( managerProvider.select((value) => value.wallet)) as FiroWallet; - totalBalanceFuture = firoWallet.availablePublicBalance(); - availableBalanceFuture = - firoWallet.availablePrivateBalance(); + totalBalanceFuture = + Future(() => firoWallet.balance.getSpendable()); + availableBalanceFuture = Future( + () => firoWallet.balancePrivate.getSpendable()); } else { - totalBalanceFuture = ref.watch(managerProvider - .select((value) => value.totalBalance)); - - availableBalanceFuture = ref.watch(managerProvider - .select((value) => value.availableBalance)); + final manager = ref.watch(walletsChangeNotifierProvider + .select((value) => value.getManager(walletId))); + totalBalanceFuture = + Future(() => manager.balance.getTotal()); + availableBalanceFuture = + Future(() => manager.balance.getSpendable()); } final locale = ref.watch(localeServiceChangeNotifierProvider diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index 531d7abb9..6eb48e7da 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; -import 'package:stackwallet/models/paymint/transactions_model.dart' as old; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; +import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -17,8 +17,6 @@ import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:tuple/tuple.dart'; -import '../providers/blockchain/dogecoin/current_height_provider.dart'; - class TransactionCard extends ConsumerStatefulWidget { const TransactionCard({ Key? key, @@ -26,7 +24,7 @@ class TransactionCard extends ConsumerStatefulWidget { required this.walletId, }) : super(key: key); - final old.Transaction transaction; + final Transaction transaction; final String walletId; @override @@ -34,17 +32,26 @@ class TransactionCard extends ConsumerStatefulWidget { } class _TransactionCardState extends ConsumerState { - late final old.Transaction _transaction; + late final Transaction _transaction; late final String walletId; - String whatIsIt(String type, Coin coin) { + String whatIsIt( + TransactionType type, + Coin coin, + int currentHeight, + ) { if (coin == Coin.epicCash && _transaction.slateId == null) { return "Restored Funds"; } - if (_transaction.subType == "mint") { + final confirmedStatus = _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ); + + if (_transaction.subType == TransactionSubType.mint) { // if (type == "Received") { - if (_transaction.confirmedStatus) { + if (confirmedStatus) { return "Anonymized"; } else { return "Anonymizing"; @@ -60,23 +67,23 @@ class _TransactionCardState extends ConsumerState { // } } - if (type == "Received") { + if (type == TransactionType.incoming) { // if (_transaction.isMinting) { // return "Minting"; // } else - if (_transaction.confirmedStatus) { + if (confirmedStatus) { return "Received"; } else { return "Receiving"; } - } else if (type == "Sent") { - if (_transaction.confirmedStatus) { + } else if (type == TransactionType.outgoing) { + if (confirmedStatus) { return "Sent"; } else { return "Sending"; } } else { - return type; + return type.name; } } @@ -106,13 +113,15 @@ class _TransactionCardState extends ConsumerState { String prefix = ""; if (Util.isDesktop) { - if (_transaction.txType == "Sent") { + if (_transaction.type == TransactionType.outgoing) { prefix = "-"; - } else if (_transaction.txType == "Received") { + } else if (_transaction.type == TransactionType.incoming) { prefix = "+"; } } + final currentHeight = ref.watch(currentHeightProvider(coin).state).state; + return Material( color: Theme.of(context).extension()!.popupBG, elevation: 0, @@ -169,269 +178,7 @@ class _TransactionCardState extends ConsumerState { padding: const EdgeInsets.all(8), child: Row( children: [ - TxIcon(transaction: _transaction), - const SizedBox( - width: 14, - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - _transaction.isCancelled - ? "Cancelled" - : whatIsIt(_transaction.txType, coin), - style: STextStyles.itemSubtitle12(context), - ), - ), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Builder( - builder: (_) { - final amount = _transaction.amount; - return Text( - "$prefix${Format.satoshiAmountToPrettyString(amount, locale, coin)} ${coin.ticker}", - style: - STextStyles.itemSubtitle12_600(context), - ); - }, - ), - ), - ), - ], - ), - const SizedBox( - height: 4, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - Format.extractDateFrom(_transaction.timestamp), - style: STextStyles.label(context), - ), - ), - ), - if (ref.watch(prefsChangeNotifierProvider - .select((value) => value.externalCalls))) - const SizedBox( - width: 10, - ), - if (ref.watch(prefsChangeNotifierProvider - .select((value) => value.externalCalls))) - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Builder( - builder: (_) { - int value = _transaction.amount; - - return Text( - "$prefix${Format.localizedStringAsFixed( - value: Format.satoshisToAmount(value, - coin: coin) * - price, - locale: locale, - decimalPlaces: 2, - )} $baseCurrency", - style: STextStyles.label(context), - ); - }, - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - ), - ), - ), - ); - } -} - -class TransactionCard2 extends ConsumerStatefulWidget { - const TransactionCard2({ - Key? key, - required this.transaction, - required this.walletId, - }) : super(key: key); - - final isar_models.Transaction transaction; - final String walletId; - - @override - ConsumerState createState() => _TransactionCardState2(); -} - -class _TransactionCardState2 extends ConsumerState { - late final isar_models.Transaction _transaction; - late final String walletId; - - String whatIsIt( - isar_models.TransactionType type, - Coin coin, - int currentHeight, - ) { - if (coin == Coin.epicCash && _transaction.slateId == null) { - return "Restored Funds"; - } - - final confirmedStatus = _transaction.isConfirmed( - currentHeight, - coin.requiredConfirmations, - ); - - if (_transaction.subType == isar_models.TransactionSubType.mint) { - // if (type == "Received") { - if (confirmedStatus) { - return "Anonymized"; - } else { - return "Anonymizing"; - } - // } else if (type == "Sent") { - // if (_transaction.confirmedStatus) { - // return "Sent MINT"; - // } else { - // return "Sending MINT"; - // } - // } else { - // return type; - // } - } - - if (type == isar_models.TransactionType.incoming) { - // if (_transaction.isMinting) { - // return "Minting"; - // } else - if (confirmedStatus) { - return "Received"; - } else { - return "Receiving"; - } - } else if (type == isar_models.TransactionType.outgoing) { - if (confirmedStatus) { - return "Sent"; - } else { - return "Sending"; - } - } else { - return type.name; - } - } - - @override - void initState() { - walletId = widget.walletId; - _transaction = widget.transaction; - super.initState(); - } - - @override - Widget build(BuildContext context) { - final locale = ref.watch( - localeServiceChangeNotifierProvider.select((value) => value.locale)); - final manager = ref.watch(walletsChangeNotifierProvider - .select((value) => value.getManager(walletId))); - - final baseCurrency = ref - .watch(prefsChangeNotifierProvider.select((value) => value.currency)); - - final coin = manager.coin; - - final price = ref - .watch(priceAnd24hChangeNotifierProvider - .select((value) => value.getPrice(coin))) - .item1; - - String prefix = ""; - if (Util.isDesktop) { - if (_transaction.type == isar_models.TransactionType.outgoing) { - prefix = "-"; - } else if (_transaction.type == isar_models.TransactionType.incoming) { - prefix = "+"; - } - } - - final currentHeight = ref.watch(currentHeightProvider(coin).state).state; - - return Material( - color: Theme.of(context).extension()!.popupBG, - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(Constants.size.circularBorderRadius), - ), - child: Padding( - padding: const EdgeInsets.all(6), - child: RawMaterialButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - onPressed: () async { - if (coin == Coin.epicCash && _transaction.slateId == null) { - unawaited(showFloatingFlushBar( - context: context, - message: - "Restored Epic funds from your Seed have no Data.\nUse Stack Backup to keep your transaction history.", - type: FlushBarType.warning, - duration: const Duration(seconds: 5), - )); - return; - } - if (Util.isDesktop) { - // await showDialog( - // context: context, - // builder: (context) => DesktopDialog( - // maxHeight: MediaQuery.of(context).size.height - 64, - // maxWidth: 580, - // child: TransactionDetailsView( - // transaction: _transaction, - // coin: coin, - // walletId: walletId, - // ), - // ), - // ); - } else { - unawaited( - Navigator.of(context).pushNamed( - TransactionDetailsView.routeName, - arguments: Tuple3( - _transaction, - coin, - walletId, - ), - ), - ); - } - }, - child: Padding( - padding: const EdgeInsets.all(8), - child: Row( - children: [ - TxIcon2( + TxIcon( transaction: _transaction, coin: ref.watch(walletsChangeNotifierProvider.select( (value) => value.getManager(widget.walletId).coin)), From 525d0fa7c406b85856f61c6166639dcf0be27639 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 22:45:32 -0600 Subject: [PATCH 109/192] update remaining ui to handle new data models --- lib/pages/exchange_view/exchange_view.dart | 10 +- lib/pages/exchange_view/send_from_view.dart | 15 ++- lib/pages/send_view/send_view.dart | 113 +++++++++--------- .../firo_balance_selection_sheet.dart | 8 +- .../wallet_syncing_options_view.dart | 3 +- .../sub_widgets/favorite_card.dart | 4 +- .../subwidgets/desktop_contact_details.dart | 14 ++- .../desktop_all_trades_view.dart | 12 +- .../subwidgets/desktop_choose_from_stack.dart | 3 +- .../subwidgets/desktop_trade_history.dart | 10 +- lib/route_generator.dart | 3 +- lib/widgets/managed_favorite.dart | 4 +- .../wallet_info_row_balance_future.dart | 3 +- 13 files changed, 111 insertions(+), 91 deletions(-) diff --git a/lib/pages/exchange_view/exchange_view.dart b/lib/pages/exchange_view/exchange_view.dart index 8fada855d..6bb1aa1c3 100644 --- a/lib/pages/exchange_view/exchange_view.dart +++ b/lib/pages/exchange_view/exchange_view.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/pages/exchange_view/exchange_form.dart'; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/providers/global/trades_service_provider.dart'; @@ -129,10 +131,10 @@ class _ExchangeViewState extends ConsumerState { //todo: check if print needed // debugPrint("name: ${manager.walletName}"); - // TODO store tx data completely locally in isar so we don't lock up ui here when querying txData - final txData = await manager.transactionData; - - final tx = txData.getAllTransactions()[txid]; + final tx = await manager.db.transactions + .filter() + .txidEqualTo(txid) + .findFirst(); if (mounted) { unawaited(Navigator.of(context).pushNamed( diff --git a/lib/pages/exchange_view/send_from_view.dart b/lib/pages/exchange_view/send_from_view.dart index 6a7fe5285..a1e242eba 100644 --- a/lib/pages/exchange_view/send_from_view.dart +++ b/lib/pages/exchange_view/send_from_view.dart @@ -438,8 +438,10 @@ class _SendFromCardState extends ConsumerState { style: STextStyles.itemSubtitle(context), ), FutureBuilder( - future: (manager.wallet as FiroWallet) - .availablePrivateBalance(), + // TODO redo this widget now that its not actually a future + future: Future(() => + (manager.wallet as FiroWallet) + .availablePrivateBalance()), builder: (builderContext, AsyncSnapshot snapshot) { if (snapshot.connectionState == @@ -524,8 +526,10 @@ class _SendFromCardState extends ConsumerState { style: STextStyles.itemSubtitle(context), ), FutureBuilder( - future: (manager.wallet as FiroWallet) - .availablePublicBalance(), + // TODO redo this widget now that its not actually a future + future: Future(() => + (manager.wallet as FiroWallet) + .availablePublicBalance()), builder: (builderContext, AsyncSnapshot snapshot) { if (snapshot.connectionState == @@ -634,7 +638,8 @@ class _SendFromCardState extends ConsumerState { ), if (!isFiro) FutureBuilder( - future: manager.totalBalance, + // TODO redo this widget now that its not actually a future + future: Future(() => manager.balance.getTotal()), builder: (builderContext, AsyncSnapshot snapshot) { if (snapshot.connectionState == diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 8afa6a6e9..7f9c82423 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -485,22 +485,22 @@ class _SendViewState extends ConsumerState { coin == Coin.firoTestNet) const Spacer(), FutureBuilder( + // TODO redo this widget now that its not actually a future future: (coin != Coin.firo && coin != Coin.firoTestNet) - ? ref.watch(provider.select( - (value) => value.availableBalance)) - : ref - .watch( - publicPrivateBalanceStateProvider - .state) - .state == + ? Future(() => ref.watch( + provider.select((value) => + value.balance.getSpendable()))) + : ref.watch(publicPrivateBalanceStateProvider.state).state == "Private" - ? (ref.watch(provider).wallet - as FiroWallet) - .availablePrivateBalance() - : (ref.watch(provider).wallet - as FiroWallet) - .availablePublicBalance(), + ? Future(() => (ref + .watch(provider) + .wallet as FiroWallet) + .availablePrivateBalance()) + : Future(() => (ref + .watch(provider) + .wallet as FiroWallet) + .availablePublicBalance()), builder: (_, AsyncSnapshot snapshot) { if (snapshot.connectionState == @@ -1085,9 +1085,10 @@ class _SendViewState extends ConsumerState { .decimalPlacesForCoin(coin)); } } else { - cryptoAmountController.text = (await ref + cryptoAmountController.text = (ref .read(provider) - .availableBalance) + .balance + .getSpendable()) .toStringAsFixed( Constants.decimalPlacesForCoin( coin)); @@ -1523,43 +1524,43 @@ class _SendViewState extends ConsumerState { .read(walletsChangeNotifierProvider) .getManager(walletId); - // TODO: remove the need for this!! - final bool isOwnAddress = - await manager.isOwnAddress(_address!); - if (isOwnAddress && coin != Coin.dogecoinTestNet) { - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return StackDialog( - title: "Transaction failed", - message: - "Sending to self is currently disabled", - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getSecondaryEnabledButtonColor( - context), - child: Text( - "Ok", - style: STextStyles.button( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .accentColorDark), - ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ); - }, - ); - return; - } + // // TODO: remove the need for this!! + // final bool isOwnAddress = + // await manager.isOwnAddress(_address!); + // if (isOwnAddress && coin != Coin.dogecoinTestNet) { + // await showDialog( + // context: context, + // useSafeArea: false, + // barrierDismissible: true, + // builder: (context) { + // return StackDialog( + // title: "Transaction failed", + // message: + // "Sending to self is currently disabled", + // rightButton: TextButton( + // style: Theme.of(context) + // .extension()! + // .getSecondaryEnabledButtonColor( + // context), + // child: Text( + // "Ok", + // style: STextStyles.button( + // context) + // .copyWith( + // color: Theme.of(context) + // .extension< + // StackColors>()! + // .accentColorDark), + // ), + // onPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ); + // }, + // ); + // return; + // } final amount = Format.decimalAmountToSatoshis( @@ -1575,22 +1576,20 @@ class _SendViewState extends ConsumerState { "Private") { availableBalance = Format.decimalAmountToSatoshis( - await (manager.wallet - as FiroWallet) + (manager.wallet as FiroWallet) .availablePrivateBalance(), coin); } else { availableBalance = Format.decimalAmountToSatoshis( - await (manager.wallet - as FiroWallet) + (manager.wallet as FiroWallet) .availablePublicBalance(), coin); } } else { availableBalance = Format.decimalAmountToSatoshis( - await manager.availableBalance, + manager.balance.getSpendable(), coin); } diff --git a/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart b/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart index d6de3c6ee..dc14f2c41 100644 --- a/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart +++ b/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart @@ -154,7 +154,9 @@ class _FiroBalanceSelectionSheetState width: 2, ), FutureBuilder( - future: firoWallet.availablePrivateBalance(), + // TODO redo this widget now that its not actually a future + future: Future( + () => firoWallet.availablePrivateBalance()), builder: (context, AsyncSnapshot snapshot) { if (snapshot.connectionState == @@ -244,7 +246,9 @@ class _FiroBalanceSelectionSheetState width: 2, ), FutureBuilder( - future: firoWallet.availablePublicBalance(), + // TODO redo this widget now that its not actually a future + future: Future( + () => firoWallet.availablePublicBalance()), builder: (context, AsyncSnapshot snapshot) { if (snapshot.connectionState == diff --git a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart index 7cbc86b7a..9c398fbf6 100644 --- a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart +++ b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart @@ -145,7 +145,8 @@ class WalletSyncingOptionsView extends ConsumerWidget { height: 2, ), FutureBuilder( - future: manager.totalBalance, + future: Future( + () => manager.balance.getTotal()), builder: (builderContext, AsyncSnapshot snapshot) { if (snapshot.connectionState == diff --git a/lib/pages/wallets_view/sub_widgets/favorite_card.dart b/lib/pages/wallets_view/sub_widgets/favorite_card.dart index 9ec13d459..fa0f0c490 100644 --- a/lib/pages/wallets_view/sub_widgets/favorite_card.dart +++ b/lib/pages/wallets_view/sub_widgets/favorite_card.dart @@ -217,8 +217,8 @@ class _FavoriteCardState extends ConsumerState { ), ), FutureBuilder( - future: ref.watch( - managerProvider.select((value) => value.totalBalance)), + future: Future(() => ref.watch(managerProvider + .select((value) => value.balance.getTotal()))), builder: (builderContext, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { diff --git a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart index 3a70443be..b48128319 100644 --- a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart +++ b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart @@ -1,8 +1,9 @@ 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/contact.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart'; @@ -57,11 +58,12 @@ class _DesktopContactDetailsState extends ConsumerState { List> result = []; for (final manager in managers) { - final transactions = (await manager.transactionData) - .getAllTransactions() - .values - .toList() - .where((e) => _contactHasAddress(e.address, contact)); + final transactions = await manager.db.transactions + .filter() + .anyOf(contact.addresses.map((e) => e.address), + (q, String e) => q.addressEqualTo(e)) + .sortByTimestampDesc() + .findAll(); for (final tx in transactions) { result.add(Tuple2(manager.walletId, tx)); diff --git a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart index 472460469..477c4562a 100644 --- a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart +++ b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart @@ -4,12 +4,15 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart'; import 'package:stackwallet/providers/global/trades_service_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; +import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/format.dart'; @@ -26,8 +29,6 @@ import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:tuple/tuple.dart'; -import '../../route_generator.dart'; - class DesktopAllTradesView extends ConsumerStatefulWidget { const DesktopAllTradesView({Key? key}) : super(key: key); @@ -349,10 +350,11 @@ class _DesktopTradeRowCardState extends ConsumerState { //todo: check if print needed // debugPrint("name: ${manager.walletName}"); - // TODO store tx data completely locally in isar so we don't lock up ui here when querying txData - final txData = await manager.transactionData; + final tx = await manager.db.transactions + .filter() + .txidEqualTo(txid) + .findFirst(); - final tx = txData.getAllTransactions()[txid]; await showDialog( context: context, builder: (context) => DesktopDialog( diff --git a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart index efa939871..3216949b0 100644 --- a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart +++ b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart @@ -305,8 +305,9 @@ class _BalanceDisplayState extends ConsumerState { final locale = ref.watch( localeServiceChangeNotifierProvider.select((value) => value.locale)); + // TODO redo this widget now that its not actually a future return FutureBuilder( - future: manager.availableBalance, + future: Future(() => manager.balance.getSpendable()), builder: (context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData && diff --git a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart index 2ba3078ac..5a6d7ce81 100644 --- a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart +++ b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart'; import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart'; @@ -126,10 +128,10 @@ class _DesktopTradeHistoryState extends ConsumerState { //todo: check if print needed // debugPrint("name: ${manager.walletName}"); - // TODO store tx data completely locally in isar so we don't lock up ui here when querying txData - final txData = await manager.transactionData; - - final tx = txData.getAllTransactions()[txid]; + final tx = await manager.db.transactions + .filter() + .txidEqualTo(txid) + .findFirst(); if (mounted) { await showDialog( diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 203edef4a..8ebdd36a2 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -5,7 +5,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/models/contact_address_entry.dart'; import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; import 'package:stackwallet/models/send_view_auto_fill_data.dart'; 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'; @@ -122,6 +121,8 @@ import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:tuple/tuple.dart'; +import 'models/isar/models/blockchain_data/transaction.dart'; + class RouteGenerator { static const bool useMaterialPageRoute = true; diff --git a/lib/widgets/managed_favorite.dart b/lib/widgets/managed_favorite.dart index 5ced849fd..a9d5fcd90 100644 --- a/lib/widgets/managed_favorite.dart +++ b/lib/widgets/managed_favorite.dart @@ -105,7 +105,7 @@ class _ManagedFavoriteCardState extends ConsumerState { Expanded( child: Text( "${Format.localizedStringAsFixed( - value: manager.cachedTotalBalance, + value: manager.balance.getTotal(), locale: ref.watch( localeServiceChangeNotifierProvider .select((value) => value.locale)), @@ -147,7 +147,7 @@ class _ManagedFavoriteCardState extends ConsumerState { ), Text( "${Format.localizedStringAsFixed( - value: manager.cachedTotalBalance, + value: manager.balance.getTotal(), locale: ref.watch(localeServiceChangeNotifierProvider .select((value) => value.locale)), decimalPlaces: 8, diff --git a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart index a59c157ec..174e251cf 100644 --- a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart +++ b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart @@ -27,8 +27,9 @@ class WalletInfoRowBalanceFuture extends ConsumerWidget { ), ); + // TODO redo this widget now that its not actually a future return FutureBuilder( - future: manager.totalBalance, + future: Future(() => manager.balance.getTotal()), builder: (builderContext, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { From 12a5eff178ea61655b3f2c5605ac974e3c90a311 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 22:45:59 -0600 Subject: [PATCH 110/192] missing value init --- lib/services/coins/coin_paynym_extension.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 303fac44f..d75b0c8a0 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -724,6 +724,7 @@ Future parseTransaction( tx.isCancelled = false; tx.slateId = null; tx.otherData = null; + tx.isLelantus = null; return tx; } From f5f53a163ad218ae3f47b8119314ddcfc55851c8 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 22:47:47 -0600 Subject: [PATCH 111/192] only print word when explicitly in debug mode --- .../verify_recovery_phrase_view.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 e8a680678..2c3c3af83 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 @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:math'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; @@ -160,8 +161,9 @@ class _VerifyRecoveryPhraseViewState result.insert(random.nextInt(wordsToShow), chosenWord); - //todo: this prints sensitive info - debugPrint("Mnemonic game correct word: $chosenWord"); + if (kDebugMode) { + print("Mnemonic game correct word: $chosenWord"); + } return Tuple2(result, chosenWord); } From e27134173857efa16069183d3ef73ad65efde519 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 09:45:55 -0600 Subject: [PATCH 112/192] ui fix --- lib/pages/wallet_view/sub_widgets/transactions_list.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index 0834b0d8d..39d9dfc7a 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; @@ -10,7 +9,6 @@ import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provide import 'package:stackwallet/providers/global/trades_service_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -210,9 +208,8 @@ class _TransactionsListState extends ConsumerState { .select((value) => value.getManager(widget.walletId))); updateHeightProvider(manager); - final wallet = manager.wallet as DogecoinWallet; return FutureBuilder( - future: wallet.isar.transactions.where().findAll(), + future: manager.transactions, builder: (fbContext, AsyncSnapshot> snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { From e115ff1b419d8315f0fca6ed5961c95ed3b96d11 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 09:52:41 -0600 Subject: [PATCH 113/192] only use the PaymentData 'data' once and do not generate p2sh data using p2wpkh unless required --- lib/services/coins/bitcoincash/bitcoincash_wallet.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 079bdce7f..33c3ca317 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1430,9 +1430,6 @@ class BitcoinCashWallet extends CoinServiceAPI { ), ); final data = PaymentData(pubkey: node.publicKey); - final p2shData = - PaymentData(redeem: P2WPKH(data: data, network: _network).data); - String address; isar_models.AddressType addrType; @@ -1442,7 +1439,12 @@ class BitcoinCashWallet extends CoinServiceAPI { addrType = isar_models.AddressType.p2pkh; break; case DerivePathType.bip49: - address = P2SH(data: p2shData, network: _network).data.address!; + address = P2SH( + data: PaymentData( + redeem: P2WPKH(data: data, network: _network).data), + network: _network) + .data + .address!; addrType = isar_models.AddressType.p2sh; break; // default: From ccb9f254bd9b02e23df5cf5d8bfd52e5f8c7eea2 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 12:15:28 -0600 Subject: [PATCH 114/192] small bug fixes and added WalletCache mixin to handle balance cache etc --- lib/hive/db.dart | 7 + lib/models/balance.dart | 20 + .../coins/bitcoincash/bitcoincash_wallet.dart | 364 ++---------------- .../coins/epiccash/epiccash_wallet.dart | 15 +- lib/services/mixins/wallet_cache.dart | 30 ++ 5 files changed, 88 insertions(+), 348 deletions(-) create mode 100644 lib/services/mixins/wallet_cache.dart diff --git a/lib/hive/db.dart b/lib/hive/db.dart index 557f4ef30..962f56405 100644 --- a/lib/hive/db.dart +++ b/lib/hive/db.dart @@ -245,3 +245,10 @@ class DB { Future deleteBoxFromDisk({required String boxName}) async => await mutex.protect(() async => await Hive.deleteBoxFromDisk(boxName)); } + +abstract class DBKeys { + static const String cachedBalance = "cachedBalance"; + static const String isFavorite = "isFavorite"; + static const String id = "id"; + static const String storedChainHeight = "storedChainHeight"; +} diff --git a/lib/models/balance.dart b/lib/models/balance.dart index 2caa6353f..90ef24570 100644 --- a/lib/models/balance.dart +++ b/lib/models/balance.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:decimal/decimal.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; @@ -36,4 +38,22 @@ class Balance { blockedTotal, coin: coin, ); + + String toJsonIgnoreCoin() => jsonEncode({ + "total": total, + "spendable": spendable, + "blockedTotal": blockedTotal, + "pendingSpendable": pendingSpendable, + }); + + factory Balance.fromJson(String json, Coin coin) { + final decoded = jsonDecode(json); + return Balance( + coin: coin, + total: decoded["total"] as int, + spendable: decoded["spendable"] as int, + blockedTotal: decoded["blockedTotal"] as int, + pendingSpendable: decoded["pendingSpendable"] as int, + ); + } } diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 33c3ca317..cf6e25c46 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -24,6 +24,7 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -37,11 +38,10 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; -import '../../../utilities/stack_file_system.dart'; - const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 546; @@ -127,7 +127,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) { return getBip32Root(args.item1, args.item2); } -class BitcoinCashWallet extends CoinServiceAPI { +class BitcoinCashWallet extends CoinServiceAPI with WalletCache { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); final _prefs = Prefs.instance; @@ -224,13 +224,13 @@ class BitcoinCashWallet extends CoinServiceAPI { @override int get storedChainHeight { final storedHeight = DB.instance - .get(boxName: walletId, key: "storedChainHeight") as int?; + .get(boxName: walletId, key: DBKeys.storedChainHeight) as int?; return storedHeight ?? 0; } Future updateStoredChainHeight({required int newHeight}) async { await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); + boxName: walletId, key: DBKeys.storedChainHeight, value: newHeight); } DerivePathType addressType({required String address}) { @@ -622,9 +622,9 @@ class BitcoinCashWallet extends CoinServiceAPI { await _updateUTXOs(); await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + .put(boxName: walletId, key: DBKeys.id, value: _walletId); + await DB.instance.put( + boxName: walletId, key: DBKeys.isFavorite, value: false); longMutex = false; } catch (e, s) { @@ -1075,7 +1075,7 @@ class BitcoinCashWallet extends CoinServiceAPI { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) != null) { + if ((DB.instance.get(boxName: walletId, key: DBKeys.id)) != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -1088,9 +1088,10 @@ class BitcoinCashWallet extends CoinServiceAPI { rethrow; } await Future.wait([ - DB.instance.put(boxName: walletId, key: "id", value: _walletId), DB.instance - .put(boxName: walletId, key: "isFavorite", value: false), + .put(boxName: walletId, key: DBKeys.id, value: _walletId), + DB.instance.put( + boxName: walletId, key: DBKeys.isFavorite, value: false), ]); } @@ -1115,7 +1116,13 @@ class BitcoinCashWallet extends CoinServiceAPI { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + print("============================================================="); + for (final k in DB.instance.keys(boxName: walletId)) { + print("$k"); + } + print("============================================================="); + + if ((DB.instance.get(boxName: walletId, key: DBKeys.id)) == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -1698,6 +1705,7 @@ class BitcoinCashWallet extends CoinServiceAPI { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); + await updateCachedBalance(walletId, _balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1705,48 +1713,9 @@ class BitcoinCashWallet extends CoinServiceAPI { } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; - // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - // /// Now also checks for output labeling. - // Future _sortOutputs(List utxos) async { - // final blockedHashArray = - // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - // as List?; - // final List lst = []; - // if (blockedHashArray != null) { - // for (var hash in blockedHashArray) { - // lst.add(hash as String); - // } - // } - // final labels = - // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - // {}; - // - // outputsList = []; - // - // for (var i = 0; i < utxos.length; i++) { - // if (labels[utxos[i].txid] != null) { - // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - // } else { - // utxos[i].txName = 'Output #$i'; - // } - // - // if (utxos[i].status.confirmed == false) { - // outputsList.add(utxos[i]); - // } else { - // if (lst.contains(utxos[i].txid)) { - // utxos[i].blocked = true; - // outputsList.add(utxos[i]); - // } else if (!lst.contains(utxos[i].txid)) { - // outputsList.add(utxos[i]); - // } - // } - // } - // } - Future getTxCount({required String address}) async { String? scripthash; try { @@ -2013,47 +1982,6 @@ class BitcoinCashWallet extends CoinServiceAPI { final List> allTxHashes = await _fetchHistory([...receivingAddresses, ...changeAddresses]); - // final cachedTransactions = - // DB.instance.get(boxName: walletId, key: 'latest_tx_model') - // as TransactionData?; - // int latestTxnBlockHeight = - // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - // as int? ?? - // 0; - - // final unconfirmedCachedTransactions = - // cachedTransactions?.getAllTransactions() ?? {}; - // unconfirmedCachedTransactions - // .removeWhere((key, value) => value.confirmedStatus); - - // if (kDebugMode) { - // print("CACHED_TRANSACTIONS_IS $cachedTransactions"); - // } - // if (cachedTransactions != null) { - // for (final tx in allTxHashes.toList(growable: false)) { - // final txHeight = tx["height"] as int; - // if (txHeight > 0 && - // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - // if (kDebugMode) { - // print( - // cachedTransactions.findTransaction(tx["tx_hash"] as String)); - // print(unconfirmedCachedTransactions[tx["tx_hash"] as String]); - // } - // final cachedTx = - // cachedTransactions.findTransaction(tx["tx_hash"] as String); - // if (!(cachedTx != null && - // addressType(address: cachedTx.address) == - // DerivePathType.bip44 && - // bitbox.Address.detectFormat(cachedTx.address) == - // bitbox.Address.formatLegacy)) { - // allTxHashes.remove(tx); - // } - // } - // } - // } - // } - List> allTransactions = []; for (final txHash in allTxHashes) { @@ -2885,8 +2813,12 @@ class BitcoinCashWallet extends CoinServiceAPI { // clear cache await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); - // back up data - await _rescanBackup(); + // clear blockchain info + await isar.writeTxn(() async { + await isar.addresses.clear(); + await isar.transactions.clear(); + await isar.utxos.clear(); + }); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2914,9 +2846,6 @@ class BitcoinCashWallet extends CoinServiceAPI { ), ); - // restore from backup - await _rescanRestore(); - longMutex = false; Logging.instance.log("Exception rethrown from fullRescan(): $e\n$s", level: LogLevel.Error); @@ -2924,251 +2853,16 @@ class BitcoinCashWallet extends CoinServiceAPI { } } - Future _rescanRestore() async { - Logging.instance.log("starting rescan restore", level: LogLevel.Info); - - // restore from backup - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); - final tempReceivingIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); - final tempChangeIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: tempReceivingAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: tempChangeAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: tempReceivingIndexP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH', - value: tempChangeIndexP2PKH); - await DB.instance.delete( - key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); - - // p2Sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); - final tempChangeAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); - final tempReceivingIndexP2SH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); - final tempChangeIndexP2SH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: tempReceivingAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: tempChangeAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: tempReceivingIndexP2SH); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); - await DB.instance.delete( - key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - final p2pkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - // P2SH derivations - final p2shReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - final p2shChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - // UTXOs - final utxoData = DB.instance - .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); - - Logging.instance.log("rescan restore complete", level: LogLevel.Info); - } - - Future _rescanBackup() async { - Logging.instance.log("starting rescan backup", level: LogLevel.Info); - - // backup current and clear data - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH_BACKUP', - value: tempReceivingAddressesP2PKH); - await DB.instance - .delete(key: 'receivingAddressesP2PKH', boxName: walletId); - - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH_BACKUP', - value: tempChangeAddressesP2PKH); - await DB.instance - .delete(key: 'changeAddressesP2PKH', boxName: walletId); - - final tempReceivingIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH_BACKUP', - value: tempReceivingIndexP2PKH); - await DB.instance - .delete(key: 'receivingIndexP2PKH', boxName: walletId); - - final tempChangeIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH_BACKUP', - value: tempChangeIndexP2PKH); - await DB.instance - .delete(key: 'changeIndexP2PKH', boxName: walletId); - - // p2sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH_BACKUP', - value: tempReceivingAddressesP2SH); - await DB.instance - .delete(key: 'receivingAddressesP2SH', boxName: walletId); - - final tempChangeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH_BACKUP', - value: tempChangeAddressesP2SH); - await DB.instance - .delete(key: 'changeAddressesP2SH', boxName: walletId); - - final tempReceivingIndexP2SH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH_BACKUP', - value: tempReceivingIndexP2SH); - await DB.instance - .delete(key: 'receivingIndexP2SH', boxName: walletId); - - final tempChangeIndexP2SH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2SH_BACKUP', - value: tempChangeIndexP2SH); - await DB.instance - .delete(key: 'changeIndexP2SH', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); - final p2pkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH_BACKUP", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); - - // P2SH derivations - final p2shReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2SH"); - final p2shChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2SH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH_BACKUP", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH_BACKUP", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); - - // UTXOs - final utxoData = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model', boxName: walletId); - - Logging.instance.log("rescan backup complete", level: LogLevel.Info); - } - @override set isFavorite(bool markFavorite) { DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + boxName: walletId, key: DBKeys.isFavorite, value: markFavorite); } @override bool get isFavorite { try { - return DB.instance.get(boxName: walletId, key: "isFavorite") + return DB.instance.get(boxName: walletId, key: DBKeys.isFavorite) as bool; } catch (e, s) { Logging.instance.log( diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 8db32c147..123dd95cc 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -1082,19 +1082,6 @@ class EpicCashWallet extends CoinServiceAPI { await DB.instance.put( boxName: walletId, key: "restoreHeight", value: bufferedCreateHeight); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance.put( - boxName: walletId, key: 'receivingAddresses', value: ["0"]); - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndex", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet // initialize address book entries await DB.instance.put( boxName: walletId, @@ -1102,6 +1089,8 @@ class EpicCashWallet extends CoinServiceAPI { value: {}); await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); + + await _isarInit(); } bool refreshMutex = false; diff --git a/lib/services/mixins/wallet_cache.dart b/lib/services/mixins/wallet_cache.dart new file mode 100644 index 000000000..6d085c734 --- /dev/null +++ b/lib/services/mixins/wallet_cache.dart @@ -0,0 +1,30 @@ +import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +mixin WalletCache { + Balance getCachedBalance(String walletId, Coin coin) { + final jsonString = DB.instance.get( + boxName: walletId, + key: DBKeys.cachedBalance, + ) as String?; + if (jsonString == null) { + return Balance( + coin: coin, + total: 0, + spendable: 0, + blockedTotal: 0, + pendingSpendable: 0, + ); + } + return Balance.fromJson(jsonString, coin); + } + + Future updateCachedBalance(String walletId, Balance balance) async { + await DB.instance.put( + boxName: walletId, + key: DBKeys.cachedBalance, + value: balance.toJsonIgnoreCoin(), + ); + } +} From 3f830218a45ce0bc9706d18fc89dce56a2797b93 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 12:46:01 -0600 Subject: [PATCH 115/192] extract wallet isar db to mixin --- .../coins/bitcoin/bitcoin_wallet.dart | 31 +++---------- .../coins/bitcoincash/bitcoincash_wallet.dart | 30 +++---------- .../coins/dogecoin/dogecoin_wallet.dart | 31 +++---------- .../coins/epiccash/epiccash_wallet.dart | 26 +++-------- lib/services/coins/firo/firo_wallet.dart | 29 +++--------- .../coins/litecoin/litecoin_wallet.dart | 31 +++---------- lib/services/coins/monero/monero_wallet.dart | 28 +++--------- .../coins/namecoin/namecoin_wallet.dart | 31 +++---------- .../coins/particl/particl_wallet.dart | 31 +++---------- .../coins/wownero/wownero_wallet.dart | 44 +++---------------- lib/services/mixins/wallet_db.dart | 32 ++++++++++++++ 11 files changed, 96 insertions(+), 248 deletions(-) create mode 100644 lib/services/mixins/wallet_db.dart diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 1e62ea73e..670ce9436 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -23,6 +23,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/notifications_api.dart'; import 'package:stackwallet/services/price.dart'; @@ -37,7 +39,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -138,7 +139,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) { return getBip32Root(args.item1, args.item2); } -class BitcoinWallet extends CoinServiceAPI { +class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); @@ -218,7 +219,7 @@ class BitcoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isar.close(); + await isarClose(); } bool _hasCalledExit = false; @@ -674,7 +675,7 @@ class BitcoinWallet extends CoinServiceAPI { p2wpkhChangeAddressArray.add(address); } - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(p2wpkhReceiveAddressArray); @@ -1173,22 +1174,6 @@ class BitcoinWallet extends CoinServiceAPI { ]); } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1200,7 +1185,7 @@ class BitcoinWallet extends CoinServiceAPI { } await _prefs.init(); - await _isarInit(); + await isarInit(walletId); } // hack to add tx to txData before refresh completes @@ -1277,8 +1262,6 @@ class BitcoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late Isar isar; - BitcoinWallet({ required String walletId, required String walletName, @@ -1493,7 +1476,7 @@ class BitcoinWallet extends CoinServiceAPI { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(initialAddresses); diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index cf6e25c46..0e2111edc 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -25,6 +25,7 @@ import 'package:stackwallet/services/event_bus/events/global/updated_in_backgrou 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/notifications_api.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -38,7 +39,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -127,7 +127,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) { return getBip32Root(args.item1, args.item2); } -class BitcoinCashWallet extends CoinServiceAPI with WalletCache { +class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); final _prefs = Prefs.instance; @@ -187,7 +187,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isar.close(); + await isarClose(); } bool _hasCalledExit = false; @@ -610,7 +610,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache { p2shChangeAddressArray.add(address); } - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(p2pkhReceiveAddressArray); @@ -1095,22 +1095,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache { ]); } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1128,7 +1112,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache { } await _prefs.init(); - await _isarInit(); + await isarInit(walletId); } // hack to add tx to txData before refresh completes @@ -1232,8 +1216,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache { late SecureStorageInterface _secureStore; - late Isar isar; - BitcoinCashWallet({ required String walletId, required String walletName, @@ -1408,7 +1390,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(initialAddresses); diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 200b509c5..f5b43397a 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -24,6 +24,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/notifications_api.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -37,7 +39,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -124,7 +125,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) { return getBip32Root(args.item1, args.item2); } -class DogecoinWallet extends CoinServiceAPI { +class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); final _prefs = Prefs.instance; @@ -185,7 +186,7 @@ class DogecoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isar.close(); + await isarClose(); } bool _hasCalledExit = false; @@ -525,7 +526,7 @@ class DogecoinWallet extends CoinServiceAPI { p2pkhChangeAddressArray.add(address); } - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(p2pkhChangeAddressArray); @@ -998,22 +999,6 @@ class DogecoinWallet extends CoinServiceAPI { ]); } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1025,7 +1010,7 @@ class DogecoinWallet extends CoinServiceAPI { } await _prefs.init(); - await _isarInit(); + await isarInit(walletId); } // hack to add tx to txData before refresh completes @@ -1102,8 +1087,6 @@ class DogecoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late Isar isar; - DogecoinWallet({ required String walletId, required String walletName, @@ -1262,7 +1245,7 @@ class DogecoinWallet extends CoinServiceAPI { final initialChangeAddressP2PKH = await _generateAddressForChain(1, 0, DerivePathType.bip44); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll([ diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 123dd95cc..12833651b 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -23,6 +23,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; @@ -515,7 +517,7 @@ Future deleteSlate( } } -class EpicCashWallet extends CoinServiceAPI { +class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); final m = Mutex(); @@ -525,8 +527,6 @@ class EpicCashWallet extends CoinServiceAPI { NodeModel? _epicNode; - late Isar isar; - EpicCashWallet( {required String walletId, required String walletName, @@ -956,22 +956,6 @@ class EpicCashWallet extends CoinServiceAPI { return; } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet", @@ -991,7 +975,7 @@ class EpicCashWallet extends CoinServiceAPI { } await _prefs.init(); await updateNode(false); - await _isarInit(); + await isarInit(walletId); await _refreshBalance(); // TODO: is there anything else that should be set up here whenever this wallet is first loaded again? } @@ -1090,7 +1074,7 @@ class EpicCashWallet extends CoinServiceAPI { await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); - await _isarInit(); + await isarInit(walletId); } bool refreshMutex = false; diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 452a3c0f5..7f823ee00 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -26,6 +26,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/notifications_api.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -39,7 +41,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -745,7 +746,7 @@ Future _setTestnetWrapper(bool isTestnet) async { } /// Handles a single instance of a firo wallet -class FiroWallet extends CoinServiceAPI { +class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); @@ -1221,8 +1222,6 @@ class FiroWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late Isar isar; - late TransactionNotificationTracker txTracker; // Constructor @@ -1837,22 +1836,6 @@ class FiroWallet extends CoinServiceAPI { ]); } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log( @@ -1865,7 +1848,7 @@ class FiroWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await _isarInit(); + await isarInit(walletId); } Future refreshIfThereIsNewData() async { @@ -2138,7 +2121,7 @@ class FiroWallet extends CoinServiceAPI { final initialReceivingAddress = await _generateAddressForChain(0, 0); final initialChangeAddress = await _generateAddressForChain(1, 0); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll([ @@ -4279,7 +4262,7 @@ class FiroWallet extends CoinServiceAPI { Logging.instance .log("PROCESSORS ${Platform.numberOfProcessors}", level: LogLevel.Info); try { - await _isarInit(); + await isarInit(walletId); final latestSetId = await getLatestSetId(); final setDataMap = getSetDataMap(latestSetId); diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 199039f02..ee44a229c 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -24,6 +24,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/notifications_api.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -36,7 +38,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -137,7 +138,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) { return getBip32Root(args.item1, args.item2); } -class LitecoinWallet extends CoinServiceAPI { +class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); @@ -217,7 +218,7 @@ class LitecoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isar.close(); + await isarClose(); } bool _hasCalledExit = false; @@ -691,7 +692,7 @@ class LitecoinWallet extends CoinServiceAPI { p2wpkhChangeAddressArray.add(address); } - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(p2wpkhReceiveAddressArray); @@ -1190,22 +1191,6 @@ class LitecoinWallet extends CoinServiceAPI { ]); } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1216,7 +1201,7 @@ class LitecoinWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await _isarInit(); + await isarInit(walletId); } // hack to add tx to txData before refresh completes @@ -1293,8 +1278,6 @@ class LitecoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late Isar isar; - LitecoinWallet({ required String walletId, required String walletName, @@ -1509,7 +1492,7 @@ class LitecoinWallet extends CoinServiceAPI { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(initialAddresses); diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 5093d2ff6..bea661ded 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -34,6 +34,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; @@ -47,14 +49,12 @@ import 'package:stackwallet/utilities/stack_file_system.dart'; const int MINIMUM_CONFIRMATIONS = 10; -class MoneroWallet extends CoinServiceAPI { +class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { final String _walletId; final Coin _coin; final SecureStorageInterface _secureStorage; final Prefs _prefs; - late Isar isar; - String _walletName; bool _shouldAutoSync = false; bool _isConnected = false; @@ -87,22 +87,6 @@ class MoneroWallet extends CoinServiceAPI { _secureStorage = secureStorage, _prefs = prefs ?? Prefs.instance; - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override bool get isFavorite { try { @@ -222,7 +206,7 @@ class MoneroWallet extends CoinServiceAPI { _autoSaveTimer?.cancel(); await walletBase?.save(prioritySave: true); walletBase?.close(); - await isar.close(); + await isarClose(); } } @@ -286,7 +270,7 @@ class MoneroWallet extends CoinServiceAPI { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await _isarInit(); + await isarInit(walletId); // final data = // DB.instance.get(boxName: walletId, key: "latest_tx_model") // as TransactionData?; @@ -421,7 +405,7 @@ class MoneroWallet extends CoinServiceAPI { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.put(initialReceivingAddress); diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index d1901ce7f..642b5e076 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -24,6 +24,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/notifications_api.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -36,7 +38,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -134,7 +135,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) { return getBip32Root(args.item1, args.item2); } -class NamecoinWallet extends CoinServiceAPI { +class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); @@ -212,7 +213,7 @@ class NamecoinWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isar.close(); + await isarClose(); } bool _hasCalledExit = false; @@ -681,7 +682,7 @@ class NamecoinWallet extends CoinServiceAPI { p2wpkhChangeAddressArray.add(address); } - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(p2wpkhReceiveAddressArray); @@ -1180,22 +1181,6 @@ class NamecoinWallet extends CoinServiceAPI { ]); } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1206,7 +1191,7 @@ class NamecoinWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await _isarInit(); + await isarInit(walletId); } // hack to add tx to txData before refresh completes @@ -1283,8 +1268,6 @@ class NamecoinWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late Isar isar; - NamecoinWallet({ required String walletId, required String walletName, @@ -1487,7 +1470,7 @@ class NamecoinWallet extends CoinServiceAPI { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(initialAddresses); diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index e5cea378a..1490371bb 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -23,6 +23,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/notifications_api.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -35,7 +37,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.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'; import 'package:uuid/uuid.dart'; @@ -130,7 +131,7 @@ bip32.BIP32 getBip32RootWrapper(Tuple2 args) { return getBip32Root(args.item1, args.item2); } -class ParticlWallet extends CoinServiceAPI { +class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); @@ -207,7 +208,7 @@ class ParticlWallet extends CoinServiceAPI { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isar.close(); + await isarClose(); } bool _hasCalledExit = false; @@ -615,7 +616,7 @@ class ParticlWallet extends CoinServiceAPI { p2wpkhChangeAddressArray.add(address); } - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(p2wpkhReceiveAddressArray); @@ -1109,22 +1110,6 @@ class ParticlWallet extends CoinServiceAPI { ]); } - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override Future initializeExisting() async { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", @@ -1135,7 +1120,7 @@ class ParticlWallet extends CoinServiceAPI { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await _isarInit(); + await isarInit(walletId); } // TODO make sure this copied implementation from bitcoin_wallet.dart applies for particl just as well--or import it @@ -1213,8 +1198,6 @@ class ParticlWallet extends CoinServiceAPI { late SecureStorageInterface _secureStore; - late Isar isar; - ParticlWallet({ required String walletId, required String walletName, @@ -1399,7 +1382,7 @@ class ParticlWallet extends CoinServiceAPI { _generateAddressForChain(1, 0, DerivePathType.bip44), ]); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.putAll(initialAddresses); diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 2a0bf0ada..c22c715e3 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -36,6 +36,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/utilities/constants.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; @@ -49,14 +51,12 @@ import 'package:stackwallet/utilities/stack_file_system.dart'; const int MINIMUM_CONFIRMATIONS = 10; -class WowneroWallet extends CoinServiceAPI { +class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { final String _walletId; final Coin _coin; final SecureStorageInterface _secureStorage; final Prefs _prefs; - late Isar isar; - String _walletName; bool _shouldAutoSync = false; bool _isConnected = false; @@ -89,22 +89,6 @@ class WowneroWallet extends CoinServiceAPI { _secureStorage = secureStorage, _prefs = prefs ?? Prefs.instance; - Future _isarInit() async { - isar = await Isar.open( - [ - isar_models.TransactionSchema, - isar_models.TransactionNoteSchema, - isar_models.InputSchema, - isar_models.OutputSchema, - isar_models.UTXOSchema, - isar_models.AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, - name: walletId, - ); - } - @override bool get isFavorite { try { @@ -245,7 +229,7 @@ class WowneroWallet extends CoinServiceAPI { _autoSaveTimer?.cancel(); await walletBase?.save(prioritySave: true); walletBase?.close(); - await isar.close(); + await isarClose(); } } @@ -310,13 +294,7 @@ class WowneroWallet extends CoinServiceAPI { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await _isarInit(); - // final data = - // DB.instance.get(boxName: walletId, key: "latest_tx_model") - // as TransactionData?; - // if (data != null) { - // _transactionData = Future(() => data); - // } + await isarInit(walletId); String? password; try { @@ -331,16 +309,6 @@ class WowneroWallet extends CoinServiceAPI { "Opened existing ${coin.prettyName} wallet $walletName", level: LogLevel.Info, ); - // Wallet already exists, triggers for a returning user - // - // String indexKey = "receivingIndex"; - // final curIndex = - // await DB.instance.get(boxName: walletId, key: indexKey) as int; - // // Use new index to derive a new receiving address - // final newReceivingAddress = await _generateAddressForChain(0, curIndex); - // Logging.instance.log( - // "wownero address in init existing: $newReceivingAddress", - // level: LogLevel.Info); } @override @@ -436,7 +404,7 @@ class WowneroWallet extends CoinServiceAPI { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await _isarInit(); + await isarInit(walletId); await isar.writeTxn(() async { await isar.addresses.put(initialReceivingAddress); diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart new file mode 100644 index 000000000..9d470ccd8 --- /dev/null +++ b/lib/services/mixins/wallet_db.dart @@ -0,0 +1,32 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; +import 'package:stackwallet/utilities/stack_file_system.dart'; + +mixin WalletDB { + Isar? _isar; + + Isar get isar => _isar!; + + /// open the db if it was not already open + /// returns true if the db was not yet open + /// returns false if the db was already open + Future isarInit(String walletId) async { + if (_isar != null && isar.isOpen) return false; + _isar = await Isar.open( + [ + TransactionSchema, + TransactionNoteSchema, + InputSchema, + OutputSchema, + UTXOSchema, + AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: false, + name: walletId, + ); + return true; + } + + Future isarClose() async => await _isar?.close() ?? false; +} From 4ab090cb92db1690f8044974f99d7818bb8d5c39 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 12:54:22 -0600 Subject: [PATCH 116/192] remove unused hive inits --- .../coins/bitcoin/bitcoin_wallet.dart | 6 ---- .../coins/bitcoincash/bitcoincash_wallet.dart | 6 ---- .../coins/dogecoin/dogecoin_wallet.dart | 6 ---- .../coins/epiccash/epiccash_wallet.dart | 16 +-------- lib/services/coins/firo/firo_wallet.dart | 6 ---- .../coins/litecoin/litecoin_wallet.dart | 6 ---- lib/services/coins/monero/monero_wallet.dart | 35 ++----------------- .../coins/namecoin/namecoin_wallet.dart | 6 ---- .../coins/particl/particl_wallet.dart | 6 ---- .../coins/wownero/wownero_wallet.dart | 25 ++----------- 10 files changed, 5 insertions(+), 113 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 670ce9436..392728835 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1455,12 +1455,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); - // Generate and add addresses to relevant arrays final initialAddresses = await Future.wait([ // P2WPKH diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 0e2111edc..70de95c33 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1373,12 +1373,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); - // Generate and add addresses to relevant arrays final initialAddresses = await Future.wait([ // P2PKH diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index f5b43397a..f7b8209b8 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1233,12 +1233,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); - // Generate and add addresses final initialReceivingAddressP2PKH = await _generateAddressForChain(0, 0, DerivePathType.bip44); diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 12833651b..a29d1fa49 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -1066,11 +1066,6 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { await DB.instance.put( boxName: walletId, key: "restoreHeight", value: bufferedCreateHeight); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); @@ -1399,16 +1394,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } await DB.instance .put(boxName: walletId, key: "changeIndex", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); + await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 7f823ee00..17a905384 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -2109,12 +2109,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); - await DB.instance .put(boxName: walletId, key: 'jindex', value: []); // Generate and add addresses to relevant arrays diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index ee44a229c..c99c9f285 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -1471,12 +1471,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); - // Generate and add addresses to relevant arrays final initialAddresses = await Future.wait([ // P2WPKH diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index bea661ded..af3acfb82 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -384,21 +384,6 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { await DB.instance .put(boxName: walletId, key: "id", value: _walletId); - // Set relevant indexes - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); - await DB.instance - .put(boxName: walletId, key: "changeIndex", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); @@ -607,26 +592,10 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // walletBase!.onNewBlock = onNewBlock; // walletBase!.onNewTransaction = onNewTransaction; // walletBase!.syncStatusChanged = syncStatusChanged; - await DB.instance.put( - boxName: walletId, - key: 'receivingAddresses', - value: [walletInfo.address!]); - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "changeIndex", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); + await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); } catch (e, s) { diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 642b5e076..d9c62b303 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -1449,12 +1449,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); - // Generate and add addresses to relevant arrays final initialAddresses = await Future.wait([ // P2WPKH diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 1490371bb..435450610 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1365,12 +1365,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); - // Generate and add addresses to relevant arrays final initialAddresses = await Future.wait([ // P2WPKH diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index c22c715e3..f7d254b01 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -393,11 +393,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { await DB.instance .put(boxName: walletId, key: "id", value: _walletId); - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); @@ -609,26 +604,10 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { .add(boxName: WalletInfo.boxName, value: walletInfo); walletBase?.close(); walletBase = wallet as WowneroWalletBase; - await DB.instance.put( - boxName: walletId, - key: 'receivingAddresses', - value: [walletInfo.address!]); - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); + await DB.instance .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "changeIndex", value: 0); - await DB.instance.put( - boxName: walletId, - key: 'blocked_tx_hashes', - value: ["0xdefault"], - ); // A list of transaction hashes to represent frozen utxos in wallet - // initialize address book entries - await DB.instance.put( - boxName: walletId, - key: 'addressBookEntries', - value: {}); + await DB.instance .put(boxName: walletId, key: "isFavorite", value: false); } catch (e, s) { From 61a1ad551fbcba95042a5dd04fa1d88065d4976a Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 12:55:57 -0600 Subject: [PATCH 117/192] clean up print --- lib/services/coins/bitcoincash/bitcoincash_wallet.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 70de95c33..dc0f36682 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1100,12 +1100,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - print("============================================================="); - for (final k in DB.instance.keys(boxName: walletId)) { - print("$k"); - } - print("============================================================="); - if ((DB.instance.get(boxName: walletId, key: DBKeys.id)) == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); From 1170f742e962f5b0f42c441753d8bd4dbda8d54b Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 13:21:03 -0600 Subject: [PATCH 118/192] use balance caching in all wallets --- lib/hive/db.dart | 1 + .../coins/bitcoin/bitcoin_wallet.dart | 3 ++- .../coins/dogecoin/dogecoin_wallet.dart | 3 ++- .../coins/epiccash/epiccash_wallet.dart | 4 ++- lib/services/coins/firo/firo_wallet.dart | 7 +++-- .../coins/litecoin/litecoin_wallet.dart | 3 ++- lib/services/coins/monero/monero_wallet.dart | 3 ++- .../coins/namecoin/namecoin_wallet.dart | 3 ++- .../coins/particl/particl_wallet.dart | 3 ++- .../coins/wownero/wownero_wallet.dart | 3 ++- lib/services/mixins/wallet_cache.dart | 26 +++++++++++++++++++ 11 files changed, 49 insertions(+), 10 deletions(-) diff --git a/lib/hive/db.dart b/lib/hive/db.dart index 962f56405..f5e031972 100644 --- a/lib/hive/db.dart +++ b/lib/hive/db.dart @@ -248,6 +248,7 @@ class DB { abstract class DBKeys { static const String cachedBalance = "cachedBalance"; + static const String cachedBalanceSecondary = "cachedBalanceSecondary"; static const String isFavorite = "isFavorite"; static const String id = "id"; static const String storedChainHeight = "storedChainHeight"; diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 392728835..5dae3eb58 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1810,6 +1810,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); + await updateCachedBalance(walletId, _balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1817,7 +1818,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index f7b8209b8..4a787bd7f 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1552,6 +1552,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); + await updateCachedBalance(walletId, _balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1559,7 +1560,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index a29d1fa49..32344d623 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -2284,10 +2284,12 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { coin, ), ); + + await updateCachedBalance(walletId, _balance!); } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; @override diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 17a905384..e3ecfd787 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -2459,6 +2459,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: 0, pendingSpendable: unconfirmedLelantusBalance + balance.total, ); + await updateCachedBalanceSecondary(walletId, _balancePrivate!); // _balance = Balance( // coin: coin, // total: utxos.satoshiBalance, @@ -3660,6 +3661,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); + await updateCachedBalance(walletId, _balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -4843,10 +4845,11 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; - Balance get balancePrivate => _balancePrivate!; + Balance get balancePrivate => + _balancePrivate ??= getCachedBalanceSecondary(walletId, coin); Balance? _balancePrivate; @override diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index c99c9f285..a19ea6eed 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -1796,6 +1796,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); + await updateCachedBalance(walletId, _balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1803,7 +1804,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index af3acfb82..a606e7f6a 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -734,6 +734,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: 0, pendingSpendable: total - available, ); + await updateCachedBalance(walletId, _balance!); } Future get _availableBalance async { @@ -1214,7 +1215,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int get storedChainHeight => throw UnimplementedError(); @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; @override diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index d9c62b303..94bcc2ff6 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -1776,6 +1776,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); + await updateCachedBalance(walletId, _balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1783,7 +1784,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 435450610..c315e7c12 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1665,6 +1665,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); + await updateCachedBalance(walletId, _balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1672,7 +1673,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index f7d254b01..ac71df11d 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -744,6 +744,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: 0, pendingSpendable: total - available, ); + await updateCachedBalance(walletId, _balance!); } Future get _availableBalance async { @@ -1284,7 +1285,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int get storedChainHeight => throw UnimplementedError(); @override - Balance get balance => _balance!; + Balance get balance => _balance ??= getCachedBalance(walletId, coin); Balance? _balance; @override diff --git a/lib/services/mixins/wallet_cache.dart b/lib/services/mixins/wallet_cache.dart index 6d085c734..c838dc684 100644 --- a/lib/services/mixins/wallet_cache.dart +++ b/lib/services/mixins/wallet_cache.dart @@ -27,4 +27,30 @@ mixin WalletCache { value: balance.toJsonIgnoreCoin(), ); } + + Balance getCachedBalanceSecondary(String walletId, Coin coin) { + final jsonString = DB.instance.get( + boxName: walletId, + key: DBKeys.cachedBalanceSecondary, + ) as String?; + if (jsonString == null) { + return Balance( + coin: coin, + total: 0, + spendable: 0, + blockedTotal: 0, + pendingSpendable: 0, + ); + } + return Balance.fromJson(jsonString, coin); + } + + Future updateCachedBalanceSecondary( + String walletId, Balance balance) async { + await DB.instance.put( + boxName: walletId, + key: DBKeys.cachedBalanceSecondary, + value: balance.toJsonIgnoreCoin(), + ); + } } From 12bbc57e6238cd7d34efcf5c638dbed018e52f63 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 14:57:07 -0600 Subject: [PATCH 119/192] update wallet cache hive mixin --- lib/services/mixins/wallet_cache.dart | 85 +++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 13 deletions(-) diff --git a/lib/services/mixins/wallet_cache.dart b/lib/services/mixins/wallet_cache.dart index c838dc684..ec0cbfe67 100644 --- a/lib/services/mixins/wallet_cache.dart +++ b/lib/services/mixins/wallet_cache.dart @@ -3,52 +3,111 @@ import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; mixin WalletCache { - Balance getCachedBalance(String walletId, Coin coin) { + late final String _walletId; + late final Coin _coin; + + void initCache(String walletId, Coin coin) { + _walletId = walletId; + _coin = coin; + } + + // cached wallet id + String? getCachedId() { + return DB.instance.get( + boxName: _walletId, + key: DBKeys.id, + ) as String?; + } + + Future updateCachedId(String? id) async { + await DB.instance.put( + boxName: _walletId, + key: DBKeys.id, + value: id, + ); + } + + // cached Chain Height + int getCachedChainHeight() { + return DB.instance.get( + boxName: _walletId, + key: DBKeys.storedChainHeight, + ) as int? ?? + 0; + } + + Future updateCachedChainHeight(int height) async { + await DB.instance.put( + boxName: _walletId, + key: DBKeys.storedChainHeight, + value: height, + ); + } + + // wallet favorite flag + bool getCachedIsFavorite() { + return DB.instance.get( + boxName: _walletId, + key: DBKeys.isFavorite, + ) as bool? ?? + false; + } + + Future updateCachedIsFavorite(bool isFavorite) async { + await DB.instance.put( + boxName: _walletId, + key: DBKeys.isFavorite, + value: isFavorite, + ); + } + + // main balance cache + Balance getCachedBalance() { final jsonString = DB.instance.get( - boxName: walletId, + boxName: _walletId, key: DBKeys.cachedBalance, ) as String?; if (jsonString == null) { return Balance( - coin: coin, + coin: _coin, total: 0, spendable: 0, blockedTotal: 0, pendingSpendable: 0, ); } - return Balance.fromJson(jsonString, coin); + return Balance.fromJson(jsonString, _coin); } - Future updateCachedBalance(String walletId, Balance balance) async { + Future updateCachedBalance(Balance balance) async { await DB.instance.put( - boxName: walletId, + boxName: _walletId, key: DBKeys.cachedBalance, value: balance.toJsonIgnoreCoin(), ); } - Balance getCachedBalanceSecondary(String walletId, Coin coin) { + // secondary balance cache for coins such as firo + Balance getCachedBalanceSecondary() { final jsonString = DB.instance.get( - boxName: walletId, + boxName: _walletId, key: DBKeys.cachedBalanceSecondary, ) as String?; if (jsonString == null) { return Balance( - coin: coin, + coin: _coin, total: 0, spendable: 0, blockedTotal: 0, pendingSpendable: 0, ); } - return Balance.fromJson(jsonString, coin); + return Balance.fromJson(jsonString, _coin); } - Future updateCachedBalanceSecondary( - String walletId, Balance balance) async { + Future updateCachedBalanceSecondary(Balance balance) async { await DB.instance.put( - boxName: walletId, + boxName: _walletId, key: DBKeys.cachedBalanceSecondary, value: balance.toJsonIgnoreCoin(), ); From 9b2b01764cb1d0a234a1c72a27f9701d51d7bea2 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 14:57:32 -0600 Subject: [PATCH 120/192] add epic cash wallet cache hive mixin --- lib/services/mixins/epic_cash_hive.dart | 112 ++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 lib/services/mixins/epic_cash_hive.dart diff --git a/lib/services/mixins/epic_cash_hive.dart b/lib/services/mixins/epic_cash_hive.dart new file mode 100644 index 000000000..80053034a --- /dev/null +++ b/lib/services/mixins/epic_cash_hive.dart @@ -0,0 +1,112 @@ +import 'package:stackwallet/hive/db.dart'; + +mixin EpicCashHive { + late final String _walletId; + + void initEpicCashHive(String walletId) { + _walletId = walletId; + } + + // receiving index + int? epicGetReceivingIndex() { + return DB.instance.get(boxName: _walletId, key: "receivingIndex") + as int?; + } + + Future epicUpdateReceivingIndex(int index) async { + await DB.instance.put( + boxName: _walletId, + key: "receivingIndex", + value: index, + ); + } + + // change index + int? epicGetChangeIndex() { + return DB.instance.get(boxName: _walletId, key: "changeIndex") + as int?; + } + + Future epicUpdateChangeIndex(int index) async { + await DB.instance.put( + boxName: _walletId, + key: "changeIndex", + value: index, + ); + } + + // slateToAddresses + Map epicGetSlatesToAddresses() { + return DB.instance.get( + boxName: _walletId, + key: "slate_to_address", + ) as Map? ?? + {}; + } + + Future epicUpdateSlatesToAddresses(Map map) async { + await DB.instance.put( + boxName: _walletId, + key: "slate_to_address", + value: map, + ); + } + + // slatesToCommits + Map? epicGetSlatesToCommits() { + return DB.instance.get( + boxName: _walletId, + key: "slatesToCommits", + ) as Map?; + } + + Future epicUpdateSlatesToCommits(Map map) async { + await DB.instance.put( + boxName: _walletId, + key: "slatesToCommits", + value: map, + ); + } + + // last scanned block + int? epicGetLastScannedBlock() { + return DB.instance.get(boxName: _walletId, key: "lastScannedBlock") + as int?; + } + + Future epicUpdateLastScannedBlock(int blockHeight) async { + await DB.instance.put( + boxName: _walletId, + key: "lastScannedBlock", + value: blockHeight, + ); + } + + // epic restore height + int? epicGetRestoreHeight() { + return DB.instance.get(boxName: _walletId, key: "restoreHeight") + as int; + } + + Future epicUpdateRestoreHeight(int height) async { + await DB.instance.put( + boxName: _walletId, + key: "restoreHeight", + value: height, + ); + } + + // epic creation height + int? epicGetCreationHeight() { + return DB.instance.get(boxName: _walletId, key: "creationHeight") + as int; + } + + Future epicUpdateCreationHeight(int height) async { + await DB.instance.put( + boxName: _walletId, + key: "creationHeight", + value: height, + ); + } +} From 85be64604969e6d0ac912d6542a2ab2bb9ee9d63 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 14:58:58 -0600 Subject: [PATCH 121/192] add mixins to epiccash_wallet.dart and remove directly interacting with hive therein --- .../coins/epiccash/epiccash_wallet.dart | 211 ++++++------------ 1 file changed, 74 insertions(+), 137 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 32344d623..73fafcbb8 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -10,7 +10,6 @@ import 'package:http/http.dart'; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:stack_wallet_backup/generate_password.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/node_model.dart'; @@ -23,6 +22,7 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha 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/epic_cash_hive.dart'; import 'package:stackwallet/services/mixins/wallet_cache.dart'; import 'package:stackwallet/services/mixins/wallet_db.dart'; import 'package:stackwallet/services/node_service.dart'; @@ -517,7 +517,8 @@ Future deleteSlate( } } -class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { +class EpicCashWallet extends CoinServiceAPI + with WalletCache, WalletDB, EpicCashHive { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); final m = Mutex(); @@ -536,6 +537,8 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { _walletName = walletName; _coin = coin; _secureStore = secureStore; + initCache(walletId, coin); + initEpicCashHive(walletId); Logging.instance.log("$walletName isolate length: ${isolates.length}", level: LogLevel.Info); @@ -562,22 +565,14 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; late ReceivePort receivePort; @@ -643,7 +638,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } Timer? timer; - late Coin _coin; + late final Coin _coin; @override Coin get coin => _coin; @@ -652,8 +647,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Future cancelPendingTransactionAndPost(String txSlateId) async { final wallet = await _secureStore.read(key: '${_walletId}_wallet'); - final int? receivingIndex = DB.instance - .get(boxName: walletId, key: "receivingIndex") as int?; + final int? receivingIndex = epicGetReceivingIndex(); final epicboxConfig = await _secureStore.read(key: '${_walletId}_epicboxConfig'); @@ -818,18 +812,11 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final txLogEntry = json.decode(tx as String); final txLogEntryFirst = txLogEntry[0]; Logger.print("TX_LOG_ENTRY_IS $txLogEntryFirst"); - final slateToAddresses = DB.instance.get( - boxName: walletId, - key: "slate_to_address", - ) as Map? ?? - {}; + final slateToAddresses = epicGetSlatesToAddresses(); final slateId = txLogEntryFirst['tx_slate_id'] as String; slateToAddresses[slateId] = txData['addresss']; - await DB.instance.put( - boxName: walletId, - key: "slate_to_address", - value: slateToAddresses, - ); + await epicUpdateSlatesToAddresses(slateToAddresses); + final slatesToCommits = await getSlatesToCommits(); String? commitId = slatesToCommits[slateId]?['commitId'] as String?; Logging.instance.log("sent commitId: $commitId", level: LogLevel.Info); @@ -917,10 +904,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { ), ); - await DB.instance.put( - boxName: walletId, - key: "lastScannedBlock", - value: await getRestoreHeight()); + await epicUpdateLastScannedBlock(await getRestoreHeight()); if (!await startScans()) { refreshMutex = false; @@ -967,7 +951,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final walletOpen = openWallet(config, password!); await _secureStore.write(key: '${_walletId}_wallet', value: walletOpen); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { //todo: check if print needed // debugPrint("Exception was thrown"); throw Exception( @@ -1063,11 +1047,10 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final bufferedCreateHeight = calculateRestoreHeightFrom( date: DateTime.now().subtract(const Duration(days: 2))); - await DB.instance.put( - boxName: walletId, key: "restoreHeight", value: bufferedCreateHeight); - - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + epicUpdateRestoreHeight(bufferedCreateHeight), + updateCachedIsFavorite(false), + ]); await isarInit(walletId); } @@ -1268,27 +1251,17 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { try { final wallet = await _secureStore.read(key: '${_walletId}_wallet'); - var restoreHeight = - DB.instance.get(boxName: walletId, key: "restoreHeight"); + var restoreHeight = epicGetRestoreHeight(); var chainHeight = await this.chainHeight; - if (!DB.instance.containsKey( - boxName: walletId, key: 'lastScannedBlock') || - DB.instance - .get(boxName: walletId, key: 'lastScannedBlock') == - null) { - await DB.instance.put( - boxName: walletId, - key: "lastScannedBlock", - value: await getRestoreHeight()); + if (epicGetLastScannedBlock() == null) { + await epicUpdateLastScannedBlock(await getRestoreHeight()); } - int lastScannedBlock = DB.instance - .get(boxName: walletId, key: 'lastScannedBlock') as int; + int lastScannedBlock = epicGetLastScannedBlock()!; const MAX_PER_LOOP = 10000; await getSyncPercent; for (; lastScannedBlock < chainHeight;) { chainHeight = await this.chainHeight; - lastScannedBlock = DB.instance - .get(boxName: walletId, key: 'lastScannedBlock') as int; + lastScannedBlock = epicGetLastScannedBlock()!; Logging.instance.log( "chainHeight: $chainHeight, restoreHeight: $restoreHeight, lastScannedBlock: $lastScannedBlock", level: LogLevel.Info); @@ -1313,10 +1286,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log('Closing scanOutPuts!\n $message', level: LogLevel.Info); }); - await DB.instance.put( - boxName: walletId, - key: "lastScannedBlock", - value: nextScannedBlock!); + await epicUpdateLastScannedBlock(nextScannedBlock!); await getSyncPercent; } Logging.instance.log("successfully at the tip", level: LogLevel.Info); @@ -1328,9 +1298,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future get getSyncPercent async { - int lastScannedBlock = DB.instance - .get(boxName: walletId, key: 'lastScannedBlock') as int? ?? - 0; + int lastScannedBlock = epicGetLastScannedBlock() ?? 0; final _chainHeight = await chainHeight; double restorePercent = lastScannedBlock / _chainHeight; GlobalEventBus.instance @@ -1379,24 +1347,13 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { ), ); - await DB.instance - .put(boxName: walletId, key: "restoreHeight", value: height); - - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance.put( - boxName: walletId, key: 'receivingAddresses', value: ["0"]); - await DB.instance - .put(boxName: walletId, key: "receivingIndex", value: 0); - if (height >= 0) { - await DB.instance.put( - boxName: walletId, key: "restoreHeight", value: height); - } - await DB.instance - .put(boxName: walletId, key: "changeIndex", value: 0); - - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + epicUpdateRestoreHeight(height), + updateCachedId(walletId), + epicUpdateReceivingIndex(0), + epicUpdateChangeIndex(0), + updateCachedIsFavorite(false), + ]); //Open Wallet final walletOpen = openWallet(stringConfig, password); @@ -1412,38 +1369,31 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future getRestoreHeight() async { - if (DB.instance - .containsKey(boxName: walletId, key: "restoreHeight")) { - return (DB.instance.get(boxName: walletId, key: "restoreHeight")) - as int; - } - return (DB.instance.get(boxName: walletId, key: "creationHeight")) - as int; + return epicGetRestoreHeight() ?? epicGetCreationHeight()!; } Future get chainHeight async { - final config = await getRealConfig(); - int? latestHeight; - await m.protect(() async { - latestHeight = await compute( - _getChainHeightWrapper, - config, - ); - }); - return latestHeight!; + try { + final config = await getRealConfig(); + int? latestHeight; + await m.protect(() async { + latestHeight = await compute( + _getChainHeightWrapper, + config, + ); + }); + + await updateCachedChainHeight(latestHeight!); + return latestHeight!; + } catch (e, s) { + Logging.instance.log("Exception caught in chainHeight: $e\n$s", + level: LogLevel.Error); + return storedChainHeight; + } } @override - int get storedChainHeight { - return DB.instance.get(boxName: walletId, key: "storedChainHeight") - as int? ?? - 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); bool _shouldAutoSync = true; @@ -1468,8 +1418,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Future setCurrentIndex() async { try { - final int receivingIndex = DB.instance - .get(boxName: walletId, key: "receivingIndex") as int; + final int receivingIndex = epicGetReceivingIndex()!; // TODO: go through pendingarray and processed array and choose the index // of the last one that has not been processed, or the index after the one most recently processed; return receivingIndex; @@ -1503,14 +1452,13 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Future> getSlatesToCommits() async { try { - var slatesToCommits = - DB.instance.get(boxName: walletId, key: "slatesToCommits"); + var slatesToCommits = epicGetSlatesToCommits(); if (slatesToCommits == null) { slatesToCommits = {}; } else { - slatesToCommits = slatesToCommits as Map; + slatesToCommits = slatesToCommits; } - return slatesToCommits as Map; + return slatesToCommits; } catch (e, s) { Logging.instance.log("$e $s", level: LogLevel.Error); return {}; @@ -1536,8 +1484,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { "from": from, "to": to, }; - await DB.instance.put( - boxName: walletId, key: "slatesToCommits", value: slatesToCommits); + await epicUpdateSlatesToCommits(slatesToCommits); return true; } catch (e, s) { Logging.instance.log("$e $s", level: LogLevel.Error); @@ -1568,8 +1515,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { "from": from, "to": to, }; - await DB.instance.put( - boxName: walletId, key: "slatesToCommits", value: slatesToCommits); + await epicUpdateSlatesToCommits(slatesToCommits); return true; } catch (e, s) { Logging.instance.log("$e $s", level: LogLevel.Error); @@ -1578,8 +1524,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future processAllSlates() async { - final int? receivingIndex = DB.instance - .get(boxName: walletId, key: "receivingIndex") as int?; + final int? receivingIndex = epicGetReceivingIndex(); for (int currentReceivingIndex = 0; receivingIndex != null && currentReceivingIndex <= receivingIndex; currentReceivingIndex++) { @@ -1752,8 +1697,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final wallet = await _secureStore.read(key: '${_walletId}_wallet'); final epicboxConfig = await _secureStore.read(key: '${_walletId}_epicboxConfig'); - final int? receivingIndex = DB.instance - .get(boxName: walletId, key: "receivingIndex") as int?; + final int? receivingIndex = epicGetReceivingIndex(); for (int currentReceivingIndex = 0; receivingIndex != null && currentReceivingIndex <= receivingIndex; @@ -1843,10 +1787,8 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { ), ); - if (!DB.instance - .containsKey(boxName: walletId, key: "creationHeight")) { - await DB.instance.put( - boxName: walletId, key: "creationHeight", value: await chainHeight); + if (epicGetCreationHeight() == null) { + await epicUpdateCreationHeight(await chainHeight); } final int curAdd = await setCurrentIndex(); @@ -1891,11 +1833,6 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // TODO: implement refresh // TODO: check if it needs a refresh and if so get all of the most recent data. if (currentHeight != storedHeight) { - if (currentHeight != -1) { - // -1 failed to fetch current height - unawaited(updateStoredChainHeight(newHeight: currentHeight)); - } - await _refreshTransactions(); GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.50, walletId)); @@ -2046,10 +1983,10 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final List midSortedArray = []; - int latestTxnBlockHeight = - DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - as int? ?? - 0; + // int latestTxnBlockHeight = + // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") + // as int? ?? + // 0; final slatesToCommits = await getSlatesToCommits(); for (var tx in jsonTransactions) { @@ -2121,9 +2058,9 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { txn.otherData = tx["id"].toString(); - if (txHeight >= latestTxnBlockHeight) { - latestTxnBlockHeight = txHeight; - } + // if (txHeight >= latestTxnBlockHeight) { + // latestTxnBlockHeight = txHeight; + // } midSortedArray.add(txn); // cachedMap?.remove(tx["id"].toString()); @@ -2209,7 +2146,7 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { @override String get walletId => _walletId; - late String _walletId; + late final String _walletId; @override String get walletName => _walletName; @@ -2285,11 +2222,11 @@ class EpicCashWallet extends CoinServiceAPI with WalletCache, WalletDB { ), ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; @override From 5c70cf796745296f7bdbe91629fad2b0ff7226bb Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 15:20:57 -0600 Subject: [PATCH 122/192] add mixins to firo_wallet.dart and remove directly interacting with hive therein --- lib/services/coins/firo/firo_wallet.dart | 432 ++++++++++------------- lib/services/mixins/firo_hive.dart | 50 +++ 2 files changed, 246 insertions(+), 236 deletions(-) create mode 100644 lib/services/mixins/firo_hive.dart diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index e3ecfd787..421090384 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -13,7 +13,6 @@ import 'package:isar/isar.dart'; import 'package:lelantus/lelantus.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/lelantus_coin.dart'; @@ -44,6 +43,8 @@ import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; +import '../../mixins/firo_hive.dart'; + const DUST_LIMIT = 1000; const MINIMUM_CONFIRMATIONS = 1; const MINT_LIMIT = 100100000000; @@ -746,14 +747,14 @@ Future _setTestnetWrapper(bool isTestnet) async { } /// Handles a single instance of a firo wallet -class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { +class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { static const integrationTestFlag = bool.fromEnvironment("IS_INTEGRATION_TEST"); final _prefs = Prefs.instance; Timer? timer; - late Coin _coin; + late final Coin _coin; bool _shouldAutoSync = false; @@ -788,22 +789,14 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; @override Coin get coin => _coin; @@ -918,7 +911,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { set walletName(String newName) => _walletName = newName; /// unique wallet id - late String _walletId; + late final String _walletId; @override String get walletId => _walletId; @@ -1241,6 +1234,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { _electrumXClient = client; _cachedElectrumXClient = cachedClient; _secureStore = secureStore; + initCache(walletId, coin); + initFiroHive(walletId); Logging.instance.log("$walletName isolates length: ${isolates.length}", level: LogLevel.Info); @@ -1815,7 +1810,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if (DB.instance.get(boxName: walletId, key: "id") != null) { + if (getCachedId() != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -1830,9 +1825,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { } await Future.wait([ - DB.instance.put(boxName: walletId, key: "id", value: _walletId), - DB.instance - .put(boxName: walletId, key: "isFavorite", value: false), + updateCachedId(walletId), + updateCachedIsFavorite(false), ]); } @@ -1842,8 +1836,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { "Opening existing $_walletId ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id") as String?) == - null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -2109,8 +2102,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { key: '${_walletId}_mnemonic', value: bip39.generateMnemonic(strength: 256)); - await DB.instance - .put(boxName: walletId, key: 'jindex', value: []); + await firoUpdateJIndex([]); // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); final initialChangeAddress = await _generateAddressForChain(1, 0); @@ -2287,8 +2279,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { } List> getLelantusCoinMap() { - final _l = DB.instance - .get(boxName: walletId, key: '_lelantus_coins') as List?; + final _l = firoGetLelantusCoins(); final List> lelantusCoins = []; for (var el in _l ?? []) { lelantusCoins.add({el.keys.first: el.values.first as LelantusCoin}); @@ -2302,8 +2293,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { lelantusCoins.removeWhere((element) => element.values.any((elementCoin) => elementCoin.value == 0)); } - final jindexes = - DB.instance.get(boxName: walletId, key: 'jindex') as List?; + final jindexes = firoGetJIndex(); final transactions = await _txnData; final lelantusTransactionsd = await lelantusTransactionData; @@ -2374,8 +2364,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { final data = await _txnData; final lData = await lelantusTransactionData; final currentChainHeight = await chainHeight; - final jindexes = - DB.instance.get(boxName: walletId, key: 'jindex') as List?; + final jindexes = firoGetJIndex(); int intLelantusBalance = 0; int unconfirmedLelantusBalance = 0; @@ -2459,7 +2448,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: 0, pendingSpendable: unconfirmedLelantusBalance + balance.total, ); - await updateCachedBalanceSecondary(walletId, _balancePrivate!); + await updateCachedBalanceSecondary(_balancePrivate!); // _balance = Balance( // coin: coin, // total: utxos.satoshiBalance, @@ -2593,8 +2582,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { var tmpTotal = total; var index = 0; var mints = >[]; - final nextFreeMintIndex = - DB.instance.get(boxName: walletId, key: 'mintIndex') as int; + final nextFreeMintIndex = firoGetMintIndex()!; while (tmpTotal > 0) { final mintValue = min(tmpTotal, MINT_LIMIT); final mint = await _getMintHex( @@ -2727,8 +2715,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { amount += utxosToUse[i].value; } - final index = - DB.instance.get(boxName: walletId, key: 'mintIndex') as int; + final index = firoGetMintIndex()!; Logging.instance.log("index of mint $index", level: LogLevel.Info); for (var mintsElement in mintsMap) { @@ -2773,8 +2760,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { Future _refreshLelantusData() async { final List> lelantusCoins = getLelantusCoinMap(); - final jindexes = - DB.instance.get(boxName: walletId, key: 'jindex') as List?; + final jindexes = firoGetJIndex(); // Get all joinsplit transaction ids @@ -2912,8 +2898,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { "_submitLelantusToNetwork txid: ${transactionInfo['txid']}", level: LogLevel.Info); if (txid == transactionInfo['txid']) { - final index = - DB.instance.get(boxName: walletId, key: 'mintIndex') as int?; + final index = firoGetMintIndex(); final List> lelantusCoins = getLelantusCoinMap(); List> coins; @@ -2951,16 +2936,12 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { false); if (jmint.value > 0) { coins.add({jmint.txId: jmint}); - final jindexes = DB.instance - .get(boxName: walletId, key: 'jindex') as List?; - jindexes!.add(index); - await DB.instance - .put(boxName: walletId, key: 'jindex', value: jindexes); - await DB.instance.put( - boxName: walletId, key: 'mintIndex', value: index + 1); + final jindexes = firoGetJIndex()!; + jindexes.add(index); + await firoUpdateJIndex(jindexes); + await firoUpdateMintIndex(index + 1); } - await DB.instance.put( - boxName: walletId, key: '_lelantus_coins', value: coins); + await firoUpdateLelantusCoins(coins); // add the send transaction final transaction = isar_models.Transaction() @@ -3017,13 +2998,11 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (mint.value > 0) { coins.add({mint.txId: mint}); - await DB.instance.put( - boxName: walletId, key: 'mintIndex', value: index + 1); + await firoUpdateMintIndex(index + 1); } } // Logging.instance.log(coins); - await DB.instance.put( - boxName: walletId, key: '_lelantus_coins', value: coins); + await firoUpdateLelantusCoins(coins); } return true; } else { @@ -3661,7 +3640,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -3865,7 +3844,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // back up data - await _rescanBackup(); + // await _rescanBackup(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3890,7 +3869,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // restore from backup - await _rescanRestore(); + // await _rescanRestore(); longMutex = false; Logging.instance.log("Exception rethrown from fullRescan(): $e\n$s", @@ -3899,150 +3878,150 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - Future _rescanBackup() async { - Logging.instance.log("starting rescan backup", level: LogLevel.Info); - - // backup current and clear data - final tempReceivingAddresses = - DB.instance.get(boxName: walletId, key: 'receivingAddresses'); - await DB.instance.delete( - key: 'receivingAddresses', - boxName: walletId, - ); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddresses_BACKUP', - value: tempReceivingAddresses); - - final tempChangeAddresses = - DB.instance.get(boxName: walletId, key: 'changeAddresses'); - await DB.instance.delete( - key: 'changeAddresses', - boxName: walletId, - ); - await DB.instance.put( - boxName: walletId, - key: 'changeAddresses_BACKUP', - value: tempChangeAddresses); - - final tempReceivingIndex = - DB.instance.get(boxName: walletId, key: 'receivingIndex'); - await DB.instance.delete( - key: 'receivingIndex', - boxName: walletId, - ); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndex_BACKUP', - value: tempReceivingIndex); - - final tempChangeIndex = - DB.instance.get(boxName: walletId, key: 'changeIndex'); - await DB.instance.delete( - key: 'changeIndex', - boxName: walletId, - ); - await DB.instance.put( - boxName: walletId, key: 'changeIndex_BACKUP', value: tempChangeIndex); - - final receiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivations"); - final changeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivations"); - - await _secureStore.write( - key: "${walletId}_receiveDerivations_BACKUP", - value: receiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivations_BACKUP", - value: changeDerivationsString); - - await _secureStore.write( - key: "${walletId}_receiveDerivations", value: null); - await _secureStore.write(key: "${walletId}_changeDerivations", value: null); - - // back up but no need to delete - final tempMintIndex = - DB.instance.get(boxName: walletId, key: 'mintIndex'); - await DB.instance.put( - boxName: walletId, key: 'mintIndex_BACKUP', value: tempMintIndex); - - final tempLelantusCoins = - DB.instance.get(boxName: walletId, key: '_lelantus_coins'); - await DB.instance.put( - boxName: walletId, - key: '_lelantus_coins_BACKUP', - value: tempLelantusCoins); - - final tempJIndex = - DB.instance.get(boxName: walletId, key: 'jindex'); - await DB.instance.put( - boxName: walletId, key: 'jindex_BACKUP', value: tempJIndex); - - final tempLelantusTxModel = DB.instance - .get(boxName: walletId, key: 'latest_lelantus_tx_model'); - await DB.instance.put( - boxName: walletId, - key: 'latest_lelantus_tx_model_BACKUP', - value: tempLelantusTxModel); - - Logging.instance.log("rescan backup complete", level: LogLevel.Info); - } - - Future _rescanRestore() async { - Logging.instance.log("starting rescan restore", level: LogLevel.Info); - - // restore from backup - final tempReceivingAddresses = DB.instance - .get(boxName: walletId, key: 'receivingAddresses_BACKUP'); - final tempChangeAddresses = DB.instance - .get(boxName: walletId, key: 'changeAddresses_BACKUP'); - final tempReceivingIndex = DB.instance - .get(boxName: walletId, key: 'receivingIndex_BACKUP'); - final tempChangeIndex = - DB.instance.get(boxName: walletId, key: 'changeIndex_BACKUP'); - final tempMintIndex = - DB.instance.get(boxName: walletId, key: 'mintIndex_BACKUP'); - final tempLelantusCoins = DB.instance - .get(boxName: walletId, key: '_lelantus_coins_BACKUP'); - final tempJIndex = - DB.instance.get(boxName: walletId, key: 'jindex_BACKUP'); - final tempLelantusTxModel = DB.instance.get( - boxName: walletId, key: 'latest_lelantus_tx_model_BACKUP'); - - final receiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivations_BACKUP"); - final changeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivations_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivations", value: receiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivations", value: changeDerivationsString); - - await DB.instance.put( - boxName: walletId, - key: 'receivingAddresses', - value: tempReceivingAddresses); - await DB.instance.put( - boxName: walletId, key: 'changeAddresses', value: tempChangeAddresses); - await DB.instance.put( - boxName: walletId, key: 'receivingIndex', value: tempReceivingIndex); - await DB.instance.put( - boxName: walletId, key: 'changeIndex', value: tempChangeIndex); - await DB.instance.put( - boxName: walletId, key: 'mintIndex', value: tempMintIndex); - await DB.instance.put( - boxName: walletId, key: '_lelantus_coins', value: tempLelantusCoins); - await DB.instance - .put(boxName: walletId, key: 'jindex', value: tempJIndex); - await DB.instance.put( - boxName: walletId, - key: 'latest_lelantus_tx_model', - value: tempLelantusTxModel); - - Logging.instance.log("rescan restore complete", level: LogLevel.Info); - } + // Future _rescanBackup() async { + // Logging.instance.log("starting rescan backup", level: LogLevel.Info); + // + // // backup current and clear data + // final tempReceivingAddresses = + // DB.instance.get(boxName: walletId, key: 'receivingAddresses'); + // await DB.instance.delete( + // key: 'receivingAddresses', + // boxName: walletId, + // ); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddresses_BACKUP', + // value: tempReceivingAddresses); + // + // final tempChangeAddresses = + // DB.instance.get(boxName: walletId, key: 'changeAddresses'); + // await DB.instance.delete( + // key: 'changeAddresses', + // boxName: walletId, + // ); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddresses_BACKUP', + // value: tempChangeAddresses); + // + // final tempReceivingIndex = + // DB.instance.get(boxName: walletId, key: 'receivingIndex'); + // await DB.instance.delete( + // key: 'receivingIndex', + // boxName: walletId, + // ); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndex_BACKUP', + // value: tempReceivingIndex); + // + // final tempChangeIndex = + // DB.instance.get(boxName: walletId, key: 'changeIndex'); + // await DB.instance.delete( + // key: 'changeIndex', + // boxName: walletId, + // ); + // await DB.instance.put( + // boxName: walletId, key: 'changeIndex_BACKUP', value: tempChangeIndex); + // + // final receiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivations"); + // final changeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivations"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivations_BACKUP", + // value: receiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivations_BACKUP", + // value: changeDerivationsString); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivations", value: null); + // await _secureStore.write(key: "${walletId}_changeDerivations", value: null); + // + // // back up but no need to delete + // final tempMintIndex = + // DB.instance.get(boxName: walletId, key: 'mintIndex'); + // await DB.instance.put( + // boxName: walletId, key: 'mintIndex_BACKUP', value: tempMintIndex); + // + // final tempLelantusCoins = + // DB.instance.get(boxName: walletId, key: '_lelantus_coins'); + // await DB.instance.put( + // boxName: walletId, + // key: '_lelantus_coins_BACKUP', + // value: tempLelantusCoins); + // + // final tempJIndex = + // DB.instance.get(boxName: walletId, key: 'jindex'); + // await DB.instance.put( + // boxName: walletId, key: 'jindex_BACKUP', value: tempJIndex); + // + // final tempLelantusTxModel = DB.instance + // .get(boxName: walletId, key: 'latest_lelantus_tx_model'); + // await DB.instance.put( + // boxName: walletId, + // key: 'latest_lelantus_tx_model_BACKUP', + // value: tempLelantusTxModel); + // + // Logging.instance.log("rescan backup complete", level: LogLevel.Info); + // } + // + // Future _rescanRestore() async { + // Logging.instance.log("starting rescan restore", level: LogLevel.Info); + // + // // restore from backup + // final tempReceivingAddresses = DB.instance + // .get(boxName: walletId, key: 'receivingAddresses_BACKUP'); + // final tempChangeAddresses = DB.instance + // .get(boxName: walletId, key: 'changeAddresses_BACKUP'); + // final tempReceivingIndex = DB.instance + // .get(boxName: walletId, key: 'receivingIndex_BACKUP'); + // final tempChangeIndex = + // DB.instance.get(boxName: walletId, key: 'changeIndex_BACKUP'); + // final tempMintIndex = + // DB.instance.get(boxName: walletId, key: 'mintIndex_BACKUP'); + // final tempLelantusCoins = DB.instance + // .get(boxName: walletId, key: '_lelantus_coins_BACKUP'); + // final tempJIndex = + // DB.instance.get(boxName: walletId, key: 'jindex_BACKUP'); + // final tempLelantusTxModel = DB.instance.get( + // boxName: walletId, key: 'latest_lelantus_tx_model_BACKUP'); + // + // final receiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivations_BACKUP"); + // final changeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivations_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivations", value: receiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivations", value: changeDerivationsString); + // + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddresses', + // value: tempReceivingAddresses); + // await DB.instance.put( + // boxName: walletId, key: 'changeAddresses', value: tempChangeAddresses); + // await DB.instance.put( + // boxName: walletId, key: 'receivingIndex', value: tempReceivingIndex); + // await DB.instance.put( + // boxName: walletId, key: 'changeIndex', value: tempChangeIndex); + // await DB.instance.put( + // boxName: walletId, key: 'mintIndex', value: tempMintIndex); + // await DB.instance.put( + // boxName: walletId, key: '_lelantus_coins', value: tempLelantusCoins); + // await DB.instance + // .put(boxName: walletId, key: 'jindex', value: tempJIndex); + // await DB.instance.put( + // boxName: walletId, + // key: 'latest_lelantus_tx_model', + // value: tempLelantusTxModel); + // + // Logging.instance.log("rescan restore complete", level: LogLevel.Info); + // } /// wrapper for _recoverWalletFromBIP32SeedPhrase() @override @@ -4266,10 +4245,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { final makeDerivations = _makeDerivations(suppliedMnemonic, maxUnusedAddressGap); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); await Future.wait([usedSerialNumbers, setDataMap, makeDerivations]); @@ -4315,14 +4294,11 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { await chainHeight, ); - await DB.instance.put( - boxName: walletId, key: 'mintIndex', value: message['mintIndex']); - await DB.instance.put( - boxName: walletId, - key: '_lelantus_coins', - value: message['_lelantus_coins']); - await DB.instance.put( - boxName: walletId, key: 'jindex', value: message['jindex']); + await Future.wait([ + firoUpdateMintIndex(message['mintIndex'] as int), + firoUpdateLelantusCoins(message['_lelantus_coins'] as List), + firoUpdateJIndex(message['jindex'] as List), + ]); final transactionMap = message["newTxMap"] as Map; @@ -4341,14 +4317,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { await isar.writeTxn(() async { await isar.transactions.putAllByTxid(transactionMap.values.toList()); }); - - // final models.TransactionData newTxData = - // models.TransactionData.fromMap(transactionMap); - // - // _lelantusTransactionData = Future(() => newTxData); - // - // await DB.instance.put( - // boxName: walletId, key: 'latest_lelantus_tx_model', value: newTxData); } Future>> fetchAnonymitySets() async { @@ -4383,7 +4351,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { int spendAmount, String address, bool subtractFeeFromAmount) async { // final price = await firoPrice; final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); - final index = DB.instance.get(boxName: walletId, key: 'mintIndex'); + final index = firoGetMintIndex(); final lelantusEntry = await _getLelantusEntry(); final anonymitySets = await fetchAnonymitySets(); final locktime = await getBlockHead(electrumXClient); @@ -4824,32 +4792,24 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get chainHeight async { try { final result = await _electrumXClient.getBlockHeadTip(); - return result["height"] as int; + final height = result["height"] as int; + await updateCachedChainHeight(height); + return height; } catch (e, s) { Logging.instance.log("Exception caught in chainHeight: $e\n$s", level: LogLevel.Error); - return -1; + return storedChainHeight; } } @override - int get storedChainHeight { - final storedHeight = DB.instance - .get(boxName: walletId, key: "storedChainHeight") as int?; - return storedHeight ?? 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; - Balance get balancePrivate => - _balancePrivate ??= getCachedBalanceSecondary(walletId, coin); + Balance get balancePrivate => _balancePrivate ??= getCachedBalanceSecondary(); Balance? _balancePrivate; @override diff --git a/lib/services/mixins/firo_hive.dart b/lib/services/mixins/firo_hive.dart new file mode 100644 index 000000000..43f0dd622 --- /dev/null +++ b/lib/services/mixins/firo_hive.dart @@ -0,0 +1,50 @@ +import 'package:stackwallet/hive/db.dart'; + +mixin FiroHive { + late final String _walletId; + + void initFiroHive(String walletId) { + _walletId = walletId; + } + + // jindex + List? firoGetJIndex() { + return DB.instance.get(boxName: _walletId, key: "jindex") as List?; + } + + Future firoUpdateJIndex(List jIndex) async { + await DB.instance.put( + boxName: _walletId, + key: "jindex", + value: jIndex, + ); + } + + // _lelantus_coins + List? firoGetLelantusCoins() { + return DB.instance.get(boxName: _walletId, key: "_lelantus_coins") + as List?; + } + + Future firoUpdateLelantusCoins(List lelantusCoins) async { + await DB.instance.put( + boxName: _walletId, + key: "_lelantus_coins", + value: lelantusCoins, + ); + } + + // mintIndex + int? firoGetMintIndex() { + return DB.instance.get(boxName: _walletId, key: "mintIndex") + as int?; + } + + Future firoUpdateMintIndex(int mintIndex) async { + await DB.instance.put( + boxName: _walletId, + key: "mintIndex", + value: mintIndex, + ); + } +} From 8c67901c287f784d52ab3f58547a2aa6fae2eec5 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 15:32:25 -0600 Subject: [PATCH 123/192] apply wallet cache mixin to rest of coin wallets and clean up hive code --- .../coins/bitcoin/bitcoin_wallet.dart | 788 ++++++++---------- .../coins/bitcoincash/bitcoincash_wallet.dart | 68 +- .../coins/dogecoin/dogecoin_wallet.dart | 338 ++++---- .../coins/litecoin/litecoin_wallet.dart | 750 ++++++++--------- lib/services/coins/monero/monero_wallet.dart | 63 +- .../coins/namecoin/namecoin_wallet.dart | 749 ++++++++--------- .../coins/particl/particl_wallet.dart | 546 ++++++------ .../coins/wownero/wownero_wallet.dart | 68 +- 8 files changed, 1598 insertions(+), 1772 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 5dae3eb58..3e34891a7 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -12,7 +12,6 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; @@ -146,7 +145,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final _prefs = Prefs.instance; Timer? timer; - late Coin _coin; + late final Coin _coin; late final TransactionNotificationTracker txTracker; @@ -163,22 +162,14 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; @override Coin get coin => _coin; @@ -245,25 +236,18 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get chainHeight async { try { final result = await _electrumXClient.getBlockHeadTip(); - return result["height"] as int; + final height = result["height"] as int; + await updateCachedChainHeight(height); + return height; } catch (e, s) { Logging.instance.log("Exception caught in chainHeight: $e\n$s", level: LogLevel.Error); - return -1; + return storedChainHeight; } } @override - int get storedChainHeight { - final storedHeight = DB.instance - .get(boxName: walletId, key: "storedChainHeight") as int?; - return storedHeight ?? 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); DerivePathType addressType({required String address}) { Uint8List? decodeBase58; @@ -688,10 +672,10 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _updateUTXOs(); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); longMutex = false; } catch (e, s) { @@ -912,11 +896,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { .log("cached height: $storedHeight", level: LogLevel.Info); if (currentHeight != storedHeight) { - if (currentHeight != -1) { - // -1 failed to fetch current height - unawaited(updateStoredChainHeight(newHeight: currentHeight)); - } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); await _checkChangeAddressForTransactions(); @@ -1154,7 +1133,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) != null) { + if (getCachedId() != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -1168,9 +1147,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { rethrow; } await Future.wait([ - DB.instance.put(boxName: walletId, key: "id", value: walletId), - DB.instance - .put(boxName: walletId, key: "isFavorite", value: false), + updateCachedId(walletId), + updateCachedIsFavorite(false), ]); } @@ -1179,7 +1157,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -1242,7 +1220,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { @override String get walletId => _walletId; - late String _walletId; + late final String _walletId; @override String get walletName => _walletName; @@ -1279,6 +1257,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _electrumXClient = client; _cachedElectrumXClient = cachedClient; _secureStore = secureStore; + initCache(walletId, coin); } @override @@ -1810,7 +1789,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1818,48 +1797,9 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; - // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) - // /// and checks for the txid associated with the utxo being blocked and marks it accordingly. - // /// Now also checks for output labeling. - // Future _sortOutputs(List utxos) async { - // final blockedHashArray = - // DB.instance.get(boxName: walletId, key: 'blocked_tx_hashes') - // as List?; - // final List lst = []; - // if (blockedHashArray != null) { - // for (var hash in blockedHashArray) { - // lst.add(hash as String); - // } - // } - // final labels = - // DB.instance.get(boxName: walletId, key: 'labels') as Map? ?? - // {}; - // - // outputsList = []; - // - // for (var i = 0; i < utxos.length; i++) { - // if (labels[utxos[i].txid] != null) { - // utxos[i].txName = labels[utxos[i].txid] as String? ?? ""; - // } else { - // utxos[i].txName = 'Output #$i'; - // } - // - // if (utxos[i].status.confirmed == false) { - // outputsList.add(utxos[i]); - // } else { - // if (lst.contains(utxos[i].txid)) { - // utxos[i].blocked = true; - // outputsList.add(utxos[i]); - // } else if (!lst.contains(utxos[i].txid)) { - // outputsList.add(utxos[i]); - // } - // } - // } - // } - Future getTxCount({required String address}) async { String? scripthash; try { @@ -3075,7 +3015,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // back up data - await _rescanBackup(); + // await _rescanBackup(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3104,7 +3044,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // restore from backup - await _rescanRestore(); + // await _rescanRestore(); longMutex = false; Logging.instance.log("Exception rethrown from fullRescan(): $e\n$s", @@ -3113,345 +3053,345 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - Future _rescanRestore() async { - Logging.instance.log("starting rescan restore", level: LogLevel.Info); - - // restore from backup - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); - final tempReceivingIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); - final tempChangeIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: tempReceivingAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: tempChangeAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: tempReceivingIndexP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH', - value: tempChangeIndexP2PKH); - await DB.instance.delete( - key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); - - // p2Sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); - final tempChangeAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); - final tempReceivingIndexP2SH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); - final tempChangeIndexP2SH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: tempReceivingAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: tempChangeAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: tempReceivingIndexP2SH); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); - await DB.instance.delete( - key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); - final tempChangeIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: tempReceivingAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: tempChangeAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: tempReceivingIndexP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: tempChangeIndexP2WPKH); - await DB.instance.delete( - key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance.delete( - key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - final p2pkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - // P2SH derivations - final p2shReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - final p2shChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - final p2wpkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - await _secureStore.delete( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - // UTXOs - final utxoData = DB.instance - .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); - - Logging.instance.log("rescan restore complete", level: LogLevel.Info); - } - - Future _rescanBackup() async { - Logging.instance.log("starting rescan backup", level: LogLevel.Info); - - // backup current and clear data - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH_BACKUP', - value: tempReceivingAddressesP2PKH); - await DB.instance - .delete(key: 'receivingAddressesP2PKH', boxName: walletId); - - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH_BACKUP', - value: tempChangeAddressesP2PKH); - await DB.instance - .delete(key: 'changeAddressesP2PKH', boxName: walletId); - - final tempReceivingIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH_BACKUP', - value: tempReceivingIndexP2PKH); - await DB.instance - .delete(key: 'receivingIndexP2PKH', boxName: walletId); - - final tempChangeIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH_BACKUP', - value: tempChangeIndexP2PKH); - await DB.instance - .delete(key: 'changeIndexP2PKH', boxName: walletId); - - // p2sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH_BACKUP', - value: tempReceivingAddressesP2SH); - await DB.instance - .delete(key: 'receivingAddressesP2SH', boxName: walletId); - - final tempChangeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH_BACKUP', - value: tempChangeAddressesP2SH); - await DB.instance - .delete(key: 'changeAddressesP2SH', boxName: walletId); - - final tempReceivingIndexP2SH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH_BACKUP', - value: tempReceivingIndexP2SH); - await DB.instance - .delete(key: 'receivingIndexP2SH', boxName: walletId); - - final tempChangeIndexP2SH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2SH_BACKUP', - value: tempChangeIndexP2SH); - await DB.instance - .delete(key: 'changeIndexP2SH', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH_BACKUP', - value: tempReceivingAddressesP2WPKH); - await DB.instance - .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); - - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH_BACKUP', - value: tempChangeAddressesP2WPKH); - await DB.instance - .delete(key: 'changeAddressesP2WPKH', boxName: walletId); - - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH_BACKUP', - value: tempReceivingIndexP2WPKH); - await DB.instance - .delete(key: 'receivingIndexP2WPKH', boxName: walletId); - - final tempChangeIndexP2WPKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH_BACKUP', - value: tempChangeIndexP2WPKH); - await DB.instance - .delete(key: 'changeIndexP2WPKH', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); - final p2pkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH_BACKUP", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); - - // P2SH derivations - final p2shReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2SH"); - final p2shChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2SH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH_BACKUP", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH_BACKUP", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); - final p2wpkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); - - // UTXOs - final utxoData = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model', boxName: walletId); - - Logging.instance.log("rescan backup complete", level: LogLevel.Info); - } + // Future _rescanRestore() async { + // Logging.instance.log("starting rescan restore", level: LogLevel.Info); + // + // // restore from backup + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); + // final tempReceivingIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); + // final tempChangeIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH', + // value: tempReceivingAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH', + // value: tempChangeAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH', + // value: tempReceivingIndexP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH', + // value: tempChangeIndexP2PKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); + // + // // p2Sh + // final tempReceivingAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); + // final tempChangeAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); + // final tempReceivingIndexP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); + // final tempChangeIndexP2SH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2SH', + // value: tempReceivingAddressesP2SH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2SH', + // value: tempChangeAddressesP2SH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2SH', + // value: tempReceivingIndexP2SH); + // await DB.instance.put( + // boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); + // await DB.instance.delete( + // key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); + // final tempChangeIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH', + // value: tempChangeAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH', + // value: tempReceivingIndexP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH', + // value: tempChangeIndexP2WPKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance.delete( + // key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // final p2pkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // // P2SH derivations + // final p2shReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2SH_BACKUP"); + // final p2shChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2SH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2SH", + // value: p2shReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2SH", + // value: p2shChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH_BACKUP"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // final p2wpkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // await _secureStore.delete( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // // UTXOs + // final utxoData = DB.instance + // .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); + // + // Logging.instance.log("rescan restore complete", level: LogLevel.Info); + // } + // + // Future _rescanBackup() async { + // Logging.instance.log("starting rescan backup", level: LogLevel.Info); + // + // // backup current and clear data + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH_BACKUP', + // value: tempReceivingAddressesP2PKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2PKH', boxName: walletId); + // + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH_BACKUP', + // value: tempChangeAddressesP2PKH); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH', boxName: walletId); + // + // final tempReceivingIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH_BACKUP', + // value: tempReceivingIndexP2PKH); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH', boxName: walletId); + // + // final tempChangeIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH_BACKUP', + // value: tempChangeIndexP2PKH); + // await DB.instance + // .delete(key: 'changeIndexP2PKH', boxName: walletId); + // + // // p2sh + // final tempReceivingAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2SH_BACKUP', + // value: tempReceivingAddressesP2SH); + // await DB.instance + // .delete(key: 'receivingAddressesP2SH', boxName: walletId); + // + // final tempChangeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2SH_BACKUP', + // value: tempChangeAddressesP2SH); + // await DB.instance + // .delete(key: 'changeAddressesP2SH', boxName: walletId); + // + // final tempReceivingIndexP2SH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2SH_BACKUP', + // value: tempReceivingIndexP2SH); + // await DB.instance + // .delete(key: 'receivingIndexP2SH', boxName: walletId); + // + // final tempChangeIndexP2SH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2SH_BACKUP', + // value: tempChangeIndexP2SH); + // await DB.instance + // .delete(key: 'changeIndexP2SH', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH_BACKUP', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); + // + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH_BACKUP', + // value: tempChangeAddressesP2WPKH); + // await DB.instance + // .delete(key: 'changeAddressesP2WPKH', boxName: walletId); + // + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH_BACKUP', + // value: tempReceivingIndexP2WPKH); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH', boxName: walletId); + // + // final tempChangeIndexP2WPKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH_BACKUP', + // value: tempChangeIndexP2WPKH); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); + // final p2pkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + // + // // P2SH derivations + // final p2shReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2SH"); + // final p2shChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2SH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2SH_BACKUP", + // value: p2shReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2SH_BACKUP", + // value: p2shChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); + // final p2wpkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + // + // // UTXOs + // final utxoData = + // DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model', boxName: walletId); + // + // Logging.instance.log("rescan backup complete", level: LogLevel.Info); + // } bool isActive = false; diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index dc0f36682..65d6190ac 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -13,7 +13,6 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/address/address.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; @@ -133,7 +132,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final _prefs = Prefs.instance; Timer? timer; - late Coin _coin; + late final Coin _coin; late final TransactionNotificationTracker txTracker; @@ -213,25 +212,18 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get chainHeight async { try { final result = await _electrumXClient.getBlockHeadTip(); - return result["height"] as int; + final height = result["height"] as int; + await updateCachedChainHeight(height); + return height; } catch (e, s) { Logging.instance.log("Exception caught in chainHeight: $e\n$s", level: LogLevel.Error); - return -1; + return storedChainHeight; } } @override - int get storedChainHeight { - final storedHeight = DB.instance - .get(boxName: walletId, key: DBKeys.storedChainHeight) as int?; - return storedHeight ?? 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: DBKeys.storedChainHeight, value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); DerivePathType addressType({required String address}) { Uint8List? decodeBase58; @@ -621,10 +613,10 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { await _updateUTXOs(); - await DB.instance - .put(boxName: walletId, key: DBKeys.id, value: _walletId); - await DB.instance.put( - boxName: walletId, key: DBKeys.isFavorite, value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); longMutex = false; } catch (e, s) { @@ -853,11 +845,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { .log("cached height: $storedHeight", level: LogLevel.Info); if (currentHeight != storedHeight) { - if (currentHeight != -1) { - // -1 failed to fetch current height - await updateStoredChainHeight(newHeight: currentHeight); - } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); await _checkChangeAddressForTransactions(); @@ -1075,7 +1062,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: DBKeys.id)) != null) { + if (getCachedId() != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -1088,10 +1075,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { rethrow; } await Future.wait([ - DB.instance - .put(boxName: walletId, key: DBKeys.id, value: _walletId), - DB.instance.put( - boxName: walletId, key: DBKeys.isFavorite, value: false), + updateCachedId(walletId), + updateCachedIsFavorite(false), ]); } @@ -1100,7 +1085,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: DBKeys.id)) == null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -1190,7 +1175,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { @override String get walletId => _walletId; - late String _walletId; + late final String _walletId; @override String get walletName => _walletName; @@ -1226,6 +1211,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { _electrumXClient = client; _cachedElectrumXClient = cachedClient; _secureStore = secureStore; + initCache(walletId, coin); } @override @@ -1675,7 +1661,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1683,7 +1669,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; Future getTxCount({required String address}) async { @@ -2825,22 +2811,14 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: DBKeys.isFavorite, value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: DBKeys.isFavorite) - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; @override bool get isRefreshing => refreshMutex; diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 4a787bd7f..a1813f465 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -13,7 +13,6 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; @@ -131,7 +130,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final _prefs = Prefs.instance; Timer? timer; - late Coin _coin; + late final Coin _coin; late final TransactionNotificationTracker txTracker; @@ -212,25 +211,18 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get chainHeight async { try { final result = await _electrumXClient.getBlockHeadTip(); - return result["height"] as int; + final height = result["height"] as int; + await updateCachedChainHeight(height); + return height; } catch (e, s) { Logging.instance.log("Exception caught in chainHeight: $e\n$s", level: LogLevel.Error); - return -1; + return storedChainHeight; } } @override - int get storedChainHeight { - final storedHeight = DB.instance - .get(boxName: walletId, key: "storedChainHeight") as int?; - return storedHeight ?? 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); DerivePathType addressType({required String address}) { Uint8List? decodeBase58; @@ -535,10 +527,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _updateUTXOs(); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); longMutex = false; } catch (e, s) { @@ -758,11 +750,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { .log("cached height: $storedHeight", level: LogLevel.Info); if (currentHeight != storedHeight) { - if (currentHeight != -1) { - // -1 failed to fetch current height - unawaited(updateStoredChainHeight(newHeight: currentHeight)); - } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); await checkChangeAddressForTransactions(); @@ -980,7 +967,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) != null) { + if (getCachedId() != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -992,10 +979,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { level: LogLevel.Fatal); rethrow; } + await Future.wait([ - DB.instance.put(boxName: walletId, key: "id", value: _walletId), - DB.instance - .put(boxName: walletId, key: "isFavorite", value: false), + updateCachedId(walletId), + updateCachedIsFavorite(false), ]); } @@ -1004,7 +991,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -1067,7 +1054,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { @override String get walletId => _walletId; - late String _walletId; + late final String _walletId; @override String get walletName => _walletName; @@ -1103,6 +1090,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _electrumXClient = client; _cachedElectrumXClient = cachedClient; _secureStore = secureStore; + initCache(walletId, coin); } @override @@ -1552,7 +1540,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1560,7 +1548,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) @@ -2436,7 +2424,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // back up data - await _rescanBackup(); + // await _rescanBackup(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2465,7 +2453,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // restore from backup - await _rescanRestore(); + // await _rescanRestore(); longMutex = false; Logging.instance.log("Exception rethrown from fullRescan(): $e\n$s", @@ -2474,158 +2462,150 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - Future _rescanRestore() async { - Logging.instance.log("starting rescan restore", level: LogLevel.Info); - - // restore from backup - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); - final tempReceivingIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); - final tempChangeIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: tempReceivingAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: tempChangeAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: tempReceivingIndexP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH', - value: tempChangeIndexP2PKH); - await DB.instance.delete( - key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - final p2pkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - // UTXOs - final utxoData = DB.instance - .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); - - Logging.instance.log("rescan restore complete", level: LogLevel.Info); - } - - Future _rescanBackup() async { - Logging.instance.log("starting rescan backup", level: LogLevel.Info); - - // backup current and clear data - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH_BACKUP', - value: tempReceivingAddressesP2PKH); - await DB.instance - .delete(key: 'receivingAddressesP2PKH', boxName: walletId); - - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH_BACKUP', - value: tempChangeAddressesP2PKH); - await DB.instance - .delete(key: 'changeAddressesP2PKH', boxName: walletId); - - final tempReceivingIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH_BACKUP', - value: tempReceivingIndexP2PKH); - await DB.instance - .delete(key: 'receivingIndexP2PKH', boxName: walletId); - - final tempChangeIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH_BACKUP', - value: tempChangeIndexP2PKH); - await DB.instance - .delete(key: 'changeIndexP2PKH', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); - final p2pkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH_BACKUP", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); - - // UTXOs - final utxoData = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model', boxName: walletId); - - Logging.instance.log("rescan backup complete", level: LogLevel.Info); - } + // Future _rescanRestore() async { + // Logging.instance.log("starting rescan restore", level: LogLevel.Info); + // + // // restore from backup + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); + // final tempReceivingIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); + // final tempChangeIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH', + // value: tempReceivingAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH', + // value: tempChangeAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH', + // value: tempReceivingIndexP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH', + // value: tempChangeIndexP2PKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // final p2pkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // // UTXOs + // final utxoData = DB.instance + // .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); + // + // Logging.instance.log("rescan restore complete", level: LogLevel.Info); + // } + // + // Future _rescanBackup() async { + // Logging.instance.log("starting rescan backup", level: LogLevel.Info); + // + // // backup current and clear data + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH_BACKUP', + // value: tempReceivingAddressesP2PKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2PKH', boxName: walletId); + // + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH_BACKUP', + // value: tempChangeAddressesP2PKH); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH', boxName: walletId); + // + // final tempReceivingIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH_BACKUP', + // value: tempReceivingIndexP2PKH); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH', boxName: walletId); + // + // final tempChangeIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH_BACKUP', + // value: tempChangeIndexP2PKH); + // await DB.instance + // .delete(key: 'changeIndexP2PKH', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); + // final p2pkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + // + // // UTXOs + // final utxoData = + // DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model', boxName: walletId); + // + // Logging.instance.log("rescan backup complete", level: LogLevel.Info); + // } @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; @override bool get isRefreshing => refreshMutex; diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index a19ea6eed..ae3847975 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -13,7 +13,6 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; @@ -145,7 +144,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final _prefs = Prefs.instance; Timer? timer; - late Coin _coin; + late final Coin _coin; late final TransactionNotificationTracker txTracker; @@ -162,22 +161,14 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; @override Coin get coin => _coin; @@ -244,25 +235,18 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get chainHeight async { try { final result = await _electrumXClient.getBlockHeadTip(); - return result["height"] as int; + final height = result["height"] as int; + await updateCachedChainHeight(height); + return height; } catch (e, s) { Logging.instance.log("Exception caught in chainHeight: $e\n$s", level: LogLevel.Error); - return -1; + return storedChainHeight; } } @override - int get storedChainHeight { - final storedHeight = DB.instance - .get(boxName: walletId, key: "storedChainHeight") as int?; - return storedHeight ?? 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); DerivePathType addressType({required String address}) { Uint8List? decodeBase58; @@ -705,10 +689,10 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _updateUTXOs(); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); longMutex = false; } catch (e, s) { @@ -929,11 +913,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { .log("cached height: $storedHeight", level: LogLevel.Info); if (currentHeight != storedHeight) { - if (currentHeight != -1) { - // -1 failed to fetch current height - unawaited(updateStoredChainHeight(newHeight: currentHeight)); - } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); await _checkChangeAddressForTransactions(); @@ -1171,7 +1150,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) != null) { + if (getCachedId() != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -1184,10 +1163,10 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { level: LogLevel.Fatal); rethrow; } + await Future.wait([ - DB.instance.put(boxName: walletId, key: "id", value: walletId), - DB.instance - .put(boxName: walletId, key: "isFavorite", value: false), + updateCachedId(walletId), + updateCachedIsFavorite(false), ]); } @@ -1196,7 +1175,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -1258,7 +1237,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { @override String get walletId => _walletId; - late String _walletId; + late final String _walletId; @override String get walletName => _walletName; @@ -1294,6 +1273,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _electrumXClient = client; _cachedElectrumXClient = cachedClient; _secureStore = secureStore; + initCache(walletId, coin); } @override @@ -1796,7 +1776,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1804,7 +1784,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) @@ -3127,7 +3107,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // back up data - await _rescanBackup(); + // await _rescanBackup(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3156,7 +3136,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // restore from backup - await _rescanRestore(); + // await _rescanRestore(); longMutex = false; Logging.instance.log("Exception rethrown from fullRescan(): $e\n$s", @@ -3165,345 +3145,345 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - Future _rescanRestore() async { - Logging.instance.log("starting rescan restore", level: LogLevel.Info); - - // restore from backup - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); - final tempReceivingIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); - final tempChangeIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: tempReceivingAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: tempChangeAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: tempReceivingIndexP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH', - value: tempChangeIndexP2PKH); - await DB.instance.delete( - key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); - - // p2Sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); - final tempChangeAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); - final tempReceivingIndexP2SH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); - final tempChangeIndexP2SH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: tempReceivingAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: tempChangeAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: tempReceivingIndexP2SH); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); - await DB.instance.delete( - key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); - final tempChangeIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: tempReceivingAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: tempChangeAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: tempReceivingIndexP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: tempChangeIndexP2WPKH); - await DB.instance.delete( - key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance.delete( - key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - final p2pkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - // P2SH derivations - final p2shReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - final p2shChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - final p2wpkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - await _secureStore.delete( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - // UTXOs - final utxoData = DB.instance - .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); - - Logging.instance.log("rescan restore complete", level: LogLevel.Info); - } - - Future _rescanBackup() async { - Logging.instance.log("starting rescan backup", level: LogLevel.Info); - - // backup current and clear data - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH_BACKUP', - value: tempReceivingAddressesP2PKH); - await DB.instance - .delete(key: 'receivingAddressesP2PKH', boxName: walletId); - - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH_BACKUP', - value: tempChangeAddressesP2PKH); - await DB.instance - .delete(key: 'changeAddressesP2PKH', boxName: walletId); - - final tempReceivingIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH_BACKUP', - value: tempReceivingIndexP2PKH); - await DB.instance - .delete(key: 'receivingIndexP2PKH', boxName: walletId); - - final tempChangeIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH_BACKUP', - value: tempChangeIndexP2PKH); - await DB.instance - .delete(key: 'changeIndexP2PKH', boxName: walletId); - - // p2sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH_BACKUP', - value: tempReceivingAddressesP2SH); - await DB.instance - .delete(key: 'receivingAddressesP2SH', boxName: walletId); - - final tempChangeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH_BACKUP', - value: tempChangeAddressesP2SH); - await DB.instance - .delete(key: 'changeAddressesP2SH', boxName: walletId); - - final tempReceivingIndexP2SH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH_BACKUP', - value: tempReceivingIndexP2SH); - await DB.instance - .delete(key: 'receivingIndexP2SH', boxName: walletId); - - final tempChangeIndexP2SH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2SH_BACKUP', - value: tempChangeIndexP2SH); - await DB.instance - .delete(key: 'changeIndexP2SH', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH_BACKUP', - value: tempReceivingAddressesP2WPKH); - await DB.instance - .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); - - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH_BACKUP', - value: tempChangeAddressesP2WPKH); - await DB.instance - .delete(key: 'changeAddressesP2WPKH', boxName: walletId); - - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH_BACKUP', - value: tempReceivingIndexP2WPKH); - await DB.instance - .delete(key: 'receivingIndexP2WPKH', boxName: walletId); - - final tempChangeIndexP2WPKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH_BACKUP', - value: tempChangeIndexP2WPKH); - await DB.instance - .delete(key: 'changeIndexP2WPKH', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); - final p2pkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH_BACKUP", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); - - // P2SH derivations - final p2shReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2SH"); - final p2shChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2SH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH_BACKUP", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH_BACKUP", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); - final p2wpkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); - - // UTXOs - final utxoData = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model', boxName: walletId); - - Logging.instance.log("rescan backup complete", level: LogLevel.Info); - } + // Future _rescanRestore() async { + // Logging.instance.log("starting rescan restore", level: LogLevel.Info); + // + // // restore from backup + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); + // final tempReceivingIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); + // final tempChangeIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH', + // value: tempReceivingAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH', + // value: tempChangeAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH', + // value: tempReceivingIndexP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH', + // value: tempChangeIndexP2PKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); + // + // // p2Sh + // final tempReceivingAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); + // final tempChangeAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); + // final tempReceivingIndexP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); + // final tempChangeIndexP2SH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2SH', + // value: tempReceivingAddressesP2SH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2SH', + // value: tempChangeAddressesP2SH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2SH', + // value: tempReceivingIndexP2SH); + // await DB.instance.put( + // boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); + // await DB.instance.delete( + // key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); + // final tempChangeIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH', + // value: tempChangeAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH', + // value: tempReceivingIndexP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH', + // value: tempChangeIndexP2WPKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance.delete( + // key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // final p2pkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // // P2SH derivations + // final p2shReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2SH_BACKUP"); + // final p2shChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2SH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2SH", + // value: p2shReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2SH", + // value: p2shChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH_BACKUP"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // final p2wpkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // await _secureStore.delete( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // // UTXOs + // final utxoData = DB.instance + // .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); + // + // Logging.instance.log("rescan restore complete", level: LogLevel.Info); + // } + // + // Future _rescanBackup() async { + // Logging.instance.log("starting rescan backup", level: LogLevel.Info); + // + // // backup current and clear data + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH_BACKUP', + // value: tempReceivingAddressesP2PKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2PKH', boxName: walletId); + // + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH_BACKUP', + // value: tempChangeAddressesP2PKH); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH', boxName: walletId); + // + // final tempReceivingIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH_BACKUP', + // value: tempReceivingIndexP2PKH); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH', boxName: walletId); + // + // final tempChangeIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH_BACKUP', + // value: tempChangeIndexP2PKH); + // await DB.instance + // .delete(key: 'changeIndexP2PKH', boxName: walletId); + // + // // p2sh + // final tempReceivingAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2SH_BACKUP', + // value: tempReceivingAddressesP2SH); + // await DB.instance + // .delete(key: 'receivingAddressesP2SH', boxName: walletId); + // + // final tempChangeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2SH_BACKUP', + // value: tempChangeAddressesP2SH); + // await DB.instance + // .delete(key: 'changeAddressesP2SH', boxName: walletId); + // + // final tempReceivingIndexP2SH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2SH_BACKUP', + // value: tempReceivingIndexP2SH); + // await DB.instance + // .delete(key: 'receivingIndexP2SH', boxName: walletId); + // + // final tempChangeIndexP2SH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2SH_BACKUP', + // value: tempChangeIndexP2SH); + // await DB.instance + // .delete(key: 'changeIndexP2SH', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH_BACKUP', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); + // + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH_BACKUP', + // value: tempChangeAddressesP2WPKH); + // await DB.instance + // .delete(key: 'changeAddressesP2WPKH', boxName: walletId); + // + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH_BACKUP', + // value: tempReceivingIndexP2WPKH); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH', boxName: walletId); + // + // final tempChangeIndexP2WPKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH_BACKUP', + // value: tempChangeIndexP2WPKH); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); + // final p2pkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + // + // // P2SH derivations + // final p2shReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2SH"); + // final p2shChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2SH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2SH_BACKUP", + // value: p2shReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2SH_BACKUP", + // value: p2shChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); + // final p2wpkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + // + // // UTXOs + // final utxoData = + // DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model', boxName: walletId); + // + // Logging.instance.log("rescan backup complete", level: LogLevel.Info); + // } bool isActive = false; diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index a606e7f6a..3d93fcc5d 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -50,12 +50,13 @@ import 'package:stackwallet/utilities/stack_file_system.dart'; const int MINIMUM_CONFIRMATIONS = 10; class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { - final String _walletId; - final Coin _coin; - final SecureStorageInterface _secureStorage; - final Prefs _prefs; + late final String _walletId; + late final Coin _coin; + late final SecureStorageInterface _secureStorage; + late final Prefs _prefs; + + late String _walletName; - String _walletName; bool _shouldAutoSync = false; bool _isConnected = false; bool _hasCalledExit = false; @@ -81,31 +82,26 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { required Coin coin, required SecureStorageInterface secureStorage, Prefs? prefs, - }) : _walletId = walletId, - _walletName = walletName, - _coin = coin, - _secureStorage = secureStorage, - _prefs = prefs ?? Prefs.instance; - - @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } + }) { + _walletId = walletId; + _walletName = walletName; + _coin = coin; + _secureStorage = secureStorage; + _prefs = prefs ?? Prefs.instance; + initCache(walletId, coin); } @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } + @override + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; + @override bool get shouldAutoSync => _shouldAutoSync; @@ -260,7 +256,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { level: LogLevel.Info, ); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -382,10 +378,10 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { node: Node(uri: "$host:${node.port}", type: WalletType.monero)); await walletBase!.startSync(); await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); + .put(boxName: walletId, key: DBKeys.id, value: _walletId); await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + .put(boxName: walletId, key: DBKeys.isFavorite, value: false); // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); @@ -593,11 +589,10 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // walletBase!.onNewTransaction = onNewTransaction; // walletBase!.syncStatusChanged = syncStatusChanged; - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); } catch (e, s) { debugPrint(e.toString()); debugPrint(s.toString()); @@ -734,7 +729,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: 0, pendingSpendable: total - available, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } Future get _availableBalance async { @@ -1215,7 +1210,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int get storedChainHeight => throw UnimplementedError(); @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; @override diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 94bcc2ff6..37bc57d87 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -13,7 +13,6 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; @@ -142,7 +141,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final _prefs = Prefs.instance; Timer? timer; - late Coin _coin; + late final Coin _coin; late final TransactionNotificationTracker txTracker; @@ -157,22 +156,14 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; @override Coin get coin => _coin; @@ -239,25 +230,18 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get chainHeight async { try { final result = await _electrumXClient.getBlockHeadTip(); - return result["height"] as int; + final height = result["height"] as int; + await updateCachedChainHeight(height); + return height; } catch (e, s) { Logging.instance.log("Exception caught in chainHeight: $e\n$s", level: LogLevel.Error); - return -1; + return storedChainHeight; } } @override - int get storedChainHeight { - final storedHeight = DB.instance - .get(boxName: walletId, key: "storedChainHeight") as int?; - return storedHeight ?? 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); DerivePathType addressType({required String address}) { Uint8List? decodeBase58; @@ -695,10 +679,10 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _updateUTXOs(); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); longMutex = false; } catch (e, s) { @@ -919,11 +903,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { .log("cached height: $storedHeight", level: LogLevel.Info); if (currentHeight != storedHeight) { - if (currentHeight != -1) { - // -1 failed to fetch current height - unawaited(updateStoredChainHeight(newHeight: currentHeight)); - } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); await _checkChangeAddressForTransactions(); @@ -1161,7 +1140,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) != null) { + if (getCachedId() != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -1175,9 +1154,8 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { rethrow; } await Future.wait([ - DB.instance.put(boxName: walletId, key: "id", value: walletId), - DB.instance - .put(boxName: walletId, key: "isFavorite", value: false), + updateCachedId(walletId), + updateCachedIsFavorite(false), ]); } @@ -1186,7 +1164,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -1248,7 +1226,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { @override String get walletId => _walletId; - late String _walletId; + late final String _walletId; @override String get walletName => _walletName; @@ -1284,6 +1262,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _electrumXClient = client; _cachedElectrumXClient = cachedClient; _secureStore = secureStore; + initCache(walletId, coin); } @override @@ -1776,7 +1755,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1784,7 +1763,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) @@ -3118,7 +3097,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // back up data - await _rescanBackup(); + // await _rescanBackup(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3147,7 +3126,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // restore from backup - await _rescanRestore(); + // await _rescanRestore(); longMutex = false; Logging.instance.log("Exception rethrown from fullRescan(): $e\n$s", @@ -3156,345 +3135,345 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - Future _rescanRestore() async { - Logging.instance.log("starting rescan restore", level: LogLevel.Info); - - // restore from backup - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); - final tempReceivingIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); - final tempChangeIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: tempReceivingAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: tempChangeAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: tempReceivingIndexP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH', - value: tempChangeIndexP2PKH); - await DB.instance.delete( - key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); - - // p2Sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); - final tempChangeAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); - final tempReceivingIndexP2SH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); - final tempChangeIndexP2SH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH', - value: tempReceivingAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH', - value: tempChangeAddressesP2SH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH', - value: tempReceivingIndexP2SH); - await DB.instance.put( - boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); - await DB.instance.delete( - key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); - final tempChangeIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: tempReceivingAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: tempChangeAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: tempReceivingIndexP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: tempChangeIndexP2WPKH); - await DB.instance.delete( - key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance.delete( - key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - final p2pkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - // P2SH derivations - final p2shReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - final p2shChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH_BACKUP"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - final p2wpkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - await _secureStore.delete( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - // UTXOs - final utxoData = DB.instance - .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); - - Logging.instance.log("rescan restore complete", level: LogLevel.Info); - } - - Future _rescanBackup() async { - Logging.instance.log("starting rescan backup", level: LogLevel.Info); - - // backup current and clear data - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH_BACKUP', - value: tempReceivingAddressesP2PKH); - await DB.instance - .delete(key: 'receivingAddressesP2PKH', boxName: walletId); - - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH_BACKUP', - value: tempChangeAddressesP2PKH); - await DB.instance - .delete(key: 'changeAddressesP2PKH', boxName: walletId); - - final tempReceivingIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH_BACKUP', - value: tempReceivingIndexP2PKH); - await DB.instance - .delete(key: 'receivingIndexP2PKH', boxName: walletId); - - final tempChangeIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH_BACKUP', - value: tempChangeIndexP2PKH); - await DB.instance - .delete(key: 'changeIndexP2PKH', boxName: walletId); - - // p2sh - final tempReceivingAddressesP2SH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2SH_BACKUP', - value: tempReceivingAddressesP2SH); - await DB.instance - .delete(key: 'receivingAddressesP2SH', boxName: walletId); - - final tempChangeAddressesP2SH = - DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2SH_BACKUP', - value: tempChangeAddressesP2SH); - await DB.instance - .delete(key: 'changeAddressesP2SH', boxName: walletId); - - final tempReceivingIndexP2SH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2SH_BACKUP', - value: tempReceivingIndexP2SH); - await DB.instance - .delete(key: 'receivingIndexP2SH', boxName: walletId); - - final tempChangeIndexP2SH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2SH_BACKUP', - value: tempChangeIndexP2SH); - await DB.instance - .delete(key: 'changeIndexP2SH', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH_BACKUP', - value: tempReceivingAddressesP2WPKH); - await DB.instance - .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); - - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH_BACKUP', - value: tempChangeAddressesP2WPKH); - await DB.instance - .delete(key: 'changeAddressesP2WPKH', boxName: walletId); - - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH_BACKUP', - value: tempReceivingIndexP2WPKH); - await DB.instance - .delete(key: 'receivingIndexP2WPKH', boxName: walletId); - - final tempChangeIndexP2WPKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH_BACKUP', - value: tempChangeIndexP2WPKH); - await DB.instance - .delete(key: 'changeIndexP2WPKH', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); - final p2pkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH_BACKUP", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); - - // P2SH derivations - final p2shReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2SH"); - final p2shChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2SH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2SH_BACKUP", - value: p2shReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2SH_BACKUP", - value: p2shChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); - final p2wpkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); - - // UTXOs - final utxoData = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model', boxName: walletId); - - Logging.instance.log("rescan backup complete", level: LogLevel.Info); - } + // Future _rescanRestore() async { + // Logging.instance.log("starting rescan restore", level: LogLevel.Info); + // + // // restore from backup + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); + // final tempReceivingIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); + // final tempChangeIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH', + // value: tempReceivingAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH', + // value: tempChangeAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH', + // value: tempReceivingIndexP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH', + // value: tempChangeIndexP2PKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); + // + // // p2Sh + // final tempReceivingAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); + // final tempChangeAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); + // final tempReceivingIndexP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); + // final tempChangeIndexP2SH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2SH', + // value: tempReceivingAddressesP2SH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2SH', + // value: tempChangeAddressesP2SH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2SH', + // value: tempReceivingIndexP2SH); + // await DB.instance.put( + // boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); + // await DB.instance.delete( + // key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); + // final tempChangeIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH', + // value: tempChangeAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH', + // value: tempReceivingIndexP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH', + // value: tempChangeIndexP2WPKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance.delete( + // key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // final p2pkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // // P2SH derivations + // final p2shReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2SH_BACKUP"); + // final p2shChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2SH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2SH", + // value: p2shReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2SH", + // value: p2shChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH_BACKUP"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // final p2wpkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // await _secureStore.delete( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // // UTXOs + // final utxoData = DB.instance + // .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); + // + // Logging.instance.log("rescan restore complete", level: LogLevel.Info); + // } + // + // Future _rescanBackup() async { + // Logging.instance.log("starting rescan backup", level: LogLevel.Info); + // + // // backup current and clear data + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH_BACKUP', + // value: tempReceivingAddressesP2PKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2PKH', boxName: walletId); + // + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH_BACKUP', + // value: tempChangeAddressesP2PKH); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH', boxName: walletId); + // + // final tempReceivingIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH_BACKUP', + // value: tempReceivingIndexP2PKH); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH', boxName: walletId); + // + // final tempChangeIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH_BACKUP', + // value: tempChangeIndexP2PKH); + // await DB.instance + // .delete(key: 'changeIndexP2PKH', boxName: walletId); + // + // // p2sh + // final tempReceivingAddressesP2SH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2SH_BACKUP', + // value: tempReceivingAddressesP2SH); + // await DB.instance + // .delete(key: 'receivingAddressesP2SH', boxName: walletId); + // + // final tempChangeAddressesP2SH = + // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2SH_BACKUP', + // value: tempChangeAddressesP2SH); + // await DB.instance + // .delete(key: 'changeAddressesP2SH', boxName: walletId); + // + // final tempReceivingIndexP2SH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2SH_BACKUP', + // value: tempReceivingIndexP2SH); + // await DB.instance + // .delete(key: 'receivingIndexP2SH', boxName: walletId); + // + // final tempChangeIndexP2SH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2SH_BACKUP', + // value: tempChangeIndexP2SH); + // await DB.instance + // .delete(key: 'changeIndexP2SH', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH_BACKUP', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); + // + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH_BACKUP', + // value: tempChangeAddressesP2WPKH); + // await DB.instance + // .delete(key: 'changeAddressesP2WPKH', boxName: walletId); + // + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH_BACKUP', + // value: tempReceivingIndexP2WPKH); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH', boxName: walletId); + // + // final tempChangeIndexP2WPKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH_BACKUP', + // value: tempChangeIndexP2WPKH); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); + // final p2pkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + // + // // P2SH derivations + // final p2shReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2SH"); + // final p2shChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2SH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2SH_BACKUP", + // value: p2shReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2SH_BACKUP", + // value: p2shChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); + // final p2wpkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + // + // // UTXOs + // final utxoData = + // DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model', boxName: walletId); + // + // Logging.instance.log("rescan backup complete", level: LogLevel.Info); + // } bool isActive = false; diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index c315e7c12..f7b941fa1 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -13,7 +13,6 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/paymint/fee_object_model.dart'; @@ -138,7 +137,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { final _prefs = Prefs.instance; Timer? timer; - late Coin _coin; + late final Coin _coin; late final TransactionNotificationTracker txTracker; @@ -153,21 +152,14 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance - .log("isFavorite fetch failed: $e\n$s", level: LogLevel.Error); - rethrow; - } - } + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; @override Coin get coin => _coin; @@ -234,25 +226,18 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get chainHeight async { try { final result = await _electrumXClient.getBlockHeadTip(); - return result["height"] as int; + final height = result["height"] as int; + await updateCachedChainHeight(height); + return height; } catch (e, s) { Logging.instance.log("Exception caught in chainHeight: $e\n$s", level: LogLevel.Error); - return -1; + return storedChainHeight; } } @override - int get storedChainHeight { - final storedHeight = DB.instance - .get(boxName: walletId, key: "storedChainHeight") as int?; - return storedHeight ?? 0; - } - - Future updateStoredChainHeight({required int newHeight}) async { - await DB.instance.put( - boxName: walletId, key: "storedChainHeight", value: newHeight); - } + int get storedChainHeight => getCachedChainHeight(); DerivePathType addressType({required String address}) { Uint8List? decodeBase58; @@ -627,10 +612,10 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { await _updateUTXOs(); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); longMutex = false; } catch (e, s) { @@ -851,11 +836,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { .log("cached height: $storedHeight", level: LogLevel.Info); if (currentHeight != storedHeight) { - if (currentHeight != -1) { - // -1 failed to fetch current height - unawaited(updateStoredChainHeight(newHeight: currentHeight)); - } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); await _checkChangeAddressForTransactions(); @@ -1090,7 +1070,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) != null) { + if (getCachedId() != null) { throw Exception( "Attempted to initialize a new wallet using an existing wallet ID!"); } @@ -1104,9 +1084,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { rethrow; } await Future.wait([ - DB.instance.put(boxName: walletId, key: "id", value: walletId), - DB.instance - .put(boxName: walletId, key: "isFavorite", value: false), + updateCachedId(walletId), + updateCachedIsFavorite(false), ]); } @@ -1115,7 +1094,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance.log("Opening existing ${coin.prettyName} wallet.", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { throw Exception( "Attempted to initialize an existing wallet using an unknown wallet ID!"); } @@ -1178,7 +1157,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { @override String get walletId => _walletId; - late String _walletId; + late final String _walletId; @override String get walletName => _walletName; @@ -1214,6 +1193,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { _electrumXClient = client; _cachedElectrumXClient = cachedClient; _secureStore = secureStore; + initCache(walletId, coin); } @override @@ -1665,7 +1645,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: satoshiBalanceBlocked, pendingSpendable: satoshiBalancePending, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } catch (e, s) { Logging.instance .log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); @@ -1673,7 +1653,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; // /// Takes in a list of UtxoObjects and adds a name (dependent on object index within list) @@ -2989,7 +2969,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // back up data - await _rescanBackup(); + // await _rescanBackup(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3018,7 +2998,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // restore from backup - await _rescanRestore(); + // await _rescanRestore(); longMutex = false; Logging.instance.log("Exception rethrown from fullRescan(): $e\n$s", @@ -3027,244 +3007,244 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - Future _rescanRestore() async { - Logging.instance.log("starting rescan restore", level: LogLevel.Info); - - // restore from backup - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); - final tempReceivingIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); - final tempChangeIndexP2PKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH', - value: tempReceivingAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH', - value: tempChangeAddressesP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH', - value: tempReceivingIndexP2PKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH', - value: tempChangeIndexP2PKH); - await DB.instance.delete( - key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance.get( - boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); - final tempChangeIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH', - value: tempReceivingAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH', - value: tempChangeAddressesP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH', - value: tempReceivingIndexP2WPKH); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH', - value: tempChangeIndexP2WPKH); - await DB.instance.delete( - key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance.delete( - key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); - await DB.instance - .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - final p2pkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = await _secureStore.read( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - final p2wpkhChangeDerivationsString = await _secureStore.read( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); - await _secureStore.delete( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); - - // UTXOs - final utxoData = DB.instance - .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); - - Logging.instance.log("rescan restore complete", level: LogLevel.Info); - } - - Future _rescanBackup() async { - Logging.instance.log("starting rescan backup", level: LogLevel.Info); - - // backup current and clear data - // p2pkh - final tempReceivingAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2PKH_BACKUP', - value: tempReceivingAddressesP2PKH); - await DB.instance - .delete(key: 'receivingAddressesP2PKH', boxName: walletId); - - final tempChangeAddressesP2PKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2PKH_BACKUP', - value: tempChangeAddressesP2PKH); - await DB.instance - .delete(key: 'changeAddressesP2PKH', boxName: walletId); - - final tempReceivingIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2PKH_BACKUP', - value: tempReceivingIndexP2PKH); - await DB.instance - .delete(key: 'receivingIndexP2PKH', boxName: walletId); - - final tempChangeIndexP2PKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2PKH_BACKUP', - value: tempChangeIndexP2PKH); - await DB.instance - .delete(key: 'changeIndexP2PKH', boxName: walletId); - - // p2wpkh - final tempReceivingAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingAddressesP2WPKH_BACKUP', - value: tempReceivingAddressesP2WPKH); - await DB.instance - .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); - - final tempChangeAddressesP2WPKH = DB.instance - .get(boxName: walletId, key: 'changeAddressesP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeAddressesP2WPKH_BACKUP', - value: tempChangeAddressesP2WPKH); - await DB.instance - .delete(key: 'changeAddressesP2WPKH', boxName: walletId); - - final tempReceivingIndexP2WPKH = DB.instance - .get(boxName: walletId, key: 'receivingIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'receivingIndexP2WPKH_BACKUP', - value: tempReceivingIndexP2WPKH); - await DB.instance - .delete(key: 'receivingIndexP2WPKH', boxName: walletId); - - final tempChangeIndexP2WPKH = - DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); - await DB.instance.put( - boxName: walletId, - key: 'changeIndexP2WPKH_BACKUP', - value: tempChangeIndexP2WPKH); - await DB.instance - .delete(key: 'changeIndexP2WPKH', boxName: walletId); - - // P2PKH derivations - final p2pkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); - final p2pkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2PKH_BACKUP", - value: p2pkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2PKH_BACKUP", - value: p2pkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); - - // P2WPKH derivations - final p2wpkhReceiveDerivationsString = - await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); - final p2wpkhChangeDerivationsString = - await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); - - await _secureStore.write( - key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", - value: p2wpkhReceiveDerivationsString); - await _secureStore.write( - key: "${walletId}_changeDerivationsP2WPKH_BACKUP", - value: p2wpkhChangeDerivationsString); - - await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); - await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); - - // UTXOs - final utxoData = - DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - await DB.instance.put( - boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); - await DB.instance - .delete(key: 'latest_utxo_model', boxName: walletId); - - Logging.instance.log("rescan backup complete", level: LogLevel.Info); - } + // Future _rescanRestore() async { + // Logging.instance.log("starting rescan restore", level: LogLevel.Info); + // + // // restore from backup + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); + // final tempReceivingIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); + // final tempChangeIndexP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH', + // value: tempReceivingAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH', + // value: tempChangeAddressesP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH', + // value: tempReceivingIndexP2PKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH', + // value: tempChangeIndexP2PKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance.get( + // boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); + // final tempChangeIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH', + // value: tempChangeAddressesP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH', + // value: tempReceivingIndexP2WPKH); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH', + // value: tempChangeIndexP2WPKH); + // await DB.instance.delete( + // key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance.delete( + // key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // final p2pkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH_BACKUP"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = await _secureStore.read( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // final p2wpkhChangeDerivationsString = await _secureStore.read( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP"); + // await _secureStore.delete( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); + // + // // UTXOs + // final utxoData = DB.instance + // .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); + // + // Logging.instance.log("rescan restore complete", level: LogLevel.Info); + // } + // + // Future _rescanBackup() async { + // Logging.instance.log("starting rescan backup", level: LogLevel.Info); + // + // // backup current and clear data + // // p2pkh + // final tempReceivingAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2PKH_BACKUP', + // value: tempReceivingAddressesP2PKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2PKH', boxName: walletId); + // + // final tempChangeAddressesP2PKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2PKH_BACKUP', + // value: tempChangeAddressesP2PKH); + // await DB.instance + // .delete(key: 'changeAddressesP2PKH', boxName: walletId); + // + // final tempReceivingIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2PKH_BACKUP', + // value: tempReceivingIndexP2PKH); + // await DB.instance + // .delete(key: 'receivingIndexP2PKH', boxName: walletId); + // + // final tempChangeIndexP2PKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2PKH_BACKUP', + // value: tempChangeIndexP2PKH); + // await DB.instance + // .delete(key: 'changeIndexP2PKH', boxName: walletId); + // + // // p2wpkh + // final tempReceivingAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingAddressesP2WPKH_BACKUP', + // value: tempReceivingAddressesP2WPKH); + // await DB.instance + // .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); + // + // final tempChangeAddressesP2WPKH = DB.instance + // .get(boxName: walletId, key: 'changeAddressesP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeAddressesP2WPKH_BACKUP', + // value: tempChangeAddressesP2WPKH); + // await DB.instance + // .delete(key: 'changeAddressesP2WPKH', boxName: walletId); + // + // final tempReceivingIndexP2WPKH = DB.instance + // .get(boxName: walletId, key: 'receivingIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'receivingIndexP2WPKH_BACKUP', + // value: tempReceivingIndexP2WPKH); + // await DB.instance + // .delete(key: 'receivingIndexP2WPKH', boxName: walletId); + // + // final tempChangeIndexP2WPKH = + // DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); + // await DB.instance.put( + // boxName: walletId, + // key: 'changeIndexP2WPKH_BACKUP', + // value: tempChangeIndexP2WPKH); + // await DB.instance + // .delete(key: 'changeIndexP2WPKH', boxName: walletId); + // + // // P2PKH derivations + // final p2pkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); + // final p2pkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2PKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2PKH_BACKUP", + // value: p2pkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2PKH_BACKUP", + // value: p2pkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + // + // // P2WPKH derivations + // final p2wpkhReceiveDerivationsString = + // await _secureStore.read(key: "${walletId}_receiveDerivationsP2WPKH"); + // final p2wpkhChangeDerivationsString = + // await _secureStore.read(key: "${walletId}_changeDerivationsP2WPKH"); + // + // await _secureStore.write( + // key: "${walletId}_receiveDerivationsP2WPKH_BACKUP", + // value: p2wpkhReceiveDerivationsString); + // await _secureStore.write( + // key: "${walletId}_changeDerivationsP2WPKH_BACKUP", + // value: p2wpkhChangeDerivationsString); + // + // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + // await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + // + // // UTXOs + // final utxoData = + // DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); + // await DB.instance.put( + // boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); + // await DB.instance + // .delete(key: 'latest_utxo_model', boxName: walletId); + // + // Logging.instance.log("rescan backup complete", level: LogLevel.Info); + // } bool isActive = false; diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index ac71df11d..ce93cfad4 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -52,12 +52,13 @@ import 'package:stackwallet/utilities/stack_file_system.dart'; const int MINIMUM_CONFIRMATIONS = 10; class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { - final String _walletId; - final Coin _coin; - final SecureStorageInterface _secureStorage; - final Prefs _prefs; + late final String _walletId; + late final Coin _coin; + late final SecureStorageInterface _secureStorage; + late final Prefs _prefs; + + late String _walletName; - String _walletName; bool _shouldAutoSync = false; bool _isConnected = false; bool _hasCalledExit = false; @@ -83,31 +84,26 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { required Coin coin, required SecureStorageInterface secureStorage, Prefs? prefs, - }) : _walletId = walletId, - _walletName = walletName, - _coin = coin, - _secureStorage = secureStorage, - _prefs = prefs ?? Prefs.instance; - - @override - bool get isFavorite { - try { - return DB.instance.get(boxName: walletId, key: "isFavorite") - as bool; - } catch (e, s) { - Logging.instance.log( - "isFavorite fetch failed (returning false by default): $e\n$s", - level: LogLevel.Error); - return false; - } + }) { + _walletId = walletId; + _walletName = walletName; + _coin = coin; + _secureStorage = secureStorage; + _prefs = prefs ?? Prefs.instance; + initCache(walletId, coin); } @override set isFavorite(bool markFavorite) { - DB.instance.put( - boxName: walletId, key: "isFavorite", value: markFavorite); + _isFavorite = markFavorite; + updateCachedIsFavorite(markFavorite); } + @override + bool get isFavorite => _isFavorite ??= getCachedIsFavorite(); + + bool? _isFavorite; + @override bool get shouldAutoSync => _shouldAutoSync; @@ -282,7 +278,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { "Opening existing ${coin.prettyName} wallet $walletName...", level: LogLevel.Info); - if ((DB.instance.get(boxName: walletId, key: "id")) == null) { + if (getCachedId() == null) { //todo: check if print needed // debugPrint("Exception was thrown"); throw Exception( @@ -390,11 +386,10 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { await walletBase?.connectToNode( node: Node(uri: "$host:${node.port}", type: WalletType.wownero)); await walletBase?.startSync(); - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); @@ -605,11 +600,10 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { walletBase?.close(); walletBase = wallet as WowneroWalletBase; - await DB.instance - .put(boxName: walletId, key: "id", value: _walletId); - - await DB.instance - .put(boxName: walletId, key: "isFavorite", value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); } catch (e, s) { //todo: come back to this debugPrint(e.toString()); @@ -744,7 +738,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { blockedTotal: 0, pendingSpendable: total - available, ); - await updateCachedBalance(walletId, _balance!); + await updateCachedBalance(_balance!); } Future get _availableBalance async { @@ -1285,7 +1279,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int get storedChainHeight => throw UnimplementedError(); @override - Balance get balance => _balance ??= getCachedBalance(walletId, coin); + Balance get balance => _balance ??= getCachedBalance(); Balance? _balance; @override From 7e6daad77978b4de36eac3e148e2a65ffe602146 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 12 Jan 2023 16:07:15 -0600 Subject: [PATCH 124/192] some small bug fixes --- lib/services/coins/epiccash/epiccash_wallet.dart | 6 +++--- lib/services/coins/monero/monero_wallet.dart | 4 ++-- lib/services/coins/wownero/wownero_wallet.dart | 4 ++-- lib/services/mixins/epic_cash_hive.dart | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 73fafcbb8..d3f3a0097 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -945,6 +945,7 @@ class EpicCashWallet extends CoinServiceAPI Logging.instance.log("Opening existing ${coin.prettyName} wallet", level: LogLevel.Info); + await isarInit(walletId); final config = await getRealConfig(); final password = await _secureStore.read(key: '${_walletId}_password'); @@ -959,7 +960,6 @@ class EpicCashWallet extends CoinServiceAPI } await _prefs.init(); await updateNode(false); - await isarInit(walletId); await _refreshBalance(); // TODO: is there anything else that should be set up here whenever this wallet is first loaded again? } @@ -1015,6 +1015,8 @@ class EpicCashWallet extends CoinServiceAPI String stringConfig = await getConfig(); String epicboxConfig = await getEpicBoxConfig(); + await isarInit(walletId); + await _secureStore.write( key: '${_walletId}_mnemonic', value: mnemonicString); await _secureStore.write(key: '${_walletId}_config', value: stringConfig); @@ -1051,8 +1053,6 @@ class EpicCashWallet extends CoinServiceAPI epicUpdateRestoreHeight(bufferedCreateHeight), updateCachedIsFavorite(false), ]); - - await isarInit(walletId); } bool refreshMutex = false; diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 3d93fcc5d..d2414ae20 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1077,6 +1077,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { if (highestPercentCached < percent) { highestPercentCached = percent; } + await updateCachedChainHeight(height); GlobalEventBus.instance.fire( RefreshPercentChangedEvent( @@ -1206,8 +1207,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); @override - // TODO: implement storedChainHeight - int get storedChainHeight => throw UnimplementedError(); + int get storedChainHeight => getCachedChainHeight(); @override Balance get balance => _balance ??= getCachedBalance(); diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index ce93cfad4..b0a535ebb 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1146,6 +1146,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { if (highestPercentCached < percent) { highestPercentCached = percent; } + await updateCachedChainHeight(height); GlobalEventBus.instance.fire( RefreshPercentChangedEvent( @@ -1275,8 +1276,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); @override - // TODO: implement storedChainHeight - int get storedChainHeight => throw UnimplementedError(); + int get storedChainHeight => getCachedChainHeight(); @override Balance get balance => _balance ??= getCachedBalance(); diff --git a/lib/services/mixins/epic_cash_hive.dart b/lib/services/mixins/epic_cash_hive.dart index 80053034a..09a3563b8 100644 --- a/lib/services/mixins/epic_cash_hive.dart +++ b/lib/services/mixins/epic_cash_hive.dart @@ -85,7 +85,7 @@ mixin EpicCashHive { // epic restore height int? epicGetRestoreHeight() { return DB.instance.get(boxName: _walletId, key: "restoreHeight") - as int; + as int?; } Future epicUpdateRestoreHeight(int height) async { @@ -99,7 +99,7 @@ mixin EpicCashHive { // epic creation height int? epicGetCreationHeight() { return DB.instance.get(boxName: _walletId, key: "creationHeight") - as int; + as int?; } Future epicUpdateCreationHeight(int height) async { From 13e6fc6b476ca04cdd559e737a9539c50dff6216 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 09:26:37 -0600 Subject: [PATCH 125/192] restoring type fix --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 2 +- lib/services/coins/bitcoincash/bitcoincash_wallet.dart | 2 +- lib/services/coins/litecoin/litecoin_wallet.dart | 2 +- lib/services/coins/namecoin/namecoin_wallet.dart | 2 +- lib/services/coins/particl/particl_wallet.dart | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 3e34891a7..b79be69f1 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -440,7 +440,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // reset counter gapCounter = 0; // add info to derivations - derivations[node["address"] as String] = { + derivations[address.value] = { "pubKey": Format.uint8listToString( (node["node"] as bip32.BIP32).publicKey), "wif": (node["node"] as bip32.BIP32).toWIF(), diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 65d6190ac..55e89d53b 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -427,7 +427,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // reset counter gapCounter = 0; // add info to derivations - derivations[node["address"] as String] = { + derivations[address.value] = { "pubKey": Format.uint8listToString( (node["node"] as bip32.BIP32).publicKey), "wif": (node["node"] as bip32.BIP32).toWIF(), diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index ae3847975..c403743a9 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -457,7 +457,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // reset counter gapCounter = 0; // add info to derivations - derivations[node["address"] as String] = { + derivations[address.value] = { "pubKey": Format.uint8listToString( (node["node"] as bip32.BIP32).publicKey), "wif": (node["node"] as bip32.BIP32).toWIF(), diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 37bc57d87..2a158b9c4 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -447,7 +447,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // reset counter gapCounter = 0; // add info to derivations - derivations[node["address"] as String] = { + derivations[address.value] = { "pubKey": Format.uint8listToString( (node["node"] as bip32.BIP32).publicKey), "wif": (node["node"] as bip32.BIP32).toWIF(), diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index f7b941fa1..13ebe4c59 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -430,7 +430,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { // reset counter gapCounter = 0; // add info to derivations - derivations[node["address"] as String] = { + derivations[address.value] = { "pubKey": Format.uint8listToString( (node["node"] as bip32.BIP32).publicKey), "wif": (node["node"] as bip32.BIP32).toWIF(), From 52d5ab0d3366f42211e78568ea939a0ae0467b7f Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 11:11:41 -0600 Subject: [PATCH 126/192] WIP tx parse + link address to transaction --- lib/models/isar/models/address/address.dart | 5 +- .../models/blockchain_data/transaction.dart | 8 +- .../all_transactions_view.dart | 8 +- .../transaction_details_view.dart | 11 +- .../coins/bitcoin/bitcoin_wallet.dart | 347 ++---------------- .../coins/bitcoincash/bitcoincash_wallet.dart | 7 +- lib/services/coins/coin_paynym_extension.dart | 11 +- .../coins/epiccash/epiccash_wallet.dart | 7 +- lib/services/coins/firo/firo_wallet.dart | 12 +- lib/services/coins/monero/monero_wallet.dart | 18 +- .../coins/particl/particl_wallet.dart | 12 +- .../coins/wownero/wownero_wallet.dart | 18 +- lib/services/mixins/wallet_db.dart | 2 +- 13 files changed, 118 insertions(+), 348 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index d40305be9..07f1a28e7 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -1,5 +1,6 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/address/crypto_currency_address.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/services/coins/coin_paynym_extension.dart'; part 'address.g.dart'; @@ -12,7 +13,7 @@ class AddressException extends SWException { class Address extends CryptoCurrencyAddress { Id id = Isar.autoIncrement; - @Index(unique: true, replace: true) + @Index(unique: true) late String value; late List publicKey; @@ -26,6 +27,8 @@ class Address extends CryptoCurrencyAddress { @enumerated late AddressSubType subType; + final transaction = IsarLink(); + int derivationChain() { if (subType == AddressSubType.receiving) { return 0; // 0 for receiving (external) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 4c87f8302..ab99f0d5a 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/address/address.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; import 'package:stackwallet/models/isar/models/transaction_note.dart'; @@ -11,7 +12,7 @@ part 'transaction.g.dart'; class Transaction { Id id = Isar.autoIncrement; - @Index(unique: true, replace: true) + @Index(unique: true) late String txid; @Index() @@ -30,8 +31,6 @@ class Transaction { late int fee; - late String address; - late int? height; late bool isCancelled; @@ -42,6 +41,9 @@ class Transaction { late String? otherData; + @Backlink(to: "transaction") + final address = IsarLink

(); + final inputs = IsarLinks(); final outputs = IsarLinks(); diff --git a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart index 4ff070712..6ebb5bd1c 100644 --- a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart +++ b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart @@ -4,11 +4,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/contact.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/models/transaction_filter.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart'; +import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; import 'package:stackwallet/providers/global/address_book_service_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; @@ -33,9 +35,6 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:stackwallet/widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; -import '../../../models/isar/models/blockchain_data/transaction.dart'; -import '../../../providers/blockchain/dogecoin/current_height_provider.dart'; - class AllTransactionsView extends ConsumerStatefulWidget { const AllTransactionsView({ Key? key, @@ -137,7 +136,8 @@ class _TransactionDetailsViewState extends ConsumerState { .isNotEmpty; // check if address contains - contains |= tx.address.toLowerCase().contains(keyword); + contains |= + tx.address.value?.value.toLowerCase().contains(keyword) ?? false; // check if note contains contains |= notes[tx.txid] != null && 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 fec0721d9..4a2e9e758 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -610,13 +610,15 @@ class _TransactionDetailsViewState TransactionType.incoming ? FutureBuilder( future: fetchContactNameFor( - _transaction.address), + _transaction.address + .value!.value), builder: (builderContext, AsyncSnapshot snapshot) { String addressOrContactName = - _transaction.address; + _transaction.address + .value!.value; if (snapshot.connectionState == ConnectionState .done && @@ -644,7 +646,8 @@ class _TransactionDetailsViewState }, ) : SelectableText( - _transaction.address, + _transaction + .address.value!.value, style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( @@ -665,7 +668,7 @@ class _TransactionDetailsViewState ), if (isDesktop) IconCopyButton( - data: _transaction.address, + data: _transaction.address.value!.value, ), ], ), diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index b79be69f1..ca3c526cb 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:developer'; import 'dart:io'; import 'package:bech32/bech32.dart'; @@ -2011,79 +2012,40 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final List allAddresses = await _fetchAllOwnAddresses(); - // final changeAddresses = DB.instance.get( - // boxName: walletId, key: 'changeAddressesP2WPKH') as List; - // final changeAddressesP2PKH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - // as List; - // final changeAddressesP2SH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - // as List; - // - // for (var i = 0; i < changeAddressesP2PKH.length; i++) { - // changeAddresses.add(changeAddressesP2PKH[i] as String); - // } - // for (var i = 0; i < changeAddressesP2SH.length; i++) { - // changeAddresses.add(changeAddressesP2SH[i] as String); - // } + final receivingAddresses = allAddresses + .where((e) => e.subType == isar_models.AddressSubType.receiving); + final changeAddresses = allAddresses + .where((e) => e.subType == isar_models.AddressSubType.change); - final List> allTxHashes = - await _fetchHistory(allAddresses.map((e) => e.value).toList()); + final List> allReceivingTxHashes = + await _fetchHistory(receivingAddresses.map((e) => e.value).toList()); - // final cachedTransactions = - // DB.instance.get(boxName: walletId, key: 'latest_tx_model') - // as TransactionData?; - // int latestTxnBlockHeight = - // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - // as int? ?? - // 0; - - // final unconfirmedCachedTransactions = - // cachedTransactions?.getAllTransactions() ?? {}; - // unconfirmedCachedTransactions - // .removeWhere((key, value) => value.confirmedStatus); - // - // if (cachedTransactions != null) { - // for (final tx in allTxHashes.toList(growable: false)) { - // final txHeight = tx["height"] as int; - // if (txHeight > 0 && - // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - // allTxHashes.remove(tx); - // } - // } - // } - // } - // + // // prefetch/cache // Set hashes = {}; - // for (var element in allTxHashes) { + // for (var element in allReceivingTxHashes) { // hashes.add(element['tx_hash'] as String); // } - List hashes = - allTxHashes.map((e) => e['tx_hash'] as String).toList(growable: false); - await fastFetch(hashes.toList()); + // await fastFetch(hashes.toList()); + List> allTransactions = []; - for (final txHash in allTxHashes) { + for (final txHash in allReceivingTxHashes) { final tx = await cachedElectrumXClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, coin: coin, ); - if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; - tx["height"] = txHash["height"]; - allTransactions.add(tx); - } + // if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); + tx["height"] = txHash["height"]; + allTransactions.add(tx); + // } } - // Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); - // Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); - - // Logging.instance.log("allTransactions length: ${allTransactions.length}", - // level: LogLevel.Info); - Set vHashes = {}; for (final txObject in allTransactions) { for (int i = 0; i < (txObject["vin"] as List).length; i++) { @@ -2094,7 +2056,14 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await fastFetch(vHashes.toList()); + final List txns = []; + for (final txObject in allTransactions) { + final pretty = const JsonEncoder.withIndent(" ").convert(txObject); + + print("========================================================="); + log(pretty); + final txn = await parseTransaction( txObject, cachedElectrumXClient, @@ -2103,260 +2072,11 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { MINIMUM_CONFIRMATIONS, ); - // final tx = await isar.transactions - // .filter() - // .txidMatches(midSortedTx.txid) - // .findFirst(); - // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar - // if (tx == null) { - await isar.writeTxn(() async { - await isar.transactions.put(txn); - }); - // } - - // List sendersArray = []; - // List recipientsArray = []; - // - // // Usually only has value when txType = 'Send' - // int inputAmtSentFromWallet = 0; - // // Usually has value regardless of txType due to change addresses - // int outputAmtAddressedToWallet = 0; - // int fee = 0; - // - // Map midSortedTx = {}; - // - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"]![i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // final address = out["scriptPubKey"]["address"] as String?; - // if (address != null) { - // sendersArray.add(address); - // } - // } - // } - // } - // - // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - // - // for (final output in txObject["vout"] as List) { - // final address = output["scriptPubKey"]["address"] as String?; - // if (address != null) { - // recipientsArray.add(address); - // } - // } - // - // Logging.instance - // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - // - // final foundInSenders = - // allAddresses.any((element) => sendersArray.contains(element)); - // Logging.instance - // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - // - // // If txType = Sent, then calculate inputAmtSentFromWallet - // if (foundInSenders) { - // int totalInput = 0; - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"]![i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // inputAmtSentFromWallet += - // (Decimal.parse(out["value"]!.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // totalInput = inputAmtSentFromWallet; - // int totalOutput = 0; - // - // for (final output in txObject["vout"] as List) { - // final String address = output["scriptPubKey"]!["address"] as String; - // final value = output["value"]!; - // final _value = (Decimal.parse(value.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOutput += _value; - // if (changeAddresses.contains(address)) { - // inputAmtSentFromWallet -= _value; - // } else { - // // change address from 'sent from' to the 'sent to' address - // txObject["address"] = address; - // } - // } - // // calculate transaction fee - // fee = totalInput - totalOutput; - // // subtract fee from sent to calculate correct value of sent tx - // inputAmtSentFromWallet -= fee; - // } else { - // // counters for fee calculation - // int totalOut = 0; - // int totalIn = 0; - // - // // add up received tx value - // for (final output in txObject["vout"] as List) { - // final address = output["scriptPubKey"]["address"]; - // if (address != null) { - // final value = (Decimal.parse(output["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOut += value; - // if (allAddresses.contains(address)) { - // outputAmtAddressedToWallet += value; - // } - // } - // } - // - // // calculate fee for received tx - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"][i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // totalIn += (Decimal.parse(out["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // fee = totalIn - totalOut; - // } - // - // // create final tx map - // midSortedTx["txid"] = txObject["txid"]; - // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - // midSortedTx["timestamp"] = txObject["blocktime"] ?? - // (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // - // if (foundInSenders) { - // midSortedTx["txType"] = "Sent"; - // midSortedTx["amount"] = inputAmtSentFromWallet; - // final String worthNow = - // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // midSortedTx["worthAtBlockTimestamp"] = worthNow; - // } else { - // midSortedTx["txType"] = "Received"; - // midSortedTx["amount"] = outputAmtAddressedToWallet; - // final worthNow = - // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // } - // midSortedTx["aliens"] = []; - // midSortedTx["fees"] = fee; - // midSortedTx["address"] = txObject["address"]; - // midSortedTx["inputSize"] = txObject["vin"].length; - // midSortedTx["outputSize"] = txObject["vout"].length; - // midSortedTx["inputs"] = txObject["vin"]; - // midSortedTx["outputs"] = txObject["vout"]; - // - // final int height = txObject["height"] as int; - // midSortedTx["height"] = height; - // - // if (height >= latestTxnBlockHeight) { - // latestTxnBlockHeight = height; - // } - // - // midSortedArray.add(midSortedTx); + txns.add(txn); } - - // // sort by date ---- //TODO not sure if needed - // // shouldn't be any issues with a null timestamp but I got one at some point? - // midSortedArray - // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // // { - // // final aT = a["timestamp"]; - // // final bT = b["timestamp"]; - // // - // // if (aT == null && bT == null) { - // // return 0; - // // } else if (aT == null) { - // // return -1; - // // } else if (bT == null) { - // // return 1; - // // } else { - // // return bT - aT; - // // } - // // }); - // - // // buildDateTimeChunks - // 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], - // }; - // result["dateTimeChunks"].add(chunk); - // } - // } - // - // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - // transactionsMap - // .addAll(TransactionData.fromJson(result).getAllTransactions()); - // - // 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); - // - // cachedTxData = txModel; - // return txModel; + await isar.writeTxn(() async { + await isar.transactions.putAll(txns); + }); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -3017,6 +2737,11 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // back up data // await _rescanBackup(); + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.addresses.clear(); + }); + try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); await _recoverWalletFromBIP32SeedPhrase( diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 55e89d53b..4908efc37 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1949,7 +1949,10 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); tx["height"] = txHash["height"]; allTransactions.add(tx); } @@ -2076,7 +2079,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { tx.subType = isar_models.TransactionSubType.none; tx.fee = fee; - tx.address = txData["address"] as String; + tx.address.value = txData["address"] as isar_models.Address; for (final json in txData["vin"] as List) { bool isCoinBase = json['coinbase'] != null; diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index d75b0c8a0..266963cea 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:developer'; import 'dart:typed_data'; import 'package:bip47/bip47.dart'; @@ -669,6 +670,10 @@ Future parseTransaction( tx.timestamp = txData["blocktime"] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); + // this should be the address we used to originally fetch the tx so we should + // be able to easily figure out if the tx is a send or receive + tx.address.value = txData["address"] as Address; + if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self tx.type = TransactionType.sentToSelf; @@ -688,7 +693,11 @@ Future parseTransaction( tx.subType = TransactionSubType.none; tx.fee = fee; - tx.address = txData["address"] as String; + + log("tx.address: ${tx.address}"); + log("mySentFromAddresses: $mySentFromAddresses"); + log("myReceivedOnAddresses: $myReceivedOnAddresses"); + log("myChangeReceivedOnAddresses: $myChangeReceivedOnAddresses"); for (final json in txData["vin"] as List) { bool isCoinBase = json['coinbase'] != null; diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index d3f3a0097..e2b07c54f 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -2041,9 +2041,10 @@ class EpicCashWallet extends CoinServiceAPI txn.timestamp = (dt.millisecondsSinceEpoch ~/ 1000); txn.amount = amt; txn.fee = (tx["fee"] == null) ? 0 : int.parse(tx["fee"] as String); - txn.address = - ""; // for this when you send a transaction you will just need to save in a hashmap in hive with the key being the txid, and the value being the address it was sent to. then you can look this value up right here in your hashmap. - txn.address = address; + // txn.address = + // ""; // for this when you send a transaction you will just need to save in a hashmap in hive with the key being the txid, and the value being the address it was sent to. then you can look this value up right here in your hashmap. + txn.address.value = + await isar.addresses.filter().valueEqualTo(address).findFirst(); txn.height = txHeight; // diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 421090384..90a26675a 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -425,7 +425,7 @@ Future> staticProcessRestore( ..fee = sharedFee ..inputs.addAll(element.inputs) ..outputs.addAll(element.outputs) - ..address = element.address + ..address.value = element.address.value ..height = element.height ..subType = isar_models.TransactionSubType.mint ..otherData = txid @@ -2955,7 +2955,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Decimal.parse(transactionInfo["amount"].toString()), coin) ..fee = Format.decimalAmountToSatoshis( Decimal.parse(transactionInfo["fees"].toString()), coin) - ..address = transactionInfo["address"] as String + ..address.value = await isar.addresses + .filter() + .valueEqualTo(transactionInfo["address"] as String) + .findFirst() ..height = transactionInfo["height"] as int? ..subType = transactionInfo["subType"] == "mint" ? isar_models.TransactionSubType.mint @@ -4731,7 +4734,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ..subType = isar_models.TransactionSubType.join ..fee = Format.decimalAmountToSatoshis( Decimal.parse(tx["fees"].toString()), coin) - ..address = tx["address"] as String + ..address.value = await isar.addresses + .filter() + .valueEqualTo(tx["address"] as String) + .findFirst() ..amount = Format.decimalAmountToSatoshis( Decimal.parse(tx["amount"].toString()), coin) ..isCancelled = false diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index d2414ae20..6e8a53283 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -868,15 +868,21 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; - txn.address = walletBase?.getTransactionAddress( - addressInfo!['accountIndex'] as int, - addressInfo['addressIndex'] as int, - ) ?? - ""; + final addressString = walletBase?.getTransactionAddress( + addressInfo!['accountIndex'] as int, + addressInfo['addressIndex'] as int, + ); + + if (addressString != null) { + txn.address.value = await isar.addresses + .filter() + .valueEqualTo(addressString) + .findFirst(); + } txn.type = isar_models.TransactionType.incoming; } else { - txn.address = ""; + // txn.address = ""; txn.type = isar_models.TransactionType.outgoing; } diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 13ebe4c59..24ee293f2 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -2015,7 +2015,10 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); // TODO fix this for sent to self transactions? if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); tx["height"] = txHash["height"]; allTransactions.add(tx); } @@ -2150,7 +2153,10 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { inputAmtSentFromWallet -= _value; } else { // change address from 'sent from' to the 'sent to' address - txObject["address"] = address; + txObject["address"] = await isar.addresses + .filter() + .valueEqualTo(address) + .findFirst(); } } catch (s) { Logging.instance.log(s.toString(), level: LogLevel.Warning); @@ -2263,7 +2269,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { tx.subType = isar_models.TransactionSubType.none; tx.fee = fee; - tx.address = midSortedTx["address"] as String; + tx.address.value = midSortedTx["address"] as isar_models.Address?; for (final json in midSortedTx["vin"] as List) { bool isCoinBase = json['coinbase'] != null; diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index b0a535ebb..701ae0589 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -937,15 +937,21 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; - txn.address = walletBase?.getTransactionAddress( - addressInfo!['accountIndex'] as int, - addressInfo['addressIndex'] as int, - ) ?? - ""; + final addressString = walletBase?.getTransactionAddress( + addressInfo!['accountIndex'] as int, + addressInfo['addressIndex'] as int, + ); + + if (addressString != null) { + txn.address.value = await isar.addresses + .filter() + .valueEqualTo(addressString) + .findFirst(); + } txn.type = isar_models.TransactionType.incoming; } else { - txn.address = ""; + // txn.address = ""; txn.type = isar_models.TransactionType.outgoing; } diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 9d470ccd8..365b6155a 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -22,7 +22,7 @@ mixin WalletDB { AddressSchema, ], directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: false, + inspector: true, name: walletId, ); return true; From d1192964924675df087959e180f438841e28df9b Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 11:13:52 -0600 Subject: [PATCH 127/192] build runner --- lib/models/isar/models/address/address.g.dart | 30 +- .../models/blockchain_data/transaction.g.dart | 289 +++--------- .../pages/send_view/send_view_test.mocks.dart | 270 +++++++++--- ...d_address_book_view_screen_test.mocks.dart | 213 ++++----- ..._entry_details_view_screen_test.mocks.dart | 261 +++++------ ...ess_book_entry_view_screen_test.mocks.dart | 203 +++++---- .../lockscreen_view_screen_test.mocks.dart | 387 +++++++++-------- .../main_view_screen_testA_test.mocks.dart | 339 ++++++++------- .../main_view_screen_testB_test.mocks.dart | 339 ++++++++------- .../main_view_screen_testC_test.mocks.dart | 339 ++++++++------- .../backup_key_view_screen_test.mocks.dart | 163 ++++--- ...up_key_warning_view_screen_test.mocks.dart | 281 ++++++------ .../create_pin_view_screen_test.mocks.dart | 387 +++++++++-------- ...restore_wallet_view_screen_test.mocks.dart | 411 +++++++++--------- ...ify_backup_key_view_screen_test.mocks.dart | 163 ++++--- .../currency_view_screen_test.mocks.dart | 163 ++++--- ...dd_custom_node_view_screen_test.mocks.dart | 269 ++++++------ .../node_details_view_screen_test.mocks.dart | 269 ++++++------ .../wallet_backup_view_screen_test.mocks.dart | 163 ++++--- ...rescan_warning_view_screen_test.mocks.dart | 163 ++++--- ...elete_mnemonic_view_screen_test.mocks.dart | 281 ++++++------ ...allet_settings_view_screen_test.mocks.dart | 389 +++++++++-------- .../settings_view_screen_test.mocks.dart | 281 ++++++------ ...search_results_view_screen_test.mocks.dart | 221 +++++----- .../confirm_send_view_screen_test.mocks.dart | 205 +++++---- .../receive_view_screen_test.mocks.dart | 163 ++++--- .../send_view_screen_test.mocks.dart | 215 ++++----- .../wallet_view_screen_test.mocks.dart | 221 +++++----- test/services/coins/manager_test.mocks.dart | 271 +++++++++--- .../managed_favorite_test.mocks.dart | 272 ++++++++---- .../table_view/table_view_row_test.mocks.dart | 272 ++++++++---- .../transaction_card_test.mocks.dart | 203 ++++++++- test/widget_tests/wallet_card_test.mocks.dart | 232 +++++++--- ...et_info_row_balance_future_test.mocks.dart | 272 ++++++++---- .../wallet_info_row_test.mocks.dart | 272 ++++++++---- 35 files changed, 5133 insertions(+), 3739 deletions(-) diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 808b182f9..0afbe1fc5 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -55,7 +55,7 @@ const AddressSchema = CollectionSchema( id: -8658876004265234192, name: r'value', unique: true, - replace: true, + replace: false, properties: [ IndexPropertySchema( name: r'value', @@ -78,7 +78,14 @@ const AddressSchema = CollectionSchema( ], ) }, - links: {}, + links: { + r'transaction': LinkSchema( + id: -7782495619063243587, + name: r'transaction', + target: r'Transaction', + single: true, + ) + }, embeddedSchemas: {}, getId: _addressGetId, getLinks: _addressGetLinks, @@ -185,11 +192,13 @@ Id _addressGetId(Address object) { } List> _addressGetLinks(Address object) { - return []; + return [object.transaction]; } void _addressAttach(IsarCollection col, Id id, Address object) { object.id = id; + object.transaction + .attach(col, col.isar.collection(), r'transaction', id); } extension AddressByIndex on IsarCollection
{ @@ -952,7 +961,20 @@ extension AddressQueryObject on QueryBuilder {} extension AddressQueryLinks - on QueryBuilder {} + on QueryBuilder { + QueryBuilder transaction( + FilterQuery q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'transaction'); + }); + } + + QueryBuilder transactionIsNull() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', 0, true, 0, true); + }); + } +} extension AddressQuerySortBy on QueryBuilder { QueryBuilder sortByDerivationIndex() { diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index b12911d1d..3d840d092 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -17,64 +17,59 @@ const TransactionSchema = CollectionSchema( name: r'Transaction', id: 5320225499417954855, properties: { - r'address': PropertySchema( - id: 0, - name: r'address', - type: IsarType.string, - ), r'amount': PropertySchema( - id: 1, + id: 0, name: r'amount', type: IsarType.long, ), r'fee': PropertySchema( - id: 2, + id: 1, name: r'fee', type: IsarType.long, ), r'height': PropertySchema( - id: 3, + id: 2, name: r'height', type: IsarType.long, ), r'isCancelled': PropertySchema( - id: 4, + id: 3, name: r'isCancelled', type: IsarType.bool, ), r'isLelantus': PropertySchema( - id: 5, + id: 4, name: r'isLelantus', type: IsarType.bool, ), r'otherData': PropertySchema( - id: 6, + id: 5, name: r'otherData', type: IsarType.string, ), r'slateId': PropertySchema( - id: 7, + id: 6, name: r'slateId', type: IsarType.string, ), r'subType': PropertySchema( - id: 8, + id: 7, name: r'subType', type: IsarType.byte, enumMap: _TransactionsubTypeEnumValueMap, ), r'timestamp': PropertySchema( - id: 9, + id: 8, name: r'timestamp', type: IsarType.long, ), r'txid': PropertySchema( - id: 10, + id: 9, name: r'txid', type: IsarType.string, ), r'type': PropertySchema( - id: 11, + id: 10, name: r'type', type: IsarType.byte, enumMap: _TransactiontypeEnumValueMap, @@ -90,7 +85,7 @@ const TransactionSchema = CollectionSchema( id: 7339874292043634331, name: r'txid', unique: true, - replace: true, + replace: false, properties: [ IndexPropertySchema( name: r'txid', @@ -114,6 +109,13 @@ const TransactionSchema = CollectionSchema( ) }, links: { + r'address': LinkSchema( + id: 2468609240108930288, + name: r'address', + target: r'Address', + single: true, + linkName: r'transaction', + ), r'inputs': LinkSchema( id: 4634425919890543640, name: r'inputs', @@ -147,7 +149,6 @@ int _transactionEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; - bytesCount += 3 + object.address.length * 3; { final value = object.otherData; if (value != null) { @@ -170,18 +171,17 @@ void _transactionSerialize( List offsets, Map> allOffsets, ) { - writer.writeString(offsets[0], object.address); - writer.writeLong(offsets[1], object.amount); - writer.writeLong(offsets[2], object.fee); - writer.writeLong(offsets[3], object.height); - writer.writeBool(offsets[4], object.isCancelled); - writer.writeBool(offsets[5], object.isLelantus); - writer.writeString(offsets[6], object.otherData); - writer.writeString(offsets[7], object.slateId); - writer.writeByte(offsets[8], object.subType.index); - writer.writeLong(offsets[9], object.timestamp); - writer.writeString(offsets[10], object.txid); - writer.writeByte(offsets[11], object.type.index); + writer.writeLong(offsets[0], object.amount); + writer.writeLong(offsets[1], object.fee); + writer.writeLong(offsets[2], object.height); + writer.writeBool(offsets[3], object.isCancelled); + writer.writeBool(offsets[4], object.isLelantus); + writer.writeString(offsets[5], object.otherData); + writer.writeString(offsets[6], object.slateId); + writer.writeByte(offsets[7], object.subType.index); + writer.writeLong(offsets[8], object.timestamp); + writer.writeString(offsets[9], object.txid); + writer.writeByte(offsets[10], object.type.index); } Transaction _transactionDeserialize( @@ -191,22 +191,21 @@ Transaction _transactionDeserialize( Map> allOffsets, ) { final object = Transaction(); - object.address = reader.readString(offsets[0]); - object.amount = reader.readLong(offsets[1]); - object.fee = reader.readLong(offsets[2]); - object.height = reader.readLongOrNull(offsets[3]); + object.amount = reader.readLong(offsets[0]); + object.fee = reader.readLong(offsets[1]); + object.height = reader.readLongOrNull(offsets[2]); object.id = id; - object.isCancelled = reader.readBool(offsets[4]); - object.isLelantus = reader.readBoolOrNull(offsets[5]); - object.otherData = reader.readStringOrNull(offsets[6]); - object.slateId = reader.readStringOrNull(offsets[7]); + object.isCancelled = reader.readBool(offsets[3]); + object.isLelantus = reader.readBoolOrNull(offsets[4]); + object.otherData = reader.readStringOrNull(offsets[5]); + object.slateId = reader.readStringOrNull(offsets[6]); object.subType = - _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[8])] ?? + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ?? TransactionSubType.none; - object.timestamp = reader.readLong(offsets[9]); - object.txid = reader.readString(offsets[10]); + object.timestamp = reader.readLong(offsets[8]); + object.txid = reader.readString(offsets[9]); object.type = - _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? + _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ?? TransactionType.outgoing; return object; } @@ -219,29 +218,27 @@ P _transactionDeserializeProp

( ) { switch (propertyId) { case 0: - return (reader.readString(offset)) as P; + return (reader.readLong(offset)) as P; case 1: return (reader.readLong(offset)) as P; case 2: - return (reader.readLong(offset)) as P; - case 3: return (reader.readLongOrNull(offset)) as P; - case 4: + case 3: return (reader.readBool(offset)) as P; - case 5: + case 4: return (reader.readBoolOrNull(offset)) as P; + case 5: + return (reader.readStringOrNull(offset)) as P; case 6: return (reader.readStringOrNull(offset)) as P; case 7: - return (reader.readStringOrNull(offset)) as P; - case 8: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 9: + case 8: return (reader.readLong(offset)) as P; - case 10: + case 9: return (reader.readString(offset)) as P; - case 11: + case 10: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; default: @@ -279,12 +276,13 @@ Id _transactionGetId(Transaction object) { } List> _transactionGetLinks(Transaction object) { - return [object.inputs, object.outputs, object.note]; + return [object.address, object.inputs, object.outputs, object.note]; } void _transactionAttach( IsarCollection col, Id id, Transaction object) { object.id = id; + object.address.attach(col, col.isar.collection

(), r'address', id); object.inputs.attach(col, col.isar.collection(), r'inputs', id); object.outputs.attach(col, col.isar.collection(), r'outputs', id); object.note.attach(col, col.isar.collection(), r'note', id); @@ -569,140 +567,6 @@ extension TransactionQueryWhere extension TransactionQueryFilter on QueryBuilder { - QueryBuilder addressEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'address', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - addressGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'address', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder addressLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'address', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder addressBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'address', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - addressStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'address', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder addressEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'address', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder addressContains( - String value, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'address', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder addressMatches( - String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'address', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - addressIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'address', - value: '', - )); - }); - } - - QueryBuilder - addressIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'address', - value: '', - )); - }); - } - QueryBuilder amountEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -1578,6 +1442,20 @@ extension TransactionQueryObject extension TransactionQueryLinks on QueryBuilder { + QueryBuilder address( + FilterQuery
q) { + return QueryBuilder.apply(this, (query) { + return query.link(q, r'address'); + }); + } + + QueryBuilder + addressIsNull() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'address', 0, true, 0, true); + }); + } + QueryBuilder inputs( FilterQuery q) { return QueryBuilder.apply(this, (query) { @@ -1716,18 +1594,6 @@ extension TransactionQueryLinks extension TransactionQuerySortBy on QueryBuilder { - QueryBuilder sortByAddress() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'address', Sort.asc); - }); - } - - QueryBuilder sortByAddressDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'address', Sort.desc); - }); - } - QueryBuilder sortByAmount() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'amount', Sort.asc); @@ -1863,18 +1729,6 @@ extension TransactionQuerySortBy extension TransactionQuerySortThenBy on QueryBuilder { - QueryBuilder thenByAddress() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'address', Sort.asc); - }); - } - - QueryBuilder thenByAddressDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'address', Sort.desc); - }); - } - QueryBuilder thenByAmount() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'amount', Sort.asc); @@ -2022,13 +1876,6 @@ extension TransactionQuerySortThenBy extension TransactionQueryWhereDistinct on QueryBuilder { - QueryBuilder distinctByAddress( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'address', caseSensitive: caseSensitive); - }); - } - QueryBuilder distinctByAmount() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'amount'); @@ -2107,12 +1954,6 @@ extension TransactionQueryProperty }); } - QueryBuilder addressProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'address'); - }); - } - QueryBuilder amountProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'amount'); diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 1b4d831f2..7204ae4e6 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -8,14 +8,14 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i9; +import 'package:isar/isar.dart' as _i13; import 'package:mockito/mockito.dart' as _i1; -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/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 _i22; import 'package:stackwallet/models/node_model.dart' as _i20; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i10; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart' as _i25; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i21; @@ -109,8 +109,8 @@ class _FakeTransactionNotificationTracker_5 extends _i1.SmartFake ); } -class _FakeIsar_6 extends _i1.SmartFake implements _i9.Isar { - _FakeIsar_6( +class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { + _FakeFeeObject_6( Object parent, Invocation parentInvocation, ) : super( @@ -119,8 +119,8 @@ class _FakeIsar_6 extends _i1.SmartFake implements _i9.Isar { ); } -class _FakeFeeObject_7 extends _i1.SmartFake implements _i10.FeeObject { - _FakeFeeObject_7( +class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { + _FakeElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -129,8 +129,9 @@ class _FakeFeeObject_7 extends _i1.SmartFake implements _i10.FeeObject { ); } -class _FakeElectrumX_8 extends _i1.SmartFake implements _i11.ElectrumX { - _FakeElectrumX_8( +class _FakeCachedElectrumX_8 extends _i1.SmartFake + implements _i11.CachedElectrumX { + _FakeCachedElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -139,9 +140,8 @@ class _FakeElectrumX_8 extends _i1.SmartFake implements _i11.ElectrumX { ); } -class _FakeCachedElectrumX_9 extends _i1.SmartFake - implements _i12.CachedElectrumX { - _FakeCachedElectrumX_9( +class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { + _FakeBalance_9( Object parent, Invocation parentInvocation, ) : super( @@ -150,8 +150,8 @@ class _FakeCachedElectrumX_9 extends _i1.SmartFake ); } -class _FakeBalance_10 extends _i1.SmartFake implements _i13.Balance { - _FakeBalance_10( +class _FakeIsar_10 extends _i1.SmartFake implements _i13.Isar { + _FakeIsar_10( Object parent, Invocation parentInvocation, ) : super( @@ -161,7 +161,7 @@ class _FakeBalance_10 extends _i1.SmartFake implements _i13.Balance { } class _FakeElectrumXNode_11 extends _i1.SmartFake - implements _i11.ElectrumXNode { + implements _i10.ElectrumXNode { _FakeElectrumXNode_11( Object parent, Invocation parentInvocation, @@ -877,22 +877,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i9.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_6( - this, - Invocation.getter(#isar), - ), - ) as _i9.Isar); - @override - set isar(_i9.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override bool get isActive => (super.noSuchMethod( Invocation.getter(#isActive), returnValue: false, @@ -950,13 +934,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValue: false, ) as bool); @override - _i17.Future<_i10.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i10.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i10.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1019,29 +1003,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i11.ElectrumX get electrumXClient => (super.noSuchMethod( + _i10.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_8( + returnValue: _FakeElectrumX_7( this, Invocation.getter(#electrumXClient), ), - ) as _i11.ElectrumX); + ) as _i10.ElectrumX); @override - _i12.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_9( + returnValue: _FakeCachedElectrumX_8( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i12.CachedElectrumX); + ) as _i11.CachedElectrumX); @override - _i13.Balance get balance => (super.noSuchMethod( + _i12.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_10( + returnValue: _FakeBalance_9( this, Invocation.getter(#balance), ), - ) as _i13.Balance); + ) as _i12.Balance); + @override + _i13.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_10( + this, + Invocation.getter(#isarInstance), + ), + ) as _i13.Isar); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -1052,6 +1044,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: null, ); @override + _i13.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_10( + this, + Invocation.getter(#isar), + ), + ) as _i13.Isar); + @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, @@ -1061,17 +1061,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future updateStoredChainHeight({required int? newHeight}) => - (super.noSuchMethod( - Invocation.method( - #updateStoredChainHeight, - [], - {#newHeight: newHeight}, - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); - @override _i21.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( @@ -1237,20 +1226,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future<_i11.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), returnValue: - _i17.Future<_i11.ElectrumXNode>.value(_FakeElectrumXNode_11( + _i17.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_11( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i17.Future<_i11.ElectrumXNode>); + ) as _i17.Future<_i10.ElectrumXNode>); @override _i17.Future addDerivation({ required int? chain, @@ -1468,6 +1457,129 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + void initCache( + String? walletId, + _i16.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i17.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i17.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i17.Future updateCachedIsFavorite(bool? isFavorite) => + (super.noSuchMethod( + Invocation.method( + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i12.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, + [], + ), + returnValue: _FakeBalance_9( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i12.Balance); + @override + _i17.Future updateCachedBalance(_i12.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i12.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_9( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i12.Balance); + @override + _i17.Future updateCachedBalanceSecondary(_i12.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); + @override + _i17.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [LocaleService]. @@ -1944,13 +2056,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i17.Future<_i10.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i10.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i10.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1962,13 +2074,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i13.Balance get balance => (super.noSuchMethod( + _i12.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_10( + returnValue: _FakeBalance_9( this, Invocation.getter(#balance), ), - ) as _i13.Balance); + ) as _i12.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -2014,6 +2126,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override + _i13.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_10( + this, + Invocation.getter(#db), + ), + ) as _i13.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2252,13 +2372,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i17.Future<_i10.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i10.FeeObject>.value(_FakeFeeObject_7( + returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i10.FeeObject>); + ) as _i17.Future<_i9.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -2270,13 +2390,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i13.Balance get balance => (super.noSuchMethod( + _i12.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_10( + returnValue: _FakeBalance_9( this, Invocation.getter(#balance), ), - ) as _i13.Balance); + ) as _i12.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -2327,6 +2447,14 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override + _i13.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_10( + this, + Invocation.getter(#isarInstance), + ), + ) as _i13.Isar); + @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 bb5c5c408..d5c5437b4 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 @@ -3,20 +3,21 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i9; +import 'dart:ui' as _i11; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; +import 'package:isar/isar.dart' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i6; import 'package:stackwallet/models/contact.dart' as _i3; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; import 'package:stackwallet/models/models.dart' as _i5; -import 'package:stackwallet/services/address_book_service.dart' as _i9; +import 'package:stackwallet/services/address_book_service.dart' as _i10; import 'package:stackwallet/services/coins/coin_service.dart' as _i4; -import 'package:stackwallet/services/coins/manager.dart' as _i11; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i12; +import 'package:stackwallet/services/coins/manager.dart' as _i12; +import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i13; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -80,17 +81,27 @@ class _FakeBalance_4 extends _i1.SmartFake implements _i6.Balance { ); } +class _FakeIsar_5 extends _i1.SmartFake implements _i7.Isar { + _FakeIsar_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [BarcodeScannerWrapper]. /// /// See the documentation for Mockito's code generation for more information. class MockBarcodeScannerWrapper extends _i1.Mock - implements _i7.BarcodeScannerWrapper { + implements _i8.BarcodeScannerWrapper { MockBarcodeScannerWrapper() { _i1.throwOnMissingStub(this); } @override - _i8.Future<_i2.ScanResult> scan( + _i9.Future<_i2.ScanResult> scan( {_i2.ScanOptions? options = const _i2.ScanOptions()}) => (super.noSuchMethod( Invocation.method( @@ -98,7 +109,7 @@ class MockBarcodeScannerWrapper extends _i1.Mock [], {#options: options}, ), - returnValue: _i8.Future<_i2.ScanResult>.value(_FakeScanResult_0( + returnValue: _i9.Future<_i2.ScanResult>.value(_FakeScanResult_0( this, Invocation.method( #scan, @@ -106,24 +117,24 @@ class MockBarcodeScannerWrapper extends _i1.Mock {#options: options}, ), )), - ) as _i8.Future<_i2.ScanResult>); + ) as _i9.Future<_i2.ScanResult>); } /// A class which mocks [AddressBookService]. /// /// See the documentation for Mockito's code generation for more information. class MockAddressBookService extends _i1.Mock - implements _i9.AddressBookService { + implements _i10.AddressBookService { @override List<_i3.Contact> get contacts => (super.noSuchMethod( Invocation.getter(#contacts), returnValue: <_i3.Contact>[], ) as List<_i3.Contact>); @override - _i8.Future> get addressBookEntries => (super.noSuchMethod( + _i9.Future> get addressBookEntries => (super.noSuchMethod( Invocation.getter(#addressBookEntries), - returnValue: _i8.Future>.value(<_i3.Contact>[]), - ) as _i8.Future>); + returnValue: _i9.Future>.value(<_i3.Contact>[]), + ) as _i9.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -144,13 +155,13 @@ class MockAddressBookService extends _i1.Mock ), ) as _i3.Contact); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i9.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value(<_i3.Contact>[]), - ) as _i8.Future>); + returnValue: _i9.Future>.value(<_i3.Contact>[]), + ) as _i9.Future>); @override bool matches( String? term, @@ -167,33 +178,33 @@ class MockAddressBookService extends _i1.Mock returnValue: false, ) as bool); @override - _i8.Future addContact(_i3.Contact? contact) => (super.noSuchMethod( + _i9.Future addContact(_i3.Contact? contact) => (super.noSuchMethod( Invocation.method( #addContact, [contact], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future editContact(_i3.Contact? editedContact) => + _i9.Future editContact(_i3.Contact? editedContact) => (super.noSuchMethod( Invocation.method( #editContact, [editedContact], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future removeContact(String? id) => (super.noSuchMethod( + _i9.Future removeContact(String? id) => (super.noSuchMethod( Invocation.method( #removeContact, [id], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -201,7 +212,7 @@ class MockAddressBookService extends _i1.Mock returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -229,7 +240,7 @@ class MockAddressBookService extends _i1.Mock /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i11.Manager { +class MockManager extends _i1.Mock implements _i12.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -257,10 +268,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override - _i12.Coin get coin => (super.noSuchMethod( + _i13.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i12.Coin.bitcoin, - ) as _i12.Coin); + returnValue: _i13.Coin.bitcoin, + ) as _i13.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -293,23 +304,23 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i5.FeeObject> get fees => (super.noSuchMethod( + _i9.Future<_i5.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i5.FeeObject>.value(_FakeFeeObject_3( + returnValue: _i9.Future<_i5.FeeObject>.value(_FakeFeeObject_3( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i5.FeeObject>); + ) as _i9.Future<_i5.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i9.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i9.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override _i6.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -319,16 +330,16 @@ class MockManager extends _i1.Mock implements _i11.Manager { ), ) as _i6.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i9.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i13.Transaction>[]), - ) as _i8.Future>); + _i9.Future>.value(<_i14.Transaction>[]), + ) as _i9.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i9.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i13.UTXO>[]), - ) as _i8.Future>); + returnValue: _i9.Future>.value(<_i14.UTXO>[]), + ) as _i9.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -348,10 +359,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i9.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -363,19 +374,27 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: 0, ) as int); @override + _i7.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#db), + ), + ) as _i7.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -385,7 +404,7 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i9.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -401,27 +420,27 @@ class MockManager extends _i1.Mock implements _i11.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i9.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i9.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -431,33 +450,33 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i9.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i9.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future recoverFromMnemonic({ + _i9.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -474,20 +493,20 @@ class MockManager extends _i1.Mock implements _i11.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i9.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future fullRescan( + _i9.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -499,11 +518,11 @@ class MockManager extends _i1.Mock implements _i11.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future estimateFeeFor( + _i9.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -515,18 +534,18 @@ class MockManager extends _i1.Mock implements _i11.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i9.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -534,7 +553,7 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 f0c334e7e..bc2a1af61 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 @@ -3,20 +3,21 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:async' as _i8; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; import 'package:stackwallet/models/contact.dart' as _i2; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/services/address_book_service.dart' as _i6; +import 'package:stackwallet/services/address_book_service.dart' as _i7; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i13; -import 'package:stackwallet/services/notes_service.dart' as _i12; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/services/locale_service.dart' as _i14; +import 'package:stackwallet/services/notes_service.dart' as _i13; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -70,21 +71,31 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [AddressBookService]. /// /// See the documentation for Mockito's code generation for more information. class MockAddressBookService extends _i1.Mock - implements _i6.AddressBookService { + implements _i7.AddressBookService { @override List<_i2.Contact> get contacts => (super.noSuchMethod( Invocation.getter(#contacts), returnValue: <_i2.Contact>[], ) as List<_i2.Contact>); @override - _i7.Future> get addressBookEntries => (super.noSuchMethod( + _i8.Future> get addressBookEntries => (super.noSuchMethod( Invocation.getter(#addressBookEntries), - returnValue: _i7.Future>.value(<_i2.Contact>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i2.Contact>[]), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -105,13 +116,13 @@ class MockAddressBookService extends _i1.Mock ), ) as _i2.Contact); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value(<_i2.Contact>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i2.Contact>[]), + ) as _i8.Future>); @override bool matches( String? term, @@ -128,33 +139,33 @@ class MockAddressBookService extends _i1.Mock returnValue: false, ) as bool); @override - _i7.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( + _i8.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( Invocation.method( #addContact, [contact], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future editContact(_i2.Contact? editedContact) => + _i8.Future editContact(_i2.Contact? editedContact) => (super.noSuchMethod( Invocation.method( #editContact, [editedContact], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future removeContact(String? id) => (super.noSuchMethod( + _i8.Future removeContact(String? id) => (super.noSuchMethod( Invocation.method( #removeContact, [id], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -162,7 +173,7 @@ class MockAddressBookService extends _i1.Mock returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -190,7 +201,7 @@ class MockAddressBookService extends _i1.Mock /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -218,10 +229,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i10.Coin get coin => (super.noSuchMethod( + _i11.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, - ) as _i10.Coin); + returnValue: _i11.Coin.bitcoin, + ) as _i11.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -254,23 +265,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -280,16 +291,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i5.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i12.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i12.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -309,10 +320,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -324,19 +335,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -346,7 +365,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -362,27 +381,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -392,33 +411,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -435,20 +454,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -460,11 +479,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -476,18 +495,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -495,7 +514,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -515,7 +534,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i12.NotesService { +class MockNotesService extends _i1.Mock implements _i13.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -527,34 +546,34 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i8.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future editOrAddNote({ + _i8.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -567,21 +586,21 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -589,7 +608,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -617,7 +636,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i13.LocaleService { +class MockLocaleService extends _i1.Mock implements _i14.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -629,17 +648,17 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValue: false, ) as bool); @override - _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i8.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -647,7 +666,7 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 f0c11b04a..7d09cecf6 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 @@ -3,18 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i8; +import 'dart:async' as _i8; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; import 'package:stackwallet/models/contact.dart' as _i2; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/services/address_book_service.dart' as _i6; +import 'package:stackwallet/services/address_book_service.dart' as _i7; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -68,21 +69,31 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [AddressBookService]. /// /// See the documentation for Mockito's code generation for more information. class MockAddressBookService extends _i1.Mock - implements _i6.AddressBookService { + implements _i7.AddressBookService { @override List<_i2.Contact> get contacts => (super.noSuchMethod( Invocation.getter(#contacts), returnValue: <_i2.Contact>[], ) as List<_i2.Contact>); @override - _i7.Future> get addressBookEntries => (super.noSuchMethod( + _i8.Future> get addressBookEntries => (super.noSuchMethod( Invocation.getter(#addressBookEntries), - returnValue: _i7.Future>.value(<_i2.Contact>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i2.Contact>[]), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -103,13 +114,13 @@ class MockAddressBookService extends _i1.Mock ), ) as _i2.Contact); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value(<_i2.Contact>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i2.Contact>[]), + ) as _i8.Future>); @override bool matches( String? term, @@ -126,33 +137,33 @@ class MockAddressBookService extends _i1.Mock returnValue: false, ) as bool); @override - _i7.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( + _i8.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( Invocation.method( #addContact, [contact], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future editContact(_i2.Contact? editedContact) => + _i8.Future editContact(_i2.Contact? editedContact) => (super.noSuchMethod( Invocation.method( #editContact, [editedContact], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future removeContact(String? id) => (super.noSuchMethod( + _i8.Future removeContact(String? id) => (super.noSuchMethod( Invocation.method( #removeContact, [id], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -160,7 +171,7 @@ class MockAddressBookService extends _i1.Mock returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -188,7 +199,7 @@ class MockAddressBookService extends _i1.Mock /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -216,10 +227,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i10.Coin get coin => (super.noSuchMethod( + _i11.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, - ) as _i10.Coin); + returnValue: _i11.Coin.bitcoin, + ) as _i11.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -252,23 +263,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -278,16 +289,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i5.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i12.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i12.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -307,10 +318,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -322,19 +333,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -344,7 +363,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -360,27 +379,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -390,33 +409,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -433,20 +452,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -458,11 +477,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -474,18 +493,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -493,7 +512,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index 6328b6881..dced538f1 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -3,19 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i11; +import 'package:stackwallet/models/node_model.dart' as _i12; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i12; -import 'package:stackwallet/services/node_service.dart' as _i10; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i13; +import 'package:stackwallet/services/node_service.dart' as _i11; +import 'package:stackwallet/services/wallets_service.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -72,24 +73,34 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i7.WalletsService { @override - _i7.Future> get walletNames => + _i8.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i8.Future>.value( + {}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i8.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -104,13 +115,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future addExistingStackWallet({ + _i8.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i9.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -124,13 +135,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future addNewWallet({ + _i8.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i9.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -143,46 +154,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i8.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future moveFavorite({ + _i8.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -195,48 +206,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i8.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i8.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future deleteWallet( + _i8.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -248,20 +259,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i8.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -269,7 +280,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -297,7 +308,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i10.NodeService { +class MockNodeService extends _i1.Mock implements _i11.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -307,33 +318,33 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i11.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i12.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override - List<_i11.NodeModel> get nodes => (super.noSuchMethod( + List<_i12.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateDefaults() => (super.noSuchMethod( + _i8.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future setPrimaryNodeFor({ - required _i8.Coin? coin, - required _i11.NodeModel? node, + _i8.Future setPrimaryNodeFor({ + required _i9.Coin? coin, + required _i12.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -346,44 +357,44 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i11.NodeModel? getPrimaryNodeFor({required _i8.Coin? coin}) => + _i12.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i11.NodeModel?); + )) as _i12.NodeModel?); @override - List<_i11.NodeModel> getNodesFor(_i8.Coin? coin) => (super.noSuchMethod( + List<_i12.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override - _i11.NodeModel? getNodeById({required String? id}) => + _i12.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i11.NodeModel?); + )) as _i12.NodeModel?); @override - List<_i11.NodeModel> failoverNodesFor({required _i8.Coin? coin}) => + List<_i12.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override - _i7.Future add( - _i11.NodeModel? node, + _i8.Future add( + _i12.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -396,11 +407,11 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future delete( + _i8.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -412,11 +423,11 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future setEnabledState( + _i8.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -430,12 +441,12 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future edit( - _i11.NodeModel? editedNode, + _i8.Future edit( + _i12.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -448,20 +459,20 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future updateCommunityNodes() => (super.noSuchMethod( + _i8.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -469,7 +480,7 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -497,7 +508,7 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i12.Manager { +class MockManager extends _i1.Mock implements _i13.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -525,10 +536,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i9.Coin.bitcoin, + ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -561,23 +572,23 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -587,16 +598,16 @@ class MockManager extends _i1.Mock implements _i12.Manager { ), ) as _i5.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i13.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i14.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i13.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i14.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -616,10 +627,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -631,19 +642,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -653,7 +672,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -669,27 +688,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -699,33 +718,33 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -742,20 +761,20 @@ class MockManager extends _i1.Mock implements _i12.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -767,11 +786,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -783,18 +802,18 @@ class MockManager extends _i1.Mock implements _i12.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -802,7 +821,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 c0c6f6902..d2448b08c 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 @@ -3,19 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:ui' as _i8; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i12; -import 'package:stackwallet/services/notes_service.dart' as _i11; -import 'package:stackwallet/services/wallets_service.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/services/locale_service.dart' as _i13; +import 'package:stackwallet/services/notes_service.dart' as _i12; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -59,24 +60,34 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i5.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i6.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i6.Future>.value( - {}), - ) as _i6.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -91,13 +102,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -111,13 +122,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #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 addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -130,46 +141,46 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i6.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - 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 addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - 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 removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - 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 moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -182,48 +193,48 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #toIndex: toIndex, }, ), - 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 checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - 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 deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -235,20 +246,20 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -256,7 +267,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -284,7 +295,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -312,10 +323,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -348,23 +359,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i6.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i6.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -374,16 +385,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i4.Balance); @override - _i6.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i6.Future>.value(<_i10.Transaction>[]), - ) as _i6.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i6.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i6.Future>.value(<_i10.UTXO>[]), - ) as _i6.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -403,10 +414,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i6.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -418,19 +429,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -440,7 +459,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -456,27 +475,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -486,33 +505,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i6.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - 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 initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - 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 recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -529,20 +548,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - 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 exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - 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 fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -554,11 +573,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - 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 estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -570,18 +589,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -589,7 +608,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -609,7 +628,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i12.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -621,34 +640,34 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValue: {}, ) as Map); @override - _i6.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -661,21 +680,21 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { #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 deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - 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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -683,7 +702,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -711,7 +730,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i12.LocaleService { +class MockLocaleService extends _i1.Mock implements _i13.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -723,17 +742,17 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValue: false, ) as bool); @override - _i6.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - 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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -741,7 +760,7 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 aef163b0e..29294e496 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 @@ -3,19 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:ui' as _i8; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i12; -import 'package:stackwallet/services/notes_service.dart' as _i11; -import 'package:stackwallet/services/wallets_service.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/services/locale_service.dart' as _i13; +import 'package:stackwallet/services/notes_service.dart' as _i12; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -59,24 +60,34 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i5.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i6.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i6.Future>.value( - {}), - ) as _i6.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -91,13 +102,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -111,13 +122,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #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 addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -130,46 +141,46 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i6.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - 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 addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - 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 removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - 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 moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -182,48 +193,48 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #toIndex: toIndex, }, ), - 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 checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - 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 deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -235,20 +246,20 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -256,7 +267,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -284,7 +295,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -312,10 +323,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -348,23 +359,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i6.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i6.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -374,16 +385,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i4.Balance); @override - _i6.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i6.Future>.value(<_i10.Transaction>[]), - ) as _i6.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i6.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i6.Future>.value(<_i10.UTXO>[]), - ) as _i6.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -403,10 +414,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i6.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -418,19 +429,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -440,7 +459,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -456,27 +475,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -486,33 +505,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i6.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - 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 initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - 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 recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -529,20 +548,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - 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 exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - 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 fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -554,11 +573,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - 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 estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -570,18 +589,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -589,7 +608,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -609,7 +628,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i12.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -621,34 +640,34 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValue: {}, ) as Map); @override - _i6.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -661,21 +680,21 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { #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 deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - 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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -683,7 +702,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -711,7 +730,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i12.LocaleService { +class MockLocaleService extends _i1.Mock implements _i13.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -723,17 +742,17 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValue: false, ) as bool); @override - _i6.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - 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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -741,7 +760,7 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 7f31b64c4..309f855bc 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 @@ -3,19 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:ui' as _i8; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/locale_service.dart' as _i12; -import 'package:stackwallet/services/notes_service.dart' as _i11; -import 'package:stackwallet/services/wallets_service.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/services/locale_service.dart' as _i13; +import 'package:stackwallet/services/notes_service.dart' as _i12; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -59,24 +60,34 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i5.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i6.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i6.Future>.value( - {}), - ) as _i6.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -91,13 +102,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -111,13 +122,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #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 addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -130,46 +141,46 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i6.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - 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 addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - 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 removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - 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 moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -182,48 +193,48 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #toIndex: toIndex, }, ), - 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 checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - 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 deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -235,20 +246,20 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -256,7 +267,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -284,7 +295,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -312,10 +323,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -348,23 +359,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i6.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i6.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -374,16 +385,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i4.Balance); @override - _i6.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i6.Future>.value(<_i10.Transaction>[]), - ) as _i6.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i6.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i6.Future>.value(<_i10.UTXO>[]), - ) as _i6.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -403,10 +414,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i6.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -418,19 +429,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -440,7 +459,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -456,27 +475,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -486,33 +505,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i6.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - 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 initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - 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 recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -529,20 +548,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - 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 exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - 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 fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -554,11 +573,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - 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 estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -570,18 +589,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -589,7 +608,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -609,7 +628,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i12.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -621,34 +640,34 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValue: {}, ) as Map); @override - _i6.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -661,21 +680,21 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { #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 deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - 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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -683,7 +702,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -711,7 +730,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i12.LocaleService { +class MockLocaleService extends _i1.Mock implements _i13.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -723,17 +742,17 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValue: false, ) as bool); @override - _i6.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - 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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -741,7 +760,7 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 56e72d944..e2a067c2a 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 @@ -3,16 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,10 +57,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -87,10 +98,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -123,23 +134,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -149,16 +160,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -178,10 +189,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -193,19 +204,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -215,7 +234,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -231,27 +250,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -261,33 +280,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -304,20 +323,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -329,11 +348,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -345,18 +364,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -364,7 +383,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 a7467d9be..451cd0bbe 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 @@ -3,17 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:ui' as _i8; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/wallets_service.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,24 +58,34 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i5.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i6.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i6.Future>.value( - {}), - ) as _i6.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -89,13 +100,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -109,13 +120,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #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 addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -128,46 +139,46 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i6.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - 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 addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - 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 removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - 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 moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -180,48 +191,48 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #toIndex: toIndex, }, ), - 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 checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - 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 deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -233,20 +244,20 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -254,7 +265,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -282,7 +293,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -310,10 +321,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -346,23 +357,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i6.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i6.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -372,16 +383,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i4.Balance); @override - _i6.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i6.Future>.value(<_i10.Transaction>[]), - ) as _i6.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i6.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i6.Future>.value(<_i10.UTXO>[]), - ) as _i6.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -401,10 +412,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i6.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -416,19 +427,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -438,7 +457,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -454,27 +473,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -484,33 +503,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i6.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - 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 initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - 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 recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -527,20 +546,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - 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 exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - 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 fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -552,11 +571,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - 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 estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -568,18 +587,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -587,7 +606,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 9267a9fba..de4576d78 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 @@ -3,19 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i11; +import 'package:stackwallet/models/node_model.dart' as _i12; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i12; -import 'package:stackwallet/services/node_service.dart' as _i10; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i13; +import 'package:stackwallet/services/node_service.dart' as _i11; +import 'package:stackwallet/services/wallets_service.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -72,24 +73,34 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i7.WalletsService { @override - _i7.Future> get walletNames => + _i8.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i8.Future>.value( + {}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i8.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -104,13 +115,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future addExistingStackWallet({ + _i8.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i9.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -124,13 +135,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future addNewWallet({ + _i8.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i9.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -143,46 +154,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i8.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future moveFavorite({ + _i8.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -195,48 +206,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i8.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i8.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future deleteWallet( + _i8.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -248,20 +259,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i8.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -269,7 +280,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -297,7 +308,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i10.NodeService { +class MockNodeService extends _i1.Mock implements _i11.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -307,33 +318,33 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i11.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i12.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override - List<_i11.NodeModel> get nodes => (super.noSuchMethod( + List<_i12.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateDefaults() => (super.noSuchMethod( + _i8.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future setPrimaryNodeFor({ - required _i8.Coin? coin, - required _i11.NodeModel? node, + _i8.Future setPrimaryNodeFor({ + required _i9.Coin? coin, + required _i12.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -346,44 +357,44 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i11.NodeModel? getPrimaryNodeFor({required _i8.Coin? coin}) => + _i12.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i11.NodeModel?); + )) as _i12.NodeModel?); @override - List<_i11.NodeModel> getNodesFor(_i8.Coin? coin) => (super.noSuchMethod( + List<_i12.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override - _i11.NodeModel? getNodeById({required String? id}) => + _i12.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i11.NodeModel?); + )) as _i12.NodeModel?); @override - List<_i11.NodeModel> failoverNodesFor({required _i8.Coin? coin}) => + List<_i12.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i11.NodeModel>[], - ) as List<_i11.NodeModel>); + returnValue: <_i12.NodeModel>[], + ) as List<_i12.NodeModel>); @override - _i7.Future add( - _i11.NodeModel? node, + _i8.Future add( + _i12.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -396,11 +407,11 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future delete( + _i8.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -412,11 +423,11 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future setEnabledState( + _i8.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -430,12 +441,12 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future edit( - _i11.NodeModel? editedNode, + _i8.Future edit( + _i12.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -448,20 +459,20 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future updateCommunityNodes() => (super.noSuchMethod( + _i8.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -469,7 +480,7 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -497,7 +508,7 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i12.Manager { +class MockManager extends _i1.Mock implements _i13.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -525,10 +536,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i9.Coin.bitcoin, + ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -561,23 +572,23 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -587,16 +598,16 @@ class MockManager extends _i1.Mock implements _i12.Manager { ), ) as _i5.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i13.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i14.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i13.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i14.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -616,10 +627,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -631,19 +642,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -653,7 +672,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -669,27 +688,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -699,33 +718,33 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -742,20 +761,20 @@ class MockManager extends _i1.Mock implements _i12.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -767,11 +786,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -783,18 +802,18 @@ class MockManager extends _i1.Mock implements _i12.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -802,7 +821,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 13aa6edb8..f5c06234e 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 @@ -3,23 +3,24 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i11; +import 'dart:async' as _i9; +import 'dart:ui' as _i12; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i15; +import 'package:stackwallet/models/node_model.dart' as _i16; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i12; -import 'package:stackwallet/services/node_service.dart' as _i14; -import 'package:stackwallet/services/wallets_service.dart' as _i9; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/services/coins/manager.dart' as _i13; +import 'package:stackwallet/services/node_service.dart' as _i15; +import 'package:stackwallet/services/wallets_service.dart' as _i10; +import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i6; + as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -73,9 +74,19 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeSecureStorageInterface_4 extends _i1.SmartFake - implements _i6.SecureStorageInterface { - _FakeSecureStorageInterface_4( +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeSecureStorageInterface_5 extends _i1.SmartFake + implements _i7.SecureStorageInterface { + _FakeSecureStorageInterface_5( Object parent, Invocation parentInvocation, ) : super( @@ -88,13 +99,13 @@ class _FakeSecureStorageInterface_4 extends _i1.SmartFake /// /// See the documentation for Mockito's code generation for more information. class MockBarcodeScannerWrapper extends _i1.Mock - implements _i7.BarcodeScannerWrapper { + implements _i8.BarcodeScannerWrapper { MockBarcodeScannerWrapper() { _i1.throwOnMissingStub(this); } @override - _i8.Future<_i2.ScanResult> scan( + _i9.Future<_i2.ScanResult> scan( {_i2.ScanOptions? options = const _i2.ScanOptions()}) => (super.noSuchMethod( Invocation.method( @@ -102,7 +113,7 @@ class MockBarcodeScannerWrapper extends _i1.Mock [], {#options: options}, ), - returnValue: _i8.Future<_i2.ScanResult>.value(_FakeScanResult_0( + returnValue: _i9.Future<_i2.ScanResult>.value(_FakeScanResult_0( this, Invocation.method( #scan, @@ -110,27 +121,27 @@ class MockBarcodeScannerWrapper extends _i1.Mock {#options: options}, ), )), - ) as _i8.Future<_i2.ScanResult>); + ) as _i9.Future<_i2.ScanResult>); } /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i9.WalletsService { +class MockWalletsService extends _i1.Mock implements _i10.WalletsService { @override - _i8.Future> get walletNames => + _i9.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i8.Future>.value( - {}), - ) as _i8.Future>); + returnValue: _i9.Future>.value( + {}), + ) as _i9.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future renameWallet({ + _i9.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -145,13 +156,13 @@ class MockWalletsService extends _i1.Mock implements _i9.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future addExistingStackWallet({ + _i9.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i10.Coin? coin, + required _i11.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -165,13 +176,13 @@ class MockWalletsService extends _i1.Mock implements _i9.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future addNewWallet({ + _i9.Future addNewWallet({ required String? name, - required _i10.Coin? coin, + required _i11.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -184,46 +195,46 @@ class MockWalletsService extends _i1.Mock implements _i9.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i9.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override - _i8.Future saveFavoriteWalletIds(List? walletIds) => + _i9.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i9.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i9.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future moveFavorite({ + _i9.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -236,48 +247,48 @@ class MockWalletsService extends _i1.Mock implements _i9.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i9.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i9.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future isMnemonicVerified({required String? walletId}) => + _i9.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future setMnemonicVerified({required String? walletId}) => + _i9.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future deleteWallet( + _i9.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -289,20 +300,20 @@ class MockWalletsService extends _i1.Mock implements _i9.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future refreshWallets(bool? shouldNotifyListeners) => + _i9.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -310,7 +321,7 @@ class MockWalletsService extends _i1.Mock implements _i9.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -338,7 +349,7 @@ class MockWalletsService extends _i1.Mock implements _i9.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i12.Manager { +class MockManager extends _i1.Mock implements _i13.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -366,10 +377,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i10.Coin get coin => (super.noSuchMethod( + _i11.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, - ) as _i10.Coin); + returnValue: _i11.Coin.bitcoin, + ) as _i11.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -402,23 +413,23 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i9.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i9.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i9.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -428,16 +439,16 @@ class MockManager extends _i1.Mock implements _i12.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i9.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i13.Transaction>[]), - ) as _i8.Future>); + _i9.Future>.value(<_i14.Transaction>[]), + ) as _i9.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i9.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i13.UTXO>[]), - ) as _i8.Future>); + returnValue: _i9.Future>.value(<_i14.UTXO>[]), + ) as _i9.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -457,10 +468,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i9.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -472,19 +483,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -494,7 +513,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i9.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -510,27 +529,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i9.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i9.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -540,33 +559,33 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i9.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i9.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future recoverFromMnemonic({ + _i9.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -583,20 +602,20 @@ class MockManager extends _i1.Mock implements _i12.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i9.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future fullRescan( + _i9.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -608,11 +627,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future estimateFeeFor( + _i9.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -624,18 +643,18 @@ class MockManager extends _i1.Mock implements _i12.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i9.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -643,7 +662,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -663,43 +682,43 @@ class MockManager extends _i1.Mock implements _i12.Manager { /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i14.NodeService { +class MockNodeService extends _i1.Mock implements _i15.NodeService { @override - _i6.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( + _i7.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_4( + returnValue: _FakeSecureStorageInterface_5( this, Invocation.getter(#secureStorageInterface), ), - ) as _i6.SecureStorageInterface); + ) as _i7.SecureStorageInterface); @override - List<_i15.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i16.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i15.NodeModel>[], - ) as List<_i15.NodeModel>); + returnValue: <_i16.NodeModel>[], + ) as List<_i16.NodeModel>); @override - List<_i15.NodeModel> get nodes => (super.noSuchMethod( + List<_i16.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i15.NodeModel>[], - ) as List<_i15.NodeModel>); + returnValue: <_i16.NodeModel>[], + ) as List<_i16.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateDefaults() => (super.noSuchMethod( + _i9.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future setPrimaryNodeFor({ - required _i10.Coin? coin, - required _i15.NodeModel? node, + _i9.Future setPrimaryNodeFor({ + required _i11.Coin? coin, + required _i16.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -712,44 +731,44 @@ class MockNodeService extends _i1.Mock implements _i14.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i15.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => + _i16.NodeModel? getPrimaryNodeFor({required _i11.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i15.NodeModel?); + )) as _i16.NodeModel?); @override - List<_i15.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( + List<_i16.NodeModel> getNodesFor(_i11.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i15.NodeModel>[], - ) as List<_i15.NodeModel>); + returnValue: <_i16.NodeModel>[], + ) as List<_i16.NodeModel>); @override - _i15.NodeModel? getNodeById({required String? id}) => + _i16.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i15.NodeModel?); + )) as _i16.NodeModel?); @override - List<_i15.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => + List<_i16.NodeModel> failoverNodesFor({required _i11.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i15.NodeModel>[], - ) as List<_i15.NodeModel>); + returnValue: <_i16.NodeModel>[], + ) as List<_i16.NodeModel>); @override - _i8.Future add( - _i15.NodeModel? node, + _i9.Future add( + _i16.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -762,11 +781,11 @@ class MockNodeService extends _i1.Mock implements _i14.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future delete( + _i9.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -778,11 +797,11 @@ class MockNodeService extends _i1.Mock implements _i14.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future setEnabledState( + _i9.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -796,12 +815,12 @@ class MockNodeService extends _i1.Mock implements _i14.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future edit( - _i15.NodeModel? editedNode, + _i9.Future edit( + _i16.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -814,20 +833,20 @@ class MockNodeService extends _i1.Mock implements _i14.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future updateCommunityNodes() => (super.noSuchMethod( + _i9.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -835,7 +854,7 @@ class MockNodeService extends _i1.Mock implements _i14.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 b8c7f3cbd..a486ac2b9 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 @@ -3,16 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,10 +57,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -87,10 +98,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -123,23 +134,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -149,16 +160,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -178,10 +189,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -193,19 +204,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -215,7 +234,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -231,27 +250,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -261,33 +280,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -304,20 +323,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -329,11 +348,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -345,18 +364,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -364,7 +383,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 68f2eeb10..7e1cc0835 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 @@ -3,16 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,10 +57,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -87,10 +98,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -123,23 +134,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -149,16 +160,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -178,10 +189,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -193,19 +204,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -215,7 +234,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -231,27 +250,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -261,33 +280,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -304,20 +323,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -329,11 +348,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -345,18 +364,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -364,7 +383,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 8b60863ab..2d520d669 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 @@ -3,18 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i9; +import 'dart:ui' as _i11; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i7; +import 'package:stackwallet/models/node_model.dart' as _i8; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i11; -import 'package:stackwallet/services/node_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/services/coins/manager.dart' as _i12; +import 'package:stackwallet/services/node_service.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -71,10 +72,20 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i6.NodeService { +class MockNodeService extends _i1.Mock implements _i7.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -84,33 +95,33 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i7.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i8.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override - List<_i7.NodeModel> get nodes => (super.noSuchMethod( + List<_i8.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateDefaults() => (super.noSuchMethod( + _i9.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future setPrimaryNodeFor({ - required _i9.Coin? coin, - required _i7.NodeModel? node, + _i9.Future setPrimaryNodeFor({ + required _i10.Coin? coin, + required _i8.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -123,44 +134,44 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i7.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => + _i8.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i7.NodeModel?); + )) as _i8.NodeModel?); @override - List<_i7.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( + List<_i8.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override - _i7.NodeModel? getNodeById({required String? id}) => + _i8.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i7.NodeModel?); + )) as _i8.NodeModel?); @override - List<_i7.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => + List<_i8.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override - _i8.Future add( - _i7.NodeModel? node, + _i9.Future add( + _i8.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -173,11 +184,11 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future delete( + _i9.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -189,11 +200,11 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future setEnabledState( + _i9.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -207,12 +218,12 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future edit( - _i7.NodeModel? editedNode, + _i9.Future edit( + _i8.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -225,20 +236,20 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future updateCommunityNodes() => (super.noSuchMethod( + _i9.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -246,7 +257,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -274,7 +285,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i11.Manager { +class MockManager extends _i1.Mock implements _i12.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -302,10 +313,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override - _i9.Coin get coin => (super.noSuchMethod( + _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, - ) as _i9.Coin); + returnValue: _i10.Coin.bitcoin, + ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -338,23 +349,23 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i9.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i9.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i9.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -364,16 +375,16 @@ class MockManager extends _i1.Mock implements _i11.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i9.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i12.Transaction>[]), - ) as _i8.Future>); + _i9.Future>.value(<_i13.Transaction>[]), + ) as _i9.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i9.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i12.UTXO>[]), - ) as _i8.Future>); + returnValue: _i9.Future>.value(<_i13.UTXO>[]), + ) as _i9.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -393,10 +404,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i9.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -408,19 +419,27 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -430,7 +449,7 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i9.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -446,27 +465,27 @@ class MockManager extends _i1.Mock implements _i11.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i9.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i9.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -476,33 +495,33 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i9.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i9.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future recoverFromMnemonic({ + _i9.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -519,20 +538,20 @@ class MockManager extends _i1.Mock implements _i11.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i9.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future fullRescan( + _i9.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -544,11 +563,11 @@ class MockManager extends _i1.Mock implements _i11.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future estimateFeeFor( + _i9.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -560,18 +579,18 @@ class MockManager extends _i1.Mock implements _i11.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i9.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -579,7 +598,7 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 09d59deb2..f635b4556 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 @@ -3,18 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i9; +import 'dart:ui' as _i11; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i7; +import 'package:stackwallet/models/node_model.dart' as _i8; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i11; -import 'package:stackwallet/services/node_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/services/coins/manager.dart' as _i12; +import 'package:stackwallet/services/node_service.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -71,10 +72,20 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i6.NodeService { +class MockNodeService extends _i1.Mock implements _i7.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -84,33 +95,33 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i7.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i8.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override - List<_i7.NodeModel> get nodes => (super.noSuchMethod( + List<_i8.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateDefaults() => (super.noSuchMethod( + _i9.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future setPrimaryNodeFor({ - required _i9.Coin? coin, - required _i7.NodeModel? node, + _i9.Future setPrimaryNodeFor({ + required _i10.Coin? coin, + required _i8.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -123,44 +134,44 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i7.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => + _i8.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i7.NodeModel?); + )) as _i8.NodeModel?); @override - List<_i7.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( + List<_i8.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override - _i7.NodeModel? getNodeById({required String? id}) => + _i8.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i7.NodeModel?); + )) as _i8.NodeModel?); @override - List<_i7.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => + List<_i8.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i7.NodeModel>[], - ) as List<_i7.NodeModel>); + returnValue: <_i8.NodeModel>[], + ) as List<_i8.NodeModel>); @override - _i8.Future add( - _i7.NodeModel? node, + _i9.Future add( + _i8.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -173,11 +184,11 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future delete( + _i9.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -189,11 +200,11 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future setEnabledState( + _i9.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -207,12 +218,12 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future edit( - _i7.NodeModel? editedNode, + _i9.Future edit( + _i8.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -225,20 +236,20 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future updateCommunityNodes() => (super.noSuchMethod( + _i9.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -246,7 +257,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -274,7 +285,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i11.Manager { +class MockManager extends _i1.Mock implements _i12.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -302,10 +313,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override - _i9.Coin get coin => (super.noSuchMethod( + _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, - ) as _i9.Coin); + returnValue: _i10.Coin.bitcoin, + ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -338,23 +349,23 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i9.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i9.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i9.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -364,16 +375,16 @@ class MockManager extends _i1.Mock implements _i11.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i9.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i12.Transaction>[]), - ) as _i8.Future>); + _i9.Future>.value(<_i13.Transaction>[]), + ) as _i9.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i9.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i12.UTXO>[]), - ) as _i8.Future>); + returnValue: _i9.Future>.value(<_i13.UTXO>[]), + ) as _i9.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -393,10 +404,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i9.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -408,19 +419,27 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -430,7 +449,7 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i9.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -446,27 +465,27 @@ class MockManager extends _i1.Mock implements _i11.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i9.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i9.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -476,33 +495,33 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i9.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i9.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future recoverFromMnemonic({ + _i9.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -519,20 +538,20 @@ class MockManager extends _i1.Mock implements _i11.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i9.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future fullRescan( + _i9.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -544,11 +563,11 @@ class MockManager extends _i1.Mock implements _i11.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future estimateFeeFor( + _i9.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -560,18 +579,18 @@ class MockManager extends _i1.Mock implements _i11.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i9.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -579,7 +598,7 @@ class MockManager extends _i1.Mock implements _i11.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 a958461b8..bfd751068 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 @@ -3,16 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,10 +57,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -87,10 +98,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -123,23 +134,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -149,16 +160,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -178,10 +189,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -193,19 +204,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -215,7 +234,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -231,27 +250,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -261,33 +280,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -304,20 +323,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -329,11 +348,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -345,18 +364,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -364,7 +383,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 284065eba..c8d4b99bc 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 @@ -3,16 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,10 +57,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -87,10 +98,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -123,23 +134,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -149,16 +160,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -178,10 +189,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -193,19 +204,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -215,7 +234,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -231,27 +250,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -261,33 +280,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -304,20 +323,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -329,11 +348,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -345,18 +364,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -364,7 +383,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 24da7d388..28012ebb0 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 @@ -3,17 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:ui' as _i8; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/wallets_service.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,24 +58,34 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i5.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i6.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i6.Future>.value( - {}), - ) as _i6.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -89,13 +100,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -109,13 +120,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #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 addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -128,46 +139,46 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i6.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - 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 addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - 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 removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - 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 moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -180,48 +191,48 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #toIndex: toIndex, }, ), - 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 checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - 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 deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -233,20 +244,20 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -254,7 +265,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -282,7 +293,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -310,10 +321,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -346,23 +357,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i6.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i6.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -372,16 +383,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i4.Balance); @override - _i6.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i6.Future>.value(<_i10.Transaction>[]), - ) as _i6.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i6.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i6.Future>.value(<_i10.UTXO>[]), - ) as _i6.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -401,10 +412,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i6.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -416,19 +427,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -438,7 +457,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -454,27 +473,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -484,33 +503,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i6.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - 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 initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - 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 recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -527,20 +546,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - 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 exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - 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 fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -552,11 +571,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - 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 estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -568,18 +587,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -587,7 +606,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 0bf926563..90e176aff 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 @@ -3,22 +3,23 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i14; +import 'dart:async' as _i9; +import 'dart:ui' as _i15; -import 'package:local_auth/auth_strings.dart' as _i11; -import 'package:local_auth/local_auth.dart' as _i10; +import 'package:isar/isar.dart' as _i6; +import 'package:local_auth/auth_strings.dart' as _i12; +import 'package:local_auth/local_auth.dart' as _i11; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i8; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i15; -import 'package:stackwallet/services/wallets_service.dart' as _i13; -import 'package:stackwallet/utilities/biometrics.dart' as _i12; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/services/coins/manager.dart' as _i16; +import 'package:stackwallet/services/wallets_service.dart' as _i14; +import 'package:stackwallet/utilities/biometrics.dart' as _i13; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; import 'package:stackwallet/utilities/prefs.dart' as _i2; // ignore_for_file: type=lint @@ -73,10 +74,20 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -105,15 +116,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { ), ) as _i2.Prefs); @override - List<_i7.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i8.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i7.ElectrumXNode>[], - ) as List<_i7.ElectrumXNode>); + returnValue: <_i8.ElectrumXNode>[], + ) as List<_i8.ElectrumXNode>); @override - _i8.Future> getAnonymitySet({ + _i9.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i9.Coin? coin, + required _i10.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -126,8 +137,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -145,9 +156,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { returnValue: '', ) as String); @override - _i8.Future> getTransaction({ + _i9.Future> getTransaction({ required String? txHash, - required _i9.Coin? coin, + required _i10.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -161,11 +172,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i8.Future> getUsedCoinSerials({ - required _i9.Coin? coin, + _i9.Future> getUsedCoinSerials({ + required _i10.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -177,43 +188,43 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override - _i8.Future clearSharedTransactionCache({required _i9.Coin? coin}) => + _i9.Future clearSharedTransactionCache({required _i10.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); } /// A class which mocks [LocalAuthentication]. /// /// See the documentation for Mockito's code generation for more information. class MockLocalAuthentication extends _i1.Mock - implements _i10.LocalAuthentication { + implements _i11.LocalAuthentication { MockLocalAuthentication() { _i1.throwOnMissingStub(this); } @override - _i8.Future get canCheckBiometrics => (super.noSuchMethod( + _i9.Future get canCheckBiometrics => (super.noSuchMethod( Invocation.getter(#canCheckBiometrics), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future authenticateWithBiometrics({ + _i9.Future authenticateWithBiometrics({ required String? localizedReason, bool? useErrorDialogs = true, bool? stickyAuth = false, - _i11.AndroidAuthMessages? androidAuthStrings = - const _i11.AndroidAuthMessages(), - _i11.IOSAuthMessages? iOSAuthStrings = const _i11.IOSAuthMessages(), + _i12.AndroidAuthMessages? androidAuthStrings = + const _i12.AndroidAuthMessages(), + _i12.IOSAuthMessages? iOSAuthStrings = const _i12.IOSAuthMessages(), bool? sensitiveTransaction = true, }) => (super.noSuchMethod( @@ -229,16 +240,16 @@ class MockLocalAuthentication extends _i1.Mock #sensitiveTransaction: sensitiveTransaction, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future authenticate({ + _i9.Future authenticate({ required String? localizedReason, bool? useErrorDialogs = true, bool? stickyAuth = false, - _i11.AndroidAuthMessages? androidAuthStrings = - const _i11.AndroidAuthMessages(), - _i11.IOSAuthMessages? iOSAuthStrings = const _i11.IOSAuthMessages(), + _i12.AndroidAuthMessages? androidAuthStrings = + const _i12.AndroidAuthMessages(), + _i12.IOSAuthMessages? iOSAuthStrings = const _i12.IOSAuthMessages(), bool? sensitiveTransaction = true, bool? biometricOnly = false, }) => @@ -256,46 +267,46 @@ class MockLocalAuthentication extends _i1.Mock #biometricOnly: biometricOnly, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future stopAuthentication() => (super.noSuchMethod( + _i9.Future stopAuthentication() => (super.noSuchMethod( Invocation.method( #stopAuthentication, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future isDeviceSupported() => (super.noSuchMethod( + _i9.Future isDeviceSupported() => (super.noSuchMethod( Invocation.method( #isDeviceSupported, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future> getAvailableBiometrics() => + _i9.Future> getAvailableBiometrics() => (super.noSuchMethod( Invocation.method( #getAvailableBiometrics, [], ), returnValue: - _i8.Future>.value(<_i10.BiometricType>[]), - ) as _i8.Future>); + _i9.Future>.value(<_i11.BiometricType>[]), + ) as _i9.Future>); } /// A class which mocks [Biometrics]. /// /// See the documentation for Mockito's code generation for more information. -class MockBiometrics extends _i1.Mock implements _i12.Biometrics { +class MockBiometrics extends _i1.Mock implements _i13.Biometrics { MockBiometrics() { _i1.throwOnMissingStub(this); } @override - _i8.Future authenticate({ + _i9.Future authenticate({ required String? cancelButtonText, required String? localizedReason, required String? title, @@ -310,28 +321,28 @@ class MockBiometrics extends _i1.Mock implements _i12.Biometrics { #title: title, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); } /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i13.WalletsService { +class MockWalletsService extends _i1.Mock implements _i14.WalletsService { @override - _i8.Future> get walletNames => + _i9.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i8.Future>.value( - {}), - ) as _i8.Future>); + returnValue: _i9.Future>.value( + {}), + ) as _i9.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future renameWallet({ + _i9.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -346,13 +357,13 @@ class MockWalletsService extends _i1.Mock implements _i13.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future addExistingStackWallet({ + _i9.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i9.Coin? coin, + required _i10.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -366,13 +377,13 @@ class MockWalletsService extends _i1.Mock implements _i13.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future addNewWallet({ + _i9.Future addNewWallet({ required String? name, - required _i9.Coin? coin, + required _i10.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -385,46 +396,46 @@ class MockWalletsService extends _i1.Mock implements _i13.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i9.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override - _i8.Future saveFavoriteWalletIds(List? walletIds) => + _i9.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i9.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i9.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future moveFavorite({ + _i9.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -437,48 +448,48 @@ class MockWalletsService extends _i1.Mock implements _i13.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i9.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i9.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future isMnemonicVerified({required String? walletId}) => + _i9.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future setMnemonicVerified({required String? walletId}) => + _i9.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future deleteWallet( + _i9.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -490,20 +501,20 @@ class MockWalletsService extends _i1.Mock implements _i13.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future refreshWallets(bool? shouldNotifyListeners) => + _i9.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -511,7 +522,7 @@ class MockWalletsService extends _i1.Mock implements _i13.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -539,7 +550,7 @@ class MockWalletsService extends _i1.Mock implements _i13.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i15.Manager { +class MockManager extends _i1.Mock implements _i16.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -567,10 +578,10 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: false, ) as bool); @override - _i9.Coin get coin => (super.noSuchMethod( + _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, - ) as _i9.Coin); + returnValue: _i10.Coin.bitcoin, + ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -603,23 +614,23 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i9.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i9.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i9.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -629,16 +640,16 @@ class MockManager extends _i1.Mock implements _i15.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i9.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i16.Transaction>[]), - ) as _i8.Future>); + _i9.Future>.value(<_i17.Transaction>[]), + ) as _i9.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i9.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i16.UTXO>[]), - ) as _i8.Future>); + returnValue: _i9.Future>.value(<_i17.UTXO>[]), + ) as _i9.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -658,10 +669,10 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i9.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -673,19 +684,27 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -695,7 +714,7 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i9.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -711,27 +730,27 @@ class MockManager extends _i1.Mock implements _i15.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i9.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i9.Future.value(''), + ) as _i9.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i9.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -741,33 +760,33 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i9.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i9.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i9.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future recoverFromMnemonic({ + _i9.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -784,20 +803,20 @@ class MockManager extends _i1.Mock implements _i15.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i9.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future fullRescan( + _i9.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -809,11 +828,11 @@ class MockManager extends _i1.Mock implements _i15.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i8.Future estimateFeeFor( + _i9.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -825,18 +844,18 @@ class MockManager extends _i1.Mock implements _i15.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i9.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -844,7 +863,7 @@ class MockManager extends _i1.Mock implements _i15.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 487f2f2bf..8472c70ab 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 @@ -3,17 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; -import 'dart:ui' as _i8; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/wallets_service.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i10; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,24 +58,34 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i5.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i6.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i6.Future>.value( - {}), - ) as _i6.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -89,13 +100,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -109,13 +120,13 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #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 addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i7.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -128,46 +139,46 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i6.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - 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 addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - 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 removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - 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 moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -180,48 +191,48 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { #toIndex: toIndex, }, ), - 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 checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i6.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - 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 deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -233,20 +244,20 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [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(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -254,7 +265,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -282,7 +293,7 @@ class MockWalletsService extends _i1.Mock implements _i5.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i10.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -310,10 +321,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -346,23 +357,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i6.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i6.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -372,16 +383,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i4.Balance); @override - _i6.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i6.Future>.value(<_i10.Transaction>[]), - ) as _i6.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i6.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i6.Future>.value(<_i10.UTXO>[]), - ) as _i6.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -401,10 +412,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i6.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -416,19 +427,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -438,7 +457,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i6.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -454,27 +473,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i6.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i6.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -484,33 +503,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i6.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i6.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - 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 initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - 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 recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -527,20 +546,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - 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 exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - 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 fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -552,11 +571,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - 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 estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -568,18 +587,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i6.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -587,7 +606,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 31bda1f65..2b52ffd37 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 @@ -3,18 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/services/locale_service.dart' as _i11; -import 'package:stackwallet/services/notes_service.dart' as _i10; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -58,10 +59,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -89,10 +100,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -125,23 +136,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -151,16 +162,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -180,10 +191,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -195,19 +206,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -217,7 +236,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -233,27 +252,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -263,33 +282,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -306,20 +325,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -331,11 +350,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -347,18 +366,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -366,7 +385,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -386,7 +405,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i10.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -398,34 +417,34 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i8.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future editOrAddNote({ + _i8.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -438,21 +457,21 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -460,7 +479,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -488,7 +507,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i11.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -500,17 +519,17 @@ class MockLocaleService extends _i1.Mock implements _i11.LocaleService { returnValue: false, ) as bool); @override - _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i8.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -518,7 +537,7 @@ class MockLocaleService extends _i1.Mock implements _i11.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 161b63e1d..0c514d22b 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 @@ -3,17 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/services/notes_service.dart' as _i10; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,10 +58,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -88,10 +99,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -124,23 +135,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -150,16 +161,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -179,10 +190,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -194,19 +205,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -216,7 +235,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -232,27 +251,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -262,33 +281,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -305,20 +324,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -330,11 +349,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -346,18 +365,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -365,7 +384,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -385,7 +404,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i10.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -397,34 +416,34 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i8.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future editOrAddNote({ + _i8.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -437,21 +456,21 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -459,7 +478,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 7172f3e29..5268ecf10 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 @@ -3,16 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,10 +57,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -87,10 +98,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -123,23 +134,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -149,16 +160,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -178,10 +189,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -193,19 +204,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -215,7 +234,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -231,27 +250,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -261,33 +280,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -304,20 +323,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -329,11 +348,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -345,18 +364,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -364,7 +383,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 ba206a8c6..f10b663e0 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 @@ -3,19 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i11; +import 'dart:async' as _i8; +import 'dart:ui' as _i12; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; +import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i8; -import 'package:stackwallet/services/notes_service.dart' as _i12; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/notes_service.dart' as _i13; +import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -69,17 +70,27 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } +class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { + _FakeIsar_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [BarcodeScannerWrapper]. /// /// See the documentation for Mockito's code generation for more information. class MockBarcodeScannerWrapper extends _i1.Mock - implements _i6.BarcodeScannerWrapper { + implements _i7.BarcodeScannerWrapper { MockBarcodeScannerWrapper() { _i1.throwOnMissingStub(this); } @override - _i7.Future<_i2.ScanResult> scan( + _i8.Future<_i2.ScanResult> scan( {_i2.ScanOptions? options = const _i2.ScanOptions()}) => (super.noSuchMethod( Invocation.method( @@ -87,7 +98,7 @@ class MockBarcodeScannerWrapper extends _i1.Mock [], {#options: options}, ), - returnValue: _i7.Future<_i2.ScanResult>.value(_FakeScanResult_0( + returnValue: _i8.Future<_i2.ScanResult>.value(_FakeScanResult_0( this, Invocation.method( #scan, @@ -95,13 +106,13 @@ class MockBarcodeScannerWrapper extends _i1.Mock {#options: options}, ), )), - ) as _i7.Future<_i2.ScanResult>); + ) as _i8.Future<_i2.ScanResult>); } /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i8.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -129,10 +140,10 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: false, ) as bool); @override - _i9.Coin get coin => (super.noSuchMethod( + _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, - ) as _i9.Coin); + returnValue: _i10.Coin.bitcoin, + ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -165,23 +176,23 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -191,16 +202,16 @@ class MockManager extends _i1.Mock implements _i8.Manager { ), ) as _i5.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i10.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i11.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i10.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i11.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -220,10 +231,10 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -235,19 +246,27 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: 0, ) as int); @override + _i6.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_4( + this, + Invocation.getter(#db), + ), + ) as _i6.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -257,7 +276,7 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -273,27 +292,27 @@ class MockManager extends _i1.Mock implements _i8.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -303,33 +322,33 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -346,20 +365,20 @@ class MockManager extends _i1.Mock implements _i8.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -371,11 +390,11 @@ class MockManager extends _i1.Mock implements _i8.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -387,18 +406,18 @@ class MockManager extends _i1.Mock implements _i8.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -406,7 +425,7 @@ class MockManager extends _i1.Mock implements _i8.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -426,7 +445,7 @@ class MockManager extends _i1.Mock implements _i8.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i12.NotesService { +class MockNotesService extends _i1.Mock implements _i13.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -438,34 +457,34 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i8.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future editOrAddNote({ + _i8.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -478,21 +497,21 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -500,7 +519,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 ae6a2d1f9..ef21b7bca 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 @@ -3,18 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; +import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i5; -import 'package:stackwallet/services/locale_service.dart' as _i11; -import 'package:stackwallet/services/notes_service.dart' as _i10; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; +import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -58,10 +59,20 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } +class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { + _FakeIsar_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i5.Manager { +class MockManager extends _i1.Mock implements _i6.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -89,10 +100,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i6.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i6.Coin.bitcoin, - ) as _i6.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -125,23 +136,23 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i8.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -151,16 +162,16 @@ class MockManager extends _i1.Mock implements _i5.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i8.Transaction>[]), - ) as _i7.Future>); + _i8.Future>.value(<_i9.Transaction>[]), + ) as _i8.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i8.UTXO>[]), - ) as _i7.Future>); + returnValue: _i8.Future>.value(<_i9.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -180,10 +191,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -195,19 +206,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: 0, ) as int); @override + _i5.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_3( + this, + Invocation.getter(#db), + ), + ) as _i5.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -217,7 +236,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -233,27 +252,27 @@ class MockManager extends _i1.Mock implements _i5.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -263,33 +282,33 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -306,20 +325,20 @@ class MockManager extends _i1.Mock implements _i5.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -331,11 +350,11 @@ class MockManager extends _i1.Mock implements _i5.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -347,18 +366,18 @@ class MockManager extends _i1.Mock implements _i5.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -366,7 +385,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -386,7 +405,7 @@ class MockManager extends _i1.Mock implements _i5.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i10.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -398,34 +417,34 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i8.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i7.Future editOrAddNote({ + _i8.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -438,21 +457,21 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -460,7 +479,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -488,7 +507,7 @@ class MockNotesService extends _i1.Mock implements _i10.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i11.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -500,17 +519,17 @@ class MockLocaleService extends _i1.Mock implements _i11.LocaleService { returnValue: false, ) as bool); @override - _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i8.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -518,7 +537,7 @@ class MockLocaleService extends _i1.Mock implements _i11.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index d288b1992..cea5d0013 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -6,17 +6,17 @@ import 'dart:async' as _i10; import 'package:decimal/decimal.dart' as _i8; -import 'package:isar/isar.dart' as _i2; +import 'package:isar/isar.dart' as _i7; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/balance.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; +import 'package:stackwallet/models/balance.dart' as _i6; import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/lelantus_coin.dart' as _i13; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i4; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i3; import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i9; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i3; + as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; // ignore_for_file: type=lint @@ -30,8 +30,9 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeIsar_0 extends _i1.SmartFake implements _i2.Isar { - _FakeIsar_0( +class _FakeTransactionNotificationTracker_0 extends _i1.SmartFake + implements _i2.TransactionNotificationTracker { + _FakeTransactionNotificationTracker_0( Object parent, Invocation parentInvocation, ) : super( @@ -40,9 +41,8 @@ class _FakeIsar_0 extends _i1.SmartFake implements _i2.Isar { ); } -class _FakeTransactionNotificationTracker_1 extends _i1.SmartFake - implements _i3.TransactionNotificationTracker { - _FakeTransactionNotificationTracker_1( +class _FakeFeeObject_1 extends _i1.SmartFake implements _i3.FeeObject { + _FakeFeeObject_1( Object parent, Invocation parentInvocation, ) : super( @@ -51,8 +51,8 @@ class _FakeTransactionNotificationTracker_1 extends _i1.SmartFake ); } -class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { - _FakeFeeObject_2( +class _FakeElectrumX_2 extends _i1.SmartFake implements _i4.ElectrumX { + _FakeElectrumX_2( Object parent, Invocation parentInvocation, ) : super( @@ -61,8 +61,9 @@ class _FakeFeeObject_2 extends _i1.SmartFake implements _i4.FeeObject { ); } -class _FakeElectrumX_3 extends _i1.SmartFake implements _i5.ElectrumX { - _FakeElectrumX_3( +class _FakeCachedElectrumX_3 extends _i1.SmartFake + implements _i5.CachedElectrumX { + _FakeCachedElectrumX_3( Object parent, Invocation parentInvocation, ) : super( @@ -71,9 +72,8 @@ class _FakeElectrumX_3 extends _i1.SmartFake implements _i5.ElectrumX { ); } -class _FakeCachedElectrumX_4 extends _i1.SmartFake - implements _i6.CachedElectrumX { - _FakeCachedElectrumX_4( +class _FakeBalance_4 extends _i1.SmartFake implements _i6.Balance { + _FakeBalance_4( Object parent, Invocation parentInvocation, ) : super( @@ -82,8 +82,8 @@ class _FakeCachedElectrumX_4 extends _i1.SmartFake ); } -class _FakeBalance_5 extends _i1.SmartFake implements _i7.Balance { - _FakeBalance_5( +class _FakeIsar_5 extends _i1.SmartFake implements _i7.Isar { + _FakeIsar_5( Object parent, Invocation parentInvocation, ) : super( @@ -119,31 +119,15 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: null, ); @override - _i2.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_0( - this, - Invocation.getter(#isar), - ), - ) as _i2.Isar); - @override - set isar(_i2.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override - _i3.TransactionNotificationTracker get txTracker => (super.noSuchMethod( + _i2.TransactionNotificationTracker get txTracker => (super.noSuchMethod( Invocation.getter(#txTracker), - returnValue: _FakeTransactionNotificationTracker_1( + returnValue: _FakeTransactionNotificationTracker_0( this, Invocation.getter(#txTracker), ), - ) as _i3.TransactionNotificationTracker); + ) as _i2.TransactionNotificationTracker); @override - set txTracker(_i3.TransactionNotificationTracker? _txTracker) => + set txTracker(_i2.TransactionNotificationTracker? _txTracker) => super.noSuchMethod( Invocation.setter( #txTracker, @@ -239,13 +223,13 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValue: _i10.Future.value(0), ) as _i10.Future); @override - _i10.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i10.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i10.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i10.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i10.Future<_i4.FeeObject>); + ) as _i10.Future<_i3.FeeObject>); @override _i10.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), @@ -280,21 +264,21 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValue: false, ) as bool); @override - _i5.ElectrumX get electrumXClient => (super.noSuchMethod( + _i4.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_3( + returnValue: _FakeElectrumX_2( this, Invocation.getter(#electrumXClient), ), - ) as _i5.ElectrumX); + ) as _i4.ElectrumX); @override - _i6.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i5.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_4( + returnValue: _FakeCachedElectrumX_3( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i6.CachedElectrumX); + ) as _i5.CachedElectrumX); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -316,21 +300,21 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValue: 0, ) as int); @override - _i7.Balance get balance => (super.noSuchMethod( + _i6.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_5( + returnValue: _FakeBalance_4( this, Invocation.getter(#balance), ), - ) as _i7.Balance); + ) as _i6.Balance); @override - _i7.Balance get balancePrivate => (super.noSuchMethod( + _i6.Balance get balancePrivate => (super.noSuchMethod( Invocation.getter(#balancePrivate), - returnValue: _FakeBalance_5( + returnValue: _FakeBalance_4( this, Invocation.getter(#balancePrivate), ), - ) as _i7.Balance); + ) as _i6.Balance); @override _i10.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), @@ -343,6 +327,14 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { _i10.Future>.value(<_i12.Transaction>[]), ) as _i10.Future>); @override + _i7.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#isarInstance), + ), + ) as _i7.Isar); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -352,6 +344,14 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: null, ); @override + _i7.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_5( + this, + Invocation.getter(#isar), + ), + ) as _i7.Isar); + @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( #validateAddress, @@ -832,7 +832,7 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { ) as _i10.Future>>); @override _i10.Future> getJMintTransactions( - _i6.CachedElectrumX? cachedClient, + _i5.CachedElectrumX? cachedClient, List? transactions, _i11.Coin? coin, ) => @@ -885,12 +885,161 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { ), ) as _i8.Decimal); @override - _i10.Future updateStoredChainHeight({required int? newHeight}) => + void initCache( + String? walletId, + _i11.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i10.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i10.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i10.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( - #updateStoredChainHeight, + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override + _i6.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, [], - {#newHeight: newHeight}, + ), + returnValue: _FakeBalance_4( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i6.Balance); + @override + _i10.Future updateCachedBalance(_i6.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override + _i6.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_4( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i6.Balance); + @override + _i10.Future updateCachedBalanceSecondary(_i6.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override + _i10.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i10.Future.value(false), + ) as _i10.Future); + @override + _i10.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i10.Future.value(false), + ) as _i10.Future); + @override + void initFiroHive(String? walletId) => super.noSuchMethod( + Invocation.method( + #initFiroHive, + [walletId], + ), + returnValueForMissingStub: null, + ); + @override + _i10.Future firoUpdateJIndex(List? jIndex) => + (super.noSuchMethod( + Invocation.method( + #firoUpdateJIndex, + [jIndex], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override + _i10.Future firoUpdateLelantusCoins(List? lelantusCoins) => + (super.noSuchMethod( + Invocation.method( + #firoUpdateLelantusCoins, + [lelantusCoins], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override + _i10.Future firoUpdateMintIndex(int? mintIndex) => (super.noSuchMethod( + Invocation.method( + #firoUpdateMintIndex, + [mintIndex], ), returnValue: _i10.Future.value(), returnValueForMissingStub: _i10.Future.value(), @@ -900,13 +1049,13 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 0def83807..599e59c30 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -8,14 +8,14 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i8; +import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; -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/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 _i21; import 'package:stackwallet/models/node_model.dart' as _i23; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; @@ -94,8 +94,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { - _FakeIsar_5( +class _FakeFeeObject_5 extends _i1.SmartFake implements _i8.FeeObject { + _FakeFeeObject_5( Object parent, Invocation parentInvocation, ) : super( @@ -104,8 +104,8 @@ class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { ); } -class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_6( +class _FakeElectrumX_6 extends _i1.SmartFake implements _i9.ElectrumX { + _FakeElectrumX_6( Object parent, Invocation parentInvocation, ) : super( @@ -114,8 +114,9 @@ class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_7( +class _FakeCachedElectrumX_7 extends _i1.SmartFake + implements _i10.CachedElectrumX { + _FakeCachedElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -124,9 +125,8 @@ class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { ); } -class _FakeCachedElectrumX_8 extends _i1.SmartFake - implements _i11.CachedElectrumX { - _FakeCachedElectrumX_8( +class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { + _FakeBalance_8( Object parent, Invocation parentInvocation, ) : super( @@ -135,8 +135,8 @@ class _FakeCachedElectrumX_8 extends _i1.SmartFake ); } -class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { - _FakeBalance_9( +class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { + _FakeIsar_9( Object parent, Invocation parentInvocation, ) : super( @@ -145,8 +145,7 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeElectrumXNode_10 extends _i1.SmartFake - implements _i10.ElectrumXNode { +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i9.ElectrumXNode { _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, @@ -669,22 +668,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i8.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_5( - this, - Invocation.getter(#isar), - ), - ) as _i8.Isar); - @override - set isar(_i8.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override bool get isActive => (super.noSuchMethod( Invocation.getter(#isActive), returnValue: false, @@ -742,13 +725,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValue: false, ) as bool); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -811,29 +794,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i10.ElectrumX get electrumXClient => (super.noSuchMethod( + _i9.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_7( + returnValue: _FakeElectrumX_6( this, Invocation.getter(#electrumXClient), ), - ) as _i10.ElectrumX); + ) as _i9.ElectrumX); @override - _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i10.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_8( + returnValue: _FakeCachedElectrumX_7( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i11.CachedElectrumX); + ) as _i10.CachedElectrumX); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); + @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -844,6 +835,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override + _i12.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isar), + ), + ) as _i12.Isar); + @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, @@ -853,17 +852,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future updateStoredChainHeight({required int? newHeight}) => - (super.noSuchMethod( - Invocation.method( - #updateStoredChainHeight, - [], - {#newHeight: newHeight}, - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); - @override _i20.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( @@ -1029,20 +1017,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), - returnValue: - _i17.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( + returnValue: _i17.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i17.Future<_i10.ElectrumXNode>); + ) as _i17.Future<_i9.ElectrumXNode>); @override _i17.Future addDerivation({ required int? chain, @@ -1260,6 +1247,129 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + void initCache( + String? walletId, + _i16.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i17.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i17.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i17.Future updateCachedIsFavorite(bool? isFavorite) => + (super.noSuchMethod( + Invocation.method( + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i11.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i11.Balance); + @override + _i17.Future updateCachedBalance(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i11.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i11.Balance); + @override + _i17.Future updateCachedBalanceSecondary(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); + @override + _i17.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [LocaleService]. @@ -1591,13 +1701,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1609,13 +1719,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1661,6 +1771,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override + _i12.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#db), + ), + ) as _i12.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -1899,13 +2017,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1917,13 +2035,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1974,6 +2092,14 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); + @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 47681f0c0..aca5e11a8 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 @@ -8,13 +8,13 @@ import 'dart:ui' as _i18; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i8; +import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; -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/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 _i20; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i19; import 'package:stackwallet/services/coins/coin_service.dart' as _i13; import 'package:stackwallet/services/coins/manager.dart' as _i6; @@ -90,8 +90,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { - _FakeIsar_5( +class _FakeFeeObject_5 extends _i1.SmartFake implements _i8.FeeObject { + _FakeFeeObject_5( Object parent, Invocation parentInvocation, ) : super( @@ -100,8 +100,8 @@ class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { ); } -class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_6( +class _FakeElectrumX_6 extends _i1.SmartFake implements _i9.ElectrumX { + _FakeElectrumX_6( Object parent, Invocation parentInvocation, ) : super( @@ -110,8 +110,9 @@ class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_7( +class _FakeCachedElectrumX_7 extends _i1.SmartFake + implements _i10.CachedElectrumX { + _FakeCachedElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -120,9 +121,8 @@ class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { ); } -class _FakeCachedElectrumX_8 extends _i1.SmartFake - implements _i11.CachedElectrumX { - _FakeCachedElectrumX_8( +class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { + _FakeBalance_8( Object parent, Invocation parentInvocation, ) : super( @@ -131,8 +131,8 @@ class _FakeCachedElectrumX_8 extends _i1.SmartFake ); } -class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { - _FakeBalance_9( +class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { + _FakeIsar_9( Object parent, Invocation parentInvocation, ) : super( @@ -141,8 +141,7 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeElectrumXNode_10 extends _i1.SmartFake - implements _i10.ElectrumXNode { +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i9.ElectrumXNode { _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, @@ -654,22 +653,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i8.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_5( - this, - Invocation.getter(#isar), - ), - ) as _i8.Isar); - @override - set isar(_i8.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override bool get isActive => (super.noSuchMethod( Invocation.getter(#isActive), returnValue: false, @@ -727,13 +710,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValue: false, ) as bool); @override - _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i9.FeeObject>); + ) as _i16.Future<_i8.FeeObject>); @override _i16.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -796,29 +779,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i10.ElectrumX get electrumXClient => (super.noSuchMethod( + _i9.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_7( + returnValue: _FakeElectrumX_6( this, Invocation.getter(#electrumXClient), ), - ) as _i10.ElectrumX); + ) as _i9.ElectrumX); @override - _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i10.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_8( + returnValue: _FakeCachedElectrumX_7( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i11.CachedElectrumX); + ) as _i10.CachedElectrumX); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); + @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -829,6 +820,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override + _i12.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isar), + ), + ) as _i12.Isar); + @override _i16.Future exit() => (super.noSuchMethod( Invocation.method( #exit, @@ -838,17 +837,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: _i16.Future.value(), ) as _i16.Future); @override - _i16.Future updateStoredChainHeight({required int? newHeight}) => - (super.noSuchMethod( - Invocation.method( - #updateStoredChainHeight, - [], - {#newHeight: newHeight}, - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); - @override _i19.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( @@ -1014,20 +1002,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: _i16.Future.value(), ) as _i16.Future); @override - _i16.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i16.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), - returnValue: - _i16.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( + returnValue: _i16.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i16.Future<_i10.ElectrumXNode>); + ) as _i16.Future<_i9.ElectrumXNode>); @override _i16.Future addDerivation({ required int? chain, @@ -1245,6 +1232,129 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { ), returnValue: _i16.Future.value(false), ) as _i16.Future); + @override + void initCache( + String? walletId, + _i15.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i16.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i16.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i16.Future updateCachedIsFavorite(bool? isFavorite) => + (super.noSuchMethod( + Invocation.method( + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); + @override + _i11.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i11.Balance); + @override + _i16.Future updateCachedBalance(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); + @override + _i11.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i11.Balance); + @override + _i16.Future updateCachedBalanceSecondary(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); + @override + _i16.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i16.Future.value(false), + ) as _i16.Future); + @override + _i16.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i16.Future.value(false), + ) as _i16.Future); } /// A class which mocks [Manager]. @@ -1314,13 +1424,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i9.FeeObject>); + ) as _i16.Future<_i8.FeeObject>); @override _i16.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1332,13 +1442,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i16.Future.value(''), ) as _i16.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i16.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1384,6 +1494,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override + _i12.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#db), + ), + ) as _i12.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -1622,13 +1740,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i16.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i16.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i16.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i16.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i16.Future<_i9.FeeObject>); + ) as _i16.Future<_i8.FeeObject>); @override _i16.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1640,13 +1758,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: _i16.Future.value(''), ) as _i16.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i16.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1697,6 +1815,14 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: 0, ) as int); @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); + @override _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 7ac548055..753e56f35 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -538,6 +538,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override + _i10.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_7( + this, + Invocation.getter(#db), + ), + ) as _i10.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -855,6 +863,14 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: 0, ) as int); @override + _i10.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_7( + this, + Invocation.getter(#isarInstance), + ), + ) as _i10.Isar); + @override _i18.Future> prepareSend({ required String? address, required int? satoshiAmount, @@ -1033,22 +1049,6 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i10.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_7( - this, - Invocation.getter(#isar), - ), - ) as _i10.Isar); - @override - set isar(_i10.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override _i11.TransactionNotificationTracker get txTracker => (super.noSuchMethod( Invocation.getter(#txTracker), returnValue: _FakeTransactionNotificationTracker_8( @@ -1257,6 +1257,14 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { _i18.Future>.value(<_i21.Transaction>[]), ) as _i18.Future>); @override + _i10.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_7( + this, + Invocation.getter(#isarInstance), + ), + ) as _i10.Isar); + @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -1266,6 +1274,14 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override + _i10.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_7( + this, + Invocation.getter(#isar), + ), + ) as _i10.Isar); + @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( #validateAddress, @@ -1799,12 +1815,161 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ), ) as _i14.Decimal); @override - _i18.Future updateStoredChainHeight({required int? newHeight}) => + void initCache( + String? walletId, + _i17.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i18.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i18.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i18.Future updateCachedIsFavorite(bool? isFavorite) => (super.noSuchMethod( Invocation.method( - #updateStoredChainHeight, + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override + _i9.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, [], - {#newHeight: newHeight}, + ), + returnValue: _FakeBalance_6( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i9.Balance); + @override + _i18.Future updateCachedBalance(_i9.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override + _i9.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_6( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i9.Balance); + @override + _i18.Future updateCachedBalanceSecondary(_i9.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override + _i18.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i18.Future.value(false), + ) as _i18.Future); + @override + _i18.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i18.Future.value(false), + ) as _i18.Future); + @override + void initFiroHive(String? walletId) => super.noSuchMethod( + Invocation.method( + #initFiroHive, + [walletId], + ), + returnValueForMissingStub: null, + ); + @override + _i18.Future firoUpdateJIndex(List? jIndex) => + (super.noSuchMethod( + Invocation.method( + #firoUpdateJIndex, + [jIndex], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override + _i18.Future firoUpdateLelantusCoins(List? lelantusCoins) => + (super.noSuchMethod( + Invocation.method( + #firoUpdateLelantusCoins, + [lelantusCoins], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override + _i18.Future firoUpdateMintIndex(int? mintIndex) => (super.noSuchMethod( + Invocation.method( + #firoUpdateMintIndex, + [mintIndex], ), returnValue: _i18.Future.value(), returnValueForMissingStub: _i18.Future.value(), diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 1be304d22..83daf81fe 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -8,13 +8,13 @@ import 'dart:ui' as _i17; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i8; +import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; -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/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 _i19; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i20; @@ -90,8 +90,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { - _FakeIsar_5( +class _FakeFeeObject_5 extends _i1.SmartFake implements _i8.FeeObject { + _FakeFeeObject_5( Object parent, Invocation parentInvocation, ) : super( @@ -100,8 +100,8 @@ class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { ); } -class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_6( +class _FakeElectrumX_6 extends _i1.SmartFake implements _i9.ElectrumX { + _FakeElectrumX_6( Object parent, Invocation parentInvocation, ) : super( @@ -110,8 +110,9 @@ class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_7( +class _FakeCachedElectrumX_7 extends _i1.SmartFake + implements _i10.CachedElectrumX { + _FakeCachedElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -120,9 +121,8 @@ class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { ); } -class _FakeCachedElectrumX_8 extends _i1.SmartFake - implements _i11.CachedElectrumX { - _FakeCachedElectrumX_8( +class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { + _FakeBalance_8( Object parent, Invocation parentInvocation, ) : super( @@ -131,8 +131,8 @@ class _FakeCachedElectrumX_8 extends _i1.SmartFake ); } -class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { - _FakeBalance_9( +class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { + _FakeIsar_9( Object parent, Invocation parentInvocation, ) : super( @@ -141,8 +141,7 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeElectrumXNode_10 extends _i1.SmartFake - implements _i10.ElectrumXNode { +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i9.ElectrumXNode { _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, @@ -417,22 +416,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i8.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_5( - this, - Invocation.getter(#isar), - ), - ) as _i8.Isar); - @override - set isar(_i8.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override bool get isActive => (super.noSuchMethod( Invocation.getter(#isActive), returnValue: false, @@ -490,13 +473,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValue: false, ) as bool); @override - _i15.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i15.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i15.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i15.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i15.Future<_i9.FeeObject>); + ) as _i15.Future<_i8.FeeObject>); @override _i15.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -559,29 +542,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i10.ElectrumX get electrumXClient => (super.noSuchMethod( + _i9.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_7( + returnValue: _FakeElectrumX_6( this, Invocation.getter(#electrumXClient), ), - ) as _i10.ElectrumX); + ) as _i9.ElectrumX); @override - _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i10.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_8( + returnValue: _FakeCachedElectrumX_7( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i11.CachedElectrumX); + ) as _i10.CachedElectrumX); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); + @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -592,6 +583,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override + _i12.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isar), + ), + ) as _i12.Isar); + @override _i15.Future exit() => (super.noSuchMethod( Invocation.method( #exit, @@ -601,17 +600,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: _i15.Future.value(), ) as _i15.Future); @override - _i15.Future updateStoredChainHeight({required int? newHeight}) => - (super.noSuchMethod( - Invocation.method( - #updateStoredChainHeight, - [], - {#newHeight: newHeight}, - ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); - @override _i18.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( @@ -777,20 +765,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: _i15.Future.value(), ) as _i15.Future); @override - _i15.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i15.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), - returnValue: - _i15.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( + returnValue: _i15.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i15.Future<_i10.ElectrumXNode>); + ) as _i15.Future<_i9.ElectrumXNode>); @override _i15.Future addDerivation({ required int? chain, @@ -1008,6 +995,129 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { ), returnValue: _i15.Future.value(false), ) as _i15.Future); + @override + void initCache( + String? walletId, + _i14.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i15.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i15.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i15.Future updateCachedIsFavorite(bool? isFavorite) => + (super.noSuchMethod( + Invocation.method( + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); + @override + _i11.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i11.Balance); + @override + _i15.Future updateCachedBalance(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); + @override + _i11.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i11.Balance); + @override + _i15.Future updateCachedBalanceSecondary(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); + @override + _i15.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i15.Future.value(false), + ) as _i15.Future); + @override + _i15.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i15.Future.value(false), + ) as _i15.Future); } /// A class which mocks [LocaleService]. 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 0bcdecec2..52c20a971 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 @@ -8,14 +8,14 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i8; +import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; -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/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 _i21; import 'package:stackwallet/models/node_model.dart' as _i22; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; @@ -93,8 +93,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { - _FakeIsar_5( +class _FakeFeeObject_5 extends _i1.SmartFake implements _i8.FeeObject { + _FakeFeeObject_5( Object parent, Invocation parentInvocation, ) : super( @@ -103,8 +103,8 @@ class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { ); } -class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_6( +class _FakeElectrumX_6 extends _i1.SmartFake implements _i9.ElectrumX { + _FakeElectrumX_6( Object parent, Invocation parentInvocation, ) : super( @@ -113,8 +113,9 @@ class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_7( +class _FakeCachedElectrumX_7 extends _i1.SmartFake + implements _i10.CachedElectrumX { + _FakeCachedElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -123,9 +124,8 @@ class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { ); } -class _FakeCachedElectrumX_8 extends _i1.SmartFake - implements _i11.CachedElectrumX { - _FakeCachedElectrumX_8( +class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { + _FakeBalance_8( Object parent, Invocation parentInvocation, ) : super( @@ -134,8 +134,8 @@ class _FakeCachedElectrumX_8 extends _i1.SmartFake ); } -class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { - _FakeBalance_9( +class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { + _FakeIsar_9( Object parent, Invocation parentInvocation, ) : super( @@ -144,8 +144,7 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeElectrumXNode_10 extends _i1.SmartFake - implements _i10.ElectrumXNode { +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i9.ElectrumXNode { _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, @@ -668,22 +667,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i8.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_5( - this, - Invocation.getter(#isar), - ), - ) as _i8.Isar); - @override - set isar(_i8.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override bool get isActive => (super.noSuchMethod( Invocation.getter(#isActive), returnValue: false, @@ -741,13 +724,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValue: false, ) as bool); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -810,29 +793,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i10.ElectrumX get electrumXClient => (super.noSuchMethod( + _i9.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_7( + returnValue: _FakeElectrumX_6( this, Invocation.getter(#electrumXClient), ), - ) as _i10.ElectrumX); + ) as _i9.ElectrumX); @override - _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i10.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_8( + returnValue: _FakeCachedElectrumX_7( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i11.CachedElectrumX); + ) as _i10.CachedElectrumX); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); + @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -843,6 +834,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override + _i12.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isar), + ), + ) as _i12.Isar); + @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, @@ -852,17 +851,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future updateStoredChainHeight({required int? newHeight}) => - (super.noSuchMethod( - Invocation.method( - #updateStoredChainHeight, - [], - {#newHeight: newHeight}, - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); - @override _i20.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( @@ -1028,20 +1016,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), - returnValue: - _i17.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( + returnValue: _i17.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i17.Future<_i10.ElectrumXNode>); + ) as _i17.Future<_i9.ElectrumXNode>); @override _i17.Future addDerivation({ required int? chain, @@ -1259,6 +1246,129 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + void initCache( + String? walletId, + _i16.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i17.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i17.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i17.Future updateCachedIsFavorite(bool? isFavorite) => + (super.noSuchMethod( + Invocation.method( + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i11.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i11.Balance); + @override + _i17.Future updateCachedBalance(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i11.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i11.Balance); + @override + _i17.Future updateCachedBalanceSecondary(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); + @override + _i17.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1528,13 +1638,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1546,13 +1656,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1598,6 +1708,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override + _i12.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#db), + ), + ) as _i12.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -1836,13 +1954,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1854,13 +1972,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1911,6 +2029,14 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); + @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 882d4d79d..23c007ff9 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 @@ -8,14 +8,14 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i8; +import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; -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/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 _i21; import 'package:stackwallet/models/node_model.dart' as _i22; -import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; +import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; @@ -93,8 +93,8 @@ class _FakeTransactionNotificationTracker_4 extends _i1.SmartFake ); } -class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { - _FakeIsar_5( +class _FakeFeeObject_5 extends _i1.SmartFake implements _i8.FeeObject { + _FakeFeeObject_5( Object parent, Invocation parentInvocation, ) : super( @@ -103,8 +103,8 @@ class _FakeIsar_5 extends _i1.SmartFake implements _i8.Isar { ); } -class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { - _FakeFeeObject_6( +class _FakeElectrumX_6 extends _i1.SmartFake implements _i9.ElectrumX { + _FakeElectrumX_6( Object parent, Invocation parentInvocation, ) : super( @@ -113,8 +113,9 @@ class _FakeFeeObject_6 extends _i1.SmartFake implements _i9.FeeObject { ); } -class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { - _FakeElectrumX_7( +class _FakeCachedElectrumX_7 extends _i1.SmartFake + implements _i10.CachedElectrumX { + _FakeCachedElectrumX_7( Object parent, Invocation parentInvocation, ) : super( @@ -123,9 +124,8 @@ class _FakeElectrumX_7 extends _i1.SmartFake implements _i10.ElectrumX { ); } -class _FakeCachedElectrumX_8 extends _i1.SmartFake - implements _i11.CachedElectrumX { - _FakeCachedElectrumX_8( +class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { + _FakeBalance_8( Object parent, Invocation parentInvocation, ) : super( @@ -134,8 +134,8 @@ class _FakeCachedElectrumX_8 extends _i1.SmartFake ); } -class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { - _FakeBalance_9( +class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { + _FakeIsar_9( Object parent, Invocation parentInvocation, ) : super( @@ -144,8 +144,7 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeElectrumXNode_10 extends _i1.SmartFake - implements _i10.ElectrumXNode { +class _FakeElectrumXNode_10 extends _i1.SmartFake implements _i9.ElectrumXNode { _FakeElectrumXNode_10( Object parent, Invocation parentInvocation, @@ -668,22 +667,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i8.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_5( - this, - Invocation.getter(#isar), - ), - ) as _i8.Isar); - @override - set isar(_i8.Isar? _isar) => super.noSuchMethod( - Invocation.setter( - #isar, - _isar, - ), - returnValueForMissingStub: null, - ); - @override bool get isActive => (super.noSuchMethod( Invocation.getter(#isActive), returnValue: false, @@ -741,13 +724,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValue: false, ) as bool); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -810,29 +793,37 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i10.ElectrumX get electrumXClient => (super.noSuchMethod( + _i9.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_7( + returnValue: _FakeElectrumX_6( this, Invocation.getter(#electrumXClient), ), - ) as _i10.ElectrumX); + ) as _i9.ElectrumX); @override - _i11.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i10.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_8( + returnValue: _FakeCachedElectrumX_7( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i11.CachedElectrumX); + ) as _i10.CachedElectrumX); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); + @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( @@ -843,6 +834,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override + _i12.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isar), + ), + ) as _i12.Isar); + @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( #exit, @@ -852,17 +851,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future updateStoredChainHeight({required int? newHeight}) => - (super.noSuchMethod( - Invocation.method( - #updateStoredChainHeight, - [], - {#newHeight: newHeight}, - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); - @override _i20.DerivePathType addressType({required String? address}) => (super.noSuchMethod( Invocation.method( @@ -1028,20 +1016,19 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future<_i10.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( + _i17.Future<_i9.ElectrumXNode> getCurrentNode() => (super.noSuchMethod( Invocation.method( #getCurrentNode, [], ), - returnValue: - _i17.Future<_i10.ElectrumXNode>.value(_FakeElectrumXNode_10( + returnValue: _i17.Future<_i9.ElectrumXNode>.value(_FakeElectrumXNode_10( this, Invocation.method( #getCurrentNode, [], ), )), - ) as _i17.Future<_i10.ElectrumXNode>); + ) as _i17.Future<_i9.ElectrumXNode>); @override _i17.Future addDerivation({ required int? chain, @@ -1259,6 +1246,129 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + void initCache( + String? walletId, + _i16.Coin? coin, + ) => + super.noSuchMethod( + Invocation.method( + #initCache, + [ + walletId, + coin, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i17.Future updateCachedId(String? id) => (super.noSuchMethod( + Invocation.method( + #updateCachedId, + [id], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + int getCachedChainHeight() => (super.noSuchMethod( + Invocation.method( + #getCachedChainHeight, + [], + ), + returnValue: 0, + ) as int); + @override + _i17.Future updateCachedChainHeight(int? height) => (super.noSuchMethod( + Invocation.method( + #updateCachedChainHeight, + [height], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + bool getCachedIsFavorite() => (super.noSuchMethod( + Invocation.method( + #getCachedIsFavorite, + [], + ), + returnValue: false, + ) as bool); + @override + _i17.Future updateCachedIsFavorite(bool? isFavorite) => + (super.noSuchMethod( + Invocation.method( + #updateCachedIsFavorite, + [isFavorite], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i11.Balance getCachedBalance() => (super.noSuchMethod( + Invocation.method( + #getCachedBalance, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalance, + [], + ), + ), + ) as _i11.Balance); + @override + _i17.Future updateCachedBalance(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalance, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i11.Balance getCachedBalanceSecondary() => (super.noSuchMethod( + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + returnValue: _FakeBalance_8( + this, + Invocation.method( + #getCachedBalanceSecondary, + [], + ), + ), + ) as _i11.Balance); + @override + _i17.Future updateCachedBalanceSecondary(_i11.Balance? balance) => + (super.noSuchMethod( + Invocation.method( + #updateCachedBalanceSecondary, + [balance], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); + @override + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + Invocation.method( + #isarInit, + [walletId], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); + @override + _i17.Future isarClose() => (super.noSuchMethod( + Invocation.method( + #isarClose, + [], + ), + returnValue: _i17.Future.value(false), + ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1528,13 +1638,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1546,13 +1656,13 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1598,6 +1708,14 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override + _i12.Isar get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#db), + ), + ) as _i12.Isar); + @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -1836,13 +1954,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValueForMissingStub: null, ); @override - _i17.Future<_i9.FeeObject> get fees => (super.noSuchMethod( + _i17.Future<_i8.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i17.Future<_i9.FeeObject>.value(_FakeFeeObject_6( + returnValue: _i17.Future<_i8.FeeObject>.value(_FakeFeeObject_5( this, Invocation.getter(#fees), )), - ) as _i17.Future<_i9.FeeObject>); + ) as _i17.Future<_i8.FeeObject>); @override _i17.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), @@ -1854,13 +1972,13 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: _i17.Future.value(''), ) as _i17.Future); @override - _i12.Balance get balance => (super.noSuchMethod( + _i11.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), - returnValue: _FakeBalance_9( + returnValue: _FakeBalance_8( this, Invocation.getter(#balance), ), - ) as _i12.Balance); + ) as _i11.Balance); @override _i17.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), @@ -1911,6 +2029,14 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override + _i12.Isar get isarInstance => (super.noSuchMethod( + Invocation.getter(#isarInstance), + returnValue: _FakeIsar_9( + this, + Invocation.getter(#isarInstance), + ), + ) as _i12.Isar); + @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, From 0543c4b044df13f03a30b94d0a9202820b449a11 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 12:00:02 -0600 Subject: [PATCH 128/192] filter by address fixes --- .../address_book_views/subviews/contact_details_view.dart | 2 +- .../address_book_view/subwidgets/desktop_contact_details.dart | 3 ++- lib/services/coins/coin_paynym_extension.dart | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pages/address_book_views/subviews/contact_details_view.dart b/lib/pages/address_book_views/subviews/contact_details_view.dart index 5459f01a1..5c75b4beb 100644 --- a/lib/pages/address_book_views/subviews/contact_details_view.dart +++ b/lib/pages/address_book_views/subviews/contact_details_view.dart @@ -62,7 +62,7 @@ class _ContactDetailsViewState extends ConsumerState { final transactions = await manager.db.transactions .filter() .anyOf(contact.addresses.map((e) => e.address), - (q, String e) => q.addressEqualTo(e)) + (q, String e) => q.address((q) => q.valueEqualTo(e))) .sortByTimestampDesc() .findAll(); diff --git a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart index b48128319..da0adb59c 100644 --- a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart +++ b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart @@ -4,6 +4,7 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/models/contact.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart'; @@ -61,7 +62,7 @@ class _DesktopContactDetailsState extends ConsumerState { final transactions = await manager.db.transactions .filter() .anyOf(contact.addresses.map((e) => e.address), - (q, String e) => q.addressEqualTo(e)) + (q, String e) => q.address((q) => q.valueEqualTo(e))) .sortByTimestampDesc() .findAll(); diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 266963cea..02486e645 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -135,7 +135,7 @@ extension PayNym on DogecoinWallet { Future hasSentNotificationTx(PaymentCode pCode) async { final tx = await isar.transactions .filter() - .addressEqualTo(pCode.notificationAddress()) + .address((q) => q.valueEqualTo(pCode.notificationAddress())) .findFirst(); return tx; } From 6310f0b1c7f714870e86d15bb2d43133acbeb497 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 12:00:25 -0600 Subject: [PATCH 129/192] only update missing or unconfirmed transactions --- .../coins/bitcoin/bitcoin_wallet.dart | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index ca3c526cb..79c2c044b 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2029,21 +2029,31 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { List> allTransactions = []; - for (final txHash in allReceivingTxHashes) { - final tx = await cachedElectrumXClient.getTransaction( - txHash: txHash["tx_hash"] as String, - verbose: true, - coin: coin, - ); + final currentHeight = await chainHeight; - // if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses - .filter() - .valueEqualTo(txHash["address"] as String) + for (final txHash in allReceivingTxHashes) { + final storedTx = await isar.transactions + .where() + .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); - tx["height"] = txHash["height"]; - allTransactions.add(tx); - // } + + if (storedTx == null || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + // if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); + tx["height"] = txHash["height"]; + allTransactions.add(tx); + // } + } } Set vHashes = {}; @@ -2059,10 +2069,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final List txns = []; for (final txObject in allTransactions) { - final pretty = const JsonEncoder.withIndent(" ").convert(txObject); - print("========================================================="); - log(pretty); + log(txObject.toString()); final txn = await parseTransaction( txObject, @@ -2075,6 +2083,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txns.add(txn); } await isar.writeTxn(() async { + await isar.transactions + .deleteAllByTxid(txns.map((e) => e.txid).toList(growable: false)); await isar.transactions.putAll(txns); }); } From 94e6ebf53b38116b177c1e7d196c1bb5732196b0 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 13:25:09 -0600 Subject: [PATCH 130/192] insert inputs/outputs after finishing tx parse --- .../coins/bitcoin/bitcoin_wallet.dart | 319 ++++-------------- lib/services/coins/coin_paynym_extension.dart | 17 +- .../coins/dogecoin/dogecoin_wallet.dart | 2 +- lib/services/coins/firo/firo_wallet.dart | 2 +- .../coins/litecoin/litecoin_wallet.dart | 2 +- .../coins/namecoin/namecoin_wallet.dart | 2 +- 6 files changed, 77 insertions(+), 267 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 79c2c044b..a4c5f4202 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1998,27 +1998,23 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - bool _duplicateTxCheck( - List> allTransactions, String txid) { - for (int i = 0; i < allTransactions.length; i++) { - if (allTransactions[i]["txid"] == txid) { - return true; - } - } - return false; - } + // bool _duplicateTxCheck( + // List> allTransactions, String txid) { + // for (int i = 0; i < allTransactions.length; i++) { + // if (allTransactions[i]["txid"] == txid) { + // return true; + // } + // } + // return false; + // } Future _refreshTransactions() async { final List allAddresses = await _fetchAllOwnAddresses(); - final receivingAddresses = allAddresses - .where((e) => e.subType == isar_models.AddressSubType.receiving); - final changeAddresses = allAddresses - .where((e) => e.subType == isar_models.AddressSubType.change); - - final List> allReceivingTxHashes = - await _fetchHistory(receivingAddresses.map((e) => e.value).toList()); + final Set> allReceivingTxHashes = + (await _fetchHistory(allAddresses.map((e) => e.value).toList())) + .toSet(); // // prefetch/cache // Set hashes = {}; @@ -2056,23 +2052,26 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - Set vHashes = {}; - for (final txObject in allTransactions) { - for (int i = 0; i < (txObject["vin"] as List).length; i++) { - final input = txObject["vin"]![i] as Map; - final prevTxid = input["txid"] as String; - vHashes.add(prevTxid); - } - } - await fastFetch(vHashes.toList()); + // // prefetch/cache + // Set vHashes = {}; + // for (final txObject in allTransactions) { + // for (int i = 0; i < (txObject["vin"] as List).length; i++) { + // final input = txObject["vin"]![i] as Map; + // final prevTxid = input["txid"] as String; + // vHashes.add(prevTxid); + // } + // } + // await fastFetch(vHashes.toList()); - final List txns = []; + final List< + Tuple3, + List>> txnsData = []; for (final txObject in allTransactions) { print("========================================================="); log(txObject.toString()); - final txn = await parseTransaction( + final data = await parseTransaction( txObject, cachedElectrumXClient, allAddresses, @@ -2080,12 +2079,40 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { MINIMUM_CONFIRMATIONS, ); - txns.add(txn); + txnsData.add(data); } await isar.writeTxn(() async { - await isar.transactions - .deleteAllByTxid(txns.map((e) => e.txid).toList(growable: false)); - await isar.transactions.putAll(txns); + for (final data in txnsData) { + final tx = data.item1; + + final prevTx = + await isar.transactions.where().txidEqualTo(tx.txid).findFirst(); + + if (prevTx != null) { + tx.note.value = prevTx.note.value; + await isar.transactions.delete(prevTx.id); + } + + // save transaction + await isar.transactions.put(tx); + + // link and save outputs + if (data.item2.isNotEmpty) { + await isar.outputs.putAll(data.item2); + tx.outputs.addAll(data.item2); + await tx.outputs.save(); + } + + // link and save inputs + if (data.item3.isNotEmpty) { + await isar.inputs.putAll(data.item3); + tx.inputs.addAll(data.item3); + await tx.inputs.save(); + } + + await tx.address.save(); + await tx.note.save(); + } }); } @@ -2749,6 +2776,9 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isar.writeTxn(() async { await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); await isar.addresses.clear(); }); @@ -2792,106 +2822,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("starting rescan restore", level: LogLevel.Info); // // // restore from backup - // // p2pkh - // final tempReceivingAddressesP2PKH = DB.instance - // .get(boxName: walletId, key: 'receivingAddressesP2PKH_BACKUP'); - // final tempChangeAddressesP2PKH = DB.instance - // .get(boxName: walletId, key: 'changeAddressesP2PKH_BACKUP'); - // final tempReceivingIndexP2PKH = DB.instance - // .get(boxName: walletId, key: 'receivingIndexP2PKH_BACKUP'); - // final tempChangeIndexP2PKH = DB.instance - // .get(boxName: walletId, key: 'changeIndexP2PKH_BACKUP'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingAddressesP2PKH', - // value: tempReceivingAddressesP2PKH); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeAddressesP2PKH', - // value: tempChangeAddressesP2PKH); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingIndexP2PKH', - // value: tempReceivingIndexP2PKH); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeIndexP2PKH', - // value: tempChangeIndexP2PKH); - // await DB.instance.delete( - // key: 'receivingAddressesP2PKH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'changeAddressesP2PKH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'receivingIndexP2PKH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'changeIndexP2PKH_BACKUP', boxName: walletId); - // - // // p2Sh - // final tempReceivingAddressesP2SH = DB.instance - // .get(boxName: walletId, key: 'receivingAddressesP2SH_BACKUP'); - // final tempChangeAddressesP2SH = DB.instance - // .get(boxName: walletId, key: 'changeAddressesP2SH_BACKUP'); - // final tempReceivingIndexP2SH = DB.instance - // .get(boxName: walletId, key: 'receivingIndexP2SH_BACKUP'); - // final tempChangeIndexP2SH = DB.instance - // .get(boxName: walletId, key: 'changeIndexP2SH_BACKUP'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingAddressesP2SH', - // value: tempReceivingAddressesP2SH); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeAddressesP2SH', - // value: tempChangeAddressesP2SH); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingIndexP2SH', - // value: tempReceivingIndexP2SH); - // await DB.instance.put( - // boxName: walletId, key: 'changeIndexP2SH', value: tempChangeIndexP2SH); - // await DB.instance.delete( - // key: 'receivingAddressesP2SH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'changeAddressesP2SH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'receivingIndexP2SH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'changeIndexP2SH_BACKUP', boxName: walletId); - // - // // p2wpkh - // final tempReceivingAddressesP2WPKH = DB.instance.get( - // boxName: walletId, key: 'receivingAddressesP2WPKH_BACKUP'); - // final tempChangeAddressesP2WPKH = DB.instance - // .get(boxName: walletId, key: 'changeAddressesP2WPKH_BACKUP'); - // final tempReceivingIndexP2WPKH = DB.instance - // .get(boxName: walletId, key: 'receivingIndexP2WPKH_BACKUP'); - // final tempChangeIndexP2WPKH = DB.instance - // .get(boxName: walletId, key: 'changeIndexP2WPKH_BACKUP'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingAddressesP2WPKH', - // value: tempReceivingAddressesP2WPKH); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeAddressesP2WPKH', - // value: tempChangeAddressesP2WPKH); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingIndexP2WPKH', - // value: tempReceivingIndexP2WPKH); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeIndexP2WPKH', - // value: tempChangeIndexP2WPKH); - // await DB.instance.delete( - // key: 'receivingAddressesP2WPKH_BACKUP', boxName: walletId); - // await DB.instance.delete( - // key: 'changeAddressesP2WPKH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'receivingIndexP2WPKH_BACKUP', boxName: walletId); - // await DB.instance - // .delete(key: 'changeIndexP2WPKH_BACKUP', boxName: walletId); - // // // P2PKH derivations // final p2pkhReceiveDerivationsString = await _secureStore.read( // key: "${walletId}_receiveDerivationsP2PKH_BACKUP"); @@ -2943,14 +2873,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // await _secureStore.delete( // key: "${walletId}_changeDerivationsP2WPKH_BACKUP"); // - // // UTXOs - // final utxoData = DB.instance - // .get(boxName: walletId, key: 'latest_utxo_model_BACKUP'); - // await DB.instance.put( - // boxName: walletId, key: 'latest_utxo_model', value: utxoData); - // await DB.instance - // .delete(key: 'latest_utxo_model_BACKUP', boxName: walletId); - // // Logging.instance.log("rescan restore complete", level: LogLevel.Info); // } // @@ -2958,117 +2880,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("starting rescan backup", level: LogLevel.Info); // // // backup current and clear data - // // p2pkh - // final tempReceivingAddressesP2PKH = DB.instance - // .get(boxName: walletId, key: 'receivingAddressesP2PKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingAddressesP2PKH_BACKUP', - // value: tempReceivingAddressesP2PKH); - // await DB.instance - // .delete(key: 'receivingAddressesP2PKH', boxName: walletId); - // - // final tempChangeAddressesP2PKH = DB.instance - // .get(boxName: walletId, key: 'changeAddressesP2PKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeAddressesP2PKH_BACKUP', - // value: tempChangeAddressesP2PKH); - // await DB.instance - // .delete(key: 'changeAddressesP2PKH', boxName: walletId); - // - // final tempReceivingIndexP2PKH = - // DB.instance.get(boxName: walletId, key: 'receivingIndexP2PKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingIndexP2PKH_BACKUP', - // value: tempReceivingIndexP2PKH); - // await DB.instance - // .delete(key: 'receivingIndexP2PKH', boxName: walletId); - // - // final tempChangeIndexP2PKH = - // DB.instance.get(boxName: walletId, key: 'changeIndexP2PKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeIndexP2PKH_BACKUP', - // value: tempChangeIndexP2PKH); - // await DB.instance - // .delete(key: 'changeIndexP2PKH', boxName: walletId); - // - // // p2sh - // final tempReceivingAddressesP2SH = DB.instance - // .get(boxName: walletId, key: 'receivingAddressesP2SH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingAddressesP2SH_BACKUP', - // value: tempReceivingAddressesP2SH); - // await DB.instance - // .delete(key: 'receivingAddressesP2SH', boxName: walletId); - // - // final tempChangeAddressesP2SH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeAddressesP2SH_BACKUP', - // value: tempChangeAddressesP2SH); - // await DB.instance - // .delete(key: 'changeAddressesP2SH', boxName: walletId); - // - // final tempReceivingIndexP2SH = - // DB.instance.get(boxName: walletId, key: 'receivingIndexP2SH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingIndexP2SH_BACKUP', - // value: tempReceivingIndexP2SH); - // await DB.instance - // .delete(key: 'receivingIndexP2SH', boxName: walletId); - // - // final tempChangeIndexP2SH = - // DB.instance.get(boxName: walletId, key: 'changeIndexP2SH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeIndexP2SH_BACKUP', - // value: tempChangeIndexP2SH); - // await DB.instance - // .delete(key: 'changeIndexP2SH', boxName: walletId); - // - // // p2wpkh - // final tempReceivingAddressesP2WPKH = DB.instance - // .get(boxName: walletId, key: 'receivingAddressesP2WPKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingAddressesP2WPKH_BACKUP', - // value: tempReceivingAddressesP2WPKH); - // await DB.instance - // .delete(key: 'receivingAddressesP2WPKH', boxName: walletId); - // - // final tempChangeAddressesP2WPKH = DB.instance - // .get(boxName: walletId, key: 'changeAddressesP2WPKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeAddressesP2WPKH_BACKUP', - // value: tempChangeAddressesP2WPKH); - // await DB.instance - // .delete(key: 'changeAddressesP2WPKH', boxName: walletId); - // - // final tempReceivingIndexP2WPKH = DB.instance - // .get(boxName: walletId, key: 'receivingIndexP2WPKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'receivingIndexP2WPKH_BACKUP', - // value: tempReceivingIndexP2WPKH); - // await DB.instance - // .delete(key: 'receivingIndexP2WPKH', boxName: walletId); - // - // final tempChangeIndexP2WPKH = - // DB.instance.get(boxName: walletId, key: 'changeIndexP2WPKH'); - // await DB.instance.put( - // boxName: walletId, - // key: 'changeIndexP2WPKH_BACKUP', - // value: tempChangeIndexP2WPKH); - // await DB.instance - // .delete(key: 'changeIndexP2WPKH', boxName: walletId); - // // // P2PKH derivations // final p2pkhReceiveDerivationsString = // await _secureStore.read(key: "${walletId}_receiveDerivationsP2PKH"); @@ -3117,13 +2928,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); // await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); // - // // UTXOs - // final utxoData = - // DB.instance.get(boxName: walletId, key: 'latest_utxo_model'); - // await DB.instance.put( - // boxName: walletId, key: 'latest_utxo_model_BACKUP', value: utxoData); - // await DB.instance - // .delete(key: 'latest_utxo_model', boxName: walletId); + // // // Logging.instance.log("rescan backup complete", level: LogLevel.Info); // } diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index 02486e645..e0a1b83f8 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -562,13 +562,15 @@ extension PayNym on DogecoinWallet { } } -Future parseTransaction( +Future, List>> parseTransaction( Map txData, dynamic electrumxClient, List
myAddresses, Coin coin, int minConfirms, ) async { + final transactionAddress = txData["address"] as Address; + Set receivingAddresses = myAddresses .where((e) => e.subType == AddressSubType.receiving) .map((e) => e.value) @@ -672,7 +674,7 @@ Future parseTransaction( // this should be the address we used to originally fetch the tx so we should // be able to easily figure out if the tx is a send or receive - tx.address.value = txData["address"] as Address; + tx.address.value = transactionAddress; if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self @@ -694,11 +696,14 @@ Future parseTransaction( tx.fee = fee; - log("tx.address: ${tx.address}"); + log("transactionAddress: $transactionAddress"); log("mySentFromAddresses: $mySentFromAddresses"); log("myReceivedOnAddresses: $myReceivedOnAddresses"); log("myChangeReceivedOnAddresses: $myChangeReceivedOnAddresses"); + List outs = []; + List ins = []; + for (final json in txData["vin"] as List) { bool isCoinBase = json['coinbase'] != null; final input = Input(); @@ -709,7 +714,7 @@ Future parseTransaction( input.isCoinbase = isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; input.sequence = json['sequence'] as int?; input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; - tx.inputs.add(input); + ins.add(input); } for (final json in txData["vout"] as List) { @@ -724,7 +729,7 @@ Future parseTransaction( Decimal.parse(json["value"].toString()), coin, ); - tx.outputs.add(output); + outs.add(output); } tx.height = txData["height"] as int?; @@ -735,5 +740,5 @@ Future parseTransaction( tx.otherData = null; tx.isLelantus = null; - return tx; + return Tuple3(tx, outs, ins); } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index a1813f465..76f9e8bd8 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1887,7 +1887,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar // if (tx == null) { await isar.writeTxn(() async { - await isar.transactions.put(txn); + await isar.transactions.put(txn.item1); }); // } } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 90a26675a..15aaa2a47 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3477,7 +3477,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar // if (tx == null) { await isar.writeTxn(() async { - await isar.transactions.put(txn); + await isar.transactions.put(txn.item1); }); // } } diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index c403743a9..c2ef099aa 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2197,7 +2197,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar // if (tx == null) { await isar.writeTxn(() async { - await isar.transactions.put(txn); + await isar.transactions.put(txn.item1); }); // } diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 2a158b9c4..d71d5460e 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2174,7 +2174,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar // if (tx == null) { await isar.writeTxn(() async { - await isar.transactions.put(txn); + await isar.transactions.put(txn.item1); }); // } From cb382e213f704184a79569e6e8b376fa46df7e84 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 13:33:46 -0600 Subject: [PATCH 131/192] separate tx note from transaction object to ensure total separation of blockchain data from other user to ease rescanning the blockchain --- lib/models/isar/models/blockchain_data/transaction.dart | 3 --- lib/models/isar/models/transaction_note.dart | 5 +++-- lib/services/coins/bitcoin/bitcoin_wallet.dart | 9 --------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index ab99f0d5a..1fbacc784 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -48,9 +48,6 @@ class Transaction { final outputs = IsarLinks(); - @Backlink(to: "transaction") - final note = IsarLink(); - int getConfirmations(int currentChainHeight) { if (height == null) return 0; return max(0, currentChainHeight - height!); diff --git a/lib/models/isar/models/transaction_note.dart b/lib/models/isar/models/transaction_note.dart index 95686bbbe..0aaf8c2f0 100644 --- a/lib/models/isar/models/transaction_note.dart +++ b/lib/models/isar/models/transaction_note.dart @@ -7,7 +7,8 @@ part 'transaction_note.g.dart'; class TransactionNote { Id id = Isar.autoIncrement; - late String value; + @Index(unique: true) + late String txid; - final transaction = IsarLink(); + late String value; } diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index a4c5f4202..e121347b9 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2085,14 +2085,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { for (final data in txnsData) { final tx = data.item1; - final prevTx = - await isar.transactions.where().txidEqualTo(tx.txid).findFirst(); - - if (prevTx != null) { - tx.note.value = prevTx.note.value; - await isar.transactions.delete(prevTx.id); - } - // save transaction await isar.transactions.put(tx); @@ -2111,7 +2103,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await tx.address.save(); - await tx.note.save(); } }); } From f53a2935834de6af58ffd66ac77e26254c0c60cf Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 13:35:21 -0600 Subject: [PATCH 132/192] build runner --- .../models/blockchain_data/transaction.g.dart | 23 +- .../isar/models/transaction_note.g.dart | 332 ++++++++++++++++-- 2 files changed, 305 insertions(+), 50 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 3d840d092..2b4e01d3a 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -127,13 +127,6 @@ const TransactionSchema = CollectionSchema( name: r'outputs', target: r'Output', single: false, - ), - r'note': LinkSchema( - id: -7669541085246698630, - name: r'note', - target: r'TransactionNote', - single: true, - linkName: r'transaction', ) }, embeddedSchemas: {}, @@ -276,7 +269,7 @@ Id _transactionGetId(Transaction object) { } List> _transactionGetLinks(Transaction object) { - return [object.address, object.inputs, object.outputs, object.note]; + return [object.address, object.inputs, object.outputs]; } void _transactionAttach( @@ -285,7 +278,6 @@ void _transactionAttach( object.address.attach(col, col.isar.collection
(), r'address', id); object.inputs.attach(col, col.isar.collection(), r'inputs', id); object.outputs.attach(col, col.isar.collection(), r'outputs', id); - object.note.attach(col, col.isar.collection(), r'note', id); } extension TransactionByIndex on IsarCollection { @@ -1577,19 +1569,6 @@ extension TransactionQueryLinks r'outputs', lower, includeLower, upper, includeUpper); }); } - - QueryBuilder note( - FilterQuery q) { - return QueryBuilder.apply(this, (query) { - return query.link(q, r'note'); - }); - } - - QueryBuilder noteIsNull() { - return QueryBuilder.apply(this, (query) { - return query.linkLength(r'note', 0, true, 0, true); - }); - } } extension TransactionQuerySortBy diff --git a/lib/models/isar/models/transaction_note.g.dart b/lib/models/isar/models/transaction_note.g.dart index be64f4919..055a45d28 100644 --- a/lib/models/isar/models/transaction_note.g.dart +++ b/lib/models/isar/models/transaction_note.g.dart @@ -17,8 +17,13 @@ const TransactionNoteSchema = CollectionSchema( name: r'TransactionNote', id: 5128348263878806765, properties: { - r'value': PropertySchema( + r'txid': PropertySchema( id: 0, + name: r'txid', + type: IsarType.string, + ), + r'value': PropertySchema( + id: 1, name: r'value', type: IsarType.string, ) @@ -28,15 +33,22 @@ const TransactionNoteSchema = CollectionSchema( deserialize: _transactionNoteDeserialize, deserializeProp: _transactionNoteDeserializeProp, idName: r'id', - indexes: {}, - links: { - r'transaction': LinkSchema( - id: -2827073548125040615, - name: r'transaction', - target: r'Transaction', - single: true, + indexes: { + r'txid': IndexSchema( + id: 7339874292043634331, + name: r'txid', + unique: true, + replace: false, + properties: [ + IndexPropertySchema( + name: r'txid', + type: IndexType.hash, + caseSensitive: true, + ) + ], ) }, + links: {}, embeddedSchemas: {}, getId: _transactionNoteGetId, getLinks: _transactionNoteGetLinks, @@ -50,6 +62,7 @@ int _transactionNoteEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; + bytesCount += 3 + object.txid.length * 3; bytesCount += 3 + object.value.length * 3; return bytesCount; } @@ -60,7 +73,8 @@ void _transactionNoteSerialize( List offsets, Map> allOffsets, ) { - writer.writeString(offsets[0], object.value); + writer.writeString(offsets[0], object.txid); + writer.writeString(offsets[1], object.value); } TransactionNote _transactionNoteDeserialize( @@ -71,7 +85,8 @@ TransactionNote _transactionNoteDeserialize( ) { final object = TransactionNote(); object.id = id; - object.value = reader.readString(offsets[0]); + object.txid = reader.readString(offsets[0]); + object.value = reader.readString(offsets[1]); return object; } @@ -84,6 +99,8 @@ P _transactionNoteDeserializeProp

( switch (propertyId) { case 0: return (reader.readString(offset)) as P; + case 1: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -94,14 +111,67 @@ Id _transactionNoteGetId(TransactionNote object) { } List> _transactionNoteGetLinks(TransactionNote object) { - return [object.transaction]; + return []; } void _transactionNoteAttach( IsarCollection col, Id id, TransactionNote object) { object.id = id; - object.transaction - .attach(col, col.isar.collection(), r'transaction', id); +} + +extension TransactionNoteByIndex on IsarCollection { + Future getByTxid(String txid) { + return getByIndex(r'txid', [txid]); + } + + TransactionNote? getByTxidSync(String txid) { + return getByIndexSync(r'txid', [txid]); + } + + Future deleteByTxid(String txid) { + return deleteByIndex(r'txid', [txid]); + } + + bool deleteByTxidSync(String txid) { + return deleteByIndexSync(r'txid', [txid]); + } + + Future> getAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndex(r'txid', values); + } + + List getAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'txid', values); + } + + Future deleteAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'txid', values); + } + + int deleteAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'txid', values); + } + + Future putByTxid(TransactionNote object) { + return putByIndex(r'txid', object); + } + + Id putByTxidSync(TransactionNote object, {bool saveLinks = true}) { + return putByIndexSync(r'txid', object, saveLinks: saveLinks); + } + + Future> putAllByTxid(List objects) { + return putAllByIndex(r'txid', objects); + } + + List putAllByTxidSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'txid', objects, saveLinks: saveLinks); + } } extension TransactionNoteQueryWhereSort @@ -182,6 +252,51 @@ extension TransactionNoteQueryWhere )); }); } + + QueryBuilder txidEqualTo( + String txid) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid', + value: [txid], + )); + }); + } + + QueryBuilder + txidNotEqualTo(String txid) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )); + } + }); + } } extension TransactionNoteQueryFilter @@ -242,6 +357,142 @@ extension TransactionNoteQueryFilter }); } + QueryBuilder + txidEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'txid', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'txid', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'txid', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + txidIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'txid', + value: '', + )); + }); + } + + QueryBuilder + txidIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'txid', + value: '', + )); + }); + } + QueryBuilder valueEqualTo( String value, { @@ -383,24 +634,23 @@ extension TransactionNoteQueryObject on QueryBuilder {} extension TransactionNoteQueryLinks - on QueryBuilder { - QueryBuilder - transaction(FilterQuery q) { - return QueryBuilder.apply(this, (query) { - return query.link(q, r'transaction'); - }); - } - - QueryBuilder - transactionIsNull() { - return QueryBuilder.apply(this, (query) { - return query.linkLength(r'transaction', 0, true, 0, true); - }); - } -} + on QueryBuilder {} extension TransactionNoteQuerySortBy on QueryBuilder { + QueryBuilder sortByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder + sortByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + QueryBuilder sortByValue() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'value', Sort.asc); @@ -429,6 +679,19 @@ extension TransactionNoteQuerySortThenBy }); } + QueryBuilder thenByTxid() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.asc); + }); + } + + QueryBuilder + thenByTxidDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'txid', Sort.desc); + }); + } + QueryBuilder thenByValue() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'value', Sort.asc); @@ -445,6 +708,13 @@ extension TransactionNoteQuerySortThenBy extension TransactionNoteQueryWhereDistinct on QueryBuilder { + QueryBuilder distinctByTxid( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'txid', caseSensitive: caseSensitive); + }); + } + QueryBuilder distinctByValue( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -461,6 +731,12 @@ extension TransactionNoteQueryProperty }); } + QueryBuilder txidProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'txid'); + }); + } + QueryBuilder valueProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'value'); From 4dd41a5048f23f6d6607a7444eb067573543c767 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 14:49:56 -0600 Subject: [PATCH 133/192] update address class for nonWallet address flag --- lib/models/isar/models/address/address.dart | 2 ++ lib/models/isar/models/address/address.g.dart | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 07f1a28e7..7d94a9315 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -53,6 +53,7 @@ enum AddressType { p2sh, p2wpkh, cryptonote, + nonWallet, } enum AddressSubType { @@ -61,4 +62,5 @@ enum AddressSubType { paynymNotification, paynymSend, paynymReceive, + nonWallet, } diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 0afbe1fc5..2f6098595 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -166,6 +166,7 @@ const _AddresssubTypeEnumValueMap = { 'paynymNotification': 2, 'paynymSend': 3, 'paynymReceive': 4, + 'nonWallet': 5, }; const _AddresssubTypeValueEnumMap = { 0: AddressSubType.receiving, @@ -173,18 +174,21 @@ const _AddresssubTypeValueEnumMap = { 2: AddressSubType.paynymNotification, 3: AddressSubType.paynymSend, 4: AddressSubType.paynymReceive, + 5: AddressSubType.nonWallet, }; const _AddresstypeEnumValueMap = { 'p2pkh': 0, 'p2sh': 1, 'p2wpkh': 2, 'cryptonote': 3, + 'nonWallet': 4, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, 1: AddressType.p2sh, 2: AddressType.p2wpkh, 3: AddressType.cryptonote, + 4: AddressType.nonWallet, }; Id _addressGetId(Address object) { From 5819241c15cf415d0aae6515aa2e20a10432c941 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 14:50:22 -0600 Subject: [PATCH 134/192] fix tx parse address bug --- lib/services/coins/coin_paynym_extension.dart | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index e0a1b83f8..e0ac141dc 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:developer'; import 'dart:typed_data'; import 'package:bip47/bip47.dart'; @@ -562,15 +561,14 @@ extension PayNym on DogecoinWallet { } } -Future, List>> parseTransaction( +Future, List, Address>> + parseTransaction( Map txData, dynamic electrumxClient, List

myAddresses, Coin coin, int minConfirms, ) async { - final transactionAddress = txData["address"] as Address; - Set receivingAddresses = myAddresses .where((e) => e.subType == AddressSubType.receiving) .map((e) => e.value) @@ -672,19 +670,32 @@ Future, List>> parseTransaction( tx.timestamp = txData["blocktime"] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // this should be the address we used to originally fetch the tx so we should - // be able to easily figure out if the tx is a send or receive - tx.address.value = transactionAddress; + // this is the address initially used to fetch the txid + Address transactionAddress = txData["address"] as Address; if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self tx.type = TransactionType.sentToSelf; + + // should be 0 tx.amount = amountSentFromWallet - amountReceivedInWallet - fee - changeAmount; } else if (mySentFromAddresses.isNotEmpty) { // outgoing tx tx.type = TransactionType.outgoing; tx.amount = amountSentFromWallet - changeAmount - fee; + + final possible = + outputAddresses.difference(myChangeReceivedOnAddresses).first; + + if (transactionAddress.value != possible) { + transactionAddress = Address() + ..value = possible + ..derivationIndex = -1 + ..subType = AddressSubType.nonWallet + ..type = AddressType.nonWallet + ..publicKey = []; + } } else { // incoming tx tx.type = TransactionType.incoming; @@ -696,11 +707,6 @@ Future, List>> parseTransaction( tx.fee = fee; - log("transactionAddress: $transactionAddress"); - log("mySentFromAddresses: $mySentFromAddresses"); - log("myReceivedOnAddresses: $myReceivedOnAddresses"); - log("myChangeReceivedOnAddresses: $myChangeReceivedOnAddresses"); - List outs = []; List ins = []; @@ -740,5 +746,5 @@ Future, List>> parseTransaction( tx.otherData = null; tx.isLelantus = null; - return Tuple3(tx, outs, ins); + return Tuple4(tx, outs, ins, transactionAddress); } From 5e7bd0d8aef16bd5b6c4121ca1c9e7ba8bec8c14 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 14:50:43 -0600 Subject: [PATCH 135/192] fix bitcoin transaction refresh --- .../coins/bitcoin/bitcoin_wallet.dart | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index e121347b9..73a9808c5 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:developer'; import 'dart:io'; import 'package:bech32/bech32.dart'; @@ -1998,15 +1997,15 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - // bool _duplicateTxCheck( - // List> allTransactions, String txid) { - // for (int i = 0; i < allTransactions.length; i++) { - // if (allTransactions[i]["txid"] == txid) { - // return true; - // } - // } - // return false; - // } + bool _duplicateTxCheck( + List> allTransactions, String txid) { + for (int i = 0; i < allTransactions.length; i++) { + if (allTransactions[i]["txid"] == txid) { + return true; + } + } + return false; + } Future _refreshTransactions() async { final List allAddresses = @@ -2041,14 +2040,14 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - // if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses - .filter() - .valueEqualTo(txHash["address"] as String) - .findFirst(); - tx["height"] = txHash["height"]; - allTransactions.add(tx); - // } + if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } } } @@ -2064,13 +2063,10 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // await fastFetch(vHashes.toList()); final List< - Tuple3, - List>> txnsData = []; + Tuple4, + List, isar_models.Address>> txnsData = []; for (final txObject in allTransactions) { - print("========================================================="); - log(txObject.toString()); - final data = await parseTransaction( txObject, cachedElectrumXClient, @@ -2102,6 +2098,16 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await tx.inputs.save(); } + // check if address exists in db and add if it does not + if (await isar.addresses + .where() + .valueEqualTo(data.item4.value) + .findFirst() == + null) { + await isar.addresses.put(data.item4); + } + // link and save address + tx.address.value = data.item4; await tx.address.save(); } }); From e14c36257450a509408b5e33b15ae5f4f6345907 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 14:59:47 -0600 Subject: [PATCH 136/192] rename var --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 73a9808c5..f0ece7dc4 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2011,7 +2011,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final List allAddresses = await _fetchAllOwnAddresses(); - final Set> allReceivingTxHashes = + final Set> allTxHashes = (await _fetchHistory(allAddresses.map((e) => e.value).toList())) .toSet(); @@ -2026,7 +2026,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentHeight = await chainHeight; - for (final txHash in allReceivingTxHashes) { + for (final txHash in allTxHashes) { final storedTx = await isar.transactions .where() .txidEqualTo(txHash["tx_hash"] as String) From 3414c717414a39feffdcfac77c94b2b70770cf7a Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 15:36:19 -0600 Subject: [PATCH 137/192] update other coin's parse transaction and db update --- .../coins/bitcoin/bitcoin_wallet.dart | 37 +- .../coins/bitcoincash/bitcoincash_wallet.dart | 71 ++-- .../coins/dogecoin/dogecoin_wallet.dart | 44 ++- lib/services/coins/firo/firo_wallet.dart | 341 +++-------------- .../coins/litecoin/litecoin_wallet.dart | 345 ++---------------- lib/services/coins/monero/monero_wallet.dart | 68 +--- .../coins/namecoin/namecoin_wallet.dart | 342 ++--------------- .../coins/particl/particl_wallet.dart | 149 ++------ .../coins/wownero/wownero_wallet.dart | 68 +--- lib/services/mixins/wallet_db.dart | 42 +++ 10 files changed, 267 insertions(+), 1240 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index f0ece7dc4..0c7d421e0 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2064,7 +2064,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final List< Tuple4, - List, isar_models.Address>> txnsData = []; + List, isar_models.Address?>> txnsData = []; for (final txObject in allTransactions) { final data = await parseTransaction( @@ -2077,40 +2077,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } - await isar.writeTxn(() async { - for (final data in txnsData) { - final tx = data.item1; - - // save transaction - await isar.transactions.put(tx); - - // link and save outputs - if (data.item2.isNotEmpty) { - await isar.outputs.putAll(data.item2); - tx.outputs.addAll(data.item2); - await tx.outputs.save(); - } - - // link and save inputs - if (data.item3.isNotEmpty) { - await isar.inputs.putAll(data.item3); - tx.inputs.addAll(data.item3); - await tx.inputs.save(); - } - - // check if address exists in db and add if it does not - if (await isar.addresses - .where() - .valueEqualTo(data.item4.value) - .findFirst() == - null) { - await isar.addresses.put(data.item4); - } - // link and save address - tx.address.value = data.item4; - await tx.address.save(); - } - }); + await addNewTransactionData(txnsData); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 4908efc37..0ed724632 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1940,21 +1940,31 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { List> allTransactions = []; - for (final txHash in allTxHashes) { - final tx = await cachedElectrumXClient.getTransaction( - txHash: txHash["tx_hash"] as String, - verbose: true, - coin: coin, - ); + final currentHeight = await chainHeight; - // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses - .filter() - .valueEqualTo(txHash["address"] as String) - .findFirst(); - tx["height"] = txHash["height"]; - allTransactions.add(tx); + for (final txHash in allTxHashes) { + final storedTx = await isar.transactions + .where() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); + + if (storedTx == null || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); + if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } } } // @@ -1964,7 +1974,9 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("allTransactions length: ${allTransactions.length}", // level: LogLevel.Info); - final List txns = []; + final List< + Tuple4, + List, isar_models.Address?>> txns = []; for (final txData in allTransactions) { Set inputAddresses = {}; @@ -2060,6 +2072,10 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { tx.timestamp = txData["blocktime"] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); + // this is the address initially used to fetch the txid + isar_models.Address transactionAddress = + txData["address"] as isar_models.Address; + if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self tx.type = isar_models.TransactionType.sentToSelf; @@ -2069,6 +2085,17 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // outgoing tx tx.type = isar_models.TransactionType.outgoing; tx.amount = amountSentFromWallet - changeAmount - fee; + final possible = + outputAddresses.difference(myChangeReceivedOnAddresses).first; + + if (transactionAddress.value != possible) { + transactionAddress = isar_models.Address() + ..value = possible + ..derivationIndex = -1 + ..subType = AddressSubType.nonWallet + ..type = AddressType.nonWallet + ..publicKey = []; + } } else { // incoming tx tx.type = isar_models.TransactionType.incoming; @@ -2079,7 +2106,9 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { tx.subType = isar_models.TransactionSubType.none; tx.fee = fee; - tx.address.value = txData["address"] as isar_models.Address; + + List inputs = []; + List outputs = []; for (final json in txData["vin"] as List) { bool isCoinBase = json['coinbase'] != null; @@ -2092,7 +2121,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; input.sequence = json['sequence'] as int?; input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; - tx.inputs.add(input); + inputs.add(input); } for (final json in txData["vout"] as List) { @@ -2107,7 +2136,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Decimal.parse(json["value"].toString()), coin, ); - tx.outputs.add(output); + outputs.add(output); } tx.height = txData["height"] as int?; @@ -2116,12 +2145,10 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { tx.slateId = null; tx.otherData = null; - txns.add(tx); + txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } - await isar.writeTxn(() async { - await isar.transactions.putAll(txns); - }); + await addNewTransactionData(txns); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 76f9e8bd8..f363d72d9 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1846,18 +1846,27 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await fastFetch(hashes); List> allTransactions = []; + final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final tx = await cachedElectrumXClient.getTransaction( - txHash: txHash["tx_hash"] as String, - verbose: true, - coin: coin, - ); + final storedTx = await isar.transactions + .where() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); - if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; - tx["height"] = txHash["height"]; - allTransactions.add(tx); + if (storedTx == null || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = txHash["address"]; + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } } } @@ -1871,6 +1880,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await fastFetch(vHashes.toList()); + final List< + Tuple4, + List, isar_models.Address?>> txns = []; + for (final txObject in allTransactions) { final txn = await parseTransaction( txObject, @@ -1880,17 +1893,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { MINIMUM_CONFIRMATIONS, ); - // final tx = await isar.transactions - // .filter() - // .txidMatches(midSortedTx.txid) - // .findFirst(); - // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar - // if (tx == null) { - await isar.writeTxn(() async { - await isar.transactions.put(txn.item1); - }); - // } + txns.add(txn); } + + await addNewTransactionData(txns); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 15aaa2a47..77409cb60 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3228,241 +3228,58 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } } + bool _duplicateTxCheck( + List> allTransactions, String txid) { + for (int i = 0; i < allTransactions.length; i++) { + if (allTransactions[i]["txid"] == txid) { + return true; + } + } + return false; + } + Future _refreshTransactions() async { - // final changeAddresses = - // DB.instance.get(boxName: walletId, key: 'changeAddresses') - // as List; - // final List allAddresses = await _fetchAllOwnAddresses(); - // // Logging.instance.log("receiving addresses: $receivingAddresses"); - // // Logging.instance.log("change addresses: $changeAddresses"); - // - // List> allTxHashes = await _fetchHistory(allAddresses); - // - // final cachedTransactions = - // DB.instance.get(boxName: walletId, key: 'latest_tx_model') - // as models.TransactionData?; - // int latestTxnBlockHeight = - // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - // as int? ?? - // 0; - // - // final unconfirmedCachedTransactions = - // cachedTransactions?.getAllTransactions() ?? {}; - // unconfirmedCachedTransactions - // .removeWhere((key, value) => value.confirmedStatus); - // - // if (cachedTransactions != null) { - // for (final tx in allTxHashes.toList(growable: false)) { - // final txHeight = tx["height"] as int; - // if (txHeight > 0 && - // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - // allTxHashes.remove(tx); - // } - // } - // } - // } - // - // List hashes = []; - // for (var element in allTxHashes) { - // hashes.add(element['tx_hash'] as String); - // } final List allAddresses = await _fetchAllOwnAddresses(); final List> allTxHashes = await _fetchHistory(allAddresses.map((e) => e.value).toList()); - List hashes = - allTxHashes.map((e) => e['tx_hash'] as String).toList(growable: false); + List> allTransactions = []; - List> allTransactions = await fastFetch(hashes); + final currentHeight = await chainHeight; - Logging.instance.log("allTransactions length: ${allTransactions.length}", - level: LogLevel.Info); + for (final txHash in allTxHashes) { + final storedTx = await isar.transactions + .where() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); + + if (storedTx == null || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } + } + } + + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; - // // sort thing stuff - // final currentPrice = await firoPrice; - // final List> midSortedArray = []; - // - // final locale = - // Platform.isWindows ? "en_US" : await Devicelocale.currentLocale; - // - // Logging.instance.log("refresh the txs", level: LogLevel.Info); for (final txObject in allTransactions) { - // // Logging.instance.log(txObject); - // List sendersArray = []; - // List recipientsArray = []; - // - // // Usually only has value when txType = 'Send' - // int inputAmtSentFromWallet = 0; - // // Usually has value regardless of txType due to change addresses - // int outputAmtAddressedToWallet = 0; - // - // Map midSortedTx = {}; - // List aliens = []; - // - // for (final input in txObject["vin"] as List) { - // final address = input["address"] as String?; - // if (address != null) { - // sendersArray.add(address); - // } - // } - // - // // Logging.instance.log("sendersArray: $sendersArray"); - // - // for (final output in txObject["vout"] as List) { - // final addresses = output["scriptPubKey"]["addresses"] as List?; - // if (addresses != null && addresses.isNotEmpty) { - // recipientsArray.add(addresses[0] as String); - // } - // } - // // Logging.instance.log("recipientsArray: $recipientsArray"); - // - // final foundInSenders = - // allAddresses.any((element) => sendersArray.contains(element)); - // // Logging.instance.log("foundInSenders: $foundInSenders"); - // - // String outAddress = ""; - // - // int fees = 0; - // - // // If txType = Sent, then calculate inputAmtSentFromWallet, calculate who received how much in aliens array (check outputs) - // if (foundInSenders) { - // int outAmount = 0; - // int inAmount = 0; - // bool nFeesUsed = false; - // - // for (final input in txObject["vin"] as List) { - // final nFees = input["nFees"]; - // if (nFees != null) { - // nFeesUsed = true; - // fees = (Decimal.parse(nFees.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // final address = input["address"]; - // final value = input["valueSat"]; - // if (address != null && value != null) { - // if (allAddresses.contains(address)) { - // inputAmtSentFromWallet += value as int; - // } - // } - // - // if (value != null) { - // inAmount += value as int; - // } - // } - // - // for (final output in txObject["vout"] as List) { - // final addresses = output["scriptPubKey"]["addresses"] as List?; - // final value = output["value"]; - // if (addresses != null && addresses.isNotEmpty) { - // final address = addresses[0] as String; - // if (value != null) { - // if (changeAddresses.contains(address)) { - // inputAmtSentFromWallet -= (Decimal.parse(value.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } else { - // outAddress = address; - // } - // } - // } - // if (value != null) { - // outAmount += (Decimal.parse(value.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // - // fees = nFeesUsed ? fees : inAmount - outAmount; - // inputAmtSentFromWallet -= inAmount - outAmount; - // } else { - // for (final input in txObject["vin"] as List) { - // final nFees = input["nFees"]; - // if (nFees != null) { - // fees += (Decimal.parse(nFees.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // - // for (final output in txObject["vout"] as List) { - // final addresses = output["scriptPubKey"]["addresses"] as List?; - // if (addresses != null && addresses.isNotEmpty) { - // final address = addresses[0] as String; - // final value = output["value"]; - // // Logging.instance.log(address + value.toString()); - // - // if (allAddresses.contains(address)) { - // outputAmtAddressedToWallet += (Decimal.parse(value.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // outAddress = address; - // } - // } - // } - // } - // - // final int confirms = txObject["confirmations"] as int? ?? 0; - // - // // create final tx map - // midSortedTx["txid"] = txObject["txid"]; - // midSortedTx["confirmed_status"] = confirms >= MINIMUM_CONFIRMATIONS; - // midSortedTx["confirmations"] = confirms; - // midSortedTx["timestamp"] = txObject["blocktime"] ?? - // (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // if (foundInSenders) { - // midSortedTx["txType"] = "Sent"; - // midSortedTx["amount"] = inputAmtSentFromWallet; - // final String worthNow = Format.localizedStringAsFixed( - // value: ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2), - // decimalPlaces: 2, - // locale: locale!); - // midSortedTx["worthNow"] = worthNow; - // midSortedTx["worthAtBlockTimestamp"] = worthNow; - // if (txObject["vout"][0]["scriptPubKey"]["type"] == "lelantusmint") { - // midSortedTx["subType"] = "mint"; - // } - // } else { - // midSortedTx["txType"] = "Received"; - // midSortedTx["amount"] = outputAmtAddressedToWallet; - // final worthNow = Format.localizedStringAsFixed( - // value: - // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2), - // decimalPlaces: 2, - // locale: locale!); - // midSortedTx["worthNow"] = worthNow; - // midSortedTx["worthAtBlockTimestamp"] = worthNow; - // } - // midSortedTx["aliens"] = aliens; - // midSortedTx["fees"] = fees; - // midSortedTx["address"] = outAddress; - // midSortedTx["inputSize"] = txObject["vin"].length; - // midSortedTx["outputSize"] = txObject["vout"].length; - // midSortedTx["inputs"] = txObject["vin"]; - // midSortedTx["outputs"] = txObject["vout"]; - // - // final int height = txObject["height"] as int? ?? 0; - // midSortedTx["height"] = height; - // - // if (height >= latestTxnBlockHeight) { - // latestTxnBlockHeight = height; - // } - // - // midSortedArray.add(midSortedTx); - - final txn = await parseTransaction( + final data = await parseTransaction( txObject, cachedElectrumXClient, allAddresses, @@ -3470,80 +3287,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { MINIMUM_CONFIRMATIONS, ); - // final tx = await isar.transactions - // .filter() - // .txidMatches(midSortedTx.txid) - // .findFirst(); - // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar - // if (tx == null) { - await isar.writeTxn(() async { - await isar.transactions.put(txn.item1); - }); - // } + txnsData.add(data); } - // - // // sort by date ---- //TODO not sure if needed - // // shouldn't be any issues with a null timestamp but I got one at some point? - // midSortedArray.sort((a, b) { - // final aT = a["timestamp"]; - // final bT = b["timestamp"]; - // - // if (aT == null && bT == null) { - // return 0; - // } else if (aT == null) { - // return -1; - // } else if (bT == null) { - // return 1; - // } else { - // return (bT as int) - (aT as int); - // } - // }); - // - // // buildDateTimeChunks - // final Map result = {"dateTimeChunks": []}; - // final dateArray = []; - // - // for (int i = 0; i < midSortedArray.length; i++) { - // final txObject = midSortedArray[i]; - // final date = - // models.extractDateFromTimestamp(txObject["timestamp"] as int); - // final txTimeArray = [txObject["timestamp"], date]; - // - // if (dateArray.contains(txTimeArray[1])) { - // result["dateTimeChunks"].forEach((dynamic chunk) { - // if (models.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], - // }; - // result["dateTimeChunks"].add(chunk); - // } - // } - // - // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - // transactionsMap - // .addAll(models.TransactionData.fromJson(result).getAllTransactions()); - // - // final txModel = models.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); - // - // cachedTxData = txModel; - // return txModel; + + await addNewTransactionData(txnsData); } Future _refreshUTXOs() async { diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index c2ef099aa..6490a7f58 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2094,83 +2094,42 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final List allAddresses = await _fetchAllOwnAddresses(); - // final changeAddresses = DB.instance.get( - // boxName: walletId, key: 'changeAddressesP2WPKH') as List; - // final changeAddressesP2PKH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - // as List; - // final changeAddressesP2SH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - // as List; - // - // for (var i = 0; i < changeAddressesP2PKH.length; i++) { - // changeAddresses.add(changeAddressesP2PKH[i] as String); - // } - // for (var i = 0; i < changeAddressesP2SH.length; i++) { - // changeAddresses.add(changeAddressesP2SH[i] as String); - // } - final List> allTxHashes = await _fetchHistory(allAddresses.map((e) => e.value).toList()); - // final cachedTransactions = - // DB.instance.get(boxName: walletId, key: 'latest_tx_model') - // as TransactionData?; - // int latestTxnBlockHeight = - // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - // as int? ?? - // 0; - // - // final unconfirmedCachedTransactions = - // cachedTransactions?.getAllTransactions() ?? {}; - // unconfirmedCachedTransactions - // .removeWhere((key, value) => value.confirmedStatus); - // - // if (cachedTransactions != null) { - // for (final tx in allTxHashes.toList(growable: false)) { - // final txHeight = tx["height"] as int; - // if (txHeight > 0 && - // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - // allTxHashes.remove(tx); - // } - // } - // } - // } - Set hashes = {}; for (var element in allTxHashes) { hashes.add(element['tx_hash'] as String); } await fastFetch(hashes.toList()); + List> allTransactions = []; + final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final tx = await cachedElectrumXClient.getTransaction( - txHash: txHash["tx_hash"] as String, - verbose: true, - coin: coin, - ); + final storedTx = await isar.transactions + .where() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); - // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; - tx["height"] = txHash["height"]; - allTransactions.add(tx); + if (storedTx == null || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); + if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = txHash["address"]; + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } } } - // Logging.instance.log("addAddresses: $allAddresses", level: LogLevel.Info); - // Logging.instance.log("allTxHashes: $allTxHashes", level: LogLevel.Info); - // - // Logging.instance.log("allTransactions length: ${allTransactions.length}", - // level: LogLevel.Info); - // - // final priceData = - // await _priceAPI.getPricesAnd24hChange(baseCurrency: _prefs.currency); - // Decimal currentPrice = priceData[coin]?.item1 ?? Decimal.zero; - // final List> midSortedArray = []; - + // prefetch/cache Set vHashes = {}; for (final txObject in allTransactions) { for (int i = 0; i < (txObject["vin"] as List).length; i++) { @@ -2181,8 +2140,12 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await fastFetch(vHashes.toList()); + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; + for (final txObject in allTransactions) { - final txn = await parseTransaction( + final data = await parseTransaction( txObject, cachedElectrumXClient, allAddresses, @@ -2190,261 +2153,9 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { MINIMUM_CONFIRMATIONS, ); - // final tx = await isar.transactions - // .filter() - // .txidMatches(midSortedTx.txid) - // .findFirst(); - // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar - // if (tx == null) { - await isar.writeTxn(() async { - await isar.transactions.put(txn.item1); - }); - // } - - // List sendersArray = []; - // List recipientsArray = []; - // - // // Usually only has value when txType = 'Send' - // int inputAmtSentFromWallet = 0; - // // Usually has value regardless of txType due to change addresses - // int outputAmtAddressedToWallet = 0; - // int fee = 0; - // - // Map midSortedTx = {}; - // - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"]![i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // final address = out["scriptPubKey"]["addresses"][0] as String?; - // if (address != null) { - // sendersArray.add(address); - // } - // } - // } - // } - // - // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - // - // for (final output in txObject["vout"] as List) { - // final address = output["scriptPubKey"]["addresses"][0] as String?; - // if (address != null) { - // recipientsArray.add(address); - // } - // } - // - // Logging.instance - // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - // - // final foundInSenders = - // allAddresses.any((element) => sendersArray.contains(element)); - // Logging.instance - // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - // - // // If txType = Sent, then calculate inputAmtSentFromWallet - // if (foundInSenders) { - // int totalInput = 0; - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"]![i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // inputAmtSentFromWallet += - // (Decimal.parse(out["value"]!.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // totalInput = inputAmtSentFromWallet; - // int totalOutput = 0; - // - // for (final output in txObject["vout"] as List) { - // final String address = - // output["scriptPubKey"]!["addresses"][0] as String; - // final value = output["value"]!; - // final _value = (Decimal.parse(value.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOutput += _value; - // if (changeAddresses.contains(address)) { - // inputAmtSentFromWallet -= _value; - // } else { - // // change address from 'sent from' to the 'sent to' address - // txObject["address"] = address; - // } - // } - // // calculate transaction fee - // fee = totalInput - totalOutput; - // // subtract fee from sent to calculate correct value of sent tx - // inputAmtSentFromWallet -= fee; - // } else { - // // counters for fee calculation - // int totalOut = 0; - // int totalIn = 0; - // - // // add up received tx value - // for (final output in txObject["vout"] as List) { - // final address = output["scriptPubKey"]["addresses"][0]; - // if (address != null) { - // final value = (Decimal.parse(output["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOut += value; - // if (allAddresses.contains(address)) { - // outputAmtAddressedToWallet += value; - // } - // } - // } - // - // // calculate fee for received tx - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"][i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // totalIn += (Decimal.parse(out["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // fee = totalIn - totalOut; - // } - // - // // create final tx map - // midSortedTx["txid"] = txObject["txid"]; - // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - // midSortedTx["timestamp"] = txObject["blocktime"] ?? - // (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // - // if (foundInSenders) { - // midSortedTx["txType"] = "Sent"; - // midSortedTx["amount"] = inputAmtSentFromWallet; - // final String worthNow = - // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // midSortedTx["worthAtBlockTimestamp"] = worthNow; - // } else { - // midSortedTx["txType"] = "Received"; - // midSortedTx["amount"] = outputAmtAddressedToWallet; - // final worthNow = - // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // } - // midSortedTx["aliens"] = []; - // midSortedTx["fees"] = fee; - // midSortedTx["address"] = txObject["address"]; - // midSortedTx["inputSize"] = txObject["vin"].length; - // midSortedTx["outputSize"] = txObject["vout"].length; - // midSortedTx["inputs"] = txObject["vin"]; - // midSortedTx["outputs"] = txObject["vout"]; - // - // final int height = txObject["height"] as int; - // midSortedTx["height"] = height; - // - // if (height >= latestTxnBlockHeight) { - // latestTxnBlockHeight = height; - // } - // - // midSortedArray.add(midSortedTx); + txnsData.add(data); } - // - // // sort by date ---- //TODO not sure if needed - // // shouldn't be any issues with a null timestamp but I got one at some point? - // midSortedArray - // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // // { - // // final aT = a["timestamp"]; - // // final bT = b["timestamp"]; - // // - // // if (aT == null && bT == null) { - // // return 0; - // // } else if (aT == null) { - // // return -1; - // // } else if (bT == null) { - // // return 1; - // // } else { - // // return bT - aT; - // // } - // // }); - // - // // buildDateTimeChunks - // 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], - // }; - // result["dateTimeChunks"].add(chunk); - // } - // } - // - // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - // transactionsMap - // .addAll(TransactionData.fromJson(result).getAllTransactions()); - // - // 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); - // - // cachedTxData = txModel; - // return txModel; + await addNewTransactionData(txnsData); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 6e8a53283..c83ee60b7 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -46,6 +46,7 @@ import 'package:stackwallet/utilities/format.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'; const int MINIMUM_CONFIRMATIONS = 10; @@ -848,7 +849,9 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // // final Set cachedTxids = Set.from(txidsList); - final List txns = []; + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; if (transactions != null) { for (var tx in transactions.entries) { @@ -865,6 +868,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { txn.txid = tx.value.id; txn.timestamp = (tx.value.date.millisecondsSinceEpoch ~/ 1000); + isar_models.Address? address; if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; @@ -874,7 +878,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (addressString != null) { - txn.address.value = await isar.addresses + address = await isar.addresses .filter() .valueEqualTo(addressString) .findFirst(); @@ -899,67 +903,11 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { txn.slateId = null; txn.otherData = null; - txns.add(txn); + txnsData.add(Tuple4(txn, [], [], address)); } } - await isar.writeTxn(() async { - await isar.transactions.putAll(txns); - }); - - // // sort by date ---- - // midSortedArray - // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // Logging.instance.log(midSortedArray, level: LogLevel.Info); - // - // // buildDateTimeChunks - // 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], - // }; - // result["dateTimeChunks"].add(chunk); - // } - // } - // - // // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - // final Map transactionsMap = {}; - // transactionsMap - // .addAll(TransactionData.fromJson(result).getAllTransactions()); - // - // 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); - // // await DB.instance.put( - // // boxName: walletId, - // // key: 'cachedTxids', - // // value: cachedTxids.toList(growable: false)); - // - // return txModel; + await addNewTransactionData(txnsData); } Future _pathForWalletDir({ diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index d71d5460e..bb9e872ce 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2076,69 +2076,37 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final List allAddresses = await _fetchAllOwnAddresses(); - // final changeAddresses = DB.instance.get( - // boxName: walletId, key: 'changeAddressesP2WPKH') as List; - // final changeAddressesP2PKH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') - // as List; - // final changeAddressesP2SH = - // DB.instance.get(boxName: walletId, key: 'changeAddressesP2SH') - // as List; - // - // for (var i = 0; i < changeAddressesP2PKH.length; i++) { - // changeAddresses.add(changeAddressesP2PKH[i] as String); - // } - // for (var i = 0; i < changeAddressesP2SH.length; i++) { - // changeAddresses.add(changeAddressesP2SH[i] as String); - // } - final List> allTxHashes = await _fetchHistory(allAddresses.map((e) => e.value).toList()); - // final cachedTransactions = - // DB.instance.get(boxName: walletId, key: 'latest_tx_model') - // as TransactionData?; - // int latestTxnBlockHeight = - // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - // as int? ?? - // 0; - // - // final unconfirmedCachedTransactions = - // cachedTransactions?.getAllTransactions() ?? {}; - // unconfirmedCachedTransactions - // .removeWhere((key, value) => value.confirmedStatus); - // - // if (cachedTransactions != null) { - // for (final tx in allTxHashes.toList(growable: false)) { - // final txHeight = tx["height"] as int; - // if (txHeight > 0 && - // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - // allTxHashes.remove(tx); - // } - // } - // } - // } - Set hashes = {}; for (var element in allTxHashes) { hashes.add(element['tx_hash'] as String); } await fastFetch(hashes.toList()); List> allTransactions = []; + final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final tx = await cachedElectrumXClient.getTransaction( - txHash: txHash["tx_hash"] as String, - verbose: true, - coin: coin, - ); + final storedTx = await isar.transactions + .where() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); - // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; - tx["height"] = txHash["height"]; - allTransactions.add(tx); + if (storedTx == null || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); + if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = txHash["address"]; + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } } } @@ -2158,8 +2126,12 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await fastFetch(vHashes.toList()); + final List< + Tuple4, + List, isar_models.Address>> txnsData = []; + for (final txObject in allTransactions) { - final txn = await parseTransaction( + final data = await parseTransaction( txObject, cachedElectrumXClient, allAddresses, @@ -2167,271 +2139,9 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { MINIMUM_CONFIRMATIONS, ); - // final tx = await isar.transactions - // .filter() - // .txidMatches(midSortedTx.txid) - // .findFirst(); - // // we don't need to check this but it saves a write tx instead of overwriting the transaction in Isar - // if (tx == null) { - await isar.writeTxn(() async { - await isar.transactions.put(txn.item1); - }); - // } - - // List sendersArray = []; - // List recipientsArray = []; - // - // // Usually only has value when txType = 'Send' - // int inputAmtSentFromWallet = 0; - // // Usually has value regardless of txType due to change addresses - // int outputAmtAddressedToWallet = 0; - // int fee = 0; - // - // Map midSortedTx = {}; - // - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"]![i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // String? address = out["scriptPubKey"]["address"] as String?; - // if (address == null && out["scriptPubKey"]["address"] != null) { - // address = out["scriptPubKey"]["address"] as String?; - // } - // - // if (address != null) { - // sendersArray.add(address); - // } - // } - // } - // } - // - // Logging.instance.log("sendersArray: $sendersArray", level: LogLevel.Info); - // - // for (final output in txObject["vout"] as List) { - // String? address = output["scriptPubKey"]["address"] as String?; - // if (address == null && output["scriptPubKey"]["address"] != null) { - // address = output["scriptPubKey"]["address"] as String?; - // } - // if (address != null) { - // recipientsArray.add(address); - // } - // } - // - // Logging.instance - // .log("recipientsArray: $recipientsArray", level: LogLevel.Info); - // - // final foundInSenders = - // allAddresses.any((element) => sendersArray.contains(element)); - // Logging.instance - // .log("foundInSenders: $foundInSenders", level: LogLevel.Info); - // - // // If txType = Sent, then calculate inputAmtSentFromWallet - // if (foundInSenders) { - // int totalInput = 0; - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"]![i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // inputAmtSentFromWallet += - // (Decimal.parse(out["value"]!.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // totalInput = inputAmtSentFromWallet; - // int totalOutput = 0; - // - // for (final output in txObject["vout"] as List) { - // Logging.instance.log(output, level: LogLevel.Info); - // final address = output["scriptPubKey"]["address"]; - // final value = output["value"]; - // final _value = (Decimal.parse(value.toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOutput += _value; - // if (changeAddresses.contains(address)) { - // inputAmtSentFromWallet -= _value; - // } else { - // // change address from 'sent from' to the 'sent to' address - // txObject["address"] = address; - // } - // } - // // calculate transaction fee - // fee = totalInput - totalOutput; - // // subtract fee from sent to calculate correct value of sent tx - // inputAmtSentFromWallet -= fee; - // } else { - // // counters for fee calculation - // int totalOut = 0; - // int totalIn = 0; - // - // // add up received tx value - // for (final output in txObject["vout"] as List) { - // String? address = output["scriptPubKey"]["address"] as String?; - // if (address == null && output["scriptPubKey"]["address"] != null) { - // address = output["scriptPubKey"]["address"] as String?; - // } - // if (address != null) { - // final value = (Decimal.parse(output["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // totalOut += value; - // if (allAddresses.contains(address)) { - // outputAmtAddressedToWallet += value; - // } - // } - // } - // - // // calculate fee for received tx - // for (int i = 0; i < (txObject["vin"] as List).length; i++) { - // final input = txObject["vin"][i] as Map; - // final prevTxid = input["txid"] as String; - // final prevOut = input["vout"] as int; - // final tx = await _cachedElectrumXClient.getTransaction( - // txHash: prevTxid, - // coin: coin, - // ); - // - // for (final out in tx["vout"] as List) { - // if (prevOut == out["n"]) { - // totalIn += (Decimal.parse(out["value"].toString()) * - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toBigInt() - // .toInt(); - // } - // } - // } - // fee = totalIn - totalOut; - // } - // - // // create final tx map - // midSortedTx["txid"] = txObject["txid"]; - // midSortedTx["confirmed_status"] = (txObject["confirmations"] != null) && - // (txObject["confirmations"] as int >= MINIMUM_CONFIRMATIONS); - // midSortedTx["confirmations"] = txObject["confirmations"] ?? 0; - // midSortedTx["timestamp"] = txObject["blocktime"] ?? - // (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // - // if (foundInSenders) { - // midSortedTx["txType"] = "Sent"; - // midSortedTx["amount"] = inputAmtSentFromWallet; - // final String worthNow = - // ((currentPrice * Decimal.fromInt(inputAmtSentFromWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // midSortedTx["worthAtBlockTimestamp"] = worthNow; - // } else { - // midSortedTx["txType"] = "Received"; - // midSortedTx["amount"] = outputAmtAddressedToWallet; - // final worthNow = - // ((currentPrice * Decimal.fromInt(outputAmtAddressedToWallet)) / - // Decimal.fromInt(Constants.satsPerCoin(coin))) - // .toDecimal(scaleOnInfinitePrecision: 2) - // .toStringAsFixed(2); - // midSortedTx["worthNow"] = worthNow; - // } - // midSortedTx["aliens"] = []; - // midSortedTx["fees"] = fee; - // midSortedTx["address"] = txObject["address"]; - // midSortedTx["inputSize"] = txObject["vin"].length; - // midSortedTx["outputSize"] = txObject["vout"].length; - // midSortedTx["inputs"] = txObject["vin"]; - // midSortedTx["outputs"] = txObject["vout"]; - // - // final int height = txObject["height"] as int; - // midSortedTx["height"] = height; - // - // if (height >= latestTxnBlockHeight) { - // latestTxnBlockHeight = height; - // } - // - // midSortedArray.add(midSortedTx); + txnsData.add(data); } - // - // // sort by date ---- //TODO not sure if needed - // // shouldn't be any issues with a null timestamp but I got one at some point? - // midSortedArray - // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // // { - // // final aT = a["timestamp"]; - // // final bT = b["timestamp"]; - // // - // // if (aT == null && bT == null) { - // // return 0; - // // } else if (aT == null) { - // // return -1; - // // } else if (bT == null) { - // // return 1; - // // } else { - // // return bT - aT; - // // } - // // }); - // - // // buildDateTimeChunks - // 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], - // }; - // result["dateTimeChunks"].add(chunk); - // } - // } - // - // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - // transactionsMap - // .addAll(TransactionData.fromJson(result).getAllTransactions()); - // - // 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); - // - // cachedTxData = txModel; - // return txModel; + await addNewTransactionData(txnsData); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 24ee293f2..37035b93c 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1962,9 +1962,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { Future _refreshTransactions() async { final allAddresses = await _fetchAllOwnAddresses(); - // final changeAddresses = DB.instance.get( - // boxName: walletId, key: 'changeAddressesP2WPKH') as List; - List changeAddresses = allAddresses .where((e) => e.subType == isar_models.AddressSubType.change) .map((e) => e.value) @@ -1973,54 +1970,38 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { final List> allTxHashes = await _fetchHistory( allAddresses.map((e) => e.value).toList(growable: false)); - // final cachedTransactions = - // DB.instance.get(boxName: walletId, key: 'latest_tx_model') - // as TransactionData?; - // int latestTxnBlockHeight = - // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") - // as int? ?? - // 0; - // - // final unconfirmedCachedTransactions = - // cachedTransactions?.getAllTransactions() ?? {}; - // unconfirmedCachedTransactions - // .removeWhere((key, value) => value.confirmedStatus); - // - // if (cachedTransactions != null) { - // for (final tx in allTxHashes.toList(growable: false)) { - // final txHeight = tx["height"] as int; - // if (txHeight > 0 && - // txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { - // if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - // allTxHashes.remove(tx); - // } - // } - // } - // } - Set hashes = {}; for (var element in allTxHashes) { hashes.add(element['tx_hash'] as String); } await fastFetch(hashes.toList()); List> allTransactions = []; + final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final tx = await cachedElectrumXClient.getTransaction( - txHash: txHash["tx_hash"] as String, - verbose: true, - coin: coin, - ); + final storedTx = await isar.transactions + .where() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); - // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - // TODO fix this for sent to self transactions? - if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses - .filter() - .valueEqualTo(txHash["address"] as String) - .findFirst(); - tx["height"] = txHash["height"]; - allTransactions.add(tx); + if (storedTx == null || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); + // TODO fix this for sent to self transactions? + if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } } } @@ -2044,7 +2025,9 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } await fastFetch(vHashes.toList()); - final List txns = []; + final List< + Tuple4, + List, isar_models.Address?>> txns = []; for (final txObject in allTransactions) { List sendersArray = []; @@ -2269,7 +2252,11 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { tx.subType = isar_models.TransactionSubType.none; tx.fee = fee; - tx.address.value = midSortedTx["address"] as isar_models.Address?; + isar_models.Address? transactionAddress = + midSortedTx["address"] as isar_models.Address?; + + List inputs = []; + List outputs = []; for (final json in midSortedTx["vin"] as List) { bool isCoinBase = json['coinbase'] != null; @@ -2282,7 +2269,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; input.sequence = json['sequence'] as int?; input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; - tx.inputs.add(input); + inputs.add(input); } for (final json in midSortedTx["vout"] as List) { @@ -2298,7 +2285,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { Decimal.tryParse(json["value"].toString()) ?? Decimal.zero, coin, ); - tx.outputs.add(output); + outputs.add(output); } tx.height = height; @@ -2307,76 +2294,10 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { tx.slateId = null; tx.otherData = null; - txns.add(tx); + txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } - await isar.writeTxn(() async { - await isar.transactions.putAll(txns); - }); - - // - // // sort by date ---- //TODO not sure if needed - // // shouldn't be any issues with a null timestamp but I got one at some point? - // midSortedArray - // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // // { - // // final aT = a["timestamp"]; - // // final bT = b["timestamp"]; - // // - // // if (aT == null && bT == null) { - // // return 0; - // // } else if (aT == null) { - // // return -1; - // // } else if (bT == null) { - // // return 1; - // // } else { - // // return bT - aT; - // // } - // // }); - // - // // buildDateTimeChunks - // 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], - // }; - // result["dateTimeChunks"].add(chunk); - // } - // } - // - // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - // transactionsMap - // .addAll(TransactionData.fromJson(result).getAllTransactions()); - // - // 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; + await addNewTransactionData(txns); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 701ae0589..70f16d58d 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -48,6 +48,7 @@ import 'package:stackwallet/utilities/format.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'; const int MINIMUM_CONFIRMATIONS = 10; @@ -875,7 +876,9 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // } // } - final List txns = []; + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; if (transactions != null) { for (var tx in transactions.entries) { @@ -934,6 +937,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { txn.txid = tx.value.id; txn.timestamp = (tx.value.date.millisecondsSinceEpoch ~/ 1000); + isar_models.Address? address; if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; @@ -943,7 +947,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (addressString != null) { - txn.address.value = await isar.addresses + address = await isar.addresses .filter() .valueEqualTo(addressString) .findFirst(); @@ -968,67 +972,11 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { txn.slateId = null; txn.otherData = null; - txns.add(txn); + txnsData.add(Tuple4(txn, [], [], address)); } } - await isar.writeTxn(() async { - await isar.transactions.putAll(txns); - }); - - // // sort by date ---- - // midSortedArray - // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); - // Logging.instance.log(midSortedArray, level: LogLevel.Info); - // - // // buildDateTimeChunks - // 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], - // }; - // result["dateTimeChunks"].add(chunk); - // } - // } - // - // // final transactionsMap = cachedTransactions?.getAllTransactions() ?? {}; - // final Map transactionsMap = {}; - // transactionsMap - // .addAll(TransactionData.fromJson(result).getAllTransactions()); - // - // 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); - // // await DB.instance.put( - // // boxName: walletId, - // // key: 'cachedTxids', - // // value: cachedTxids.toList(growable: false)); - // - // return txModel; + await addNewTransactionData(txnsData); } Future _pathForWalletDir({ diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 365b6155a..5ea3a236a 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -1,6 +1,7 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/utilities/stack_file_system.dart'; +import 'package:tuple/tuple.dart'; mixin WalletDB { Isar? _isar; @@ -29,4 +30,45 @@ mixin WalletDB { } Future isarClose() async => await _isar?.close() ?? false; + + Future addNewTransactionData( + List, List, Address?>> + transactionsData) async { + await isar.writeTxn(() async { + for (final data in transactionsData) { + final tx = data.item1; + + // save transaction + await isar.transactions.put(tx); + + // link and save outputs + if (data.item2.isNotEmpty) { + await isar.outputs.putAll(data.item2); + tx.outputs.addAll(data.item2); + await tx.outputs.save(); + } + + // link and save inputs + if (data.item3.isNotEmpty) { + await isar.inputs.putAll(data.item3); + tx.inputs.addAll(data.item3); + await tx.inputs.save(); + } + + if (data.item4 != null) { + // check if address exists in db and add if it does not + if (await isar.addresses + .where() + .valueEqualTo(data.item4!.value) + .findFirst() == + null) { + await isar.addresses.put(data.item4!); + } + // link and save address + tx.address.value = data.item4; + await tx.address.save(); + } + } + }); + } } From 061658f2e90fe802ae9db570ce413e7195d0b730 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 15:44:14 -0600 Subject: [PATCH 138/192] dynamic map value fix --- lib/services/coins/dogecoin/dogecoin_wallet.dart | 5 ++++- lib/services/coins/litecoin/litecoin_wallet.dart | 5 ++++- lib/services/coins/namecoin/namecoin_wallet.dart | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index f363d72d9..ed887d1bb 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1863,7 +1863,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); tx["height"] = txHash["height"]; allTransactions.add(tx); } diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 6490a7f58..e596a9072 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2122,7 +2122,10 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); tx["height"] = txHash["height"]; allTransactions.add(tx); } diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index bb9e872ce..760c0afd6 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2103,7 +2103,10 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = txHash["address"]; + tx["address"] = await isar.addresses + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); tx["height"] = txHash["height"]; allTransactions.add(tx); } From 8a7236b46de65fb99d60bf6496c9078fc676114f Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 15:47:56 -0600 Subject: [PATCH 139/192] clear out isar blockchain data per wallet when doing full rescan --- .../coins/bitcoincash/bitcoincash_wallet.dart | 4 +++- lib/services/coins/dogecoin/dogecoin_wallet.dart | 9 +++++++++ lib/services/coins/epiccash/epiccash_wallet.dart | 9 +++++++++ lib/services/coins/firo/firo_wallet.dart | 9 +++++++++ lib/services/coins/litecoin/litecoin_wallet.dart | 9 +++++++++ lib/services/coins/monero/monero_wallet.dart | 9 +++++++++ lib/services/coins/namecoin/namecoin_wallet.dart | 9 +++++++++ lib/services/coins/particl/particl_wallet.dart | 11 +++++++++-- lib/services/coins/wownero/wownero_wallet.dart | 9 +++++++++ 9 files changed, 75 insertions(+), 3 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 0ed724632..6c48516a0 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2801,9 +2801,11 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // clear blockchain info await isar.writeTxn(() async { - await isar.addresses.clear(); await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); await isar.utxos.clear(); + await isar.addresses.clear(); }); try { diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index ed887d1bb..ff478c8c6 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -2435,6 +2435,15 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // back up data // await _rescanBackup(); + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); await _recoverWalletFromBIP32SeedPhrase( diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index e2b07c54f..c008132a2 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -904,6 +904,15 @@ class EpicCashWallet extends CoinServiceAPI ), ); + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + await epicUpdateLastScannedBlock(await getRestoreHeight()); if (!await startScans()) { diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 77409cb60..518fb5c68 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3596,6 +3596,15 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { // back up data // await _rescanBackup(); + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); await _recoverWalletFromBIP32SeedPhrase(mnemonic!, maxUnusedAddressGap); diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index e596a9072..0d0a867c3 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2823,6 +2823,15 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // back up data // await _rescanBackup(); + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); await _recoverWalletFromBIP32SeedPhrase( diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index c83ee60b7..b4d4a4778 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -215,6 +215,15 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int maxUnusedAddressGap, int maxNumberOfIndexesToCheck, ) async { + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; await walletBase?.rescan(height: restoreHeight); diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 760c0afd6..63883f887 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2812,6 +2812,15 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // back up data // await _rescanBackup(); + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); await _recoverWalletFromBIP32SeedPhrase( diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 37035b93c..01dfff0b8 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1992,8 +1992,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); - // TODO fix this for sent to self transactions? if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { tx["address"] = await isar.addresses .filter() @@ -2898,6 +2896,15 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { // back up data // await _rescanBackup(); + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); await _recoverWalletFromBIP32SeedPhrase( diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 70f16d58d..c09ac5294 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -238,6 +238,15 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int maxUnusedAddressGap, int maxNumberOfIndexesToCheck, ) async { + // clear blockchain info + await isar.writeTxn(() async { + await isar.transactions.clear(); + await isar.inputs.clear(); + await isar.outputs.clear(); + await isar.utxos.clear(); + await isar.addresses.clear(); + }); + var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; await walletBase?.rescan(height: restoreHeight); From afdc4963316d610b198bd6844ae6e933c309a461 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 15:57:49 -0600 Subject: [PATCH 140/192] update address model link --- lib/models/isar/models/address/address.dart | 2 +- lib/models/isar/models/address/address.g.dart | 51 ++++++++++++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 7d94a9315..bdddcb04a 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -27,7 +27,7 @@ class Address extends CryptoCurrencyAddress { @enumerated late AddressSubType subType; - final transaction = IsarLink(); + final transaction = IsarLinks(); int derivationChain() { if (subType == AddressSubType.receiving) { diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 2f6098595..490c0618b 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -83,7 +83,7 @@ const AddressSchema = CollectionSchema( id: -7782495619063243587, name: r'transaction', target: r'Transaction', - single: true, + single: false, ) }, embeddedSchemas: {}, @@ -973,11 +973,58 @@ extension AddressQueryLinks }); } - QueryBuilder transactionIsNull() { + QueryBuilder + transactionLengthEqualTo(int length) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', length, true, length, true); + }); + } + + QueryBuilder transactionIsEmpty() { return QueryBuilder.apply(this, (query) { return query.linkLength(r'transaction', 0, true, 0, true); }); } + + QueryBuilder + transactionIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', 0, false, 999999, true); + }); + } + + QueryBuilder + transactionLengthLessThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', 0, true, length, include); + }); + } + + QueryBuilder + transactionLengthGreaterThan( + int length, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength(r'transaction', length, include, 999999, true); + }); + } + + QueryBuilder + transactionLengthBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.linkLength( + r'transaction', lower, includeLower, upper, includeUpper); + }); + } } extension AddressQuerySortBy on QueryBuilder { From 40af5e520680de641d8725d3299bf983f1811dcf Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 15:58:05 -0600 Subject: [PATCH 141/192] build runner --- .../pages/send_view/send_view_test.mocks.dart | 49 +++++++++------ test/services/coins/manager_test.mocks.dart | 15 +++++ .../managed_favorite_test.mocks.dart | 59 ++++++++++++------- .../table_view/table_view_row_test.mocks.dart | 15 +++++ .../transaction_card_test.mocks.dart | 14 +++++ test/widget_tests/wallet_card_test.mocks.dart | 19 +++++- ...et_info_row_balance_future_test.mocks.dart | 55 ++++++++++------- .../wallet_info_row_test.mocks.dart | 55 ++++++++++------- 8 files changed, 200 insertions(+), 81 deletions(-) diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 7204ae4e6..53da96b3f 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -17,22 +17,23 @@ import 'package:stackwallet/models/isar/models/isar_models.dart' as _i22; import 'package:stackwallet/models/node_model.dart' as _i20; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart' - as _i25; + as _i26; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i21; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i23; +import 'package:stackwallet/services/locale_service.dart' as _i24; 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 _i15; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i26; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i27; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i24; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i25; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i18; +import 'package:tuple/tuple.dart' as _i23; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1580,12 +1581,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + _i17.Future addNewTransactionData( + List< + _i23.Tuple4<_i22.Transaction, List<_i22.Output>, + List<_i22.Input>, _i22.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i23.LocaleService { +class MockLocaleService extends _i1.Mock implements _i24.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1703,12 +1718,12 @@ class MockPrefs extends _i1.Mock implements _i18.Prefs { returnValueForMissingStub: null, ); @override - _i24.SyncingType get syncType => (super.noSuchMethod( + _i25.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i24.SyncingType.currentWalletOnly, - ) as _i24.SyncingType); + returnValue: _i25.SyncingType.currentWalletOnly, + ) as _i25.SyncingType); @override - set syncType(_i24.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i25.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -1768,12 +1783,12 @@ class MockPrefs extends _i1.Mock implements _i18.Prefs { returnValueForMissingStub: null, ); @override - _i25.ExchangeRateType get exchangeRateType => (super.noSuchMethod( + _i26.ExchangeRateType get exchangeRateType => (super.noSuchMethod( Invocation.getter(#exchangeRateType), - returnValue: _i25.ExchangeRateType.estimated, - ) as _i25.ExchangeRateType); + returnValue: _i26.ExchangeRateType.estimated, + ) as _i26.ExchangeRateType); @override - set exchangeRateType(_i25.ExchangeRateType? exchangeRateType) => + set exchangeRateType(_i26.ExchangeRateType? exchangeRateType) => super.noSuchMethod( Invocation.setter( #exchangeRateType, @@ -1855,12 +1870,12 @@ class MockPrefs extends _i1.Mock implements _i18.Prefs { returnValueForMissingStub: null, ); @override - _i26.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i27.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i26.BackupFrequencyType.everyTenMinutes, - ) as _i26.BackupFrequencyType); + returnValue: _i27.BackupFrequencyType.everyTenMinutes, + ) as _i27.BackupFrequencyType); @override - set backupFrequencyType(_i26.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i27.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index cea5d0013..b723c35c6 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -18,6 +18,7 @@ import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i9; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; +import 'package:tuple/tuple.dart' as _i14; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1008,6 +1009,20 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValue: _i10.Future.value(false), ) as _i10.Future); @override + _i10.Future addNewTransactionData( + List< + _i14.Tuple4<_i12.Transaction, List<_i12.Output>, + List<_i12.Input>, _i12.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); + @override void initFiroHive(String? walletId) => super.noSuchMethod( Invocation.method( #initFiroHive, diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 599e59c30..a75b0e294 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -14,12 +14,12 @@ 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 _i21; -import 'package:stackwallet/models/node_model.dart' as _i23; +import 'package:stackwallet/models/node_model.dart' as _i24; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i22; +import 'package:stackwallet/services/locale_service.dart' as _i23; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -29,6 +29,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i13; import 'package:stackwallet/utilities/prefs.dart' as _i18; +import 'package:tuple/tuple.dart' as _i22; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1370,12 +1371,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + _i17.Future addNewTransactionData( + List< + _i22.Tuple4<_i21.Transaction, List<_i21.Output>, + List<_i21.Input>, _i21.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i22.LocaleService { +class MockLocaleService extends _i1.Mock implements _i23.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1447,15 +1462,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i13.SecureStorageInterface); @override - List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i24.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i24.NodeModel>[], + ) as List<_i24.NodeModel>); @override - List<_i23.NodeModel> get nodes => (super.noSuchMethod( + List<_i24.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i24.NodeModel>[], + ) as List<_i24.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -1473,7 +1488,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i17.Future setPrimaryNodeFor({ required _i16.Coin? coin, - required _i23.NodeModel? node, + required _i24.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1490,40 +1505,40 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i23.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i24.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i23.NodeModel?); + )) as _i24.NodeModel?); @override - List<_i23.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i24.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i24.NodeModel>[], + ) as List<_i24.NodeModel>); @override - _i23.NodeModel? getNodeById({required String? id}) => + _i24.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i23.NodeModel?); + )) as _i24.NodeModel?); @override - List<_i23.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i24.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i24.NodeModel>[], + ) as List<_i24.NodeModel>); @override _i17.Future add( - _i23.NodeModel? node, + _i24.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1575,7 +1590,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i17.Future); @override _i17.Future edit( - _i23.NodeModel? editedNode, + _i24.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => 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 aca5e11a8..758f15bab 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 @@ -25,6 +25,7 @@ import 'package:stackwallet/services/wallets.dart' as _i14; import 'package:stackwallet/services/wallets_service.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; import 'package:stackwallet/utilities/prefs.dart' as _i17; +import 'package:tuple/tuple.dart' as _i21; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1355,6 +1356,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { ), returnValue: _i16.Future.value(false), ) as _i16.Future); + @override + _i16.Future addNewTransactionData( + List< + _i21.Tuple4<_i20.Transaction, List<_i20.Output>, + List<_i20.Input>, _i20.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); } /// A class which mocks [Manager]. diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 753e56f35..828ce04b9 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -1938,6 +1938,20 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: _i18.Future.value(false), ) as _i18.Future); @override + _i18.Future addNewTransactionData( + List< + _i15.Tuple4<_i21.Transaction, List<_i21.Output>, + List<_i21.Input>, _i21.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); + @override void initFiroHive(String? walletId) => super.noSuchMethod( Invocation.method( #initFiroHive, diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 83daf81fe..ac666d17c 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -17,7 +17,7 @@ import 'package:stackwallet/models/isar/models/isar_models.dart' as _i19; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i20; +import 'package:stackwallet/services/locale_service.dart' as _i21; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -25,6 +25,7 @@ import 'package:stackwallet/services/wallets.dart' as _i13; import 'package:stackwallet/services/wallets_service.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i14; import 'package:stackwallet/utilities/prefs.dart' as _i16; +import 'package:tuple/tuple.dart' as _i20; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1118,12 +1119,26 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { ), returnValue: _i15.Future.value(false), ) as _i15.Future); + @override + _i15.Future addNewTransactionData( + List< + _i20.Tuple4<_i19.Transaction, List<_i19.Output>, + List<_i19.Input>, _i19.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i20.LocaleService { +class MockLocaleService extends _i1.Mock implements _i21.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } 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 52c20a971..5b897ada5 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 @@ -14,7 +14,7 @@ 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 _i21; -import 'package:stackwallet/models/node_model.dart' as _i22; +import 'package:stackwallet/models/node_model.dart' as _i23; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; @@ -28,6 +28,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i13; import 'package:stackwallet/utilities/prefs.dart' as _i18; +import 'package:tuple/tuple.dart' as _i22; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1369,6 +1370,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + _i17.Future addNewTransactionData( + List< + _i22.Tuple4<_i21.Transaction, List<_i21.Output>, + List<_i21.Input>, _i21.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1384,15 +1399,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i13.SecureStorageInterface); @override - List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - List<_i22.NodeModel> get nodes => (super.noSuchMethod( + List<_i23.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -1410,7 +1425,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i17.Future setPrimaryNodeFor({ required _i16.Coin? coin, - required _i22.NodeModel? node, + required _i23.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1427,40 +1442,40 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i22.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i23.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i22.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i22.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i23.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - _i22.NodeModel? getNodeById({required String? id}) => + _i23.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i22.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i22.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i23.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override _i17.Future add( - _i22.NodeModel? node, + _i23.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1512,7 +1527,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i17.Future); @override _i17.Future edit( - _i22.NodeModel? editedNode, + _i23.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => 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 23c007ff9..9cbc74ac1 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 @@ -14,7 +14,7 @@ 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 _i21; -import 'package:stackwallet/models/node_model.dart' as _i22; +import 'package:stackwallet/models/node_model.dart' as _i23; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; @@ -28,6 +28,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i13; import 'package:stackwallet/utilities/prefs.dart' as _i18; +import 'package:tuple/tuple.dart' as _i22; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1369,6 +1370,20 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValue: _i17.Future.value(false), ) as _i17.Future); + @override + _i17.Future addNewTransactionData( + List< + _i22.Tuple4<_i21.Transaction, List<_i21.Output>, + List<_i21.Input>, _i21.Address?>>? + transactionsData) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [transactionsData], + ), + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1384,15 +1399,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i13.SecureStorageInterface); @override - List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - List<_i22.NodeModel> get nodes => (super.noSuchMethod( + List<_i23.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -1410,7 +1425,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i17.Future setPrimaryNodeFor({ required _i16.Coin? coin, - required _i22.NodeModel? node, + required _i23.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1427,40 +1442,40 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i22.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i23.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i22.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i22.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i23.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - _i22.NodeModel? getNodeById({required String? id}) => + _i23.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i22.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i22.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i23.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override _i17.Future add( - _i22.NodeModel? node, + _i23.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1512,7 +1527,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i17.Future); @override _i17.Future edit( - _i22.NodeModel? editedNode, + _i23.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => From c08c3f779df6bde34fa12aeef81a486483824344 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 16:11:34 -0600 Subject: [PATCH 142/192] shared address parse fix --- lib/services/mixins/wallet_db.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 5ea3a236a..00247f851 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -56,16 +56,18 @@ mixin WalletDB { } if (data.item4 != null) { + final address = await isar.addresses + .where() + .valueEqualTo(data.item4!.value) + .findFirst(); + // check if address exists in db and add if it does not - if (await isar.addresses - .where() - .valueEqualTo(data.item4!.value) - .findFirst() == - null) { + if (address == null) { await isar.addresses.put(data.item4!); } + // link and save address - tx.address.value = data.item4; + tx.address.value = address ?? data.item4!; await tx.address.save(); } } From ed0089e94d82f354a761d673c0366438d3298dab Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 16:35:14 -0600 Subject: [PATCH 143/192] default nodes fix --- lib/utilities/default_nodes.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index e45e33aec..b04bdcb7f 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -158,7 +158,7 @@ abstract class DefaultNodes { isDown: false); static NodeModel get bitcoinTestnet => NodeModel( - host: "bitcoin-testnet.cypherstack.com", + host: "bitcoin-testnet.stackwallet.com", port: 51002, name: defaultName, id: _nodeId(Coin.bitcoinTestNet), From c1e860ff52a186b5d3c091a10558a6e36eda9348 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 16:45:20 -0600 Subject: [PATCH 144/192] getConfirms fix --- lib/models/isar/models/blockchain_data/utxo.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index eda4c06ff..ff5507f39 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -31,6 +31,7 @@ class UTXO { late int? blockTime; int getConfirmations(int currentChainHeight) { + if (blockTime == null || blockHash == null) return 0; if (blockHeight == null) return 0; return max(0, currentChainHeight - blockHeight!); } From ea212b3dd869c75eb54faf32c56b000c7c0ddaef Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 17:00:05 -0600 Subject: [PATCH 145/192] useless print --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 0c7d421e0..a2aacbc25 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -892,8 +892,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log("chain height: $currentHeight", level: LogLevel.Info); - Logging.instance - .log("cached height: $storedHeight", level: LogLevel.Info); + // Logging.instance + // .log("cached height: $storedHeight", level: LogLevel.Info); if (currentHeight != storedHeight) { GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); From c503e8f8d8fb57cb16bc4edbbe7ed80fa2ece820 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 17:26:24 -0600 Subject: [PATCH 146/192] confirms bugfix --- lib/models/isar/models/blockchain_data/transaction.dart | 5 ++--- lib/models/isar/models/blockchain_data/utxo.dart | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 1fbacc784..efeefe85a 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -4,7 +4,6 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/address/address.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; -import 'package:stackwallet/models/isar/models/transaction_note.dart'; part 'transaction.g.dart'; @@ -49,8 +48,8 @@ class Transaction { final outputs = IsarLinks(); int getConfirmations(int currentChainHeight) { - if (height == null) return 0; - return max(0, currentChainHeight - height!); + if (height == null || height! <= 0) return 0; + return max(0, currentChainHeight - (height! - 1)); } bool isConfirmed(int currentChainHeight, int minimumConfirms) { diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index ff5507f39..d17ed23a8 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -32,8 +32,8 @@ class UTXO { int getConfirmations(int currentChainHeight) { if (blockTime == null || blockHash == null) return 0; - if (blockHeight == null) return 0; - return max(0, currentChainHeight - blockHeight!); + if (blockHeight == null || blockHeight! <= 0) return 0; + return max(0, currentChainHeight - (blockHeight! - 1)); } bool isConfirmed(int currentChainHeight, int minimumConfirms) { From 7fc4b724c4f930f5635806d75f057824073b3a12 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Jan 2023 17:36:59 -0600 Subject: [PATCH 147/192] add replace tx logic for potentially unconfirmed transactions to update properly --- lib/services/mixins/wallet_db.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 00247f851..3668670f1 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -38,6 +38,13 @@ mixin WalletDB { for (final data in transactionsData) { final tx = data.item1; + final potentiallyUnconfirmedTx = + await isar.transactions.where().txidEqualTo(tx.txid).findFirst(); + if (potentiallyUnconfirmedTx != null) { + // update use id to replace tx + tx.id = potentiallyUnconfirmedTx.id; + await isar.transactions.delete(potentiallyUnconfirmedTx.id); + } // save transaction await isar.transactions.put(tx); From 09b51def04e6300ca985a21bef6bd496cd5ac8f7 Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 14 Jan 2023 08:00:43 -0600 Subject: [PATCH 148/192] missing value init fix --- lib/services/coins/monero/monero_wallet.dart | 1 + lib/services/coins/wownero/wownero_wallet.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index b4d4a4778..cd5b1e35a 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -909,6 +909,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { txn.height = txHeight; txn.isCancelled = false; + txn.isLelantus = null; txn.slateId = null; txn.otherData = null; diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index c09ac5294..69a4e5d72 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -978,6 +978,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { txn.height = txHeight; txn.isCancelled = false; + txn.isLelantus = null; txn.slateId = null; txn.otherData = null; From 3d4d57a97c2f79bb98612de96b238318a9598f7d Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 08:34:52 -0600 Subject: [PATCH 149/192] max log message length to store in db --- lib/utilities/logger.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/utilities/logger.dart b/lib/utilities/logger.dart index 6a5083cbc..86bfef91e 100644 --- a/lib/utilities/logger.dart +++ b/lib/utilities/logger.dart @@ -49,9 +49,16 @@ class Logging { Logger.print(object, normalLength: !printFullLength); return; } + String message = object.toString(); + + // random value to check max size of message before storing in db + if (message.length > 20000) { + message = "${message.substring(0, 20000)}..."; + } + final now = core.DateTime.now().toUtc(); final log = Log() - ..message = object.toString() + ..message = message ..logLevel = level ..timestampInMillisUTC = now.millisecondsSinceEpoch; if (level == LogLevel.Error || level == LogLevel.Fatal) { From 5e592f8d2990df8a6c355cc1f179acb33154c0f7 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 08:53:46 -0600 Subject: [PATCH 150/192] epic index fix --- lib/services/coins/epiccash/epiccash_wallet.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index c008132a2..a2e45ec01 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -1061,6 +1061,8 @@ class EpicCashWallet extends CoinServiceAPI await Future.wait([ epicUpdateRestoreHeight(bufferedCreateHeight), updateCachedIsFavorite(false), + epicUpdateReceivingIndex(0), + epicUpdateChangeIndex(0), ]); } From 9388885047cc561de67e935c80d1bdc8f986ce91 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 09:17:32 -0600 Subject: [PATCH 151/192] add optional prefix param to address to script conversion --- lib/utilities/address_utils.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index a6cbb8b58..c5c4ae39b 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -20,9 +20,14 @@ class AddressUtils { /// attempts to convert a string to a valid scripthash /// /// Returns the scripthash or throws an exception on invalid firo address - static String convertToScriptHash(String address, NetworkType network) { + static String convertToScriptHash( + String address, + NetworkType network, [ + String overridePrefix = "", + ]) { try { - final output = Address.addressToOutputScript(address, network); + final output = + Address.addressToOutputScript(address, network, overridePrefix); final hash = sha256.convert(output.toList(growable: false)).toString(); final chars = hash.split(""); From 0223a75d9566ad3bbe1e6bdd3706baeec8f0230a Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 12:58:10 -0600 Subject: [PATCH 152/192] putAll --- lib/services/coins/firo/firo_wallet.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 518fb5c68..f1a562c4c 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -2849,8 +2849,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } // TODO: optimize this whole lelantus process - await isar.writeTxn( - () async => isar.transactions.putAllByTxid(listLelantusTxData)); + await isar + .writeTxn(() async => isar.transactions.putAll(listLelantusTxData)); // // update the _lelantusTransactionData // final models.TransactionData newTxData = @@ -4074,7 +4074,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } await isar.writeTxn(() async { - await isar.transactions.putAllByTxid(transactionMap.values.toList()); + await isar.transactions.putAll(transactionMap.values.toList()); }); } From 5562c14527e57327d374adc55048491ce71bd123 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 15:04:03 -0600 Subject: [PATCH 153/192] WIP refactor to single main isar db --- lib/db/main_db.dart | 167 +++++++ lib/main.dart | 4 + lib/models/isar/models/address/address.dart | 5 +- lib/models/isar/models/address/address.g.dart | 395 +++++++++++++++-- .../isar/models/blockchain_data/input.dart | 3 + .../isar/models/blockchain_data/input.g.dart | 238 +++++++++- .../isar/models/blockchain_data/output.dart | 3 + .../isar/models/blockchain_data/output.g.dart | 238 +++++++++- .../models/blockchain_data/transaction.dart | 5 +- .../models/blockchain_data/transaction.g.dart | 402 +++++++++++++++-- .../isar/models/blockchain_data/utxo.dart | 5 +- .../isar/models/blockchain_data/utxo.g.dart | 394 +++++++++++++++-- lib/models/isar/models/transaction_note.dart | 6 +- .../isar/models/transaction_note.g.dart | 405 +++++++++++++++-- .../subviews/contact_details_view.dart | 5 +- lib/pages/exchange_view/exchange_view.dart | 5 +- .../subwidgets/desktop_contact_details.dart | 5 +- .../desktop_all_trades_view.dart | 5 +- .../subwidgets/desktop_trade_history.dart | 5 +- .../coins/bitcoin/bitcoin_wallet.dart | 111 +++-- .../coins/bitcoincash/bitcoincash_wallet.dart | 111 +++-- lib/services/coins/coin_paynym_extension.dart | 11 +- lib/services/coins/coin_service.dart | 3 - .../coins/dogecoin/dogecoin_wallet.dart | 111 +++-- .../coins/epiccash/epiccash_wallet.dart | 30 +- lib/services/coins/firo/firo_wallet.dart | 134 +++--- .../coins/litecoin/litecoin_wallet.dart | 109 +++-- lib/services/coins/manager.dart | 3 - lib/services/coins/monero/monero_wallet.dart | 35 +- .../coins/namecoin/namecoin_wallet.dart | 109 +++-- .../coins/particl/particl_wallet.dart | 108 ++--- .../coins/wownero/wownero_wallet.dart | 35 +- lib/services/mixins/wallet_db.dart | 56 +-- .../pages/send_view/send_view_test.mocks.dart | 70 +-- ...d_address_book_view_screen_test.mocks.dart | 213 +++++---- ..._entry_details_view_screen_test.mocks.dart | 261 ++++++----- ...ess_book_entry_view_screen_test.mocks.dart | 203 ++++----- .../lockscreen_view_screen_test.mocks.dart | 387 ++++++++--------- .../main_view_screen_testA_test.mocks.dart | 339 +++++++-------- .../main_view_screen_testB_test.mocks.dart | 339 +++++++-------- .../main_view_screen_testC_test.mocks.dart | 339 +++++++-------- .../backup_key_view_screen_test.mocks.dart | 163 +++---- ...up_key_warning_view_screen_test.mocks.dart | 281 ++++++------ .../create_pin_view_screen_test.mocks.dart | 387 ++++++++--------- ...restore_wallet_view_screen_test.mocks.dart | 411 +++++++++--------- ...ify_backup_key_view_screen_test.mocks.dart | 163 +++---- .../currency_view_screen_test.mocks.dart | 163 +++---- ...dd_custom_node_view_screen_test.mocks.dart | 269 ++++++------ .../node_details_view_screen_test.mocks.dart | 269 ++++++------ .../wallet_backup_view_screen_test.mocks.dart | 163 +++---- ...rescan_warning_view_screen_test.mocks.dart | 163 +++---- ...elete_mnemonic_view_screen_test.mocks.dart | 281 ++++++------ ...allet_settings_view_screen_test.mocks.dart | 389 ++++++++--------- .../settings_view_screen_test.mocks.dart | 281 ++++++------ ...search_results_view_screen_test.mocks.dart | 221 +++++----- .../confirm_send_view_screen_test.mocks.dart | 205 ++++----- .../receive_view_screen_test.mocks.dart | 163 +++---- .../send_view_screen_test.mocks.dart | 215 +++++---- .../wallet_view_screen_test.mocks.dart | 221 +++++----- test/services/coins/manager_test.mocks.dart | 54 +-- .../managed_favorite_test.mocks.dart | 70 +-- .../table_view/table_view_row_test.mocks.dart | 70 +-- .../transaction_card_test.mocks.dart | 114 ++--- test/widget_tests/wallet_card_test.mocks.dart | 54 +-- ...et_info_row_balance_future_test.mocks.dart | 70 +-- .../wallet_info_row_test.mocks.dart | 70 +-- 66 files changed, 5752 insertions(+), 4570 deletions(-) create mode 100644 lib/db/main_db.dart diff --git a/lib/db/main_db.dart b/lib/db/main_db.dart new file mode 100644 index 000000000..1e8c710d3 --- /dev/null +++ b/lib/db/main_db.dart @@ -0,0 +1,167 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; +import 'package:stackwallet/utilities/stack_file_system.dart'; + +class MainDB { + MainDB._(); + static MainDB? _instance; + static MainDB get instance => _instance ??= MainDB._(); + + Isar? _isar; + + Isar get isar => _isar!; + + Future isarInit() async { + if (_isar != null && isar.isOpen) return false; + _isar = await Isar.open( + [ + TransactionSchema, + TransactionNoteSchema, + InputSchema, + OutputSchema, + UTXOSchema, + AddressSchema, + ], + directory: (await StackFileSystem.applicationIsarDirectory()).path, + inspector: true, + name: "wallet_data", + ); + return true; + } + + // addresses + QueryBuilder getAddresses( + String walletId) => + isar.addresses.where().walletIdEqualTo(walletId); + + Future putAddress(Address address) => isar.writeTxn(() async { + await isar.addresses.put(address); + }); + + Future putAddresses(List
addresses) => isar.writeTxn(() async { + await isar.addresses.putAll(addresses); + }); + + // transactions + QueryBuilder getTransactions( + String walletId) => + isar.transactions.where().walletIdEqualTo(walletId); + + Future putTransaction(Transaction transaction) => + isar.writeTxn(() async { + await isar.transactions.put(transaction); + }); + + Future putTransactions(List transactions) => + isar.writeTxn(() async { + await isar.transactions.putAll(transactions); + }); + + // utxos + QueryBuilder getUTXOs(String walletId) => + isar.utxos.where().walletIdEqualTo(walletId); + + Future putUTXO(UTXO utxo) => isar.writeTxn(() async { + await isar.utxos.put(utxo); + }); + + Future putUTXOs(List utxos) => isar.writeTxn(() async { + await isar.utxos.putAll(utxos); + }); + + // inputs + QueryBuilder getInputs(String walletId) => + isar.inputs.where().walletIdEqualTo(walletId); + + Future putInput(Input input) => isar.writeTxn(() async { + await isar.inputs.put(input); + }); + + Future putInputs(List inputs) => isar.writeTxn(() async { + await isar.inputs.putAll(inputs); + }); + + // outputs + QueryBuilder getOutputs(String walletId) => + isar.outputs.where().walletIdEqualTo(walletId); + + Future putOutput(Output output) => isar.writeTxn(() async { + await isar.outputs.put(output); + }); + + Future putOutputs(List outputs) => isar.writeTxn(() async { + await isar.outputs.putAll(outputs); + }); + + // transaction notes + QueryBuilder + getTransactionNotes(String walletId) => + isar.transactionNotes.where().walletIdEqualTo(walletId); + + Future putTransactionNote(TransactionNote transactionNote) => + isar.writeTxn(() async { + await isar.transactionNotes.put(transactionNote); + }); + + Future putTransactionNotes(List transactionNotes) => + isar.writeTxn(() async { + await isar.transactionNotes.putAll(transactionNotes); + }); + + // + Future deleteWalletBlockchainData(String walletId) async { + await isar.writeTxn(() async { + const paginateLimit = 50; + + // transactions + for (int i = 0; + i < getTransactions(walletId).countSync(); + i += paginateLimit) { + final txns = await getTransactions(walletId) + .offset(i) + .limit(paginateLimit) + .findAll(); + await isar.transactions + .deleteAll(txns.map((e) => e.id).toList(growable: false)); + } + + // addresses + for (int i = 0; + i < getAddresses(walletId).countSync(); + i += paginateLimit) { + final addresses = await getAddresses(walletId) + .offset(i) + .limit(paginateLimit) + .findAll(); + await isar.addresses + .deleteAll(addresses.map((e) => e.id).toList(growable: false)); + } + + // utxos + for (int i = 0; i < getUTXOs(walletId).countSync(); i += paginateLimit) { + final utxos = + await getUTXOs(walletId).offset(i).limit(paginateLimit).findAll(); + await isar.utxos + .deleteAll(utxos.map((e) => e.id).toList(growable: false)); + } + + // inputs + for (int i = 0; i < getInputs(walletId).countSync(); i += paginateLimit) { + final inputs = + await getInputs(walletId).offset(i).limit(paginateLimit).findAll(); + await isar.inputs + .deleteAll(inputs.map((e) => e.id).toList(growable: false)); + } + + // outputs + for (int i = 0; + i < getOutputs(walletId).countSync(); + i += paginateLimit) { + final outputs = + await getOutputs(walletId).offset(i).limit(paginateLimit).findAll(); + await isar.outputs + .deleteAll(outputs.map((e) => e.id).toList(growable: false)); + } + }); + } +} diff --git a/lib/main.dart b/lib/main.dart index 4303889b7..304d3d8fb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -63,6 +63,8 @@ import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:window_size/window_size.dart'; +import 'db/main_db.dart'; + final openedFromSWBFileStringStateProvider = StateProvider((ref) => null); @@ -263,6 +265,8 @@ class _MaterialAppWithThemeState extends ConsumerState await loadShared(); } + await MainDB.instance.isarInit(); + _notificationsService = ref.read(notificationsProvider); _nodeService = ref.read(nodeServiceChangeNotifierProvider); _tradesService = ref.read(tradesServiceProvider); diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index bdddcb04a..184b3eed8 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -13,7 +13,10 @@ class AddressException extends SWException { class Address extends CryptoCurrencyAddress { Id id = Isar.autoIncrement; - @Index(unique: true) + @Index() + late String walletId; + + @Index(unique: true, composite: [CompositeIndex("walletId")]) late String value; late List publicKey; diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 490c0618b..5d237f37d 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -43,6 +43,11 @@ const AddressSchema = CollectionSchema( id: 4, name: r'value', type: IsarType.string, + ), + r'walletId': PropertySchema( + id: 5, + name: r'walletId', + type: IsarType.string, ) }, estimateSize: _addressEstimateSize, @@ -51,9 +56,22 @@ const AddressSchema = CollectionSchema( deserializeProp: _addressDeserializeProp, idName: r'id', indexes: { - r'value': IndexSchema( - id: -8658876004265234192, - name: r'value', + r'walletId': IndexSchema( + id: -1783113319798776304, + name: r'walletId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'value_walletId': IndexSchema( + id: -7332188919457190704, + name: r'value_walletId', unique: true, replace: false, properties: [ @@ -61,6 +79,11 @@ const AddressSchema = CollectionSchema( name: r'value', type: IndexType.hash, caseSensitive: true, + ), + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, ) ], ), @@ -101,6 +124,7 @@ int _addressEstimateSize( var bytesCount = offsets.last; bytesCount += 3 + object.publicKey.length; bytesCount += 3 + object.value.length * 3; + bytesCount += 3 + object.walletId.length * 3; return bytesCount; } @@ -115,6 +139,7 @@ void _addressSerialize( writer.writeByte(offsets[2], object.subType.index); writer.writeByte(offsets[3], object.type.index); writer.writeString(offsets[4], object.value); + writer.writeString(offsets[5], object.walletId); } Address _addressDeserialize( @@ -133,6 +158,7 @@ Address _addressDeserialize( object.type = _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[3])] ?? AddressType.p2pkh; object.value = reader.readString(offsets[4]); + object.walletId = reader.readString(offsets[5]); return object; } @@ -155,6 +181,8 @@ P _addressDeserializeProp

( AddressType.p2pkh) as P; case 4: return (reader.readString(offset)) as P; + case 5: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -206,56 +234,89 @@ void _addressAttach(IsarCollection col, Id id, Address object) { } extension AddressByIndex on IsarCollection

{ - Future getByValue(String value) { - return getByIndex(r'value', [value]); + Future getByValueWalletId(String value, String walletId) { + return getByIndex(r'value_walletId', [value, walletId]); } - Address? getByValueSync(String value) { - return getByIndexSync(r'value', [value]); + Address? getByValueWalletIdSync(String value, String walletId) { + return getByIndexSync(r'value_walletId', [value, walletId]); } - Future deleteByValue(String value) { - return deleteByIndex(r'value', [value]); + Future deleteByValueWalletId(String value, String walletId) { + return deleteByIndex(r'value_walletId', [value, walletId]); } - bool deleteByValueSync(String value) { - return deleteByIndexSync(r'value', [value]); + bool deleteByValueWalletIdSync(String value, String walletId) { + return deleteByIndexSync(r'value_walletId', [value, walletId]); } - Future> getAllByValue(List valueValues) { - final values = valueValues.map((e) => [e]).toList(); - return getAllByIndex(r'value', values); + Future> getAllByValueWalletId( + List valueValues, List walletIdValues) { + final len = valueValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([valueValues[i], walletIdValues[i]]); + } + + return getAllByIndex(r'value_walletId', values); } - List getAllByValueSync(List valueValues) { - final values = valueValues.map((e) => [e]).toList(); - return getAllByIndexSync(r'value', values); + List getAllByValueWalletIdSync( + List valueValues, List walletIdValues) { + final len = valueValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([valueValues[i], walletIdValues[i]]); + } + + return getAllByIndexSync(r'value_walletId', values); } - Future deleteAllByValue(List valueValues) { - final values = valueValues.map((e) => [e]).toList(); - return deleteAllByIndex(r'value', values); + Future deleteAllByValueWalletId( + List valueValues, List walletIdValues) { + final len = valueValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([valueValues[i], walletIdValues[i]]); + } + + return deleteAllByIndex(r'value_walletId', values); } - int deleteAllByValueSync(List valueValues) { - final values = valueValues.map((e) => [e]).toList(); - return deleteAllByIndexSync(r'value', values); + int deleteAllByValueWalletIdSync( + List valueValues, List walletIdValues) { + final len = valueValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([valueValues[i], walletIdValues[i]]); + } + + return deleteAllByIndexSync(r'value_walletId', values); } - Future putByValue(Address object) { - return putByIndex(r'value', object); + Future putByValueWalletId(Address object) { + return putByIndex(r'value_walletId', object); } - Id putByValueSync(Address object, {bool saveLinks = true}) { - return putByIndexSync(r'value', object, saveLinks: saveLinks); + Id putByValueWalletIdSync(Address object, {bool saveLinks = true}) { + return putByIndexSync(r'value_walletId', object, saveLinks: saveLinks); } - Future> putAllByValue(List
objects) { - return putAllByIndex(r'value', objects); + Future> putAllByValueWalletId(List
objects) { + return putAllByIndex(r'value_walletId', objects); } - List putAllByValueSync(List
objects, {bool saveLinks = true}) { - return putAllByIndexSync(r'value', objects, saveLinks: saveLinks); + List putAllByValueWalletIdSync(List
objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'value_walletId', objects, saveLinks: saveLinks); } } @@ -341,28 +402,74 @@ extension AddressQueryWhere on QueryBuilder { }); } - QueryBuilder valueEqualTo(String value) { + QueryBuilder walletIdEqualTo( + String walletId) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IndexWhereClause.equalTo( - indexName: r'value', + indexName: r'walletId', + value: [walletId], + )); + }); + } + + QueryBuilder walletIdNotEqualTo( + String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder valueEqualToAnyWalletId( + String value) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'value_walletId', value: [value], )); }); } - QueryBuilder valueNotEqualTo( + QueryBuilder valueNotEqualToAnyWalletId( String value) { return QueryBuilder.apply(this, (query) { if (query.whereSort == Sort.asc) { return query .addWhereClause(IndexWhereClause.between( - indexName: r'value', + indexName: r'value_walletId', lower: [], upper: [value], includeUpper: false, )) .addWhereClause(IndexWhereClause.between( - indexName: r'value', + indexName: r'value_walletId', lower: [value], includeLower: false, upper: [], @@ -370,13 +477,13 @@ extension AddressQueryWhere on QueryBuilder { } else { return query .addWhereClause(IndexWhereClause.between( - indexName: r'value', + indexName: r'value_walletId', lower: [value], includeLower: false, upper: [], )) .addWhereClause(IndexWhereClause.between( - indexName: r'value', + indexName: r'value_walletId', lower: [], upper: [value], includeUpper: false, @@ -385,6 +492,51 @@ extension AddressQueryWhere on QueryBuilder { }); } + QueryBuilder valueWalletIdEqualTo( + String value, String walletId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'value_walletId', + value: [value, walletId], + )); + }); + } + + QueryBuilder + valueEqualToWalletIdNotEqualTo(String value, String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'value_walletId', + lower: [value], + upper: [value, walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'value_walletId', + lower: [value, walletId], + includeLower: false, + upper: [value], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'value_walletId', + lower: [value, walletId], + includeLower: false, + upper: [value], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'value_walletId', + lower: [value], + upper: [value, walletId], + includeUpper: false, + )); + } + }); + } + QueryBuilder derivationIndexEqualTo( int derivationIndex) { return QueryBuilder.apply(this, (query) { @@ -959,6 +1111,136 @@ extension AddressQueryFilter )); }); } + + QueryBuilder walletIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'walletId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'walletId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: '', + )); + }); + } + + QueryBuilder walletIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'walletId', + value: '', + )); + }); + } } extension AddressQueryObject @@ -1075,6 +1357,18 @@ extension AddressQuerySortBy on QueryBuilder { return query.addSortBy(r'value', Sort.desc); }); } + + QueryBuilder sortByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder sortByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension AddressQuerySortThenBy @@ -1138,6 +1432,18 @@ extension AddressQuerySortThenBy return query.addSortBy(r'value', Sort.desc); }); } + + QueryBuilder thenByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder thenByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension AddressQueryWhereDistinct @@ -1172,6 +1478,13 @@ extension AddressQueryWhereDistinct return query.addDistinctBy(r'value', caseSensitive: caseSensitive); }); } + + QueryBuilder distinctByWalletId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive); + }); + } } extension AddressQueryProperty @@ -1211,4 +1524,10 @@ extension AddressQueryProperty return query.addPropertyName(r'value'); }); } + + QueryBuilder walletIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'walletId'); + }); + } } diff --git a/lib/models/isar/models/blockchain_data/input.dart b/lib/models/isar/models/blockchain_data/input.dart index 0be374b81..0843dce36 100644 --- a/lib/models/isar/models/blockchain_data/input.dart +++ b/lib/models/isar/models/blockchain_data/input.dart @@ -8,6 +8,9 @@ part 'input.g.dart'; class Input { Id id = Isar.autoIncrement; + @Index() + late String walletId; + late String txid; late int vout; diff --git a/lib/models/isar/models/blockchain_data/input.g.dart b/lib/models/isar/models/blockchain_data/input.g.dart index b4a9c2865..1279f0a2e 100644 --- a/lib/models/isar/models/blockchain_data/input.g.dart +++ b/lib/models/isar/models/blockchain_data/input.g.dart @@ -51,6 +51,11 @@ const InputSchema = CollectionSchema( id: 6, name: r'vout', type: IsarType.long, + ), + r'walletId': PropertySchema( + id: 7, + name: r'walletId', + type: IsarType.string, ) }, estimateSize: _inputEstimateSize, @@ -58,7 +63,21 @@ const InputSchema = CollectionSchema( deserialize: _inputDeserialize, deserializeProp: _inputDeserializeProp, idName: r'id', - indexes: {}, + indexes: { + r'walletId': IndexSchema( + id: -1783113319798776304, + name: r'walletId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, links: { r'prevOut': LinkSchema( id: 2963704715567457192, @@ -106,6 +125,7 @@ int _inputEstimateSize( } } bytesCount += 3 + object.txid.length * 3; + bytesCount += 3 + object.walletId.length * 3; return bytesCount; } @@ -122,6 +142,7 @@ void _inputSerialize( writer.writeLong(offsets[4], object.sequence); writer.writeString(offsets[5], object.txid); writer.writeLong(offsets[6], object.vout); + writer.writeString(offsets[7], object.walletId); } Input _inputDeserialize( @@ -139,6 +160,7 @@ Input _inputDeserialize( object.sequence = reader.readLongOrNull(offsets[4]); object.txid = reader.readString(offsets[5]); object.vout = reader.readLong(offsets[6]); + object.walletId = reader.readString(offsets[7]); return object; } @@ -163,6 +185,8 @@ P _inputDeserializeProp

( return (reader.readString(offset)) as P; case 6: return (reader.readLong(offset)) as P; + case 7: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -256,6 +280,51 @@ extension InputQueryWhere on QueryBuilder { )); }); } + + QueryBuilder walletIdEqualTo( + String walletId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'walletId', + value: [walletId], + )); + }); + } + + QueryBuilder walletIdNotEqualTo( + String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )); + } + }); + } } extension InputQueryFilter on QueryBuilder { @@ -1030,6 +1099,136 @@ extension InputQueryFilter on QueryBuilder { )); }); } + + QueryBuilder walletIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'walletId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'walletId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: '', + )); + }); + } + + QueryBuilder walletIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'walletId', + value: '', + )); + }); + } } extension InputQueryObject on QueryBuilder {} @@ -1146,6 +1345,18 @@ extension InputQuerySortBy on QueryBuilder { return query.addSortBy(r'vout', Sort.desc); }); } + + QueryBuilder sortByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder sortByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension InputQuerySortThenBy on QueryBuilder { @@ -1244,6 +1455,18 @@ extension InputQuerySortThenBy on QueryBuilder { return query.addSortBy(r'vout', Sort.desc); }); } + + QueryBuilder thenByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder thenByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension InputQueryWhereDistinct on QueryBuilder { @@ -1293,6 +1516,13 @@ extension InputQueryWhereDistinct on QueryBuilder { return query.addDistinctBy(r'vout'); }); } + + QueryBuilder distinctByWalletId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive); + }); + } } extension InputQueryProperty on QueryBuilder { @@ -1344,4 +1574,10 @@ extension InputQueryProperty on QueryBuilder { return query.addPropertyName(r'vout'); }); } + + QueryBuilder walletIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'walletId'); + }); + } } diff --git a/lib/models/isar/models/blockchain_data/output.dart b/lib/models/isar/models/blockchain_data/output.dart index 0e4361a15..fe289f910 100644 --- a/lib/models/isar/models/blockchain_data/output.dart +++ b/lib/models/isar/models/blockchain_data/output.dart @@ -7,6 +7,9 @@ part 'output.g.dart'; class Output { Id id = Isar.autoIncrement; + @Index() + late String walletId; + late String? scriptPubKey; late String? scriptPubKeyAsm; diff --git a/lib/models/isar/models/blockchain_data/output.g.dart b/lib/models/isar/models/blockchain_data/output.g.dart index 086fd0684..c57015253 100644 --- a/lib/models/isar/models/blockchain_data/output.g.dart +++ b/lib/models/isar/models/blockchain_data/output.g.dart @@ -41,6 +41,11 @@ const OutputSchema = CollectionSchema( id: 4, name: r'value', type: IsarType.long, + ), + r'walletId': PropertySchema( + id: 5, + name: r'walletId', + type: IsarType.string, ) }, estimateSize: _outputEstimateSize, @@ -48,7 +53,21 @@ const OutputSchema = CollectionSchema( deserialize: _outputDeserialize, deserializeProp: _outputDeserializeProp, idName: r'id', - indexes: {}, + indexes: { + r'walletId': IndexSchema( + id: -1783113319798776304, + name: r'walletId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, links: { r'transaction': LinkSchema( id: -2089310750171432135, @@ -90,6 +109,7 @@ int _outputEstimateSize( bytesCount += 3 + value.length * 3; } } + bytesCount += 3 + object.walletId.length * 3; return bytesCount; } @@ -104,6 +124,7 @@ void _outputSerialize( writer.writeString(offsets[2], object.scriptPubKeyAsm); writer.writeString(offsets[3], object.scriptPubKeyType); writer.writeLong(offsets[4], object.value); + writer.writeString(offsets[5], object.walletId); } Output _outputDeserialize( @@ -119,6 +140,7 @@ Output _outputDeserialize( object.scriptPubKeyAsm = reader.readStringOrNull(offsets[2]); object.scriptPubKeyType = reader.readStringOrNull(offsets[3]); object.value = reader.readLong(offsets[4]); + object.walletId = reader.readString(offsets[5]); return object; } @@ -139,6 +161,8 @@ P _outputDeserializeProp

( return (reader.readStringOrNull(offset)) as P; case 4: return (reader.readLong(offset)) as P; + case 5: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -231,6 +255,51 @@ extension OutputQueryWhere on QueryBuilder { )); }); } + + QueryBuilder walletIdEqualTo( + String walletId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'walletId', + value: [walletId], + )); + }); + } + + QueryBuilder walletIdNotEqualTo( + String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )); + } + }); + } } extension OutputQueryFilter on QueryBuilder { @@ -919,6 +988,136 @@ extension OutputQueryFilter on QueryBuilder { )); }); } + + QueryBuilder walletIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'walletId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'walletId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: '', + )); + }); + } + + QueryBuilder walletIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'walletId', + value: '', + )); + }); + } } extension OutputQueryObject on QueryBuilder {} @@ -998,6 +1197,18 @@ extension OutputQuerySortBy on QueryBuilder { return query.addSortBy(r'value', Sort.desc); }); } + + QueryBuilder sortByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder sortByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension OutputQuerySortThenBy on QueryBuilder { @@ -1072,6 +1283,18 @@ extension OutputQuerySortThenBy on QueryBuilder { return query.addSortBy(r'value', Sort.desc); }); } + + QueryBuilder thenByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder thenByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension OutputQueryWhereDistinct on QueryBuilder { @@ -1111,6 +1334,13 @@ extension OutputQueryWhereDistinct on QueryBuilder { return query.addDistinctBy(r'value'); }); } + + QueryBuilder distinctByWalletId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive); + }); + } } extension OutputQueryProperty on QueryBuilder { @@ -1149,4 +1379,10 @@ extension OutputQueryProperty on QueryBuilder { return query.addPropertyName(r'value'); }); } + + QueryBuilder walletIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'walletId'); + }); + } } diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index efeefe85a..3c39e2fe6 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -11,7 +11,10 @@ part 'transaction.g.dart'; class Transaction { Id id = Isar.autoIncrement; - @Index(unique: true) + @Index() + late String walletId; + + @Index(unique: true, composite: [CompositeIndex("walletId")]) late String txid; @Index() diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 2b4e01d3a..12b95b5df 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -73,6 +73,11 @@ const TransactionSchema = CollectionSchema( name: r'type', type: IsarType.byte, enumMap: _TransactiontypeEnumValueMap, + ), + r'walletId': PropertySchema( + id: 11, + name: r'walletId', + type: IsarType.string, ) }, estimateSize: _transactionEstimateSize, @@ -81,9 +86,22 @@ const TransactionSchema = CollectionSchema( deserializeProp: _transactionDeserializeProp, idName: r'id', indexes: { - r'txid': IndexSchema( - id: 7339874292043634331, - name: r'txid', + r'walletId': IndexSchema( + id: -1783113319798776304, + name: r'walletId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'txid_walletId': IndexSchema( + id: -2771771174176035985, + name: r'txid_walletId', unique: true, replace: false, properties: [ @@ -91,6 +109,11 @@ const TransactionSchema = CollectionSchema( name: r'txid', type: IndexType.hash, caseSensitive: true, + ), + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, ) ], ), @@ -155,6 +178,7 @@ int _transactionEstimateSize( } } bytesCount += 3 + object.txid.length * 3; + bytesCount += 3 + object.walletId.length * 3; return bytesCount; } @@ -175,6 +199,7 @@ void _transactionSerialize( writer.writeLong(offsets[8], object.timestamp); writer.writeString(offsets[9], object.txid); writer.writeByte(offsets[10], object.type.index); + writer.writeString(offsets[11], object.walletId); } Transaction _transactionDeserialize( @@ -200,6 +225,7 @@ Transaction _transactionDeserialize( object.type = _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ?? TransactionType.outgoing; + object.walletId = reader.readString(offsets[11]); return object; } @@ -234,6 +260,8 @@ P _transactionDeserializeProp

( case 10: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; + case 11: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -281,57 +309,89 @@ void _transactionAttach( } extension TransactionByIndex on IsarCollection { - Future getByTxid(String txid) { - return getByIndex(r'txid', [txid]); + Future getByTxidWalletId(String txid, String walletId) { + return getByIndex(r'txid_walletId', [txid, walletId]); } - Transaction? getByTxidSync(String txid) { - return getByIndexSync(r'txid', [txid]); + Transaction? getByTxidWalletIdSync(String txid, String walletId) { + return getByIndexSync(r'txid_walletId', [txid, walletId]); } - Future deleteByTxid(String txid) { - return deleteByIndex(r'txid', [txid]); + Future deleteByTxidWalletId(String txid, String walletId) { + return deleteByIndex(r'txid_walletId', [txid, walletId]); } - bool deleteByTxidSync(String txid) { - return deleteByIndexSync(r'txid', [txid]); + bool deleteByTxidWalletIdSync(String txid, String walletId) { + return deleteByIndexSync(r'txid_walletId', [txid, walletId]); } - Future> getAllByTxid(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return getAllByIndex(r'txid', values); + Future> getAllByTxidWalletId( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return getAllByIndex(r'txid_walletId', values); } - List getAllByTxidSync(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return getAllByIndexSync(r'txid', values); + List getAllByTxidWalletIdSync( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return getAllByIndexSync(r'txid_walletId', values); } - Future deleteAllByTxid(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return deleteAllByIndex(r'txid', values); + Future deleteAllByTxidWalletId( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return deleteAllByIndex(r'txid_walletId', values); } - int deleteAllByTxidSync(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return deleteAllByIndexSync(r'txid', values); + int deleteAllByTxidWalletIdSync( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return deleteAllByIndexSync(r'txid_walletId', values); } - Future putByTxid(Transaction object) { - return putByIndex(r'txid', object); + Future putByTxidWalletId(Transaction object) { + return putByIndex(r'txid_walletId', object); } - Id putByTxidSync(Transaction object, {bool saveLinks = true}) { - return putByIndexSync(r'txid', object, saveLinks: saveLinks); + Id putByTxidWalletIdSync(Transaction object, {bool saveLinks = true}) { + return putByIndexSync(r'txid_walletId', object, saveLinks: saveLinks); } - Future> putAllByTxid(List objects) { - return putAllByIndex(r'txid', objects); + Future> putAllByTxidWalletId(List objects) { + return putAllByIndex(r'txid_walletId', objects); } - List putAllByTxidSync(List objects, + List putAllByTxidWalletIdSync(List objects, {bool saveLinks = true}) { - return putAllByIndexSync(r'txid', objects, saveLinks: saveLinks); + return putAllByIndexSync(r'txid_walletId', objects, saveLinks: saveLinks); } } @@ -420,29 +480,74 @@ extension TransactionQueryWhere }); } - QueryBuilder txidEqualTo( - String txid) { + QueryBuilder walletIdEqualTo( + String walletId) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IndexWhereClause.equalTo( - indexName: r'txid', + indexName: r'walletId', + value: [walletId], + )); + }); + } + + QueryBuilder walletIdNotEqualTo( + String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + txidEqualToAnyWalletId(String txid) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid_walletId', value: [txid], )); }); } - QueryBuilder txidNotEqualTo( - String txid) { + QueryBuilder + txidNotEqualToAnyWalletId(String txid) { return QueryBuilder.apply(this, (query) { if (query.whereSort == Sort.asc) { return query .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [], upper: [txid], includeUpper: false, )) .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [txid], includeLower: false, upper: [], @@ -450,13 +555,13 @@ extension TransactionQueryWhere } else { return query .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [txid], includeLower: false, upper: [], )) .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [], upper: [txid], includeUpper: false, @@ -465,6 +570,51 @@ extension TransactionQueryWhere }); } + QueryBuilder txidWalletIdEqualTo( + String txid, String walletId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid_walletId', + value: [txid, walletId], + )); + }); + } + + QueryBuilder + txidEqualToWalletIdNotEqualTo(String txid, String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid], + upper: [txid, walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid, walletId], + includeLower: false, + upper: [txid], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid, walletId], + includeLower: false, + upper: [txid], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid], + upper: [txid, walletId], + includeUpper: false, + )); + } + }); + } + QueryBuilder timestampEqualTo( int timestamp) { return QueryBuilder.apply(this, (query) { @@ -1427,6 +1577,141 @@ extension TransactionQueryFilter )); }); } + + QueryBuilder walletIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'walletId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'walletId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: '', + )); + }); + } + + QueryBuilder + walletIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'walletId', + value: '', + )); + }); + } } extension TransactionQueryObject @@ -1704,6 +1989,18 @@ extension TransactionQuerySortBy return query.addSortBy(r'type', Sort.desc); }); } + + QueryBuilder sortByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder sortByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension TransactionQuerySortThenBy @@ -1851,6 +2148,18 @@ extension TransactionQuerySortThenBy return query.addSortBy(r'type', Sort.desc); }); } + + QueryBuilder thenByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder thenByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension TransactionQueryWhereDistinct @@ -1923,6 +2232,13 @@ extension TransactionQueryWhereDistinct return query.addDistinctBy(r'type'); }); } + + QueryBuilder distinctByWalletId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive); + }); + } } extension TransactionQueryProperty @@ -1999,4 +2315,10 @@ extension TransactionQueryProperty return query.addPropertyName(r'type'); }); } + + QueryBuilder walletIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'walletId'); + }); + } } diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index d17ed23a8..e89fce9d8 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -8,7 +8,10 @@ part 'utxo.g.dart'; class UTXO { Id id = Isar.autoIncrement; - @Index(unique: true, replace: true) + @Index() + late String walletId; + + @Index(unique: true, replace: true, composite: [CompositeIndex("walletId")]) late String txid; late int vout; diff --git a/lib/models/isar/models/blockchain_data/utxo.g.dart b/lib/models/isar/models/blockchain_data/utxo.g.dart index 9c0772968..24496eb88 100644 --- a/lib/models/isar/models/blockchain_data/utxo.g.dart +++ b/lib/models/isar/models/blockchain_data/utxo.g.dart @@ -66,6 +66,11 @@ const UTXOSchema = CollectionSchema( id: 9, name: r'vout', type: IsarType.long, + ), + r'walletId': PropertySchema( + id: 10, + name: r'walletId', + type: IsarType.string, ) }, estimateSize: _uTXOEstimateSize, @@ -74,9 +79,22 @@ const UTXOSchema = CollectionSchema( deserializeProp: _uTXODeserializeProp, idName: r'id', indexes: { - r'txid': IndexSchema( - id: 7339874292043634331, - name: r'txid', + r'walletId': IndexSchema( + id: -1783113319798776304, + name: r'walletId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'txid_walletId': IndexSchema( + id: -2771771174176035985, + name: r'txid_walletId', unique: true, replace: true, properties: [ @@ -84,6 +102,11 @@ const UTXOSchema = CollectionSchema( name: r'txid', type: IndexType.hash, caseSensitive: true, + ), + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, ) ], ), @@ -129,6 +152,7 @@ int _uTXOEstimateSize( } bytesCount += 3 + object.name.length * 3; bytesCount += 3 + object.txid.length * 3; + bytesCount += 3 + object.walletId.length * 3; return bytesCount; } @@ -148,6 +172,7 @@ void _uTXOSerialize( writer.writeString(offsets[7], object.txid); writer.writeLong(offsets[8], object.value); writer.writeLong(offsets[9], object.vout); + writer.writeString(offsets[10], object.walletId); } UTXO _uTXODeserialize( @@ -168,6 +193,7 @@ UTXO _uTXODeserialize( object.txid = reader.readString(offsets[7]); object.value = reader.readLong(offsets[8]); object.vout = reader.readLong(offsets[9]); + object.walletId = reader.readString(offsets[10]); return object; } @@ -198,6 +224,8 @@ P _uTXODeserializeProp

( return (reader.readLong(offset)) as P; case 9: return (reader.readLong(offset)) as P; + case 10: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -216,56 +244,89 @@ void _uTXOAttach(IsarCollection col, Id id, UTXO object) { } extension UTXOByIndex on IsarCollection { - Future getByTxid(String txid) { - return getByIndex(r'txid', [txid]); + Future getByTxidWalletId(String txid, String walletId) { + return getByIndex(r'txid_walletId', [txid, walletId]); } - UTXO? getByTxidSync(String txid) { - return getByIndexSync(r'txid', [txid]); + UTXO? getByTxidWalletIdSync(String txid, String walletId) { + return getByIndexSync(r'txid_walletId', [txid, walletId]); } - Future deleteByTxid(String txid) { - return deleteByIndex(r'txid', [txid]); + Future deleteByTxidWalletId(String txid, String walletId) { + return deleteByIndex(r'txid_walletId', [txid, walletId]); } - bool deleteByTxidSync(String txid) { - return deleteByIndexSync(r'txid', [txid]); + bool deleteByTxidWalletIdSync(String txid, String walletId) { + return deleteByIndexSync(r'txid_walletId', [txid, walletId]); } - Future> getAllByTxid(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return getAllByIndex(r'txid', values); + Future> getAllByTxidWalletId( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return getAllByIndex(r'txid_walletId', values); } - List getAllByTxidSync(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return getAllByIndexSync(r'txid', values); + List getAllByTxidWalletIdSync( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return getAllByIndexSync(r'txid_walletId', values); } - Future deleteAllByTxid(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return deleteAllByIndex(r'txid', values); + Future deleteAllByTxidWalletId( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return deleteAllByIndex(r'txid_walletId', values); } - int deleteAllByTxidSync(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return deleteAllByIndexSync(r'txid', values); + int deleteAllByTxidWalletIdSync( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return deleteAllByIndexSync(r'txid_walletId', values); } - Future putByTxid(UTXO object) { - return putByIndex(r'txid', object); + Future putByTxidWalletId(UTXO object) { + return putByIndex(r'txid_walletId', object); } - Id putByTxidSync(UTXO object, {bool saveLinks = true}) { - return putByIndexSync(r'txid', object, saveLinks: saveLinks); + Id putByTxidWalletIdSync(UTXO object, {bool saveLinks = true}) { + return putByIndexSync(r'txid_walletId', object, saveLinks: saveLinks); } - Future> putAllByTxid(List objects) { - return putAllByIndex(r'txid', objects); + Future> putAllByTxidWalletId(List objects) { + return putAllByIndex(r'txid_walletId', objects); } - List putAllByTxidSync(List objects, {bool saveLinks = true}) { - return putAllByIndexSync(r'txid', objects, saveLinks: saveLinks); + List putAllByTxidWalletIdSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'txid_walletId', objects, saveLinks: saveLinks); } } @@ -351,27 +412,73 @@ extension UTXOQueryWhere on QueryBuilder { }); } - QueryBuilder txidEqualTo(String txid) { + QueryBuilder walletIdEqualTo(String walletId) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IndexWhereClause.equalTo( - indexName: r'txid', + indexName: r'walletId', + value: [walletId], + )); + }); + } + + QueryBuilder walletIdNotEqualTo( + String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder txidEqualToAnyWalletId( + String txid) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid_walletId', value: [txid], )); }); } - QueryBuilder txidNotEqualTo(String txid) { + QueryBuilder txidNotEqualToAnyWalletId( + String txid) { return QueryBuilder.apply(this, (query) { if (query.whereSort == Sort.asc) { return query .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [], upper: [txid], includeUpper: false, )) .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [txid], includeLower: false, upper: [], @@ -379,13 +486,13 @@ extension UTXOQueryWhere on QueryBuilder { } else { return query .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [txid], includeLower: false, upper: [], )) .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [], upper: [txid], includeUpper: false, @@ -394,6 +501,51 @@ extension UTXOQueryWhere on QueryBuilder { }); } + QueryBuilder txidWalletIdEqualTo( + String txid, String walletId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid_walletId', + value: [txid, walletId], + )); + }); + } + + QueryBuilder txidEqualToWalletIdNotEqualTo( + String txid, String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid], + upper: [txid, walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid, walletId], + includeLower: false, + upper: [txid], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid, walletId], + includeLower: false, + upper: [txid], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid], + upper: [txid, walletId], + includeUpper: false, + )); + } + }); + } + QueryBuilder isBlockedEqualTo(bool isBlocked) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IndexWhereClause.equalTo( @@ -1299,6 +1451,135 @@ extension UTXOQueryFilter on QueryBuilder { )); }); } + + QueryBuilder walletIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'walletId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdContains(String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'walletId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder walletIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: '', + )); + }); + } + + QueryBuilder walletIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'walletId', + value: '', + )); + }); + } } extension UTXOQueryObject on QueryBuilder {} @@ -1425,6 +1706,18 @@ extension UTXOQuerySortBy on QueryBuilder { return query.addSortBy(r'vout', Sort.desc); }); } + + QueryBuilder sortByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder sortByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension UTXOQuerySortThenBy on QueryBuilder { @@ -1559,6 +1852,18 @@ extension UTXOQuerySortThenBy on QueryBuilder { return query.addSortBy(r'vout', Sort.desc); }); } + + QueryBuilder thenByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder thenByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension UTXOQueryWhereDistinct on QueryBuilder { @@ -1626,6 +1931,13 @@ extension UTXOQueryWhereDistinct on QueryBuilder { return query.addDistinctBy(r'vout'); }); } + + QueryBuilder distinctByWalletId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive); + }); + } } extension UTXOQueryProperty on QueryBuilder { @@ -1694,4 +2006,10 @@ extension UTXOQueryProperty on QueryBuilder { return query.addPropertyName(r'vout'); }); } + + QueryBuilder walletIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'walletId'); + }); + } } diff --git a/lib/models/isar/models/transaction_note.dart b/lib/models/isar/models/transaction_note.dart index 0aaf8c2f0..d383c16d2 100644 --- a/lib/models/isar/models/transaction_note.dart +++ b/lib/models/isar/models/transaction_note.dart @@ -1,5 +1,4 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; part 'transaction_note.g.dart'; @@ -7,7 +6,10 @@ part 'transaction_note.g.dart'; class TransactionNote { Id id = Isar.autoIncrement; - @Index(unique: true) + @Index() + late String walletId; + + @Index(unique: true, composite: [CompositeIndex("walletId")]) late String txid; late String value; diff --git a/lib/models/isar/models/transaction_note.g.dart b/lib/models/isar/models/transaction_note.g.dart index 055a45d28..07db4d600 100644 --- a/lib/models/isar/models/transaction_note.g.dart +++ b/lib/models/isar/models/transaction_note.g.dart @@ -26,6 +26,11 @@ const TransactionNoteSchema = CollectionSchema( id: 1, name: r'value', type: IsarType.string, + ), + r'walletId': PropertySchema( + id: 2, + name: r'walletId', + type: IsarType.string, ) }, estimateSize: _transactionNoteEstimateSize, @@ -34,9 +39,22 @@ const TransactionNoteSchema = CollectionSchema( deserializeProp: _transactionNoteDeserializeProp, idName: r'id', indexes: { - r'txid': IndexSchema( - id: 7339874292043634331, - name: r'txid', + r'walletId': IndexSchema( + id: -1783113319798776304, + name: r'walletId', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'txid_walletId': IndexSchema( + id: -2771771174176035985, + name: r'txid_walletId', unique: true, replace: false, properties: [ @@ -44,6 +62,11 @@ const TransactionNoteSchema = CollectionSchema( name: r'txid', type: IndexType.hash, caseSensitive: true, + ), + IndexPropertySchema( + name: r'walletId', + type: IndexType.hash, + caseSensitive: true, ) ], ) @@ -64,6 +87,7 @@ int _transactionNoteEstimateSize( var bytesCount = offsets.last; bytesCount += 3 + object.txid.length * 3; bytesCount += 3 + object.value.length * 3; + bytesCount += 3 + object.walletId.length * 3; return bytesCount; } @@ -75,6 +99,7 @@ void _transactionNoteSerialize( ) { writer.writeString(offsets[0], object.txid); writer.writeString(offsets[1], object.value); + writer.writeString(offsets[2], object.walletId); } TransactionNote _transactionNoteDeserialize( @@ -87,6 +112,7 @@ TransactionNote _transactionNoteDeserialize( object.id = id; object.txid = reader.readString(offsets[0]); object.value = reader.readString(offsets[1]); + object.walletId = reader.readString(offsets[2]); return object; } @@ -101,6 +127,8 @@ P _transactionNoteDeserializeProp

( return (reader.readString(offset)) as P; case 1: return (reader.readString(offset)) as P; + case 2: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -120,57 +148,89 @@ void _transactionNoteAttach( } extension TransactionNoteByIndex on IsarCollection { - Future getByTxid(String txid) { - return getByIndex(r'txid', [txid]); + Future getByTxidWalletId(String txid, String walletId) { + return getByIndex(r'txid_walletId', [txid, walletId]); } - TransactionNote? getByTxidSync(String txid) { - return getByIndexSync(r'txid', [txid]); + TransactionNote? getByTxidWalletIdSync(String txid, String walletId) { + return getByIndexSync(r'txid_walletId', [txid, walletId]); } - Future deleteByTxid(String txid) { - return deleteByIndex(r'txid', [txid]); + Future deleteByTxidWalletId(String txid, String walletId) { + return deleteByIndex(r'txid_walletId', [txid, walletId]); } - bool deleteByTxidSync(String txid) { - return deleteByIndexSync(r'txid', [txid]); + bool deleteByTxidWalletIdSync(String txid, String walletId) { + return deleteByIndexSync(r'txid_walletId', [txid, walletId]); } - Future> getAllByTxid(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return getAllByIndex(r'txid', values); + Future> getAllByTxidWalletId( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return getAllByIndex(r'txid_walletId', values); } - List getAllByTxidSync(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return getAllByIndexSync(r'txid', values); + List getAllByTxidWalletIdSync( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return getAllByIndexSync(r'txid_walletId', values); } - Future deleteAllByTxid(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return deleteAllByIndex(r'txid', values); + Future deleteAllByTxidWalletId( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return deleteAllByIndex(r'txid_walletId', values); } - int deleteAllByTxidSync(List txidValues) { - final values = txidValues.map((e) => [e]).toList(); - return deleteAllByIndexSync(r'txid', values); + int deleteAllByTxidWalletIdSync( + List txidValues, List walletIdValues) { + final len = txidValues.length; + assert(walletIdValues.length == len, + 'All index values must have the same length'); + final values = >[]; + for (var i = 0; i < len; i++) { + values.add([txidValues[i], walletIdValues[i]]); + } + + return deleteAllByIndexSync(r'txid_walletId', values); } - Future putByTxid(TransactionNote object) { - return putByIndex(r'txid', object); + Future putByTxidWalletId(TransactionNote object) { + return putByIndex(r'txid_walletId', object); } - Id putByTxidSync(TransactionNote object, {bool saveLinks = true}) { - return putByIndexSync(r'txid', object, saveLinks: saveLinks); + Id putByTxidWalletIdSync(TransactionNote object, {bool saveLinks = true}) { + return putByIndexSync(r'txid_walletId', object, saveLinks: saveLinks); } - Future> putAllByTxid(List objects) { - return putAllByIndex(r'txid', objects); + Future> putAllByTxidWalletId(List objects) { + return putAllByIndex(r'txid_walletId', objects); } - List putAllByTxidSync(List objects, + List putAllByTxidWalletIdSync(List objects, {bool saveLinks = true}) { - return putAllByIndexSync(r'txid', objects, saveLinks: saveLinks); + return putAllByIndexSync(r'txid_walletId', objects, saveLinks: saveLinks); } } @@ -253,29 +313,74 @@ extension TransactionNoteQueryWhere }); } - QueryBuilder txidEqualTo( - String txid) { + QueryBuilder + walletIdEqualTo(String walletId) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IndexWhereClause.equalTo( - indexName: r'txid', + indexName: r'walletId', + value: [walletId], + )); + }); + } + + QueryBuilder + walletIdNotEqualTo(String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [walletId], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'walletId', + lower: [], + upper: [walletId], + includeUpper: false, + )); + } + }); + } + + QueryBuilder + txidEqualToAnyWalletId(String txid) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid_walletId', value: [txid], )); }); } QueryBuilder - txidNotEqualTo(String txid) { + txidNotEqualToAnyWalletId(String txid) { return QueryBuilder.apply(this, (query) { if (query.whereSort == Sort.asc) { return query .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [], upper: [txid], includeUpper: false, )) .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [txid], includeLower: false, upper: [], @@ -283,13 +388,13 @@ extension TransactionNoteQueryWhere } else { return query .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [txid], includeLower: false, upper: [], )) .addWhereClause(IndexWhereClause.between( - indexName: r'txid', + indexName: r'txid_walletId', lower: [], upper: [txid], includeUpper: false, @@ -297,6 +402,51 @@ extension TransactionNoteQueryWhere } }); } + + QueryBuilder + txidWalletIdEqualTo(String txid, String walletId) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid_walletId', + value: [txid, walletId], + )); + }); + } + + QueryBuilder + txidEqualToWalletIdNotEqualTo(String txid, String walletId) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid], + upper: [txid, walletId], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid, walletId], + includeLower: false, + upper: [txid], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid, walletId], + includeLower: false, + upper: [txid], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid_walletId', + lower: [txid], + upper: [txid, walletId], + includeUpper: false, + )); + } + }); + } } extension TransactionNoteQueryFilter @@ -628,6 +778,142 @@ extension TransactionNoteQueryFilter )); }); } + + QueryBuilder + walletIdEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'walletId', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'walletId', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'walletId', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + walletIdIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'walletId', + value: '', + )); + }); + } + + QueryBuilder + walletIdIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'walletId', + value: '', + )); + }); + } } extension TransactionNoteQueryObject @@ -663,6 +949,20 @@ extension TransactionNoteQuerySortBy return query.addSortBy(r'value', Sort.desc); }); } + + QueryBuilder + sortByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder + sortByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension TransactionNoteQuerySortThenBy @@ -704,6 +1004,20 @@ extension TransactionNoteQuerySortThenBy return query.addSortBy(r'value', Sort.desc); }); } + + QueryBuilder + thenByWalletId() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.asc); + }); + } + + QueryBuilder + thenByWalletIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'walletId', Sort.desc); + }); + } } extension TransactionNoteQueryWhereDistinct @@ -721,6 +1035,13 @@ extension TransactionNoteQueryWhereDistinct return query.addDistinctBy(r'value', caseSensitive: caseSensitive); }); } + + QueryBuilder distinctByWalletId( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive); + }); + } } extension TransactionNoteQueryProperty @@ -742,4 +1063,10 @@ extension TransactionNoteQueryProperty return query.addPropertyName(r'value'); }); } + + QueryBuilder walletIdProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'walletId'); + }); + } } diff --git a/lib/pages/address_book_views/subviews/contact_details_view.dart b/lib/pages/address_book_views/subviews/contact_details_view.dart index 5c75b4beb..b95818a97 100644 --- a/lib/pages/address_book_views/subviews/contact_details_view.dart +++ b/lib/pages/address_book_views/subviews/contact_details_view.dart @@ -27,6 +27,8 @@ import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; +import '../../../db/main_db.dart'; + class ContactDetailsView extends ConsumerStatefulWidget { const ContactDetailsView({ Key? key, @@ -59,7 +61,8 @@ class _ContactDetailsViewState extends ConsumerState { List> result = []; for (final manager in managers) { - final transactions = await manager.db.transactions + final transactions = await MainDB.instance + .getTransactions(manager.walletId) .filter() .anyOf(contact.addresses.map((e) => e.address), (q, String e) => q.address((q) => q.valueEqualTo(e))) diff --git a/lib/pages/exchange_view/exchange_view.dart b/lib/pages/exchange_view/exchange_view.dart index 6bb1aa1c3..f429b2c7b 100644 --- a/lib/pages/exchange_view/exchange_view.dart +++ b/lib/pages/exchange_view/exchange_view.dart @@ -14,6 +14,8 @@ import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/trade_card.dart'; import 'package:tuple/tuple.dart'; +import '../../db/main_db.dart'; + class ExchangeView extends ConsumerStatefulWidget { const ExchangeView({Key? key}) : super(key: key); @@ -131,7 +133,8 @@ class _ExchangeViewState extends ConsumerState { //todo: check if print needed // debugPrint("name: ${manager.walletName}"); - final tx = await manager.db.transactions + final tx = await MainDB.instance + .getTransactions(walletIds.first) .filter() .txidEqualTo(txid) .findFirst(); diff --git a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart index da0adb59c..98fce4a0b 100644 --- a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart +++ b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart @@ -24,6 +24,8 @@ import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; +import '../../../db/main_db.dart'; + class DesktopContactDetails extends ConsumerStatefulWidget { const DesktopContactDetails({ Key? key, @@ -59,7 +61,8 @@ class _DesktopContactDetailsState extends ConsumerState { List> result = []; for (final manager in managers) { - final transactions = await manager.db.transactions + final transactions = await MainDB.instance + .getTransactions(manager.walletId) .filter() .anyOf(contact.addresses.map((e) => e.address), (q, String e) => q.address((q) => q.valueEqualTo(e))) diff --git a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart index 477c4562a..7dd6578c3 100644 --- a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart +++ b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart @@ -29,6 +29,8 @@ import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:tuple/tuple.dart'; +import '../../db/main_db.dart'; + class DesktopAllTradesView extends ConsumerStatefulWidget { const DesktopAllTradesView({Key? key}) : super(key: key); @@ -350,7 +352,8 @@ class _DesktopTradeRowCardState extends ConsumerState { //todo: check if print needed // debugPrint("name: ${manager.walletName}"); - final tx = await manager.db.transactions + final tx = await MainDB.instance + .getTransactions(walletIds.first) .filter() .txidEqualTo(txid) .findFirst(); diff --git a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart index 5a6d7ce81..296847d71 100644 --- a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart +++ b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart @@ -19,6 +19,8 @@ import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/trade_card.dart'; +import '../../../db/main_db.dart'; + class DesktopTradeHistory extends ConsumerStatefulWidget { const DesktopTradeHistory({Key? key}) : super(key: key); @@ -128,7 +130,8 @@ class _DesktopTradeHistoryState extends ConsumerState { //todo: check if print needed // debugPrint("name: ${manager.walletName}"); - final tx = await manager.db.transactions + final tx = await MainDB.instance + .getTransactions(walletIds.first) .filter() .txidEqualTo(txid) .findFirst(); diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index a2aacbc25..32b48282e 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -175,34 +175,34 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Coin get coin => _coin; @override - Future> get utxos => isar.utxos.where().findAll(); + Future> get utxos => db.getUTXOs(walletId).findAll(); @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override Future get currentReceivingAddress async => (await _currentReceivingAddress).value; - Future get _currentReceivingAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentReceivingAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; Future get currentChangeAddress async => (await _currentChangeAddress).value; - Future get _currentChangeAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.change) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentChangeAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -210,7 +210,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isarClose(); } bool _hasCalledExit = false; @@ -661,14 +660,14 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(p2wpkhReceiveAddressArray); - await isar.addresses.putAll(p2wpkhChangeAddressArray); - await isar.addresses.putAll(p2pkhReceiveAddressArray); - await isar.addresses.putAll(p2pkhChangeAddressArray); - await isar.addresses.putAll(p2shReceiveAddressArray); - await isar.addresses.putAll(p2shChangeAddressArray); - }); + await db.putAddresses([ + ...p2wpkhReceiveAddressArray, + ...p2wpkhChangeAddressArray, + ...p2pkhReceiveAddressArray, + ...p2pkhChangeAddressArray, + ...p2shReceiveAddressArray, + ...p2shChangeAddressArray, + ]); await _updateUTXOs(); @@ -719,7 +718,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; - if ((await isar.transactions + if ((await db + .getTransactions(walletId) .filter() .txidMatches(txid) .findFirst()) == @@ -748,13 +748,13 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentChainHeight = await chainHeight; - final txCount = await isar.transactions.count(); + final txCount = await db.getTransactions(walletId).count(); const paginateLimit = 50; for (int i = 0; i < txCount; i += paginateLimit) { - final transactions = await isar.transactions - .where() + final transactions = await db + .getTransactions(walletId) .offset(i) .limit(paginateLimit) .findAll(); @@ -1314,7 +1314,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.addresses + final allAddresses = await db + .getAddresses(walletId) .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() @@ -1449,11 +1450,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(walletId); - - await isar.writeTxn(() async { - await isar.addresses.putAll(initialAddresses); - }); + await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1544,7 +1541,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { type = isar_models.AddressType.p2wpkh; break; } - address = await isar.addresses + address = await db + .getAddresses(walletId) .filter() .typeEqualTo(type) .subTypeEqualTo(subType) @@ -1776,9 +1774,10 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log('Outputs fetched: $outputArray', level: LogLevel.Info); - await isar.writeTxn(() async { - await isar.utxos.clear(); - await isar.utxos.putAll(outputArray); + // TODO move this out of here and into IDB + await db.isar.writeTxn(() async { + await db.isar.utxos.clear(); + await db.isar.utxos.putAll(outputArray); }); // finally update balance @@ -1858,9 +1857,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } catch (e, s) { Logging.instance.log( @@ -1887,9 +1884,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 1, newChangeIndex, DerivePathType.bip84); // Add that new change address - await isar.writeTxn(() async { - await isar.addresses.put(newChangeAddress); - }); + await db.putAddress(newChangeAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -2027,8 +2022,9 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final storedTx = await isar.transactions - .where() + final storedTx = await db + .getTransactions(walletId) + .filter() .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); @@ -2041,7 +2037,8 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses + tx["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) .findFirst(); @@ -2073,11 +2070,12 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allAddresses, coin, MINIMUM_CONFIRMATIONS, + walletId, ); txnsData.add(data); } - await addNewTransactionData(txnsData); + await addNewTransactionData(txnsData, walletId); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2738,13 +2736,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // back up data // await _rescanBackup(); - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2981,9 +2973,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -2993,7 +2983,4 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { return false; } } - - @override - Isar get isarInstance => isar; } diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 6c48516a0..41cbec46c 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -148,11 +148,11 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future> get utxos => isar.utxos.where().findAll(); + Future> get utxos => db.getUTXOs(walletId).findAll(); @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override Coin get coin => _coin; @@ -161,24 +161,24 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get currentReceivingAddress async => (await _currentReceivingAddress).value; - Future get _currentReceivingAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentReceivingAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; Future get currentChangeAddress async => (await _currentChangeAddress).value; - Future get _currentChangeAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(isar_models.AddressSubType.change) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentChangeAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -186,7 +186,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isarClose(); } bool _hasCalledExit = false; @@ -389,6 +388,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } final address = isar_models.Address() + ..walletId = walletId ..subType = chain == 0 ? isar_models.AddressSubType.receiving : isar_models.AddressSubType.change @@ -604,12 +604,12 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(p2pkhReceiveAddressArray); - await isar.addresses.putAll(p2pkhChangeAddressArray); - await isar.addresses.putAll(p2shReceiveAddressArray); - await isar.addresses.putAll(p2shChangeAddressArray); - }); + await db.putAddresses([ + ...p2pkhReceiveAddressArray, + ...p2pkhChangeAddressArray, + ...p2shReceiveAddressArray, + ...p2shChangeAddressArray, + ]); await _updateUTXOs(); @@ -664,7 +664,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; - if ((await isar.transactions + if ((await db + .getTransactions(walletId) .filter() .txidMatches(txid) .findFirst()) == @@ -693,13 +694,13 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentChainHeight = await chainHeight; - final txCount = await isar.transactions.count(); + final txCount = await db.getTransactions(walletId).count(); const paginateLimit = 50; for (int i = 0; i < txCount; i += paginateLimit) { - final transactions = await isar.transactions - .where() + final transactions = await db + .getTransactions(walletId) .offset(i) .limit(paginateLimit) .findAll(); @@ -1268,7 +1269,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.addresses + final allAddresses = await db + .getAddresses(walletId) .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() @@ -1366,9 +1368,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(initialAddresses); - }); + await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1425,6 +1425,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { ); return isar_models.Address() + ..walletId = walletId ..derivationIndex = index ..value = address ..publicKey = node.publicKey @@ -1455,7 +1456,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { break; } - final address = await isar.addresses + final address = await db + .getAddresses(walletId) .filter() .typeEqualTo(type) .subTypeEqualTo(subType) @@ -1613,7 +1615,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO(); + final utxo = isar_models.UTXO()..walletId = walletId; utxo.txid = txn["txid"] as String; utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; @@ -1648,9 +1650,10 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log('Outputs fetched: $outputArray', level: LogLevel.Info); - await isar.writeTxn(() async { - await isar.utxos.clear(); - await isar.utxos.putAll(outputArray); + // TODO move this out of here and into IDB + await db.isar.writeTxn(() async { + await db.isar.utxos.clear(); + await db.isar.utxos.putAll(outputArray); }); // finally update balance @@ -1741,9 +1744,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip44); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1775,9 +1776,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { 1, newChangeIndex, DerivePathType.bip44); // Add that new change address - await isar.writeTxn(() async { - await isar.addresses.put(newChangeAddress); - }); + await db.putAddress(newChangeAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1943,8 +1942,9 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final storedTx = await isar.transactions - .where() + final storedTx = await db + .getTransactions(walletId) + .filter() .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); @@ -1958,7 +1958,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses + tx["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) .findFirst(); @@ -2067,7 +2068,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final fee = totalInputValue - totalOutputValue; - final tx = isar_models.Transaction(); + final tx = isar_models.Transaction()..walletId = walletId; tx.txid = txData["txid"] as String; tx.timestamp = txData["blocktime"] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); @@ -2090,6 +2091,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { if (transactionAddress.value != possible) { transactionAddress = isar_models.Address() + ..walletId = walletId ..value = possible ..derivationIndex = -1 ..subType = AddressSubType.nonWallet @@ -2148,7 +2150,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } - await addNewTransactionData(txns); + await addNewTransactionData(txns, walletId); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2800,13 +2802,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2940,9 +2936,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip44); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -2952,9 +2946,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { return false; } } - - @override - Isar get isarInstance => isar; } // Bitcoincash Network diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index e0ac141dc..c97b57776 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -132,7 +132,8 @@ extension PayNym on DogecoinWallet { /// return the notification tx sent from my wallet if it exists Future hasSentNotificationTx(PaymentCode pCode) async { - final tx = await isar.transactions + final tx = await db + .getTransactions(walletId) .filter() .address((q) => q.valueEqualTo(pCode.notificationAddress())) .findFirst(); @@ -568,6 +569,7 @@ Future, List, Address>> List

myAddresses, Coin coin, int minConfirms, + String walletId, ) async { Set receivingAddresses = myAddresses .where((e) => e.subType == AddressSubType.receiving) @@ -665,7 +667,7 @@ Future, List, Address>> final fee = totalInputValue - totalOutputValue; - final tx = Transaction(); + final tx = Transaction()..walletId = walletId; tx.txid = txData["txid"] as String; tx.timestamp = txData["blocktime"] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000); @@ -690,6 +692,7 @@ Future, List, Address>> if (transactionAddress.value != possible) { transactionAddress = Address() + ..walletId = walletId ..value = possible ..derivationIndex = -1 ..subType = AddressSubType.nonWallet @@ -712,7 +715,7 @@ Future, List, Address>> for (final json in txData["vin"] as List) { bool isCoinBase = json['coinbase'] != null; - final input = Input(); + final input = Input()..walletId = walletId; input.txid = json['txid'] as String; input.vout = json['vout'] as int? ?? -1; input.scriptSig = json['scriptSig']?['hex'] as String?; @@ -724,7 +727,7 @@ Future, List, Address>> } for (final json in txData["vout"] as List) { - final output = Output(); + final output = Output()..walletId = walletId; output.scriptPubKey = json['scriptPubKey']?['hex'] as String?; output.scriptPubKeyAsm = json['scriptPubKey']?['asm'] as String?; output.scriptPubKeyType = json['scriptPubKey']?['type'] as String?; diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index e6f5eba5e..fb433466c 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -1,4 +1,3 @@ -import 'package:isar/isar.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -295,6 +294,4 @@ abstract class CoinServiceAPI { Future updateSentCachedTxData(Map txData); int get storedChainHeight; - - Isar get isarInstance; } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index ff478c8c6..42ad7f8ff 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -146,11 +146,11 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } @override - Future> get utxos => isar.utxos.where().findAll(); + Future> get utxos => db.getUTXOs(walletId).findAll(); @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override Coin get coin => _coin; @@ -159,25 +159,25 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Future get currentReceivingAddress async => (await _currentReceivingAddress).value; - Future get _currentReceivingAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentReceivingAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; // @override Future get currentChangeAddress async => (await _currentChangeAddress).value; - Future get _currentChangeAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(isar_models.AddressSubType.change) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentChangeAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -185,7 +185,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isarClose(); } bool _hasCalledExit = false; @@ -356,6 +355,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { .data .address!; address = isar_models.Address() + ..walletId = walletId ..subType = chain == 0 ? isar_models.AddressSubType.receiving : isar_models.AddressSubType.change @@ -520,10 +520,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(p2pkhChangeAddressArray); - await isar.addresses.putAll(p2pkhReceiveAddressArray); - }); + await db.putAddresses([ + ...p2pkhReceiveAddressArray, + ...p2pkhChangeAddressArray, + ]); await _updateUTXOs(); @@ -577,7 +577,8 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; - if ((await isar.transactions + if ((await db + .getTransactions(walletId) .filter() .txidMatches(txid) .findFirst()) == @@ -606,13 +607,13 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentChainHeight = await chainHeight; - final txCount = await isar.transactions.count(); + final txCount = await db.getTransactions(walletId).count(); const paginateLimit = 50; for (int i = 0; i < txCount; i += paginateLimit) { - final transactions = await isar.transactions - .where() + final transactions = await db + .getTransactions(walletId) .offset(i) .limit(paginateLimit) .findAll(); @@ -1147,7 +1148,8 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.addresses + final allAddresses = await db + .getAddresses(walletId) .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() @@ -1229,12 +1231,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll([ - initialReceivingAddressP2PKH, - initialChangeAddressP2PKH, - ]); - }); + await db.putAddresses([ + initialReceivingAddressP2PKH, + initialChangeAddressP2PKH, + ]); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1280,6 +1280,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); return isar_models.Address() + ..walletId = walletId ..derivationIndex = index ..value = address ..publicKey = node.publicKey @@ -1303,7 +1304,8 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { isar_models.Address? address; switch (derivePathType) { case DerivePathType.bip44: - address = await isar.addresses + address = await db + .getAddresses(walletId) .filter() .typeEqualTo(isar_models.AddressType.p2pkh) .subTypeEqualTo(subType) @@ -1492,7 +1494,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO(); + final utxo = isar_models.UTXO()..walletId = walletId; utxo.txid = txn["txid"] as String; utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; @@ -1527,9 +1529,10 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log('Outputs fetched: $outputArray', level: LogLevel.Info); - await isar.writeTxn(() async { - await isar.utxos.clear(); - await isar.utxos.putAll(outputArray); + // TODO move this out of here and into IDB + await db.isar.writeTxn(() async { + await db.isar.utxos.clear(); + await db.isar.utxos.putAll(outputArray); }); // finally update balance @@ -1648,9 +1651,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip44); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1682,9 +1683,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 1, newChangeIndex, DerivePathType.bip44); // Add that new change address - await isar.writeTxn(() async { - await isar.addresses.put(newChangeAddress); - }); + await db.putAddress(newChangeAddress); } } catch (e, s) { Logging.instance.log( @@ -1849,8 +1848,9 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final storedTx = await isar.transactions - .where() + final storedTx = await db + .getTransactions(walletId) + .filter() .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); @@ -1863,7 +1863,8 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses + tx["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) .findFirst(); @@ -1894,12 +1895,13 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allAddresses, coin, MINIMUM_CONFIRMATIONS, + walletId, ); txns.add(txn); } - await addNewTransactionData(txns); + await addNewTransactionData(txns, walletId); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2436,13 +2438,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // await _rescanBackup(); // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2713,9 +2709,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip44); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -2725,9 +2719,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { return false; } } - - @override - Isar get isarInstance => isar; } // Dogecoin Network diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index a2e45ec01..adeaf592e 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -905,13 +905,7 @@ class EpicCashWallet extends CoinServiceAPI ); // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); await epicUpdateLastScannedBlock(await getRestoreHeight()); @@ -1761,8 +1755,11 @@ class EpicCashWallet extends CoinServiceAPI try { await cancelPendingTransaction(txSlateId); - final tx = - await isar.transactions.where().txidEqualTo(commitId).findFirst(); + final tx = await db + .getTransactions(walletId) + .filter() + .txidEqualTo(commitId) + .findFirst(); if ((tx?.isCancelled ?? false) == true) { await deleteCancels(receiveAddressFromMap, signature, txSlateId); } @@ -2054,8 +2051,11 @@ class EpicCashWallet extends CoinServiceAPI txn.fee = (tx["fee"] == null) ? 0 : int.parse(tx["fee"] as String); // txn.address = // ""; // for this when you send a transaction you will just need to save in a hashmap in hive with the key being the txid, and the value being the address it was sent to. then you can look this value up right here in your hashmap. - txn.address.value = - await isar.addresses.filter().valueEqualTo(address).findFirst(); + txn.address.value = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(address) + .findFirst(); txn.height = txHeight; // @@ -2080,8 +2080,7 @@ class EpicCashWallet extends CoinServiceAPI // Logging.instance.log("cmap: $cachedMap", level: LogLevel.Info); } - await isar - .writeTxn(() async => await isar.transactions.putAll(midSortedArray)); + await db.putTransactions(midSortedArray); // midSortedArray // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); @@ -2246,8 +2245,5 @@ class EpicCashWallet extends CoinServiceAPI @override Future> get transactions => - isar.transactions.where().findAll(); - - @override - Isar get isarInstance => isar; + db.getTransactions(walletId).findAll(); } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index f1a562c4c..cb875fac1 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -810,7 +810,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } /// Holds wallet transaction data - Future> get _txnData => isar.transactions + Future> get _txnData => db + .getTransactions(walletId) .filter() .isLelantusIsNull() .or() @@ -867,7 +868,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { /// Holds wallet lelantus transaction data Future> get lelantusTransactionData => - isar.transactions.filter().isLelantusEqualTo(true).findAll(); + db.getTransactions(walletId).filter().isLelantusEqualTo(true).findAll(); // _lelantusTransactionData ??= _getLelantusTransactionData(); /// Holds the max fee that can be sent @@ -883,24 +884,24 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Future get currentReceivingAddress async => (await _currentReceivingAddress).value; - Future get _currentReceivingAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentReceivingAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; Future get currentChangeAddress async => (await _currentChangeAddress).value; - Future get _currentChangeAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2pkh) - .subTypeEqualTo(isar_models.AddressSubType.change) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentChangeAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2pkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; late String _walletName; @override @@ -1875,7 +1876,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; - if ((await isar.transactions + if ((await db + .getTransactions(walletId) .filter() .txidMatches(txid) .findFirst()) == @@ -1905,14 +1907,18 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final currentChainHeight = await chainHeight; - final txTxns = await isar.transactions + final txTxns = await db + .getTransactions(walletId) .filter() .isLelantusIsNull() .or() .isLelantusEqualTo(false) .findAll(); - final ltxTxns = - await isar.transactions.filter().isLelantusEqualTo(true).findAll(); + final ltxTxns = await db + .getTransactions(walletId) + .filter() + .isLelantusEqualTo(true) + .findAll(); for (isar_models.Transaction tx in txTxns) { isar_models.Transaction? lTx; @@ -2109,12 +2115,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll([ - initialReceivingAddress, - initialChangeAddress, - ]); - }); + await db.putAddresses([ + initialReceivingAddress, + initialChangeAddress, + ]); } bool refreshMutex = false; @@ -2849,8 +2853,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } // TODO: optimize this whole lelantus process - await isar - .writeTxn(() async => isar.transactions.putAll(listLelantusTxData)); + await db.putTransactions(listLelantusTxData); // // update the _lelantusTransactionData // final models.TransactionData newTxData = @@ -2955,7 +2958,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Decimal.parse(transactionInfo["amount"].toString()), coin) ..fee = Format.decimalAmountToSatoshis( Decimal.parse(transactionInfo["fees"].toString()), coin) - ..address.value = await isar.addresses + ..address.value = await db + .getAddresses(walletId) .filter() .valueEqualTo(transactionInfo["address"] as String) .findFirst() @@ -2969,9 +2973,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ..isLelantus = true ..isCancelled = false; - await isar.writeTxn(() async { - await isar.transactions.put(transaction); - }); + await db.putTransaction(transaction); // final models.TransactionData newTxData = // models.TransactionData.fromMap(transactions); @@ -3105,9 +3107,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -3142,9 +3142,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ); // Add that new change address - await isar.writeTxn(() async { - await isar.addresses.put(newChangeAddress); - }); + await db.putAddress(newChangeAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -3160,7 +3158,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.addresses + final allAddresses = await db + .getAddresses(walletId) .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() @@ -3250,8 +3249,9 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final storedTx = await isar.transactions - .where() + final storedTx = await db + .getTransactions(walletId) + .filter() .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); @@ -3264,7 +3264,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses + tx["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) .findFirst(); @@ -3285,12 +3286,13 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { allAddresses, coin, MINIMUM_CONFIRMATIONS, + walletId, ); txnsData.add(data); } - await addNewTransactionData(txnsData); + await addNewTransactionData(txnsData, walletId); } Future _refreshUTXOs() async { @@ -3377,9 +3379,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Logging.instance .log('Outputs fetched: $outputArray', level: LogLevel.Info); - await isar.writeTxn(() async { - await isar.utxos.clear(); - await isar.utxos.putAll(outputArray); + // TODO move this out of here and into IDB + await db.isar.writeTxn(() async { + await db.isar.utxos.clear(); + await db.isar.utxos.putAll(outputArray); }); // finally update public balance @@ -3404,7 +3407,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ? isar_models.AddressSubType.receiving : isar_models.AddressSubType.change; - isar_models.Address? address = await isar.addresses + isar_models.Address? address = await db + .getAddresses(walletId) .filter() .typeEqualTo(isar_models.AddressType.p2pkh) .subTypeEqualTo(subType) @@ -3597,13 +3601,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { // await _rescanBackup(); // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3981,12 +3979,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { changeAddressArray.add(changeAddress); } - await isar.writeTxn(() async { - await isar.addresses.putAll([ - ...receivingAddressArray, - ...changeAddressArray, - ]); - }); + await db.putAddresses([ + ...receivingAddressArray, + ...changeAddressArray, + ]); } /// Recovers wallet from [suppliedMnemonic]. Expects a valid mnemonic. @@ -4073,9 +4069,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { transactionMap[element.txid] = element; } - await isar.writeTxn(() async { - await isar.transactions.putAll(transactionMap.values.toList()); - }); + await db.putTransactions(transactionMap.values.toList()); } Future>> fetchAnonymitySets() async { @@ -4490,7 +4484,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ..subType = isar_models.TransactionSubType.join ..fee = Format.decimalAmountToSatoshis( Decimal.parse(tx["fees"].toString()), coin) - ..address.value = await isar.addresses + ..address.value = await db + .getAddresses(walletId) .filter() .valueEqualTo(tx["address"] as String) .findFirst() @@ -4530,9 +4525,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { ); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -4575,12 +4568,9 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Balance? _balancePrivate; @override - Future> get utxos => isar.utxos.where().findAll(); + Future> get utxos => db.getUTXOs(walletId).findAll(); @override Future> get transactions => - isar.transactions.where().findAll(); - - @override - Isar get isarInstance => isar; + db.getTransactions(walletId).findAll(); } diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 0d0a867c3..14aa517ee 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -174,34 +174,34 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Coin get coin => _coin; @override - Future> get utxos => isar.utxos.where().findAll(); + Future> get utxos => db.getUTXOs(walletId).findAll(); @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override Future get currentReceivingAddress async => (await _currentReceivingAddress).value; - Future get _currentReceivingAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentReceivingAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; Future get currentChangeAddress async => (await _currentChangeAddress).value; - Future get _currentChangeAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.change) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentChangeAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -209,7 +209,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isarClose(); } bool _hasCalledExit = false; @@ -678,14 +677,14 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(p2wpkhReceiveAddressArray); - await isar.addresses.putAll(p2wpkhChangeAddressArray); - await isar.addresses.putAll(p2pkhReceiveAddressArray); - await isar.addresses.putAll(p2pkhChangeAddressArray); - await isar.addresses.putAll(p2shReceiveAddressArray); - await isar.addresses.putAll(p2shChangeAddressArray); - }); + await db.putAddresses([ + ...p2wpkhReceiveAddressArray, + ...p2wpkhChangeAddressArray, + ...p2pkhReceiveAddressArray, + ...p2pkhChangeAddressArray, + ...p2shReceiveAddressArray, + ...p2shChangeAddressArray, + ]); await _updateUTXOs(); @@ -736,7 +735,8 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; - if ((await isar.transactions + if ((await db + .getTransactions(walletId) .filter() .txidMatches(txid) .findFirst()) == @@ -765,13 +765,13 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentChainHeight = await chainHeight; - final txCount = await isar.transactions.count(); + final txCount = await db.getTransactions(walletId).count(); const paginateLimit = 50; for (int i = 0; i < txCount; i += paginateLimit) { - final transactions = await isar.transactions - .where() + final transactions = await db + .getTransactions(walletId) .offset(i) .limit(paginateLimit) .findAll(); @@ -1330,7 +1330,8 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.addresses + final allAddresses = await db + .getAddresses(walletId) .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() @@ -1468,9 +1469,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(initialAddresses); - }); + await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1568,7 +1567,8 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { type = isar_models.AddressType.p2wpkh; break; } - address = await isar.addresses + address = await db + .getAddresses(walletId) .filter() .typeEqualTo(type) .subTypeEqualTo(subType) @@ -1763,9 +1763,10 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log('Outputs fetched: $outputArray', level: LogLevel.Info); - await isar.writeTxn(() async { - await isar.utxos.clear(); - await isar.utxos.putAll(outputArray); + // TODO move this out of here and into IDB + await db.isar.writeTxn(() async { + await db.isar.utxos.clear(); + await db.isar.utxos.putAll(outputArray); }); // finally update balance @@ -1882,9 +1883,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } catch (e, s) { Logging.instance.log( @@ -1911,9 +1910,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 1, newChangeIndex, DerivePathType.bip84); // Add that new change address - await isar.writeTxn(() async { - await isar.addresses.put(newChangeAddress); - }); + await db.putAddress(newChangeAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -2107,8 +2104,9 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final storedTx = await isar.transactions - .where() + final storedTx = await db + .getTransactions(walletId) + .filter() .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); @@ -2122,7 +2120,8 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses + tx["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) .findFirst(); @@ -2154,11 +2153,12 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allAddresses, coin, MINIMUM_CONFIRMATIONS, + walletId, ); txnsData.add(data); } - await addNewTransactionData(txnsData); + await addNewTransactionData(txnsData, walletId); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2824,13 +2824,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // await _rescanBackup(); // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3292,9 +3286,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -3304,9 +3296,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { return false; } } - - @override - Isar get isarInstance => isar; } final litecoin = NetworkType( diff --git a/lib/services/coins/manager.dart b/lib/services/coins/manager.dart index 90e91ce60..a590752e0 100644 --- a/lib/services/coins/manager.dart +++ b/lib/services/coins/manager.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; -import 'package:isar/isar.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/models.dart'; @@ -215,6 +214,4 @@ class Manager with ChangeNotifier { } int get currentHeight => _currentWallet.storedChainHeight; - - Isar get db => _currentWallet.isarInstance; } diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index cd5b1e35a..cc936e141 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -71,7 +71,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { Timer? _autoSaveTimer; Future get _currentReceivingAddress => - isar.addresses.where().sortByDerivationIndexDesc().findFirst(); + db.getAddresses(walletId).sortByDerivationIndexDesc().findFirst(); Future? _feeObject; Mutex prepareSendMutex = Mutex(); @@ -203,7 +203,6 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { _autoSaveTimer?.cancel(); await walletBase?.save(prioritySave: true); walletBase?.close(); - await isarClose(); } } @@ -216,13 +215,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int maxNumberOfIndexesToCheck, ) async { // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; @@ -243,9 +236,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -398,9 +389,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // final initialChangeAddress = await _generateAddressForChain(1, 0); await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.put(initialReceivingAddress); - }); + await db.putAddress(initialReceivingAddress); walletBase?.close(); Logging.instance @@ -887,7 +876,8 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (addressString != null) { - address = await isar.addresses + address = await db + .getAddresses(walletId) .filter() .valueEqualTo(addressString) .findFirst(); @@ -917,7 +907,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - await addNewTransactionData(txnsData); + await addNewTransactionData(txnsData, walletId); } Future _pathForWalletDir({ @@ -1001,7 +991,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { Future _refreshTxData() async { await _refreshTransactions(); - final count = await isar.transactions.count(); + final count = await db.getTransactions(walletId).count(); if (count > _txCount) { _txCount = count; @@ -1142,9 +1132,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { await _generateAddressForChain(0, newReceivingIndex); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1179,12 +1167,9 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override // TODO: implement utxos Future> get utxos => throw UnimplementedError(); - - @override - Isar get isarInstance => isar; } diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 63883f887..b1d76f465 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -169,34 +169,34 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Coin get coin => _coin; @override - Future> get utxos => isar.utxos.where().findAll(); + Future> get utxos => db.getUTXOs(walletId).findAll(); @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override Future get currentReceivingAddress async => (await _currentReceivingAddress).value; - Future get _currentReceivingAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentReceivingAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; Future get currentChangeAddress async => (await _currentChangeAddress).value; - Future get _currentChangeAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.change) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentChangeAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -204,7 +204,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isarClose(); } bool _hasCalledExit = false; @@ -668,14 +667,14 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(p2wpkhReceiveAddressArray); - await isar.addresses.putAll(p2wpkhChangeAddressArray); - await isar.addresses.putAll(p2pkhReceiveAddressArray); - await isar.addresses.putAll(p2pkhChangeAddressArray); - await isar.addresses.putAll(p2shReceiveAddressArray); - await isar.addresses.putAll(p2shChangeAddressArray); - }); + await db.putAddresses([ + ...p2wpkhReceiveAddressArray, + ...p2wpkhChangeAddressArray, + ...p2pkhReceiveAddressArray, + ...p2pkhChangeAddressArray, + ...p2shReceiveAddressArray, + ...p2shChangeAddressArray, + ]); await _updateUTXOs(); @@ -726,7 +725,8 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; - if ((await isar.transactions + if ((await db + .getTransactions(walletId) .filter() .txidMatches(txid) .findFirst()) == @@ -755,13 +755,13 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentChainHeight = await chainHeight; - final txCount = await isar.transactions.count(); + final txCount = await db.getTransactions(walletId).count(); const paginateLimit = 50; for (int i = 0; i < txCount; i += paginateLimit) { - final transactions = await isar.transactions - .where() + final transactions = await db + .getTransactions(walletId) .offset(i) .limit(paginateLimit) .findAll(); @@ -1319,7 +1319,8 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.addresses + final allAddresses = await db + .getAddresses(walletId) .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() @@ -1445,9 +1446,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(initialAddresses); - }); + await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1545,7 +1544,8 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { type = isar_models.AddressType.p2wpkh; break; } - address = await isar.addresses + address = await db + .getAddresses(walletId) .filter() .typeEqualTo(type) .subTypeEqualTo(subType) @@ -1742,9 +1742,10 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log('Outputs fetched: $outputArray', level: LogLevel.Info); - await isar.writeTxn(() async { - await isar.utxos.clear(); - await isar.utxos.putAll(outputArray); + // TODO move this out of here and into IDB + await db.isar.writeTxn(() async { + await db.isar.utxos.clear(); + await db.isar.utxos.putAll(outputArray); }); // finally update balance @@ -1864,9 +1865,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } catch (e, s) { Logging.instance.log( @@ -1893,9 +1892,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 1, newChangeIndex, DerivePathType.bip84); // Add that new change address - await isar.writeTxn(() async { - await isar.addresses.put(newChangeAddress); - }); + await db.putAddress(newChangeAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -2088,8 +2085,9 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final storedTx = await isar.transactions - .where() + final storedTx = await db + .getTransactions(walletId) + .filter() .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); @@ -2103,7 +2101,8 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("TRANSACTION: ${jsonEncode(tx)}"); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses + tx["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) .findFirst(); @@ -2140,11 +2139,12 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { allAddresses, coin, MINIMUM_CONFIRMATIONS, + walletId, ); txnsData.add(data); } - await addNewTransactionData(txnsData); + await addNewTransactionData(txnsData, walletId); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2813,13 +2813,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // await _rescanBackup(); // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3282,9 +3276,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -3294,9 +3286,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { return false; } } - - @override - Isar get isarInstance => isar; } // Namecoin Network diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 01dfff0b8..56560712b 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -165,34 +165,34 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { Coin get coin => _coin; @override - Future> get utxos => isar.utxos.where().findAll(); + Future> get utxos => db.getUTXOs(walletId).findAll(); @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override Future get currentReceivingAddress async => (await _currentReceivingAddress).value; - Future get _currentReceivingAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentReceivingAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .sortByDerivationIndexDesc() + .findFirst())!; Future get currentChangeAddress async => (await _currentChangeAddress).value; - Future get _currentChangeAddress async => - (await isar.addresses - .filter() - .typeEqualTo(isar_models.AddressType.p2wpkh) - .subTypeEqualTo(isar_models.AddressSubType.change) - .sortByDerivationIndexDesc() - .findFirst())!; + Future get _currentChangeAddress async => (await db + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2wpkh) + .subTypeEqualTo(isar_models.AddressSubType.change) + .sortByDerivationIndexDesc() + .findFirst())!; @override Future exit() async { @@ -200,7 +200,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { timer?.cancel(); timer = null; stopNetworkAlivePinging(); - await isarClose(); } bool _hasCalledExit = false; @@ -603,12 +602,12 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(p2wpkhReceiveAddressArray); - await isar.addresses.putAll(p2wpkhChangeAddressArray); - await isar.addresses.putAll(p2pkhReceiveAddressArray); - await isar.addresses.putAll(p2pkhChangeAddressArray); - }); + await db.putAddresses([ + ...p2wpkhReceiveAddressArray, + ...p2wpkhChangeAddressArray, + ...p2pkhReceiveAddressArray, + ...p2pkhChangeAddressArray, + ]); await _updateUTXOs(); @@ -659,7 +658,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { allOwnAddresses.map((e) => e.value).toList(growable: false)); for (Map transaction in allTxs) { final txid = transaction['tx_hash'] as String; - if ((await isar.transactions + if ((await db + .getTransactions(walletId) .filter() .txidMatches(txid) .findFirst()) == @@ -688,13 +688,13 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentChainHeight = await chainHeight; - final txCount = await isar.transactions.count(); + final txCount = await db.getTransactions(walletId).count(); const paginateLimit = 50; for (int i = 0; i < txCount; i += paginateLimit) { - final transactions = await isar.transactions - .where() + final transactions = await db + .getTransactions(walletId) .offset(i) .limit(paginateLimit) .findAll(); @@ -1250,7 +1250,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } Future> _fetchAllOwnAddresses() async { - final allAddresses = await isar.addresses + final allAddresses = await db + .getAddresses(walletId) .filter() .subTypeEqualTo(isar_models.AddressSubType.receiving) .or() @@ -1358,9 +1359,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.putAll(initialAddresses); - }); + await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); } @@ -1439,7 +1438,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { type = isar_models.AddressType.p2wpkh; break; } - address = await isar.addresses + address = await db + .getAddresses(walletId) .filter() .typeEqualTo(type) .subTypeEqualTo(subType) @@ -1632,9 +1632,10 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { Logging.instance .log('Outputs fetched: $outputArray', level: LogLevel.Info); - await isar.writeTxn(() async { - await isar.utxos.clear(); - await isar.utxos.putAll(outputArray); + // TODO move this out of here and into IDB + await db.isar.writeTxn(() async { + await db.isar.utxos.clear(); + await db.isar.utxos.putAll(outputArray); }); // finally update balance @@ -1751,9 +1752,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } catch (e, s) { Logging.instance.log( @@ -1780,9 +1779,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { 1, newChangeIndex, DerivePathType.bip84); // Add that new change address - await isar.writeTxn(() async { - await isar.addresses.put(newChangeAddress); - }); + await db.putAddress(newChangeAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1979,8 +1976,9 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { final currentHeight = await chainHeight; for (final txHash in allTxHashes) { - final storedTx = await isar.transactions - .where() + final storedTx = await db + .getTransactions(walletId) + .filter() .txidEqualTo(txHash["tx_hash"] as String) .findFirst(); @@ -1993,7 +1991,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await isar.addresses + tx["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) .findFirst(); @@ -2134,7 +2133,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { inputAmtSentFromWallet -= _value; } else { // change address from 'sent from' to the 'sent to' address - txObject["address"] = await isar.addresses + txObject["address"] = await db + .getAddresses(walletId) .filter() .valueEqualTo(address) .findFirst(); @@ -2295,7 +2295,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } - await addNewTransactionData(txns); + await addNewTransactionData(txns, walletId); } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2896,14 +2896,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { // back up data // await _rescanBackup(); - // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3264,9 +3257,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { 0, newReceivingIndex, DerivePathType.bip84); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -3276,9 +3267,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { return false; } } - - @override - Isar get isarInstance => isar; } // Particl Network diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 69a4e5d72..cd78040d7 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -73,7 +73,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { Timer? _autoSaveTimer; Future get _currentReceivingAddress => - isar.addresses.where().sortByDerivationIndexDesc().findFirst(); + db.getAddresses(walletId).sortByDerivationIndexDesc().findFirst(); Future? _feeObject; Mutex prepareSendMutex = Mutex(); @@ -226,7 +226,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { _autoSaveTimer?.cancel(); await walletBase?.save(prioritySave: true); walletBase?.close(); - await isarClose(); } } @@ -239,13 +238,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { int maxNumberOfIndexesToCheck, ) async { // clear blockchain info - await isar.writeTxn(() async { - await isar.transactions.clear(); - await isar.inputs.clear(); - await isar.outputs.clear(); - await isar.utxos.clear(); - await isar.addresses.clear(); - }); + await db.deleteWalletBlockchainData(walletId); var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; @@ -266,9 +259,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); return true; } catch (e, s) { @@ -406,9 +397,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // final initialChangeAddress = await _generateAddressForChain(1, 0); await isarInit(walletId); - await isar.writeTxn(() async { - await isar.addresses.put(initialReceivingAddress); - }); + await db.putAddress(initialReceivingAddress); walletBase?.close(); @@ -956,7 +945,8 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (addressString != null) { - address = await isar.addresses + address = await db + .getAddresses(walletId) .filter() .valueEqualTo(addressString) .findFirst(); @@ -986,7 +976,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - await addNewTransactionData(txnsData); + await addNewTransactionData(txnsData, walletId); } Future _pathForWalletDir({ @@ -1055,7 +1045,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { Future _refreshTxData() async { await _refreshTransactions(); - final count = await isar.transactions.count(); + final count = await db.getTransactions(walletId).count(); if (count > _txCount) { _txCount = count; @@ -1211,9 +1201,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { await _generateAddressForChain(0, newReceivingIndex); // Add that new receiving address - await isar.writeTxn(() async { - await isar.addresses.put(newReceivingAddress); - }); + await db.putAddress(newReceivingAddress); } } on SocketException catch (se, s) { Logging.instance.log( @@ -1248,12 +1236,9 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { @override Future> get transactions => - isar.transactions.where().sortByTimestampDesc().findAll(); + db.getTransactions(walletId).sortByTimestampDesc().findAll(); @override // TODO: implement utxos Future> get utxos => throw UnimplementedError(); - - @override - Isar get isarInstance => isar; } diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 3668670f1..a1c68408f 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -1,76 +1,60 @@ import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; import 'package:tuple/tuple.dart'; mixin WalletDB { - Isar? _isar; + MainDB get db => MainDB.instance; - Isar get isar => _isar!; - - /// open the db if it was not already open - /// returns true if the db was not yet open - /// returns false if the db was already open - Future isarInit(String walletId) async { - if (_isar != null && isar.isOpen) return false; - _isar = await Isar.open( - [ - TransactionSchema, - TransactionNoteSchema, - InputSchema, - OutputSchema, - UTXOSchema, - AddressSchema, - ], - directory: (await StackFileSystem.applicationIsarDirectory()).path, - inspector: true, - name: walletId, - ); - return true; + Future isarInit(String walletId) async { + await db.isarInit(); } - Future isarClose() async => await _isar?.close() ?? false; - Future addNewTransactionData( List, List, Address?>> - transactionsData) async { - await isar.writeTxn(() async { + transactionsData, + String walletId) async { + await db.isar.writeTxn(() async { for (final data in transactionsData) { final tx = data.item1; - final potentiallyUnconfirmedTx = - await isar.transactions.where().txidEqualTo(tx.txid).findFirst(); + final potentiallyUnconfirmedTx = await db + .getTransactions(walletId) + .filter() + .txidEqualTo(tx.txid) + .findFirst(); if (potentiallyUnconfirmedTx != null) { // update use id to replace tx tx.id = potentiallyUnconfirmedTx.id; - await isar.transactions.delete(potentiallyUnconfirmedTx.id); + await db.isar.transactions.delete(potentiallyUnconfirmedTx.id); } // save transaction - await isar.transactions.put(tx); + await db.isar.transactions.put(tx); // link and save outputs if (data.item2.isNotEmpty) { - await isar.outputs.putAll(data.item2); + await db.isar.outputs.putAll(data.item2); tx.outputs.addAll(data.item2); await tx.outputs.save(); } // link and save inputs if (data.item3.isNotEmpty) { - await isar.inputs.putAll(data.item3); + await db.isar.inputs.putAll(data.item3); tx.inputs.addAll(data.item3); await tx.inputs.save(); } if (data.item4 != null) { - final address = await isar.addresses - .where() + final address = await db + .getAddresses(walletId) + .filter() .valueEqualTo(data.item4!.value) .findFirst(); // check if address exists in db and add if it does not if (address == null) { - await isar.addresses.put(data.item4!); + await db.isar.addresses.put(data.item4!); } // link and save address diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 53da96b3f..4d7402aaf 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -8,7 +8,6 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i13; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; @@ -22,6 +21,7 @@ import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i21; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i24; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i13; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i8; @@ -151,8 +151,8 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeIsar_10 extends _i1.SmartFake implements _i13.Isar { - _FakeIsar_10( +class _FakeIDB_10 extends _i1.SmartFake implements _i13.IDB { + _FakeIDB_10( Object parent, Invocation parentInvocation, ) : super( @@ -1028,14 +1028,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { ), ) as _i12.Balance); @override - _i13.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_10( - this, - Invocation.getter(#isarInstance), - ), - ) as _i13.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -1045,13 +1037,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i13.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_10( + _i13.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_10( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i13.Isar); + ) as _i13.IDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( @@ -1566,31 +1558,29 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); - @override - _i17.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override _i17.Future addNewTransactionData( - List< - _i23.Tuple4<_i22.Transaction, List<_i22.Output>, - List<_i22.Input>, _i22.Address?>>? - transactionsData) => + List< + _i23.Tuple4<_i22.Transaction, List<_i22.Output>, List<_i22.Input>, + _i22.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), @@ -2141,14 +2131,6 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i13.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_10( - this, - Invocation.getter(#db), - ), - ) as _i13.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2462,14 +2444,6 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override - _i13.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_10( - this, - Invocation.getter(#isarInstance), - ), - ) as _i13.Isar); - @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 d5c5437b4..bb5c5c408 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 @@ -3,21 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i9; -import 'dart:ui' as _i11; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; -import 'package:isar/isar.dart' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i6; import 'package:stackwallet/models/contact.dart' as _i3; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i5; -import 'package:stackwallet/services/address_book_service.dart' as _i10; +import 'package:stackwallet/services/address_book_service.dart' as _i9; import 'package:stackwallet/services/coins/coin_service.dart' as _i4; -import 'package:stackwallet/services/coins/manager.dart' as _i12; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i13; +import 'package:stackwallet/services/coins/manager.dart' as _i11; +import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -81,27 +80,17 @@ class _FakeBalance_4 extends _i1.SmartFake implements _i6.Balance { ); } -class _FakeIsar_5 extends _i1.SmartFake implements _i7.Isar { - _FakeIsar_5( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [BarcodeScannerWrapper]. /// /// See the documentation for Mockito's code generation for more information. class MockBarcodeScannerWrapper extends _i1.Mock - implements _i8.BarcodeScannerWrapper { + implements _i7.BarcodeScannerWrapper { MockBarcodeScannerWrapper() { _i1.throwOnMissingStub(this); } @override - _i9.Future<_i2.ScanResult> scan( + _i8.Future<_i2.ScanResult> scan( {_i2.ScanOptions? options = const _i2.ScanOptions()}) => (super.noSuchMethod( Invocation.method( @@ -109,7 +98,7 @@ class MockBarcodeScannerWrapper extends _i1.Mock [], {#options: options}, ), - returnValue: _i9.Future<_i2.ScanResult>.value(_FakeScanResult_0( + returnValue: _i8.Future<_i2.ScanResult>.value(_FakeScanResult_0( this, Invocation.method( #scan, @@ -117,24 +106,24 @@ class MockBarcodeScannerWrapper extends _i1.Mock {#options: options}, ), )), - ) as _i9.Future<_i2.ScanResult>); + ) as _i8.Future<_i2.ScanResult>); } /// A class which mocks [AddressBookService]. /// /// See the documentation for Mockito's code generation for more information. class MockAddressBookService extends _i1.Mock - implements _i10.AddressBookService { + implements _i9.AddressBookService { @override List<_i3.Contact> get contacts => (super.noSuchMethod( Invocation.getter(#contacts), returnValue: <_i3.Contact>[], ) as List<_i3.Contact>); @override - _i9.Future> get addressBookEntries => (super.noSuchMethod( + _i8.Future> get addressBookEntries => (super.noSuchMethod( Invocation.getter(#addressBookEntries), - returnValue: _i9.Future>.value(<_i3.Contact>[]), - ) as _i9.Future>); + returnValue: _i8.Future>.value(<_i3.Contact>[]), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -155,13 +144,13 @@ class MockAddressBookService extends _i1.Mock ), ) as _i3.Contact); @override - _i9.Future> search(String? text) => (super.noSuchMethod( + _i8.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i9.Future>.value(<_i3.Contact>[]), - ) as _i9.Future>); + returnValue: _i8.Future>.value(<_i3.Contact>[]), + ) as _i8.Future>); @override bool matches( String? term, @@ -178,33 +167,33 @@ class MockAddressBookService extends _i1.Mock returnValue: false, ) as bool); @override - _i9.Future addContact(_i3.Contact? contact) => (super.noSuchMethod( + _i8.Future addContact(_i3.Contact? contact) => (super.noSuchMethod( Invocation.method( #addContact, [contact], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future editContact(_i3.Contact? editedContact) => + _i8.Future editContact(_i3.Contact? editedContact) => (super.noSuchMethod( Invocation.method( #editContact, [editedContact], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future removeContact(String? id) => (super.noSuchMethod( + _i8.Future removeContact(String? id) => (super.noSuchMethod( Invocation.method( #removeContact, [id], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -212,7 +201,7 @@ class MockAddressBookService extends _i1.Mock returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -240,7 +229,7 @@ class MockAddressBookService extends _i1.Mock /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i12.Manager { +class MockManager extends _i1.Mock implements _i11.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -268,10 +257,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i13.Coin get coin => (super.noSuchMethod( + _i12.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i13.Coin.bitcoin, - ) as _i13.Coin); + returnValue: _i12.Coin.bitcoin, + ) as _i12.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -304,23 +293,23 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i9.Future<_i5.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i5.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i9.Future<_i5.FeeObject>.value(_FakeFeeObject_3( + returnValue: _i8.Future<_i5.FeeObject>.value(_FakeFeeObject_3( this, Invocation.getter(#fees), )), - ) as _i9.Future<_i5.FeeObject>); + ) as _i8.Future<_i5.FeeObject>); @override - _i9.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i6.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -330,16 +319,16 @@ class MockManager extends _i1.Mock implements _i12.Manager { ), ) as _i6.Balance); @override - _i9.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i9.Future>.value(<_i14.Transaction>[]), - ) as _i9.Future>); + _i8.Future>.value(<_i13.Transaction>[]), + ) as _i8.Future>); @override - _i9.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i9.Future>.value(<_i14.UTXO>[]), - ) as _i9.Future>); + returnValue: _i8.Future>.value(<_i13.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -359,10 +348,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: '', ) as String); @override - _i9.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -374,27 +363,19 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: 0, ) as int); @override - _i7.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_5( - this, - Invocation.getter(#db), - ), - ) as _i7.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -404,7 +385,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i9.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -420,27 +401,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { }, ), returnValue: - _i9.Future>.value({}), - ) as _i9.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i9.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i9.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -450,33 +431,33 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i9.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -493,20 +474,20 @@ class MockManager extends _i1.Mock implements _i12.Manager { #height: height, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -518,11 +499,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -534,18 +515,18 @@ class MockManager extends _i1.Mock implements _i12.Manager { feeRate, ], ), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -553,7 +534,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 bc2a1af61..f0c334e7e 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 @@ -3,21 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i9; +import 'dart:async' as _i7; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; import 'package:stackwallet/models/contact.dart' as _i2; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/services/address_book_service.dart' as _i7; +import 'package:stackwallet/services/address_book_service.dart' as _i6; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/services/locale_service.dart' as _i14; -import 'package:stackwallet/services/notes_service.dart' as _i13; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/locale_service.dart' as _i13; +import 'package:stackwallet/services/notes_service.dart' as _i12; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -71,31 +70,21 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [AddressBookService]. /// /// See the documentation for Mockito's code generation for more information. class MockAddressBookService extends _i1.Mock - implements _i7.AddressBookService { + implements _i6.AddressBookService { @override List<_i2.Contact> get contacts => (super.noSuchMethod( Invocation.getter(#contacts), returnValue: <_i2.Contact>[], ) as List<_i2.Contact>); @override - _i8.Future> get addressBookEntries => (super.noSuchMethod( + _i7.Future> get addressBookEntries => (super.noSuchMethod( Invocation.getter(#addressBookEntries), - returnValue: _i8.Future>.value(<_i2.Contact>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i2.Contact>[]), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -116,13 +105,13 @@ class MockAddressBookService extends _i1.Mock ), ) as _i2.Contact); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value(<_i2.Contact>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i2.Contact>[]), + ) as _i7.Future>); @override bool matches( String? term, @@ -139,33 +128,33 @@ class MockAddressBookService extends _i1.Mock returnValue: false, ) as bool); @override - _i8.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( + _i7.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( Invocation.method( #addContact, [contact], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future editContact(_i2.Contact? editedContact) => + _i7.Future editContact(_i2.Contact? editedContact) => (super.noSuchMethod( Invocation.method( #editContact, [editedContact], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future removeContact(String? id) => (super.noSuchMethod( + _i7.Future removeContact(String? id) => (super.noSuchMethod( Invocation.method( #removeContact, [id], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -173,7 +162,7 @@ class MockAddressBookService extends _i1.Mock returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -201,7 +190,7 @@ class MockAddressBookService extends _i1.Mock /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -229,10 +218,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i11.Coin get coin => (super.noSuchMethod( + _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i11.Coin.bitcoin, - ) as _i11.Coin); + returnValue: _i10.Coin.bitcoin, + ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -265,23 +254,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i7.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -291,16 +280,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i12.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i12.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -320,10 +309,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -335,27 +324,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -365,7 +346,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -381,27 +362,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -411,33 +392,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -454,20 +435,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -479,11 +460,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -495,18 +476,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -514,7 +495,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -534,7 +515,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i13.NotesService { +class MockNotesService extends _i1.Mock implements _i12.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -546,34 +527,34 @@ class MockNotesService extends _i1.Mock implements _i13.NotesService { returnValue: {}, ) as Map); @override - _i8.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -586,21 +567,21 @@ class MockNotesService extends _i1.Mock implements _i13.NotesService { #note: note, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -608,7 +589,7 @@ class MockNotesService extends _i1.Mock implements _i13.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -636,7 +617,7 @@ class MockNotesService extends _i1.Mock implements _i13.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i14.LocaleService { +class MockLocaleService extends _i1.Mock implements _i13.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -648,17 +629,17 @@ class MockLocaleService extends _i1.Mock implements _i14.LocaleService { returnValue: false, ) as bool); @override - _i8.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -666,7 +647,7 @@ class MockLocaleService extends _i1.Mock implements _i14.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 7d09cecf6..f0c11b04a 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 @@ -3,19 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i9; +import 'dart:async' as _i7; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; import 'package:stackwallet/models/contact.dart' as _i2; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/services/address_book_service.dart' as _i7; +import 'package:stackwallet/services/address_book_service.dart' as _i6; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -69,31 +68,21 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [AddressBookService]. /// /// See the documentation for Mockito's code generation for more information. class MockAddressBookService extends _i1.Mock - implements _i7.AddressBookService { + implements _i6.AddressBookService { @override List<_i2.Contact> get contacts => (super.noSuchMethod( Invocation.getter(#contacts), returnValue: <_i2.Contact>[], ) as List<_i2.Contact>); @override - _i8.Future> get addressBookEntries => (super.noSuchMethod( + _i7.Future> get addressBookEntries => (super.noSuchMethod( Invocation.getter(#addressBookEntries), - returnValue: _i8.Future>.value(<_i2.Contact>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i2.Contact>[]), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -114,13 +103,13 @@ class MockAddressBookService extends _i1.Mock ), ) as _i2.Contact); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value(<_i2.Contact>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i2.Contact>[]), + ) as _i7.Future>); @override bool matches( String? term, @@ -137,33 +126,33 @@ class MockAddressBookService extends _i1.Mock returnValue: false, ) as bool); @override - _i8.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( + _i7.Future addContact(_i2.Contact? contact) => (super.noSuchMethod( Invocation.method( #addContact, [contact], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future editContact(_i2.Contact? editedContact) => + _i7.Future editContact(_i2.Contact? editedContact) => (super.noSuchMethod( Invocation.method( #editContact, [editedContact], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future removeContact(String? id) => (super.noSuchMethod( + _i7.Future removeContact(String? id) => (super.noSuchMethod( Invocation.method( #removeContact, [id], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -171,7 +160,7 @@ class MockAddressBookService extends _i1.Mock returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -199,7 +188,7 @@ class MockAddressBookService extends _i1.Mock /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -227,10 +216,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i11.Coin get coin => (super.noSuchMethod( + _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i11.Coin.bitcoin, - ) as _i11.Coin); + returnValue: _i10.Coin.bitcoin, + ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -263,23 +252,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i7.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -289,16 +278,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i12.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i11.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i12.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i11.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -318,10 +307,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -333,27 +322,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -363,7 +344,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -379,27 +360,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -409,33 +390,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -452,20 +433,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -477,11 +458,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -493,18 +474,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -512,7 +493,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index dced538f1..6328b6881 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -3,20 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i12; +import 'package:stackwallet/models/node_model.dart' as _i11; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i13; -import 'package:stackwallet/services/node_service.dart' as _i11; -import 'package:stackwallet/services/wallets_service.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/services/coins/manager.dart' as _i12; +import 'package:stackwallet/services/node_service.dart' as _i10; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -73,34 +72,24 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i7.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i8.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i8.Future>.value( - {}), - ) as _i8.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -115,13 +104,13 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i9.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -135,13 +124,13 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i9.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -154,46 +143,46 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i8.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -206,48 +195,48 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -259,20 +248,20 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -280,7 +269,7 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -308,7 +297,7 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i11.NodeService { +class MockNodeService extends _i1.Mock implements _i10.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -318,33 +307,33 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i12.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i11.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override - List<_i12.NodeModel> get nodes => (super.noSuchMethod( + List<_i11.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateDefaults() => (super.noSuchMethod( + _i7.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future setPrimaryNodeFor({ - required _i9.Coin? coin, - required _i12.NodeModel? node, + _i7.Future setPrimaryNodeFor({ + required _i8.Coin? coin, + required _i11.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -357,44 +346,44 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i12.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => + _i11.NodeModel? getPrimaryNodeFor({required _i8.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i12.NodeModel?); + )) as _i11.NodeModel?); @override - List<_i12.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( + List<_i11.NodeModel> getNodesFor(_i8.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override - _i12.NodeModel? getNodeById({required String? id}) => + _i11.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i12.NodeModel?); + )) as _i11.NodeModel?); @override - List<_i12.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => + List<_i11.NodeModel> failoverNodesFor({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override - _i8.Future add( - _i12.NodeModel? node, + _i7.Future add( + _i11.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -407,11 +396,11 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future delete( + _i7.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -423,11 +412,11 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future setEnabledState( + _i7.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -441,12 +430,12 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future edit( - _i12.NodeModel? editedNode, + _i7.Future edit( + _i11.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -459,20 +448,20 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future updateCommunityNodes() => (super.noSuchMethod( + _i7.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -480,7 +469,7 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -508,7 +497,7 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i13.Manager { +class MockManager extends _i1.Mock implements _i12.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -536,10 +525,10 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: false, ) as bool); @override - _i9.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, - ) as _i9.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -572,23 +561,23 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i7.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -598,16 +587,16 @@ class MockManager extends _i1.Mock implements _i13.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i14.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i13.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i14.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i13.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -627,10 +616,10 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -642,27 +631,19 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -672,7 +653,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -688,27 +669,27 @@ class MockManager extends _i1.Mock implements _i13.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -718,33 +699,33 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -761,20 +742,20 @@ class MockManager extends _i1.Mock implements _i13.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -786,11 +767,11 @@ class MockManager extends _i1.Mock implements _i13.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -802,18 +783,18 @@ class MockManager extends _i1.Mock implements _i13.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -821,7 +802,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 d2448b08c..c0c6f6902 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 @@ -3,20 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i6; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/services/locale_service.dart' as _i13; -import 'package:stackwallet/services/notes_service.dart' as _i12; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/services/wallets_service.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -60,34 +59,24 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i5.WalletsService { @override - _i7.Future> get walletNames => + _i6.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i6.Future>.value( + {}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i6.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -102,13 +91,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future addExistingStackWallet({ + _i6.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -122,13 +111,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addNewWallet({ + _i6.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -141,46 +130,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i6.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future moveFavorite({ + _i6.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -193,48 +182,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i6.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i6.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i6.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteWallet( + _i6.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -246,20 +235,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i6.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -267,7 +256,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -295,7 +284,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -323,10 +312,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -359,23 +348,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i6.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i6.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i6.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -385,16 +374,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i6.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i6.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -414,10 +403,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i6.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -429,27 +418,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -459,7 +440,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i6.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -475,27 +456,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i6.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -505,33 +486,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i6.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i6.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i6.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future recoverFromMnemonic({ + _i6.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -548,20 +529,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i6.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future fullRescan( + _i6.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -573,11 +554,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future estimateFeeFor( + _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -589,18 +570,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i6.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -608,7 +589,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -628,7 +609,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i12.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -640,34 +621,34 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i6.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i6.Future>.value({}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i6.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i6.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future editOrAddNote({ + _i6.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -680,21 +661,21 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i6.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -702,7 +683,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -730,7 +711,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i13.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -742,17 +723,17 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValue: false, ) as bool); @override - _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i6.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -760,7 +741,7 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 29294e496..aef163b0e 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 @@ -3,20 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i6; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/services/locale_service.dart' as _i13; -import 'package:stackwallet/services/notes_service.dart' as _i12; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/services/wallets_service.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -60,34 +59,24 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i5.WalletsService { @override - _i7.Future> get walletNames => + _i6.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i6.Future>.value( + {}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i6.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -102,13 +91,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future addExistingStackWallet({ + _i6.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -122,13 +111,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addNewWallet({ + _i6.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -141,46 +130,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i6.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future moveFavorite({ + _i6.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -193,48 +182,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i6.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i6.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i6.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteWallet( + _i6.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -246,20 +235,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i6.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -267,7 +256,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -295,7 +284,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -323,10 +312,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -359,23 +348,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i6.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i6.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i6.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -385,16 +374,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i6.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i6.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -414,10 +403,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i6.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -429,27 +418,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -459,7 +440,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i6.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -475,27 +456,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i6.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -505,33 +486,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i6.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i6.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i6.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future recoverFromMnemonic({ + _i6.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -548,20 +529,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i6.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future fullRescan( + _i6.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -573,11 +554,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future estimateFeeFor( + _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -589,18 +570,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i6.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -608,7 +589,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -628,7 +609,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i12.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -640,34 +621,34 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i6.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i6.Future>.value({}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i6.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i6.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future editOrAddNote({ + _i6.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -680,21 +661,21 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i6.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -702,7 +683,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -730,7 +711,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i13.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -742,17 +723,17 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValue: false, ) as bool); @override - _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i6.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -760,7 +741,7 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 309f855bc..7f31b64c4 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 @@ -3,20 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i6; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/services/locale_service.dart' as _i13; -import 'package:stackwallet/services/notes_service.dart' as _i12; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/locale_service.dart' as _i12; +import 'package:stackwallet/services/notes_service.dart' as _i11; +import 'package:stackwallet/services/wallets_service.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -60,34 +59,24 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i5.WalletsService { @override - _i7.Future> get walletNames => + _i6.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i6.Future>.value( + {}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i6.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -102,13 +91,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future addExistingStackWallet({ + _i6.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -122,13 +111,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addNewWallet({ + _i6.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -141,46 +130,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i6.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future moveFavorite({ + _i6.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -193,48 +182,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i6.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i6.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i6.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteWallet( + _i6.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -246,20 +235,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i6.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -267,7 +256,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -295,7 +284,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -323,10 +312,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -359,23 +348,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i6.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i6.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i6.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -385,16 +374,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i6.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i6.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -414,10 +403,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i6.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -429,27 +418,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -459,7 +440,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i6.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -475,27 +456,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i6.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -505,33 +486,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i6.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i6.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i6.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future recoverFromMnemonic({ + _i6.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -548,20 +529,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i6.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future fullRescan( + _i6.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -573,11 +554,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future estimateFeeFor( + _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -589,18 +570,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i6.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -608,7 +589,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -628,7 +609,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i12.NotesService { +class MockNotesService extends _i1.Mock implements _i11.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -640,34 +621,34 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValue: {}, ) as Map); @override - _i7.Future> get notes => (super.noSuchMethod( + _i6.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i6.Future>.value({}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future> search(String? text) => (super.noSuchMethod( + _i6.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i6.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future editOrAddNote({ + _i6.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -680,21 +661,21 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { #note: note, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i6.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -702,7 +683,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -730,7 +711,7 @@ class MockNotesService extends _i1.Mock implements _i12.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i13.LocaleService { +class MockLocaleService extends _i1.Mock implements _i12.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -742,17 +723,17 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValue: false, ) as bool); @override - _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i6.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -760,7 +741,7 @@ class MockLocaleService extends _i1.Mock implements _i13.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 e2a067c2a..56e72d944 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 @@ -3,17 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,20 +56,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -98,10 +87,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -134,23 +123,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -160,16 +149,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -189,10 +178,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -204,27 +193,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -234,7 +215,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -250,27 +231,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -280,33 +261,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -323,20 +304,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -348,11 +329,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -364,18 +345,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -383,7 +364,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 451cd0bbe..a7467d9be 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 @@ -3,18 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i6; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/wallets_service.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -58,34 +57,24 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i5.WalletsService { @override - _i7.Future> get walletNames => + _i6.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i6.Future>.value( + {}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i6.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -100,13 +89,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future addExistingStackWallet({ + _i6.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -120,13 +109,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addNewWallet({ + _i6.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -139,46 +128,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i6.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future moveFavorite({ + _i6.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -191,48 +180,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i6.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i6.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i6.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteWallet( + _i6.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -244,20 +233,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i6.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -265,7 +254,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -293,7 +282,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -321,10 +310,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -357,23 +346,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i6.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i6.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i6.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -383,16 +372,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i6.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i6.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -412,10 +401,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i6.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -427,27 +416,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -457,7 +438,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i6.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -473,27 +454,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i6.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -503,33 +484,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i6.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i6.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i6.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future recoverFromMnemonic({ + _i6.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -546,20 +527,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i6.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future fullRescan( + _i6.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -571,11 +552,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future estimateFeeFor( + _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -587,18 +568,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i6.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -606,7 +587,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 de4576d78..9267a9fba 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 @@ -3,20 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i12; +import 'package:stackwallet/models/node_model.dart' as _i11; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i13; -import 'package:stackwallet/services/node_service.dart' as _i11; -import 'package:stackwallet/services/wallets_service.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; +import 'package:stackwallet/services/coins/manager.dart' as _i12; +import 'package:stackwallet/services/node_service.dart' as _i10; +import 'package:stackwallet/services/wallets_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -73,34 +72,24 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i7.WalletsService { +class MockWalletsService extends _i1.Mock implements _i6.WalletsService { @override - _i8.Future> get walletNames => + _i7.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i8.Future>.value( - {}), - ) as _i8.Future>); + returnValue: _i7.Future>.value( + {}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future renameWallet({ + _i7.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -115,13 +104,13 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future addExistingStackWallet({ + _i7.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i9.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -135,13 +124,13 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future addNewWallet({ + _i7.Future addNewWallet({ required String? name, - required _i9.Coin? coin, + required _i8.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -154,46 +143,46 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override - _i8.Future saveFavoriteWalletIds(List? walletIds) => + _i7.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future moveFavorite({ + _i7.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -206,48 +195,48 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future isMnemonicVerified({required String? walletId}) => + _i7.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future setMnemonicVerified({required String? walletId}) => + _i7.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future deleteWallet( + _i7.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -259,20 +248,20 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future refreshWallets(bool? shouldNotifyListeners) => + _i7.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -280,7 +269,7 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -308,7 +297,7 @@ class MockWalletsService extends _i1.Mock implements _i7.WalletsService { /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i11.NodeService { +class MockNodeService extends _i1.Mock implements _i10.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -318,33 +307,33 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i12.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i11.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override - List<_i12.NodeModel> get nodes => (super.noSuchMethod( + List<_i11.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateDefaults() => (super.noSuchMethod( + _i7.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future setPrimaryNodeFor({ - required _i9.Coin? coin, - required _i12.NodeModel? node, + _i7.Future setPrimaryNodeFor({ + required _i8.Coin? coin, + required _i11.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -357,44 +346,44 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i12.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => + _i11.NodeModel? getPrimaryNodeFor({required _i8.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i12.NodeModel?); + )) as _i11.NodeModel?); @override - List<_i12.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( + List<_i11.NodeModel> getNodesFor(_i8.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override - _i12.NodeModel? getNodeById({required String? id}) => + _i11.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i12.NodeModel?); + )) as _i11.NodeModel?); @override - List<_i12.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => + List<_i11.NodeModel> failoverNodesFor({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i12.NodeModel>[], - ) as List<_i12.NodeModel>); + returnValue: <_i11.NodeModel>[], + ) as List<_i11.NodeModel>); @override - _i8.Future add( - _i12.NodeModel? node, + _i7.Future add( + _i11.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -407,11 +396,11 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future delete( + _i7.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -423,11 +412,11 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future setEnabledState( + _i7.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -441,12 +430,12 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future edit( - _i12.NodeModel? editedNode, + _i7.Future edit( + _i11.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -459,20 +448,20 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { shouldNotifyListeners, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future updateCommunityNodes() => (super.noSuchMethod( + _i7.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -480,7 +469,7 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -508,7 +497,7 @@ class MockNodeService extends _i1.Mock implements _i11.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i13.Manager { +class MockManager extends _i1.Mock implements _i12.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -536,10 +525,10 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: false, ) as bool); @override - _i9.Coin get coin => (super.noSuchMethod( + _i8.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i9.Coin.bitcoin, - ) as _i9.Coin); + returnValue: _i8.Coin.bitcoin, + ) as _i8.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -572,23 +561,23 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i7.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -598,16 +587,16 @@ class MockManager extends _i1.Mock implements _i13.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i14.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i13.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i14.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i13.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -627,10 +616,10 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -642,27 +631,19 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -672,7 +653,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -688,27 +669,27 @@ class MockManager extends _i1.Mock implements _i13.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -718,33 +699,33 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -761,20 +742,20 @@ class MockManager extends _i1.Mock implements _i13.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -786,11 +767,11 @@ class MockManager extends _i1.Mock implements _i13.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -802,18 +783,18 @@ class MockManager extends _i1.Mock implements _i13.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -821,7 +802,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 f5c06234e..13aa6edb8 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 @@ -3,24 +3,23 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i9; -import 'dart:ui' as _i12; +import 'dart:async' as _i8; +import 'dart:ui' as _i11; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i14; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i16; +import 'package:stackwallet/models/node_model.dart' as _i15; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i13; -import 'package:stackwallet/services/node_service.dart' as _i15; -import 'package:stackwallet/services/wallets_service.dart' as _i10; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; +import 'package:stackwallet/services/coins/manager.dart' as _i12; +import 'package:stackwallet/services/node_service.dart' as _i14; +import 'package:stackwallet/services/wallets_service.dart' as _i9; +import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i7; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' - as _i7; + as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -74,19 +73,9 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeSecureStorageInterface_5 extends _i1.SmartFake - implements _i7.SecureStorageInterface { - _FakeSecureStorageInterface_5( +class _FakeSecureStorageInterface_4 extends _i1.SmartFake + implements _i6.SecureStorageInterface { + _FakeSecureStorageInterface_4( Object parent, Invocation parentInvocation, ) : super( @@ -99,13 +88,13 @@ class _FakeSecureStorageInterface_5 extends _i1.SmartFake /// /// See the documentation for Mockito's code generation for more information. class MockBarcodeScannerWrapper extends _i1.Mock - implements _i8.BarcodeScannerWrapper { + implements _i7.BarcodeScannerWrapper { MockBarcodeScannerWrapper() { _i1.throwOnMissingStub(this); } @override - _i9.Future<_i2.ScanResult> scan( + _i8.Future<_i2.ScanResult> scan( {_i2.ScanOptions? options = const _i2.ScanOptions()}) => (super.noSuchMethod( Invocation.method( @@ -113,7 +102,7 @@ class MockBarcodeScannerWrapper extends _i1.Mock [], {#options: options}, ), - returnValue: _i9.Future<_i2.ScanResult>.value(_FakeScanResult_0( + returnValue: _i8.Future<_i2.ScanResult>.value(_FakeScanResult_0( this, Invocation.method( #scan, @@ -121,27 +110,27 @@ class MockBarcodeScannerWrapper extends _i1.Mock {#options: options}, ), )), - ) as _i9.Future<_i2.ScanResult>); + ) as _i8.Future<_i2.ScanResult>); } /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i10.WalletsService { +class MockWalletsService extends _i1.Mock implements _i9.WalletsService { @override - _i9.Future> get walletNames => + _i8.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i9.Future>.value( - {}), - ) as _i9.Future>); + returnValue: _i8.Future>.value( + {}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future renameWallet({ + _i8.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -156,13 +145,13 @@ class MockWalletsService extends _i1.Mock implements _i10.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future addExistingStackWallet({ + _i8.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i11.Coin? coin, + required _i10.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -176,13 +165,13 @@ class MockWalletsService extends _i1.Mock implements _i10.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future addNewWallet({ + _i8.Future addNewWallet({ required String? name, - required _i11.Coin? coin, + required _i10.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -195,46 +184,46 @@ class MockWalletsService extends _i1.Mock implements _i10.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i9.Future saveFavoriteWalletIds(List? walletIds) => + _i8.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future moveFavorite({ + _i8.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -247,48 +236,48 @@ class MockWalletsService extends _i1.Mock implements _i10.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future isMnemonicVerified({required String? walletId}) => + _i8.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future setMnemonicVerified({required String? walletId}) => + _i8.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future deleteWallet( + _i8.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -300,20 +289,20 @@ class MockWalletsService extends _i1.Mock implements _i10.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future refreshWallets(bool? shouldNotifyListeners) => + _i8.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -321,7 +310,7 @@ class MockWalletsService extends _i1.Mock implements _i10.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -349,7 +338,7 @@ class MockWalletsService extends _i1.Mock implements _i10.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i13.Manager { +class MockManager extends _i1.Mock implements _i12.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -377,10 +366,10 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: false, ) as bool); @override - _i11.Coin get coin => (super.noSuchMethod( + _i10.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i11.Coin.bitcoin, - ) as _i11.Coin); + returnValue: _i10.Coin.bitcoin, + ) as _i10.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -413,23 +402,23 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i9.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i9.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -439,16 +428,16 @@ class MockManager extends _i1.Mock implements _i13.Manager { ), ) as _i5.Balance); @override - _i9.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i9.Future>.value(<_i14.Transaction>[]), - ) as _i9.Future>); + _i8.Future>.value(<_i13.Transaction>[]), + ) as _i8.Future>); @override - _i9.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i9.Future>.value(<_i14.UTXO>[]), - ) as _i9.Future>); + returnValue: _i8.Future>.value(<_i13.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -468,10 +457,10 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: '', ) as String); @override - _i9.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -483,27 +472,19 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -513,7 +494,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - _i9.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -529,27 +510,27 @@ class MockManager extends _i1.Mock implements _i13.Manager { }, ), returnValue: - _i9.Future>.value({}), - ) as _i9.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i9.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i9.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -559,33 +540,33 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValue: false, ) as bool); @override - _i9.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -602,20 +583,20 @@ class MockManager extends _i1.Mock implements _i13.Manager { #height: height, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -627,11 +608,11 @@ class MockManager extends _i1.Mock implements _i13.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -643,18 +624,18 @@ class MockManager extends _i1.Mock implements _i13.Manager { feeRate, ], ), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -662,7 +643,7 @@ class MockManager extends _i1.Mock implements _i13.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -682,43 +663,43 @@ class MockManager extends _i1.Mock implements _i13.Manager { /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i15.NodeService { +class MockNodeService extends _i1.Mock implements _i14.NodeService { @override - _i7.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( + _i6.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeSecureStorageInterface_5( + returnValue: _FakeSecureStorageInterface_4( this, Invocation.getter(#secureStorageInterface), ), - ) as _i7.SecureStorageInterface); + ) as _i6.SecureStorageInterface); @override - List<_i16.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i15.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i16.NodeModel>[], - ) as List<_i16.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override - List<_i16.NodeModel> get nodes => (super.noSuchMethod( + List<_i15.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i16.NodeModel>[], - ) as List<_i16.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateDefaults() => (super.noSuchMethod( + _i8.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future setPrimaryNodeFor({ - required _i11.Coin? coin, - required _i16.NodeModel? node, + _i8.Future setPrimaryNodeFor({ + required _i10.Coin? coin, + required _i15.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -731,44 +712,44 @@ class MockNodeService extends _i1.Mock implements _i15.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i16.NodeModel? getPrimaryNodeFor({required _i11.Coin? coin}) => + _i15.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i16.NodeModel?); + )) as _i15.NodeModel?); @override - List<_i16.NodeModel> getNodesFor(_i11.Coin? coin) => (super.noSuchMethod( + List<_i15.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i16.NodeModel>[], - ) as List<_i16.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override - _i16.NodeModel? getNodeById({required String? id}) => + _i15.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i16.NodeModel?); + )) as _i15.NodeModel?); @override - List<_i16.NodeModel> failoverNodesFor({required _i11.Coin? coin}) => + List<_i15.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i16.NodeModel>[], - ) as List<_i16.NodeModel>); + returnValue: <_i15.NodeModel>[], + ) as List<_i15.NodeModel>); @override - _i9.Future add( - _i16.NodeModel? node, + _i8.Future add( + _i15.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -781,11 +762,11 @@ class MockNodeService extends _i1.Mock implements _i15.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future delete( + _i8.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -797,11 +778,11 @@ class MockNodeService extends _i1.Mock implements _i15.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future setEnabledState( + _i8.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -815,12 +796,12 @@ class MockNodeService extends _i1.Mock implements _i15.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future edit( - _i16.NodeModel? editedNode, + _i8.Future edit( + _i15.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -833,20 +814,20 @@ class MockNodeService extends _i1.Mock implements _i15.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future updateCommunityNodes() => (super.noSuchMethod( + _i8.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -854,7 +835,7 @@ class MockNodeService extends _i1.Mock implements _i15.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 a486ac2b9..b8c7f3cbd 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 @@ -3,17 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,20 +56,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -98,10 +87,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -134,23 +123,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -160,16 +149,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -189,10 +178,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -204,27 +193,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -234,7 +215,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -250,27 +231,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -280,33 +261,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -323,20 +304,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -348,11 +329,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -364,18 +345,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -383,7 +364,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 7e1cc0835..68f2eeb10 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 @@ -3,17 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,20 +56,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -98,10 +87,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -134,23 +123,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -160,16 +149,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -189,10 +178,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -204,27 +193,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -234,7 +215,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -250,27 +231,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -280,33 +261,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -323,20 +304,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -348,11 +329,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -364,18 +345,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -383,7 +364,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 2d520d669..8b60863ab 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 @@ -3,19 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i9; -import 'dart:ui' as _i11; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i8; +import 'package:stackwallet/models/node_model.dart' as _i7; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i12; -import 'package:stackwallet/services/node_service.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/services/coins/manager.dart' as _i11; +import 'package:stackwallet/services/node_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -72,20 +71,10 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i7.NodeService { +class MockNodeService extends _i1.Mock implements _i6.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -95,33 +84,33 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i8.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i7.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override - List<_i8.NodeModel> get nodes => (super.noSuchMethod( + List<_i7.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateDefaults() => (super.noSuchMethod( + _i8.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future setPrimaryNodeFor({ - required _i10.Coin? coin, - required _i8.NodeModel? node, + _i8.Future setPrimaryNodeFor({ + required _i9.Coin? coin, + required _i7.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -134,44 +123,44 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i8.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => + _i7.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i8.NodeModel?); + )) as _i7.NodeModel?); @override - List<_i8.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( + List<_i7.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override - _i8.NodeModel? getNodeById({required String? id}) => + _i7.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i8.NodeModel?); + )) as _i7.NodeModel?); @override - List<_i8.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => + List<_i7.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override - _i9.Future add( - _i8.NodeModel? node, + _i8.Future add( + _i7.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -184,11 +173,11 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future delete( + _i8.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -200,11 +189,11 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future setEnabledState( + _i8.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -218,12 +207,12 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future edit( - _i8.NodeModel? editedNode, + _i8.Future edit( + _i7.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -236,20 +225,20 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future updateCommunityNodes() => (super.noSuchMethod( + _i8.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -257,7 +246,7 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -285,7 +274,7 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i12.Manager { +class MockManager extends _i1.Mock implements _i11.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -313,10 +302,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i10.Coin get coin => (super.noSuchMethod( + _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, - ) as _i10.Coin); + returnValue: _i9.Coin.bitcoin, + ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -349,23 +338,23 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i9.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i9.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -375,16 +364,16 @@ class MockManager extends _i1.Mock implements _i12.Manager { ), ) as _i5.Balance); @override - _i9.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i9.Future>.value(<_i13.Transaction>[]), - ) as _i9.Future>); + _i8.Future>.value(<_i12.Transaction>[]), + ) as _i8.Future>); @override - _i9.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i9.Future>.value(<_i13.UTXO>[]), - ) as _i9.Future>); + returnValue: _i8.Future>.value(<_i12.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -404,10 +393,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: '', ) as String); @override - _i9.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -419,27 +408,19 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -449,7 +430,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i9.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -465,27 +446,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { }, ), returnValue: - _i9.Future>.value({}), - ) as _i9.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i9.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i9.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -495,33 +476,33 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i9.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -538,20 +519,20 @@ class MockManager extends _i1.Mock implements _i12.Manager { #height: height, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -563,11 +544,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -579,18 +560,18 @@ class MockManager extends _i1.Mock implements _i12.Manager { feeRate, ], ), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -598,7 +579,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 f635b4556..09d59deb2 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 @@ -3,19 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i9; -import 'dart:ui' as _i11; +import 'dart:async' as _i8; +import 'dart:ui' as _i10; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i13; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/models.dart' as _i4; -import 'package:stackwallet/models/node_model.dart' as _i8; +import 'package:stackwallet/models/node_model.dart' as _i7; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i12; -import 'package:stackwallet/services/node_service.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/services/coins/manager.dart' as _i11; +import 'package:stackwallet/services/node_service.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; @@ -72,20 +71,10 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [NodeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNodeService extends _i1.Mock implements _i7.NodeService { +class MockNodeService extends _i1.Mock implements _i6.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), @@ -95,33 +84,33 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { ), ) as _i2.SecureStorageInterface); @override - List<_i8.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i7.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override - List<_i8.NodeModel> get nodes => (super.noSuchMethod( + List<_i7.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateDefaults() => (super.noSuchMethod( + _i8.Future updateDefaults() => (super.noSuchMethod( Invocation.method( #updateDefaults, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future setPrimaryNodeFor({ - required _i10.Coin? coin, - required _i8.NodeModel? node, + _i8.Future setPrimaryNodeFor({ + required _i9.Coin? coin, + required _i7.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -134,44 +123,44 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i8.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => + _i7.NodeModel? getPrimaryNodeFor({required _i9.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i8.NodeModel?); + )) as _i7.NodeModel?); @override - List<_i8.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( + List<_i7.NodeModel> getNodesFor(_i9.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override - _i8.NodeModel? getNodeById({required String? id}) => + _i7.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i8.NodeModel?); + )) as _i7.NodeModel?); @override - List<_i8.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => + List<_i7.NodeModel> failoverNodesFor({required _i9.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i8.NodeModel>[], - ) as List<_i8.NodeModel>); + returnValue: <_i7.NodeModel>[], + ) as List<_i7.NodeModel>); @override - _i9.Future add( - _i8.NodeModel? node, + _i8.Future add( + _i7.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -184,11 +173,11 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future delete( + _i8.Future delete( String? id, bool? shouldNotifyListeners, ) => @@ -200,11 +189,11 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future setEnabledState( + _i8.Future setEnabledState( String? id, bool? enabled, bool? shouldNotifyListeners, @@ -218,12 +207,12 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future edit( - _i8.NodeModel? editedNode, + _i8.Future edit( + _i7.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -236,20 +225,20 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future updateCommunityNodes() => (super.noSuchMethod( + _i8.Future updateCommunityNodes() => (super.noSuchMethod( Invocation.method( #updateCommunityNodes, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -257,7 +246,7 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -285,7 +274,7 @@ class MockNodeService extends _i1.Mock implements _i7.NodeService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i12.Manager { +class MockManager extends _i1.Mock implements _i11.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -313,10 +302,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i10.Coin get coin => (super.noSuchMethod( + _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, - ) as _i10.Coin); + returnValue: _i9.Coin.bitcoin, + ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -349,23 +338,23 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i9.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i9.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -375,16 +364,16 @@ class MockManager extends _i1.Mock implements _i12.Manager { ), ) as _i5.Balance); @override - _i9.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i9.Future>.value(<_i13.Transaction>[]), - ) as _i9.Future>); + _i8.Future>.value(<_i12.Transaction>[]), + ) as _i8.Future>); @override - _i9.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i9.Future>.value(<_i13.UTXO>[]), - ) as _i9.Future>); + returnValue: _i8.Future>.value(<_i12.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -404,10 +393,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: '', ) as String); @override - _i9.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -419,27 +408,19 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -449,7 +430,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - _i9.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -465,27 +446,27 @@ class MockManager extends _i1.Mock implements _i12.Manager { }, ), returnValue: - _i9.Future>.value({}), - ) as _i9.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i9.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i9.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -495,33 +476,33 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValue: false, ) as bool); @override - _i9.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -538,20 +519,20 @@ class MockManager extends _i1.Mock implements _i12.Manager { #height: height, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -563,11 +544,11 @@ class MockManager extends _i1.Mock implements _i12.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -579,18 +560,18 @@ class MockManager extends _i1.Mock implements _i12.Manager { feeRate, ], ), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -598,7 +579,7 @@ class MockManager extends _i1.Mock implements _i12.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 bfd751068..a958461b8 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 @@ -3,17 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,20 +56,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -98,10 +87,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -134,23 +123,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -160,16 +149,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -189,10 +178,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -204,27 +193,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -234,7 +215,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -250,27 +231,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -280,33 +261,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -323,20 +304,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -348,11 +329,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -364,18 +345,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -383,7 +364,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 c8d4b99bc..284065eba 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 @@ -3,17 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,20 +56,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -98,10 +87,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -134,23 +123,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -160,16 +149,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -189,10 +178,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -204,27 +193,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -234,7 +215,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -250,27 +231,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -280,33 +261,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -323,20 +304,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -348,11 +329,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -364,18 +345,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -383,7 +364,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 28012ebb0..24da7d388 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 @@ -3,18 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i6; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/wallets_service.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -58,34 +57,24 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i5.WalletsService { @override - _i7.Future> get walletNames => + _i6.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i6.Future>.value( + {}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i6.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -100,13 +89,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future addExistingStackWallet({ + _i6.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -120,13 +109,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addNewWallet({ + _i6.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -139,46 +128,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i6.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future moveFavorite({ + _i6.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -191,48 +180,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i6.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i6.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i6.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteWallet( + _i6.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -244,20 +233,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i6.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -265,7 +254,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -293,7 +282,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -321,10 +310,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -357,23 +346,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i6.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i6.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i6.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -383,16 +372,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i6.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i6.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -412,10 +401,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i6.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -427,27 +416,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -457,7 +438,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i6.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -473,27 +454,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i6.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -503,33 +484,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i6.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i6.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i6.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future recoverFromMnemonic({ + _i6.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -546,20 +527,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i6.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future fullRescan( + _i6.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -571,11 +552,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future estimateFeeFor( + _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -587,18 +568,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i6.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -606,7 +587,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 90e176aff..0bf926563 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 @@ -3,23 +3,22 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i9; -import 'dart:ui' as _i15; +import 'dart:async' as _i8; +import 'dart:ui' as _i14; -import 'package:isar/isar.dart' as _i6; -import 'package:local_auth/auth_strings.dart' as _i12; -import 'package:local_auth/local_auth.dart' as _i11; +import 'package:local_auth/auth_strings.dart' as _i11; +import 'package:local_auth/local_auth.dart' as _i10; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i8; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i7; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i16; -import 'package:stackwallet/services/wallets_service.dart' as _i14; -import 'package:stackwallet/utilities/biometrics.dart' as _i13; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/services/coins/manager.dart' as _i15; +import 'package:stackwallet/services/wallets_service.dart' as _i13; +import 'package:stackwallet/utilities/biometrics.dart' as _i12; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; import 'package:stackwallet/utilities/prefs.dart' as _i2; // ignore_for_file: type=lint @@ -74,20 +73,10 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -116,15 +105,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i2.Prefs); @override - List<_i8.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i7.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i8.ElectrumXNode>[], - ) as List<_i8.ElectrumXNode>); + returnValue: <_i7.ElectrumXNode>[], + ) as List<_i7.ElectrumXNode>); @override - _i9.Future> getAnonymitySet({ + _i8.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i10.Coin? coin, + required _i9.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -137,8 +126,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i9.Future>.value({}), - ) as _i9.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -156,9 +145,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i9.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, - required _i10.Coin? coin, + required _i9.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -172,11 +161,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i9.Future>.value({}), - ) as _i9.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i9.Future> getUsedCoinSerials({ - required _i10.Coin? coin, + _i8.Future> getUsedCoinSerials({ + required _i9.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -188,43 +177,43 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i9.Future clearSharedTransactionCache({required _i10.Coin? coin}) => + _i8.Future clearSharedTransactionCache({required _i9.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } /// A class which mocks [LocalAuthentication]. /// /// See the documentation for Mockito's code generation for more information. class MockLocalAuthentication extends _i1.Mock - implements _i11.LocalAuthentication { + implements _i10.LocalAuthentication { MockLocalAuthentication() { _i1.throwOnMissingStub(this); } @override - _i9.Future get canCheckBiometrics => (super.noSuchMethod( + _i8.Future get canCheckBiometrics => (super.noSuchMethod( Invocation.getter(#canCheckBiometrics), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future authenticateWithBiometrics({ + _i8.Future authenticateWithBiometrics({ required String? localizedReason, bool? useErrorDialogs = true, bool? stickyAuth = false, - _i12.AndroidAuthMessages? androidAuthStrings = - const _i12.AndroidAuthMessages(), - _i12.IOSAuthMessages? iOSAuthStrings = const _i12.IOSAuthMessages(), + _i11.AndroidAuthMessages? androidAuthStrings = + const _i11.AndroidAuthMessages(), + _i11.IOSAuthMessages? iOSAuthStrings = const _i11.IOSAuthMessages(), bool? sensitiveTransaction = true, }) => (super.noSuchMethod( @@ -240,16 +229,16 @@ class MockLocalAuthentication extends _i1.Mock #sensitiveTransaction: sensitiveTransaction, }, ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future authenticate({ + _i8.Future authenticate({ required String? localizedReason, bool? useErrorDialogs = true, bool? stickyAuth = false, - _i12.AndroidAuthMessages? androidAuthStrings = - const _i12.AndroidAuthMessages(), - _i12.IOSAuthMessages? iOSAuthStrings = const _i12.IOSAuthMessages(), + _i11.AndroidAuthMessages? androidAuthStrings = + const _i11.AndroidAuthMessages(), + _i11.IOSAuthMessages? iOSAuthStrings = const _i11.IOSAuthMessages(), bool? sensitiveTransaction = true, bool? biometricOnly = false, }) => @@ -267,46 +256,46 @@ class MockLocalAuthentication extends _i1.Mock #biometricOnly: biometricOnly, }, ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future stopAuthentication() => (super.noSuchMethod( + _i8.Future stopAuthentication() => (super.noSuchMethod( Invocation.method( #stopAuthentication, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future isDeviceSupported() => (super.noSuchMethod( + _i8.Future isDeviceSupported() => (super.noSuchMethod( Invocation.method( #isDeviceSupported, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future> getAvailableBiometrics() => + _i8.Future> getAvailableBiometrics() => (super.noSuchMethod( Invocation.method( #getAvailableBiometrics, [], ), returnValue: - _i9.Future>.value(<_i11.BiometricType>[]), - ) as _i9.Future>); + _i8.Future>.value(<_i10.BiometricType>[]), + ) as _i8.Future>); } /// A class which mocks [Biometrics]. /// /// See the documentation for Mockito's code generation for more information. -class MockBiometrics extends _i1.Mock implements _i13.Biometrics { +class MockBiometrics extends _i1.Mock implements _i12.Biometrics { MockBiometrics() { _i1.throwOnMissingStub(this); } @override - _i9.Future authenticate({ + _i8.Future authenticate({ required String? cancelButtonText, required String? localizedReason, required String? title, @@ -321,28 +310,28 @@ class MockBiometrics extends _i1.Mock implements _i13.Biometrics { #title: title, }, ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); } /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i14.WalletsService { +class MockWalletsService extends _i1.Mock implements _i13.WalletsService { @override - _i9.Future> get walletNames => + _i8.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i9.Future>.value( - {}), - ) as _i9.Future>); + returnValue: _i8.Future>.value( + {}), + ) as _i8.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future renameWallet({ + _i8.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -357,13 +346,13 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future addExistingStackWallet({ + _i8.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i10.Coin? coin, + required _i9.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -377,13 +366,13 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future addNewWallet({ + _i8.Future addNewWallet({ required String? name, - required _i10.Coin? coin, + required _i9.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -396,46 +385,46 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i8.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i9.Future saveFavoriteWalletIds(List? walletIds) => + _i8.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i8.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future moveFavorite({ + _i8.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -448,48 +437,48 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i8.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i8.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future isMnemonicVerified({required String? walletId}) => + _i8.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future setMnemonicVerified({required String? walletId}) => + _i8.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future deleteWallet( + _i8.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -501,20 +490,20 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future refreshWallets(bool? shouldNotifyListeners) => + _i8.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -522,7 +511,7 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -550,7 +539,7 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i16.Manager { +class MockManager extends _i1.Mock implements _i15.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -578,10 +567,10 @@ class MockManager extends _i1.Mock implements _i16.Manager { returnValue: false, ) as bool); @override - _i10.Coin get coin => (super.noSuchMethod( + _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, - ) as _i10.Coin); + returnValue: _i9.Coin.bitcoin, + ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -614,23 +603,23 @@ class MockManager extends _i1.Mock implements _i16.Manager { returnValueForMissingStub: null, ); @override - _i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i9.Future<_i4.FeeObject>); + ) as _i8.Future<_i4.FeeObject>); @override - _i9.Future get maxFee => (super.noSuchMethod( + _i8.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future get currentReceivingAddress => (super.noSuchMethod( + _i8.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -640,16 +629,16 @@ class MockManager extends _i1.Mock implements _i16.Manager { ), ) as _i5.Balance); @override - _i9.Future> get transactions => (super.noSuchMethod( + _i8.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i9.Future>.value(<_i17.Transaction>[]), - ) as _i9.Future>); + _i8.Future>.value(<_i16.Transaction>[]), + ) as _i8.Future>); @override - _i9.Future> get utxos => (super.noSuchMethod( + _i8.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i9.Future>.value(<_i17.UTXO>[]), - ) as _i9.Future>); + returnValue: _i8.Future>.value(<_i16.UTXO>[]), + ) as _i8.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -669,10 +658,10 @@ class MockManager extends _i1.Mock implements _i16.Manager { returnValue: '', ) as String); @override - _i9.Future> get mnemonic => (super.noSuchMethod( + _i8.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i9.Future>.value([]), - ) as _i9.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -684,27 +673,19 @@ class MockManager extends _i1.Mock implements _i16.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i9.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -714,7 +695,7 @@ class MockManager extends _i1.Mock implements _i16.Manager { returnValueForMissingStub: null, ); @override - _i9.Future> prepareSend({ + _i8.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -730,27 +711,27 @@ class MockManager extends _i1.Mock implements _i16.Manager { }, ), returnValue: - _i9.Future>.value({}), - ) as _i9.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i9.Future confirmSend({required Map? txData}) => + _i8.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i9.Future.value(''), - ) as _i9.Future); + returnValue: _i8.Future.value(''), + ) as _i8.Future); @override - _i9.Future refresh() => (super.noSuchMethod( + _i8.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -760,33 +741,33 @@ class MockManager extends _i1.Mock implements _i16.Manager { returnValue: false, ) as bool); @override - _i9.Future testNetworkConnection() => (super.noSuchMethod( + _i8.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i9.Future initializeNew() => (super.noSuchMethod( + _i8.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future initializeExisting() => (super.noSuchMethod( + _i8.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future recoverFromMnemonic({ + _i8.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -803,20 +784,20 @@ class MockManager extends _i1.Mock implements _i16.Manager { #height: height, }, ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future exitCurrentWallet() => (super.noSuchMethod( + _i8.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future fullRescan( + _i8.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -828,11 +809,11 @@ class MockManager extends _i1.Mock implements _i16.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i9.Future estimateFeeFor( + _i8.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -844,18 +825,18 @@ class MockManager extends _i1.Mock implements _i16.Manager { feeRate, ], ), - returnValue: _i9.Future.value(0), - ) as _i9.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i9.Future generateNewAddress() => (super.noSuchMethod( + _i8.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i9.Future.value(false), - ) as _i9.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -863,7 +844,7 @@ class MockManager extends _i1.Mock implements _i16.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 8472c70ab..487f2f2bf 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 @@ -3,18 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i9; +import 'dart:async' as _i6; +import 'dart:ui' as _i8; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i10; -import 'package:stackwallet/services/wallets_service.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; +import 'package:stackwallet/services/coins/manager.dart' as _i9; +import 'package:stackwallet/services/wallets_service.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -58,34 +57,24 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [WalletsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockWalletsService extends _i1.Mock implements _i6.WalletsService { +class MockWalletsService extends _i1.Mock implements _i5.WalletsService { @override - _i7.Future> get walletNames => + _i6.Future> get walletNames => (super.noSuchMethod( Invocation.getter(#walletNames), - returnValue: _i7.Future>.value( - {}), - ) as _i7.Future>); + returnValue: _i6.Future>.value( + {}), + ) as _i6.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future renameWallet({ + _i6.Future renameWallet({ required String? from, required String? to, required bool? shouldNotifyListeners, @@ -100,13 +89,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future addExistingStackWallet({ + _i6.Future addExistingStackWallet({ required String? name, required String? walletId, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -120,13 +109,13 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addNewWallet({ + _i6.Future addNewWallet({ required String? name, - required _i8.Coin? coin, + required _i7.Coin? coin, required bool? shouldNotifyListeners, }) => (super.noSuchMethod( @@ -139,46 +128,46 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #shouldNotifyListeners: shouldNotifyListeners, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future> getFavoriteWalletIds() => (super.noSuchMethod( + _i6.Future> getFavoriteWalletIds() => (super.noSuchMethod( Invocation.method( #getFavoriteWalletIds, [], ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i7.Future saveFavoriteWalletIds(List? walletIds) => + _i6.Future saveFavoriteWalletIds(List? walletIds) => (super.noSuchMethod( Invocation.method( #saveFavoriteWalletIds, [walletIds], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future addFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future addFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #addFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future removeFavorite(String? walletId) => (super.noSuchMethod( + _i6.Future removeFavorite(String? walletId) => (super.noSuchMethod( Invocation.method( #removeFavorite, [walletId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future moveFavorite({ + _i6.Future moveFavorite({ required int? fromIndex, required int? toIndex, }) => @@ -191,48 +180,48 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { #toIndex: toIndex, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future checkForDuplicate(String? name) => (super.noSuchMethod( + _i6.Future checkForDuplicate(String? name) => (super.noSuchMethod( Invocation.method( #checkForDuplicate, [name], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future getWalletId(String? walletName) => (super.noSuchMethod( + _i6.Future getWalletId(String? walletName) => (super.noSuchMethod( Invocation.method( #getWalletId, [walletName], ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future isMnemonicVerified({required String? walletId}) => + _i6.Future isMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #isMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future setMnemonicVerified({required String? walletId}) => + _i6.Future setMnemonicVerified({required String? walletId}) => (super.noSuchMethod( Invocation.method( #setMnemonicVerified, [], {#walletId: walletId}, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future deleteWallet( + _i6.Future deleteWallet( String? name, bool? shouldNotifyListeners, ) => @@ -244,20 +233,20 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { shouldNotifyListeners, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future refreshWallets(bool? shouldNotifyListeners) => + _i6.Future refreshWallets(bool? shouldNotifyListeners) => (super.noSuchMethod( Invocation.method( #refreshWallets, [shouldNotifyListeners], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -265,7 +254,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -293,7 +282,7 @@ class MockWalletsService extends _i1.Mock implements _i6.WalletsService { /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i10.Manager { +class MockManager extends _i1.Mock implements _i9.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -321,10 +310,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i8.Coin get coin => (super.noSuchMethod( + _i7.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i8.Coin.bitcoin, - ) as _i8.Coin); + returnValue: _i7.Coin.bitcoin, + ) as _i7.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -357,23 +346,23 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i6.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i6.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i7.Future<_i3.FeeObject>); + ) as _i6.Future<_i3.FeeObject>); @override - _i7.Future get maxFee => (super.noSuchMethod( + _i6.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future get currentReceivingAddress => (super.noSuchMethod( + _i6.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -383,16 +372,16 @@ class MockManager extends _i1.Mock implements _i10.Manager { ), ) as _i4.Balance); @override - _i7.Future> get transactions => (super.noSuchMethod( + _i6.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i7.Future>.value(<_i11.Transaction>[]), - ) as _i7.Future>); + _i6.Future>.value(<_i10.Transaction>[]), + ) as _i6.Future>); @override - _i7.Future> get utxos => (super.noSuchMethod( + _i6.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i7.Future>.value(<_i11.UTXO>[]), - ) as _i7.Future>); + returnValue: _i6.Future>.value(<_i10.UTXO>[]), + ) as _i6.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -412,10 +401,10 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: '', ) as String); @override - _i7.Future> get mnemonic => (super.noSuchMethod( + _i6.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -427,27 +416,19 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i6.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -457,7 +438,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - _i7.Future> prepareSend({ + _i6.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -473,27 +454,27 @@ class MockManager extends _i1.Mock implements _i10.Manager { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i7.Future confirmSend({required Map? txData}) => + _i6.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i7.Future.value(''), - ) as _i7.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i7.Future refresh() => (super.noSuchMethod( + _i6.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -503,33 +484,33 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValue: false, ) as bool); @override - _i7.Future testNetworkConnection() => (super.noSuchMethod( + _i6.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i7.Future initializeNew() => (super.noSuchMethod( + _i6.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future initializeExisting() => (super.noSuchMethod( + _i6.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future recoverFromMnemonic({ + _i6.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -546,20 +527,20 @@ class MockManager extends _i1.Mock implements _i10.Manager { #height: height, }, ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future exitCurrentWallet() => (super.noSuchMethod( + _i6.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future fullRescan( + _i6.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -571,11 +552,11 @@ class MockManager extends _i1.Mock implements _i10.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override - _i7.Future estimateFeeFor( + _i6.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -587,18 +568,18 @@ class MockManager extends _i1.Mock implements _i10.Manager { feeRate, ], ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i7.Future generateNewAddress() => (super.noSuchMethod( + _i6.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -606,7 +587,7 @@ class MockManager extends _i1.Mock implements _i10.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i8.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 2b52ffd37..31bda1f65 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 @@ -3,19 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i12; -import 'package:stackwallet/services/notes_service.dart' as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/services/locale_service.dart' as _i11; +import 'package:stackwallet/services/notes_service.dart' as _i10; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -59,20 +58,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -100,10 +89,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -136,23 +125,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -162,16 +151,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -191,10 +180,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -206,27 +195,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -236,7 +217,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -252,27 +233,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -282,33 +263,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -325,20 +306,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -350,11 +331,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -366,18 +347,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -385,7 +366,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -405,7 +386,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i10.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -417,34 +398,34 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValue: {}, ) as Map); @override - _i8.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -457,21 +438,21 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { #note: note, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -479,7 +460,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -507,7 +488,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i12.LocaleService { +class MockLocaleService extends _i1.Mock implements _i11.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -519,17 +500,17 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValue: false, ) as bool); @override - _i8.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -537,7 +518,7 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 0c514d22b..161b63e1d 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 @@ -3,18 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/notes_service.dart' as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/services/notes_service.dart' as _i10; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -58,20 +57,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -99,10 +88,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -135,23 +124,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -161,16 +150,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -190,10 +179,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -205,27 +194,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -235,7 +216,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -251,27 +232,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -281,33 +262,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -324,20 +305,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -349,11 +330,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -365,18 +346,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -384,7 +365,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -404,7 +385,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i10.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -416,34 +397,34 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValue: {}, ) as Map); @override - _i8.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -456,21 +437,21 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { #note: note, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -478,7 +459,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 5268ecf10..7172f3e29 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 @@ -3,17 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -57,20 +56,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -98,10 +87,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -134,23 +123,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -160,16 +149,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -189,10 +178,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -204,27 +193,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -234,7 +215,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -250,27 +231,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -280,33 +261,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -323,20 +304,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -348,11 +329,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -364,18 +345,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -383,7 +364,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 f10b663e0..ba206a8c6 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 @@ -3,20 +3,19 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i12; +import 'dart:async' as _i7; +import 'dart:ui' as _i11; import 'package:barcode_scan2/barcode_scan2.dart' as _i2; -import 'package:isar/isar.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i10; import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/services/coins/coin_service.dart' as _i3; -import 'package:stackwallet/services/coins/manager.dart' as _i9; -import 'package:stackwallet/services/notes_service.dart' as _i13; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; +import 'package:stackwallet/services/coins/manager.dart' as _i8; +import 'package:stackwallet/services/notes_service.dart' as _i12; +import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i6; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -70,27 +69,17 @@ class _FakeBalance_3 extends _i1.SmartFake implements _i5.Balance { ); } -class _FakeIsar_4 extends _i1.SmartFake implements _i6.Isar { - _FakeIsar_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [BarcodeScannerWrapper]. /// /// See the documentation for Mockito's code generation for more information. class MockBarcodeScannerWrapper extends _i1.Mock - implements _i7.BarcodeScannerWrapper { + implements _i6.BarcodeScannerWrapper { MockBarcodeScannerWrapper() { _i1.throwOnMissingStub(this); } @override - _i8.Future<_i2.ScanResult> scan( + _i7.Future<_i2.ScanResult> scan( {_i2.ScanOptions? options = const _i2.ScanOptions()}) => (super.noSuchMethod( Invocation.method( @@ -98,7 +87,7 @@ class MockBarcodeScannerWrapper extends _i1.Mock [], {#options: options}, ), - returnValue: _i8.Future<_i2.ScanResult>.value(_FakeScanResult_0( + returnValue: _i7.Future<_i2.ScanResult>.value(_FakeScanResult_0( this, Invocation.method( #scan, @@ -106,13 +95,13 @@ class MockBarcodeScannerWrapper extends _i1.Mock {#options: options}, ), )), - ) as _i8.Future<_i2.ScanResult>); + ) as _i7.Future<_i2.ScanResult>); } /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i9.Manager { +class MockManager extends _i1.Mock implements _i8.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -140,10 +129,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i10.Coin get coin => (super.noSuchMethod( + _i9.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i10.Coin.bitcoin, - ) as _i10.Coin); + returnValue: _i9.Coin.bitcoin, + ) as _i9.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -176,23 +165,23 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i4.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2( + returnValue: _i7.Future<_i4.FeeObject>.value(_FakeFeeObject_2( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i4.FeeObject>); + ) as _i7.Future<_i4.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i5.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -202,16 +191,16 @@ class MockManager extends _i1.Mock implements _i9.Manager { ), ) as _i5.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i11.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i10.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i11.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i10.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -231,10 +220,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -246,27 +235,19 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: 0, ) as int); @override - _i6.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_4( - this, - Invocation.getter(#db), - ), - ) as _i6.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -276,7 +257,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -292,27 +273,27 @@ class MockManager extends _i1.Mock implements _i9.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -322,33 +303,33 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -365,20 +346,20 @@ class MockManager extends _i1.Mock implements _i9.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -390,11 +371,11 @@ class MockManager extends _i1.Mock implements _i9.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -406,18 +387,18 @@ class MockManager extends _i1.Mock implements _i9.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -425,7 +406,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -445,7 +426,7 @@ class MockManager extends _i1.Mock implements _i9.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i13.NotesService { +class MockNotesService extends _i1.Mock implements _i12.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -457,34 +438,34 @@ class MockNotesService extends _i1.Mock implements _i13.NotesService { returnValue: {}, ) as Map); @override - _i8.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -497,21 +478,21 @@ class MockNotesService extends _i1.Mock implements _i13.NotesService { #note: note, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -519,7 +500,7 @@ class MockNotesService extends _i1.Mock implements _i13.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], 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 ef21b7bca..ae6a2d1f9 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 @@ -3,19 +3,18 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i8; -import 'dart:ui' as _i10; +import 'dart:async' as _i7; +import 'dart:ui' as _i9; -import 'package:isar/isar.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/balance.dart' as _i4; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i9; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i8; import 'package:stackwallet/models/models.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i2; -import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i12; -import 'package:stackwallet/services/notes_service.dart' as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; +import 'package:stackwallet/services/coins/manager.dart' as _i5; +import 'package:stackwallet/services/locale_service.dart' as _i11; +import 'package:stackwallet/services/notes_service.dart' as _i10; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -59,20 +58,10 @@ class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { ); } -class _FakeIsar_3 extends _i1.SmartFake implements _i5.Isar { - _FakeIsar_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [Manager]. /// /// See the documentation for Mockito's code generation for more information. -class MockManager extends _i1.Mock implements _i6.Manager { +class MockManager extends _i1.Mock implements _i5.Manager { @override bool get isActiveWallet => (super.noSuchMethod( Invocation.getter(#isActiveWallet), @@ -100,10 +89,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i7.Coin get coin => (super.noSuchMethod( + _i6.Coin get coin => (super.noSuchMethod( Invocation.getter(#coin), - returnValue: _i7.Coin.bitcoin, - ) as _i7.Coin); + returnValue: _i6.Coin.bitcoin, + ) as _i6.Coin); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -136,23 +125,23 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future<_i3.FeeObject> get fees => (super.noSuchMethod( + _i7.Future<_i3.FeeObject> get fees => (super.noSuchMethod( Invocation.getter(#fees), - returnValue: _i8.Future<_i3.FeeObject>.value(_FakeFeeObject_1( + returnValue: _i7.Future<_i3.FeeObject>.value(_FakeFeeObject_1( this, Invocation.getter(#fees), )), - ) as _i8.Future<_i3.FeeObject>); + ) as _i7.Future<_i3.FeeObject>); @override - _i8.Future get maxFee => (super.noSuchMethod( + _i7.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future get currentReceivingAddress => (super.noSuchMethod( + _i7.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override _i4.Balance get balance => (super.noSuchMethod( Invocation.getter(#balance), @@ -162,16 +151,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i4.Balance); @override - _i8.Future> get transactions => (super.noSuchMethod( + _i7.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i8.Future>.value(<_i9.Transaction>[]), - ) as _i8.Future>); + _i7.Future>.value(<_i8.Transaction>[]), + ) as _i7.Future>); @override - _i8.Future> get utxos => (super.noSuchMethod( + _i7.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i8.Future>.value(<_i9.UTXO>[]), - ) as _i8.Future>); + returnValue: _i7.Future>.value(<_i8.UTXO>[]), + ) as _i7.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -191,10 +180,10 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: '', ) as String); @override - _i8.Future> get mnemonic => (super.noSuchMethod( + _i7.Future> get mnemonic => (super.noSuchMethod( Invocation.getter(#mnemonic), - returnValue: _i8.Future>.value([]), - ) as _i8.Future>); + returnValue: _i7.Future>.value([]), + ) as _i7.Future>); @override bool get isConnected => (super.noSuchMethod( Invocation.getter(#isConnected), @@ -206,27 +195,19 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i5.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_3( - this, - Invocation.getter(#db), - ), - ) as _i5.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( + _i7.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod( Invocation.method( #updateNode, [shouldRefresh], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override void dispose() => super.noSuchMethod( Invocation.method( @@ -236,7 +217,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - _i8.Future> prepareSend({ + _i7.Future> prepareSend({ required String? address, required int? satoshiAmount, Map? args, @@ -252,27 +233,27 @@ class MockManager extends _i1.Mock implements _i6.Manager { }, ), returnValue: - _i8.Future>.value({}), - ) as _i8.Future>); + _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future confirmSend({required Map? txData}) => + _i7.Future confirmSend({required Map? txData}) => (super.noSuchMethod( Invocation.method( #confirmSend, [], {#txData: txData}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future refresh() => (super.noSuchMethod( + _i7.Future refresh() => (super.noSuchMethod( Invocation.method( #refresh, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -282,33 +263,33 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: false, ) as bool); @override - _i8.Future testNetworkConnection() => (super.noSuchMethod( + _i7.Future testNetworkConnection() => (super.noSuchMethod( Invocation.method( #testNetworkConnection, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - _i8.Future initializeNew() => (super.noSuchMethod( + _i7.Future initializeNew() => (super.noSuchMethod( Invocation.method( #initializeNew, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future initializeExisting() => (super.noSuchMethod( + _i7.Future initializeExisting() => (super.noSuchMethod( Invocation.method( #initializeExisting, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future recoverFromMnemonic({ + _i7.Future recoverFromMnemonic({ required String? mnemonic, required int? maxUnusedAddressGap, required int? maxNumberOfIndexesToCheck, @@ -325,20 +306,20 @@ class MockManager extends _i1.Mock implements _i6.Manager { #height: height, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future exitCurrentWallet() => (super.noSuchMethod( + _i7.Future exitCurrentWallet() => (super.noSuchMethod( Invocation.method( #exitCurrentWallet, [], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future fullRescan( + _i7.Future fullRescan( int? maxUnusedAddressGap, int? maxNumberOfIndexesToCheck, ) => @@ -350,11 +331,11 @@ class MockManager extends _i1.Mock implements _i6.Manager { maxNumberOfIndexesToCheck, ], ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future estimateFeeFor( + _i7.Future estimateFeeFor( int? satoshiAmount, int? feeRate, ) => @@ -366,18 +347,18 @@ class MockManager extends _i1.Mock implements _i6.Manager { feeRate, ], ), - returnValue: _i8.Future.value(0), - ) as _i8.Future); + returnValue: _i7.Future.value(0), + ) as _i7.Future); @override - _i8.Future generateNewAddress() => (super.noSuchMethod( + _i7.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( #generateNewAddress, [], ), - returnValue: _i8.Future.value(false), - ) as _i8.Future); + returnValue: _i7.Future.value(false), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -385,7 +366,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -405,7 +386,7 @@ class MockManager extends _i1.Mock implements _i6.Manager { /// A class which mocks [NotesService]. /// /// See the documentation for Mockito's code generation for more information. -class MockNotesService extends _i1.Mock implements _i11.NotesService { +class MockNotesService extends _i1.Mock implements _i10.NotesService { @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), @@ -417,34 +398,34 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValue: {}, ) as Map); @override - _i8.Future> get notes => (super.noSuchMethod( + _i7.Future> get notes => (super.noSuchMethod( Invocation.getter(#notes), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, ) as bool); @override - _i8.Future> search(String? text) => (super.noSuchMethod( + _i7.Future> search(String? text) => (super.noSuchMethod( Invocation.method( #search, [text], ), - returnValue: _i8.Future>.value({}), - ) as _i8.Future>); + returnValue: _i7.Future>.value({}), + ) as _i7.Future>); @override - _i8.Future getNoteFor({required String? txid}) => (super.noSuchMethod( + _i7.Future getNoteFor({required String? txid}) => (super.noSuchMethod( Invocation.method( #getNoteFor, [], {#txid: txid}, ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); + returnValue: _i7.Future.value(''), + ) as _i7.Future); @override - _i8.Future editOrAddNote({ + _i7.Future editOrAddNote({ required String? txid, required String? note, }) => @@ -457,21 +438,21 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { #note: note, }, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - _i8.Future deleteNote({required String? txid}) => (super.noSuchMethod( + _i7.Future deleteNote({required String? txid}) => (super.noSuchMethod( Invocation.method( #deleteNote, [], {#txid: txid}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -479,7 +460,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -507,7 +488,7 @@ class MockNotesService extends _i1.Mock implements _i11.NotesService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i12.LocaleService { +class MockLocaleService extends _i1.Mock implements _i11.LocaleService { @override String get locale => (super.noSuchMethod( Invocation.getter(#locale), @@ -519,17 +500,17 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValue: false, ) as bool); @override - _i8.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( + _i7.Future loadLocale({bool? notify = true}) => (super.noSuchMethod( Invocation.method( #loadLocale, [], {#notify: notify}, ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); + returnValue: _i7.Future.value(), + returnValueForMissingStub: _i7.Future.value(), + ) as _i7.Future); @override - void addListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -537,7 +518,7 @@ class MockLocaleService extends _i1.Mock implements _i12.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i10.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i9.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index b723c35c6..cb02aa126 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -6,7 +6,6 @@ import 'dart:async' as _i10; import 'package:decimal/decimal.dart' as _i8; -import 'package:isar/isar.dart' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; @@ -15,6 +14,7 @@ import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/lelantus_coin.dart' as _i13; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i3; import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i9; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i7; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; @@ -83,8 +83,8 @@ class _FakeBalance_4 extends _i1.SmartFake implements _i6.Balance { ); } -class _FakeIsar_5 extends _i1.SmartFake implements _i7.Isar { - _FakeIsar_5( +class _FakeIDB_5 extends _i1.SmartFake implements _i7.IDB { + _FakeIDB_5( Object parent, Invocation parentInvocation, ) : super( @@ -328,14 +328,6 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { _i10.Future>.value(<_i12.Transaction>[]), ) as _i10.Future>); @override - _i7.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_5( - this, - Invocation.getter(#isarInstance), - ), - ) as _i7.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -345,13 +337,13 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: null, ); @override - _i7.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_5( + _i7.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_5( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i7.Isar); + ) as _i7.IDB); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -993,31 +985,29 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i10.Future isarInit(String? walletId) => (super.noSuchMethod( + _i10.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i10.Future.value(false), - ) as _i10.Future); - @override - _i10.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i10.Future.value(false), - ) as _i10.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override _i10.Future addNewTransactionData( - List< - _i14.Tuple4<_i12.Transaction, List<_i12.Output>, - List<_i12.Input>, _i12.Address?>>? - transactionsData) => + List< + _i14.Tuple4<_i12.Transaction, List<_i12.Output>, List<_i12.Input>, + _i12.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i10.Future.value(), returnValueForMissingStub: _i10.Future.value(), diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index a75b0e294..31ab09dc3 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -8,7 +8,6 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; @@ -20,6 +19,7 @@ import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i23; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -136,8 +136,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { - _FakeIsar_9( +class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { + _FakeIDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -819,14 +819,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), ) as _i11.Balance); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -836,13 +828,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_9( + _i12.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_9( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i12.Isar); + ) as _i12.IDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( @@ -1356,31 +1348,29 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); - @override - _i17.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override _i17.Future addNewTransactionData( - List< - _i22.Tuple4<_i21.Transaction, List<_i21.Output>, - List<_i21.Input>, _i21.Address?>>? - transactionsData) => + List< + _i22.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, + _i21.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), @@ -1786,14 +1776,6 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i12.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#db), - ), - ) as _i12.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2107,14 +2089,6 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 758f15bab..8730e670d 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 @@ -8,7 +8,6 @@ import 'dart:ui' as _i18; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; @@ -18,6 +17,7 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i19; import 'package:stackwallet/services/coins/coin_service.dart' as _i13; import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -132,8 +132,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { - _FakeIsar_9( +class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { + _FakeIDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -804,14 +804,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { ), ) as _i11.Balance); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -821,13 +813,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_9( + _i12.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_9( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i12.Isar); + ) as _i12.IDB); @override _i16.Future exit() => (super.noSuchMethod( Invocation.method( @@ -1341,31 +1333,29 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: _i16.Future.value(), ) as _i16.Future); @override - _i16.Future isarInit(String? walletId) => (super.noSuchMethod( + _i16.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); - @override - _i16.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i16.Future.value(false), - ) as _i16.Future); + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); @override _i16.Future addNewTransactionData( - List< - _i21.Tuple4<_i20.Transaction, List<_i20.Output>, - List<_i20.Input>, _i20.Address?>>? - transactionsData) => + List< + _i21.Tuple4<_i20.Transaction, List<_i20.Output>, List<_i20.Input>, + _i20.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i16.Future.value(), returnValueForMissingStub: _i16.Future.value(), @@ -1509,14 +1499,6 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i12.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#db), - ), - ) as _i12.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -1830,14 +1812,6 @@ class MockCoinServiceAPI extends _i1.Mock implements _i13.CoinServiceAPI { returnValue: 0, ) as int); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override _i16.Future> prepareSend({ required String? address, required int? satoshiAmount, diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 828ce04b9..f86713805 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -9,10 +9,9 @@ import 'dart:ui' as _i20; import 'package:decimal/decimal.dart' as _i14; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i10; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i13; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i12; +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 _i9; import 'package:stackwallet/models/isar/models/isar_models.dart' as _i21; import 'package:stackwallet/models/models.dart' as _i8; @@ -22,11 +21,12 @@ import 'package:stackwallet/services/coins/coin_service.dart' as _i7; import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i22; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i23; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i13; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/notes_service.dart' as _i28; import 'package:stackwallet/services/price_service.dart' as _i27; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i11; + as _i10; import 'package:stackwallet/services/wallets.dart' as _i16; import 'package:stackwallet/services/wallets_service.dart' as _i2; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i26; @@ -119,8 +119,9 @@ class _FakeBalance_6 extends _i1.SmartFake implements _i9.Balance { ); } -class _FakeIsar_7 extends _i1.SmartFake implements _i10.Isar { - _FakeIsar_7( +class _FakeTransactionNotificationTracker_7 extends _i1.SmartFake + implements _i10.TransactionNotificationTracker { + _FakeTransactionNotificationTracker_7( Object parent, Invocation parentInvocation, ) : super( @@ -129,9 +130,8 @@ class _FakeIsar_7 extends _i1.SmartFake implements _i10.Isar { ); } -class _FakeTransactionNotificationTracker_8 extends _i1.SmartFake - implements _i11.TransactionNotificationTracker { - _FakeTransactionNotificationTracker_8( +class _FakeElectrumX_8 extends _i1.SmartFake implements _i11.ElectrumX { + _FakeElectrumX_8( Object parent, Invocation parentInvocation, ) : super( @@ -140,8 +140,9 @@ class _FakeTransactionNotificationTracker_8 extends _i1.SmartFake ); } -class _FakeElectrumX_9 extends _i1.SmartFake implements _i12.ElectrumX { - _FakeElectrumX_9( +class _FakeCachedElectrumX_9 extends _i1.SmartFake + implements _i12.CachedElectrumX { + _FakeCachedElectrumX_9( Object parent, Invocation parentInvocation, ) : super( @@ -150,9 +151,8 @@ class _FakeElectrumX_9 extends _i1.SmartFake implements _i12.ElectrumX { ); } -class _FakeCachedElectrumX_10 extends _i1.SmartFake - implements _i13.CachedElectrumX { - _FakeCachedElectrumX_10( +class _FakeIDB_10 extends _i1.SmartFake implements _i13.IDB { + _FakeIDB_10( Object parent, Invocation parentInvocation, ) : super( @@ -538,14 +538,6 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i10.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_7( - this, - Invocation.getter(#db), - ), - ) as _i10.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -863,14 +855,6 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI { returnValue: 0, ) as int); @override - _i10.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_7( - this, - Invocation.getter(#isarInstance), - ), - ) as _i10.Isar); - @override _i18.Future> prepareSend({ required String? address, required int? satoshiAmount, @@ -1049,15 +1033,15 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i11.TransactionNotificationTracker get txTracker => (super.noSuchMethod( + _i10.TransactionNotificationTracker get txTracker => (super.noSuchMethod( Invocation.getter(#txTracker), - returnValue: _FakeTransactionNotificationTracker_8( + returnValue: _FakeTransactionNotificationTracker_7( this, Invocation.getter(#txTracker), ), - ) as _i11.TransactionNotificationTracker); + ) as _i10.TransactionNotificationTracker); @override - set txTracker(_i11.TransactionNotificationTracker? _txTracker) => + set txTracker(_i10.TransactionNotificationTracker? _txTracker) => super.noSuchMethod( Invocation.setter( #txTracker, @@ -1194,21 +1178,21 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: false, ) as bool); @override - _i12.ElectrumX get electrumXClient => (super.noSuchMethod( + _i11.ElectrumX get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumX_9( + returnValue: _FakeElectrumX_8( this, Invocation.getter(#electrumXClient), ), - ) as _i12.ElectrumX); + ) as _i11.ElectrumX); @override - _i13.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( + _i12.CachedElectrumX get cachedElectrumXClient => (super.noSuchMethod( Invocation.getter(#cachedElectrumXClient), - returnValue: _FakeCachedElectrumX_10( + returnValue: _FakeCachedElectrumX_9( this, Invocation.getter(#cachedElectrumXClient), ), - ) as _i13.CachedElectrumX); + ) as _i12.CachedElectrumX); @override bool get isRefreshing => (super.noSuchMethod( Invocation.getter(#isRefreshing), @@ -1257,14 +1241,6 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { _i18.Future>.value(<_i21.Transaction>[]), ) as _i18.Future>); @override - _i10.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_7( - this, - Invocation.getter(#isarInstance), - ), - ) as _i10.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -1274,13 +1250,13 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i10.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_7( + _i13.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_10( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i10.Isar); + ) as _i13.IDB); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( @@ -1762,7 +1738,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { ) as _i18.Future>>); @override _i18.Future> getJMintTransactions( - _i13.CachedElectrumX? cachedClient, + _i12.CachedElectrumX? cachedClient, List? transactions, _i17.Coin? coin, ) => @@ -1922,31 +1898,29 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: _i18.Future.value(), ) as _i18.Future); @override - _i18.Future isarInit(String? walletId) => (super.noSuchMethod( + _i18.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); - @override - _i18.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i18.Future.value(false), - ) as _i18.Future); + returnValue: _i18.Future.value(), + returnValueForMissingStub: _i18.Future.value(), + ) as _i18.Future); @override _i18.Future addNewTransactionData( - List< - _i15.Tuple4<_i21.Transaction, List<_i21.Output>, - List<_i21.Input>, _i21.Address?>>? - transactionsData) => + List< + _i15.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, + _i21.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i18.Future.value(), returnValueForMissingStub: _i18.Future.value(), diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index ac666d17c..7fa2ae018 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -8,7 +8,6 @@ import 'dart:ui' as _i17; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; @@ -18,6 +17,7 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i21; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -132,8 +132,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { - _FakeIsar_9( +class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { + _FakeIDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -567,14 +567,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { ), ) as _i11.Balance); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -584,13 +576,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_9( + _i12.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_9( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i12.Isar); + ) as _i12.IDB); @override _i15.Future exit() => (super.noSuchMethod( Invocation.method( @@ -1104,31 +1096,29 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: _i15.Future.value(), ) as _i15.Future); @override - _i15.Future isarInit(String? walletId) => (super.noSuchMethod( + _i15.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); - @override - _i15.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i15.Future.value(false), - ) as _i15.Future); + returnValue: _i15.Future.value(), + returnValueForMissingStub: _i15.Future.value(), + ) as _i15.Future); @override _i15.Future addNewTransactionData( - List< - _i20.Tuple4<_i19.Transaction, List<_i19.Output>, - List<_i19.Input>, _i19.Address?>>? - transactionsData) => + List< + _i20.Tuple4<_i19.Transaction, List<_i19.Output>, List<_i19.Input>, + _i19.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i15.Future.value(), returnValueForMissingStub: _i15.Future.value(), 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 5b897ada5..b939e96d8 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 @@ -8,7 +8,6 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; @@ -19,6 +18,7 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -135,8 +135,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { - _FakeIsar_9( +class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { + _FakeIDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -818,14 +818,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), ) as _i11.Balance); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -835,13 +827,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_9( + _i12.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_9( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i12.Isar); + ) as _i12.IDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( @@ -1355,31 +1347,29 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); - @override - _i17.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override _i17.Future addNewTransactionData( - List< - _i22.Tuple4<_i21.Transaction, List<_i21.Output>, - List<_i21.Input>, _i21.Address?>>? - transactionsData) => + List< + _i22.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, + _i21.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), @@ -1723,14 +1713,6 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i12.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#db), - ), - ) as _i12.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2044,14 +2026,6 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, 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 9cbc74ac1..488bdcb8c 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 @@ -8,7 +8,6 @@ import 'dart:ui' as _i19; import 'package:flutter/foundation.dart' as _i4; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; -import 'package:isar/isar.dart' as _i12; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; @@ -19,6 +18,7 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -135,8 +135,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIsar_9 extends _i1.SmartFake implements _i12.Isar { - _FakeIsar_9( +class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { + _FakeIDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -818,14 +818,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), ) as _i11.Balance); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override set onIsActiveWalletChanged(void Function(bool)? _onIsActiveWalletChanged) => super.noSuchMethod( Invocation.setter( @@ -835,13 +827,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_9( + _i12.IDB get db => (super.noSuchMethod( + Invocation.getter(#db), + returnValue: _FakeIDB_9( this, - Invocation.getter(#isar), + Invocation.getter(#db), ), - ) as _i12.Isar); + ) as _i12.IDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( @@ -1355,31 +1347,29 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit(String? walletId) => (super.noSuchMethod( Invocation.method( #isarInit, [walletId], ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); - @override - _i17.Future isarClose() => (super.noSuchMethod( - Invocation.method( - #isarClose, - [], - ), - returnValue: _i17.Future.value(false), - ) as _i17.Future); + returnValue: _i17.Future.value(), + returnValueForMissingStub: _i17.Future.value(), + ) as _i17.Future); @override _i17.Future addNewTransactionData( - List< - _i22.Tuple4<_i21.Transaction, List<_i21.Output>, - List<_i21.Input>, _i21.Address?>>? - transactionsData) => + List< + _i22.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, + _i21.Address?>>? + transactionsData, + String? walletId, + ) => (super.noSuchMethod( Invocation.method( #addNewTransactionData, - [transactionsData], + [ + transactionsData, + walletId, + ], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), @@ -1723,14 +1713,6 @@ class MockManager extends _i1.Mock implements _i6.Manager { returnValue: 0, ) as int); @override - _i12.Isar get db => (super.noSuchMethod( - Invocation.getter(#db), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#db), - ), - ) as _i12.Isar); - @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), returnValue: false, @@ -2044,14 +2026,6 @@ class MockCoinServiceAPI extends _i1.Mock implements _i14.CoinServiceAPI { returnValue: 0, ) as int); @override - _i12.Isar get isarInstance => (super.noSuchMethod( - Invocation.getter(#isarInstance), - returnValue: _FakeIsar_9( - this, - Invocation.getter(#isarInstance), - ), - ) as _i12.Isar); - @override _i17.Future> prepareSend({ required String? address, required int? satoshiAmount, From d1f237ae51b78055b52bd8a0c2088f07ce4f4249 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 16:37:00 -0600 Subject: [PATCH 154/192] explicit isar model constructors --- lib/models/isar/models/address/address.dart | 11 + lib/models/isar/models/address/address.g.dart | 32 +-- .../isar/models/blockchain_data/input.dart | 11 + .../isar/models/blockchain_data/input.g.dart | 19 +- .../isar/models/blockchain_data/output.dart | 9 + .../isar/models/blockchain_data/output.g.dart | 15 +- .../models/blockchain_data/transaction.dart | 15 ++ .../models/blockchain_data/transaction.g.dart | 34 +-- .../isar/models/blockchain_data/utxo.dart | 14 ++ .../isar/models/blockchain_data/utxo.g.dart | 25 +- lib/models/isar/models/transaction_note.dart | 6 + .../isar/models/transaction_note.g.dart | 9 +- .../coins/bitcoin/bitcoin_wallet.dart | 59 ++--- .../coins/bitcoincash/bitcoincash_wallet.dart | 161 ++++++------- lib/services/coins/coin_paynym_extension.dart | 101 ++++---- .../coins/dogecoin/dogecoin_wallet.dart | 62 ++--- .../coins/epiccash/epiccash_wallet.dart | 40 ++-- lib/services/coins/firo/firo_wallet.dart | 215 ++++++++++-------- .../coins/litecoin/litecoin_wallet.dart | 59 ++--- lib/services/coins/monero/monero_wallet.dart | 53 +++-- .../coins/namecoin/namecoin_wallet.dart | 59 ++--- .../coins/particl/particl_wallet.dart | 141 ++++++------ .../coins/wownero/wownero_wallet.dart | 53 +++-- 23 files changed, 663 insertions(+), 540 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 184b3eed8..f8b0195ca 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -11,6 +11,15 @@ class AddressException extends SWException { @Collection(accessor: "addresses") class Address extends CryptoCurrencyAddress { + Address({ + required this.walletId, + required this.value, + required this.publicKey, + required this.derivationIndex, + required this.type, + required this.subType, + }); + Id id = Isar.autoIncrement; @Index() @@ -56,6 +65,7 @@ enum AddressType { p2sh, p2wpkh, cryptonote, + mimbleWimble, nonWallet, } @@ -65,5 +75,6 @@ enum AddressSubType { paynymNotification, paynymSend, paynymReceive, + unknown, nonWallet, } diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 5d237f37d..629881192 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -148,17 +148,17 @@ Address _addressDeserialize( List offsets, Map> allOffsets, ) { - final object = Address(); - object.derivationIndex = reader.readLong(offsets[0]); + final object = Address( + derivationIndex: reader.readLong(offsets[0]), + publicKey: reader.readByteList(offsets[1]) ?? [], + subType: _AddresssubTypeValueEnumMap[reader.readByteOrNull(offsets[2])] ?? + AddressSubType.receiving, + type: _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[3])] ?? + AddressType.p2pkh, + value: reader.readString(offsets[4]), + walletId: reader.readString(offsets[5]), + ); object.id = id; - object.publicKey = reader.readByteList(offsets[1]) ?? []; - object.subType = - _AddresssubTypeValueEnumMap[reader.readByteOrNull(offsets[2])] ?? - AddressSubType.receiving; - object.type = _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[3])] ?? - AddressType.p2pkh; - object.value = reader.readString(offsets[4]); - object.walletId = reader.readString(offsets[5]); return object; } @@ -194,7 +194,8 @@ const _AddresssubTypeEnumValueMap = { 'paynymNotification': 2, 'paynymSend': 3, 'paynymReceive': 4, - 'nonWallet': 5, + 'unknown': 5, + 'nonWallet': 6, }; const _AddresssubTypeValueEnumMap = { 0: AddressSubType.receiving, @@ -202,21 +203,24 @@ const _AddresssubTypeValueEnumMap = { 2: AddressSubType.paynymNotification, 3: AddressSubType.paynymSend, 4: AddressSubType.paynymReceive, - 5: AddressSubType.nonWallet, + 5: AddressSubType.unknown, + 6: AddressSubType.nonWallet, }; const _AddresstypeEnumValueMap = { 'p2pkh': 0, 'p2sh': 1, 'p2wpkh': 2, 'cryptonote': 3, - 'nonWallet': 4, + 'mimbleWimble': 4, + 'nonWallet': 5, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, 1: AddressType.p2sh, 2: AddressType.p2wpkh, 3: AddressType.cryptonote, - 4: AddressType.nonWallet, + 4: AddressType.mimbleWimble, + 5: AddressType.nonWallet, }; Id _addressGetId(Address object) { diff --git a/lib/models/isar/models/blockchain_data/input.dart b/lib/models/isar/models/blockchain_data/input.dart index 0843dce36..403cd48f1 100644 --- a/lib/models/isar/models/blockchain_data/input.dart +++ b/lib/models/isar/models/blockchain_data/input.dart @@ -6,6 +6,17 @@ part 'input.g.dart'; @Collection() class Input { + Input({ + required this.walletId, + required this.txid, + required this.vout, + required this.scriptSig, + required this.scriptSigAsm, + required this.isCoinbase, + required this.sequence, + required this.innerRedeemScriptAsm, + }); + Id id = Isar.autoIncrement; @Index() diff --git a/lib/models/isar/models/blockchain_data/input.g.dart b/lib/models/isar/models/blockchain_data/input.g.dart index 1279f0a2e..499538b42 100644 --- a/lib/models/isar/models/blockchain_data/input.g.dart +++ b/lib/models/isar/models/blockchain_data/input.g.dart @@ -151,16 +151,17 @@ Input _inputDeserialize( List offsets, Map> allOffsets, ) { - final object = Input(); + final object = Input( + innerRedeemScriptAsm: reader.readStringOrNull(offsets[0]), + isCoinbase: reader.readBoolOrNull(offsets[1]), + scriptSig: reader.readStringOrNull(offsets[2]), + scriptSigAsm: reader.readStringOrNull(offsets[3]), + sequence: reader.readLongOrNull(offsets[4]), + txid: reader.readString(offsets[5]), + vout: reader.readLong(offsets[6]), + walletId: reader.readString(offsets[7]), + ); object.id = id; - object.innerRedeemScriptAsm = reader.readStringOrNull(offsets[0]); - object.isCoinbase = reader.readBoolOrNull(offsets[1]); - object.scriptSig = reader.readStringOrNull(offsets[2]); - object.scriptSigAsm = reader.readStringOrNull(offsets[3]); - object.sequence = reader.readLongOrNull(offsets[4]); - object.txid = reader.readString(offsets[5]); - object.vout = reader.readLong(offsets[6]); - object.walletId = reader.readString(offsets[7]); return object; } diff --git a/lib/models/isar/models/blockchain_data/output.dart b/lib/models/isar/models/blockchain_data/output.dart index fe289f910..1b24fc39d 100644 --- a/lib/models/isar/models/blockchain_data/output.dart +++ b/lib/models/isar/models/blockchain_data/output.dart @@ -5,6 +5,15 @@ part 'output.g.dart'; @Collection() class Output { + Output({ + required this.walletId, + required this.scriptPubKey, + required this.scriptPubKeyAsm, + required this.scriptPubKeyType, + required this.scriptPubKeyAddress, + required this.value, + }); + Id id = Isar.autoIncrement; @Index() diff --git a/lib/models/isar/models/blockchain_data/output.g.dart b/lib/models/isar/models/blockchain_data/output.g.dart index c57015253..619ae04b8 100644 --- a/lib/models/isar/models/blockchain_data/output.g.dart +++ b/lib/models/isar/models/blockchain_data/output.g.dart @@ -133,14 +133,15 @@ Output _outputDeserialize( List offsets, Map> allOffsets, ) { - final object = Output(); + final object = Output( + scriptPubKey: reader.readStringOrNull(offsets[0]), + scriptPubKeyAddress: reader.readString(offsets[1]), + scriptPubKeyAsm: reader.readStringOrNull(offsets[2]), + scriptPubKeyType: reader.readStringOrNull(offsets[3]), + value: reader.readLong(offsets[4]), + walletId: reader.readString(offsets[5]), + ); object.id = id; - object.scriptPubKey = reader.readStringOrNull(offsets[0]); - object.scriptPubKeyAddress = reader.readString(offsets[1]); - object.scriptPubKeyAsm = reader.readStringOrNull(offsets[2]); - object.scriptPubKeyType = reader.readStringOrNull(offsets[3]); - object.value = reader.readLong(offsets[4]); - object.walletId = reader.readString(offsets[5]); return object; } diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 3c39e2fe6..c26a8b613 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -9,6 +9,21 @@ part 'transaction.g.dart'; @Collection() class Transaction { + Transaction({ + required this.walletId, + required this.txid, + required this.timestamp, + required this.type, + required this.subType, + required this.amount, + required this.fee, + required this.height, + required this.isCancelled, + required this.isLelantus, + required this.slateId, + required this.otherData, + }); + Id id = Isar.autoIncrement; @Index() diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 12b95b5df..167b85cd5 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -208,24 +208,24 @@ Transaction _transactionDeserialize( List offsets, Map> allOffsets, ) { - final object = Transaction(); - object.amount = reader.readLong(offsets[0]); - object.fee = reader.readLong(offsets[1]); - object.height = reader.readLongOrNull(offsets[2]); + final object = Transaction( + amount: reader.readLong(offsets[0]), + fee: reader.readLong(offsets[1]), + height: reader.readLongOrNull(offsets[2]), + isCancelled: reader.readBool(offsets[3]), + isLelantus: reader.readBoolOrNull(offsets[4]), + otherData: reader.readStringOrNull(offsets[5]), + slateId: reader.readStringOrNull(offsets[6]), + subType: + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ?? + TransactionSubType.none, + timestamp: reader.readLong(offsets[8]), + txid: reader.readString(offsets[9]), + type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ?? + TransactionType.outgoing, + walletId: reader.readString(offsets[11]), + ); object.id = id; - object.isCancelled = reader.readBool(offsets[3]); - object.isLelantus = reader.readBoolOrNull(offsets[4]); - object.otherData = reader.readStringOrNull(offsets[5]); - object.slateId = reader.readStringOrNull(offsets[6]); - object.subType = - _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ?? - TransactionSubType.none; - object.timestamp = reader.readLong(offsets[8]); - object.txid = reader.readString(offsets[9]); - object.type = - _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ?? - TransactionType.outgoing; - object.walletId = reader.readString(offsets[11]); return object; } diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index e89fce9d8..56f6c608f 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -6,6 +6,20 @@ part 'utxo.g.dart'; @Collection(accessor: "utxos") class UTXO { + UTXO({ + required this.walletId, + required this.txid, + required this.vout, + required this.value, + required this.name, + required this.isBlocked, + required this.blockedReason, + required this.isCoinbase, + required this.blockHash, + required this.blockHeight, + required this.blockTime, + }); + Id id = Isar.autoIncrement; @Index() diff --git a/lib/models/isar/models/blockchain_data/utxo.g.dart b/lib/models/isar/models/blockchain_data/utxo.g.dart index 24496eb88..f58f516fa 100644 --- a/lib/models/isar/models/blockchain_data/utxo.g.dart +++ b/lib/models/isar/models/blockchain_data/utxo.g.dart @@ -181,19 +181,20 @@ UTXO _uTXODeserialize( List offsets, Map> allOffsets, ) { - final object = UTXO(); - object.blockHash = reader.readStringOrNull(offsets[0]); - object.blockHeight = reader.readLongOrNull(offsets[1]); - object.blockTime = reader.readLongOrNull(offsets[2]); - object.blockedReason = reader.readStringOrNull(offsets[3]); + final object = UTXO( + blockHash: reader.readStringOrNull(offsets[0]), + blockHeight: reader.readLongOrNull(offsets[1]), + blockTime: reader.readLongOrNull(offsets[2]), + blockedReason: reader.readStringOrNull(offsets[3]), + isBlocked: reader.readBool(offsets[4]), + isCoinbase: reader.readBool(offsets[5]), + name: reader.readString(offsets[6]), + txid: reader.readString(offsets[7]), + value: reader.readLong(offsets[8]), + vout: reader.readLong(offsets[9]), + walletId: reader.readString(offsets[10]), + ); object.id = id; - object.isBlocked = reader.readBool(offsets[4]); - object.isCoinbase = reader.readBool(offsets[5]); - object.name = reader.readString(offsets[6]); - object.txid = reader.readString(offsets[7]); - object.value = reader.readLong(offsets[8]); - object.vout = reader.readLong(offsets[9]); - object.walletId = reader.readString(offsets[10]); return object; } diff --git a/lib/models/isar/models/transaction_note.dart b/lib/models/isar/models/transaction_note.dart index d383c16d2..a1e9e8d3f 100644 --- a/lib/models/isar/models/transaction_note.dart +++ b/lib/models/isar/models/transaction_note.dart @@ -4,6 +4,12 @@ part 'transaction_note.g.dart'; @Collection() class TransactionNote { + TransactionNote({ + required this.walletId, + required this.txid, + required this.value, + }); + Id id = Isar.autoIncrement; @Index() diff --git a/lib/models/isar/models/transaction_note.g.dart b/lib/models/isar/models/transaction_note.g.dart index 07db4d600..7bfe7d639 100644 --- a/lib/models/isar/models/transaction_note.g.dart +++ b/lib/models/isar/models/transaction_note.g.dart @@ -108,11 +108,12 @@ TransactionNote _transactionNoteDeserialize( List offsets, Map> allOffsets, ) { - final object = TransactionNote(); + final object = TransactionNote( + txid: reader.readString(offsets[0]), + value: reader.readString(offsets[1]), + walletId: reader.readString(offsets[2]), + ); object.id = id; - object.txid = reader.readString(offsets[0]); - object.value = reader.readString(offsets[1]); - object.walletId = reader.readString(offsets[2]); return object; } diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 32b48282e..ad72e1fb9 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -402,14 +402,16 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { throw Exception("No Path type $type exists"); } - final address = isar_models.Address() - ..subType = chain == 0 + final address = isar_models.Address( + walletId: walletId, + value: addressString, + publicKey: node.publicKey, + type: addrType, + derivationIndex: index + j, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = addrType - ..publicKey = node.publicKey - ..value = addressString - ..derivationIndex = index + j; + : isar_models.AddressSubType.change, + ); receivingNodes.addAll({ "${_id}_$j": { @@ -1507,14 +1509,16 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { derivePathType: derivePathType, ); - return isar_models.Address() - ..derivationIndex = index - ..value = address - ..publicKey = node.publicKey - ..type = addrType - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + value: address, + publicKey: node.publicKey, + type: addrType, + derivationIndex: index, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] @@ -1739,21 +1743,20 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO(); - - utxo.txid = txn["txid"] as String; - utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; - utxo.value = fetchedUtxoList[i][j]["value"] as int; - utxo.name = ""; - // todo check here if we should mark as blocked - utxo.isBlocked = false; - utxo.blockedReason = null; - - utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; - utxo.blockHash = txn["blockhash"] as String?; - utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; - utxo.blockTime = txn["blocktime"] as int?; + final utxo = isar_models.UTXO( + walletId: walletId, + txid: txn["txid"] as String, + vout: fetchedUtxoList[i][j]["tx_pos"] as int, + value: fetchedUtxoList[i][j]["value"] as int, + name: "", + isBlocked: false, + blockedReason: null, + isCoinbase: txn["is_coinbase"] as bool? ?? false, + blockHash: txn["blockhash"] as String?, + blockHeight: fetchedUtxoList[i][j]["height"] as int?, + blockTime: txn["blocktime"] as int?, + ); satoshiBalanceTotal += utxo.value; diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 41cbec46c..bcd0dbc19 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -387,15 +387,16 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { throw Exception("No Path type $type exists"); } - final address = isar_models.Address() - ..walletId = walletId - ..subType = chain == 0 + final address = isar_models.Address( + walletId: walletId, + value: addressString, + publicKey: node.publicKey, + type: addrType, + derivationIndex: index + j, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = addrType - ..publicKey = node.publicKey - ..value = addressString - ..derivationIndex = index + j; + : isar_models.AddressSubType.change, + ); receivingNodes.addAll({ "${_id}_$j": { @@ -1424,15 +1425,16 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { derivePathType: derivePathType, ); - return isar_models.Address() - ..walletId = walletId - ..derivationIndex = index - ..value = address - ..publicKey = node.publicKey - ..type = addrType - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + value: address, + publicKey: node.publicKey, + type: addrType, + derivationIndex: index, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] @@ -1615,21 +1617,20 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO()..walletId = walletId; - - utxo.txid = txn["txid"] as String; - utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; - utxo.value = fetchedUtxoList[i][j]["value"] as int; - utxo.name = ""; - // todo check here if we should mark as blocked - utxo.isBlocked = false; - utxo.blockedReason = null; - - utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; - utxo.blockHash = txn["blockhash"] as String?; - utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; - utxo.blockTime = txn["blocktime"] as int?; + final utxo = isar_models.UTXO( + walletId: walletId, + txid: txn["txid"] as String, + vout: fetchedUtxoList[i][j]["tx_pos"] as int, + value: fetchedUtxoList[i][j]["value"] as int, + name: "", + isBlocked: false, + blockedReason: null, + isCoinbase: txn["is_coinbase"] as bool? ?? false, + blockHash: txn["blockhash"] as String?, + blockHeight: fetchedUtxoList[i][j]["height"] as int?, + blockTime: txn["blocktime"] as int?, + ); satoshiBalanceTotal += utxo.value; @@ -2068,85 +2069,91 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final fee = totalInputValue - totalOutputValue; - final tx = isar_models.Transaction()..walletId = walletId; - tx.txid = txData["txid"] as String; - tx.timestamp = txData["blocktime"] as int? ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // this is the address initially used to fetch the txid isar_models.Address transactionAddress = txData["address"] as isar_models.Address; + isar_models.TransactionType type; + int amount; if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self - tx.type = isar_models.TransactionType.sentToSelf; - tx.amount = + type = isar_models.TransactionType.sentToSelf; + amount = amountSentFromWallet - amountReceivedInWallet - fee - changeAmount; } else if (mySentFromAddresses.isNotEmpty) { // outgoing tx - tx.type = isar_models.TransactionType.outgoing; - tx.amount = amountSentFromWallet - changeAmount - fee; + type = isar_models.TransactionType.outgoing; + amount = amountSentFromWallet - changeAmount - fee; final possible = outputAddresses.difference(myChangeReceivedOnAddresses).first; if (transactionAddress.value != possible) { - transactionAddress = isar_models.Address() - ..walletId = walletId - ..value = possible - ..derivationIndex = -1 - ..subType = AddressSubType.nonWallet - ..type = AddressType.nonWallet - ..publicKey = []; + transactionAddress = isar_models.Address( + walletId: walletId, + value: possible, + publicKey: [], + type: AddressType.nonWallet, + derivationIndex: -1, + subType: AddressSubType.nonWallet, + ); } } else { // incoming tx - tx.type = isar_models.TransactionType.incoming; - tx.amount = amountReceivedInWallet; + type = isar_models.TransactionType.incoming; + amount = amountReceivedInWallet; } - // TODO: other subtypes - tx.subType = isar_models.TransactionSubType.none; - - tx.fee = fee; + final tx = isar_models.Transaction( + walletId: walletId, + txid: txData["txid"] as String, + timestamp: txData["blocktime"] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000), + type: type, + subType: isar_models.TransactionSubType.none, + amount: amount, + fee: fee, + height: txData["height"] as int?, + isCancelled: false, + isLelantus: false, + slateId: null, + otherData: null, + ); List inputs = []; List outputs = []; for (final json in txData["vin"] as List) { bool isCoinBase = json['coinbase'] != null; - final input = isar_models.Input(); - input.txid = json['txid'] as String; - input.vout = json['vout'] as int? ?? -1; - input.scriptSig = json['scriptSig']?['hex'] as String?; - input.scriptSigAsm = json['scriptSig']?['asm'] as String?; - input.isCoinbase = - isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; - input.sequence = json['sequence'] as int?; - input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; + final input = isar_models.Input( + walletId: walletId, + txid: json['txid'] as String, + vout: json['vout'] as int? ?? -1, + scriptSig: json['scriptSig']?['hex'] as String?, + scriptSigAsm: json['scriptSig']?['asm'] as String?, + isCoinbase: isCoinBase ? isCoinBase : json['is_coinbase'] as bool?, + sequence: json['sequence'] as int?, + innerRedeemScriptAsm: json['innerRedeemscriptAsm'] as String?, + ); inputs.add(input); } for (final json in txData["vout"] as List) { - final output = isar_models.Output(); - output.scriptPubKey = json['scriptPubKey']?['hex'] as String?; - output.scriptPubKeyAsm = json['scriptPubKey']?['asm'] as String?; - output.scriptPubKeyType = json['scriptPubKey']?['type'] as String?; - output.scriptPubKeyAddress = - json["scriptPubKey"]?["addresses"]?[0] as String? ?? - json['scriptPubKey']['type'] as String; - output.value = Format.decimalAmountToSatoshis( - Decimal.parse(json["value"].toString()), - coin, + final output = isar_models.Output( + walletId: walletId, + scriptPubKey: json['scriptPubKey']?['hex'] as String?, + scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?, + scriptPubKeyType: json['scriptPubKey']?['type'] as String?, + scriptPubKeyAddress: + json["scriptPubKey"]?["addresses"]?[0] as String? ?? + json['scriptPubKey']['type'] as String, + value: Format.decimalAmountToSatoshis( + Decimal.parse(json["value"].toString()), + coin, + ), ); outputs.add(output); } - tx.height = txData["height"] as int?; - - tx.isCancelled = false; - tx.slateId = null; - tx.otherData = null; - txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } diff --git a/lib/services/coins/coin_paynym_extension.dart b/lib/services/coins/coin_paynym_extension.dart index c97b57776..a5e8a07d5 100644 --- a/lib/services/coins/coin_paynym_extension.dart +++ b/lib/services/coins/coin_paynym_extension.dart @@ -667,87 +667,90 @@ Future, List, Address>> final fee = totalInputValue - totalOutputValue; - final tx = Transaction()..walletId = walletId; - tx.txid = txData["txid"] as String; - tx.timestamp = txData["blocktime"] as int? ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000); - // this is the address initially used to fetch the txid Address transactionAddress = txData["address"] as Address; + TransactionType type; + int amount; if (mySentFromAddresses.isNotEmpty && myReceivedOnAddresses.isNotEmpty) { // tx is sent to self - tx.type = TransactionType.sentToSelf; + type = TransactionType.sentToSelf; // should be 0 - tx.amount = - amountSentFromWallet - amountReceivedInWallet - fee - changeAmount; + amount = amountSentFromWallet - amountReceivedInWallet - fee - changeAmount; } else if (mySentFromAddresses.isNotEmpty) { // outgoing tx - tx.type = TransactionType.outgoing; - tx.amount = amountSentFromWallet - changeAmount - fee; + type = TransactionType.outgoing; + amount = amountSentFromWallet - changeAmount - fee; final possible = outputAddresses.difference(myChangeReceivedOnAddresses).first; if (transactionAddress.value != possible) { - transactionAddress = Address() - ..walletId = walletId - ..value = possible - ..derivationIndex = -1 - ..subType = AddressSubType.nonWallet - ..type = AddressType.nonWallet - ..publicKey = []; + transactionAddress = Address( + walletId: walletId, + value: possible, + derivationIndex: -1, + subType: AddressSubType.nonWallet, + type: AddressType.nonWallet, + publicKey: [], + ); } } else { // incoming tx - tx.type = TransactionType.incoming; - tx.amount = amountReceivedInWallet; + type = TransactionType.incoming; + amount = amountReceivedInWallet; } - // TODO: other subtypes - tx.subType = TransactionSubType.none; - - tx.fee = fee; + final tx = Transaction( + walletId: walletId, + txid: txData["txid"] as String, + timestamp: txData["blocktime"] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000), + type: type, + subType: TransactionSubType.none, + amount: amount, + fee: fee, + height: txData["height"] as int?, + isCancelled: false, + isLelantus: false, + slateId: null, + otherData: null, + ); List outs = []; List ins = []; for (final json in txData["vin"] as List) { bool isCoinBase = json['coinbase'] != null; - final input = Input()..walletId = walletId; - input.txid = json['txid'] as String; - input.vout = json['vout'] as int? ?? -1; - input.scriptSig = json['scriptSig']?['hex'] as String?; - input.scriptSigAsm = json['scriptSig']?['asm'] as String?; - input.isCoinbase = isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; - input.sequence = json['sequence'] as int?; - input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; + final input = Input( + walletId: walletId, + txid: json['txid'] as String, + vout: json['vout'] as int? ?? -1, + scriptSig: json['scriptSig']?['hex'] as String?, + scriptSigAsm: json['scriptSig']?['asm'] as String?, + isCoinbase: isCoinBase ? isCoinBase : json['is_coinbase'] as bool?, + sequence: json['sequence'] as int?, + innerRedeemScriptAsm: json['innerRedeemscriptAsm'] as String?, + ); ins.add(input); } for (final json in txData["vout"] as List) { - final output = Output()..walletId = walletId; - output.scriptPubKey = json['scriptPubKey']?['hex'] as String?; - output.scriptPubKeyAsm = json['scriptPubKey']?['asm'] as String?; - output.scriptPubKeyType = json['scriptPubKey']?['type'] as String?; - output.scriptPubKeyAddress = - json["scriptPubKey"]?["addresses"]?[0] as String? ?? - json['scriptPubKey']['type'] as String; - output.value = Format.decimalAmountToSatoshis( - Decimal.parse(json["value"].toString()), - coin, + final output = Output( + walletId: walletId, + scriptPubKey: json['scriptPubKey']?['hex'] as String?, + scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?, + scriptPubKeyType: json['scriptPubKey']?['type'] as String?, + scriptPubKeyAddress: json["scriptPubKey"]?["addresses"]?[0] as String? ?? + json['scriptPubKey']['type'] as String, + value: Format.decimalAmountToSatoshis( + Decimal.parse(json["value"].toString()), + coin, + ), ); outs.add(output); } - tx.height = txData["height"] as int?; - - //TODO: change these for epic (or other coins that need it) - tx.isCancelled = false; - tx.slateId = null; - tx.otherData = null; - tx.isLelantus = null; - return Tuple4(tx, outs, ins, transactionAddress); } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 42ad7f8ff..3f93b26df 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -354,15 +354,16 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { data: PaymentData(pubkey: node.publicKey), network: network) .data .address!; - address = isar_models.Address() - ..walletId = walletId - ..subType = chain == 0 + address = isar_models.Address( + walletId: walletId, + value: addressString, + publicKey: node.publicKey, + type: isar_models.AddressType.p2pkh, + derivationIndex: index + j, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = isar_models.AddressType.p2pkh - ..publicKey = node.publicKey - ..value = addressString - ..derivationIndex = index + j; + : isar_models.AddressSubType.change, + ); break; default: throw Exception("No Path type $type exists"); @@ -1278,16 +1279,16 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { wif: node.toWIF(), derivePathType: derivePathType, ); - - return isar_models.Address() - ..walletId = walletId - ..derivationIndex = index - ..value = address - ..publicKey = node.publicKey - ..type = isar_models.AddressType.p2pkh - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + value: address, + publicKey: node.publicKey, + type: isar_models.AddressType.p2pkh, + derivationIndex: index, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] @@ -1494,21 +1495,20 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO()..walletId = walletId; - - utxo.txid = txn["txid"] as String; - utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; - utxo.value = fetchedUtxoList[i][j]["value"] as int; - utxo.name = ""; - // todo check here if we should mark as blocked - utxo.isBlocked = false; - utxo.blockedReason = null; - - utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; - utxo.blockHash = txn["blockhash"] as String?; - utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; - utxo.blockTime = txn["blocktime"] as int?; + final utxo = isar_models.UTXO( + walletId: walletId, + txid: txn["txid"] as String, + vout: fetchedUtxoList[i][j]["tx_pos"] as int, + value: fetchedUtxoList[i][j]["value"] as int, + name: "", + isBlocked: false, + blockedReason: null, + isCoinbase: txn["is_coinbase"] as bool? ?? false, + blockHash: txn["blockhash"] as String?, + blockHeight: fetchedUtxoList[i][j]["height"] as int?, + blockTime: txn["blocktime"] as int?, + ); satoshiBalanceTotal += utxo.value; diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index adeaf592e..bf98ddcb8 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -2025,30 +2025,31 @@ class EpicCashWallet extends CoinServiceAPI DateTime dt = DateTime.parse(tx["creation_ts"] as String); - final txn = isar_models.Transaction(); - txn.type = (tx["tx_type"] == "TxReceived" || - tx["tx_type"] == "TxReceivedCancelled") - ? isar_models.TransactionType.incoming - : isar_models.TransactionType.outgoing; - String? slateId = tx['tx_slate_id'] as String?; - String? address = slatesToCommits[slateId] + String address = slatesToCommits[slateId] ?[tx["tx_type"] == "TxReceived" ? "from" : "to"] as String? ?? ""; String? commitId = slatesToCommits[slateId]?['commitId'] as String?; - Logging.instance.log( - "commitId: $commitId, slateId: $slateId, id: ${tx["id"]}", - level: LogLevel.Info); - bool isCancelled = tx["tx_type"] == "TxSentCancelled" || - tx["tx_type"] == "TxReceivedCancelled"; + final txn = isar_models.Transaction( + walletId: walletId, + txid: commitId ?? tx["id"].toString(), + timestamp: (dt.millisecondsSinceEpoch ~/ 1000), + type: (tx["tx_type"] == "TxReceived" || + tx["tx_type"] == "TxReceivedCancelled") + ? isar_models.TransactionType.incoming + : isar_models.TransactionType.outgoing, + subType: isar_models.TransactionSubType.none, + amount: amt, + fee: (tx["fee"] == null) ? 0 : int.parse(tx["fee"] as String), + height: txHeight, + isCancelled: tx["tx_type"] == "TxSentCancelled" || + tx["tx_type"] == "TxReceivedCancelled", + isLelantus: false, + slateId: slateId, + otherData: tx["id"].toString(), + ); - txn.slateId = slateId; - txn.isCancelled = isCancelled; - txn.txid = commitId ?? tx["id"].toString(); - txn.timestamp = (dt.millisecondsSinceEpoch ~/ 1000); - txn.amount = amt; - txn.fee = (tx["fee"] == null) ? 0 : int.parse(tx["fee"] as String); // txn.address = // ""; // for this when you send a transaction you will just need to save in a hashmap in hive with the key being the txid, and the value being the address it was sent to. then you can look this value up right here in your hashmap. txn.address.value = await db @@ -2056,7 +2057,6 @@ class EpicCashWallet extends CoinServiceAPI .filter() .valueEqualTo(address) .findFirst(); - txn.height = txHeight; // // midSortedTx["inputSize"] = tx["num_inputs"]; @@ -2068,8 +2068,6 @@ class EpicCashWallet extends CoinServiceAPI // key id not used afaik? // midSortedTx["key_id"] = tx["parent_key_id"]; - txn.otherData = tx["id"].toString(); - // if (txHeight >= latestTxnBlockHeight) { // latestTxnBlockHeight = txHeight; // } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index cb875fac1..f5f27e56e 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -417,20 +417,23 @@ Future> staticProcessRestore( int mintFee = tx.fee; int sharedFee = mintFee ~/ inputs.length; for (var element in inputs) { - editedTransactions[element.txid] = isar_models.Transaction() - ..txid = element.txid - ..timestamp = element.timestamp - ..type = element.type - ..amount = element.amount - ..fee = sharedFee + editedTransactions[element.txid] = isar_models.Transaction( + walletId: element.walletId, + txid: element.txid, + timestamp: element.timestamp, + type: element.type, + subType: isar_models.TransactionSubType.mint, + amount: element.amount, + fee: sharedFee, + height: element.height, + isCancelled: false, + isLelantus: true, + slateId: null, + otherData: txid, + ) ..inputs.addAll(element.inputs) ..outputs.addAll(element.outputs) - ..address.value = element.address.value - ..height = element.height - ..subType = isar_models.TransactionSubType.mint - ..otherData = txid - ..isLelantus = true - ..isCancelled = false; + ..address.value = element.address.value; } }); } @@ -2947,31 +2950,39 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { await firoUpdateLelantusCoins(coins); // add the send transaction - final transaction = isar_models.Transaction() - ..txid = transactionInfo['txid'] as String - ..timestamp = transactionInfo['timestamp'] as int? ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000) - ..type = transactionInfo['txType'] == "Received" + final transaction = isar_models.Transaction( + walletId: walletId, + txid: transactionInfo['txid'] as String, + timestamp: transactionInfo['timestamp'] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000), + type: transactionInfo['txType'] == "Received" ? isar_models.TransactionType.incoming - : isar_models.TransactionType.outgoing - ..amount = Format.decimalAmountToSatoshis( - Decimal.parse(transactionInfo["amount"].toString()), coin) - ..fee = Format.decimalAmountToSatoshis( - Decimal.parse(transactionInfo["fees"].toString()), coin) - ..address.value = await db - .getAddresses(walletId) - .filter() - .valueEqualTo(transactionInfo["address"] as String) - .findFirst() - ..height = transactionInfo["height"] as int? - ..subType = transactionInfo["subType"] == "mint" + : isar_models.TransactionType.outgoing, + subType: transactionInfo["subType"] == "mint" ? isar_models.TransactionSubType.mint : transactionInfo["subType"] == "join" ? isar_models.TransactionSubType.join - : isar_models.TransactionSubType.none - ..otherData = transactionInfo["otherData"] as String? - ..isLelantus = true - ..isCancelled = false; + : isar_models.TransactionSubType.none, + amount: Format.decimalAmountToSatoshis( + Decimal.parse(transactionInfo["amount"].toString()), + coin, + ), + fee: Format.decimalAmountToSatoshis( + Decimal.parse(transactionInfo["fees"].toString()), + coin, + ), + height: transactionInfo["height"] as int?, + isCancelled: false, + isLelantus: true, + slateId: null, + otherData: transactionInfo["otherData"] as String?, + ); + + transaction.address.value = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(transactionInfo["address"] as String) + .findFirst(); await db.putTransaction(transaction); @@ -3344,21 +3355,20 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { coin: coin, ); - final utxo = isar_models.UTXO(); - - utxo.txid = txn["txid"] as String; - utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; - utxo.value = fetchedUtxoList[i][j]["value"] as int; - utxo.name = ""; - // todo check here if we should mark as blocked - utxo.isBlocked = false; - utxo.blockedReason = null; - - utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; - utxo.blockHash = txn["blockhash"] as String?; - utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; - utxo.blockTime = txn["blocktime"] as int?; + final utxo = isar_models.UTXO( + walletId: walletId, + txid: txn["txid"] as String, + vout: fetchedUtxoList[i][j]["tx_pos"] as int, + value: fetchedUtxoList[i][j]["value"] as int, + name: "", + isBlocked: false, + blockedReason: null, + isCoinbase: txn["is_coinbase"] as bool? ?? false, + blockHash: txn["blockhash"] as String?, + blockHeight: fetchedUtxoList[i][j]["height"] as int?, + blockTime: txn["blocktime"] as int?, + ); satoshiBalanceTotal += utxo.value; @@ -3507,15 +3517,17 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { level: LogLevel.Info); return _generateAddressForChain(chain, index); } - return isar_models.Address() - ..value = derivations["$index"]['address'] as String - ..publicKey = Format.stringToUint8List( - derivations["$index"]['publicKey'] as String) - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + value: derivations["$index"]['address'] as String, + publicKey: Format.stringToUint8List( + derivations["$index"]['publicKey'] as String), + type: isar_models.AddressType.p2pkh, + derivationIndex: index, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = isar_models.AddressType.p2pkh - ..derivationIndex = index; + : isar_models.AddressSubType.change, + ); } else { final node = await compute( getBip32NodeWrapper, Tuple4(chain, index, mnemonic!, _network)); @@ -3524,14 +3536,16 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { .data .address!; - return isar_models.Address() - ..value = address - ..publicKey = node.publicKey - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + value: address, + publicKey: node.publicKey, + type: isar_models.AddressType.p2pkh, + derivationIndex: index, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = isar_models.AddressType.p2pkh - ..derivationIndex = index; + : isar_models.AddressSubType.change, + ); } } @@ -3921,13 +3935,15 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { int numTxs = await futureNumTxs; if (numTxs >= 1) { receivingIndex = i; - final addr = isar_models.Address() - ..value = address - ..type = isar_models.AddressType.p2pkh - ..subType = isar_models.AddressSubType.receiving - ..derivationIndex = i - ..publicKey = Format.stringToUint8List( - receiveDerivation['publicKey'] as String); + final addr = isar_models.Address( + walletId: walletId, + value: address, + publicKey: Format.stringToUint8List( + receiveDerivation['publicKey'] as String), + type: isar_models.AddressType.p2pkh, + derivationIndex: i, + subType: isar_models.AddressSubType.receiving, + ); receivingAddressArray.add(addr); } else if (numTxs == 0) { receivingGapCounter += 1; @@ -3945,13 +3961,15 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { int numTxs = await _futureNumTxs; if (numTxs >= 1) { changeIndex = i; - final addr = isar_models.Address() - ..value = address - ..type = isar_models.AddressType.p2pkh - ..subType = isar_models.AddressSubType.change - ..derivationIndex = i - ..publicKey = Format.stringToUint8List( - changeDerivation['publicKey'] as String); + final addr = isar_models.Address( + walletId: walletId, + value: address, + publicKey: Format.stringToUint8List( + changeDerivation['publicKey'] as String), + type: isar_models.AddressType.p2pkh, + derivationIndex: i, + subType: isar_models.AddressSubType.change, + ); changeAddressArray.add(addr); } else if (numTxs == 0) { changeGapCounter += 1; @@ -4475,24 +4493,33 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { tx["address"] = tx["vout"][sendIndex]["scriptPubKey"]["addresses"][0]; tx["fees"] = tx["vin"][0]["nFees"]; - final txn = isar_models.Transaction() - ..isLelantus = true - ..txid = tx["txid"] as String - ..timestamp = tx["time"] as int? ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000) - ..type = isar_models.TransactionType.outgoing - ..subType = isar_models.TransactionSubType.join - ..fee = Format.decimalAmountToSatoshis( - Decimal.parse(tx["fees"].toString()), coin) - ..address.value = await db - .getAddresses(walletId) - .filter() - .valueEqualTo(tx["address"] as String) - .findFirst() - ..amount = Format.decimalAmountToSatoshis( - Decimal.parse(tx["amount"].toString()), coin) - ..isCancelled = false - ..height = tx["height"] as int?; + final txn = isar_models.Transaction( + walletId: walletId, + txid: tx["txid"] as String, + timestamp: tx["time"] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000), + type: isar_models.TransactionType.outgoing, + subType: isar_models.TransactionSubType.join, + amount: Format.decimalAmountToSatoshis( + Decimal.parse(tx["amount"].toString()), + coin, + ), + fee: Format.decimalAmountToSatoshis( + Decimal.parse(tx["fees"].toString()), + coin, + ), + height: tx["height"] as int?, + isCancelled: false, + isLelantus: true, + slateId: null, + otherData: null, + ); + + txn.address.value = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(tx["address"] as String) + .findFirst(); txs.add(txn); } catch (e, s) { diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 14aa517ee..8a6728f40 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -419,14 +419,16 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { throw Exception("No Path type $type exists"); } - final address = isar_models.Address() - ..subType = chain == 0 + final address = isar_models.Address( + walletId: walletId, + value: addressString, + publicKey: node.publicKey, + type: addrType, + derivationIndex: index + j, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = addrType - ..publicKey = node.publicKey - ..value = addressString - ..derivationIndex = index + j; + : isar_models.AddressSubType.change, + ); receivingNodes.addAll({ "${_id}_$j": { @@ -1533,14 +1535,16 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { derivePathType: derivePathType, ); - return isar_models.Address() - ..derivationIndex = index - ..value = address - ..publicKey = node.publicKey - ..type = addrType - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + value: address, + publicKey: node.publicKey, + type: addrType, + derivationIndex: index, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] @@ -1728,21 +1732,20 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO(); - - utxo.txid = txn["txid"] as String; - utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; - utxo.value = fetchedUtxoList[i][j]["value"] as int; - utxo.name = ""; - // todo check here if we should mark as blocked - utxo.isBlocked = false; - utxo.blockedReason = null; - - utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; - utxo.blockHash = txn["blockhash"] as String?; - utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; - utxo.blockTime = txn["blocktime"] as int?; + final utxo = isar_models.UTXO( + walletId: walletId, + txid: txn["txid"] as String, + vout: fetchedUtxoList[i][j]["tx_pos"] as int, + value: fetchedUtxoList[i][j]["value"] as int, + name: "", + isBlocked: false, + blockedReason: null, + isCoinbase: txn["is_coinbase"] as bool? ?? false, + blockHash: txn["blockhash"] as String?, + blockHeight: fetchedUtxoList[i][j]["height"] as int?, + blockTime: txn["blocktime"] as int?, + ); satoshiBalanceTotal += utxo.value; diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index cc936e141..0483a8eca 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -807,14 +807,16 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // String address = walletBase!.getTransactionAddress(chain, index); - return isar_models.Address() - ..derivationIndex = index - ..value = address - ..publicKey = [] - ..type = isar_models.AddressType.cryptonote - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + derivationIndex: index, + value: address, + publicKey: [], + type: isar_models.AddressType.cryptonote, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } Future _getFees() async { @@ -861,12 +863,8 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // " ${tx.value.keyIndex}", // level: LogLevel.Info); - final int txHeight = tx.value.height ?? 0; - final txn = isar_models.Transaction(); - txn.txid = tx.value.id; - txn.timestamp = (tx.value.date.millisecondsSinceEpoch ~/ 1000); - isar_models.Address? address; + isar_models.TransactionType type; if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; @@ -883,25 +881,26 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { .findFirst(); } - txn.type = isar_models.TransactionType.incoming; + type = isar_models.TransactionType.incoming; } else { // txn.address = ""; - txn.type = isar_models.TransactionType.outgoing; + type = isar_models.TransactionType.outgoing; } - txn.amount = tx.value.amount ?? 0; - - // TODO: other subtypes - txn.subType = isar_models.TransactionSubType.none; - - txn.fee = tx.value.fee ?? 0; - - txn.height = txHeight; - - txn.isCancelled = false; - txn.isLelantus = null; - txn.slateId = null; - txn.otherData = null; + final txn = isar_models.Transaction( + walletId: walletId, + txid: tx.value.id, + timestamp: (tx.value.date.millisecondsSinceEpoch ~/ 1000), + type: type, + subType: isar_models.TransactionSubType.none, + amount: tx.value.amount ?? 0, + fee: tx.value.fee ?? 0, + height: tx.value.height, + isCancelled: false, + isLelantus: false, + slateId: null, + otherData: null, + ); txnsData.add(Tuple4(txn, [], [], address)); } diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index b1d76f465..9e63f6502 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -409,14 +409,16 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { throw Exception("No Path type $type exists"); } - final address = isar_models.Address() - ..subType = chain == 0 + final address = isar_models.Address( + walletId: walletId, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = addrType - ..publicKey = node.publicKey - ..value = addressString - ..derivationIndex = index + j; + : isar_models.AddressSubType.change, + type: addrType, + publicKey: node.publicKey, + value: addressString, + derivationIndex: index + j, + ); receivingNodes.addAll({ "${_id}_$j": { @@ -1510,14 +1512,16 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { derivePathType: derivePathType, ); - return isar_models.Address() - ..derivationIndex = index - ..value = address - ..publicKey = node.publicKey - ..type = addrType - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + derivationIndex: index, + value: address, + publicKey: node.publicKey, + type: addrType, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] @@ -1707,21 +1711,20 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO(); - - utxo.txid = txn["txid"] as String; - utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; - utxo.value = fetchedUtxoList[i][j]["value"] as int; - utxo.name = ""; - // todo check here if we should mark as blocked - utxo.isBlocked = false; - utxo.blockedReason = null; - - utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; - utxo.blockHash = txn["blockhash"] as String?; - utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; - utxo.blockTime = txn["blocktime"] as int?; + final utxo = isar_models.UTXO( + walletId: walletId, + txid: txn["txid"] as String, + vout: fetchedUtxoList[i][j]["tx_pos"] as int, + value: fetchedUtxoList[i][j]["value"] as int, + name: "", + isBlocked: false, + blockedReason: null, + isCoinbase: txn["is_coinbase"] as bool? ?? false, + blockHash: txn["blockhash"] as String?, + blockHeight: fetchedUtxoList[i][j]["height"] as int?, + blockTime: txn["blocktime"] as int?, + ); satoshiBalanceTotal += utxo.value; diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 56560712b..14edcd2dd 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -392,14 +392,16 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { throw Exception("No Path type $type exists"); } - final address = isar_models.Address() - ..subType = chain == 0 + final address = isar_models.Address( + walletId: walletId, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change - ..type = addrType - ..publicKey = node.publicKey - ..value = addressString - ..derivationIndex = index + j; + : isar_models.AddressSubType.change, + type: addrType, + publicKey: node.publicKey, + value: addressString, + derivationIndex: index + j, + ); receivingNodes.addAll({ "${_id}_$j": { @@ -1407,14 +1409,16 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { derivePathType: derivePathType, ); - return isar_models.Address() - ..derivationIndex = index - ..value = address - ..publicKey = node.publicKey - ..type = addrType - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + derivationIndex: index, + value: address, + publicKey: node.publicKey, + type: addrType, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] @@ -1597,21 +1601,20 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { coin: coin, ); - final utxo = isar_models.UTXO(); - - utxo.txid = txn["txid"] as String; - utxo.vout = fetchedUtxoList[i][j]["tx_pos"] as int; - utxo.value = fetchedUtxoList[i][j]["value"] as int; - utxo.name = ""; - // todo check here if we should mark as blocked - utxo.isBlocked = false; - utxo.blockedReason = null; - - utxo.isCoinbase = txn["is_coinbase"] as bool? ?? false; - utxo.blockHash = txn["blockhash"] as String?; - utxo.blockHeight = fetchedUtxoList[i][j]["height"] as int?; - utxo.blockTime = txn["blocktime"] as int?; + final utxo = isar_models.UTXO( + walletId: walletId, + txid: txn["txid"] as String, + vout: fetchedUtxoList[i][j]["tx_pos"] as int, + value: fetchedUtxoList[i][j]["value"] as int, + name: "", + isBlocked: false, + blockedReason: null, + isCoinbase: txn["is_coinbase"] as bool? ?? false, + blockHash: txn["blockhash"] as String?, + blockHeight: fetchedUtxoList[i][j]["height"] as int?, + blockTime: txn["blocktime"] as int?, + ); satoshiBalanceTotal += utxo.value; @@ -2231,25 +2234,32 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { midSortedTx["inputs"] = txObject["vin"]; midSortedTx["outputs"] = txObject["vout"]; - final int height = txObject["height"] as int; - // midSortedArray.add(midSortedTx); - final tx = isar_models.Transaction(); - tx.txid = midSortedTx["txid"] as String; - tx.timestamp = midSortedTx["timestamp"] as int; - + isar_models.TransactionType type; + int amount; if (foundInSenders) { - tx.type = isar_models.TransactionType.outgoing; - tx.amount = inputAmtSentFromWallet; + type = isar_models.TransactionType.outgoing; + amount = inputAmtSentFromWallet; } else { - tx.type = isar_models.TransactionType.incoming; - tx.amount = outputAmtAddressedToWallet; + type = isar_models.TransactionType.incoming; + amount = outputAmtAddressedToWallet; } - // TODO: other subtypes - tx.subType = isar_models.TransactionSubType.none; + final tx = isar_models.Transaction( + walletId: walletId, + txid: midSortedTx["txid"] as String, + timestamp: midSortedTx["timestamp"] as int, + type: type, + subType: isar_models.TransactionSubType.none, + amount: amount, + fee: fee, + height: txObject["height"] as int, + isCancelled: false, + isLelantus: false, + slateId: null, + otherData: null, + ); - tx.fee = fee; isar_models.Address? transactionAddress = midSortedTx["address"] as isar_models.Address?; @@ -2258,40 +2268,37 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { for (final json in midSortedTx["vin"] as List) { bool isCoinBase = json['coinbase'] != null; - final input = isar_models.Input(); - input.txid = json['txid'] as String? ?? ""; - input.vout = json['vout'] as int? ?? -1; - input.scriptSig = json['scriptSig']?['hex'] as String?; - input.scriptSigAsm = json['scriptSig']?['asm'] as String?; - input.isCoinbase = - isCoinBase ? isCoinBase : json['is_coinbase'] as bool?; - input.sequence = json['sequence'] as int?; - input.innerRedeemScriptAsm = json['innerRedeemscriptAsm'] as String?; + final input = isar_models.Input( + walletId: walletId, + txid: json['txid'] as String, + vout: json['vout'] as int? ?? -1, + scriptSig: json['scriptSig']?['hex'] as String?, + scriptSigAsm: json['scriptSig']?['asm'] as String?, + isCoinbase: isCoinBase ? isCoinBase : json['is_coinbase'] as bool?, + sequence: json['sequence'] as int?, + innerRedeemScriptAsm: json['innerRedeemscriptAsm'] as String?, + ); inputs.add(input); } for (final json in midSortedTx["vout"] as List) { - final output = isar_models.Output(); - output.scriptPubKey = json['scriptPubKey']?['hex'] as String?; - output.scriptPubKeyAsm = json['scriptPubKey']?['asm'] as String?; - output.scriptPubKeyType = json['scriptPubKey']?['type'] as String?; - output.scriptPubKeyAddress = - json["scriptPubKey"]?["addresses"]?[0] as String? ?? - json['scriptPubKey']?['type'] as String? ?? - ""; - output.value = Format.decimalAmountToSatoshis( - Decimal.tryParse(json["value"].toString()) ?? Decimal.zero, - coin, + final output = isar_models.Output( + walletId: walletId, + scriptPubKey: json['scriptPubKey']?['hex'] as String?, + scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?, + scriptPubKeyType: json['scriptPubKey']?['type'] as String?, + scriptPubKeyAddress: + json["scriptPubKey"]?["addresses"]?[0] as String? ?? + json['scriptPubKey']['type'] as String? ?? + "", + value: Format.decimalAmountToSatoshis( + Decimal.parse(json["value"].toString()), + coin, + ), ); outputs.add(output); } - tx.height = height; - - tx.isCancelled = false; - tx.slateId = null; - tx.otherData = null; - txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index cd78040d7..dc72f0c26 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -816,14 +816,16 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // String address = walletBase!.getTransactionAddress(chain, index); - return isar_models.Address() - ..derivationIndex = index - ..value = address - ..publicKey = [] - ..type = isar_models.AddressType.cryptonote - ..subType = chain == 0 + return isar_models.Address( + walletId: walletId, + derivationIndex: index, + value: address, + publicKey: [], + type: isar_models.AddressType.cryptonote, + subType: chain == 0 ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; + : isar_models.AddressSubType.change, + ); } Future _getFees() async { @@ -930,12 +932,8 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // midSortedTx["outputs"] = []; // midSortedArray.add(midSortedTx); - final int txHeight = tx.value.height ?? 0; - final txn = isar_models.Transaction(); - txn.txid = tx.value.id; - txn.timestamp = (tx.value.date.millisecondsSinceEpoch ~/ 1000); - isar_models.Address? address; + isar_models.TransactionType type; if (tx.value.direction == TransactionDirection.incoming) { final addressInfo = tx.value.additionalInfo; @@ -952,25 +950,26 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { .findFirst(); } - txn.type = isar_models.TransactionType.incoming; + type = isar_models.TransactionType.incoming; } else { // txn.address = ""; - txn.type = isar_models.TransactionType.outgoing; + type = isar_models.TransactionType.outgoing; } - txn.amount = tx.value.amount ?? 0; - - // TODO: other subtypes - txn.subType = isar_models.TransactionSubType.none; - - txn.fee = tx.value.fee ?? 0; - - txn.height = txHeight; - - txn.isCancelled = false; - txn.isLelantus = null; - txn.slateId = null; - txn.otherData = null; + final txn = isar_models.Transaction( + walletId: walletId, + txid: tx.value.id, + timestamp: (tx.value.date.millisecondsSinceEpoch ~/ 1000), + type: type, + subType: isar_models.TransactionSubType.none, + amount: tx.value.amount ?? 0, + fee: tx.value.fee ?? 0, + height: tx.value.height, + isCancelled: false, + isLelantus: false, + slateId: null, + otherData: null, + ); txnsData.add(Tuple4(txn, [], [], address)); } From 6ac6dc27243911205aadb71c764a5c5ae85b266e Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 16:37:12 -0600 Subject: [PATCH 155/192] build runner mocks --- test/pages/send_view/send_view_test.mocks.dart | 12 ++++++------ test/services/coins/manager_test.mocks.dart | 12 ++++++------ test/widget_tests/managed_favorite_test.mocks.dart | 12 ++++++------ .../table_view/table_view_row_test.mocks.dart | 12 ++++++------ test/widget_tests/transaction_card_test.mocks.dart | 12 ++++++------ test/widget_tests/wallet_card_test.mocks.dart | 12 ++++++------ .../wallet_info_row_balance_future_test.mocks.dart | 12 ++++++------ .../wallet_info_row/wallet_info_row_test.mocks.dart | 12 ++++++------ 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 4d7402aaf..9479bb190 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -9,6 +9,7 @@ import 'dart:ui' as _i19; 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/main_db.dart' as _i13; 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; @@ -21,7 +22,6 @@ import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i21; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i24; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i13; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i8; @@ -151,8 +151,8 @@ class _FakeBalance_9 extends _i1.SmartFake implements _i12.Balance { ); } -class _FakeIDB_10 extends _i1.SmartFake implements _i13.IDB { - _FakeIDB_10( +class _FakeMainDB_10 extends _i1.SmartFake implements _i13.MainDB { + _FakeMainDB_10( Object parent, Invocation parentInvocation, ) : super( @@ -1037,13 +1037,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i13.IDB get db => (super.noSuchMethod( + _i13.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_10( + returnValue: _FakeMainDB_10( this, Invocation.getter(#db), ), - ) as _i13.IDB); + ) as _i13.MainDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index cb02aa126..403e10555 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -7,6 +7,7 @@ import 'dart:async' as _i10; import 'package:decimal/decimal.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/db/main_db.dart' as _i7; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/models/balance.dart' as _i6; @@ -14,7 +15,6 @@ import 'package:stackwallet/models/isar/models/isar_models.dart' as _i12; import 'package:stackwallet/models/lelantus_coin.dart' as _i13; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i3; import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i9; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i7; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; @@ -83,8 +83,8 @@ class _FakeBalance_4 extends _i1.SmartFake implements _i6.Balance { ); } -class _FakeIDB_5 extends _i1.SmartFake implements _i7.IDB { - _FakeIDB_5( +class _FakeMainDB_5 extends _i1.SmartFake implements _i7.MainDB { + _FakeMainDB_5( Object parent, Invocation parentInvocation, ) : super( @@ -337,13 +337,13 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: null, ); @override - _i7.IDB get db => (super.noSuchMethod( + _i7.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_5( + returnValue: _FakeMainDB_5( this, Invocation.getter(#db), ), - ) as _i7.IDB); + ) as _i7.MainDB); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 31ab09dc3..90be31d3f 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -9,6 +9,7 @@ import 'dart:ui' as _i19; 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/main_db.dart' as _i12; 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; @@ -19,7 +20,6 @@ import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i23; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -136,8 +136,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { - _FakeIDB_9( +class _FakeMainDB_9 extends _i1.SmartFake implements _i12.MainDB { + _FakeMainDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -828,13 +828,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.IDB get db => (super.noSuchMethod( + _i12.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_9( + returnValue: _FakeMainDB_9( this, Invocation.getter(#db), ), - ) as _i12.IDB); + ) as _i12.MainDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( 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 8730e670d..2535d905e 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 @@ -9,6 +9,7 @@ import 'dart:ui' as _i18; 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/main_db.dart' as _i12; 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; @@ -17,7 +18,6 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i19; import 'package:stackwallet/services/coins/coin_service.dart' as _i13; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -132,8 +132,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { - _FakeIDB_9( +class _FakeMainDB_9 extends _i1.SmartFake implements _i12.MainDB { + _FakeMainDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -813,13 +813,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.IDB get db => (super.noSuchMethod( + _i12.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_9( + returnValue: _FakeMainDB_9( this, Invocation.getter(#db), ), - ) as _i12.IDB); + ) as _i12.MainDB); @override _i16.Future exit() => (super.noSuchMethod( Invocation.method( diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index f86713805..4c77114bc 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -10,6 +10,7 @@ import 'package:decimal/decimal.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/main_db.dart' as _i13; 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 _i9; @@ -21,7 +22,6 @@ import 'package:stackwallet/services/coins/coin_service.dart' as _i7; import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i22; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i23; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i13; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/notes_service.dart' as _i28; import 'package:stackwallet/services/price_service.dart' as _i27; @@ -151,8 +151,8 @@ class _FakeCachedElectrumX_9 extends _i1.SmartFake ); } -class _FakeIDB_10 extends _i1.SmartFake implements _i13.IDB { - _FakeIDB_10( +class _FakeMainDB_10 extends _i1.SmartFake implements _i13.MainDB { + _FakeMainDB_10( Object parent, Invocation parentInvocation, ) : super( @@ -1250,13 +1250,13 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i13.IDB get db => (super.noSuchMethod( + _i13.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_10( + returnValue: _FakeMainDB_10( this, Invocation.getter(#db), ), - ) as _i13.IDB); + ) as _i13.MainDB); @override bool validateAddress(String? address) => (super.noSuchMethod( Invocation.method( diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 7fa2ae018..3dd40d057 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -9,6 +9,7 @@ import 'dart:ui' as _i17; 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/main_db.dart' as _i12; 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; @@ -17,7 +18,6 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; import 'package:stackwallet/services/locale_service.dart' as _i21; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -132,8 +132,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { - _FakeIDB_9( +class _FakeMainDB_9 extends _i1.SmartFake implements _i12.MainDB { + _FakeMainDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -576,13 +576,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.IDB get db => (super.noSuchMethod( + _i12.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_9( + returnValue: _FakeMainDB_9( this, Invocation.getter(#db), ), - ) as _i12.IDB); + ) as _i12.MainDB); @override _i15.Future exit() => (super.noSuchMethod( Invocation.method( 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 b939e96d8..5cd61baef 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 @@ -9,6 +9,7 @@ import 'dart:ui' as _i19; 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/main_db.dart' as _i12; 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; @@ -18,7 +19,6 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -135,8 +135,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { - _FakeIDB_9( +class _FakeMainDB_9 extends _i1.SmartFake implements _i12.MainDB { + _FakeMainDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -827,13 +827,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.IDB get db => (super.noSuchMethod( + _i12.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_9( + returnValue: _FakeMainDB_9( this, Invocation.getter(#db), ), - ) as _i12.IDB); + ) as _i12.MainDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( 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 488bdcb8c..b42a0843e 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 @@ -9,6 +9,7 @@ import 'dart:ui' as _i19; 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/main_db.dart' as _i12; 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; @@ -18,7 +19,6 @@ import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/mixins/wallet_db.dart' as _i12; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -135,8 +135,8 @@ class _FakeBalance_8 extends _i1.SmartFake implements _i11.Balance { ); } -class _FakeIDB_9 extends _i1.SmartFake implements _i12.IDB { - _FakeIDB_9( +class _FakeMainDB_9 extends _i1.SmartFake implements _i12.MainDB { + _FakeMainDB_9( Object parent, Invocation parentInvocation, ) : super( @@ -827,13 +827,13 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i12.IDB get db => (super.noSuchMethod( + _i12.MainDB get db => (super.noSuchMethod( Invocation.getter(#db), - returnValue: _FakeIDB_9( + returnValue: _FakeMainDB_9( this, Invocation.getter(#db), ), - ) as _i12.IDB); + ) as _i12.MainDB); @override _i17.Future exit() => (super.noSuchMethod( Invocation.method( From 203cd126787a0c75f429b79f47d0a73b5bef60a7 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 16:56:24 -0600 Subject: [PATCH 156/192] epic bugfix --- lib/services/coins/epiccash/epiccash_wallet.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index bf98ddcb8..375f8de10 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -1055,6 +1055,7 @@ class EpicCashWallet extends CoinServiceAPI await Future.wait([ epicUpdateRestoreHeight(bufferedCreateHeight), updateCachedIsFavorite(false), + updateCachedId(walletId), epicUpdateReceivingIndex(0), epicUpdateChangeIndex(0), ]); From 880c82ba7292c721d1e13df4366290eee0bbebbd Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 17:00:32 -0600 Subject: [PATCH 157/192] update delete wallet function to handle wallet isar data --- lib/services/wallets_service.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/services/wallets_service.dart b/lib/services/wallets_service.dart index 7bb37d2a6..41bfd477f 100644 --- a/lib/services/wallets_service.dart +++ b/lib/services/wallets_service.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_libmonero/monero/monero.dart'; import 'package:flutter_libmonero/wownero/wownero.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'; import 'package:stackwallet/services/notifications_service.dart'; @@ -385,6 +386,9 @@ class WalletsService extends ChangeNotifier { level: LogLevel.Info); } + // delete wallet data in main db + await MainDB.instance.deleteWalletBlockchainData(walletId); + // box data may currently still be read/written to if wallet was refreshing // when delete was requested so instead of deleting now we mark the wallet // as needs delete by adding it's id to a list which gets checked on app start From 90870c7563fe2c0c285d4f3982e08f261ebd896d Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Jan 2023 17:17:35 -0600 Subject: [PATCH 158/192] wallet delete ui bugfix for desktop --- lib/db/main_db.dart | 22 +++++++++---------- .../my_stack_view/coin_wallets_table.dart | 1 + .../my_stack_view/wallet_summary_table.dart | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/db/main_db.dart b/lib/db/main_db.dart index 1e8c710d3..be6a98089 100644 --- a/lib/db/main_db.dart +++ b/lib/db/main_db.dart @@ -110,13 +110,17 @@ class MainDB { // Future deleteWalletBlockchainData(String walletId) async { + final transactionCount = await getTransactions(walletId).count(); + final addressCount = await getAddresses(walletId).count(); + final utxoCount = await getUTXOs(walletId).count(); + final inputCount = await getInputs(walletId).count(); + final outputCount = await getOutputs(walletId).count(); + await isar.writeTxn(() async { const paginateLimit = 50; // transactions - for (int i = 0; - i < getTransactions(walletId).countSync(); - i += paginateLimit) { + for (int i = 0; i < transactionCount; i += paginateLimit) { final txns = await getTransactions(walletId) .offset(i) .limit(paginateLimit) @@ -126,9 +130,7 @@ class MainDB { } // addresses - for (int i = 0; - i < getAddresses(walletId).countSync(); - i += paginateLimit) { + for (int i = 0; i < addressCount; i += paginateLimit) { final addresses = await getAddresses(walletId) .offset(i) .limit(paginateLimit) @@ -138,7 +140,7 @@ class MainDB { } // utxos - for (int i = 0; i < getUTXOs(walletId).countSync(); i += paginateLimit) { + for (int i = 0; i < utxoCount; i += paginateLimit) { final utxos = await getUTXOs(walletId).offset(i).limit(paginateLimit).findAll(); await isar.utxos @@ -146,7 +148,7 @@ class MainDB { } // inputs - for (int i = 0; i < getInputs(walletId).countSync(); i += paginateLimit) { + for (int i = 0; i < inputCount; i += paginateLimit) { final inputs = await getInputs(walletId).offset(i).limit(paginateLimit).findAll(); await isar.inputs @@ -154,9 +156,7 @@ class MainDB { } // outputs - for (int i = 0; - i < getOutputs(walletId).countSync(); - i += paginateLimit) { + for (int i = 0; i < outputCount; i += paginateLimit) { final outputs = await getOutputs(walletId).offset(i).limit(paginateLimit).findAll(); await isar.outputs diff --git a/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart b/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart index 073ea73b4..c61708c70 100644 --- a/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart +++ b/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart @@ -40,6 +40,7 @@ class CoinWalletsTable extends ConsumerWidget { children: [ for (int i = 0; i < walletIds.length; i++) Column( + key: Key("${coin.name}_$runtimeType${walletIds[i]}_key"), children: [ if (i != 0) const SizedBox( diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart b/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart index 40a72f6e0..d638b3d04 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart @@ -37,6 +37,7 @@ class _WalletTableState extends ConsumerState { rows: [ for (int i = 0; i < providersByCoin.length; i++) Builder( + key: Key("${providersByCoin[i].key.name}_${runtimeType}_key"), builder: (context) { final providers = ref.watch(walletsChangeNotifierProvider.select( (value) => value From b348761bbea4e3c353913f8599ad6b979617fb7a Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Jan 2023 08:04:30 -0600 Subject: [PATCH 159/192] bch cashaddr fix --- lib/services/coins/bitcoincash/bitcoincash_wallet.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index bcd0dbc19..cd22c893a 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -373,6 +373,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { case DerivePathType.bip44: addressString = P2PKH(data: data, network: _network).data.address!; addrType = isar_models.AddressType.p2pkh; + addressString = bitbox.Address.toCashAddress(addressString); break; case DerivePathType.bip49: addressString = P2SH( @@ -1401,6 +1402,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { case DerivePathType.bip44: address = P2PKH(data: data, network: _network).data.address!; addrType = isar_models.AddressType.p2pkh; + address = bitbox.Address.toCashAddress(address); break; case DerivePathType.bip49: address = P2SH( From 38453ceafbdfaed863e8b1521b792d7760c6cc69 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Jan 2023 08:19:30 -0600 Subject: [PATCH 160/192] delete old derivations when doing full rescan --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 15 +++++++++++++++ .../coins/bitcoincash/bitcoincash_wallet.dart | 11 +++++++++++ lib/services/coins/dogecoin/dogecoin_wallet.dart | 7 +++++++ lib/services/coins/firo/firo_wallet.dart | 7 +++++++ lib/services/coins/litecoin/litecoin_wallet.dart | 15 +++++++++++++++ lib/services/coins/namecoin/namecoin_wallet.dart | 15 +++++++++++++++ lib/services/coins/particl/particl_wallet.dart | 11 +++++++++++ 7 files changed, 81 insertions(+) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index ad72e1fb9..e5a500a40 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2740,6 +2740,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // await _rescanBackup(); await db.deleteWalletBlockchainData(walletId); + await _deleteDerivations(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2892,6 +2893,20 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // Logging.instance.log("rescan backup complete", level: LogLevel.Info); // } + Future _deleteDerivations() async { + // P2PKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + + // P2SH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); + + // P2WPKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + } + bool isActive = false; @override diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index cd22c893a..df1fe4128 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2812,6 +2812,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { // clear blockchain info await db.deleteWalletBlockchainData(walletId); + await _deleteDerivations(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2846,6 +2847,16 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } } + Future _deleteDerivations() async { + // P2PKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + + // P2SH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); + } + @override set isFavorite(bool markFavorite) { _isFavorite = markFavorite; diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 3f93b26df..4ce4fe1f6 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -2439,6 +2439,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // clear blockchain info await db.deleteWalletBlockchainData(walletId); + await _deleteDerivations(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2476,6 +2477,12 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } + Future _deleteDerivations() async { + // P2PKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + } + // Future _rescanRestore() async { // Logging.instance.log("starting rescan restore", level: LogLevel.Info); // diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index f5f27e56e..c43b243e3 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3616,6 +3616,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { // clear blockchain info await db.deleteWalletBlockchainData(walletId); + await _deleteDerivations(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -3649,6 +3650,12 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } } + Future _deleteDerivations() async { + // P2PKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivations"); + await _secureStore.delete(key: "${walletId}_changeDerivations"); + } + // Future _rescanBackup() async { // Logging.instance.log("starting rescan backup", level: LogLevel.Info); // diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 8a6728f40..62b7c4232 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2828,6 +2828,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // clear blockchain info await db.deleteWalletBlockchainData(walletId); + await _deleteDerivations(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2865,6 +2866,20 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } + Future _deleteDerivations() async { + // P2PKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + + // P2SH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); + + // P2WPKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + } + // Future _rescanRestore() async { // Logging.instance.log("starting rescan restore", level: LogLevel.Info); // diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 9e63f6502..2995ea441 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2817,6 +2817,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { // clear blockchain info await db.deleteWalletBlockchainData(walletId); + await _deleteDerivations(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2854,6 +2855,20 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } } + Future _deleteDerivations() async { + // P2PKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + + // P2SH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2SH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2SH"); + + // P2WPKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + } + // Future _rescanRestore() async { // Logging.instance.log("starting rescan restore", level: LogLevel.Info); // diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 14edcd2dd..964b5ce17 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -2904,6 +2904,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { // await _rescanBackup(); await db.deleteWalletBlockchainData(walletId); + await _deleteDerivations(); try { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); @@ -2941,6 +2942,16 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } } + Future _deleteDerivations() async { + // P2PKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2PKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2PKH"); + + // P2WPKH derivations + await _secureStore.delete(key: "${walletId}_receiveDerivationsP2WPKH"); + await _secureStore.delete(key: "${walletId}_changeDerivationsP2WPKH"); + } + // Future _rescanRestore() async { // Logging.instance.log("starting rescan restore", level: LogLevel.Info); // From 9bb71b0e13ec87e8422d291ef9de6d95ff17980b Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Jan 2023 12:31:07 -0600 Subject: [PATCH 161/192] firo isar index and null address fix --- lib/services/coins/firo/firo_wallet.dart | 407 +++++++++++++++++++---- lib/widgets/transaction_card.dart | 3 +- 2 files changed, 337 insertions(+), 73 deletions(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index c43b243e3..9a587b12e 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -18,7 +18,6 @@ import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/lelantus_coin.dart'; import 'package:stackwallet/models/lelantus_fee_data.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/coins/coin_paynym_extension.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/refresh_percent_changed_event.dart'; @@ -103,28 +102,25 @@ Future executeNative(Map arguments) async { final subtractFeeFromAmount = arguments['subtractFeeFromAmount'] as bool; final mnemonic = arguments['mnemonic'] as String; final index = arguments['index'] as int; - final price = arguments['price'] as Decimal; final lelantusEntries = arguments['lelantusEntries'] as List; final coin = arguments['coin'] as Coin; final network = arguments['network'] as NetworkType?; final locktime = arguments['locktime'] as int; final anonymitySets = arguments['_anonymity_sets'] as List?; - final locale = arguments["locale"] as String; if (!(network == null || anonymitySets == null)) { var joinSplit = await isolateCreateJoinSplitTransaction( - spendAmount, - address, - subtractFeeFromAmount, - mnemonic, - index, - price, - lelantusEntries, - locktime, - coin, - network, - anonymitySets, - locale); + spendAmount, + address, + subtractFeeFromAmount, + mnemonic, + index, + lelantusEntries, + locktime, + coin, + network, + anonymitySets, + ); sendPort.send(joinSplit); return; } @@ -496,13 +492,11 @@ Future isolateCreateJoinSplitTransaction( bool subtractFeeFromAmount, String mnemonic, int index, - Decimal price, List lelantusEntries, int locktime, Coin coin, NetworkType _network, List> anonymitySetsArg, - String locale, ) async { final estimateJoinSplitFee = await isolateEstimateJoinSplitFee( spendAmount, subtractFeeFromAmount, lelantusEntries, coin); @@ -647,12 +641,6 @@ Future isolateCreateJoinSplitTransaction( "confirmed_status": false, "amount": Format.satoshisToAmount(amount, coin: coin).toDouble(), "recipientAmt": amount, - "worthNow": Format.localizedStringAsFixed( - value: ((Decimal.fromInt(amount) * price) / - Decimal.fromInt(Constants.satsPerCoin(coin))) - .toDecimal(scaleOnInfinitePrecision: 2), - decimalPlaces: 2, - locale: locale), "address": address, "timestamp": DateTime.now().millisecondsSinceEpoch ~/ 1000, "subType": "join", @@ -869,11 +857,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { // _transactionData = Future(() => cachedTxData!); } - /// Holds wallet lelantus transaction data - Future> get lelantusTransactionData => - db.getTransactions(walletId).filter().isLelantusEqualTo(true).findAll(); - // _lelantusTransactionData ??= _getLelantusTransactionData(); - /// Holds the max fee that can be sent Future? _maxFee; @override @@ -2302,7 +2285,11 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } final jindexes = firoGetJIndex(); final transactions = await _txnData; - final lelantusTransactionsd = await lelantusTransactionData; + final lelantusTransactionsd = await db + .getTransactions(walletId) + .filter() + .isLelantusEqualTo(true) + .findAll(); List coins = []; @@ -2369,7 +2356,11 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { element.values.any((elementCoin) => elementCoin.value == 0)); } final data = await _txnData; - final lData = await lelantusTransactionData; + final lData = await db + .getTransactions(walletId) + .filter() + .isLelantusEqualTo(true) + .findAll(); final currentChainHeight = await chainHeight; final jindexes = firoGetJIndex(); int intLelantusBalance = 0; @@ -2771,7 +2762,11 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { // Get all joinsplit transaction ids - final listLelantusTxData = await lelantusTransactionData; + final listLelantusTxData = await db + .getTransactions(walletId) + .filter() + .isLelantusEqualTo(true) + .findAll(); List joinsplits = []; for (final tx in listLelantusTxData) { if (tx.subType == isar_models.TransactionSubType.join) { @@ -2790,6 +2785,12 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } } + Map> data = + {}; + for (final entry in listLelantusTxData) { + data[entry.txid] = Tuple2(entry.address.value, entry); + } + // Grab the most recent information on all the joinsplits final updatedJSplit = await getJMintTransactions( @@ -2801,26 +2802,29 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final currentChainHeight = await chainHeight; // update all of joinsplits that are now confirmed. - for (final tx in updatedJSplit) { + for (final tx in updatedJSplit.entries) { isar_models.Transaction? currentTx; try { - currentTx = listLelantusTxData.firstWhere((e) => e.txid == tx.txid); + currentTx = + listLelantusTxData.firstWhere((e) => e.txid == tx.value.txid); } catch (_) { currentTx = null; } if (currentTx == null) { // this send was accidentally not included in the list - tx.isLelantus = true; - listLelantusTxData.add(tx); + tx.value.isLelantus = true; + data[tx.value.txid] = + Tuple2(tx.value.address.value ?? tx.key, tx.value); + continue; } if (currentTx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS) != - tx.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { - listLelantusTxData.removeWhere((e) => e.txid == tx.txid); - tx.isLelantus = true; - listLelantusTxData.add(tx); + tx.value.isConfirmed(currentChainHeight, MINIMUM_CONFIRMATIONS)) { + tx.value.isLelantus = true; + data[tx.value.txid] = + Tuple2(tx.value.address.value ?? tx.key, tx.value); } } @@ -2844,19 +2848,31 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { if (value.type == isar_models.TransactionType.incoming && value.subType != isar_models.TransactionSubType.mint) { // Every receive other than a mint should be shown. Mints will be collected and shown from the send side - listLelantusTxData.removeWhere((e) => e.txid == value.txid); value.isLelantus = true; - listLelantusTxData.add(value); + data[value.txid] = Tuple2(value.address.value, value); } else if (value.type == isar_models.TransactionType.outgoing) { // all sends should be shown, mints will be displayed correctly in the ui - listLelantusTxData.removeWhere((e) => e.txid == value.txid); value.isLelantus = true; - listLelantusTxData.add(value); + data[value.txid] = Tuple2(value.address.value, value); } } // TODO: optimize this whole lelantus process - await db.putTransactions(listLelantusTxData); + + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; + + for (final value in data.values) { + final transactionAddress = value.item1!; + final outs = + value.item2.outputs.where((_) => true).toList(growable: false); + final ins = value.item2.inputs.where((_) => true).toList(growable: false); + + txnsData.add(Tuple4(value.item2, outs, ins, transactionAddress)); + } + + await addNewTransactionData(txnsData, walletId); // // update the _lelantusTransactionData // final models.TransactionData newTxData = @@ -2978,13 +2994,27 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { otherData: transactionInfo["otherData"] as String?, ); - transaction.address.value = await db - .getAddresses(walletId) - .filter() - .valueEqualTo(transactionInfo["address"] as String) - .findFirst(); + final transactionAddress = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(transactionInfo["address"] as String) + .findFirst() ?? + isar_models.Address( + walletId: walletId, + value: transactionInfo["address"] as String, + derivationIndex: -1, + type: isar_models.AddressType.nonWallet, + subType: isar_models.AddressSubType.nonWallet, + publicKey: [], + ); - await db.putTransaction(transaction); + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; + + txnsData.add(Tuple4(transaction, [], [], transactionAddress)); + + await addNewTransactionData(txnsData, walletId); // final models.TransactionData newTxData = // models.TransactionData.fromMap(transactions); @@ -3290,17 +3320,209 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Tuple4, List, isar_models.Address?>> txnsData = []; + Set changeAddresses = allAddresses + .where((e) => e.subType == isar_models.AddressSubType.change) + .map((e) => e.value) + .toSet(); + for (final txObject in allTransactions) { - final data = await parseTransaction( - txObject, - cachedElectrumXClient, - allAddresses, - coin, - MINIMUM_CONFIRMATIONS, - walletId, + // Logging.instance.log(txObject); + List sendersArray = []; + List recipientsArray = []; + + // Usually only has value when txType = 'Send' + int inputAmtSentFromWallet = 0; + // Usually has value regardless of txType due to change addresses + int outputAmtAddressedToWallet = 0; + + for (final input in txObject["vin"] as List) { + final address = input["address"] as String?; + if (address != null) { + sendersArray.add(address); + } + } + + // Logging.instance.log("sendersArray: $sendersArray"); + + for (final output in txObject["vout"] as List) { + final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? + output["scriptPubKey"]?["address"] as String?; + if (address != null) { + recipientsArray.add(address); + } + } + // Logging.instance.log("recipientsArray: $recipientsArray"); + + final foundInSenders = + allAddresses.any((element) => sendersArray.contains(element.value)); + // Logging.instance.log("foundInSenders: $foundInSenders"); + + String outAddress = ""; + + int fees = 0; + + // If txType = Sent, then calculate inputAmtSentFromWallet, calculate who received how much in aliens array (check outputs) + if (foundInSenders) { + int outAmount = 0; + int inAmount = 0; + bool nFeesUsed = false; + + for (final input in txObject["vin"] as List) { + final nFees = input["nFees"]; + if (nFees != null) { + nFeesUsed = true; + fees = (Decimal.parse(nFees.toString()) * + Decimal.fromInt(Constants.satsPerCoin(coin))) + .toBigInt() + .toInt(); + } + final address = input["address"] as String?; + final value = input["valueSat"] as int?; + if (address != null && value != null) { + if (allAddresses.where((e) => e.value == address).isNotEmpty) { + inputAmtSentFromWallet += value; + } + } + + if (value != null) { + inAmount += value; + } + } + + for (final output in txObject["vout"] as List) { + final address = output["scriptPubKey"]?["addresses"]?[0] as String? ?? + output["scriptPubKey"]?["address"] as String?; + final value = output["value"]; + + if (value != null) { + outAmount += (Decimal.parse(value.toString()) * + Decimal.fromInt(Constants.satsPerCoin(coin))) + .toBigInt() + .toInt(); + + if (address != null) { + if (changeAddresses.contains(address)) { + inputAmtSentFromWallet -= (Decimal.parse(value.toString()) * + Decimal.fromInt(Constants.satsPerCoin(coin))) + .toBigInt() + .toInt(); + } else { + outAddress = address; + } + } + } + } + + fees = nFeesUsed ? fees : inAmount - outAmount; + inputAmtSentFromWallet -= inAmount - outAmount; + } else { + for (final input in txObject["vin"] as List) { + final nFees = input["nFees"]; + if (nFees != null) { + fees += (Decimal.parse(nFees.toString()) * + Decimal.fromInt(Constants.satsPerCoin(coin))) + .toBigInt() + .toInt(); + } + } + + for (final output in txObject["vout"] as List) { + final addresses = output["scriptPubKey"]["addresses"] as List?; + if (addresses != null && addresses.isNotEmpty) { + final address = addresses[0] as String; + final value = output["value"] ?? 0; + // Logging.instance.log(address + value.toString()); + + if (allAddresses.where((e) => e.value == address).isNotEmpty) { + outputAmtAddressedToWallet += (Decimal.parse(value.toString()) * + Decimal.fromInt(Constants.satsPerCoin(coin))) + .toBigInt() + .toInt(); + outAddress = address; + } + } + } + } + + isar_models.TransactionType type; + isar_models.TransactionSubType subType = + isar_models.TransactionSubType.none; + int amount; + if (foundInSenders) { + type = isar_models.TransactionType.outgoing; + amount = inputAmtSentFromWallet; + + if (txObject["vout"][0]["scriptPubKey"]["type"] == "lelantusmint") { + subType = isar_models.TransactionSubType.mint; + } + } else { + type = isar_models.TransactionType.incoming; + amount = outputAmtAddressedToWallet; + } + + final transactionAddress = + allAddresses.firstWhere((e) => e.value == outAddress, + orElse: () => isar_models.Address( + walletId: walletId, + value: outAddress, + derivationIndex: -1, + type: isar_models.AddressType.nonWallet, + subType: isar_models.AddressSubType.nonWallet, + publicKey: [], + )); + + final tx = isar_models.Transaction( + walletId: walletId, + txid: txObject["txid"] as String, + timestamp: txObject["blocktime"] as int? ?? + (DateTime.now().millisecondsSinceEpoch ~/ 1000), + type: type, + subType: subType, + amount: amount, + fee: fees, + height: txObject["height"] as int? ?? 0, + isCancelled: false, + isLelantus: false, + slateId: null, + otherData: null, ); - txnsData.add(data); + List outs = []; + List ins = []; + + for (final json in txObject["vin"] as List) { + bool isCoinBase = json['coinbase'] != null; + final input = isar_models.Input( + walletId: walletId, + txid: json['txid'] as String? ?? "", + vout: json['vout'] as int? ?? -1, + scriptSig: json['scriptSig']?['hex'] as String?, + scriptSigAsm: json['scriptSig']?['asm'] as String?, + isCoinbase: isCoinBase ? isCoinBase : json['is_coinbase'] as bool?, + sequence: json['sequence'] as int?, + innerRedeemScriptAsm: json['innerRedeemscriptAsm'] as String?, + ); + ins.add(input); + } + + for (final json in txObject["vout"] as List) { + final output = isar_models.Output( + walletId: walletId, + scriptPubKey: json['scriptPubKey']?['hex'] as String?, + scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?, + scriptPubKeyType: json['scriptPubKey']?['type'] as String?, + scriptPubKeyAddress: + json["scriptPubKey"]?["addresses"]?[0] as String? ?? + json['scriptPubKey']['type'] as String, + value: Format.decimalAmountToSatoshis( + Decimal.parse(json["value"].toString()), + coin, + ), + ); + outs.add(output); + } + + txnsData.add(Tuple4(tx, outs, ins, transactionAddress)); } await addNewTransactionData(txnsData, walletId); @@ -3970,7 +4192,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { changeIndex = i; final addr = isar_models.Address( walletId: walletId, - value: address, + value: _address, publicKey: Format.stringToUint8List( changeDerivation['publicKey'] as String), type: isar_models.AddressType.p2pkh, @@ -4046,7 +4268,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Future _restore(int latestSetId, Map setDataMap, dynamic usedSerialNumbers) async { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); - final dataFuture = _txnData; + final dataFuture = _refreshTransactions(); ReceivePort receivePort = await getIsolate({ "function": "restore", @@ -4069,7 +4291,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { stop(receivePort); final message = await staticProcessRestore( - (await dataFuture), + (await _txnData), result as Map, await chainHeight, ); @@ -4082,6 +4304,12 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final transactionMap = message["newTxMap"] as Map; + Map> data = + {}; + + for (final entry in transactionMap.entries) { + data[entry.key] = Tuple2(entry.value.address.value, entry.value); + } // Create the joinsplit transactions. final spendTxs = await getJMintTransactions( @@ -4090,11 +4318,37 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { coin, ); Logging.instance.log(spendTxs, level: LogLevel.Info); - for (var element in spendTxs) { - transactionMap[element.txid] = element; + + for (var element in spendTxs.entries) { + final address = element.value.address.value ?? + data[element.value.txid]?.item1 ?? + element.key; + // isar_models.Address( + // walletId: walletId, + // value: transactionInfo["address"] as String, + // derivationIndex: -1, + // type: isar_models.AddressType.nonWallet, + // subType: isar_models.AddressSubType.nonWallet, + // publicKey: [], + // ); + + data[element.value.txid] = Tuple2(address, element.value); } - await db.putTransactions(transactionMap.values.toList()); + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; + + for (final value in data.values) { + final transactionAddress = value.item1!; + final outs = + value.item2.outputs.where((_) => true).toList(growable: false); + final ins = value.item2.inputs.where((_) => true).toList(growable: false); + + txnsData.add(Tuple4(value.item2, outs, ins, transactionAddress)); + } + + await addNewTransactionData(txnsData, walletId); } Future>> fetchAnonymitySets() async { @@ -4474,7 +4728,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { return allTransactions; } - Future> getJMintTransactions( + Future> + getJMintTransactions( CachedElectrumX cachedClient, List transactions, // String currency, @@ -4483,7 +4738,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { // String locale, ) async { try { - List txs = []; + Map txs = {}; List> allTransactions = await fastFetch(transactions); @@ -4522,13 +4777,21 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { otherData: null, ); - txn.address.value = await db - .getAddresses(walletId) - .filter() - .valueEqualTo(tx["address"] as String) - .findFirst(); + final address = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(tx["address"] as String) + .findFirst() ?? + isar_models.Address( + walletId: walletId, + value: tx["address"] as String, + derivationIndex: -2, + type: isar_models.AddressType.nonWallet, + subType: isar_models.AddressSubType.unknown, + publicKey: [], + ); - txs.add(txn); + txs[address] = txn; } catch (e, s) { Logging.instance.log( "Exception caught in getJMintTransactions(): $e\n$s", diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index 6eb48e7da..031234142 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -49,7 +49,8 @@ class _TransactionCardState extends ConsumerState { coin.requiredConfirmations, ); - if (_transaction.subType == TransactionSubType.mint) { + if (type != TransactionType.incoming && + _transaction.subType == TransactionSubType.mint) { // if (type == "Received") { if (confirmedStatus) { return "Anonymized"; From 957b4cba9b010a59bc5e610e26debd700ed11ea1 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Jan 2023 16:10:45 -0600 Subject: [PATCH 162/192] widget key fix --- lib/pages/wallet_view/sub_widgets/transactions_list.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index 39d9dfc7a..71f56ccad 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -85,13 +85,16 @@ class _TransactionsListState extends ConsumerState { children: [ TransactionCard( // this may mess with combined firo transactions - key: Key(tx.toString()), // + key: Key(tx.txid + tx.type.name + tx.address.value.toString()), // transaction: tx, walletId: widget.walletId, ), TradeCard( // this may mess with combined firo transactions - key: Key(tx.toString() + trade.uuid), // + key: Key(tx.txid + + tx.type.name + + tx.address.value.toString() + + trade.uuid), // trade: trade, onTap: () async { if (Util.isDesktop) { @@ -177,7 +180,7 @@ class _TransactionsListState extends ConsumerState { ), child: TransactionCard( // this may mess with combined firo transactions - key: Key(tx.toString()), // + key: Key(tx.txid + tx.type.name + tx.address.value.toString()), // transaction: tx, walletId: widget.walletId, ), From ef9205a0a992c1cd75f476a347b9a4b4f78bf701 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Jan 2023 16:11:04 -0600 Subject: [PATCH 163/192] particl isar tx parse fixes --- .../coins/particl/particl_wallet.dart | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 964b5ce17..1dba3b144 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1994,11 +1994,11 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { ); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { - tx["address"] = await db + tx["address"] = (await db .getAddresses(walletId) .filter() .valueEqualTo(txHash["address"] as String) - .findFirst(); + .findFirst())!; tx["height"] = txHash["height"]; allTransactions.add(tx); } @@ -2053,7 +2053,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { for (final out in tx["vout"] as List) { if (prevOut == out["n"]) { - final address = out["scriptPubKey"]["addresses"][0] as String?; + final address = out["scriptPubKey"]?["address"] as String? ?? + out["scriptPubKey"]?["addresses"]?[0] as String?; if (address != null) { sendersArray.add(address); } @@ -2067,7 +2068,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { // Particl has different tx types that need to be detected and handled here if (output.containsKey('scriptPubKey') as bool) { // Logging.instance.log("output is transparent", level: LogLevel.Info); - final address = output["scriptPubKey"]["addresses"][0] as String?; + final address = output["scriptPubKey"]?["address"] as String? ?? + output["scriptPubKey"]?["addresses"]?[0] as String?; if (address != null) { recipientsArray.add(address); } @@ -2137,10 +2139,18 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } else { // change address from 'sent from' to the 'sent to' address txObject["address"] = await db - .getAddresses(walletId) - .filter() - .valueEqualTo(address) - .findFirst(); + .getAddresses(walletId) + .filter() + .valueEqualTo(address) + .findFirst() ?? + isar_models.Address( + walletId: walletId, + type: isar_models.AddressType.nonWallet, + subType: isar_models.AddressSubType.nonWallet, + value: address, + publicKey: [], + derivationIndex: -1, + ); } } catch (s) { Logging.instance.log(s.toString(), level: LogLevel.Warning); @@ -2186,14 +2196,15 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { // add up received tx value for (final output in txObject["vout"] as List) { try { - final address = output["scriptPubKey"]["addresses"][0]; + final address = output["scriptPubKey"]?["address"] as String? ?? + output["scriptPubKey"]?["addresses"]?[0] as String?; if (address != null) { - final value = (Decimal.parse(output["value"].toString()) * + final value = (Decimal.parse((output["value"] ?? 0).toString()) * Decimal.fromInt(Constants.satsPerCoin(coin))) .toBigInt() .toInt(); totalOut += value; - if (allAddresses.contains(address)) { + if (allAddresses.where((e) => e.value == address).isNotEmpty) { outputAmtAddressedToWallet += value; } } @@ -2214,7 +2225,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { for (final out in tx["vout"] as List) { if (prevOut == out["n"]) { - totalIn += (Decimal.parse(out["value"].toString()) * + totalIn += (Decimal.parse((out["value"] ?? 0).toString()) * Decimal.fromInt(Constants.satsPerCoin(coin))) .toBigInt() .toInt(); @@ -2260,13 +2271,13 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { otherData: null, ); - isar_models.Address? transactionAddress = - midSortedTx["address"] as isar_models.Address?; + isar_models.Address transactionAddress = + midSortedTx["address"] as isar_models.Address; List inputs = []; List outputs = []; - for (final json in midSortedTx["vin"] as List) { + for (final json in txObject["vin"] as List) { bool isCoinBase = json['coinbase'] != null; final input = isar_models.Input( walletId: walletId, @@ -2281,7 +2292,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { inputs.add(input); } - for (final json in midSortedTx["vout"] as List) { + for (final json in txObject["vout"] as List) { final output = isar_models.Output( walletId: walletId, scriptPubKey: json['scriptPubKey']?['hex'] as String?, @@ -2289,10 +2300,10 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { scriptPubKeyType: json['scriptPubKey']?['type'] as String?, scriptPubKeyAddress: json["scriptPubKey"]?["addresses"]?[0] as String? ?? - json['scriptPubKey']['type'] as String? ?? + json['scriptPubKey']?['type'] as String? ?? "", value: Format.decimalAmountToSatoshis( - Decimal.parse(json["value"].toString()), + Decimal.parse((json["value"] ?? 0).toString()), coin, ), ); From 505e8adad7cd0339a8c9b53750f672a774a17594 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Jan 2023 16:56:21 -0600 Subject: [PATCH 164/192] xmr isar tx sync fixes --- lib/services/coins/monero/monero_wallet.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 0483a8eca..538488bfa 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -163,7 +163,8 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { @override Future get currentReceivingAddress async => - (await _currentReceivingAddress)!.value; + (await _currentReceivingAddress)?.value ?? + (await _generateAddressForChain(0, 0)).value; @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { @@ -378,11 +379,11 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { await walletBase!.connectToNode( node: Node(uri: "$host:${node.port}", type: WalletType.monero)); await walletBase!.startSync(); - await DB.instance - .put(boxName: walletId, key: DBKeys.id, value: _walletId); - await DB.instance - .put(boxName: walletId, key: DBKeys.isFavorite, value: false); + await Future.wait([ + updateCachedId(walletId), + updateCachedIsFavorite(false), + ]); // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); @@ -1120,7 +1121,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Check the new receiving index final currentReceiving = await _currentReceivingAddress; - final curIndex = currentReceiving!.derivationIndex; + final curIndex = currentReceiving?.derivationIndex ?? -1; if (highestIndex >= curIndex) { // First increment the receiving index From 30635b05d5ee0226b00c36328383b43842148eb0 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Jan 2023 17:19:09 -0600 Subject: [PATCH 165/192] wow isar tx sync fixes --- lib/services/coins/wownero/wownero_wallet.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index dc72f0c26..f864d44e0 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -165,7 +165,8 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { @override Future get currentReceivingAddress async => - (await _currentReceivingAddress)!.value; + (await _currentReceivingAddress)?.value ?? + (await _generateAddressForChain(0, 0)).value; @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { @@ -1189,7 +1190,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Check the new receiving index final currentReceiving = await _currentReceivingAddress; - final curIndex = currentReceiving!.derivationIndex; + final curIndex = currentReceiving?.derivationIndex ?? -1; if (highestIndex >= curIndex) { // First increment the receiving index From cd4408449c74ca29b18330cad412164762a7a893 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 08:07:25 -0600 Subject: [PATCH 166/192] desktop db migrate enabled --- lib/main.dart | 4 +-- .../password/desktop_login_view.dart | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 304d3d8fb..6292c39ef 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -157,7 +157,7 @@ void main() async { await Hive.openBox(DB.boxNameDBInfo); - // todo: db migrate stuff for desktop needs to be handled eventually + // Desktop migrate handled elsewhere (currently desktop_login_view.dart) if (!Util.isDesktop) { int dbVersion = DB.instance.get( boxName: DB.boxNameDBInfo, key: "hive_data_version") as int? ?? @@ -172,7 +172,7 @@ void main() async { ), ); } catch (e, s) { - Logging.instance.log("Cannot migrate database\n$e $s", + Logging.instance.log("Cannot migrate mobile database\n$e $s", level: LogLevel.Error, printFullLength: true); } } diff --git a/lib/pages_desktop_specific/password/desktop_login_view.dart b/lib/pages_desktop_specific/password/desktop_login_view.dart index 713cb52c2..67eab0903 100644 --- a/lib/pages_desktop_specific/password/desktop_login_view.dart +++ b/lib/pages_desktop_specific/password/desktop_login_view.dart @@ -13,12 +13,17 @@ import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/loading_indicator.dart'; import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../hive/db.dart'; +import '../../utilities/db_version_migration.dart'; +import '../../utilities/logger.dart'; + class DesktopLoginView extends ConsumerStatefulWidget { const DesktopLoginView({ Key? key, @@ -43,6 +48,25 @@ class _DesktopLoginViewState extends ConsumerState { bool hidePassword = true; bool _continueEnabled = false; + Future _checkDesktopMigrate() async { + if (Util.isDesktop) { + int dbVersion = DB.instance.get( + boxName: DB.boxNameDBInfo, key: "hive_data_version") as int? ?? + 0; + if (dbVersion < Constants.currentHiveDbVersion) { + try { + await DbVersionMigrator().migrate( + dbVersion, + secureStore: ref.read(secureStoreProvider), + ); + } catch (e, s) { + Logging.instance.log("Cannot migrate desktop database\n$e $s", + level: LogLevel.Error, printFullLength: true); + } + } + } + } + Future login() async { try { unawaited( @@ -63,12 +87,18 @@ class _DesktopLoginViewState extends ConsumerState { await Future.delayed(const Duration(seconds: 1)); + // init security context await ref .read(storageCryptoHandlerProvider) .initFromExisting(passwordController.text); + // init desktop secure storage await (ref.read(secureStoreProvider).store as DesktopSecureStore).init(); + // check and migrate if needed + await _checkDesktopMigrate(); + + // load data await widget.load?.call(); // if no errors passphrase is correct From 719f70697aac9d8a8ae062d04f063517ded9ab1c Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 09:42:46 -0600 Subject: [PATCH 167/192] epic isar fixes --- .../coins/epiccash/epiccash_wallet.dart | 111 ++++++++++++------ 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 375f8de10..1480a4e02 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -657,8 +657,8 @@ class EpicCashWallet extends CoinServiceAPI int? currentReceivingIndex; for (int i = 0; i <= receivingIndex!; i++) { - final indexesAddress = await _getCurrentAddressForChain(i); - if (indexesAddress == sendersAddress) { + final indexesAddress = await _getReceivingAddressForIndex(i); + if (indexesAddress.value == sendersAddress) { currentReceivingIndex = i; break; } @@ -829,32 +829,52 @@ class EpicCashWallet extends CoinServiceAPI } } - /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] - /// and - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _getCurrentAddressForChain( - int chain, + Future _getReceivingAddressForIndex( + int index, ) async { - final wallet = await _secureStore.read(key: '${_walletId}_wallet'); - final epicboxConfig = - await _secureStore.read(key: '${_walletId}_epicboxConfig'); + isar_models.Address? address = await db + .getAddresses(walletId) + .filter() + .derivationIndexEqualTo(index) + .findFirst(); - String? walletAddress; - await m.protect(() async { - walletAddress = await compute( - _initGetAddressInfoWrapper, - Tuple3(wallet!, chain, epicboxConfig!), + if (address == null) { + final wallet = await _secureStore.read(key: '${_walletId}_wallet'); + final epicboxConfig = + await _secureStore.read(key: '${_walletId}_epicboxConfig'); + + String? walletAddress; + await m.protect(() async { + walletAddress = await compute( + _initGetAddressInfoWrapper, + Tuple3(wallet!, index, epicboxConfig!), + ); + }); + Logging.instance + .log("WALLET_ADDRESS_IS $walletAddress", level: LogLevel.Info); + + address = isar_models.Address( + walletId: walletId, + value: walletAddress!, + derivationIndex: index, + type: isar_models.AddressType.mimbleWimble, + subType: isar_models.AddressSubType.receiving, + publicKey: [], // ?? ); - }); - Logging.instance - .log("WALLET_ADDRESS_IS $walletAddress", level: LogLevel.Info); - return walletAddress!; + + await db.putAddress(address); + } + + return address; } @override - Future get currentReceivingAddress => - _currentReceivingAddress ??= _getCurrentAddressForChain(0); - Future? _currentReceivingAddress; + Future get currentReceivingAddress async => + (await _currentReceivingAddress)?.value ?? + (await _getReceivingAddressForIndex(0)).value; + + Future get _currentReceivingAddress => + db.getAddresses(walletId).sortByDerivationIndexDesc().findFirst(); @override Future exit() async { @@ -1059,6 +1079,11 @@ class EpicCashWallet extends CoinServiceAPI epicUpdateReceivingIndex(0), epicUpdateChangeIndex(0), ]); + + await isarInit(walletId); + final initialReceivingAddress = await _getReceivingAddressForIndex(0); + + await db.putAddress(initialReceivingAddress); } bool refreshMutex = false; @@ -1535,7 +1560,7 @@ class EpicCashWallet extends CoinServiceAPI receivingIndex != null && currentReceivingIndex <= receivingIndex; currentReceivingIndex++) { final currentAddress = - await _getCurrentAddressForChain(currentReceivingIndex); + await _getReceivingAddressForIndex(currentReceivingIndex); final wallet = await _secureStore.read(key: '${_walletId}_wallet'); final epicboxConfig = await _secureStore.read(key: '${_walletId}_epicboxConfig'); @@ -1564,7 +1589,7 @@ class EpicCashWallet extends CoinServiceAPI Logging.instance .log(subscribeRequest['signature'], level: LogLevel.Info); // final unprocessedSlates = await getSlates( - currentAddress, subscribeRequest['signature'] as String); + currentAddress.value, subscribeRequest['signature'] as String); if (unprocessedSlates == null || unprocessedSlates is! List) { Logging.instance.log( "index $currentReceivingIndex at ${await currentReceivingAddress} does not have any slates", @@ -1630,7 +1655,7 @@ class EpicCashWallet extends CoinServiceAPI if (response == "") { Logging.instance.log("response: ${response.runtimeType}", level: LogLevel.Info); - await deleteSlate(currentAddress, + await deleteSlate(currentAddress.value, subscribeRequest['signature'] as String, slate as String); } @@ -1639,7 +1664,7 @@ class EpicCashWallet extends CoinServiceAPI //Already processed - to be deleted Logging.instance .log("DELETING_PROCESSED_SLATE", level: LogLevel.Info); - final slateDelete = await deleteSlate(currentAddress, + final slateDelete = await deleteSlate(currentAddress.value, subscribeRequest['signature'] as String, slate as String); Logging.instance.log("DELETE_SLATE_RESPONSE $slateDelete", level: LogLevel.Info); @@ -1659,7 +1684,7 @@ class EpicCashWallet extends CoinServiceAPI final postSlateToServer = await postSlate(slateSender, encryptedSlate); - await deleteSlate(currentAddress, + await deleteSlate(currentAddress.value, subscribeRequest['signature'] as String, slate as String); Logging.instance.log("POST_SLATE_RESPONSE $postSlateToServer", level: LogLevel.Info); @@ -1676,7 +1701,7 @@ class EpicCashWallet extends CoinServiceAPI Logging.instance .log("TX_SLATE_ID_IS $txSlateId", level: LogLevel.Info); final postToNode = await postSlateToNode(wallet, txSlateId); - await deleteSlate(currentAddress, + await deleteSlate(currentAddress.value, subscribeRequest['signature'] as String, slate as String); Logging.instance.log("POST_SLATE_RESPONSE $postToNode", level: LogLevel.Info); @@ -1709,7 +1734,7 @@ class EpicCashWallet extends CoinServiceAPI receivingIndex != null && currentReceivingIndex <= receivingIndex; currentReceivingIndex++) { final receiveAddress = - await _getCurrentAddressForChain(currentReceivingIndex); + await _getReceivingAddressForIndex(currentReceivingIndex); dynamic subscribeRequest; await m.protect(() async { @@ -1733,7 +1758,7 @@ class EpicCashWallet extends CoinServiceAPI level: LogLevel.Info); }); String? signature = subscribeRequest['signature'] as String?; - final cancels = await getCancels(receiveAddress, signature!); + final cancels = await getCancels(receiveAddress.value, signature!); final slatesToCommits = await getSlatesToCommits(); for (final cancel in cancels as List) { @@ -1801,7 +1826,7 @@ class EpicCashWallet extends CoinServiceAPI } final int curAdd = await setCurrentIndex(); - _currentReceivingAddress = _getCurrentAddressForChain(curAdd); + await _getReceivingAddressForIndex(curAdd); if (!await startScans()) { refreshMutex = false; @@ -1990,7 +2015,9 @@ class EpicCashWallet extends CoinServiceAPI final String transactions = message['result'] as String; final jsonTransactions = json.decode(transactions) as List; - final List midSortedArray = []; + final List< + Tuple4, + List, isar_models.Address?>> txnsData = []; // int latestTxnBlockHeight = // DB.instance.get(boxName: walletId, key: "storedTxnDataHeight") @@ -2000,9 +2027,8 @@ class EpicCashWallet extends CoinServiceAPI for (var tx in jsonTransactions) { Logging.instance.log("tx: $tx", level: LogLevel.Info); - final txHeight = tx["kernel_lookup_min_height"] as int? ?? 0; // // TODO: does "confirmed" mean finalized? If so please remove this todo - // final isConfirmed = tx["confirmed"] as bool; + 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 @@ -2032,6 +2058,14 @@ class EpicCashWallet extends CoinServiceAPI ""; String? commitId = slatesToCommits[slateId]?['commitId'] as String?; + int? height; + + if (isConfirmed) { + height = tx["kernel_lookup_min_height"] as int? ?? 1; + } else { + height = null; + } + final txn = isar_models.Transaction( walletId: walletId, txid: commitId ?? tx["id"].toString(), @@ -2043,7 +2077,7 @@ class EpicCashWallet extends CoinServiceAPI subType: isar_models.TransactionSubType.none, amount: amt, fee: (tx["fee"] == null) ? 0 : int.parse(tx["fee"] as String), - height: txHeight, + height: height, isCancelled: tx["tx_type"] == "TxSentCancelled" || tx["tx_type"] == "TxReceivedCancelled", isLelantus: false, @@ -2053,12 +2087,11 @@ class EpicCashWallet extends CoinServiceAPI // txn.address = // ""; // for this when you send a transaction you will just need to save in a hashmap in hive with the key being the txid, and the value being the address it was sent to. then you can look this value up right here in your hashmap. - txn.address.value = await db + isar_models.Address? transactionAddress = await db .getAddresses(walletId) .filter() .valueEqualTo(address) .findFirst(); - // // midSortedTx["inputSize"] = tx["num_inputs"]; // midSortedTx["outputSize"] = tx["num_outputs"]; @@ -2073,13 +2106,13 @@ class EpicCashWallet extends CoinServiceAPI // latestTxnBlockHeight = txHeight; // } - midSortedArray.add(txn); + txnsData.add(Tuple4(txn, [], [], transactionAddress)); // cachedMap?.remove(tx["id"].toString()); // cachedMap?.remove(commitId); // Logging.instance.log("cmap: $cachedMap", level: LogLevel.Info); } - await db.putTransactions(midSortedArray); + await addNewTransactionData(txnsData, walletId); // midSortedArray // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); From 4dabeebfab2d7090b8ed8326e4fc8d2294c2a9d0 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 14:29:24 -0600 Subject: [PATCH 168/192] WIP migrate --- lib/models/isar/models/address/address.dart | 3 +- lib/utilities/constants.dart | 2 +- lib/utilities/db_version_migration.dart | 406 +++++++++++++++++++- 3 files changed, 397 insertions(+), 14 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index f8b0195ca..a21d991dd 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -31,7 +31,7 @@ class Address extends CryptoCurrencyAddress { late List publicKey; @Index() - late int derivationIndex; + late int derivationIndex; // -1 generally means unknown @enumerated late AddressType type; @@ -66,6 +66,7 @@ enum AddressType { p2wpkh, cryptonote, mimbleWimble, + unknown, nonWallet, } diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index 740e40c24..e78d7a76f 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -38,7 +38,7 @@ abstract class Constants { // Enable Logger.print statements static const bool disableLogger = false; - static const int currentHiveDbVersion = 4; + static const int currentHiveDbVersion = 5; static int satsPerCoin(Coin coin) { switch (coin) { diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index 57c53f385..4abe653bf 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -1,19 +1,25 @@ +import 'dart:convert'; + import 'package:hive/hive.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/lelantus_coin.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; +import 'package:stackwallet/models/models.dart'; import 'package:stackwallet/models/node_model.dart'; +import 'package:stackwallet/services/mixins/wallet_db.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/wallets_service.dart'; import 'package:stackwallet/utilities/default_nodes.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; +import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; +import 'package:tuple/tuple.dart'; -class DbVersionMigrator { +class DbVersionMigrator with WalletDB { Future migrate( int fromVersion, { required SecureStorageInterface secureStore, @@ -169,20 +175,396 @@ class DbVersionMigrator { // try to continue migrating return await migrate(4, secureStore: secureStore); - // case 4: - // // TODO: once isar migration is ready - // // 1. Address arrays - // - // // update version - // await DB.instance.put( - // boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 5); - // - // // try to continue migrating - // return await migrate(5, secureStore: secureStore); + case 4: + // migrate + await _v4(secureStore); + + // update version + await DB.instance.put( + boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 5); + + // try to continue migrating + return await migrate(5, secureStore: secureStore); default: // finally return return; } } + + Future _v4(SecureStorageInterface secureStore) async { + await Hive.openBox(DB.boxNameAllWalletsData); + await Hive.openBox(DB.boxNamePrefs); + final walletsService = WalletsService(secureStorageInterface: secureStore); + final prefs = Prefs.instance; + final walletInfoList = await walletsService.walletNames; + await prefs.init(); + + for (final walletId in walletInfoList.keys) { + final info = walletInfoList[walletId]!; + assert(info.walletId == walletId); + + final walletBox = await Hive.openBox(info.walletId); + + final receiveDerivePrefix = "${walletId}_receiveDerivations"; + final changeDerivePrefix = "${walletId}_changeDerivations"; + + const receiveAddressesPrefix = "receivingAddresses"; + const changeAddressesPrefix = "changeAddresses"; + + final p2pkhRcvDerivations = + (await secureStore.read(key: receiveDerivePrefix)) ?? + (await secureStore.read(key: "${receiveDerivePrefix}P2PKH")); + final p2shRcvDerivations = + await secureStore.read(key: "${receiveDerivePrefix}P2SH"); + final p2wpkhRcvDerivations = + await secureStore.read(key: "${receiveDerivePrefix}P2WPKH"); + + final p2pkhCngDerivations = + (await secureStore.read(key: changeDerivePrefix)) ?? + (await secureStore.read(key: "${changeDerivePrefix}P2PKH")); + final p2shCngDerivations = + await secureStore.read(key: "${changeDerivePrefix}P2SH"); + final p2wpkhCngDerivations = + await secureStore.read(key: "${changeDerivePrefix}P2WPKH"); + + // useless? + // const receiveIndexPrefix = "receivingIndex"; + // const changeIndexPrefix = "changeIndex"; + // final p2pkhRcvIndex = walletBox.get(receiveIndexPrefix) as int? ?? + // walletBox.get("${receiveIndexPrefix}P2PKH") as int?; + // final p2shRcvIndex = + // walletBox.get("${receiveIndexPrefix}P2SH") as int?; + // final p2wpkhRcvIndex = + // walletBox.get("${receiveIndexPrefix}P2WPKH") as int?; + // + // final p2pkhCngIndex = walletBox.get(changeIndexPrefix) as int? ?? + // walletBox.get("${changeIndexPrefix}P2PKH") as int?; + // final p2shCngIndex = + // walletBox.get("${changeIndexPrefix}P2SH") as int?; + // final p2wpkhCngIndex = + // walletBox.get("${changeIndexPrefix}P2WPKH") as int?; + + final List newAddresses = []; + + if (p2pkhRcvDerivations != null) { + newAddresses.addAll( + _v4GetAddressesFromDerivationString( + p2pkhRcvDerivations, + isar_models.AddressType.p2pkh, + isar_models.AddressSubType.receiving, + walletId, + ), + ); + } + + if (p2shRcvDerivations != null) { + newAddresses.addAll( + _v4GetAddressesFromDerivationString( + p2shRcvDerivations, + isar_models.AddressType.p2sh, + isar_models.AddressSubType.receiving, + walletId, + ), + ); + } + + if (p2wpkhRcvDerivations != null) { + newAddresses.addAll( + _v4GetAddressesFromDerivationString( + p2wpkhRcvDerivations, + isar_models.AddressType.p2wpkh, + isar_models.AddressSubType.receiving, + walletId, + ), + ); + } + + if (p2pkhCngDerivations != null) { + newAddresses.addAll( + _v4GetAddressesFromDerivationString( + p2pkhCngDerivations, + isar_models.AddressType.p2pkh, + isar_models.AddressSubType.change, + walletId, + ), + ); + } + + if (p2shCngDerivations != null) { + newAddresses.addAll( + _v4GetAddressesFromDerivationString( + p2shCngDerivations, + isar_models.AddressType.p2sh, + isar_models.AddressSubType.change, + walletId, + ), + ); + } + + if (p2wpkhCngDerivations != null) { + newAddresses.addAll( + _v4GetAddressesFromDerivationString( + p2wpkhCngDerivations, + isar_models.AddressType.p2wpkh, + isar_models.AddressSubType.change, + walletId, + ), + ); + } + + final currentNewSet = newAddresses.map((e) => e.value).toSet(); + + final p2pkhRcvAddresses = _v4GetAddressesFromList( + walletBox.get(receiveAddressesPrefix) as List? ?? + walletBox.get("${receiveAddressesPrefix}P2PKH") + as List? ?? + [], + isar_models.AddressType.p2pkh, + isar_models.AddressSubType.receiving, + walletId); + for (final address in p2pkhRcvAddresses) { + if (!currentNewSet.contains(address.value)) { + newAddresses.add(address); + } + } + + final p2shRcvAddresses = _v4GetAddressesFromList( + walletBox.get("${receiveAddressesPrefix}P2SH") as List? ?? [], + isar_models.AddressType.p2sh, + isar_models.AddressSubType.receiving, + walletId); + for (final address in p2shRcvAddresses) { + if (!currentNewSet.contains(address.value)) { + newAddresses.add(address); + } + } + + final p2wpkhRcvAddresses = _v4GetAddressesFromList( + walletBox.get("${receiveAddressesPrefix}P2WPKH") as List? ?? + [], + isar_models.AddressType.p2wpkh, + isar_models.AddressSubType.receiving, + walletId); + for (final address in p2wpkhRcvAddresses) { + if (!currentNewSet.contains(address.value)) { + newAddresses.add(address); + } + } + + final p2pkhCngAddresses = _v4GetAddressesFromList( + walletBox.get(changeAddressesPrefix) as List? ?? + walletBox.get("${changeAddressesPrefix}P2PKH") as List? ?? + [], + isar_models.AddressType.p2wpkh, + isar_models.AddressSubType.change, + walletId); + for (final address in p2pkhCngAddresses) { + if (!currentNewSet.contains(address.value)) { + newAddresses.add(address); + } + } + + final p2shCngAddresses = _v4GetAddressesFromList( + walletBox.get("${changeAddressesPrefix}P2SH") as List? ?? [], + isar_models.AddressType.p2wpkh, + isar_models.AddressSubType.change, + walletId); + for (final address in p2shCngAddresses) { + if (!currentNewSet.contains(address.value)) { + newAddresses.add(address); + } + } + + final p2wpkhCngAddresses = _v4GetAddressesFromList( + walletBox.get("${changeAddressesPrefix}P2WPKH") as List? ?? + [], + isar_models.AddressType.p2wpkh, + isar_models.AddressSubType.change, + walletId); + for (final address in p2wpkhCngAddresses) { + if (!currentNewSet.contains(address.value)) { + newAddresses.add(address); + } + } + + // transactions + final txnData = walletBox.get("latest_tx_model") as TransactionData?; + final txns = txnData?.getAllTransactions().values ?? []; + final txnDataLelantus = + walletBox.get("latest_lelantus_tx_model") as TransactionData?; + final txnsLelantus = txnDataLelantus?.getAllTransactions().values ?? []; + + final List< + Tuple4< + isar_models.Transaction, + List, + List, + isar_models.Address?>> newTransactions = []; + + newTransactions + .addAll(_parseTransactions(txns, walletId, false, newAddresses)); + newTransactions.addAll( + _parseTransactions(txnsLelantus, walletId, true, newAddresses)); + + // store newly parsed data in isar + await isarInit(walletId); + await db.isar.writeTxn(() async { + await db.isar.addresses.putAll(newAddresses); + }); + await addNewTransactionData(newTransactions, walletId); + + // delete data from hive + await walletBox.delete(receiveAddressesPrefix); + await walletBox.delete("${receiveAddressesPrefix}P2PKH"); + await walletBox.delete("${receiveAddressesPrefix}P2SH"); + await walletBox.delete("${receiveAddressesPrefix}P2WPKH"); + await walletBox.delete(changeAddressesPrefix); + await walletBox.delete("${changeAddressesPrefix}P2PKH"); + await walletBox.delete("${changeAddressesPrefix}P2SH"); + await walletBox.delete("${changeAddressesPrefix}P2WPKH"); + await walletBox.delete("latest_tx_model"); + await walletBox.delete("latest_lelantus_tx_model"); + } + } + + List< + Tuple4, + List, isar_models.Address?>> _parseTransactions( + Iterable txns, + String walletId, + bool isLelantus, + List parsedAddresses, + ) { + List< + Tuple4, + List, isar_models.Address?>> transactions = []; + for (final tx in txns) { + final type = tx.txType.toLowerCase() == "received" + ? isar_models.TransactionType.incoming + : isar_models.TransactionType.outgoing; + final subType = tx.subType.toLowerCase() == "mint" + ? isar_models.TransactionSubType.mint + : tx.subType.toLowerCase() == "join" + ? isar_models.TransactionSubType.join + : isar_models.TransactionSubType.none; + + final transaction = isar_models.Transaction( + walletId: walletId, + txid: tx.txid, + timestamp: tx.timestamp, + type: type, + subType: subType, + amount: tx.amount, + fee: tx.fees, + height: tx.height, + isCancelled: tx.isCancelled, + isLelantus: false, + slateId: tx.slateId, + otherData: tx.otherData, + ); + + final List inputs = []; + final List outputs = []; + + for (final inp in tx.inputs) { + final input = isar_models.Input( + walletId: walletId, + txid: inp.txid, + vout: inp.vout, + scriptSig: inp.scriptsig, + scriptSigAsm: inp.scriptsigAsm, + isCoinbase: inp.isCoinbase, + sequence: inp.sequence, + innerRedeemScriptAsm: inp.innerRedeemscriptAsm, + ); + inputs.add(input); + } + for (final out in tx.outputs) { + final output = isar_models.Output( + walletId: walletId, + scriptPubKey: out.scriptpubkey, + scriptPubKeyAsm: out.scriptpubkeyAsm, + scriptPubKeyType: out.scriptpubkeyType, + scriptPubKeyAddress: out.scriptpubkeyAddress, + value: out.value, + ); + outputs.add(output); + } + + isar_models.Address? address; + if (tx.address.isNotEmpty) { + final addresses = parsedAddresses.where((e) => e.value == tx.address); + if (addresses.isNotEmpty) { + address = addresses.first; + } else { + address = isar_models.Address( + walletId: walletId, + value: tx.address, + publicKey: [], + derivationIndex: -1, + type: isar_models.AddressType.unknown, + subType: type == isar_models.TransactionType.incoming + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.change, + ); + } + } + + transactions.add(Tuple4(transaction, outputs, inputs, address)); + } + return transactions; + } + + List _v4GetAddressesFromDerivationString( + String derivationsString, + isar_models.AddressType type, + isar_models.AddressSubType subType, + String walletId, + ) { + final List addresses = []; + + final derivations = + Map.from(jsonDecode(derivationsString) as Map); + + for (final entry in derivations.entries) { + final addr = entry.key; + final pubKey = entry.value["pubKey"] as String; + + final address = isar_models.Address( + walletId: walletId, + value: addr, + publicKey: Format.stringToUint8List(pubKey), + derivationIndex: -1, + type: type, + subType: subType, + ); + addresses.add(address); + } + + return addresses; + } + + List _v4GetAddressesFromList( + List addressStrings, + isar_models.AddressType type, + isar_models.AddressSubType subType, + String walletId, + ) { + final List addresses = []; + + for (final addr in addressStrings) { + final address = isar_models.Address( + walletId: walletId, + value: addr, + publicKey: [], + derivationIndex: -1, + type: type, + subType: subType, + ); + addresses.add(address); + } + + return addresses; + } } From 6784e6aab44071b1abd8ba7bc62086c76be79e8c Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 15:15:38 -0600 Subject: [PATCH 169/192] dynamic parsing fixes --- lib/utilities/db_version_migration.dart | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index 4abe653bf..b3fb1ca5e 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -316,10 +316,8 @@ class DbVersionMigrator with WalletDB { final currentNewSet = newAddresses.map((e) => e.value).toSet(); final p2pkhRcvAddresses = _v4GetAddressesFromList( - walletBox.get(receiveAddressesPrefix) as List? ?? - walletBox.get("${receiveAddressesPrefix}P2PKH") - as List? ?? - [], + _getList(walletBox.get(receiveAddressesPrefix) ?? + walletBox.get("${receiveAddressesPrefix}P2PKH")), isar_models.AddressType.p2pkh, isar_models.AddressSubType.receiving, walletId); @@ -330,7 +328,7 @@ class DbVersionMigrator with WalletDB { } final p2shRcvAddresses = _v4GetAddressesFromList( - walletBox.get("${receiveAddressesPrefix}P2SH") as List? ?? [], + _getList(walletBox.get("${receiveAddressesPrefix}P2SH")), isar_models.AddressType.p2sh, isar_models.AddressSubType.receiving, walletId); @@ -341,8 +339,7 @@ class DbVersionMigrator with WalletDB { } final p2wpkhRcvAddresses = _v4GetAddressesFromList( - walletBox.get("${receiveAddressesPrefix}P2WPKH") as List? ?? - [], + _getList(walletBox.get("${receiveAddressesPrefix}P2WPKH")), isar_models.AddressType.p2wpkh, isar_models.AddressSubType.receiving, walletId); @@ -353,9 +350,8 @@ class DbVersionMigrator with WalletDB { } final p2pkhCngAddresses = _v4GetAddressesFromList( - walletBox.get(changeAddressesPrefix) as List? ?? - walletBox.get("${changeAddressesPrefix}P2PKH") as List? ?? - [], + _getList(walletBox.get(changeAddressesPrefix) ?? + walletBox.get("${changeAddressesPrefix}P2PKH")), isar_models.AddressType.p2wpkh, isar_models.AddressSubType.change, walletId); @@ -366,7 +362,7 @@ class DbVersionMigrator with WalletDB { } final p2shCngAddresses = _v4GetAddressesFromList( - walletBox.get("${changeAddressesPrefix}P2SH") as List? ?? [], + _getList(walletBox.get("${changeAddressesPrefix}P2SH")), isar_models.AddressType.p2wpkh, isar_models.AddressSubType.change, walletId); @@ -377,8 +373,7 @@ class DbVersionMigrator with WalletDB { } final p2wpkhCngAddresses = _v4GetAddressesFromList( - walletBox.get("${changeAddressesPrefix}P2WPKH") as List? ?? - [], + _getList(walletBox.get("${changeAddressesPrefix}P2WPKH")), isar_models.AddressType.p2wpkh, isar_models.AddressSubType.change, walletId); @@ -528,14 +523,16 @@ class DbVersionMigrator with WalletDB { Map.from(jsonDecode(derivationsString) as Map); for (final entry in derivations.entries) { - final addr = entry.key; - final pubKey = entry.value["pubKey"] as String; + final addr = entry.value["address"] as String? ?? entry.key; + final pubKey = entry.value["pubKey"] as String? ?? + entry.value["publicKey"] as String; + final index = int.tryParse(entry.key) ?? -1; final address = isar_models.Address( walletId: walletId, value: addr, publicKey: Format.stringToUint8List(pubKey), - derivationIndex: -1, + derivationIndex: index, type: type, subType: subType, ); @@ -567,4 +564,9 @@ class DbVersionMigrator with WalletDB { return addresses; } + + List _getList(dynamic list) { + if (list == null) return []; + return List.from(list as List); + } } From 575cce1a7d5feed75cb58879f831888e5b7a0fae Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 16:55:59 -0600 Subject: [PATCH 170/192] update address in case of bad index from migrate or any other reason --- lib/db/main_db.dart | 11 ++++++ .../coins/bitcoin/bitcoin_wallet.dart | 38 +++++++++++++++++-- .../coins/bitcoincash/bitcoincash_wallet.dart | 38 +++++++++++++++++-- .../coins/dogecoin/dogecoin_wallet.dart | 38 +++++++++++++++++-- lib/services/coins/firo/firo_wallet.dart | 38 +++++++++++++++++-- .../coins/litecoin/litecoin_wallet.dart | 38 +++++++++++++++++-- lib/services/coins/monero/monero_wallet.dart | 19 +++++++++- .../coins/namecoin/namecoin_wallet.dart | 38 +++++++++++++++++-- .../coins/particl/particl_wallet.dart | 38 +++++++++++++++++-- .../coins/wownero/wownero_wallet.dart | 19 +++++++++- 10 files changed, 283 insertions(+), 32 deletions(-) diff --git a/lib/db/main_db.dart b/lib/db/main_db.dart index be6a98089..a886dcf06 100644 --- a/lib/db/main_db.dart +++ b/lib/db/main_db.dart @@ -42,6 +42,17 @@ class MainDB { await isar.addresses.putAll(addresses); }); + Future updateAddress(Address oldAddress, Address newAddress) => + isar.writeTxn(() async { + newAddress.id = oldAddress.id; + await oldAddress.transaction.load(); + final txns = oldAddress.transaction.toList(); + await isar.addresses.delete(oldAddress.id); + await isar.addresses.put(newAddress); + newAddress.transaction.addAll(txns); + await newAddress.transaction.save(); + }); + // transactions QueryBuilder getTransactions( String walletId) => diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index e5a500a40..f0ca06915 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1859,8 +1859,23 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain( 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } catch (e, s) { Logging.instance.log( @@ -1886,8 +1901,23 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newChangeAddress = await _generateAddressForChain( 1, newChangeIndex, DerivePathType.bip84); - // Add that new change address - await db.putAddress(newChangeAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newChangeAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newChangeAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newChangeAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkChangeAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index df1fe4128..b3fc5b4b5 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1746,8 +1746,23 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain( 0, newReceivingIndex, DerivePathType.bip44); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( @@ -1778,8 +1793,23 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final newChangeAddress = await _generateAddressForChain( 1, newChangeIndex, DerivePathType.bip44); - // Add that new change address - await db.putAddress(newChangeAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newChangeAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newChangeAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newChangeAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkChangeAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 4ce4fe1f6..bc799530a 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1650,8 +1650,23 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain( 0, newReceivingIndex, DerivePathType.bip44); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( @@ -1682,8 +1697,23 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newChangeAddress = await _generateAddressForChain( 1, newChangeIndex, DerivePathType.bip44); - // Add that new change address - await db.putAddress(newChangeAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newChangeAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newChangeAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newChangeAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await checkChangeAddressForTransactions(); + } } } catch (e, s) { Logging.instance.log( diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 9a587b12e..b679f203f 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3147,8 +3147,23 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { newReceivingIndex, ); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await checkReceivingAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( @@ -3182,8 +3197,23 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { newChangeIndex, ); - // Add that new change address - await db.putAddress(newChangeAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newChangeAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newChangeAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newChangeAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await checkChangeAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 62b7c4232..7604d3811 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -1885,8 +1885,23 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain( 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } catch (e, s) { Logging.instance.log( @@ -1912,8 +1927,23 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newChangeAddress = await _generateAddressForChain( 1, newChangeIndex, DerivePathType.bip84); - // Add that new change address - await db.putAddress(newChangeAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newChangeAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newChangeAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newChangeAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkChangeAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 538488bfa..663e5fe34 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -1131,8 +1131,23 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain(0, newReceivingIndex); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 2995ea441..fe064fe7f 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -1867,8 +1867,23 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain( 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } catch (e, s) { Logging.instance.log( @@ -1894,8 +1909,23 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final newChangeAddress = await _generateAddressForChain( 1, newChangeIndex, DerivePathType.bip84); - // Add that new change address - await db.putAddress(newChangeAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newChangeAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newChangeAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newChangeAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkChangeAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 1dba3b144..59e9e718e 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1754,8 +1754,23 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain( 0, newReceivingIndex, DerivePathType.bip84); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } catch (e, s) { Logging.instance.log( @@ -1781,8 +1796,23 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { final newChangeAddress = await _generateAddressForChain( 1, newChangeIndex, DerivePathType.bip84); - // Add that new change address - await db.putAddress(newChangeAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newChangeAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newChangeAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newChangeAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkChangeAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index f864d44e0..6c2dfcbb7 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1200,8 +1200,23 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { final newReceivingAddress = await _generateAddressForChain(0, newReceivingIndex); - // Add that new receiving address - await db.putAddress(newReceivingAddress); + final existing = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(newReceivingAddress.value) + .findFirst(); + if (existing == null) { + // Add that new change address + await db.putAddress(newReceivingAddress); + } else { + // we need to update the address + await db.updateAddress(existing, newReceivingAddress); + + // since we updated an existing address there is a chance it has + // some tx history. To prevent address reuse we will call check again + // recursively + await _checkReceivingAddressForTransactions(); + } } } on SocketException catch (se, s) { Logging.instance.log( From 0a3c00184546057d79136e3d33d3e7162d72bf74 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 17:20:23 -0600 Subject: [PATCH 171/192] fix all own addresses query --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 10 +++++++--- .../coins/bitcoincash/bitcoincash_wallet.dart | 10 +++++++--- lib/services/coins/dogecoin/dogecoin_wallet.dart | 10 +++++++--- lib/services/coins/firo/firo_wallet.dart | 10 +++++++--- lib/services/coins/litecoin/litecoin_wallet.dart | 10 +++++++--- lib/services/coins/namecoin/namecoin_wallet.dart | 10 +++++++--- lib/services/coins/particl/particl_wallet.dart | 11 ++++++++--- 7 files changed, 50 insertions(+), 21 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index f0ca06915..e0d9a1e72 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1319,9 +1319,13 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final allAddresses = await db .getAddresses(walletId) .filter() - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .or() - .subTypeEqualTo(isar_models.AddressSubType.change) + .not() + .typeEqualTo(isar_models.AddressType.nonWallet) + .and() + .group((q) => q + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change)) .findAll(); // final List allAddresses = []; // final receivingAddresses = DB.instance.get( diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index b3fc5b4b5..94cc16139 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -1274,9 +1274,13 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { final allAddresses = await db .getAddresses(walletId) .filter() - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .or() - .subTypeEqualTo(isar_models.AddressSubType.change) + .not() + .typeEqualTo(isar_models.AddressType.nonWallet) + .and() + .group((q) => q + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change)) .findAll(); // for (var i = 0; i < receivingAddressesP2PKH.length; i++) { diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index bc799530a..01d148c51 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1152,9 +1152,13 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final allAddresses = await db .getAddresses(walletId) .filter() - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .or() - .subTypeEqualTo(isar_models.AddressSubType.change) + .not() + .typeEqualTo(isar_models.AddressType.nonWallet) + .and() + .group((q) => q + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change)) .findAll(); return allAddresses; } diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index b679f203f..259420ac2 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3232,9 +3232,13 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final allAddresses = await db .getAddresses(walletId) .filter() - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .or() - .subTypeEqualTo(isar_models.AddressSubType.change) + .not() + .typeEqualTo(isar_models.AddressType.nonWallet) + .and() + .group((q) => q + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change)) .findAll(); // final List allAddresses = []; // final receivingAddresses = diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 7604d3811..1a019eacb 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -1335,9 +1335,13 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final allAddresses = await db .getAddresses(walletId) .filter() - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .or() - .subTypeEqualTo(isar_models.AddressSubType.change) + .not() + .typeEqualTo(isar_models.AddressType.nonWallet) + .and() + .group((q) => q + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change)) .findAll(); // final List allAddresses = []; // final receivingAddresses = DB.instance.get( diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index fe064fe7f..70d3e85ed 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -1324,9 +1324,13 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final allAddresses = await db .getAddresses(walletId) .filter() - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .or() - .subTypeEqualTo(isar_models.AddressSubType.change) + .not() + .typeEqualTo(isar_models.AddressType.nonWallet) + .and() + .group((q) => q + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change)) .findAll(); // final List allAddresses = []; // final receivingAddresses = DB.instance.get( diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 59e9e718e..a0448630b 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -1255,10 +1255,15 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { final allAddresses = await db .getAddresses(walletId) .filter() - .subTypeEqualTo(isar_models.AddressSubType.receiving) - .or() - .subTypeEqualTo(isar_models.AddressSubType.change) + .not() + .typeEqualTo(isar_models.AddressType.nonWallet) + .and() + .group((q) => q + .subTypeEqualTo(isar_models.AddressSubType.receiving) + .or() + .subTypeEqualTo(isar_models.AddressSubType.change)) .findAll(); + // final List allAddresses = []; // final receivingAddresses = DB.instance.get( // boxName: walletId, key: 'receivingAddressesP2WPKH') as List; From f507f6a60a5cf46e4a6e01698cfaf9c7bc0171a9 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 17:44:10 -0600 Subject: [PATCH 172/192] make fields final and other small QOL changes --- lib/db/main_db.dart | 8 +-- lib/models/isar/models/address/address.dart | 29 ++++++++--- .../isar/models/blockchain_data/input.dart | 16 +++--- .../isar/models/blockchain_data/output.dart | 12 ++--- .../models/blockchain_data/transaction.dart | 49 +++++++++++++------ .../isar/models/blockchain_data/utxo.dart | 41 +++++++++++----- 6 files changed, 102 insertions(+), 53 deletions(-) diff --git a/lib/db/main_db.dart b/lib/db/main_db.dart index a886dcf06..cc4e50952 100644 --- a/lib/db/main_db.dart +++ b/lib/db/main_db.dart @@ -45,12 +45,12 @@ class MainDB { Future updateAddress(Address oldAddress, Address newAddress) => isar.writeTxn(() async { newAddress.id = oldAddress.id; - await oldAddress.transaction.load(); - final txns = oldAddress.transaction.toList(); + await oldAddress.transactions.load(); + final txns = oldAddress.transactions.toList(); await isar.addresses.delete(oldAddress.id); await isar.addresses.put(newAddress); - newAddress.transaction.addAll(txns); - await newAddress.transaction.save(); + newAddress.transactions.addAll(txns); + await newAddress.transactions.save(); }); // transactions diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index a21d991dd..df6d06fa7 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -18,28 +18,31 @@ class Address extends CryptoCurrencyAddress { required this.derivationIndex, required this.type, required this.subType, + this.otherData, }); Id id = Isar.autoIncrement; @Index() - late String walletId; + late final String walletId; @Index(unique: true, composite: [CompositeIndex("walletId")]) - late String value; + late final String value; - late List publicKey; + late final List publicKey; @Index() - late int derivationIndex; // -1 generally means unknown + late final int derivationIndex; // -1 generally means unknown @enumerated - late AddressType type; + late final AddressType type; @enumerated - late AddressSubType subType; + late final AddressSubType subType; - final transaction = IsarLinks(); + late final String? otherData; + + final transactions = IsarLinks(); int derivationChain() { if (subType == AddressSubType.receiving) { @@ -57,7 +60,17 @@ class Address extends CryptoCurrencyAddress { subType == AddressSubType.paynymReceive; @override - String toString() => value; + String toString() => "{ " + "id: $id, " + "walletId: $walletId, " + "value: $value, " + "publicKey: $publicKey, " + "derivationIndex: $derivationIndex, " + "type: ${type.name}, " + "subType: ${subType.name}, " + "transactionsLength: ${transactions.length} " + "otherData: $otherData, " + "}"; } enum AddressType { diff --git a/lib/models/isar/models/blockchain_data/input.dart b/lib/models/isar/models/blockchain_data/input.dart index 403cd48f1..58bbef889 100644 --- a/lib/models/isar/models/blockchain_data/input.dart +++ b/lib/models/isar/models/blockchain_data/input.dart @@ -20,24 +20,24 @@ class Input { Id id = Isar.autoIncrement; @Index() - late String walletId; + late final String walletId; - late String txid; + late final String txid; - late int vout; + late final int vout; - late String? scriptSig; + late final String? scriptSig; - late String? scriptSigAsm; + late final String? scriptSigAsm; // TODO: find witness type // is it even used? // late List? witness; - late bool? isCoinbase; + late final bool? isCoinbase; - late int? sequence; + late final int? sequence; - late String? innerRedeemScriptAsm; + late final String? innerRedeemScriptAsm; final prevOut = IsarLink(); diff --git a/lib/models/isar/models/blockchain_data/output.dart b/lib/models/isar/models/blockchain_data/output.dart index 1b24fc39d..d5e934511 100644 --- a/lib/models/isar/models/blockchain_data/output.dart +++ b/lib/models/isar/models/blockchain_data/output.dart @@ -17,17 +17,17 @@ class Output { Id id = Isar.autoIncrement; @Index() - late String walletId; + late final String walletId; - late String? scriptPubKey; + late final String? scriptPubKey; - late String? scriptPubKeyAsm; + late final String? scriptPubKeyAsm; - late String? scriptPubKeyType; + late final String? scriptPubKeyType; - late String scriptPubKeyAddress; + late final String scriptPubKeyAddress; - late int value; + late final int value; @Backlink(to: 'outputs') final transaction = IsarLink(); diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index c26a8b613..ee35776fa 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -27,38 +27,35 @@ class Transaction { Id id = Isar.autoIncrement; @Index() - late String walletId; + late final String walletId; @Index(unique: true, composite: [CompositeIndex("walletId")]) - late String txid; + late final String txid; @Index() - late int timestamp; + late final int timestamp; @enumerated - late TransactionType type; + late final TransactionType type; @enumerated - late TransactionSubType subType; + late final TransactionSubType subType; - late int amount; + late final int amount; - // TODO: do we need this? - // late List aliens; + late final int fee; - late int fee; + late final int? height; - late int? height; + late final bool isCancelled; - late bool isCancelled; + late final bool? isLelantus; - late bool? isLelantus; + late final String? slateId; - late String? slateId; + late final String? otherData; - late String? otherData; - - @Backlink(to: "transaction") + @Backlink(to: "transactions") final address = IsarLink
(); final inputs = IsarLinks(); @@ -74,6 +71,26 @@ class Transaction { final confirmations = getConfirmations(currentChainHeight); return confirmations >= minimumConfirms; } + + @override + toString() => "{ " + "id: $id, " + "walletId: $walletId, " + "txid: $txid, " + "timestamp: $timestamp, " + "type: ${type.name}, " + "subType: ${subType.name}, " + "amount: $amount, " + "fee: $fee, " + "height: $height, " + "isCancelled: $isCancelled, " + "isLelantus: $isLelantus, " + "slateId: $slateId, " + "otherData: $otherData, " + "address: ${address.value}, " + "inputsLength: ${inputs.length}, " + "outputsLength: ${outputs.length}, " + "}"; } // Used in Isar db and stored there as int indexes so adding/removing values diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index 56f6c608f..2bea3eead 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -18,34 +18,37 @@ class UTXO { required this.blockHash, required this.blockHeight, required this.blockTime, + this.otherData, }); Id id = Isar.autoIncrement; @Index() - late String walletId; + late final String walletId; @Index(unique: true, replace: true, composite: [CompositeIndex("walletId")]) - late String txid; + late final String txid; - late int vout; + late final int vout; - late int value; + late final int value; - late String name; + late final String name; @Index() - late bool isBlocked; + late final bool isBlocked; - late String? blockedReason; + late final String? blockedReason; - late bool isCoinbase; + late final bool isCoinbase; - late String? blockHash; + late final String? blockHash; - late int? blockHeight; + late final int? blockHeight; - late int? blockTime; + late final int? blockTime; + + late final String? otherData; int getConfirmations(int currentChainHeight) { if (blockTime == null || blockHash == null) return 0; @@ -57,4 +60,20 @@ class UTXO { final confirmations = getConfirmations(currentChainHeight); return confirmations >= minimumConfirms; } + + @override + String toString() => "{ " + "id: $id, " + "walletId: $walletId, " + "txid: $txid, " + "vout: $vout, " + "value: $value, " + "name: $name, " + "isBlocked: $isBlocked, " + "blockedReason: $blockedReason, " + "isCoinbase: $isCoinbase, " + "blockHash: $blockHash, " + "blockHeight: $blockHeight, " + "blockTime: $blockTime, " + "}"; } From 42e53c31a65359e1dd09dfbc6b522433ff8a1916 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 17:48:44 -0600 Subject: [PATCH 173/192] build runner --- lib/models/isar/models/address/address.g.dart | 282 +++++++++++++++--- .../models/blockchain_data/transaction.g.dart | 4 +- test/services/coins/manager_test.mocks.dart | 15 +- .../transaction_card_test.mocks.dart | 15 +- 4 files changed, 251 insertions(+), 65 deletions(-) diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 629881192..6ff9f44b0 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -22,30 +22,35 @@ const AddressSchema = CollectionSchema( name: r'derivationIndex', type: IsarType.long, ), - r'publicKey': PropertySchema( + r'otherData': PropertySchema( id: 1, + name: r'otherData', + type: IsarType.string, + ), + r'publicKey': PropertySchema( + id: 2, name: r'publicKey', type: IsarType.byteList, ), r'subType': PropertySchema( - id: 2, + id: 3, name: r'subType', type: IsarType.byte, enumMap: _AddresssubTypeEnumValueMap, ), r'type': PropertySchema( - id: 3, + id: 4, name: r'type', type: IsarType.byte, enumMap: _AddresstypeEnumValueMap, ), r'value': PropertySchema( - id: 4, + id: 5, name: r'value', type: IsarType.string, ), r'walletId': PropertySchema( - id: 5, + id: 6, name: r'walletId', type: IsarType.string, ) @@ -102,9 +107,9 @@ const AddressSchema = CollectionSchema( ) }, links: { - r'transaction': LinkSchema( - id: -7782495619063243587, - name: r'transaction', + r'transactions': LinkSchema( + id: -20231914767662480, + name: r'transactions', target: r'Transaction', single: false, ) @@ -122,6 +127,12 @@ int _addressEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; + { + final value = object.otherData; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } bytesCount += 3 + object.publicKey.length; bytesCount += 3 + object.value.length * 3; bytesCount += 3 + object.walletId.length * 3; @@ -135,11 +146,12 @@ void _addressSerialize( Map> allOffsets, ) { writer.writeLong(offsets[0], object.derivationIndex); - writer.writeByteList(offsets[1], object.publicKey); - writer.writeByte(offsets[2], object.subType.index); - writer.writeByte(offsets[3], object.type.index); - writer.writeString(offsets[4], object.value); - writer.writeString(offsets[5], object.walletId); + writer.writeString(offsets[1], object.otherData); + writer.writeByteList(offsets[2], object.publicKey); + writer.writeByte(offsets[3], object.subType.index); + writer.writeByte(offsets[4], object.type.index); + writer.writeString(offsets[5], object.value); + writer.writeString(offsets[6], object.walletId); } Address _addressDeserialize( @@ -150,13 +162,14 @@ Address _addressDeserialize( ) { final object = Address( derivationIndex: reader.readLong(offsets[0]), - publicKey: reader.readByteList(offsets[1]) ?? [], - subType: _AddresssubTypeValueEnumMap[reader.readByteOrNull(offsets[2])] ?? + otherData: reader.readStringOrNull(offsets[1]), + publicKey: reader.readByteList(offsets[2]) ?? [], + subType: _AddresssubTypeValueEnumMap[reader.readByteOrNull(offsets[3])] ?? AddressSubType.receiving, - type: _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[3])] ?? + type: _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[4])] ?? AddressType.p2pkh, - value: reader.readString(offsets[4]), - walletId: reader.readString(offsets[5]), + value: reader.readString(offsets[5]), + walletId: reader.readString(offsets[6]), ); object.id = id; return object; @@ -172,17 +185,19 @@ P _addressDeserializeProp

( case 0: return (reader.readLong(offset)) as P; case 1: - return (reader.readByteList(offset) ?? []) as P; + return (reader.readStringOrNull(offset)) as P; case 2: + return (reader.readByteList(offset) ?? []) as P; + case 3: return (_AddresssubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? AddressSubType.receiving) as P; - case 3: + case 4: return (_AddresstypeValueEnumMap[reader.readByteOrNull(offset)] ?? AddressType.p2pkh) as P; - case 4: - return (reader.readString(offset)) as P; case 5: return (reader.readString(offset)) as P; + case 6: + return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -212,7 +227,8 @@ const _AddresstypeEnumValueMap = { 'p2wpkh': 2, 'cryptonote': 3, 'mimbleWimble': 4, - 'nonWallet': 5, + 'unknown': 5, + 'nonWallet': 6, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, @@ -220,7 +236,8 @@ const _AddresstypeValueEnumMap = { 2: AddressType.p2wpkh, 3: AddressType.cryptonote, 4: AddressType.mimbleWimble, - 5: AddressType.nonWallet, + 5: AddressType.unknown, + 6: AddressType.nonWallet, }; Id _addressGetId(Address object) { @@ -228,13 +245,13 @@ Id _addressGetId(Address object) { } List> _addressGetLinks(Address object) { - return [object.transaction]; + return [object.transactions]; } void _addressAttach(IsarCollection col, Id id, Address object) { object.id = id; - object.transaction - .attach(col, col.isar.collection(), r'transaction', id); + object.transactions + .attach(col, col.isar.collection(), r'transactions', id); } extension AddressByIndex on IsarCollection

{ @@ -740,6 +757,152 @@ extension AddressQueryFilter }); } + QueryBuilder otherDataIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'otherData', + )); + }); + } + + QueryBuilder otherDataIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'otherData', + )); + }); + } + + QueryBuilder otherDataEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'otherData', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'otherData', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'otherData', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder otherDataIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'otherData', + value: '', + )); + }); + } + + QueryBuilder otherDataIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'otherData', + value: '', + )); + }); + } + QueryBuilder publicKeyElementEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -1252,55 +1415,55 @@ extension AddressQueryObject extension AddressQueryLinks on QueryBuilder { - QueryBuilder transaction( + QueryBuilder transactions( FilterQuery q) { return QueryBuilder.apply(this, (query) { - return query.link(q, r'transaction'); + return query.link(q, r'transactions'); }); } QueryBuilder - transactionLengthEqualTo(int length) { + transactionsLengthEqualTo(int length) { return QueryBuilder.apply(this, (query) { - return query.linkLength(r'transaction', length, true, length, true); + return query.linkLength(r'transactions', length, true, length, true); }); } - QueryBuilder transactionIsEmpty() { + QueryBuilder transactionsIsEmpty() { return QueryBuilder.apply(this, (query) { - return query.linkLength(r'transaction', 0, true, 0, true); + return query.linkLength(r'transactions', 0, true, 0, true); }); } QueryBuilder - transactionIsNotEmpty() { + transactionsIsNotEmpty() { return QueryBuilder.apply(this, (query) { - return query.linkLength(r'transaction', 0, false, 999999, true); + return query.linkLength(r'transactions', 0, false, 999999, true); }); } QueryBuilder - transactionLengthLessThan( + transactionsLengthLessThan( int length, { bool include = false, }) { return QueryBuilder.apply(this, (query) { - return query.linkLength(r'transaction', 0, true, length, include); + return query.linkLength(r'transactions', 0, true, length, include); }); } QueryBuilder - transactionLengthGreaterThan( + transactionsLengthGreaterThan( int length, { bool include = false, }) { return QueryBuilder.apply(this, (query) { - return query.linkLength(r'transaction', length, include, 999999, true); + return query.linkLength(r'transactions', length, include, 999999, true); }); } QueryBuilder - transactionLengthBetween( + transactionsLengthBetween( int lower, int upper, { bool includeLower = true, @@ -1308,7 +1471,7 @@ extension AddressQueryLinks }) { return QueryBuilder.apply(this, (query) { return query.linkLength( - r'transaction', lower, includeLower, upper, includeUpper); + r'transactions', lower, includeLower, upper, includeUpper); }); } } @@ -1326,6 +1489,18 @@ extension AddressQuerySortBy on QueryBuilder { }); } + QueryBuilder sortByOtherData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.asc); + }); + } + + QueryBuilder sortByOtherDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.desc); + }); + } + QueryBuilder sortBySubType() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'subType', Sort.asc); @@ -1401,6 +1576,18 @@ extension AddressQuerySortThenBy }); } + QueryBuilder thenByOtherData() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.asc); + }); + } + + QueryBuilder thenByOtherDataDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'otherData', Sort.desc); + }); + } + QueryBuilder thenBySubType() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'subType', Sort.asc); @@ -1458,6 +1645,13 @@ extension AddressQueryWhereDistinct }); } + QueryBuilder distinctByOtherData( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'otherData', caseSensitive: caseSensitive); + }); + } + QueryBuilder distinctByPublicKey() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'publicKey'); @@ -1505,6 +1699,12 @@ extension AddressQueryProperty }); } + QueryBuilder otherDataProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'otherData'); + }); + } + QueryBuilder, QQueryOperations> publicKeyProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'publicKey'); diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 167b85cd5..a15f38215 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -133,11 +133,11 @@ const TransactionSchema = CollectionSchema( }, links: { r'address': LinkSchema( - id: 2468609240108930288, + id: 7060979817661293320, name: r'address', target: r'Address', single: true, - linkName: r'transaction', + linkName: r'transactions', ), r'inputs': LinkSchema( id: 4634425919890543640, diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index 403e10555..48582fca8 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -212,13 +212,6 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValue: _i10.Future>.value([]), ) as _i10.Future>); @override - _i10.Future> get lelantusTransactionData => - (super.noSuchMethod( - Invocation.getter(#lelantusTransactionData), - returnValue: - _i10.Future>.value(<_i12.Transaction>[]), - ) as _i10.Future>); - @override _i10.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), returnValue: _i10.Future.value(0), @@ -824,7 +817,7 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { >[]), ) as _i10.Future>>); @override - _i10.Future> getJMintTransactions( + _i10.Future> getJMintTransactions( _i5.CachedElectrumX? cachedClient, List? transactions, _i11.Coin? coin, @@ -838,9 +831,9 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { coin, ], ), - returnValue: - _i10.Future>.value(<_i12.Transaction>[]), - ) as _i10.Future>); + returnValue: _i10.Future>.value( + <_i12.Address, _i12.Transaction>{}), + ) as _i10.Future>); @override _i10.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 4c77114bc..2fa1ed27b 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -1125,13 +1125,6 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValue: _i18.Future>.value([]), ) as _i18.Future>); @override - _i18.Future> get lelantusTransactionData => - (super.noSuchMethod( - Invocation.getter(#lelantusTransactionData), - returnValue: - _i18.Future>.value(<_i21.Transaction>[]), - ) as _i18.Future>); - @override _i18.Future get maxFee => (super.noSuchMethod( Invocation.getter(#maxFee), returnValue: _i18.Future.value(0), @@ -1737,7 +1730,7 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { >[]), ) as _i18.Future>>); @override - _i18.Future> getJMintTransactions( + _i18.Future> getJMintTransactions( _i12.CachedElectrumX? cachedClient, List? transactions, _i17.Coin? coin, @@ -1751,9 +1744,9 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { coin, ], ), - returnValue: - _i18.Future>.value(<_i21.Transaction>[]), - ) as _i18.Future>); + returnValue: _i18.Future>.value( + <_i21.Address, _i21.Transaction>{}), + ) as _i18.Future>); @override _i18.Future generateNewAddress() => (super.noSuchMethod( Invocation.method( From 89f0704bd46861e44171e04b52d4f94f8bd6766e Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 18:03:53 -0600 Subject: [PATCH 174/192] revert late on isLelantus --- lib/models/isar/models/blockchain_data/transaction.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index ee35776fa..644f8aa70 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -49,7 +49,7 @@ class Transaction { late final bool isCancelled; - late final bool? isLelantus; + late bool? isLelantus; late final String? slateId; From 7d061866bda939e0fb1f3e28f5963d696fdb239e Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 18 Jan 2023 18:13:08 -0600 Subject: [PATCH 175/192] btc tx fetch fetch fix --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index e0d9a1e72..02c300572 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1320,6 +1320,9 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { .getAddresses(walletId) .filter() .not() + .typeEqualTo(isar_models.AddressType.unknown) + .and() + .not() .typeEqualTo(isar_models.AddressType.nonWallet) .and() .group((q) => q From 95b9e6170fcd4636c1708410acd86ded3bdd7b52 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 09:16:30 -0600 Subject: [PATCH 176/192] firo mint tx migrate fix --- lib/services/coins/firo/firo_wallet.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 259420ac2..df777a63c 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -2864,7 +2864,14 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { List, isar_models.Address?>> txnsData = []; for (final value in data.values) { - final transactionAddress = value.item1!; + // allow possible null address on mints as we don't display address + // this should normally never be null anyways but old (dbVersion up to 4) + // migrated transactions may not have had an address (full rescan should + // fix this) + final transactionAddress = + value.item2.subType == isar_models.TransactionSubType.mint + ? value.item1 + : value.item1!; final outs = value.item2.outputs.where((_) => true).toList(growable: false); final ins = value.item2.inputs.where((_) => true).toList(growable: false); From 5badeab6210cff1e9274f954bdd2c898c6dcdcb1 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 09:41:10 -0600 Subject: [PATCH 177/192] temp disable partial paynym support in ui --- lib/utilities/enums/coin_enum.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index a517992de..2f952651d 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -190,7 +190,8 @@ extension CoinExt on Coin { case Coin.dogecoin: case Coin.dogecoinTestNet: - return true; + // return true; + return false; } } From db205b40e2ff8df1f0cf8fa5dcde09c6b781e1f2 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 10:29:00 -0600 Subject: [PATCH 178/192] notify ui of tx changes and force refresh on rescan --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 12 ++++++++++++ .../coins/bitcoincash/bitcoincash_wallet.dart | 12 ++++++++++++ lib/services/coins/dogecoin/dogecoin_wallet.dart | 12 ++++++++++++ lib/services/coins/epiccash/epiccash_wallet.dart | 12 ++++++++++++ lib/services/coins/firo/firo_wallet.dart | 12 ++++++++++++ lib/services/coins/litecoin/litecoin_wallet.dart | 12 ++++++++++++ lib/services/coins/monero/monero_wallet.dart | 12 ++++++++++++ lib/services/coins/namecoin/namecoin_wallet.dart | 12 ++++++++++++ lib/services/coins/particl/particl_wallet.dart | 12 ++++++++++++ lib/services/coins/wownero/wownero_wallet.dart | 12 ++++++++++++ 10 files changed, 120 insertions(+) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 02c300572..0b7100190 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2116,6 +2116,17 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2788,6 +2799,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 94cc16139..b517c7de5 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2194,6 +2194,17 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txns, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txns.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2857,6 +2868,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 01d148c51..1bdc98fbf 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -1936,6 +1936,17 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txns, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txns.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2484,6 +2495,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 1480a4e02..7d3c70b93 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -947,6 +947,7 @@ class EpicCashWallet extends CoinServiceAPI ); return; } + await refresh(); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.synced, @@ -2114,6 +2115,17 @@ class EpicCashWallet extends CoinServiceAPI await addNewTransactionData(txnsData, walletId); + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } + // midSortedArray // .sort((a, b) => (b["timestamp"] as int) - (a["timestamp"] as int)); // diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index df777a63c..aac0b5ccd 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -3567,6 +3567,17 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } Future _refreshUTXOs() async { @@ -3886,6 +3897,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { await _recoverWalletFromBIP32SeedPhrase(mnemonic!, maxUnusedAddressGap); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 1a019eacb..0b68132b3 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2196,6 +2196,17 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2873,6 +2884,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 663e5fe34..242683d87 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -221,6 +221,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; await walletBase?.rescan(height: restoreHeight); + await refresh(); } @override @@ -908,6 +909,17 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } Future _pathForWalletDir({ diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 70d3e85ed..26ee63983 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2182,6 +2182,17 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2862,6 +2873,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index a0448630b..5caaea47a 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -2349,6 +2349,17 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txns, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txns.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } int estimateTxFee({required int vSize, required int feeRatePerKB}) { @@ -2961,6 +2972,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { ); longMutex = false; + await refresh(); Logging.instance.log("Full rescan complete!", level: LogLevel.Info); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 6c2dfcbb7..d295ac68c 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -244,6 +244,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { var restoreHeight = walletBase?.walletInfo.restoreHeight; highestPercentCached = 0; await walletBase?.rescan(height: restoreHeight); + await refresh(); } @override @@ -977,6 +978,17 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } await addNewTransactionData(txnsData, walletId); + + // quick hack to notify manager to call notifyListeners if + // transactions changed + if (txnsData.isNotEmpty) { + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "Transactions updated/added for: $walletId $walletName ", + walletId, + ), + ); + } } Future _pathForWalletDir({ From 686c897515aad2d92792cd164490193a0e9888c3 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 11:41:59 -0600 Subject: [PATCH 179/192] remove unused param from constructor --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 0b7100190..678d3810c 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -26,7 +26,6 @@ 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/notifications_api.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -1249,7 +1248,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required ElectrumX client, required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, - PriceAPI? priceAPI, required SecureStorageInterface secureStore, }) { txTracker = tracker; From e248a6fd77ab1bc99b9a191089779905cb59663a Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 11:55:40 -0600 Subject: [PATCH 180/192] fix manager tests and update fakecoinservice --- .../services/coins/fake_coin_service_api.dart | 59 +++------ test/services/coins/manager_test.dart | 115 ++++++------------ 2 files changed, 57 insertions(+), 117 deletions(-) diff --git a/test/services/coins/fake_coin_service_api.dart b/test/services/coins/fake_coin_service_api.dart index c5f300c16..37f47fa8e 100644 --- a/test/services/coins/fake_coin_service_api.dart +++ b/test/services/coins/fake_coin_service_api.dart @@ -1,19 +1,11 @@ -import 'package:decimal/decimal.dart'; +import 'package:stackwallet/models/balance.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/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; class FakeCoinServiceAPI extends CoinServiceAPI { - @override - // TODO: implement allOwnAddresses - Future> get allOwnAddresses => throw UnimplementedError(); - - @override - // TODO: implement balanceMinusMaxFee - Future get balanceMinusMaxFee => throw UnimplementedError(); - @override // TODO: implement currentReceivingAddress Future get currentReceivingAddress => throw UnimplementedError(); @@ -32,24 +24,12 @@ class FakeCoinServiceAPI extends CoinServiceAPI { // TODO: implement mnemonic Future> get mnemonic => throw UnimplementedError(); - @override - // TODO: implement pendingBalance - Future get pendingBalance => throw UnimplementedError(); - @override Future refresh() { // TODO: implement refresh throw UnimplementedError(); } - @override - // TODO: implement totalBalance - Future get totalBalance => throw UnimplementedError(); - - @override - // TODO: implement transactionData - Future get transactionData => throw UnimplementedError(); - @override bool validateAddress(String address) { // TODO: implement validateAddress @@ -71,10 +51,6 @@ class FakeCoinServiceAPI extends CoinServiceAPI { throw UnimplementedError(); } - @override - // TODO: implement unspentOutputs - Future> get unspentOutputs => throw UnimplementedError(); - @override bool get isFavorite => throw UnimplementedError(); @@ -84,10 +60,6 @@ class FakeCoinServiceAPI extends CoinServiceAPI { @override late bool shouldAutoSync; - @override - // TODO: implement availableBalance - Future get availableBalance => throw UnimplementedError(); - @override // TODO: implement coin Coin get coin => throw UnimplementedError(); @@ -162,15 +134,6 @@ class FakeCoinServiceAPI extends CoinServiceAPI { throw UnimplementedError(); } - @override - Future send( - {required String toAddress, - required int amount, - Map args = const {}}) { - // TODO: implement send - throw UnimplementedError(); - } - @override Future testNetworkConnection() { // TODO: implement testNetworkConnection @@ -188,4 +151,20 @@ class FakeCoinServiceAPI extends CoinServiceAPI { // TODO: implement updateSentCachedTxData throw UnimplementedError(); } + + @override + // TODO: implement balance + Balance get balance => throw UnimplementedError(); + + @override + // TODO: implement storedChainHeight + int get storedChainHeight => throw UnimplementedError(); + + @override + // TODO: implement transactions + Future> get transactions => throw UnimplementedError(); + + @override + // TODO: implement utxos + Future> get utxos => throw UnimplementedError(); } diff --git a/test/services/coins/manager_test.dart b/test/services/coins/manager_test.dart index 60cab37c0..e3cd7b917 100644 --- a/test/services/coins/manager_test.dart +++ b/test/services/coins/manager_test.dart @@ -1,15 +1,15 @@ -import 'package:decimal/decimal.dart'; 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/models/models.dart'; +import 'package:stackwallet/models/balance.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; +import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'firo/sample_data/transaction_data_samples.dart'; import 'manager_test.mocks.dart'; @GenerateMocks([FiroWallet, ElectrumX]) @@ -28,30 +28,6 @@ void main() { expect(manager.coin, Coin.firo); }); - group("send", () { - test("successful send", () async { - final CoinServiceAPI wallet = MockFiroWallet(); - when(wallet.send(toAddress: "some address", amount: 1987634)) - .thenAnswer((_) async => "some txid"); - - final manager = Manager(wallet); - - expect(await manager.send(toAddress: "some address", amount: 1987634), - "some txid"); - }); - - test("failed send", () { - final CoinServiceAPI wallet = MockFiroWallet(); - when(wallet.send(toAddress: "some address", amount: 1987634)) - .thenThrow(Exception("Tx failed!")); - - final manager = Manager(wallet); - - expect(() => manager.send(toAddress: "some address", amount: 1987634), - throwsA(isA())); - }); - }); - test("fees", () async { final CoinServiceAPI wallet = MockFiroWallet(); when(wallet.fees).thenAnswer((_) async => FeeObject( @@ -98,68 +74,53 @@ void main() { group("get balances", () { test("balance", () async { final CoinServiceAPI wallet = MockFiroWallet(); - when(wallet.availableBalance).thenAnswer((_) async => Decimal.ten); + when(wallet.balance).thenAnswer( + (_) => Balance( + coin: Coin.firo, + total: 10, + spendable: 1, + blockedTotal: 0, + pendingSpendable: 9, + ), + ); final manager = Manager(wallet); - expect(await manager.availableBalance, Decimal.ten); - }); - - test("pendingBalance", () async { - final CoinServiceAPI wallet = MockFiroWallet(); - when(wallet.pendingBalance).thenAnswer((_) async => Decimal.fromInt(23)); - - final manager = Manager(wallet); - - expect(await manager.pendingBalance, Decimal.fromInt(23)); - }); - - test("totalBalance", () async { - final wallet = MockFiroWallet(); - when(wallet.totalBalance).thenAnswer((_) async => Decimal.fromInt(2)); - - final manager = Manager(wallet); - - expect(await manager.totalBalance, Decimal.fromInt(2)); - }); - - test("balanceMinusMaxFee", () async { - final CoinServiceAPI wallet = MockFiroWallet(); - when(wallet.balanceMinusMaxFee).thenAnswer((_) async => Decimal.one); - - final manager = Manager(wallet); - - expect(await manager.balanceMinusMaxFee, Decimal.one); + expect(manager.balance.coin, Coin.firo); + expect(manager.balance.total, 10); + expect(manager.balance.spendable, 1); + expect(manager.balance.blockedTotal, 0); + expect(manager.balance.pendingSpendable, 9); }); }); - test("allOwnAddresses", () async { + test("transactions", () async { final CoinServiceAPI wallet = MockFiroWallet(); - when(wallet.allOwnAddresses) - .thenAnswer((_) async => ["address1", "address2", "address3"]); + final tx = Transaction( + walletId: "walletId", + txid: "txid", + timestamp: 6, + type: TransactionType.incoming, + subType: TransactionSubType.mint, + amount: 123, + fee: 3, + height: 123, + isCancelled: false, + isLelantus: true, + slateId: null, + otherData: null, + ); + when(wallet.transactions).thenAnswer((_) async => [ + tx, + ]); final manager = Manager(wallet); - expect(await manager.allOwnAddresses, ["address1", "address2", "address3"]); - }); + final result = await manager.transactions; - test("transactionData", () async { - final CoinServiceAPI wallet = MockFiroWallet(); - when(wallet.transactionData) - .thenAnswer((_) async => TransactionData.fromJson(dateTimeChunksJson)); + expect(result.length, 1); - final manager = Manager(wallet); - - final expectedMap = - TransactionData.fromJson(dateTimeChunksJson).getAllTransactions(); - final result = (await manager.transactionData).getAllTransactions(); - - expect(result.length, expectedMap.length); - - for (int i = 0; i < expectedMap.length; i++) { - final resultTxid = result.keys.toList(growable: false)[i]; - expect(result[resultTxid].toString(), expectedMap[resultTxid].toString()); - } + expect(result.first, tx); }); test("refresh", () async { From e2b7c07b78ef220c93624a2e4fe7d0b62554d660 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 12:20:27 -0600 Subject: [PATCH 181/192] update transaction card test --- test/widget_tests/transaction_card_test.dart | 149 ++++++++++--------- 1 file changed, 77 insertions(+), 72 deletions(-) diff --git a/test/widget_tests/transaction_card_test.dart b/test/widget_tests/transaction_card_test.dart index f28c5f81d..0ab7e4477 100644 --- a/test/widget_tests/transaction_card_test.dart +++ b/test/widget_tests/transaction_card_test.dart @@ -6,7 +6,8 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockingjay/mockingjay.dart' as mockingjay; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:stackwallet/models/models.dart'; +import 'package:stackwallet/models/isar/models/address/address.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; @@ -47,23 +48,24 @@ void main() { final tx = Transaction( txid: "some txid", - confirmedStatus: true, timestamp: 1648595998, - txType: "Sent", + type: TransactionType.outgoing, amount: 100000000, - aliens: [], - worthNow: "0.01", - worthAtBlockTimestamp: "0.01", - fees: 3794, - inputSize: 1, - outputSize: 1, - inputs: [], - outputs: [], - address: "", + fee: 3794, height: 450123, - subType: "", - confirmations: 10, - isCancelled: false); + subType: TransactionSubType.none, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '') + ..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); final CoinServiceAPI wallet = MockFiroWallet(); @@ -125,7 +127,7 @@ void main() { verify(mockPrefs.currency).called(1); verify(mockPriceService.getPrice(Coin.firo)).called(1); - verify(wallet.coin.ticker).called(1); + verify(wallet.coin.ticker).called(2); verify(mockLocaleService.locale).called(1); @@ -142,23 +144,24 @@ void main() { final tx = Transaction( txid: "some txid", - confirmedStatus: true, timestamp: 1648595998, - txType: "Anonymized", - amount: 100000000, - aliens: [], - worthNow: "0.01", - worthAtBlockTimestamp: "0.01", - fees: 3794, - inputSize: 1, - outputSize: 1, - inputs: [], - outputs: [], - address: "", + type: TransactionType.outgoing, + amount: 9659, + fee: 3794, height: 450123, - subType: "mint", - confirmations: 10, - isCancelled: false); + subType: TransactionSubType.mint, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '') + ..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); final CoinServiceAPI wallet = MockFiroWallet(); @@ -199,7 +202,7 @@ void main() { // final title = find.text("Anonymized"); // final price1 = find.text("0.00 USD"); - final amount = find.text("1.00000000 FIRO"); + final amount = find.text("-0.00009659 FIRO"); final icon = find.byIcon(FeatherIcons.arrowUp); @@ -218,7 +221,7 @@ void main() { verify(mockPrefs.currency).called(1); verify(mockPriceService.getPrice(Coin.firo)).called(1); - verify(wallet.coin.ticker).called(1); + verify(wallet.coin.ticker).called(2); verify(mockLocaleService.locale).called(1); @@ -234,24 +237,25 @@ void main() { final mockPriceService = MockPriceService(); final tx = Transaction( - txid: "some txid", - confirmedStatus: false, - timestamp: 1648595998, - txType: "Received", - amount: 100000000, - aliens: [], - worthNow: "0.01", - worthAtBlockTimestamp: "0.01", - fees: 3794, - inputSize: 1, - outputSize: 1, - inputs: [], - outputs: [], - address: "", - height: 0, - subType: "", - confirmations: 0, - ); + txid: "some txid", + timestamp: 1648595998, + type: TransactionType.incoming, + amount: 100000000, + fee: 3794, + height: 450123, + subType: TransactionSubType.none, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '') + ..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); final CoinServiceAPI wallet = MockFiroWallet(); @@ -289,7 +293,7 @@ void main() { ), ); - final title = find.text("Receiving"); + final title = find.text("Received"); final amount = Util.isDesktop ? find.text("+1.00000000 FIRO") : find.text("1.00000000 FIRO"); @@ -303,7 +307,7 @@ void main() { verify(mockPrefs.currency).called(1); verify(mockPriceService.getPrice(Coin.firo)).called(1); - verify(wallet.coin.ticker).called(1); + verify(wallet.coin.ticker).called(2); verify(mockLocaleService.locale).called(1); @@ -320,24 +324,25 @@ void main() { final navigator = mockingjay.MockNavigator(); final tx = Transaction( - txid: "some txid", - confirmedStatus: false, - timestamp: 1648595998, - txType: "Received", - amount: 100000000, - aliens: [], - worthNow: "0.01", - worthAtBlockTimestamp: "0.01", - fees: 3794, - inputSize: 1, - outputSize: 1, - inputs: [], - outputs: [], - address: "", - height: 250, - subType: "", - confirmations: 10, - ); + txid: "some txid", + timestamp: 1648595998, + type: TransactionType.outgoing, + amount: 100000000, + fee: 3794, + height: 450123, + subType: TransactionSubType.none, + isCancelled: false, + walletId: '', + isLelantus: null, + slateId: '', + otherData: '') + ..address.value = Address( + walletId: "walletId", + value: "", + publicKey: [], + derivationIndex: 0, + type: AddressType.p2pkh, + subType: AddressSubType.receiving); final CoinServiceAPI wallet = MockFiroWallet(); @@ -389,7 +394,7 @@ void main() { verify(mockPrefs.currency).called(2); verify(mockLocaleService.locale).called(4); - verify(wallet.coin.ticker).called(1); + verify(wallet.coin.ticker).called(2); verifyNoMoreInteractions(wallet); verifyNoMoreInteractions(mockLocaleService); From aafca9289ddfd2853c21ca37d45fddd4cb27d148 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 13:07:20 -0600 Subject: [PATCH 182/192] WIP test fixing --- .../coins/bitcoin/bitcoin_wallet_test.dart | 429 ++++++++---------- .../bitcoincash/bitcoincash_wallet_test.dart | 390 ++++++---------- .../coins/dogecoin/dogecoin_wallet_test.dart | 323 +++++-------- .../services/coins/firo/firo_wallet_test.dart | 383 ++-------------- .../coins/namecoin/namecoin_wallet_test.dart | 96 ++-- .../coins/particl/particl_wallet_test.dart | 73 +-- 6 files changed, 503 insertions(+), 1191 deletions(-) diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index e33ffafdf..a2b339ac5 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -3,6 +3,7 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; +import 'package:isar/isar.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; @@ -15,17 +16,17 @@ import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:tuple/tuple.dart'; import 'bitcoin_history_sample_data.dart'; import 'bitcoin_transaction_data_samples.dart'; -import 'bitcoin_utxo_sample_data.dart'; import 'bitcoin_wallet_test.mocks.dart'; import 'bitcoin_wallet_test_parameters.dart'; @GenerateMocks( [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) -void main() { +void main() async { + await Isar.initializeIsarCore(download: true); + group("bitcoin constants", () { test("bitcoin minimum confirmations", () async { expect(MINIMUM_CONFIRMATIONS, 1); @@ -102,7 +103,6 @@ void main() { group("validate testnet bitcoin addresses", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -111,7 +111,6 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -122,7 +121,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -131,20 +129,18 @@ void main() { expect( testnetWallet?.validateAddress("mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("valid testnet bitcoin p2sh-p2wpkh address", () { expect( testnetWallet?.validateAddress("2Mugf9hpSYdQPPLNtWiU2utCi6cM9v5Pnro"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("valid testnet bitcoin p2wpkh address", () { @@ -152,30 +148,27 @@ void main() { testnetWallet ?.validateAddress("tb1qzzlm6mnc8k54mx6akehl8p9ray8r439va5ndyq"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("invalid testnet bitcoin legacy/p2pkh address", () { expect( testnetWallet?.validateAddress("16YB85zQHjro7fqjR2hMcwdQWCX8jNVtr5"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("invalid testnet bitcoin p2sh-p2wpkh address", () { expect( testnetWallet?.validateAddress("3Ns8HuQmkyyKnVixk2yQtG7pN3GcJ6xctk"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("invalid testnet bitcoin p2wpkh address", () { @@ -183,17 +176,15 @@ void main() { testnetWallet ?.validateAddress("bc1qc5ymmsay89r6gr4fy2kklvrkuvzyln4shdvjhf"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); group("validate mainnet bitcoin addresses", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -202,7 +193,6 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -213,7 +203,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -223,11 +212,10 @@ void main() { mainnetWallet?.addressType( address: "16YB85zQHjro7fqjR2hMcwdQWCX8jNVtr5"), DerivePathType.bip44); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet p2sh-p2wpkh address type", () { @@ -235,11 +223,10 @@ void main() { mainnetWallet?.addressType( address: "3Ns8HuQmkyyKnVixk2yQtG7pN3GcJ6xctk"), DerivePathType.bip49); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet bech32 p2wpkh address type", () { @@ -247,11 +234,10 @@ void main() { mainnetWallet?.addressType( address: "bc1qc5ymmsay89r6gr4fy2kklvrkuvzyln4shdvjhf"), DerivePathType.bip84); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid base58 address type", () { @@ -259,11 +245,10 @@ void main() { () => mainnetWallet?.addressType( address: "mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid bech32 address type", () { @@ -271,11 +256,10 @@ void main() { () => mainnetWallet?.addressType( address: "tb1qzzlm6mnc8k54mx6akehl8p9ray8r439va5ndyq"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("address has no matching script", () { @@ -283,33 +267,30 @@ void main() { () => mainnetWallet?.addressType( address: "mpMk94ETazqonHutyC1v6ajshgtP8oiFKU"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet bitcoin legacy/p2pkh address", () { expect( mainnetWallet?.validateAddress("16YB85zQHjro7fqjR2hMcwdQWCX8jNVtr5"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet bitcoin p2sh-p2wpkh address", () { expect( mainnetWallet?.validateAddress("3Ns8HuQmkyyKnVixk2yQtG7pN3GcJ6xctk"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet bitcoin p2wpkh address", () { @@ -317,33 +298,30 @@ void main() { mainnetWallet ?.validateAddress("bc1qc5ymmsay89r6gr4fy2kklvrkuvzyln4shdvjhf"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid mainnet bitcoin legacy/p2pkh address", () { expect( mainnetWallet?.validateAddress("mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid mainnet bitcoin p2sh-p2wpkh address", () { expect( mainnetWallet?.validateAddress("2Mugf9hpSYdQPPLNtWiU2utCi6cM9v5Pnro"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid mainnet bitcoin p2wpkh address", () { @@ -351,18 +329,17 @@ void main() { mainnetWallet ?.validateAddress("tb1qzzlm6mnc8k54mx6akehl8p9ray8r439va5ndyq"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("testNetworkConnection", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -371,7 +348,7 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -382,7 +359,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -391,43 +367,40 @@ void main() { when(client?.ping()).thenAnswer((_) async => false); final bool? result = await btc?.testNetworkConnection(); expect(result, false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection fails due to exception", () async { when(client?.ping()).thenThrow(Exception); final bool? result = await btc?.testNetworkConnection(); expect(result, false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection test success", () async { when(client?.ping()).thenAnswer((_) async => true); final bool? result = await btc?.testNetworkConnection(); expect(result, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); group("basic getters, setters, and functions", () { - final testWalletId = "BTCtestWalletID"; - final testWalletName = "BTCWallet"; + const testWalletId = "BTCtestWalletID"; + const testWalletName = "BTCWallet"; MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -436,7 +409,7 @@ void main() { setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -447,17 +420,15 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); test("get networkType main", () async { expect(Coin.bitcoin, Coin.bitcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get networkType test", () async { @@ -468,48 +439,42 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); expect(Coin.bitcoinTestNet, Coin.bitcoinTestNet); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get cryptoCurrency", () async { expect(Coin.bitcoin, Coin.bitcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get coinName", () async { expect(Coin.bitcoin, Coin.bitcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get coinTicker", () async { expect(Coin.bitcoin, Coin.bitcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get and set walletName", () async { expect(Coin.bitcoin, Coin.bitcoin); btc?.walletName = "new name"; expect(btc?.walletName, "new name"); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("estimateTxFee", () async { @@ -521,10 +486,9 @@ void main() { expect(btc?.estimateTxFee(vSize: 356, feeRatePerKB: 1699), 712); expect(btc?.estimateTxFee(vSize: 356, feeRatePerKB: 2000), 712); expect(btc?.estimateTxFee(vSize: 356, feeRatePerKB: 12345), 4628); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get fees succeeds", () async { @@ -555,10 +519,9 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get fees fails", () async { @@ -592,10 +555,9 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("get maxFee", () async { @@ -627,19 +589,19 @@ void main() { // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); // verifyNoMoreInteractions(tracker); - // verifyNoMoreInteractions(priceAPI); + // // }); }); group("Bitcoin service class functions that depend on shared storage", () { - final testWalletId = "BTCtestWalletID"; - final testWalletName = "BTCWallet"; + const testWalletId = "BTCtestWalletID"; + const testWalletName = "BTCWallet"; bool hiveAdaptersRegistered = false; MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -662,13 +624,13 @@ void main() { Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -679,7 +641,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -691,7 +652,7 @@ void main() { // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeWallet no network exception", () async { @@ -702,7 +663,7 @@ void main() { // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test("initializeWallet mainnet throws bad network", () async { @@ -718,16 +679,16 @@ void main() { "services": [] }); // await btc?.initializeNew(); - final wallets = await Hive.openBox(testWalletId); + final wallets = await Hive.openBox(testWalletId); - expectLater(() => btc?.initializeExisting(), throwsA(isA())) + await expectLater( + () => btc?.initializeExisting(), throwsA(isA())) .then((_) { - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); // verify(client?.ping()).called(1); // verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -743,18 +704,17 @@ void main() { "hash_function": "sha256", "services": [] }); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); final wallets = await Hive.openBox(testWalletId); expectLater(() => btc?.initializeExisting(), throwsA(isA())) .then((_) { - expect(secureStore?.interactions, 1); + expect(secureStore.interactions, 1); // verify(client?.ping()).called(1); // verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -778,7 +738,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // @@ -789,7 +749,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // }); @@ -839,7 +799,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("initializeWallet new main net wallet", () async { @@ -922,7 +882,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("initializeWallet existing main net wallet", () async { @@ -996,7 +956,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // @@ -1063,7 +1023,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // // test("get fiatPrice", () async { @@ -1074,7 +1034,7 @@ void main() { // // verify(priceAPI.getBitcoinPrice(baseCurrency: "USD")).called(1); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); // // test("get current receiving addresses", () async { @@ -1085,7 +1045,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1116,7 +1076,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("get allOwnAddresses", () async { @@ -1127,7 +1087,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1154,7 +1114,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("get utxos and balances", () async { @@ -1165,7 +1125,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1266,7 +1226,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("get utxos - multiple batches", () async { @@ -1277,7 +1237,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1331,7 +1291,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("get utxos fails", () async { @@ -1342,7 +1302,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1376,7 +1336,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("chain height fetch, update, and get", () async { @@ -1387,7 +1347,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1428,7 +1388,7 @@ void main() { // verify(client?.getBlockHeadTip()).called(2); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("fetch and update useBiometrics", () async { @@ -1444,7 +1404,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("getTxCount succeeds", () async { @@ -1477,7 +1437,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("getTxCount fails", () async { @@ -1502,7 +1462,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { @@ -1551,7 +1511,7 @@ void main() { // expect(secureStore?.deletes, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("_checkCurrentReceivingAddressesForTransactions fails", () async { @@ -1591,7 +1551,7 @@ void main() { // expect(secureStore?.deletes, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("_checkCurrentChangeAddressesForTransactions succeeds", () async { @@ -1640,7 +1600,7 @@ void main() { // expect(secureStore?.deletes, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("_checkCurrentChangeAddressesForTransactions fails", () async { @@ -1678,7 +1638,7 @@ void main() { // expect(secureStore?.deletes, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("getAllTxsToWatch", () async { @@ -1706,7 +1666,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData true A", () async { @@ -1726,7 +1686,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1763,7 +1723,7 @@ void main() { // expect(secureStore.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData true B", () async { @@ -1864,7 +1824,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1904,7 +1864,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData false A", () async { @@ -2005,7 +1965,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -2045,7 +2005,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("refreshIfThereIsNewData false B", () async { @@ -2064,7 +2024,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -2101,7 +2061,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test( @@ -2132,10 +2092,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test( @@ -2148,7 +2107,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -2176,10 +2134,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test( @@ -2196,7 +2153,7 @@ void main() { "services": [] }); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic words"); bool hasThrown = false; @@ -2213,10 +2170,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 2); + expect(secureStore.interactions, 2); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { @@ -2264,14 +2220,13 @@ void main() { verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - expect(secureStore?.interactions, 20); - expect(secureStore?.writes, 7); - expect(secureStore?.reads, 13); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 20); + expect(secureStore.writes, 7); + expect(secureStore.reads, 13); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get mnemonic list", () async { @@ -2318,7 +2273,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using non empty seed on mainnet succeeds", @@ -2387,14 +2341,13 @@ void main() { true); } - expect(secureStore?.interactions, 14); - expect(secureStore?.writes, 7); - expect(secureStore?.reads, 7); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 14); + expect(secureStore.writes, 7); + expect(secureStore.reads, 7); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan succeeds", () async { @@ -2481,17 +2434,17 @@ void main() { final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore?.read( + final preReceiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = await secureStore?.read( - key: "${testWalletId}_receiveDerivationsP2SH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final preReceiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); final preChangeDerivationsStringP2SH = - await secureStore?.read(key: "${testWalletId}_changeDerivationsP2SH"); - final preReceiveDerivationsStringP2WPKH = await secureStore?.read( + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final preReceiveDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore?.read( + final preChangeDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_changeDerivationsP2WPKH"); // destroy the data that the rescan will fix @@ -2513,17 +2466,17 @@ void main() { await wallet.put('changeIndexP2PKH', 123); await wallet.put('changeIndexP2SH', 123); await wallet.put('changeIndexP2WPKH', 123); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); bool hasThrown = false; @@ -2550,17 +2503,17 @@ void main() { final changeIndexP2SH = await wallet.get('changeIndexP2SH'); final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore?.read( + final receiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = await secureStore?.read( - key: "${testWalletId}_receiveDerivationsP2SH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final receiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); final changeDerivationsStringP2SH = - await secureStore?.read(key: "${testWalletId}_changeDerivationsP2SH"); - final receiveDerivationsStringP2WPKH = await secureStore?.read( + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final receiveDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore?.read( + final changeDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_changeDerivationsP2WPKH"); expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); @@ -2624,13 +2577,12 @@ void main() { ] })).called(2); - expect(secureStore?.writes, 25); - expect(secureStore?.reads, 32); - expect(secureStore?.deletes, 6); + expect(secureStore.writes, 25); + expect(secureStore.reads, 32); + expect(secureStore.deletes, 6); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan fails", () async { @@ -2718,17 +2670,17 @@ void main() { final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore?.read( + final preReceiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = await secureStore?.read( - key: "${testWalletId}_receiveDerivationsP2SH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final preReceiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); final preChangeDerivationsStringP2SH = - await secureStore?.read(key: "${testWalletId}_changeDerivationsP2SH"); - final preReceiveDerivationsStringP2WPKH = await secureStore?.read( + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final preReceiveDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore?.read( + final preChangeDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_changeDerivationsP2WPKH"); when(client?.getBatchHistory(args: historyBatchArgs0)) @@ -2758,17 +2710,17 @@ void main() { final changeIndexP2SH = await wallet.get('changeIndexP2SH'); final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore?.read( + final receiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = await secureStore?.read( - key: "${testWalletId}_receiveDerivationsP2SH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final receiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); final changeDerivationsStringP2SH = - await secureStore?.read(key: "${testWalletId}_changeDerivationsP2SH"); - final receiveDerivationsStringP2WPKH = await secureStore?.read( + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final receiveDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore?.read( + final changeDerivationsStringP2WPKH = await secureStore.read( key: "${testWalletId}_changeDerivationsP2WPKH"); expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); @@ -2832,13 +2784,12 @@ void main() { ] })).called(1); - expect(secureStore?.writes, 19); - expect(secureStore?.reads, 32); - expect(secureStore?.deletes, 12); + expect(secureStore.writes, 19); + expect(secureStore.reads, 32); + expect(secureStore.deletes, 12); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("fetchBuildTxData succeeds", () async { @@ -3040,7 +2991,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("fetchBuildTxData throws", () async { @@ -3120,7 +3071,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("build transaction succeeds", () async { @@ -3225,7 +3176,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("build transaction fails", () async { @@ -3336,7 +3287,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("two output coinSelection succeeds", () async { @@ -3441,7 +3392,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("one output option A coinSelection", () async { @@ -3545,7 +3496,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("one output option B coinSelection", () async { @@ -3649,7 +3600,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("insufficient funds option A coinSelection", () async { @@ -3712,7 +3663,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("insufficient funds option B coinSelection", () async { @@ -3775,7 +3726,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("insufficient funds option C coinSelection", () async { @@ -3874,7 +3825,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("check for more outputs coinSelection", () async { @@ -3980,7 +3931,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("prepareSend and confirmSend succeed", () async { @@ -4097,7 +4048,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test("prepareSend fails", () async { @@ -4161,27 +4112,27 @@ void main() { height: 4000); // modify addresses to properly mock data to build a tx - final rcv44 = await secureStore?.read( + final rcv44 = await secureStore.read( key: testWalletId + "_receiveDerivationsP2PKH"); - await secureStore?.write( + await secureStore.write( key: testWalletId + "_receiveDerivationsP2PKH", value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); - final rcv49 = await secureStore?.read( - key: testWalletId + "_receiveDerivationsP2SH"); - await secureStore?.write( + final rcv49 = + await secureStore.read(key: testWalletId + "_receiveDerivationsP2SH"); + await secureStore.write( key: testWalletId + "_receiveDerivationsP2SH", value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); - final rcv84 = await secureStore?.read( + final rcv84 = await secureStore.read( key: testWalletId + "_receiveDerivationsP2WPKH"); - await secureStore?.write( + await secureStore.write( key: testWalletId + "_receiveDerivationsP2WPKH", value: rcv84?.replaceFirst( "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); - btc?.outputsList = utxoList; + // btc?.outputsList = utxoList; bool didThrow = false; try { @@ -4231,14 +4182,13 @@ void main() { true); } - expect(secureStore?.interactions, 20); - expect(secureStore?.writes, 10); - expect(secureStore?.reads, 10); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 20); + expect(secureStore.writes, 10); + expect(secureStore.reads, 10); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend no hex", () async { @@ -4251,10 +4201,9 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend hex is not string", () async { @@ -4267,10 +4216,9 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend hex is string but missing other data", () async { @@ -4287,10 +4235,9 @@ void main() { rawTx: "a string", requestID: anyNamed("requestID"))) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails due to vSize being greater than fee", () async { @@ -4308,10 +4255,9 @@ void main() { rawTx: "a string", requestID: anyNamed("requestID"))) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails when broadcast transactions throws", () async { @@ -4333,11 +4279,10 @@ void main() { rawTx: "a string", requestID: anyNamed("requestID"))) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); // // // this test will create a non mocked electrumx client that will try to connect @@ -4350,7 +4295,7 @@ void main() { // // networkType: BasicNetworkType.test, // // client: client, // // cachedClient: cachedClient, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // @@ -4386,7 +4331,7 @@ void main() { // // expect(secureStore.interactions, 0); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); test("refresh wallet mutex locked", () async { @@ -4453,15 +4398,14 @@ void main() { true); } - expect(secureStore?.interactions, 14); - expect(secureStore?.writes, 7); - expect(secureStore?.reads, 7); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 14); + expect(secureStore.writes, 7); + expect(secureStore.reads, 7); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("refresh wallet normally", () async { @@ -4482,9 +4426,6 @@ void main() { when(client?.estimateFee(blocks: anyNamed("blocks"))) .thenAnswer((_) async => Decimal.one); - when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")) - .thenAnswer((_) async => {Coin.bitcoin: Tuple2(Decimal.one, 0.3)}); - final List dynamicArgValues = []; when(client?.getBatchHistory(args: anyNamed("args"))) @@ -4513,7 +4454,6 @@ void main() { verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); verify(client?.getBlockHeadTip()).called(1); - verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2); for (final arg in dynamicArgValues) { final map = Map>.from(arg as Map); @@ -4521,14 +4461,13 @@ void main() { verify(client?.getBatchHistory(args: map)).called(1); } - expect(secureStore?.interactions, 14); - expect(secureStore?.writes, 7); - expect(secureStore?.reads, 7); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 14); + expect(secureStore.writes, 7); + expect(secureStore.reads, 7); + expect(secureStore.deletes, 0); // verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); tearDown(() async { diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index e469662dd..3b6cc47f4 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -63,7 +63,6 @@ void main() { group("mainnet bitcoincash addressType", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -72,7 +71,6 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -83,7 +81,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -93,11 +90,10 @@ void main() { mainnetWallet?.addressType( address: "1DP3PUePwMa5CoZwzjznVKhzdLsZftjcAT"), DerivePathType.bip44); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid base58 address type", () { @@ -105,11 +101,10 @@ void main() { () => mainnetWallet?.addressType( address: "mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid bech32 address type", () { @@ -117,11 +112,10 @@ void main() { () => mainnetWallet?.addressType( address: "tb1qzzlm6mnc8k54mx6akehl8p9ray8r439va5ndyq"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("address has no matching script", () { @@ -129,11 +123,10 @@ void main() { () => mainnetWallet?.addressType( address: "mpMk94ETazqonHutyC1v6ajshgtP8oiFKU"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("P2PKH cashaddr with prefix", () { @@ -142,11 +135,10 @@ void main() { address: "bitcoincash:qrwjyc4pewj9utzrtnh0whkzkuvy5q8wg52n254x6k"), DerivePathType.bip44); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("P2PKH cashaddr without prefix", () { @@ -154,11 +146,10 @@ void main() { mainnetWallet?.addressType( address: "qrwjyc4pewj9utzrtnh0whkzkuvy5q8wg52n254x6k"), DerivePathType.bip44); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("Multisig cashaddr with prefix", () { @@ -167,11 +158,10 @@ void main() { address: "bitcoincash:pzpp3nchmzzf0gr69lj82ymurg5u3ds6kcwr5m07np"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("Multisig cashaddr without prefix", () { @@ -179,11 +169,10 @@ void main() { () => mainnetWallet?.addressType( address: "pzpp3nchmzzf0gr69lj82ymurg5u3ds6kcwr5m07np"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("Multisig/P2SH address", () { @@ -191,18 +180,17 @@ void main() { mainnetWallet?.addressType( address: "3DYuVEmuKWQFxJcF7jDPhwPiXLTiNnyMFb"), DerivePathType.bip49); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("validate mainnet bitcoincash addresses", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -211,7 +199,7 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -222,7 +210,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -231,11 +218,10 @@ void main() { expect( mainnetWallet?.validateAddress("1DP3PUePwMa5CoZwzjznVKhzdLsZftjcAT"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet legacy/p2pkh cashaddr with prefix address type", () { @@ -243,11 +229,10 @@ void main() { mainnetWallet?.validateAddress( "bitcoincash:qrwjyc4pewj9utzrtnh0whkzkuvy5q8wg52n254x6k"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet legacy/p2pkh cashaddr without prefix address type", () { @@ -255,22 +240,20 @@ void main() { mainnetWallet ?.validateAddress("qrwjyc4pewj9utzrtnh0whkzkuvy5q8wg52n254x6k"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid legacy/p2pkh address type", () { expect( mainnetWallet?.validateAddress("mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test( @@ -280,40 +263,37 @@ void main() { mainnetWallet ?.validateAddress("pzpp3nchmzzf0gr69lj82ymurg5u3ds6kcwr5m07np"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("multisig address should fail for bitbox", () { expect( mainnetWallet?.validateAddress("3DYuVEmuKWQFxJcF7jDPhwPiXLTiNnyMFb"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid mainnet bitcoincash legacy/p2pkh address", () { expect( mainnetWallet?.validateAddress("mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("testNetworkConnection", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -322,7 +302,7 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -333,7 +313,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -342,47 +321,44 @@ void main() { when(client?.ping()).thenAnswer((_) async => false); final bool? result = await bch?.testNetworkConnection(); expect(result, false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection fails due to exception", () async { when(client?.ping()).thenThrow(Exception); final bool? result = await bch?.testNetworkConnection(); expect(result, false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection test success", () async { when(client?.ping()).thenAnswer((_) async => true); final bool? result = await bch?.testNetworkConnection(); expect(result, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("basic getters, setters, and functions", () { - final bchcoin = Coin.bitcoincash; - final testWalletId = "BCHtestWalletID"; - final testWalletName = "BCHWallet"; + const bchcoin = Coin.bitcoincash; + const testWalletId = "BCHtestWalletID"; + const testWalletName = "BCHWallet"; MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -391,7 +367,7 @@ void main() { setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -402,18 +378,16 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); test("get networkType main", () async { expect(bch?.coin, bchcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get networkType test", () async { @@ -424,53 +398,47 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); expect(bch?.coin, bchcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get cryptoCurrency", () async { expect(Coin.bitcoincash, Coin.bitcoincash); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get coinName", () async { expect(Coin.bitcoincash, Coin.bitcoincash); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get coinTicker", () async { expect(Coin.bitcoincash, Coin.bitcoincash); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get and set walletName", () async { expect(Coin.bitcoincash, Coin.bitcoincash); bch?.walletName = "new name"; expect(bch?.walletName, "new name"); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("estimateTxFee", () async { @@ -482,11 +450,10 @@ void main() { expect(bch?.estimateTxFee(vSize: 356, feeRatePerKB: 1699), 712); expect(bch?.estimateTxFee(vSize: 356, feeRatePerKB: 2000), 712); expect(bch?.estimateTxFee(vSize: 356, feeRatePerKB: 12345), 4628); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get fees succeeds", () async { @@ -517,11 +484,10 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get fees fails", () async { @@ -555,11 +521,10 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get maxFee", () async { @@ -587,25 +552,24 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("BCHWallet service class functions that depend on shared storage", () { - final bchcoin = Coin.bitcoincash; - final bchtestcoin = Coin.bitcoincashTestnet; - final testWalletId = "BCHtestWalletID"; - final testWalletName = "BCHWallet"; + const bchcoin = Coin.bitcoincash; + const bchtestcoin = Coin.bitcoincashTestnet; + const testWalletId = "BCHtestWalletID"; + const testWalletName = "BCHWallet"; bool hiveAdaptersRegistered = false; MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -634,7 +598,7 @@ void main() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -645,7 +609,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -659,7 +622,7 @@ void main() { // verify(client?.ping()).called(0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeExisting no network exception", () async { @@ -670,7 +633,7 @@ void main() { // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeNew mainnet throws bad network", () async { @@ -695,7 +658,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // }); @@ -710,20 +673,19 @@ void main() { "hash_function": "sha256", "services": [] }); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); await Hive.openBox(testWalletId); await Hive.openBox(DB.boxNamePrefs); - expectLater(() => bch?.initializeNew(), throwsA(isA())) + await expectLater(() => bch?.initializeNew(), throwsA(isA())) .then((_) { - expect(secureStore?.interactions, 2); + expect(secureStore.interactions, 2); verifyNever(client?.ping()).called(0); verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -747,7 +709,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // @@ -761,7 +723,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // }); @@ -812,7 +774,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeWallet new main net wallet", () async { @@ -866,7 +828,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("initializeWallet existing main net wallet", () async { @@ -920,7 +882,7 @@ void main() { // // coin: dtestcoin, // // client: client!, // // cachedClient: cachedClient!, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // @@ -961,7 +923,7 @@ void main() { // // verify(client?.getServerFeatures()).called(1); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); test("get current receiving addresses", () async { @@ -972,7 +934,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.ping()).thenAnswer((_) async => true); @@ -1000,50 +961,6 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); - }); - - test("get allOwnAddresses", () async { - bch = BitcoinCashWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: bchtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - priceAPI: priceAPI, - secureStore: secureStore, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - final addresses = await bch?.allOwnAddresses; - expect(addresses, isA>()); - expect(addresses?.length, 2); - - for (int i = 0; i < 2; i++) { - expect(bch?.validateAddress(addresses![i]), true); - } - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("get utxos and balances", () async { @@ -1054,7 +971,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1148,7 +1065,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // // test("get utxos - multiple batches", () async { @@ -1158,7 +1075,7 @@ void main() { // // coin: dtestcoin, // // client: client!, // // cachedClient: cachedClient!, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // when(client?.ping()).thenAnswer((_) async => true); @@ -1211,7 +1128,7 @@ void main() { // // // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); // test("get utxos fails", () async { @@ -1222,7 +1139,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.ping()).thenAnswer((_) async => true); @@ -1261,7 +1177,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("chain height fetch, update, and get", () async { @@ -1272,7 +1187,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.ping()).thenAnswer((_) async => true); @@ -1319,7 +1233,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("getTxCount succeeds", () async { @@ -1349,11 +1262,10 @@ void main() { "1df1cab6d109d506aa424b00b6a013c5e1947dc13b78d62b4d0e9f518b3035d1")) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); //TODO - Needs refactoring test("getTxCount fails", () async { @@ -1375,11 +1287,10 @@ void main() { "64953f7db441a21172de206bf70b920c8c718ed4f03df9a85073c0400be0053c")) .called(0); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { @@ -1426,13 +1337,12 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 20); - expect(secureStore?.reads, 13); - expect(secureStore?.writes, 7); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 20); + expect(secureStore.reads, 13); + expect(secureStore.writes, 7); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentReceivingAddressesForTransactions fails", () async { @@ -1468,13 +1378,12 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 14); - expect(secureStore?.reads, 9); - expect(secureStore?.writes, 5); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 14); + expect(secureStore.reads, 9); + expect(secureStore.writes, 5); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentChangeAddressesForTransactions succeeds", () async { @@ -1521,14 +1430,13 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 20); - expect(secureStore?.reads, 13); - expect(secureStore?.writes, 7); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 20); + expect(secureStore.reads, 13); + expect(secureStore.writes, 7); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentChangeAddressesForTransactions fails", () async { @@ -1564,13 +1472,12 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 14); - expect(secureStore?.reads, 9); - expect(secureStore?.writes, 5); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 14); + expect(secureStore.reads, 9); + expect(secureStore.writes, 5); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("getAllTxsToWatch", () async { @@ -1598,7 +1505,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData true A", () async { @@ -1617,7 +1524,7 @@ void main() { // coin: dtestcoin, // client: client!, // cachedClient: cachedClient!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1646,7 +1553,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData true B", () async { @@ -1746,7 +1653,7 @@ void main() { // coin: dtestcoin, // client: client!, // cachedClient: cachedClient!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1778,7 +1685,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("refreshIfThereIsNewData false A", () async { @@ -1879,7 +1786,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1912,7 +1819,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData false B", () async { @@ -1931,7 +1838,7 @@ void main() { // // client: client!, // // cachedClient: cachedClient!, // // tracker: tracker!, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // final wallet = await Hive.openBox(testWalletId); @@ -1956,7 +1863,7 @@ void main() { // // expect(secureStore?.interactions, 0); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); test("get mnemonic list", () async { @@ -2006,7 +1913,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test( @@ -2037,10 +1943,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test( @@ -2053,7 +1958,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -2081,10 +1985,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test( @@ -2101,7 +2004,7 @@ void main() { "services": [] }); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic words"); bool hasThrown = false; @@ -2118,10 +2021,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 2); + expect(secureStore.interactions, 2); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using non empty seed on mainnet succeeds", @@ -2185,15 +2087,14 @@ void main() { true); } - expect(secureStore?.interactions, 10); - expect(secureStore?.writes, 5); - expect(secureStore?.reads, 5); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 10); + expect(secureStore.writes, 5); + expect(secureStore.reads, 5); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan succeeds", () async { @@ -2262,15 +2163,15 @@ void main() { final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore?.read( + final preReceiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = await secureStore?.read( - key: "${testWalletId}_receiveDerivationsP2SH"); + final preReceiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); final preChangeDerivationsStringP2SH = - await secureStore?.read(key: "${testWalletId}_changeDerivationsP2SH"); + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); // destroy the data that the rescan will fix await wallet.put( @@ -2289,14 +2190,14 @@ void main() { await wallet.put('receivingIndexP2SH', 123); await wallet.put('changeIndexP2SH', 123); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); bool hasThrown = false; @@ -2320,15 +2221,15 @@ void main() { final changeIndexP2SH = await wallet.get('changeIndexP2SH'); final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore?.read( + final receiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = await secureStore?.read( - key: "${testWalletId}_receiveDerivationsP2SH"); + final receiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); final changeDerivationsStringP2SH = - await secureStore?.read(key: "${testWalletId}_changeDerivationsP2SH"); + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); expect(preChangeAddressesP2PKH, changeAddressesP2PKH); @@ -2377,14 +2278,13 @@ void main() { ] })).called(2); - expect(secureStore?.writes, 17); - expect(secureStore?.reads, 22); - expect(secureStore?.deletes, 4); + expect(secureStore.writes, 17); + expect(secureStore.reads, 22); + expect(secureStore.deletes, 4); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan fails", () async { @@ -2448,10 +2348,10 @@ void main() { final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore?.read( + final preReceiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenThrow(Exception("fake exception")); @@ -2472,10 +2372,10 @@ void main() { final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore?.read( + final receiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); expect(preChangeAddressesP2PKH, changeAddressesP2PKH); @@ -2514,9 +2414,9 @@ void main() { ] })).called(2); - expect(secureStore?.writes, 13); - expect(secureStore?.reads, 18); - expect(secureStore?.deletes, 8); + expect(secureStore.writes, 13); + expect(secureStore.reads, 18); + expect(secureStore.deletes, 8); }); // // test("fetchBuildTxData succeeds", () async { @@ -2693,7 +2593,7 @@ void main() { // // // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); // test("fetchBuildTxData throws", () async { @@ -2774,7 +2674,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("build transaction succeeds", () async { @@ -2867,7 +2767,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test("confirmSend error 1", () async { @@ -2880,11 +2780,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend error 2", () async { @@ -2897,11 +2796,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend some other error code", () async { @@ -2914,11 +2812,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend no hex", () async { @@ -2931,11 +2828,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails due to vSize being greater than fee", () async { @@ -2953,11 +2849,10 @@ void main() { rawTx: "a string", requestID: anyNamed("requestID"))) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails when broadcast transactions throws", () async { @@ -2979,11 +2874,10 @@ void main() { rawTx: "a string", requestID: anyNamed("requestID"))) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("refresh wallet mutex locked", () async { @@ -3065,15 +2959,14 @@ void main() { ] })).called(1); - expect(secureStore?.interactions, 10); - expect(secureStore?.writes, 5); - expect(secureStore?.reads, 5); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 10); + expect(secureStore.writes, 5); + expect(secureStore.reads, 5); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("refresh wallet throws", () async { @@ -3162,15 +3055,14 @@ void main() { verify(client?.getBlockHeadTip()).called(1); verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - expect(secureStore?.interactions, 10); - expect(secureStore?.writes, 5); - expect(secureStore?.reads, 5); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 10); + expect(secureStore.writes, 5); + expect(secureStore.reads, 5); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); // test("refresh wallet normally", () async { @@ -3231,7 +3123,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); }); diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index ac863bd2a..d003e39a7 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -96,7 +96,6 @@ void main() { group("validate mainnet dogecoin addresses", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -105,7 +104,6 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -116,7 +114,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -126,11 +123,10 @@ void main() { mainnetWallet?.addressType( address: "DBYiFr1BRc2zB19p8jxdSu6DvFGTdWvkVF"), DerivePathType.bip44); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid base58 address type", () { @@ -138,11 +134,10 @@ void main() { () => mainnetWallet?.addressType( address: "mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid bech32 address type", () { @@ -150,11 +145,10 @@ void main() { () => mainnetWallet?.addressType( address: "tb1qzzlm6mnc8k54mx6akehl8p9ray8r439va5ndyq"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("address has no matching script", () { @@ -162,40 +156,37 @@ void main() { () => mainnetWallet?.addressType( address: "mpMk94ETazqonHutyC1v6ajshgtP8oiFKU"), throwsArgumentError); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet dogecoin legacy/p2pkh address", () { expect( mainnetWallet?.validateAddress("DBYiFr1BRc2zB19p8jxdSu6DvFGTdWvkVF"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid mainnet dogecoin legacy/p2pkh address", () { expect( mainnetWallet?.validateAddress("mhqpGtwhcR6gFuuRjLTpHo41919QfuGy8Y"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("testNetworkConnection", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -204,7 +195,6 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -215,7 +205,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -224,36 +213,33 @@ void main() { when(client?.ping()).thenAnswer((_) async => false); final bool? result = await doge?.testNetworkConnection(); expect(result, false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection fails due to exception", () async { when(client?.ping()).thenThrow(Exception); final bool? result = await doge?.testNetworkConnection(); expect(result, false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection test success", () async { when(client?.ping()).thenAnswer((_) async => true); final bool? result = await doge?.testNetworkConnection(); expect(result, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); @@ -265,7 +251,7 @@ void main() { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -274,7 +260,7 @@ void main() { setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -285,18 +271,16 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); test("get networkType main", () async { expect(doge?.coin, dcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get networkType test", () async { @@ -307,53 +291,47 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); expect(doge?.coin, dtestcoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get cryptoCurrency", () async { expect(Coin.dogecoin, Coin.dogecoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get coinName", () async { expect(Coin.dogecoin, Coin.dogecoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get coinTicker", () async { expect(Coin.dogecoin, Coin.dogecoin); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get and set walletName", () async { expect(Coin.dogecoin, Coin.dogecoin); doge?.walletName = "new name"; expect(doge?.walletName, "new name"); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("estimateTxFee", () async { @@ -365,11 +343,10 @@ void main() { expect(doge?.estimateTxFee(vSize: 356, feeRatePerKB: 1699), 712); expect(doge?.estimateTxFee(vSize: 356, feeRatePerKB: 2000), 712); expect(doge?.estimateTxFee(vSize: 356, feeRatePerKB: 12345), 4628); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get fees succeeds", () async { @@ -400,11 +377,10 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get fees fails", () async { @@ -438,11 +414,10 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("get maxFee", () async { @@ -470,11 +445,10 @@ void main() { verify(client?.estimateFee(blocks: 1)).called(1); verify(client?.estimateFee(blocks: 5)).called(1); verify(client?.estimateFee(blocks: 20)).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); @@ -488,7 +462,7 @@ void main() { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -517,7 +491,7 @@ void main() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -528,7 +502,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -542,7 +515,7 @@ void main() { // verify(client?.ping()).called(0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeExisting no network exception", () async { @@ -553,7 +526,7 @@ void main() { // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeNew mainnet throws bad network", () async { @@ -578,7 +551,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // }); @@ -593,7 +566,7 @@ void main() { "hash_function": "sha256", "services": [] }); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); await Hive.openBox(testWalletId); @@ -601,12 +574,11 @@ void main() { expectLater(() => doge?.initializeNew(), throwsA(isA())) .then((_) { - expect(secureStore?.interactions, 2); + expect(secureStore.interactions, 2); verifyNever(client?.ping()).called(0); verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -630,7 +602,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // @@ -644,7 +616,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // }); @@ -695,7 +667,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeWallet new main net wallet", () async { @@ -749,7 +721,7 @@ void main() { // verify(client?.getServerFeatures()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("initializeWallet existing main net wallet", () async { @@ -803,7 +775,7 @@ void main() { // // coin: dtestcoin, // // client: client!, // // cachedClient: cachedClient!, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // @@ -844,7 +816,7 @@ void main() { // // verify(client?.getServerFeatures()).called(1); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); test("get current receiving addresses", () async { @@ -855,7 +827,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.ping()).thenAnswer((_) async => true); @@ -892,50 +863,6 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); - }); - - test("get allOwnAddresses", () async { - doge = DogecoinWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: dtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - priceAPI: priceAPI, - secureStore: secureStore, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - final addresses = await doge?.allOwnAddresses; - expect(addresses, isA>()); - expect(addresses?.length, 2); - - for (int i = 0; i < 2; i++) { - expect(Address.validateAddress(addresses![i], dogecointestnet), true); - } - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("get utxos and balances", () async { @@ -946,7 +873,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // when(client?.ping()).thenAnswer((_) async => true); @@ -1040,7 +967,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // // test("get utxos - multiple batches", () async { @@ -1050,7 +977,7 @@ void main() { // // coin: dtestcoin, // // client: client!, // // cachedClient: cachedClient!, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // when(client?.ping()).thenAnswer((_) async => true); @@ -1103,7 +1030,7 @@ void main() { // // // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); // test("get utxos fails", () async { @@ -1114,7 +1041,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.ping()).thenAnswer((_) async => true); @@ -1153,7 +1079,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("chain height fetch, update, and get", () async { @@ -1164,7 +1089,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.ping()).thenAnswer((_) async => true); @@ -1211,7 +1135,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("getTxCount succeeds", () async { @@ -1241,11 +1164,10 @@ void main() { "64953f7db441a21172de206bf70b920c8c718ed4f03df9a85073c0400be0053c")) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("getTxCount fails", () async { @@ -1267,11 +1189,10 @@ void main() { "64953f7db441a21172de206bf70b920c8c718ed4f03df9a85073c0400be0053c")) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { @@ -1318,13 +1239,12 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 11); - expect(secureStore?.reads, 7); - expect(secureStore?.writes, 4); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 11); + expect(secureStore.reads, 7); + expect(secureStore.writes, 4); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentReceivingAddressesForTransactions fails", () async { @@ -1360,13 +1280,12 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 8); - expect(secureStore?.reads, 5); - expect(secureStore?.writes, 3); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 8); + expect(secureStore.reads, 5); + expect(secureStore.writes, 3); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentChangeAddressesForTransactions succeeds", () async { @@ -1413,14 +1332,13 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 11); - expect(secureStore?.reads, 7); - expect(secureStore?.writes, 4); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 11); + expect(secureStore.reads, 7); + expect(secureStore.writes, 4); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("_checkCurrentChangeAddressesForTransactions fails", () async { @@ -1456,13 +1374,12 @@ void main() { verify(client?.getServerFeatures()).called(1); verifyNever(client?.ping()).called(0); - expect(secureStore?.interactions, 8); - expect(secureStore?.reads, 5); - expect(secureStore?.writes, 3); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 8); + expect(secureStore.reads, 5); + expect(secureStore.writes, 3); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("getAllTxsToWatch", () async { @@ -1490,7 +1407,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData true A", () async { @@ -1509,7 +1426,7 @@ void main() { // coin: dtestcoin, // client: client!, // cachedClient: cachedClient!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1538,7 +1455,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData true B", () async { @@ -1638,7 +1555,7 @@ void main() { // coin: dtestcoin, // client: client!, // cachedClient: cachedClient!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1670,7 +1587,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("refreshIfThereIsNewData false A", () async { @@ -1771,7 +1688,7 @@ void main() { // client: client!, // cachedClient: cachedClient!, // tracker: tracker!, - // priceAPI: priceAPI, + // // secureStore: secureStore, // ); // final wallet = await Hive.openBox(testWalletId); @@ -1804,7 +1721,7 @@ void main() { // expect(secureStore?.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // // test("refreshIfThereIsNewData false B", () async { @@ -1823,7 +1740,7 @@ void main() { // // client: client!, // // cachedClient: cachedClient!, // // tracker: tracker!, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // final wallet = await Hive.openBox(testWalletId); @@ -1848,7 +1765,7 @@ void main() { // // expect(secureStore?.interactions, 0); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); test("get mnemonic list", () async { @@ -1885,7 +1802,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test( @@ -1916,10 +1832,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test( @@ -1932,7 +1847,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1960,10 +1874,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test( @@ -1980,7 +1893,7 @@ void main() { "services": [] }); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic words"); bool hasThrown = false; @@ -1997,10 +1910,9 @@ void main() { verify(client?.getServerFeatures()).called(1); - expect(secureStore?.interactions, 2); + expect(secureStore.interactions, 2); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using non empty seed on mainnet succeeds", @@ -2060,15 +1972,14 @@ void main() { ] })).called(1); - expect(secureStore?.interactions, 6); - expect(secureStore?.writes, 3); - expect(secureStore?.reads, 3); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 6); + expect(secureStore.writes, 3); + expect(secureStore.reads, 3); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan succeeds", () async { @@ -2117,10 +2028,10 @@ void main() { final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore?.read( + final preReceiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); // destroy the data that the rescan will fix await wallet.put( @@ -2130,9 +2041,9 @@ void main() { await wallet.put('receivingIndexP2PKH', 123); await wallet.put('changeIndexP2PKH', 123); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore?.write( + await secureStore.write( key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); bool hasThrown = false; @@ -2150,10 +2061,10 @@ void main() { final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore?.read( + final receiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); expect(preChangeAddressesP2PKH, changeAddressesP2PKH); @@ -2179,14 +2090,13 @@ void main() { verify(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) .called(1); - expect(secureStore?.writes, 9); - expect(secureStore?.reads, 12); - expect(secureStore?.deletes, 2); + expect(secureStore.writes, 9); + expect(secureStore.reads, 12); + expect(secureStore.deletes, 2); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan fails", () async { @@ -2237,10 +2147,10 @@ void main() { final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore?.read( + final preReceiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenThrow(Exception("fake exception")); @@ -2261,10 +2171,10 @@ void main() { final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore?.read( + final receiveDerivationsStringP2PKH = await secureStore.read( key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = await secureStore?.read( - key: "${testWalletId}_changeDerivationsP2PKH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); expect(preChangeAddressesP2PKH, changeAddressesP2PKH); @@ -2290,14 +2200,13 @@ void main() { verify(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) .called(1); - expect(secureStore?.writes, 7); - expect(secureStore?.reads, 12); - expect(secureStore?.deletes, 4); + expect(secureStore.writes, 7); + expect(secureStore.reads, 12); + expect(secureStore.deletes, 4); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); // // test("fetchBuildTxData succeeds", () async { @@ -2474,7 +2383,7 @@ void main() { // // // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); // test("fetchBuildTxData throws", () async { @@ -2555,7 +2464,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("build transaction succeeds", () async { @@ -2648,7 +2557,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test("confirmSend error 1", () async { @@ -2661,11 +2570,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend error 2", () async { @@ -2678,11 +2586,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend some other error code", () async { @@ -2695,11 +2602,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend no hex", () async { @@ -2712,11 +2618,10 @@ void main() { expect(didThrow, true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails due to vSize being greater than fee", () async { @@ -2734,11 +2639,10 @@ void main() { rawTx: "a string", requestID: anyNamed("requestID"))) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails when broadcast transactions throws", () async { @@ -2760,11 +2664,10 @@ void main() { rawTx: "a string", requestID: anyNamed("requestID"))) .called(1); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("refresh wallet mutex locked", () async { @@ -2821,15 +2724,14 @@ void main() { ] })).called(1); - expect(secureStore?.interactions, 6); - expect(secureStore?.writes, 3); - expect(secureStore?.reads, 3); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 6); + expect(secureStore.writes, 3); + expect(secureStore.reads, 3); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("refresh wallet throws", () async { @@ -2889,15 +2791,14 @@ void main() { verify(client?.getBlockHeadTip()).called(1); verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - expect(secureStore?.interactions, 6); - expect(secureStore?.writes, 3); - expect(secureStore?.reads, 3); - expect(secureStore?.deletes, 0); + expect(secureStore.interactions, 6); + expect(secureStore.writes, 3); + expect(secureStore.reads, 3); + expect(secureStore.deletes, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); // test("refresh wallet normally", () async { @@ -2958,7 +2859,7 @@ void main() { // // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); }); diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index 22a505adf..2539b3da1 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -75,7 +75,8 @@ void main() { usedSerials, firoNetwork, ); - final result = await staticProcessRestore(txData, message); + const currentHeight = 100000000000; + final result = await staticProcessRestore(txData, message, currentHeight); expect(result, isA>()); expect(result["mintIndex"], 8); @@ -371,7 +372,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -386,7 +386,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -401,7 +400,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -416,7 +414,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -431,7 +428,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -446,7 +442,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -466,7 +461,6 @@ void main() { client: client, cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); final bool result = await firo.testNetworkConnection(); @@ -485,7 +479,6 @@ void main() { client: client, cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); final bool result = await firo.testNetworkConnection(); @@ -504,7 +497,6 @@ void main() { client: client, cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); final bool result = await firo.testNetworkConnection(); @@ -558,7 +550,7 @@ void main() { // client: client,coin: Coin.firo, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -580,7 +572,7 @@ void main() { // coin: Coin.firo, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -613,7 +605,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -645,7 +637,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -691,7 +683,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -762,7 +754,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -868,7 +860,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -954,7 +946,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: tracker, // ); // @@ -1051,14 +1043,13 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: tracker, ); // firo.unconfirmedTxs = {}; final wallet = - await Hive.openBox(testWalletId + "refreshIfThereIsNewData"); + await Hive.openBox("${testWalletId}refreshIfThereIsNewData"); await wallet.put('receivingAddresses', [ "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", @@ -1119,7 +1110,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: tracker, // ); // @@ -1150,7 +1141,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -1174,7 +1164,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -1248,7 +1237,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -1379,7 +1367,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -1553,13 +1540,12 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); // pre grab derivations in order to set up mock calls needed later on await firo.fillAddresses(TEST_MNEMONIC); - final wallet = await Hive.openBox(testWalletId + "fullRescan"); + final wallet = await Hive.openBox("${testWalletId}fullRescan"); final rcv = await secureStore.read( key: "${testWalletId}fullRescan_receiveDerivations"); @@ -1761,7 +1747,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -1919,7 +1904,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -2179,7 +2163,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -2212,12 +2195,11 @@ void main() { final firo = FiroWallet( walletName: testWalletName, - walletId: testWalletId + "recoverFromMnemonic fails mainnet", + walletId: "${testWalletId}recoverFromMnemonic fails mainnet", coin: Coin.firo, client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -2230,98 +2212,6 @@ void main() { throwsA(isA())); }); - test("incrementAddressIndexForChain receiving", () async { - final firo = FiroWallet( - walletId: "${testWalletId}incrementAddressIndexForChain receiving", - walletName: testWalletName, - coin: Coin.firo, - client: MockElectrumX(), - cachedClient: MockCachedElectrumX(), - secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), - tracker: MockTransactionNotificationTracker(), - ); - - final wallet = await Hive.openBox( - "${testWalletId}incrementAddressIndexForChain receiving"); - await wallet.put("receivingIndex", 1); - - await expectLater(() async => await firo.incrementAddressIndexForChain(0), - returnsNormally); - - expect(wallet.get("receivingIndex"), 2); - }); - - test("incrementAddressIndexForChain change", () async { - final firo = FiroWallet( - walletId: "${testWalletId}incrementAddressIndexForChain change", - walletName: testWalletName, - coin: Coin.firo, - client: MockElectrumX(), - cachedClient: MockCachedElectrumX(), - secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), - tracker: MockTransactionNotificationTracker(), - ); - - final wallet = await Hive.openBox( - "${testWalletId}incrementAddressIndexForChain change"); - await wallet.put("changeIndex", 1); - - await expectLater(() async => await firo.incrementAddressIndexForChain(1), - returnsNormally); - - expect(wallet.get("changeIndex"), 2); - }); - - test("addToAddressesArrayForChain receiving", () async { - final firo = FiroWallet( - walletId: "${testWalletId}addToAddressesArrayForChain receiving", - walletName: testWalletName, - coin: Coin.firo, - client: MockElectrumX(), - cachedClient: MockCachedElectrumX(), - secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), - tracker: MockTransactionNotificationTracker(), - ); - - final wallet = await Hive.openBox( - "${testWalletId}addToAddressesArrayForChain receiving"); - - await expectLater( - () async => - await firo.addToAddressesArrayForChain("Some Address String", 0), - returnsNormally); - - expect(wallet.get("receivingAddresses"), ["Some Address String"]); - }); - - test("addToAddressesArrayForChain change", () async { - final firo = FiroWallet( - walletId: "${testWalletId}addToAddressesArrayForChain change", - walletName: testWalletName, - coin: Coin.firo, - client: MockElectrumX(), - cachedClient: MockCachedElectrumX(), - secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), - tracker: MockTransactionNotificationTracker(), - ); - - final wallet = await Hive.openBox( - "${testWalletId}addToAddressesArrayForChain change"); - await wallet.put("changeAddresses", ["some address A"]); - - await expectLater( - () async => - await firo.addToAddressesArrayForChain("Some Address B", 1), - returnsNormally); - - expect( - wallet.get("changeAddresses"), ["some address A", "Some Address B"]); - }); - test("checkReceivingAddressForTransactions fails", () async { final firo = FiroWallet( walletId: "${testWalletId}checkReceivingAddressForTransactions fails", @@ -2330,7 +2220,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -2358,7 +2247,6 @@ void main() { client: client, cachedClient: MockCachedElectrumX(), secureStore: secureStore, - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -2385,13 +2273,12 @@ void main() { when(client.getLatestCoinId()).thenAnswer((_) async => 1); final firo = FiroWallet( - walletId: testWalletId + "exit", + walletId: "${testWalletId}exit", walletName: testWalletName, coin: Coin.firo, client: client, cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -2412,7 +2299,7 @@ void main() { // client: client, // cachedClient: MockCachedElectrumX(), // secureStore: FakeSecureStorage(), - // priceAPI: MockPriceAPI(), + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -2435,13 +2322,12 @@ void main() { (_) async => GetUsedSerialsSampleData.serials['serials'] as List); final firo = FiroWallet( - walletId: testWalletId + "getUsedCoinSerials", + walletId: "${testWalletId}getUsedCoinSerials", walletName: testWalletName, coin: Coin.firo, client: client, cachedClient: cachedClient, secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -2559,7 +2445,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -2669,7 +2554,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -2758,7 +2643,7 @@ void main() { // expect(result.length, 64); // }, timeout: const Timeout(Duration(minutes: 3))); - test("send fails due to insufficient balance", () async { + test("prepareSend fails due to insufficient balance", () async { TestWidgetsFlutterBinding.ensureInitialized(); const MethodChannel('uk.spiralarm.flutter/devicelocale') .setMockMethodCallHandler((methodCall) async => 'en_US'); @@ -2851,7 +2736,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -2933,8 +2817,9 @@ void main() { .put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); expect( - () async => await firo.send( - toAddress: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV", amount: 100), + () async => await firo.prepareSend( + address: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV", + satoshiAmount: 100), throwsA(isA())); }, timeout: const Timeout(Duration(minutes: 3))); @@ -3021,7 +2906,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -3173,7 +3057,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: FakeSecureStorage(), - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); @@ -3192,211 +3075,9 @@ void main() { "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", ]); - expect(await firo.pendingBalance, Decimal.zero); - expect(await firo.availableBalance, Decimal.parse("0.00021594")); - expect(await firo.totalBalance, Decimal.parse("0.00021594")); - }); - - test("wallet balance minus maxfee - wallet balance is zero", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final priceAPI = MockPriceAPI(); - final secureStore = FakeSecureStorage(); - - when(client.getBatchHistory(args: batchHistoryRequest0)) - .thenAnswer((realInvocation) async => batchHistoryResponse0); - - when(client.getBatchUTXOs(args: batchUtxoRequest)) - .thenAnswer((realInvocation) async => {}); - - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - - // mock history calls - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) - .thenAnswer((_) async => SampleGetHistoryData.data0); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) - .thenAnswer((_) async => SampleGetHistoryData.data1); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2)) - .thenAnswer((_) async => SampleGetHistoryData.data2); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3)) - .thenAnswer((_) async => SampleGetHistoryData.data3); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - - final firo = FiroWallet( - walletId: "${testWalletId}wallet balance minus maxfee", - walletName: "pendingBalance wallet name", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - priceAPI: priceAPI, - tracker: MockTransactionNotificationTracker(), - ); - - await secureStore.write( - key: "${testWalletId}wallet balance minus maxfee_mnemonic", - value: TEST_MNEMONIC); - - final wallet = await Hive.openBox( - "${testWalletId}wallet balance minus maxfee"); - await wallet.put('receivingAddresses', [ - "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", - "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", - "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq", - ]); - - await wallet.put('changeAddresses', [ - "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", - ]); - - expect(await firo.maxFee, 0); // ??? - - expect(await firo.balanceMinusMaxFee, Decimal.parse("0")); - }); - - test("wallet balance minus maxfee - wallet balance is not zero", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final priceAPI = MockPriceAPI(); - final secureStore = FakeSecureStorage(); - - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - - // mock history calls - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) - .thenAnswer((_) async => SampleGetHistoryData.data0); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) - .thenAnswer((_) async => SampleGetHistoryData.data1); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2)) - .thenAnswer((_) async => SampleGetHistoryData.data2); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3)) - .thenAnswer((_) async => SampleGetHistoryData.data3); - - when(client.getBatchHistory(args: batchHistoryRequest0)) - .thenAnswer((realInvocation) async => batchHistoryResponse0); - - when(client.getBatchUTXOs(args: batchUtxoRequest)) - .thenAnswer((realInvocation) async => {}); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash7, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData7); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash8, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData8); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash9, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData9); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash10, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData10); - - final firo = FiroWallet( - walletId: "${testWalletId}wallet balance minus maxfee", - walletName: "pendingBalance wallet name", - client: client, - coin: Coin.firo, - cachedClient: cachedClient, - secureStore: secureStore, - priceAPI: priceAPI, - tracker: MockTransactionNotificationTracker(), - ); - - await secureStore.write( - key: "${testWalletId}wallet balance minus maxfee_mnemonic", - value: TEST_MNEMONIC); - - final wallet = await Hive.openBox( - "${testWalletId}wallet balance minus maxfee"); - await wallet.put('_lelantus_coins', SampleLelantus.lelantusCoins); - await wallet.put('jindex', [2, 4, 6]); - await wallet.put('mintIndex', 8); - await wallet.put('receivingAddresses', [ - "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", - "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", - "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq", - ]); - - await wallet.put('changeAddresses', [ - "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", - ]); - - expect(await firo.maxFee, 8914); - - expect(await firo.balanceMinusMaxFee, Decimal.parse("0.0001268")); + expect(firo.balance.getPending(), Decimal.zero); + expect(firo.balance.getSpendable(), Decimal.parse("0.00021594")); + expect(firo.balance.getTotal(), Decimal.parse("0.00021594")); }); test("get transactionData", () async { @@ -3490,11 +3171,10 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - priceAPI: priceAPI, tracker: MockTransactionNotificationTracker(), ); - final wallet = await Hive.openBox(testWalletId + "transactionData"); + final wallet = await Hive.openBox("${testWalletId}transactionData"); await wallet.put( 'receivingAddresses', RefreshTestParams.receivingAddresses); await wallet.put('changeAddresses', RefreshTestParams.changeAddresses); @@ -3634,7 +3314,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // priceAPI: priceAPI, + // // tracker: MockTransactionNotificationTracker(), // ); // @@ -3734,7 +3414,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -3774,7 +3453,6 @@ void main() { client: client, cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -3796,7 +3474,6 @@ void main() { client: client, cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -3813,7 +3490,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -3828,7 +3504,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -3851,7 +3526,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: store, - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); final List result = await firo.mnemonic; @@ -3880,7 +3554,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: store, - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); final mnemonic = await firo.mnemonic; @@ -3896,7 +3569,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); @@ -3914,7 +3586,6 @@ void main() { client: MockElectrumX(), cachedClient: MockCachedElectrumX(), secureStore: FakeSecureStorage(), - priceAPI: MockPriceAPI(), tracker: MockTransactionNotificationTracker(), ); diff --git a/test/services/coins/namecoin/namecoin_wallet_test.dart b/test/services/coins/namecoin/namecoin_wallet_test.dart index 1975f66e0..7e3856f28 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.dart @@ -15,7 +15,6 @@ import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:tuple/tuple.dart'; import 'namecoin_history_sample_data.dart'; import 'namecoin_transaction_data_samples.dart'; @@ -102,7 +101,6 @@ void main() { group("validate mainnet namecoin addresses", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -111,7 +109,6 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -122,7 +119,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -136,7 +132,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet bech32 p2wpkh address type", () { @@ -148,7 +143,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid bech32 address type", () { @@ -160,7 +154,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("address has no matching script", () { @@ -172,14 +165,12 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("testNetworkConnection", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -188,7 +179,6 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -199,7 +189,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -212,7 +201,6 @@ void main() { verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection fails due to exception", () async { @@ -223,7 +211,6 @@ void main() { verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection test success", () async { @@ -234,7 +221,6 @@ void main() { verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -244,7 +230,7 @@ void main() { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -253,7 +239,7 @@ void main() { setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -264,7 +250,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -274,7 +259,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get networkType test", () async { @@ -285,14 +269,12 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); expect(Coin.namecoin, Coin.namecoin); expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get cryptoCurrency", () async { @@ -300,7 +282,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get coinName", () async { @@ -308,7 +289,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get coinTicker", () async { @@ -316,7 +296,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get and set walletName", () async { @@ -326,7 +305,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("estimateTxFee", () async { @@ -341,7 +319,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get fees succeeds", () async { @@ -375,7 +352,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get fees fails", () async { @@ -412,7 +388,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("get maxFee", () async { @@ -444,7 +419,7 @@ void main() { // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); // verifyNoMoreInteractions(tracker); - // verifyNoMoreInteractions(priceAPI); + // // }); }); @@ -456,7 +431,7 @@ void main() { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -485,7 +460,7 @@ void main() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -496,7 +471,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -508,18 +482,18 @@ void main() { // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeWallet no network exception", () async { // when(client?.ping()).thenThrow(Exception("Network connection failed")); - // final wallets = await Hive.openBox(testWalletId); + // final wallets = await Hive.openBox(testWalletId); // expect(await nmc?.initializeExisting(), false); // expect(secureStore.interactions, 0); // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test("initializeWallet mainnet throws bad network", () async { @@ -535,16 +509,16 @@ void main() { "services": [] }); // await nmc?.initializeNew(); - final wallets = await Hive.openBox(testWalletId); + final wallets = await Hive.openBox(testWalletId); - expectLater(() => nmc?.initializeExisting(), throwsA(isA())) + await expectLater( + () => nmc?.initializeExisting(), throwsA(isA())) .then((_) { expect(secureStore.interactions, 0); // verify(client?.ping()).called(1); // verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -563,15 +537,15 @@ void main() { await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); - final wallets = await Hive.openBox(testWalletId); - expectLater(() => nmc?.initializeExisting(), throwsA(isA())) + final wallets = await Hive.openBox(testWalletId); + await expectLater( + () => nmc?.initializeExisting(), throwsA(isA())) .then((_) { expect(secureStore.interactions, 1); // verify(client?.ping()).called(1); // verify(client?.getServerFeatures()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -606,7 +580,7 @@ void main() { // expect(secureStore.interactions, 0); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test( @@ -643,7 +617,6 @@ void main() { expect(secureStore.interactions, 2); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { @@ -670,7 +643,7 @@ void main() { when(client?.getBatchHistory(args: historyBatchArgs5)) .thenAnswer((_) async => emptyHistoryBatchResponse); await DB.instance.init(); - final wallet = await Hive.openBox(testWalletId); + final wallet = await Hive.openBox(testWalletId); bool hasThrown = false; try { await nmc?.recoverFromMnemonic( @@ -698,7 +671,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get mnemonic list", () async { @@ -725,7 +697,7 @@ void main() { when(client?.getBatchHistory(args: historyBatchArgs5)) .thenAnswer((_) async => emptyHistoryBatchResponse); - final wallet = await Hive.openBox(testWalletId); + final wallet = await Hive.openBox(testWalletId); await nmc?.recoverFromMnemonic( mnemonic: TEST_MNEMONIC, @@ -745,7 +717,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using non empty seed on mainnet succeeds", @@ -821,7 +792,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan succeeds", () async { @@ -1088,7 +1058,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan fails", () async { @@ -1302,7 +1271,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("prepareSend fails", () async { @@ -1367,21 +1335,21 @@ void main() { // modify addresses to properly mock data to build a tx final rcv44 = await secureStore.read( - key: testWalletId + "_receiveDerivationsP2PKH"); + key: "${testWalletId}_receiveDerivationsP2PKH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2PKH", + key: "${testWalletId}_receiveDerivationsP2PKH", value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); final rcv49 = - await secureStore.read(key: testWalletId + "_receiveDerivationsP2SH"); + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2SH", + key: "${testWalletId}_receiveDerivationsP2SH", value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); final rcv84 = await secureStore.read( - key: testWalletId + "_receiveDerivationsP2WPKH"); + key: "${testWalletId}_receiveDerivationsP2WPKH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2WPKH", + key: "${testWalletId}_receiveDerivationsP2WPKH", value: rcv84?.replaceFirst( "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); @@ -1443,7 +1411,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend no hex", () async { @@ -1459,7 +1426,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend hex is not string", () async { @@ -1475,7 +1441,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend hex is string but missing other data", () async { @@ -1495,7 +1460,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails due to vSize being greater than fee", () async { @@ -1516,7 +1480,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails when broadcast transactions throws", () async { @@ -1542,7 +1505,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); // // // this test will create a non mocked electrumx client that will try to connect @@ -1555,12 +1517,12 @@ void main() { // // networkType: BasicNetworkType.test, // // client: client, // // cachedClient: cachedClient, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // // // // set node - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox(testWalletId); // // await wallet.put("nodes", { // // "default": { // // "id": "some nodeID", @@ -1591,7 +1553,7 @@ void main() { // // expect(secureStore.interactions, 0); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); test("refresh wallet mutex locked", () async { @@ -1666,7 +1628,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("refresh wallet normally", () async { @@ -1687,9 +1648,6 @@ void main() { when(client?.estimateFee(blocks: anyNamed("blocks"))) .thenAnswer((_) async => Decimal.one); - when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")) - .thenAnswer((_) async => {Coin.namecoin: Tuple2(Decimal.one, 0.3)}); - final List dynamicArgValues = []; when(client?.getBatchHistory(args: anyNamed("args"))) @@ -1718,7 +1676,6 @@ void main() { verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); verify(client?.getBlockHeadTip()).called(1); - verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2); for (final arg in dynamicArgValues) { final map = Map>.from(arg as Map); @@ -1733,7 +1690,6 @@ void main() { // verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); tearDown(() async { diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index bbe34a5ec..99cf68d6d 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -12,7 +12,6 @@ import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:tuple/tuple.dart'; import 'particl_history_sample_data.dart'; import 'particl_transaction_data_samples.dart'; @@ -100,7 +99,7 @@ void main() { group("validate mainnet particl addresses", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -110,7 +109,7 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -121,7 +120,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -133,7 +131,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet particl legacy/p2pkh address type", () { @@ -145,7 +142,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet particl p2wpkh address", () { @@ -160,7 +156,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("valid mainnet particl legacy/p2pkh address", () { @@ -170,7 +165,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("invalid mainnet particl legacy/p2pkh address", () { @@ -183,7 +177,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("invalid mainnet particl p2wpkh address", () { @@ -195,7 +188,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("invalid bech32 address type", () { @@ -207,7 +199,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("address has no matching script", () { @@ -219,14 +210,13 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); }); group("testNetworkConnection", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -235,7 +225,7 @@ void main() { setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -246,7 +236,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -259,7 +248,6 @@ void main() { verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection fails due to exception", () async { @@ -270,7 +258,6 @@ void main() { verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("attempted connection test success", () async { @@ -281,7 +268,6 @@ void main() { verify(client?.ping()).called(1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -291,7 +277,7 @@ void main() { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -300,7 +286,7 @@ void main() { setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -311,7 +297,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -321,7 +306,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get networkType test", () async { @@ -332,14 +316,12 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); expect(Coin.particl, Coin.particl); expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get cryptoCurrency", () async { @@ -347,7 +329,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get coinName", () async { @@ -355,7 +336,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get coinTicker", () async { @@ -363,7 +343,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get and set walletName", () async { @@ -373,7 +352,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("estimateTxFee", () async { @@ -388,7 +366,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get fees succeeds", () async { @@ -422,7 +399,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get fees fails", () async { @@ -459,7 +435,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); // test("get maxFee", () async { @@ -491,7 +466,7 @@ void main() { // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); // verifyNoMoreInteractions(tracker); - // verifyNoMoreInteractions(priceAPI); + // // }); }); @@ -503,7 +478,7 @@ void main() { MockElectrumX? client; MockCachedElectrumX? cachedClient; - MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -532,7 +507,7 @@ void main() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -543,7 +518,6 @@ void main() { client: client!, cachedClient: cachedClient!, tracker: tracker!, - priceAPI: priceAPI, secureStore: secureStore, ); }); @@ -555,7 +529,7 @@ void main() { // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); // test("initializeWallet no network exception", () async { @@ -566,7 +540,7 @@ void main() { // verify(client?.ping()).called(1); // verifyNoMoreInteractions(client); // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); + // // }); test("initializeWallet mainnet throws bad network", () async { @@ -589,7 +563,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -615,7 +588,6 @@ void main() { expect(secureStore.interactions, 1); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); }); @@ -650,7 +622,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test( @@ -687,7 +658,6 @@ void main() { expect(secureStore.interactions, 2); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { @@ -737,7 +707,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("get mnemonic list", () async { @@ -778,7 +747,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("recoverFromMnemonic using non empty seed on mainnet succeeds", @@ -847,7 +815,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan succeeds", () async { @@ -1040,7 +1007,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("fullRescan fails", () async { @@ -1243,7 +1209,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("prepareSend fails", () async { @@ -1372,7 +1337,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend no hex", () async { @@ -1388,7 +1352,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend hex is not string", () async { @@ -1404,7 +1367,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend hex is string but missing other data", () async { @@ -1424,7 +1386,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails due to vSize being greater than fee", () async { @@ -1445,7 +1406,6 @@ void main() { expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); test("confirmSend fails when broadcast transactions throws", () async { @@ -1471,7 +1431,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); // // // this test will create a non mocked electrumx client that will try to connect @@ -1484,7 +1443,7 @@ void main() { // // networkType: BasicNetworkType.test, // // client: client, // // cachedClient: cachedClient, - // // priceAPI: priceAPI, + // // // // secureStore: secureStore, // // ); // // @@ -1520,7 +1479,7 @@ void main() { // // expect(secureStore.interactions, 0); // // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); + // // // // }); test("refresh wallet mutex locked", () async { @@ -1588,7 +1547,6 @@ void main() { verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); - verifyNoMoreInteractions(priceAPI); }); test("refresh wallet normally", () async { @@ -1609,9 +1567,6 @@ void main() { when(client?.estimateFee(blocks: anyNamed("blocks"))) .thenAnswer((_) async => Decimal.one); - when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")) - .thenAnswer((_) async => {Coin.particl: Tuple2(Decimal.one, 0.3)}); - final List dynamicArgValues = []; when(client?.getBatchHistory(args: anyNamed("args"))) @@ -1640,7 +1595,6 @@ void main() { verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(3); verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); verify(client?.getBlockHeadTip()).called(1); - verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2); for (final arg in dynamicArgValues) { final map = Map>.from(arg as Map); @@ -1654,7 +1608,6 @@ void main() { expect(secureStore.deletes, 0); verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(priceAPI); }); tearDown(() async { From 35f6ffd4fc9345a10faaadd97058788506422c45 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 13:24:16 -0600 Subject: [PATCH 183/192] coin tests linter warnings and clean up --- .../coins/bitcoin/bitcoin_wallet_test.dart | 215 +++++++++--------- .../bitcoincash/bitcoincash_wallet_test.dart | 162 ++++++------- .../coins/dogecoin/dogecoin_wallet_test.dart | 178 +++++++-------- .../services/coins/firo/firo_wallet_test.dart | 171 +++++--------- .../coins/monero/monero_wallet_test.dart | 2 +- .../coins/namecoin/namecoin_wallet_test.dart | 78 +++---- .../coins/particl/particl_wallet_test.dart | 86 +++---- .../coins/wownero/wownero_wallet_test.dart | 2 +- 8 files changed, 417 insertions(+), 477 deletions(-) diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index a2b339ac5..3b3b35e73 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -494,14 +494,14 @@ void main() async { test("get fees succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -527,14 +527,14 @@ void main() async { test("get fees fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -563,14 +563,14 @@ void main() async { // test("get maxFee", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.estimateFee(blocks: 20)) // .thenAnswer((realInvocation) async => Decimal.zero); @@ -657,7 +657,7 @@ void main() async { // test("initializeWallet no network exception", () async { // when(client?.ping()).thenThrow(Exception("Network connection failed")); - // final wallets = await Hive.openBox(testWalletId); + // final wallets = await Hive.openBox (testWalletId); // expect(await btc?.initializeExisting(), false); // expect(secureStore?.interactions, 0); // verify(client?.ping()).called(1); @@ -669,17 +669,17 @@ void main() async { test("initializeWallet mainnet throws bad network", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); // await btc?.initializeNew(); - final wallets = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await expectLater( () => btc?.initializeExisting(), throwsA(isA())) @@ -695,20 +695,21 @@ void main() async { test("initializeWallet throws mnemonic overwrite exception", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); - final wallets = await Hive.openBox(testWalletId); - expectLater(() => btc?.initializeExisting(), throwsA(isA())) + await Hive.openBox(testWalletId); + await expectLater( + () => btc?.initializeExisting(), throwsA(isA())) .then((_) { expect(secureStore.interactions, 1); // verify(client?.ping()).called(1); @@ -721,14 +722,14 @@ void main() async { // test("initializeWallet testnet throws bad network", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // btc = BitcoinWallet( @@ -758,14 +759,14 @@ void main() async { // // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // expect(await btc?.initializeWallet(), true); // @@ -779,7 +780,7 @@ void main() async { // expect(didThrow, true); // // // set node - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put("nodes", { // "default": { // "id": "some nodeID", @@ -807,18 +808,18 @@ void main() async { // // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // expect(await btc?.initializeWallet(), true); // - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // // expect(await wallet.get("addressBookEntries"), {}); // expect(await wallet.get('notes'), null); @@ -892,20 +893,20 @@ void main() async { // when(client?.getBatchHistory(args: anyNamed("args"))) // .thenAnswer((_) async => {}); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // init new wallet // expect(await btc?.initializeWallet(), true); // // // fetch data to compare later - // final newWallet = await Hive.openBox(testWalletId); + // final newWallet = await Hive.openBox (testWalletId); // // final addressBookEntries = await newWallet.get("addressBookEntries"); // final notes = await newWallet.get('notes'); @@ -964,7 +965,7 @@ void main() async { // expect(await btc?.initializeWallet(), true); // // // compare data to ensure state matches state of previously closed wallet - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // // expect(await wallet.get("addressBookEntries"), addressBookEntries); // expect(await wallet.get('notes'), notes); @@ -1029,7 +1030,7 @@ void main() async { // // test("get fiatPrice", () async { // // // when(priceAPI.getBitcoinPrice(baseCurrency: "USD")) // // // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); - // // await Hive.openBox(testWalletId); + // // await Hive.openBox (testWalletId); // // expect(await btc.basePrice, Decimal.fromInt(10)); // // verify(priceAPI.getBitcoinPrice(baseCurrency: "USD")).called(1); // // verifyNoMoreInteractions(client); @@ -1050,14 +1051,14 @@ void main() async { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // await btc?.initializeWallet(); // expect( @@ -1092,14 +1093,14 @@ void main() async { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // await btc?.initializeWallet(); // final addresses = await btc?.allOwnAddresses; @@ -1130,14 +1131,14 @@ void main() async { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // when(client?.getBatchUTXOs(args: anyNamed("args"))) @@ -1242,14 +1243,14 @@ void main() async { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // when(client?.getBatchUTXOs(args: anyNamed("args"))) @@ -1307,14 +1308,14 @@ void main() async { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // when(client?.getBatchUTXOs(args: anyNamed("args"))) @@ -1352,14 +1353,14 @@ void main() async { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // await btc?.initializeWallet(); // @@ -1468,14 +1469,14 @@ void main() async { // test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getHistory(scripthash: anyNamed("scripthash"))) // .thenAnswer((realInvocation) async => [ @@ -1517,18 +1518,18 @@ void main() async { // test("_checkCurrentReceivingAddressesForTransactions fails", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getHistory(scripthash: anyNamed("scripthash"))) // .thenThrow(Exception("some exception")); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // // await btc?.initializeNew(); // await btc?.initializeExisting(); @@ -1557,14 +1558,14 @@ void main() async { // test("_checkCurrentChangeAddressesForTransactions succeeds", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getHistory(scripthash: anyNamed("scripthash"))) // .thenAnswer((realInvocation) async => [ @@ -1606,14 +1607,14 @@ void main() async { // test("_checkCurrentChangeAddressesForTransactions fails", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getHistory(scripthash: anyNamed("scripthash"))) // .thenThrow(Exception("some exception")); @@ -1689,7 +1690,7 @@ void main() async { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2SH', [ // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", @@ -1827,7 +1828,7 @@ void main() async { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2SH', [ // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", @@ -1968,7 +1969,7 @@ void main() async { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2SH', [ // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", @@ -2027,7 +2028,7 @@ void main() async { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2SH', [ // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", @@ -2068,14 +2069,14 @@ void main() async { "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); bool hasThrown = false; @@ -2110,14 +2111,14 @@ void main() async { secureStore: secureStore, ); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); bool hasThrown = false; @@ -2143,14 +2144,14 @@ void main() async { "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( @@ -2177,14 +2178,14 @@ void main() async { test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => emptyHistoryBatchResponse); @@ -2199,7 +2200,7 @@ void main() async { when(client?.getBatchHistory(args: historyBatchArgs5)) .thenAnswer((_) async => emptyHistoryBatchResponse); // await DB.instance.init(); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); bool hasThrown = false; try { await btc?.recoverFromMnemonic( @@ -2231,14 +2232,14 @@ void main() async { test("get mnemonic list", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => emptyHistoryBatchResponse); @@ -2253,7 +2254,7 @@ void main() async { when(client?.getBatchHistory(args: historyBatchArgs5)) .thenAnswer((_) async => emptyHistoryBatchResponse); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await btc?.recoverFromMnemonic( mnemonic: TEST_MNEMONIC, @@ -2278,14 +2279,14 @@ void main() async { test("recoverFromMnemonic using non empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2352,14 +2353,14 @@ void main() async { test("fullRescan succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2587,14 +2588,14 @@ void main() async { test("fullRescan fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) @@ -2794,14 +2795,14 @@ void main() async { // test("fetchBuildTxData succeeds", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -2996,14 +2997,14 @@ void main() async { // // test("fetchBuildTxData throws", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3076,14 +3077,14 @@ void main() async { // // test("build transaction succeeds", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3181,14 +3182,14 @@ void main() async { // // test("build transaction fails", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3292,14 +3293,14 @@ void main() async { // // test("two output coinSelection succeeds", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3397,14 +3398,14 @@ void main() async { // // test("one output option A coinSelection", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3501,14 +3502,14 @@ void main() async { // // test("one output option B coinSelection", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3605,14 +3606,14 @@ void main() async { // // test("insufficient funds option A coinSelection", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3668,14 +3669,14 @@ void main() async { // // test("insufficient funds option B coinSelection", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3731,14 +3732,14 @@ void main() async { // // test("insufficient funds option C coinSelection", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3830,14 +3831,14 @@ void main() async { // // test("check for more outputs coinSelection", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -3936,14 +3937,14 @@ void main() async { // // test("prepareSend and confirmSend succeed", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -4053,14 +4054,14 @@ void main() async { test("prepareSend fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -4113,21 +4114,21 @@ void main() async { // modify addresses to properly mock data to build a tx final rcv44 = await secureStore.read( - key: testWalletId + "_receiveDerivationsP2PKH"); + key: "${testWalletId}_receiveDerivationsP2PKH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2PKH", + key: "${testWalletId}_receiveDerivationsP2PKH", value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); final rcv49 = - await secureStore.read(key: testWalletId + "_receiveDerivationsP2SH"); + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2SH", + key: "${testWalletId}_receiveDerivationsP2SH", value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); final rcv84 = await secureStore.read( - key: testWalletId + "_receiveDerivationsP2WPKH"); + key: "${testWalletId}_receiveDerivationsP2WPKH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2WPKH", + key: "${testWalletId}_receiveDerivationsP2WPKH", value: rcv84?.replaceFirst( "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); @@ -4300,7 +4301,7 @@ void main() async { // // ); // // // // // set node - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put("nodes", { // // "default": { // // "id": "some nodeID", @@ -4336,14 +4337,14 @@ void main() async { test("refresh wallet mutex locked", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -4412,14 +4413,14 @@ void main() async { when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => {"height": 520481, "hex": "some block hex"}); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenAnswer((_) async => []); diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index 3b6cc47f4..0a28b9d1f 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -459,14 +459,14 @@ void main() { test("get fees succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -493,14 +493,14 @@ void main() { test("get fees fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -530,14 +530,14 @@ void main() { test("get maxFee", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 20)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -592,7 +592,7 @@ void main() { Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -638,14 +638,14 @@ void main() { // test("initializeNew mainnet throws bad network", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // await Hive.openBox(testWalletId); @@ -664,14 +664,14 @@ void main() { test("initializeNew throws mnemonic overwrite exception", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); @@ -692,14 +692,14 @@ void main() { // test("initializeExisting testnet throws bad network", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // bch = BitcoinCashWallet( @@ -732,14 +732,14 @@ void main() { // // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // await DebugService.instance.init(); // expect(bch?.initializeExisting(), true); @@ -754,7 +754,7 @@ void main() { // expect(didThrow, true); // // // set node - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put("nodes", { // "default": { // "id": "some nodeID", @@ -782,18 +782,18 @@ void main() { // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // expect(await bch?.initializeWallet(), true); // - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // // expect(await wallet.get("addressBookEntries"), {}); // expect(await wallet.get('notes'), null); @@ -838,20 +838,20 @@ void main() { // // when(client?.getBatchHistory(args: anyNamed("args"))) // // .thenAnswer((_) async => {}); // // when(client?.getServerFeatures()).thenAnswer((_) async => { - // // "hosts": {}, + // // "hosts": {}, // // "pruning": null, // // "server_version": "Unit tests", // // "protocol_min": "1.4", // // "protocol_max": "1.4.2", // // "genesis_hash": GENESIS_HASH_MAINNET, // // "hash_function": "sha256", - // // "services": [] + // // "services": [] // // }); // // // init new wallet // // expect(bch?.initializeNew(), true); // // // // // fetch data to compare later - // // final newWallet = await Hive.openBox(testWalletId); + // // final newWallet = await Hive.openBox (testWalletId); // // // // final addressBookEntries = await newWallet.get("addressBookEntries"); // // final notes = await newWallet.get('notes'); @@ -890,7 +890,7 @@ void main() { // // expect(bch?.initializeExisting(), true); // // // // // compare data to ensure state matches state of previously closed wallet - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // // // expect(await wallet.get("addressBookEntries"), addressBookEntries); // // expect(await wallet.get('notes'), notes); @@ -938,14 +938,14 @@ void main() { ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); await Hive.openBox(testWalletId); @@ -976,14 +976,14 @@ void main() { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // await Hive.openBox(testWalletId); @@ -1080,14 +1080,14 @@ void main() { // // ); // // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.getServerFeatures()).thenAnswer((_) async => { - // // "hosts": {}, + // // "hosts": {}, // // "pruning": null, // // "server_version": "Unit tests", // // "protocol_min": "1.4", // // "protocol_max": "1.4.2", // // "genesis_hash": GENESIS_HASH_TESTNET, // // "hash_function": "sha256", - // // "services": [] + // // "services": [] // // }); // // // // when(client?.getBatchUTXOs(args: anyNamed("args"))) @@ -1099,7 +1099,7 @@ void main() { // // await bch?.initializeWallet(); // // // // // add some extra addresses to make sure we have more than the single batch size of 10 - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // final addresses = await wallet.get("receivingAddressesP2PKH"); // // addresses.add("DQaAi9R58GXMpDyhePys6hHCuif4fhc1sN"); // // addresses.add("DBVhuF8QgeuxU2pssxzMgJqPhGCx5qyVkD"); @@ -1143,14 +1143,14 @@ void main() { ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); await Hive.openBox(testWalletId); @@ -1191,14 +1191,14 @@ void main() { ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); await Hive.openBox(testWalletId); @@ -1208,7 +1208,7 @@ void main() { await bch?.initializeExisting(); // get stored - expect(await bch?.storedChainHeight, 0); + expect(bch?.storedChainHeight, 0); // fetch fails when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); @@ -1222,10 +1222,10 @@ void main() { expect(await bch?.chainHeight, 100); // update - await bch?.updateStoredChainHeight(newHeight: 1000); + await bch?.updateCachedChainHeight(1000); // fetch updated - expect(await bch?.storedChainHeight, 1000); + expect(bch?.storedChainHeight, 1000); verifyNever(client?.ping()).called(0); verify(client?.getServerFeatures()).called(1); @@ -1296,14 +1296,14 @@ void main() { test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenAnswer((realInvocation) async => [ @@ -1348,14 +1348,14 @@ void main() { test("_checkCurrentReceivingAddressesForTransactions fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenThrow(Exception("some exception")); @@ -1389,14 +1389,14 @@ void main() { test("_checkCurrentChangeAddressesForTransactions succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenAnswer((realInvocation) async => [ @@ -1442,14 +1442,14 @@ void main() { test("_checkCurrentChangeAddressesForTransactions fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenThrow(Exception("some exception")); @@ -1527,7 +1527,7 @@ void main() { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []); @@ -1656,7 +1656,7 @@ void main() { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []); @@ -1789,7 +1789,7 @@ void main() { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []); @@ -1841,7 +1841,7 @@ void main() { // // // // secureStore: secureStore, // // ); - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put('receivingAddressesP2PKH', []); // // // // await wallet.put('changeAddressesP2PKH', []); @@ -1868,14 +1868,14 @@ void main() { test("get mnemonic list", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); // when(client?.getBatchHistory(args: anyNamed("args"))) @@ -1893,7 +1893,7 @@ void main() { when(client?.getBatchHistory(args: historyBatchArgs3)) .thenAnswer((_) async => emptyHistoryBatchResponse); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); // add maxNumberOfIndexesToCheck and height await bch?.recoverFromMnemonic( @@ -1919,14 +1919,14 @@ void main() { "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); bool hasThrown = false; @@ -1961,14 +1961,14 @@ void main() { secureStore: secureStore, ); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); bool hasThrown = false; @@ -1994,14 +1994,14 @@ void main() { "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( @@ -2029,14 +2029,14 @@ void main() { test("recoverFromMnemonic using non empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2058,7 +2058,7 @@ void main() { return historyBatchResponse; }); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); await Hive.openBox(testWalletId); bool hasThrown = false; @@ -2099,14 +2099,14 @@ void main() { test("fullRescan succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2140,7 +2140,7 @@ void main() { ] })).thenAnswer((_) async => {"0": []}); - final wallet = await Hive.openBox(testWalletId); + final wallet = await Hive.openBox(testWalletId); // restore so we have something to rescan await bch?.recoverFromMnemonic( @@ -2289,14 +2289,14 @@ void main() { test("fullRescan fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) @@ -2331,7 +2331,7 @@ void main() { ] })).thenAnswer((_) async => {"0": []}); - final wallet = await Hive.openBox(testWalletId); + final wallet = await Hive.openBox(testWalletId); // restore so we have something to rescan await bch?.recoverFromMnemonic( @@ -2421,14 +2421,14 @@ void main() { // // test("fetchBuildTxData succeeds", () async { // // when(client.getServerFeatures()).thenAnswer((_) async => { - // // "hosts": {}, + // // "hosts": {}, // // "pruning": null, // // "server_version": "Unit tests", // // "protocol_min": "1.4", // // "protocol_max": "1.4.2", // // "genesis_hash": GENESIS_HASH_MAINNET, // // "hash_function": "sha256", - // // "services": [] + // // "services": [] // // }); // // when(client.getBatchHistory(args: historyBatchArgs0)) // // .thenAnswer((_) async => historyBatchResponse); @@ -2598,14 +2598,14 @@ void main() { // test("fetchBuildTxData throws", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -2679,14 +2679,14 @@ void main() { // test("build transaction succeeds", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -2882,14 +2882,14 @@ void main() { test("refresh wallet mutex locked", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2920,7 +2920,7 @@ void main() { ] })).thenAnswer((realInvocation) async => {"0": []}); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); // recover to fill data await bch?.recoverFromMnemonic( mnemonic: TEST_MNEMONIC, @@ -2972,14 +2972,14 @@ void main() { test("refresh wallet throws", () async { when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -3014,7 +3014,7 @@ void main() { when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenThrow(Exception("some exception")); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); // recover to fill data await bch?.recoverFromMnemonic( @@ -3069,14 +3069,14 @@ void main() { // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => // {"height": 520481, "hex": "some block hex"}); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index d003e39a7..bc59e7b98 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -244,10 +244,10 @@ void main() { }); group("basic getters, setters, and functions", () { - final dcoin = Coin.dogecoin; - final dtestcoin = Coin.dogecoinTestNet; - final testWalletId = "DOGEtestWalletID"; - final testWalletName = "DOGEWallet"; + const dcoin = Coin.dogecoin; + const dtestcoin = Coin.dogecoinTestNet; + const testWalletId = "DOGEtestWalletID"; + const testWalletName = "DOGEWallet"; MockElectrumX? client; MockCachedElectrumX? cachedClient; @@ -352,14 +352,14 @@ void main() { test("get fees succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -386,14 +386,14 @@ void main() { test("get fees fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -423,14 +423,14 @@ void main() { test("get maxFee", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 20)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -453,10 +453,10 @@ void main() { }); group("DogeWallet service class functions that depend on shared storage", () { - final dcoin = Coin.dogecoin; - final dtestcoin = Coin.dogecoinTestNet; - final testWalletId = "DOGEtestWalletID"; - final testWalletName = "DOGEWallet"; + const dcoin = Coin.dogecoin; + const dtestcoin = Coin.dogecoinTestNet; + const testWalletId = "DOGEtestWalletID"; + const testWalletName = "DOGEWallet"; bool hiveAdaptersRegistered = false; @@ -485,7 +485,7 @@ void main() { Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -531,14 +531,14 @@ void main() { // test("initializeNew mainnet throws bad network", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // await Hive.openBox(testWalletId); @@ -557,14 +557,14 @@ void main() { test("initializeNew throws mnemonic overwrite exception", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); @@ -572,7 +572,7 @@ void main() { await Hive.openBox(testWalletId); await Hive.openBox(DB.boxNamePrefs); - expectLater(() => doge?.initializeNew(), throwsA(isA())) + await expectLater(() => doge?.initializeNew(), throwsA(isA())) .then((_) { expect(secureStore.interactions, 2); verifyNever(client?.ping()).called(0); @@ -585,14 +585,14 @@ void main() { // test("initializeExisting testnet throws bad network", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // doge = DogecoinWallet( @@ -625,14 +625,14 @@ void main() { // // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // await DebugService.instance.init(); // expect(doge?.initializeExisting(), true); @@ -647,7 +647,7 @@ void main() { // expect(didThrow, true); // // // set node - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put("nodes", { // "default": { // "id": "some nodeID", @@ -675,18 +675,18 @@ void main() { // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // expect(await doge?.initializeWallet(), true); // - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // // expect(await wallet.get("addressBookEntries"), {}); // expect(await wallet.get('notes'), null); @@ -731,20 +731,20 @@ void main() { // // when(client?.getBatchHistory(args: anyNamed("args"))) // // .thenAnswer((_) async => {}); // // when(client?.getServerFeatures()).thenAnswer((_) async => { - // // "hosts": {}, + // // "hosts": {}, // // "pruning": null, // // "server_version": "Unit tests", // // "protocol_min": "1.4", // // "protocol_max": "1.4.2", // // "genesis_hash": GENESIS_HASH_MAINNET, // // "hash_function": "sha256", - // // "services": [] + // // "services": [] // // }); // // // init new wallet // // expect(doge?.initializeNew(), true); // // // // // fetch data to compare later - // // final newWallet = await Hive.openBox(testWalletId); + // // final newWallet = await Hive.openBox (testWalletId); // // // // final addressBookEntries = await newWallet.get("addressBookEntries"); // // final notes = await newWallet.get('notes'); @@ -783,7 +783,7 @@ void main() { // // expect(doge?.initializeExisting(), true); // // // // // compare data to ensure state matches state of previously closed wallet - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // // // expect(await wallet.get("addressBookEntries"), addressBookEntries); // // expect(await wallet.get('notes'), notes); @@ -831,14 +831,14 @@ void main() { ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); await Hive.openBox(testWalletId); @@ -878,14 +878,14 @@ void main() { // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // await Hive.openBox(testWalletId); @@ -982,14 +982,14 @@ void main() { // // ); // // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.getServerFeatures()).thenAnswer((_) async => { - // // "hosts": {}, + // // "hosts": {}, // // "pruning": null, // // "server_version": "Unit tests", // // "protocol_min": "1.4", // // "protocol_max": "1.4.2", // // "genesis_hash": GENESIS_HASH_TESTNET, // // "hash_function": "sha256", - // // "services": [] + // // "services": [] // // }); // // // // when(client?.getBatchUTXOs(args: anyNamed("args"))) @@ -1001,7 +1001,7 @@ void main() { // // await doge?.initializeWallet(); // // // // // add some extra addresses to make sure we have more than the single batch size of 10 - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // final addresses = await wallet.get("receivingAddressesP2PKH"); // // addresses.add("DQaAi9R58GXMpDyhePys6hHCuif4fhc1sN"); // // addresses.add("DBVhuF8QgeuxU2pssxzMgJqPhGCx5qyVkD"); @@ -1045,14 +1045,14 @@ void main() { ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); await Hive.openBox(testWalletId); @@ -1093,14 +1093,14 @@ void main() { ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); await Hive.openBox(testWalletId); @@ -1110,7 +1110,7 @@ void main() { await doge?.initializeExisting(); // get stored - expect(await doge?.storedChainHeight, 0); + expect(doge?.storedChainHeight, 0); // fetch fails when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); @@ -1124,10 +1124,10 @@ void main() { expect(await doge?.chainHeight, 100); // update - await doge?.updateStoredChainHeight(newHeight: 1000); + await doge?.updateCachedChainHeight(1000); // fetch updated - expect(await doge?.storedChainHeight, 1000); + expect(doge?.storedChainHeight, 1000); verifyNever(client?.ping()).called(0); verify(client?.getServerFeatures()).called(1); @@ -1198,14 +1198,14 @@ void main() { test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenAnswer((realInvocation) async => [ @@ -1250,14 +1250,14 @@ void main() { test("_checkCurrentReceivingAddressesForTransactions fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenThrow(Exception("some exception")); @@ -1291,14 +1291,14 @@ void main() { test("_checkCurrentChangeAddressesForTransactions succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenAnswer((realInvocation) async => [ @@ -1344,14 +1344,14 @@ void main() { test("_checkCurrentChangeAddressesForTransactions fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenThrow(Exception("some exception")); @@ -1429,7 +1429,7 @@ void main() { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []); @@ -1558,7 +1558,7 @@ void main() { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []); @@ -1691,7 +1691,7 @@ void main() { // // secureStore: secureStore, // ); - // final wallet = await Hive.openBox(testWalletId); + // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []); @@ -1743,7 +1743,7 @@ void main() { // // // // secureStore: secureStore, // // ); - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put('receivingAddressesP2PKH', []); // // // // await wallet.put('changeAddressesP2PKH', []); @@ -1770,21 +1770,21 @@ void main() { test("get mnemonic list", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => emptyHistoryBatchResponse); when(client?.getBatchHistory(args: historyBatchArgs1)) .thenAnswer((_) async => emptyHistoryBatchResponse); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); // add maxNumberOfIndexesToCheck and height await doge?.recoverFromMnemonic( @@ -1808,14 +1808,14 @@ void main() { "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); bool hasThrown = false; @@ -1850,14 +1850,14 @@ void main() { secureStore: secureStore, ); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); bool hasThrown = false; @@ -1883,14 +1883,14 @@ void main() { "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( @@ -1918,14 +1918,14 @@ void main() { test("recoverFromMnemonic using non empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -1944,7 +1944,7 @@ void main() { ] })).thenAnswer((realInvocation) async => {"0": []}); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); bool hasThrown = false; try { @@ -1984,14 +1984,14 @@ void main() { test("fullRescan succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2101,14 +2101,14 @@ void main() { test("fullRescan fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) @@ -2130,7 +2130,7 @@ void main() { when(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) .thenAnswer((realInvocation) async {}); - final wallet = await Hive.openBox(testWalletId); + final wallet = await Hive.openBox(testWalletId); // restore so we have something to rescan await doge?.recoverFromMnemonic( @@ -2211,14 +2211,14 @@ void main() { // // test("fetchBuildTxData succeeds", () async { // // when(client.getServerFeatures()).thenAnswer((_) async => { - // // "hosts": {}, + // // "hosts": {}, // // "pruning": null, // // "server_version": "Unit tests", // // "protocol_min": "1.4", // // "protocol_max": "1.4.2", // // "genesis_hash": GENESIS_HASH_MAINNET, // // "hash_function": "sha256", - // // "services": [] + // // "services": [] // // }); // // when(client.getBatchHistory(args: historyBatchArgs0)) // // .thenAnswer((_) async => historyBatchResponse); @@ -2388,14 +2388,14 @@ void main() { // test("fetchBuildTxData throws", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -2469,14 +2469,14 @@ void main() { // test("build transaction succeeds", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); @@ -2672,14 +2672,14 @@ void main() { test("refresh wallet mutex locked", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2697,7 +2697,7 @@ void main() { ] })).thenAnswer((realInvocation) async => {"0": []}); - final wallet = await Hive.openBox(testWalletId); + final wallet = await Hive.openBox(testWalletId); // recover to fill data await doge?.recoverFromMnemonic( @@ -2737,14 +2737,14 @@ void main() { test("refresh wallet throws", () async { when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -2764,7 +2764,7 @@ void main() { when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenThrow(Exception("some exception")); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); // recover to fill data await doge?.recoverFromMnemonic( @@ -2805,14 +2805,14 @@ void main() { // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => // {"height": 520481, "hex": "some block hex"}); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.getBatchHistory(args: historyBatchArgs0)) // .thenAnswer((_) async => historyBatchResponse); diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index 2539b3da1..2fc203a9b 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:typed_data'; import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; @@ -20,7 +19,6 @@ import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.dart'; -import 'package:tuple/tuple.dart'; import 'firo_wallet_test.mocks.dart'; import 'firo_wallet_test_parameters.dart'; @@ -44,7 +42,7 @@ void main() { test("isolateRestore success", () async { final cachedClient = MockCachedElectrumX(); final txData = TransactionData.fromJson(dateTimeChunksJson); - final Map setData = {}; + final Map setData = {}; setData[1] = GetAnonymitySetSampleData.data; final usedSerials = GetUsedSerialsSampleData.serials["serials"] as List; @@ -87,8 +85,8 @@ void main() { }); test("isolateRestore throws", () async { - final Map setData = {}; - final usedSerials = []; + final Map setData = {}; + final usedSerials = []; expect( () => isolateRestore( @@ -109,13 +107,11 @@ void main() { false, TEST_MNEMONIC, 2, - Decimal.ten, [], 459185, Coin.firo, firoNetwork, [GetAnonymitySetSampleData.data], - "en_US", ); expect(result, 1); @@ -208,7 +204,7 @@ void main() { // "getJMintTransactions throws Error due to some invalid transactions passed to this function", // () { // final cachedClient = MockCachedElectrumX(); - // final priceAPI = MockPriceAPI(); + // // // // mock price calls // when(priceAPI.getPricesAnd24hChange( baseCurrency: "USD")) @@ -269,7 +265,7 @@ void main() { // // test("getJMintTransactions success", () async { // final cachedClient = MockCachedElectrumX(); - // final priceAPI = MockPriceAPI(); + // // // // mock price calls // when(priceAPI.getPricesAnd24hChange( baseCurrency: "USD")) @@ -532,7 +528,7 @@ void main() { Hive.registerAdapter(LelantusCoinAdapter()); } - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); }); @@ -540,7 +536,7 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // when(client.getServerFeatures()).thenAnswer((_) async => false); // @@ -561,7 +557,7 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // when(client.ping()).thenThrow(Exception("Network connection failed")); // @@ -583,19 +579,19 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // when(client.ping()).thenAnswer((_) async => true); // // when(client.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // final firo = FiroWallet( @@ -616,19 +612,19 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // when(client.ping()).thenAnswer((_) async => true); // // when(client.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // final firo = FiroWallet( @@ -652,21 +648,21 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // when(priceAPI.getPrice(ticker: "tFIRO", baseCurrency: "USD")) // .thenAnswer((_) async => Decimal.fromInt(-1)); // // when(client.ping()).thenAnswer((_) async => true); // // when(client.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // final List> emptyList = []; @@ -723,21 +719,21 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // when(priceAPI.getPrice(ticker: "tFIRO", baseCurrency: "USD")) // // .thenAnswer((_) async => Decimal.fromInt(-1)); // // when(client.ping()).thenAnswer((_) async => true); // // when(client.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // final List> emptyList = []; @@ -828,7 +824,7 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // mock price calls // when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( // (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); @@ -836,14 +832,14 @@ void main() { // when(client.ping()).thenAnswer((_) async => true); // // when(client.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // final List> emptyList = []; @@ -905,7 +901,7 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // final tracker = MockTransactionNotificationTracker(); // // await Hive.openBox(DB.boxNamePrefs); @@ -971,12 +967,8 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); - final tracker = MockTransactionNotificationTracker(); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); + final tracker = MockTransactionNotificationTracker(); when(tracker.pendings).thenAnswer((realInvocation) => [ "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e", @@ -1048,8 +1040,8 @@ void main() { // firo.unconfirmedTxs = {}; - final wallet = - await Hive.openBox("${testWalletId}refreshIfThereIsNewData"); + final wallet = await Hive.openBox( + "${testWalletId}refreshIfThereIsNewData"); await wallet.put('receivingAddresses', [ "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", @@ -1070,7 +1062,7 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // final tracker = MockTransactionNotificationTracker(); // // when(client.getTransaction(txHash: SampleGetTransactionData.txHash6)) @@ -1126,7 +1118,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); when(client.broadcastTransaction( rawTx: @@ -1155,7 +1146,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); final firo = FiroWallet( walletName: testWalletName, @@ -1225,11 +1215,6 @@ void main() { when(client.getBlockHeadTip()).thenAnswer( (_) async => {"height": 455873, "hex": "this value not used here"}); - final priceAPI = MockPriceAPI(); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - final firo = FiroWallet( walletName: testWalletName, walletId: "${testWalletId}buildMintTransaction", @@ -1240,7 +1225,8 @@ void main() { tracker: MockTransactionNotificationTracker(), ); - final wallet = await Hive.openBox("${testWalletId}buildMintTransaction"); + final wallet = + await Hive.openBox("${testWalletId}buildMintTransaction"); await wallet.put("mintIndex", 0); @@ -1268,18 +1254,17 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client.getLatestCoinId()).thenAnswer((_) async => 1); @@ -1356,10 +1341,6 @@ void main() { return SampleGetTransactionData.txData7; }); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - final firo = FiroWallet( walletName: testWalletName, walletId: "${testWalletId}recoverFromMnemonic", @@ -1507,7 +1488,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); await secureStore.write( key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); @@ -1529,10 +1509,6 @@ void main() { when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) .thenAnswer((_) async => {}); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - final firo = FiroWallet( walletName: testWalletName, walletId: "${testWalletId}fullRescan", @@ -1545,7 +1521,7 @@ void main() { // pre grab derivations in order to set up mock calls needed later on await firo.fillAddresses(TEST_MNEMONIC); - final wallet = await Hive.openBox("${testWalletId}fullRescan"); + final wallet = await Hive.openBox("${testWalletId}fullRescan"); final rcv = await secureStore.read( key: "${testWalletId}fullRescan_receiveDerivations"); @@ -1721,7 +1697,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); await secureStore.write( key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); @@ -1736,10 +1711,6 @@ void main() { when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) .thenAnswer((_) async => {}); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - final firo = FiroWallet( walletName: testWalletName, walletId: "${testWalletId}fullRescan", @@ -1864,18 +1835,17 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client.getLatestCoinId()).thenAnswer((_) async => 1); @@ -1893,9 +1863,6 @@ void main() { when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) .thenAnswer( (_) async => GetUsedSerialsSampleData.serials['serials'] as List); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); final firo = FiroWallet( walletName: testWalletName, @@ -2142,18 +2109,17 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); final firo = FiroWallet( @@ -2179,18 +2145,17 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); final firo = FiroWallet( @@ -2343,7 +2308,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); // set mnemonic await secureStore.write( @@ -2367,14 +2331,14 @@ void main() { // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client.getLatestCoinId()).thenAnswer((_) async => 1); @@ -2434,10 +2398,6 @@ void main() { when(client.getUTXOs(scripthash: anyNamed("scripthash"))) .thenAnswer((_) async => []); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - final firo = FiroWallet( walletName: testWalletName, walletId: "${testWalletId}refresh", @@ -2469,7 +2429,7 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // String expectedTxid = "-1"; // when(client.getLatestCoinId()).thenAnswer((_) async => 1); @@ -2651,7 +2611,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); + when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getBlockHeadTip()).thenAnswer( (_) async => {"height": 459185, "hex": "... some block hex ..."}); @@ -2679,10 +2639,6 @@ void main() { coin: Coin.firo, )).thenAnswer((_) async => GetAnonymitySetSampleData.data); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - // mock transaction calls when(cachedClient.getTransaction( txHash: SampleGetTransactionData.txHash0, @@ -2805,8 +2761,8 @@ void main() { .thenAnswer((_) async => data); } - await wallet.put('_lelantus_coins', []); - await wallet.put('jindex', []); + await wallet.put('_lelantus_coins', []); + await wallet.put('jindex', []); await wallet.put('mintIndex', 0); await wallet.put('receivingAddresses', [ "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", @@ -2831,7 +2787,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); + when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getBlockHeadTip()).thenAnswer( (_) async => {"height": 459185, "hex": "... some block hex ..."}); @@ -2849,10 +2805,6 @@ void main() { coin: Coin.firo, )).thenAnswer((_) async => GetAnonymitySetSampleData.data); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - // mock transaction calls when(cachedClient.getTransaction( txHash: SampleGetTransactionData.txHash0, @@ -2985,11 +2937,6 @@ void main() { ]); await wallet .put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); - - expect( - () async => await firo.send( - toAddress: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV", amount: 100), - throwsA(isA())); }, timeout: const Timeout(Duration(minutes: 3))); test("wallet balances", () async { @@ -2999,10 +2946,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); - final priceAPI = MockPriceAPI(); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); // mock history calls when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) @@ -3084,7 +3027,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final priceAPI = MockPriceAPI(); // set mnemonic await secureStore.write( @@ -3093,14 +3035,14 @@ void main() { // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client.getLatestCoinId()).thenAnswer((_) async => 1); @@ -3160,10 +3102,6 @@ void main() { when(client.getUTXOs(scripthash: anyNamed("scripthash"))) .thenAnswer((_) async => []); - // mock price calls - when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( - (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); - final firo = FiroWallet( walletName: testWalletName, walletId: "${testWalletId}transactionData", @@ -3174,7 +3112,8 @@ void main() { tracker: MockTransactionNotificationTracker(), ); - final wallet = await Hive.openBox("${testWalletId}transactionData"); + final wallet = + await Hive.openBox("${testWalletId}transactionData"); await wallet.put( 'receivingAddresses', RefreshTestParams.receivingAddresses); await wallet.put('changeAddresses', RefreshTestParams.changeAddresses); @@ -3195,18 +3134,18 @@ void main() { // final client = MockElectrumX(); // final cachedClient = MockCachedElectrumX(); // final secureStore = FakeSecureStorage(); - // final priceAPI = MockPriceAPI(); + // // // // mock electrumx client calls // when(client.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_MAINNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // when(client.getBlockHeadTip()).thenAnswer( @@ -3515,7 +3454,7 @@ void main() { test("fetch and convert properly stored mnemonic to list of words", () async { final store = FakeSecureStorage(); - store.write( + await store.write( key: "some id_mnemonic", value: "some test mnemonic string of words"); @@ -3543,7 +3482,7 @@ void main() { test("attempt fetch and convert non existent mnemonic to list of words", () async { final store = FakeSecureStorage(); - store.write( + await store.write( key: "some id_mnemonic", value: "some test mnemonic string of words"); diff --git a/test/services/coins/monero/monero_wallet_test.dart b/test/services/coins/monero/monero_wallet_test.dart index d6d600e36..16f0be14b 100644 --- a/test/services/coins/monero/monero_wallet_test.dart +++ b/test/services/coins/monero/monero_wallet_test.dart @@ -68,7 +68,7 @@ void main() async { Hive.registerAdapter(WalletTypeAdapter()); Hive.registerAdapter(UnspentCoinsInfoAdapter()); - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', name); _walletInfoSource = await Hive.openBox(WalletInfo.boxName); diff --git a/test/services/coins/namecoin/namecoin_wallet_test.dart b/test/services/coins/namecoin/namecoin_wallet_test.dart index 7e3856f28..621f2d9a3 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.dart @@ -225,8 +225,8 @@ void main() { }); group("basic getters, setters, and functions", () { - final testWalletId = "NMCtestWalletID"; - final testWalletName = "NMCWallet"; + const testWalletId = "NMCtestWalletID"; + const testWalletName = "NMCWallet"; MockElectrumX? client; MockCachedElectrumX? cachedClient; @@ -324,14 +324,14 @@ void main() { test("get fees succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -357,14 +357,14 @@ void main() { test("get fees fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -393,14 +393,14 @@ void main() { // test("get maxFee", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.estimateFee(blocks: 20)) // .thenAnswer((realInvocation) async => Decimal.zero); @@ -424,8 +424,8 @@ void main() { }); group("Namecoin service class functions that depend on shared storage", () { - final testWalletId = "NMCtestWalletID"; - final testWalletName = "NMCWallet"; + const testWalletId = "NMCtestWalletID"; + const testWalletName = "NMCWallet"; bool hiveAdaptersRegistered = false; @@ -454,7 +454,7 @@ void main() { Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -499,17 +499,17 @@ void main() { test("initializeWallet mainnet throws bad network", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); // await nmc?.initializeNew(); - final wallets = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await expectLater( () => nmc?.initializeExisting(), throwsA(isA())) @@ -525,19 +525,19 @@ void main() { test("initializeWallet throws mnemonic overwrite exception", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); - final wallets = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await expectLater( () => nmc?.initializeExisting(), throwsA(isA())) .then((_) { @@ -553,14 +553,14 @@ void main() { // "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", // () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // // bool hasThrown = false; @@ -587,14 +587,14 @@ void main() { "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( @@ -621,14 +621,14 @@ void main() { test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => emptyHistoryBatchResponse); @@ -643,7 +643,7 @@ void main() { when(client?.getBatchHistory(args: historyBatchArgs5)) .thenAnswer((_) async => emptyHistoryBatchResponse); await DB.instance.init(); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); bool hasThrown = false; try { await nmc?.recoverFromMnemonic( @@ -675,14 +675,14 @@ void main() { test("get mnemonic list", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => emptyHistoryBatchResponse); @@ -697,7 +697,7 @@ void main() { when(client?.getBatchHistory(args: historyBatchArgs5)) .thenAnswer((_) async => emptyHistoryBatchResponse); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await nmc?.recoverFromMnemonic( mnemonic: TEST_MNEMONIC, @@ -722,14 +722,14 @@ void main() { test("recoverFromMnemonic using non empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -796,14 +796,14 @@ void main() { test("fullRescan succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -1062,14 +1062,14 @@ void main() { test("fullRescan fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) @@ -1275,14 +1275,14 @@ void main() { test("prepareSend fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -1558,14 +1558,14 @@ void main() { test("refresh wallet mutex locked", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -1634,14 +1634,14 @@ void main() { when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => {"height": 520481, "hex": "some block hex"}); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenAnswer((_) async => []); diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index 99cf68d6d..4cac06c9f 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -272,8 +272,8 @@ void main() { }); group("basic getters, setters, and functions", () { - final testWalletId = "ParticltestWalletID"; - final testWalletName = "ParticlWallet"; + const testWalletId = "ParticltestWalletID"; + const testWalletName = "ParticlWallet"; MockElectrumX? client; MockCachedElectrumX? cachedClient; @@ -371,14 +371,14 @@ void main() { test("get fees succeeds", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -404,14 +404,14 @@ void main() { test("get fees fails", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.estimateFee(blocks: 1)) .thenAnswer((realInvocation) async => Decimal.zero); @@ -440,14 +440,14 @@ void main() { // test("get maxFee", () async { // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, + // "hosts": {}, // "pruning": null, // "server_version": "Unit tests", // "protocol_min": "1.4", // "protocol_max": "1.4.2", // "genesis_hash": GENESIS_HASH_TESTNET, // "hash_function": "sha256", - // "services": [] + // "services": [] // }); // when(client?.estimateFee(blocks: 20)) // .thenAnswer((realInvocation) async => Decimal.zero); @@ -501,7 +501,7 @@ void main() { Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -534,7 +534,7 @@ void main() { // test("initializeWallet no network exception", () async { // when(client?.ping()).thenThrow(Exception("Network connection failed")); - // final wallets = await Hive.openBox(testWalletId); + // final wallets = await Hive.openBox (testWalletId); // expect(await nmc?.initializeExisting(), false); // expect(secureStore.interactions, 0); // verify(client?.ping()).called(1); @@ -546,16 +546,16 @@ void main() { test("initializeWallet mainnet throws bad network", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); - await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await expectLater( () => part?.initializeExisting(), throwsA(isA())) @@ -569,19 +569,19 @@ void main() { test("initializeWallet throws mnemonic overwrite exception", () async { when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( key: "${testWalletId}_mnemonic", value: "some mnemonic"); - await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await expectLater( () => part?.initializeExisting(), throwsA(isA())) .then((_) { @@ -595,14 +595,14 @@ void main() { "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_TESTNET, "hash_function": "sha256", - "services": [] + "services": [] }); bool hasThrown = false; @@ -628,14 +628,14 @@ void main() { "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); await secureStore.write( @@ -662,14 +662,14 @@ void main() { test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => emptyHistoryBatchResponse); @@ -681,7 +681,7 @@ void main() { .thenAnswer((_) async => emptyHistoryBatchResponse); // await DB.instance.init(); - final wallet = await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); bool hasThrown = false; try { await part?.recoverFromMnemonic( @@ -711,14 +711,14 @@ void main() { test("get mnemonic list", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => emptyHistoryBatchResponse); @@ -729,7 +729,7 @@ void main() { when(client?.getBatchHistory(args: historyBatchArgs3)) .thenAnswer((_) async => emptyHistoryBatchResponse); - await Hive.openBox(testWalletId); + await Hive.openBox(testWalletId); await part?.recoverFromMnemonic( mnemonic: TEST_MNEMONIC, @@ -752,14 +752,14 @@ void main() { test("recoverFromMnemonic using non empty seed on mainnet succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -819,14 +819,14 @@ void main() { test("fullRescan succeeds", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -1011,14 +1011,14 @@ void main() { test("fullRescan fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) @@ -1213,14 +1213,14 @@ void main() { test("prepareSend fails", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -1269,15 +1269,15 @@ void main() { // modify addresses to properly mock data to build a tx final rcv44 = await secureStore.read( - key: testWalletId + "_receiveDerivationsP2PKH"); + key: "${testWalletId}_receiveDerivationsP2PKH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2PKH", + key: "${testWalletId}_receiveDerivationsP2PKH", value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); final rcv84 = await secureStore.read( - key: testWalletId + "_receiveDerivationsP2WPKH"); + key: "${testWalletId}_receiveDerivationsP2WPKH"); await secureStore.write( - key: testWalletId + "_receiveDerivationsP2WPKH", + key: "${testWalletId}_receiveDerivationsP2WPKH", value: rcv84?.replaceFirst( "pw1qvr6ehcm44vvqe96mxy9zw9aa5sa5yezvr2r94s", "pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy")); @@ -1448,7 +1448,7 @@ void main() { // // ); // // // // // set node - // // final wallet = await Hive.openBox(testWalletId); + // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put("nodes", { // // "default": { // // "id": "some nodeID", @@ -1484,14 +1484,14 @@ void main() { test("refresh wallet mutex locked", () async { when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getBatchHistory(args: historyBatchArgs0)) .thenAnswer((_) async => historyBatchResponse); @@ -1553,14 +1553,14 @@ void main() { when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => {"height": 520481, "hex": "some block hex"}); when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, + "hosts": {}, "pruning": null, "server_version": "Unit tests", "protocol_min": "1.4", "protocol_max": "1.4.2", "genesis_hash": GENESIS_HASH_MAINNET, "hash_function": "sha256", - "services": [] + "services": [] }); when(client?.getHistory(scripthash: anyNamed("scripthash"))) .thenAnswer((_) async => []); diff --git a/test/services/coins/wownero/wownero_wallet_test.dart b/test/services/coins/wownero/wownero_wallet_test.dart index 637a40b81..ec1d5a95c 100644 --- a/test/services/coins/wownero/wownero_wallet_test.dart +++ b/test/services/coins/wownero/wownero_wallet_test.dart @@ -66,7 +66,7 @@ void main() async { Hive.registerAdapter(WalletTypeAdapter()); Hive.registerAdapter(UnspentCoinsInfoAdapter()); - final wallets = await Hive.openBox('wallets'); + final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', name); _walletInfoSource = await Hive.openBox(WalletInfo.boxName); From 722a884553b1af798e07356523c15908acaccb7c Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 13:47:51 -0600 Subject: [PATCH 184/192] coin tests code error cleanup --- .gitignore | 1 + .../coins/bitcoin/bitcoin_wallet_test.dart | 102 ++++++++---------- .../bitcoincash/bitcoincash_wallet_test.dart | 31 ++---- .../coins/dogecoin/dogecoin_wallet_test.dart | 28 +---- .../services/coins/firo/firo_wallet_test.dart | 74 ++++++++----- .../coins/namecoin/namecoin_wallet_test.dart | 17 +-- .../coins/particl/particl_wallet_test.dart | 17 +-- 7 files changed, 106 insertions(+), 164 deletions(-) diff --git a/.gitignore b/.gitignore index e2b5c5a6a..ed66fa960 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ libcw_monero.dll libcw_wownero.dll libepic_cash_wallet.dll libmobileliblelantus.dll +/libisar.so diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index 3b3b35e73..82c6e8f57 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -8,9 +8,9 @@ import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; +import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -612,18 +612,6 @@ void main() async { if (!hiveAdaptersRegistered) { hiveAdaptersRegistered = true; - // Registering Transaction Model Adapters - Hive.registerAdapter(TransactionDataAdapter()); - Hive.registerAdapter(TransactionChunkAdapter()); - Hive.registerAdapter(TransactionAdapter()); - Hive.registerAdapter(InputAdapter()); - Hive.registerAdapter(OutputAdapter()); - - // Registering Utxo Model Adapters - Hive.registerAdapter(UtxoDataAdapter()); - Hive.registerAdapter(UtxoObjectAdapter()); - Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -1295,50 +1283,48 @@ void main() async { // // }); // - // test("get utxos fails", () async { - // btc = BitcoinWallet( - // walletId: testWalletId, - // walletName: testWalletName, - // coin: Coin.bitcoinTestNet, - // client: client!, - // cachedClient: cachedClient!, - // tracker: tracker!, - // - // secureStore: secureStore, - // ); - // when(client?.ping()).thenAnswer((_) async => true); - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_TESTNET, - // "hash_function": "sha256", - // "services": [] - // }); - // - // when(client?.getBatchUTXOs(args: anyNamed("args"))) - // .thenThrow(Exception("some exception")); - // - // await btc?.initializeWallet(); - // final utxoData = await btc?.utxoData; - // expect(utxoData, isA()); - // expect(utxoData.toString(), - // r"{totalUserCurrency: $0.00, satoshiBalance: 0, bitcoinBalance: 0, unspentOutputArray: []}"); - // - // final outputs = await btc?.unspentOutputs; - // expect(outputs, isA>()); - // expect(outputs?.length, 0); - // - // verify(client?.ping()).called(1); - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); - // - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // - // }); + test("get utxos fails", () async { + btc = BitcoinWallet( + walletId: testWalletId, + walletName: testWalletName, + coin: Coin.bitcoinTestNet, + client: client!, + cachedClient: cachedClient!, + tracker: tracker!, + secureStore: secureStore, + ); + when(client?.ping()).thenAnswer((_) async => true); + when(client?.getServerFeatures()).thenAnswer((_) async => { + "hosts": {}, + "pruning": null, + "server_version": "Unit tests", + "protocol_min": "1.4", + "protocol_max": "1.4.2", + "genesis_hash": GENESIS_HASH_TESTNET, + "hash_function": "sha256", + "services": [] + }); + + await Hive.openBox(testWalletId); + await Hive.openBox(DB.boxNamePrefs); + + when(client?.getBatchUTXOs(args: anyNamed("args"))) + .thenThrow(Exception("some exception")); + + await btc?.initializeNew(); + await btc?.initializeExisting(); + + final outputs = await btc!.utxos; + expect(outputs, isA>()); + expect(outputs.length, 0); + + verify(client?.ping()).called(1); + verify(client?.getServerFeatures()).called(1); + verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); + + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + }); // // test("chain height fetch, update, and get", () async { // btc = BitcoinWallet( diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index 0a28b9d1f..7bf17df50 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -2,14 +2,14 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; +import 'package:isar/isar.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -22,7 +22,9 @@ import 'bitcoincash_wallet_test_parameters.dart'; @GenerateMocks( [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) -void main() { +void main() async { + await Isar.initializeIsarCore(download: true); + group("bitcoincash constants", () { test("bitcoincash minimum confirmations", () async { expect(MINIMUM_CONFIRMATIONS, 1); @@ -580,18 +582,6 @@ void main() { if (!hiveAdaptersRegistered) { hiveAdaptersRegistered = true; - // Registering Transaction Model Adapters - Hive.registerAdapter(TransactionDataAdapter()); - Hive.registerAdapter(TransactionChunkAdapter()); - Hive.registerAdapter(TransactionAdapter()); - Hive.registerAdapter(InputAdapter()); - Hive.registerAdapter(OutputAdapter()); - - // Registering Utxo Model Adapters - Hive.registerAdapter(UtxoDataAdapter()); - Hive.registerAdapter(UtxoObjectAdapter()); - Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -1162,14 +1152,9 @@ void main() { await bch?.initializeNew(); await bch?.initializeExisting(); - final utxoData = await bch?.utxoData; - expect(utxoData, isA()); - expect(utxoData.toString(), - r"{totalUserCurrency: 0.00, satoshiBalance: 0, bitcoinBalance: 0, unspentOutputArray: []}"); - - final outputs = await bch?.unspentOutputs; - expect(outputs, isA>()); - expect(outputs?.length, 0); + final outputs = await bch!.utxos; + expect(outputs, isA>()); + expect(outputs.length, 0); verifyNever(client?.ping()).called(0); verify(client?.getServerFeatures()).called(1); diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index bc59e7b98..8b2d83eb7 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -1,5 +1,3 @@ -// import 'dart:typed_data'; - import 'package:bitcoindart/bitcoindart.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -10,9 +8,8 @@ import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -473,18 +470,6 @@ void main() { if (!hiveAdaptersRegistered) { hiveAdaptersRegistered = true; - // Registering Transaction Model Adapters - Hive.registerAdapter(TransactionDataAdapter()); - Hive.registerAdapter(TransactionChunkAdapter()); - Hive.registerAdapter(TransactionAdapter()); - Hive.registerAdapter(InputAdapter()); - Hive.registerAdapter(OutputAdapter()); - - // Registering Utxo Model Adapters - Hive.registerAdapter(UtxoDataAdapter()); - Hive.registerAdapter(UtxoObjectAdapter()); - Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -1064,14 +1049,9 @@ void main() { await doge?.initializeNew(); await doge?.initializeExisting(); - final utxoData = await doge?.utxoData; - expect(utxoData, isA()); - expect(utxoData.toString(), - r"{totalUserCurrency: 0.00, satoshiBalance: 0, bitcoinBalance: 0, unspentOutputArray: []}"); - - final outputs = await doge?.unspentOutputs; - expect(outputs, isA>()); - expect(outputs?.length, 0); + final outputs = await doge!.utxos; + expect(outputs, isA>()); + expect(outputs.length, 0); verifyNever(client?.ping()).called(0); verify(client?.getServerFeatures()).called(1); diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index 2fc203a9b..110eab9c1 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -11,7 +11,11 @@ import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/models/models.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/lelantus_coin.dart'; +import 'package:stackwallet/models/lelantus_fee_data.dart'; +import 'package:stackwallet/models/paymint/transactions_model.dart' as old; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -41,7 +45,7 @@ void main() { test("isolateRestore success", () async { final cachedClient = MockCachedElectrumX(); - final txData = TransactionData.fromJson(dateTimeChunksJson); + final txDataOLD = old.TransactionData.fromJson(dateTimeChunksJson); final Map setData = {}; setData[1] = GetAnonymitySetSampleData.data; final usedSerials = GetUsedSerialsSampleData.serials["serials"] as List; @@ -74,6 +78,34 @@ void main() { firoNetwork, ); const currentHeight = 100000000000; + + final txData = txDataOLD + .getAllTransactions() + .values + .map( + (t) => Transaction( + walletId: "walletId", + txid: t.txid, + timestamp: t.timestamp, + type: t.txType == "Sent" + ? TransactionType.outgoing + : TransactionType.incoming, + subType: t.subType == "mint" + ? TransactionSubType.mint + : t.subType == "join" + ? TransactionSubType.join + : TransactionSubType.none, + amount: t.amount, + fee: t.fees, + height: t.height, + isCancelled: t.isCancelled, + isLelantus: null, + slateId: t.slateId, + otherData: t.otherData, + ), + ) + .toList(); + final result = await staticProcessRestore(txData, message, currentHeight); expect(result, isA>()); @@ -512,18 +544,6 @@ void main() { if (!hiveAdaptersRegistered) { hiveAdaptersRegistered = true; - // Registering Transaction Model Adapters - Hive.registerAdapter(TransactionDataAdapter()); - Hive.registerAdapter(TransactionChunkAdapter()); - Hive.registerAdapter(TransactionAdapter()); - Hive.registerAdapter(InputAdapter()); - Hive.registerAdapter(OutputAdapter()); - - // Registering Utxo Model Adapters - Hive.registerAdapter(UtxoDataAdapter()); - Hive.registerAdapter(UtxoObjectAdapter()); - Hive.registerAdapter(StatusAdapter()); - // Registering Lelantus Model Adapters Hive.registerAdapter(LelantusCoinAdapter()); } @@ -1181,21 +1201,19 @@ void main() { const MethodChannel('uk.spiralarm.flutter/devicelocale') .setMockMethodCallHandler((methodCall) async => 'en_US'); - List utxos = [ - UtxoObject( + List utxos = [ + UTXO( txid: BuildMintTxTestParams.utxoInfo["txid"] as String, vout: BuildMintTxTestParams.utxoInfo["vout"] as int, value: BuildMintTxTestParams.utxoInfo["value"] as int, - txName: '', - status: Status( - confirmed: false, - blockHash: "", - blockHeight: -1, - blockTime: 42, - confirmations: 0), isCoinbase: false, - blocked: false, - fiatWorth: '', + walletId: '', + name: '', + isBlocked: false, + blockedReason: '', + blockHash: '', + blockHeight: -1, + blockTime: 42, ) ]; const sats = 9658; @@ -3023,7 +3041,7 @@ void main() { expect(firo.balance.getTotal(), Decimal.parse("0.00021594")); }); - test("get transactionData", () async { + test("get transactions", () async { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); @@ -3118,9 +3136,9 @@ void main() { 'receivingAddresses', RefreshTestParams.receivingAddresses); await wallet.put('changeAddresses', RefreshTestParams.changeAddresses); - final txData = await firo.transactionData; + final txData = await firo.transactions; - expect(txData, isA()); + expect(txData, isA>()); // kill timer and listener await firo.exit(); diff --git a/test/services/coins/namecoin/namecoin_wallet_test.dart b/test/services/coins/namecoin/namecoin_wallet_test.dart index 621f2d9a3..041882470 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.dart @@ -8,8 +8,6 @@ import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; -import 'package:stackwallet/models/paymint/utxo_model.dart'; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -18,7 +16,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'namecoin_history_sample_data.dart'; import 'namecoin_transaction_data_samples.dart'; -import 'namecoin_utxo_sample_data.dart'; import 'namecoin_wallet_test.mocks.dart'; import 'namecoin_wallet_test_parameters.dart'; @@ -442,18 +439,6 @@ void main() { if (!hiveAdaptersRegistered) { hiveAdaptersRegistered = true; - // Registering Transaction Model Adapters - Hive.registerAdapter(TransactionDataAdapter()); - Hive.registerAdapter(TransactionChunkAdapter()); - Hive.registerAdapter(TransactionAdapter()); - Hive.registerAdapter(InputAdapter()); - Hive.registerAdapter(OutputAdapter()); - - // Registering Utxo Model Adapters - Hive.registerAdapter(UtxoDataAdapter()); - Hive.registerAdapter(UtxoObjectAdapter()); - Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -1354,7 +1339,7 @@ void main() { "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); - nmc?.outputsList = utxoList; + // nmc?.outputsList = utxoList; bool didThrow = false; try { diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index 4cac06c9f..1ef429209 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -6,7 +6,7 @@ import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/models/models.dart'; +import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/particl/particl_wallet.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; @@ -15,7 +15,6 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'particl_history_sample_data.dart'; import 'particl_transaction_data_samples.dart'; -import 'particl_utxo_sample_data.dart'; import 'particl_wallet_test.mocks.dart'; import 'particl_wallet_test_parameters.dart'; @@ -489,18 +488,6 @@ void main() { if (!hiveAdaptersRegistered) { hiveAdaptersRegistered = true; - // Registering Transaction Model Adapters - Hive.registerAdapter(TransactionDataAdapter()); - Hive.registerAdapter(TransactionChunkAdapter()); - Hive.registerAdapter(TransactionAdapter()); - Hive.registerAdapter(InputAdapter()); - Hive.registerAdapter(OutputAdapter()); - - // Registering Utxo Model Adapters - Hive.registerAdapter(UtxoDataAdapter()); - Hive.registerAdapter(UtxoObjectAdapter()); - Hive.registerAdapter(StatusAdapter()); - final wallets = await Hive.openBox('wallets'); await wallets.put('currentWalletName', testWalletName); } @@ -1282,7 +1269,7 @@ void main() { "pw1qvr6ehcm44vvqe96mxy9zw9aa5sa5yezvr2r94s", "pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy")); - part?.outputsList = utxoList; + // part?.outputsList = utxoList; bool didThrow = false; try { From ea68e811ecd5b0f02d7a2d8584da9f57b8687dca Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 13:52:50 -0600 Subject: [PATCH 185/192] remove unneeded PriceAPI mock generation for coin tests --- test/services/coins/bitcoin/bitcoin_wallet_test.dart | 4 +--- test/services/coins/bitcoincash/bitcoincash_wallet_test.dart | 4 +--- test/services/coins/dogecoin/dogecoin_wallet_test.dart | 4 +--- test/services/coins/firo/firo_wallet_test.dart | 4 +--- test/services/coins/namecoin/namecoin_wallet_test.dart | 4 +--- test/services/coins/particl/particl_wallet_test.dart | 4 +--- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index 82c6e8f57..3fc19a1fe 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -12,7 +12,6 @@ import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; @@ -22,8 +21,7 @@ import 'bitcoin_transaction_data_samples.dart'; import 'bitcoin_wallet_test.mocks.dart'; import 'bitcoin_wallet_test_parameters.dart'; -@GenerateMocks( - [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) +@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() async { await Isar.initializeIsarCore(download: true); diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index 7bf17df50..258693bcb 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -11,7 +11,6 @@ import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; @@ -20,8 +19,7 @@ import 'bitcoincash_history_sample_data.dart'; import 'bitcoincash_wallet_test.mocks.dart'; import 'bitcoincash_wallet_test_parameters.dart'; -@GenerateMocks( - [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) +@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() async { await Isar.initializeIsarCore(download: true); diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index 8b2d83eb7..14d61e6dd 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -11,7 +11,6 @@ import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; @@ -20,8 +19,7 @@ import 'dogecoin_history_sample_data.dart'; import 'dogecoin_wallet_test.mocks.dart'; import 'dogecoin_wallet_test_parameters.dart'; -@GenerateMocks( - [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) +@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() { group("dogecoin constants", () { test("dogecoin minimum confirmations", () async { diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index 110eab9c1..eb5d1aae2 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -17,7 +17,6 @@ import 'package:stackwallet/models/lelantus_coin.dart'; import 'package:stackwallet/models/lelantus_fee_data.dart'; import 'package:stackwallet/models/paymint/transactions_model.dart' as old; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -32,8 +31,7 @@ import 'sample_data/get_utxos_sample_data.dart'; import 'sample_data/gethistory_samples.dart'; import 'sample_data/transaction_data_samples.dart'; -@GenerateMocks( - [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) +@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() { group("isolate functions", () { test("isolateDerive", () async { diff --git a/test/services/coins/namecoin/namecoin_wallet_test.dart b/test/services/coins/namecoin/namecoin_wallet_test.dart index 041882470..b9a234d69 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.dart @@ -9,7 +9,6 @@ import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; @@ -19,8 +18,7 @@ import 'namecoin_transaction_data_samples.dart'; import 'namecoin_wallet_test.mocks.dart'; import 'namecoin_wallet_test_parameters.dart'; -@GenerateMocks( - [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) +@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() { group("namecoin constants", () { test("namecoin minimum confirmations", () async { diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index 1ef429209..56035e88e 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -8,7 +8,6 @@ import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/particl/particl_wallet.dart'; -import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; @@ -18,8 +17,7 @@ import 'particl_transaction_data_samples.dart'; import 'particl_wallet_test.mocks.dart'; import 'particl_wallet_test_parameters.dart'; -@GenerateMocks( - [ElectrumX, CachedElectrumX, PriceAPI, TransactionNotificationTracker]) +@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() { group("particl constants", () { test("particl minimum confirmations", () async { From daa2648763e52b3ef22b48987df7e52fc48e7a7a Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 13:54:31 -0600 Subject: [PATCH 186/192] builder runner update mocks --- .../bitcoin/bitcoin_wallet_test.mocks.dart | 239 +++++++----------- .../bitcoincash_wallet_test.mocks.dart | 239 +++++++----------- .../dogecoin/dogecoin_wallet_test.mocks.dart | 239 +++++++----------- .../coins/firo/firo_wallet_test.mocks.dart | 239 +++++++----------- .../namecoin/namecoin_wallet_test.mocks.dart | 239 +++++++----------- .../particl/particl_wallet_test.mocks.dart | 239 +++++++----------- 6 files changed, 558 insertions(+), 876 deletions(-) diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart index 32a6c7195..1a01906ea 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart @@ -3,19 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:http/http.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/services/price.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -48,26 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeClient_2 extends _i1.SmartFake implements _i4.Client { - _FakeClient_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -103,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -122,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -142,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -159,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -170,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -181,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -197,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -214,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -230,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -242,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -259,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -271,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -291,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -310,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -326,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -343,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -363,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -379,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -390,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -406,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -441,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -462,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -481,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -497,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -513,66 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [PriceAPI]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockPriceAPI extends _i1.Mock implements _i9.PriceAPI { - MockPriceAPI() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_2( - this, - Invocation.getter(#client), - ), - ) as _i4.Client); - @override - void resetLastCalledToForceNextCallToUpdateCache() => super.noSuchMethod( - Invocation.method( - #resetLastCalledToForceNextCallToUpdateCache, - [], - ), - returnValueForMissingStub: null, - ); - @override - _i6.Future< - Map<_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>> getPricesAnd24hChange( - {required String? baseCurrency}) => - (super.noSuchMethod( - Invocation.method( - #getPricesAnd24hChange, - [], - {#baseCurrency: baseCurrency}, - ), - returnValue: - _i6.Future>>.value( - <_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>{}), - ) as _i6.Future>>); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i11.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -601,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -618,12 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart index bfc5f793b..4f0016262 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart @@ -3,19 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:http/http.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/services/price.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -48,26 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeClient_2 extends _i1.SmartFake implements _i4.Client { - _FakeClient_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -103,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -122,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -142,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -159,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -170,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -181,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -197,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -214,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -230,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -242,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -259,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -271,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -291,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -310,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -326,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -343,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -363,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -379,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -390,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -406,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -441,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -462,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -481,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -497,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -513,66 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [PriceAPI]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockPriceAPI extends _i1.Mock implements _i9.PriceAPI { - MockPriceAPI() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_2( - this, - Invocation.getter(#client), - ), - ) as _i4.Client); - @override - void resetLastCalledToForceNextCallToUpdateCache() => super.noSuchMethod( - Invocation.method( - #resetLastCalledToForceNextCallToUpdateCache, - [], - ), - returnValueForMissingStub: null, - ); - @override - _i6.Future< - Map<_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>> getPricesAnd24hChange( - {required String? baseCurrency}) => - (super.noSuchMethod( - Invocation.method( - #getPricesAnd24hChange, - [], - {#baseCurrency: baseCurrency}, - ), - returnValue: - _i6.Future>>.value( - <_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>{}), - ) as _i6.Future>>); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i11.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -601,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -618,12 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart index f7220922e..ae555da22 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart @@ -3,19 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:http/http.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/services/price.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -48,26 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeClient_2 extends _i1.SmartFake implements _i4.Client { - _FakeClient_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -103,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -122,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -142,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -159,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -170,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -181,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -197,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -214,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -230,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -242,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -259,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -271,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -291,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -310,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -326,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -343,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -363,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -379,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -390,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -406,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -441,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -462,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -481,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -497,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -513,66 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [PriceAPI]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockPriceAPI extends _i1.Mock implements _i9.PriceAPI { - MockPriceAPI() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_2( - this, - Invocation.getter(#client), - ), - ) as _i4.Client); - @override - void resetLastCalledToForceNextCallToUpdateCache() => super.noSuchMethod( - Invocation.method( - #resetLastCalledToForceNextCallToUpdateCache, - [], - ), - returnValueForMissingStub: null, - ); - @override - _i6.Future< - Map<_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>> getPricesAnd24hChange( - {required String? baseCurrency}) => - (super.noSuchMethod( - Invocation.method( - #getPricesAnd24hChange, - [], - {#baseCurrency: baseCurrency}, - ), - returnValue: - _i6.Future>>.value( - <_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>{}), - ) as _i6.Future>>); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i11.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -601,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -618,12 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/firo/firo_wallet_test.mocks.dart b/test/services/coins/firo/firo_wallet_test.mocks.dart index 2d32cef48..ac107eaa2 100644 --- a/test/services/coins/firo/firo_wallet_test.mocks.dart +++ b/test/services/coins/firo/firo_wallet_test.mocks.dart @@ -3,19 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:http/http.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/services/price.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -48,26 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeClient_2 extends _i1.SmartFake implements _i4.Client { - _FakeClient_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -103,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -122,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -142,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -159,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -170,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -181,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -197,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -214,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -230,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -242,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -259,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -271,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -291,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -310,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -326,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -343,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -363,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -379,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -390,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -406,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -441,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -462,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -481,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -497,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -513,66 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [PriceAPI]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockPriceAPI extends _i1.Mock implements _i9.PriceAPI { - MockPriceAPI() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_2( - this, - Invocation.getter(#client), - ), - ) as _i4.Client); - @override - void resetLastCalledToForceNextCallToUpdateCache() => super.noSuchMethod( - Invocation.method( - #resetLastCalledToForceNextCallToUpdateCache, - [], - ), - returnValueForMissingStub: null, - ); - @override - _i6.Future< - Map<_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>> getPricesAnd24hChange( - {required String? baseCurrency}) => - (super.noSuchMethod( - Invocation.method( - #getPricesAnd24hChange, - [], - {#baseCurrency: baseCurrency}, - ), - returnValue: - _i6.Future>>.value( - <_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>{}), - ) as _i6.Future>>); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i11.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -601,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -618,12 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart index 91c3e5bfa..47870a622 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart @@ -3,19 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:http/http.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/services/price.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -48,26 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeClient_2 extends _i1.SmartFake implements _i4.Client { - _FakeClient_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -103,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -122,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -142,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -159,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -170,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -181,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -197,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -214,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -230,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -242,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -259,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -271,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -291,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -310,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -326,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -343,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -363,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -379,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -390,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -406,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -441,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -462,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -481,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -497,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -513,66 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [PriceAPI]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockPriceAPI extends _i1.Mock implements _i9.PriceAPI { - MockPriceAPI() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_2( - this, - Invocation.getter(#client), - ), - ) as _i4.Client); - @override - void resetLastCalledToForceNextCallToUpdateCache() => super.noSuchMethod( - Invocation.method( - #resetLastCalledToForceNextCallToUpdateCache, - [], - ), - returnValueForMissingStub: null, - ); - @override - _i6.Future< - Map<_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>> getPricesAnd24hChange( - {required String? baseCurrency}) => - (super.noSuchMethod( - Invocation.method( - #getPricesAnd24hChange, - [], - {#baseCurrency: baseCurrency}, - ), - returnValue: - _i6.Future>>.value( - <_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>{}), - ) as _i6.Future>>); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i11.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -601,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -618,12 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/particl/particl_wallet_test.mocks.dart b/test/services/coins/particl/particl_wallet_test.mocks.dart index fb0f50d79..ab2e8f310 100644 --- a/test/services/coins/particl/particl_wallet_test.mocks.dart +++ b/test/services/coins/particl/particl_wallet_test.mocks.dart @@ -3,19 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:http/http.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/services/price.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i11; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -48,26 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeClient_2 extends _i1.SmartFake implements _i4.Client { - _FakeClient_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -103,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -122,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -142,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -159,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -170,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -181,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -197,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -214,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -230,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -242,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -259,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -271,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -291,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -310,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -326,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -343,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -363,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -379,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -390,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -406,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -441,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -462,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -481,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -497,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -513,66 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [PriceAPI]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockPriceAPI extends _i1.Mock implements _i9.PriceAPI { - MockPriceAPI() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Client get client => (super.noSuchMethod( - Invocation.getter(#client), - returnValue: _FakeClient_2( - this, - Invocation.getter(#client), - ), - ) as _i4.Client); - @override - void resetLastCalledToForceNextCallToUpdateCache() => super.noSuchMethod( - Invocation.method( - #resetLastCalledToForceNextCallToUpdateCache, - [], - ), - returnValueForMissingStub: null, - ); - @override - _i6.Future< - Map<_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>> getPricesAnd24hChange( - {required String? baseCurrency}) => - (super.noSuchMethod( - Invocation.method( - #getPricesAnd24hChange, - [], - {#baseCurrency: baseCurrency}, - ), - returnValue: - _i6.Future>>.value( - <_i8.Coin, _i10.Tuple2<_i2.Decimal, double>>{}), - ) as _i6.Future>>); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i11.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -601,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -618,12 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } From 8921302ee030a1b0ce59ceb59c1a8bcd2e97766d Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 14:07:08 -0600 Subject: [PATCH 187/192] remove useless walletId param from db init --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 4 ++-- lib/services/coins/bitcoincash/bitcoincash_wallet.dart | 6 +++--- lib/services/coins/dogecoin/dogecoin_wallet.dart | 6 +++--- lib/services/coins/epiccash/epiccash_wallet.dart | 6 +++--- lib/services/coins/firo/firo_wallet.dart | 6 +++--- lib/services/coins/litecoin/litecoin_wallet.dart | 6 +++--- lib/services/coins/monero/monero_wallet.dart | 4 ++-- lib/services/coins/namecoin/namecoin_wallet.dart | 6 +++--- lib/services/coins/particl/particl_wallet.dart | 6 +++--- lib/services/coins/wownero/wownero_wallet.dart | 4 ++-- lib/services/mixins/wallet_db.dart | 2 +- lib/utilities/db_version_migration.dart | 2 +- test/pages/send_view/send_view_test.mocks.dart | 4 ++-- test/services/coins/manager_test.mocks.dart | 4 ++-- test/widget_tests/managed_favorite_test.mocks.dart | 4 ++-- test/widget_tests/table_view/table_view_row_test.mocks.dart | 4 ++-- test/widget_tests/transaction_card_test.mocks.dart | 4 ++-- test/widget_tests/wallet_card_test.mocks.dart | 4 ++-- .../wallet_info_row_balance_future_test.mocks.dart | 4 ++-- .../wallet_info_row/wallet_info_row_test.mocks.dart | 4 ++-- 20 files changed, 45 insertions(+), 45 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 678d3810c..3e6ae4819 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -659,7 +659,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(walletId); + await isarInit(); await db.putAddresses([ ...p2wpkhReceiveAddressArray, @@ -1164,7 +1164,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(walletId); + await isarInit(); } // hack to add tx to txData before refresh completes diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index b517c7de5..81d98ca19 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -604,7 +604,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { p2shChangeAddressArray.add(address); } - await isarInit(walletId); + await isarInit(); await db.putAddresses([ ...p2pkhReceiveAddressArray, @@ -1094,7 +1094,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(walletId); + await isarInit(); } // hack to add tx to txData before refresh completes @@ -1372,7 +1372,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(walletId); + await isarInit(); await db.putAddresses(initialAddresses); diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 1bdc98fbf..b4ae07a9b 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -519,7 +519,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2pkhChangeAddressArray.add(address); } - await isarInit(walletId); + await isarInit(); await db.putAddresses([ ...p2pkhReceiveAddressArray, @@ -999,7 +999,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(walletId); + await isarInit(); } // hack to add tx to txData before refresh completes @@ -1234,7 +1234,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final initialChangeAddressP2PKH = await _generateAddressForChain(1, 0, DerivePathType.bip44); - await isarInit(walletId); + await isarInit(); await db.putAddresses([ initialReceivingAddressP2PKH, diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 7d3c70b93..878f4672e 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -969,7 +969,7 @@ class EpicCashWallet extends CoinServiceAPI Logging.instance.log("Opening existing ${coin.prettyName} wallet", level: LogLevel.Info); - await isarInit(walletId); + await isarInit(); final config = await getRealConfig(); final password = await _secureStore.read(key: '${_walletId}_password'); @@ -1039,7 +1039,7 @@ class EpicCashWallet extends CoinServiceAPI String stringConfig = await getConfig(); String epicboxConfig = await getEpicBoxConfig(); - await isarInit(walletId); + await isarInit(); await _secureStore.write( key: '${_walletId}_mnemonic', value: mnemonicString); @@ -1081,7 +1081,7 @@ class EpicCashWallet extends CoinServiceAPI epicUpdateChangeIndex(0), ]); - await isarInit(walletId); + await isarInit(); final initialReceivingAddress = await _getReceivingAddressForIndex(0); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index aac0b5ccd..15e408ccd 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -1828,7 +1828,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(walletId); + await isarInit(); } Future refreshIfThereIsNewData() async { @@ -2099,7 +2099,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final initialReceivingAddress = await _generateAddressForChain(0, 0); final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(walletId); + await isarInit(); await db.putAddresses([ initialReceivingAddress, @@ -4292,7 +4292,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Logging.instance .log("PROCESSORS ${Platform.numberOfProcessors}", level: LogLevel.Info); try { - await isarInit(walletId); + await isarInit(); final latestSetId = await getLatestSetId(); final setDataMap = getSetDataMap(latestSetId); diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 0b68132b3..f3d2bf44a 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -677,7 +677,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(walletId); + await isarInit(); await db.putAddresses([ ...p2wpkhReceiveAddressArray, @@ -1182,7 +1182,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(walletId); + await isarInit(); } // hack to add tx to txData before refresh completes @@ -1473,7 +1473,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(walletId); + await isarInit(); await db.putAddresses(initialAddresses); diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 242683d87..689f05894 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -269,7 +269,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await isarInit(walletId); + await isarInit(); // final data = // DB.instance.get(boxName: walletId, key: "latest_tx_model") // as TransactionData?; @@ -389,7 +389,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(walletId); + await isarInit(); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 26ee63983..25ee0c590 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -667,7 +667,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(walletId); + await isarInit(); await db.putAddresses([ ...p2wpkhReceiveAddressArray, @@ -1171,7 +1171,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(walletId); + await isarInit(); } // hack to add tx to txData before refresh completes @@ -1450,7 +1450,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(walletId); + await isarInit(); await db.putAddresses(initialAddresses); diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 5caaea47a..30be6f966 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -602,7 +602,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(walletId); + await isarInit(); await db.putAddresses([ ...p2wpkhReceiveAddressArray, @@ -1101,7 +1101,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(walletId); + await isarInit(); } // TODO make sure this copied implementation from bitcoin_wallet.dart applies for particl just as well--or import it @@ -1364,7 +1364,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip44), ]); - await isarInit(walletId); + await isarInit(); await db.putAddresses(initialAddresses); diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index d295ac68c..2d031b290 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -293,7 +293,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await isarInit(walletId); + await isarInit(); String? password; try { @@ -397,7 +397,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(walletId); + await isarInit(); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index a1c68408f..5d442d56f 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -6,7 +6,7 @@ import 'package:tuple/tuple.dart'; mixin WalletDB { MainDB get db => MainDB.instance; - Future isarInit(String walletId) async { + Future isarInit() async { await db.isarInit(); } diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index b3fb1ca5e..25eaf86d9 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -403,7 +403,7 @@ class DbVersionMigrator with WalletDB { _parseTransactions(txnsLelantus, walletId, true, newAddresses)); // store newly parsed data in isar - await isarInit(walletId); + await isarInit(); await db.isar.writeTxn(() async { await db.isar.addresses.putAll(newAddresses); }); diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 9479bb190..5cc3a41b7 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -1558,10 +1558,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index 48582fca8..f3a321238 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -978,10 +978,10 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i10.Future isarInit(String? walletId) => (super.noSuchMethod( + _i10.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i10.Future.value(), returnValueForMissingStub: _i10.Future.value(), diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 90be31d3f..8217b6d42 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -1348,10 +1348,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), 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 2535d905e..7c3b50370 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 @@ -1333,10 +1333,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: _i16.Future.value(), ) as _i16.Future); @override - _i16.Future isarInit(String? walletId) => (super.noSuchMethod( + _i16.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i16.Future.value(), returnValueForMissingStub: _i16.Future.value(), diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 2fa1ed27b..554acc38a 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -1891,10 +1891,10 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: _i18.Future.value(), ) as _i18.Future); @override - _i18.Future isarInit(String? walletId) => (super.noSuchMethod( + _i18.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i18.Future.value(), returnValueForMissingStub: _i18.Future.value(), diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 3dd40d057..8ae43ff12 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -1096,10 +1096,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: _i15.Future.value(), ) as _i15.Future); @override - _i15.Future isarInit(String? walletId) => (super.noSuchMethod( + _i15.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i15.Future.value(), returnValueForMissingStub: _i15.Future.value(), 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 5cd61baef..a7acaf138 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 @@ -1347,10 +1347,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), 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 b42a0843e..b5179f019 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 @@ -1347,10 +1347,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit(String? walletId) => (super.noSuchMethod( + _i17.Future isarInit() => (super.noSuchMethod( Invocation.method( #isarInit, - [walletId], + [], ), returnValue: _i17.Future.value(), returnValueForMissingStub: _i17.Future.value(), From 60e850f44269fbb1688126d6a1261fe0ce6b8b30 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 14:33:23 -0600 Subject: [PATCH 188/192] add mockable override option for testing purposes --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 6 +++--- .../coins/bitcoincash/bitcoincash_wallet.dart | 8 +++----- .../coins/dogecoin/dogecoin_wallet.dart | 9 ++++----- .../coins/epiccash/epiccash_wallet.dart | 18 +++++++++--------- lib/services/coins/firo/firo_wallet.dart | 8 +++----- .../coins/litecoin/litecoin_wallet.dart | 8 +++----- lib/services/coins/monero/monero_wallet.dart | 6 ++++-- .../coins/namecoin/namecoin_wallet.dart | 8 +++----- lib/services/coins/particl/particl_wallet.dart | 8 +++----- lib/services/coins/wownero/wownero_wallet.dart | 5 +++-- lib/services/mixins/wallet_db.dart | 7 ++++--- lib/utilities/db_version_migration.dart | 2 +- test/pages/send_view/send_view_test.mocks.dart | 8 ++++---- .../coins/bitcoin/bitcoin_wallet_test.dart | 3 --- .../bitcoincash/bitcoincash_wallet_test.dart | 3 --- test/services/coins/manager_test.mocks.dart | 8 ++++---- .../managed_favorite_test.mocks.dart | 8 ++++---- .../table_view/table_view_row_test.mocks.dart | 8 ++++---- .../transaction_card_test.mocks.dart | 8 ++++---- test/widget_tests/wallet_card_test.mocks.dart | 8 ++++---- ...let_info_row_balance_future_test.mocks.dart | 8 ++++---- .../wallet_info_row_test.mocks.dart | 8 ++++---- 22 files changed, 75 insertions(+), 88 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 3e6ae4819..21e4e44c2 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -10,6 +10,7 @@ import 'package:bs58check/bs58check.dart' as bs58check; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -659,8 +660,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1164,7 +1163,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1249,6 +1247,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1258,6 +1257,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 81d98ca19..9f7c6f22c 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -11,6 +11,7 @@ import 'package:bs58check/bs58check.dart' as bs58check; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -604,8 +605,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { p2shChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2pkhReceiveAddressArray, ...p2pkhChangeAddressArray, @@ -1094,7 +1093,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1206,6 +1204,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1215,6 +1214,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1372,8 +1372,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index b4ae07a9b..c250a4abb 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -41,6 +41,8 @@ import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; +import '../../../db/main_db.dart'; + const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 1000000; @@ -519,8 +521,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2pkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2pkhReceiveAddressArray, ...p2pkhChangeAddressArray, @@ -999,7 +999,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1084,6 +1083,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1093,6 +1093,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1234,8 +1235,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final initialChangeAddressP2PKH = await _generateAddressForChain(1, 0, DerivePathType.bip44); - await isarInit(); - await db.putAddresses([ initialReceivingAddressP2PKH, initialChangeAddressP2PKH, diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 878f4672e..e50247bda 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -10,6 +10,7 @@ import 'package:http/http.dart'; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:stack_wallet_backup/generate_password.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/node_model.dart'; @@ -528,17 +529,20 @@ class EpicCashWallet extends CoinServiceAPI NodeModel? _epicNode; - EpicCashWallet( - {required String walletId, - required String walletName, - required Coin coin, - required SecureStorageInterface secureStore}) { + EpicCashWallet({ + required String walletId, + required String walletName, + required Coin coin, + required SecureStorageInterface secureStore, + MainDB? mockableOverride, + }) { _walletId = walletId; _walletName = walletName; _coin = coin; _secureStore = secureStore; initCache(walletId, coin); initEpicCashHive(walletId); + isarInit(mockableOverride: mockableOverride); Logging.instance.log("$walletName isolate length: ${isolates.length}", level: LogLevel.Info); @@ -969,7 +973,6 @@ class EpicCashWallet extends CoinServiceAPI Logging.instance.log("Opening existing ${coin.prettyName} wallet", level: LogLevel.Info); - await isarInit(); final config = await getRealConfig(); final password = await _secureStore.read(key: '${_walletId}_password'); @@ -1039,8 +1042,6 @@ class EpicCashWallet extends CoinServiceAPI String stringConfig = await getConfig(); String epicboxConfig = await getEpicBoxConfig(); - await isarInit(); - await _secureStore.write( key: '${_walletId}_mnemonic', value: mnemonicString); await _secureStore.write(key: '${_walletId}_config', value: stringConfig); @@ -1081,7 +1082,6 @@ class EpicCashWallet extends CoinServiceAPI epicUpdateChangeIndex(0), ]); - await isarInit(); final initialReceivingAddress = await _getReceivingAddressForIndex(0); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 15e408ccd..4a8994cff 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -11,6 +11,7 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:lelantus/lelantus.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -1213,6 +1214,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1223,6 +1225,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { _secureStore = secureStore; initCache(walletId, coin); initFiroHive(walletId); + isarInit(mockableOverride: mockableOverride); Logging.instance.log("$walletName isolates length: ${isolates.length}", level: LogLevel.Info); @@ -1828,7 +1831,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } Future refreshIfThereIsNewData() async { @@ -2099,8 +2101,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final initialReceivingAddress = await _generateAddressForChain(0, 0); final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(); - await db.putAddresses([ initialReceivingAddress, initialChangeAddress, @@ -4292,8 +4292,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Logging.instance .log("PROCESSORS ${Platform.numberOfProcessors}", level: LogLevel.Info); try { - await isarInit(); - final latestSetId = await getLatestSetId(); final setDataMap = getSetDataMap(latestSetId); final usedSerialNumbers = getUsedCoinSerials(); diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index f3d2bf44a..72a14649b 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -677,8 +678,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1182,7 +1181,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1267,6 +1265,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1276,6 +1275,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1473,8 +1473,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 689f05894..40055e953 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -23,6 +23,7 @@ import 'package:flutter_libmonero/monero/monero.dart'; import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; @@ -83,6 +84,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { required Coin coin, required SecureStorageInterface secureStorage, Prefs? prefs, + MainDB? mockableOverride, }) { _walletId = walletId; _walletName = walletName; @@ -90,6 +92,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { _secureStorage = secureStorage; _prefs = prefs ?? Prefs.instance; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -269,7 +272,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await isarInit(); + // final data = // DB.instance.get(boxName: walletId, key: "latest_tx_model") // as TransactionData?; @@ -389,7 +392,6 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 25ee0c590..fd7515ebc 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -667,8 +668,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1171,7 +1170,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1256,6 +1254,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1265,6 +1264,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1450,8 +1450,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 30be6f966..b7b8197f6 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -602,8 +603,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1101,7 +1100,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } // TODO make sure this copied implementation from bitcoin_wallet.dart applies for particl just as well--or import it @@ -1187,6 +1185,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1196,6 +1195,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1364,8 +1364,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip44), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 2d031b290..d6b8f9396 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -25,6 +25,7 @@ import 'package:flutter_libmonero/view_model/send/output.dart' import 'package:flutter_libmonero/wownero/wownero.dart'; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; @@ -85,6 +86,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { required Coin coin, required SecureStorageInterface secureStorage, Prefs? prefs, + MainDB? mockableOverride, }) { _walletId = walletId; _walletName = walletName; @@ -92,6 +94,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { _secureStorage = secureStorage; _prefs = prefs ?? Prefs.instance; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -293,7 +296,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await isarInit(); String? password; try { @@ -397,7 +399,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 5d442d56f..11f1619f3 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -4,10 +4,11 @@ import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:tuple/tuple.dart'; mixin WalletDB { - MainDB get db => MainDB.instance; + MainDB? _db; + MainDB get db => _db!; - Future isarInit() async { - await db.isarInit(); + void isarInit({MainDB? mockableOverride}) async { + _db = mockableOverride ?? MainDB.instance; } Future addNewTransactionData( diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index 25eaf86d9..372a37997 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -403,7 +403,7 @@ class DbVersionMigrator with WalletDB { _parseTransactions(txnsLelantus, walletId, true, newAddresses)); // store newly parsed data in isar - await isarInit(); + isarInit(); await db.isar.writeTxn(() async { await db.isar.addresses.putAll(newAddresses); }); diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 5cc3a41b7..b16a2a675 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -1558,14 +1558,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i13.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List< diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index 3fc19a1fe..33f40659c 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -3,7 +3,6 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; -import 'package:isar/isar.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; @@ -23,8 +22,6 @@ import 'bitcoin_wallet_test_parameters.dart'; @GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() async { - await Isar.initializeIsarCore(download: true); - group("bitcoin constants", () { test("bitcoin minimum confirmations", () async { expect(MINIMUM_CONFIRMATIONS, 1); diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index 258693bcb..464b5fb58 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -2,7 +2,6 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; -import 'package:isar/isar.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; @@ -21,8 +20,6 @@ import 'bitcoincash_wallet_test_parameters.dart'; @GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() async { - await Isar.initializeIsarCore(download: true); - group("bitcoincash constants", () { test("bitcoincash minimum confirmations", () async { expect(MINIMUM_CONFIRMATIONS, 1); diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index f3a321238..7944c0767 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -978,14 +978,14 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i10.Future isarInit() => (super.noSuchMethod( + void isarInit({_i7.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i10.Future.value(), - returnValueForMissingStub: _i10.Future.value(), - ) as _i10.Future); + returnValueForMissingStub: null, + ); @override _i10.Future addNewTransactionData( List< diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 8217b6d42..961777add 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -1348,14 +1348,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List< 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 7c3b50370..8639ec3f6 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 @@ -1333,14 +1333,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: _i16.Future.value(), ) as _i16.Future); @override - _i16.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValueForMissingStub: null, + ); @override _i16.Future addNewTransactionData( List< diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 554acc38a..915942570 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -1891,14 +1891,14 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: _i18.Future.value(), ) as _i18.Future); @override - _i18.Future isarInit() => (super.noSuchMethod( + void isarInit({_i13.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValueForMissingStub: null, + ); @override _i18.Future addNewTransactionData( List< diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 8ae43ff12..b802b64dd 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -1096,14 +1096,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: _i15.Future.value(), ) as _i15.Future); @override - _i15.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValueForMissingStub: null, + ); @override _i15.Future addNewTransactionData( List< 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 a7acaf138..8f37d1879 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 @@ -1347,14 +1347,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List< 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 b5179f019..e72c999cb 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 @@ -1347,14 +1347,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List< From fd5a2371702dc202f4b6366d273489de2d2d3cc5 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 15:13:03 -0600 Subject: [PATCH 189/192] move db modifying func to MainDB out of WalletDb, add MainDB mocks to coin tests, build runner generate mocks --- lib/db/main_db.dart | 54 ++ .../coins/bitcoin/bitcoin_wallet.dart | 2 +- .../coins/bitcoincash/bitcoincash_wallet.dart | 2 +- .../coins/dogecoin/dogecoin_wallet.dart | 5 +- .../coins/epiccash/epiccash_wallet.dart | 2 +- lib/services/coins/firo/firo_wallet.dart | 8 +- .../coins/litecoin/litecoin_wallet.dart | 2 +- lib/services/coins/monero/monero_wallet.dart | 2 +- .../coins/namecoin/namecoin_wallet.dart | 2 +- .../coins/particl/particl_wallet.dart | 2 +- .../coins/wownero/wownero_wallet.dart | 2 +- lib/services/mixins/wallet_db.dart | 58 -- lib/utilities/db_version_migration.dart | 2 +- .../pages/send_view/send_view_test.mocks.dart | 54 +- .../coins/bitcoin/bitcoin_wallet_test.dart | 34 +- .../bitcoin/bitcoin_wallet_test.mocks.dart | 501 ++++++++++++++---- .../bitcoincash/bitcoincash_wallet_test.dart | 41 +- .../bitcoincash_wallet_test.mocks.dart | 501 ++++++++++++++---- .../coins/dogecoin/dogecoin_wallet_test.dart | 33 +- .../dogecoin/dogecoin_wallet_test.mocks.dart | 501 ++++++++++++++---- .../services/coins/firo/firo_wallet_test.dart | 52 +- .../coins/firo/firo_wallet_test.mocks.dart | 501 ++++++++++++++---- test/services/coins/manager_test.mocks.dart | 20 - .../coins/monero/monero_wallet_test.dart | 39 +- .../monero/monero_wallet_test.mocks.dart | 333 ++++++++++++ .../coins/namecoin/namecoin_wallet_test.dart | 22 +- .../namecoin/namecoin_wallet_test.mocks.dart | 501 ++++++++++++++---- .../coins/particl/particl_wallet_test.dart | 22 +- .../particl/particl_wallet_test.mocks.dart | 501 ++++++++++++++---- .../coins/wownero/wownero_wallet_test.dart | 37 +- .../wownero/wownero_wallet_test.mocks.dart | 333 ++++++++++++ .../managed_favorite_test.mocks.dart | 64 +-- .../table_view/table_view_row_test.mocks.dart | 20 - .../transaction_card_test.mocks.dart | 19 - test/widget_tests/wallet_card_test.mocks.dart | 24 +- ...et_info_row_balance_future_test.mocks.dart | 60 +-- .../wallet_info_row_test.mocks.dart | 60 +-- 37 files changed, 3486 insertions(+), 930 deletions(-) create mode 100644 test/services/coins/monero/monero_wallet_test.mocks.dart create mode 100644 test/services/coins/wownero/wownero_wallet_test.mocks.dart diff --git a/lib/db/main_db.dart b/lib/db/main_db.dart index cc4e50952..33bc15f12 100644 --- a/lib/db/main_db.dart +++ b/lib/db/main_db.dart @@ -1,6 +1,7 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/utilities/stack_file_system.dart'; +import 'package:tuple/tuple.dart'; class MainDB { MainDB._(); @@ -175,4 +176,57 @@ class MainDB { } }); } + + Future addNewTransactionData( + List, List, Address?>> + transactionsData, + String walletId) async { + await isar.writeTxn(() async { + for (final data in transactionsData) { + final tx = data.item1; + + final potentiallyUnconfirmedTx = await getTransactions(walletId) + .filter() + .txidEqualTo(tx.txid) + .findFirst(); + if (potentiallyUnconfirmedTx != null) { + // update use id to replace tx + tx.id = potentiallyUnconfirmedTx.id; + await isar.transactions.delete(potentiallyUnconfirmedTx.id); + } + // save transaction + await isar.transactions.put(tx); + + // link and save outputs + if (data.item2.isNotEmpty) { + await isar.outputs.putAll(data.item2); + tx.outputs.addAll(data.item2); + await tx.outputs.save(); + } + + // link and save inputs + if (data.item3.isNotEmpty) { + await isar.inputs.putAll(data.item3); + tx.inputs.addAll(data.item3); + await tx.inputs.save(); + } + + if (data.item4 != null) { + final address = await getAddresses(walletId) + .filter() + .valueEqualTo(data.item4!.value) + .findFirst(); + + // check if address exists in db and add if it does not + if (address == null) { + await isar.addresses.put(data.item4!); + } + + // link and save address + tx.address.value = address ?? data.item4!; + await tx.address.save(); + } + } + }); + } } diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 21e4e44c2..b3ea2485f 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -2113,7 +2113,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 9f7c6f22c..b5338c443 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2191,7 +2191,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } - await addNewTransactionData(txns, walletId); + await db.addNewTransactionData(txns, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index c250a4abb..9fc5d2f04 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -11,6 +11,7 @@ import 'package:bs58check/bs58check.dart' as bs58check; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -41,8 +42,6 @@ import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; -import '../../../db/main_db.dart'; - const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 1000000; @@ -1934,7 +1933,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txns.add(txn); } - await addNewTransactionData(txns, walletId); + await db.addNewTransactionData(txns, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index e50247bda..3e569d0ea 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -2113,7 +2113,7 @@ class EpicCashWallet extends CoinServiceAPI // Logging.instance.log("cmap: $cachedMap", level: LogLevel.Info); } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 4a8994cff..dcb4153a7 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -2879,7 +2879,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { txnsData.add(Tuple4(value.item2, outs, ins, transactionAddress)); } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // // update the _lelantusTransactionData // final models.TransactionData newTxData = @@ -3021,7 +3021,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { txnsData.add(Tuple4(transaction, [], [], transactionAddress)); - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // final models.TransactionData newTxData = // models.TransactionData.fromMap(transactions); @@ -3566,7 +3566,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { txnsData.add(Tuple4(tx, outs, ins, transactionAddress)); } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed @@ -4399,7 +4399,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { txnsData.add(Tuple4(value.item2, outs, ins, transactionAddress)); } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); } Future>> fetchAnonymitySets() async { diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index 72a14649b..25e963b4b 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -2193,7 +2193,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 40055e953..2452099ad 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -910,7 +910,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index fd7515ebc..34728bcc3 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2179,7 +2179,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { txnsData.add(data); } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index b7b8197f6..c4afcd1ed 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -2346,7 +2346,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { txns.add(Tuple4(tx, outputs, inputs, transactionAddress)); } - await addNewTransactionData(txns, walletId); + await db.addNewTransactionData(txns, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index d6b8f9396..126cc2eb3 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -978,7 +978,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { } } - await addNewTransactionData(txnsData, walletId); + await db.addNewTransactionData(txnsData, walletId); // quick hack to notify manager to call notifyListeners if // transactions changed diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 11f1619f3..c1e02c9a2 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -1,7 +1,4 @@ -import 'package:isar/isar.dart'; import 'package:stackwallet/db/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:tuple/tuple.dart'; mixin WalletDB { MainDB? _db; @@ -10,59 +7,4 @@ mixin WalletDB { void isarInit({MainDB? mockableOverride}) async { _db = mockableOverride ?? MainDB.instance; } - - Future addNewTransactionData( - List, List, Address?>> - transactionsData, - String walletId) async { - await db.isar.writeTxn(() async { - for (final data in transactionsData) { - final tx = data.item1; - - final potentiallyUnconfirmedTx = await db - .getTransactions(walletId) - .filter() - .txidEqualTo(tx.txid) - .findFirst(); - if (potentiallyUnconfirmedTx != null) { - // update use id to replace tx - tx.id = potentiallyUnconfirmedTx.id; - await db.isar.transactions.delete(potentiallyUnconfirmedTx.id); - } - // save transaction - await db.isar.transactions.put(tx); - - // link and save outputs - if (data.item2.isNotEmpty) { - await db.isar.outputs.putAll(data.item2); - tx.outputs.addAll(data.item2); - await tx.outputs.save(); - } - - // link and save inputs - if (data.item3.isNotEmpty) { - await db.isar.inputs.putAll(data.item3); - tx.inputs.addAll(data.item3); - await tx.inputs.save(); - } - - if (data.item4 != null) { - final address = await db - .getAddresses(walletId) - .filter() - .valueEqualTo(data.item4!.value) - .findFirst(); - - // check if address exists in db and add if it does not - if (address == null) { - await db.isar.addresses.put(data.item4!); - } - - // link and save address - tx.address.value = address ?? data.item4!; - await tx.address.save(); - } - } - }); - } } diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index 372a37997..9562f168c 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -407,7 +407,7 @@ class DbVersionMigrator with WalletDB { await db.isar.writeTxn(() async { await db.isar.addresses.putAll(newAddresses); }); - await addNewTransactionData(newTransactions, walletId); + await db.addNewTransactionData(newTransactions, walletId); // delete data from hive await walletBox.delete(receiveAddressesPrefix); diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index b16a2a675..1fd95c2a2 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -17,23 +17,22 @@ import 'package:stackwallet/models/isar/models/isar_models.dart' as _i22; import 'package:stackwallet/models/node_model.dart' as _i20; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart' - as _i26; + as _i25; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i21; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i24; +import 'package:stackwallet/services/locale_service.dart' as _i23; 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 _i15; import 'package:stackwallet/services/wallets_service.dart' as _i2; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i27; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i26; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i25; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i24; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i18; -import 'package:tuple/tuple.dart' as _i23; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1566,31 +1565,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { ), returnValueForMissingStub: null, ); - @override - _i17.Future addNewTransactionData( - List< - _i23.Tuple4<_i22.Transaction, List<_i22.Output>, List<_i22.Input>, - _i22.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i24.LocaleService { +class MockLocaleService extends _i1.Mock implements _i23.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1708,12 +1688,12 @@ class MockPrefs extends _i1.Mock implements _i18.Prefs { returnValueForMissingStub: null, ); @override - _i25.SyncingType get syncType => (super.noSuchMethod( + _i24.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i25.SyncingType.currentWalletOnly, - ) as _i25.SyncingType); + returnValue: _i24.SyncingType.currentWalletOnly, + ) as _i24.SyncingType); @override - set syncType(_i25.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i24.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -1773,12 +1753,12 @@ class MockPrefs extends _i1.Mock implements _i18.Prefs { returnValueForMissingStub: null, ); @override - _i26.ExchangeRateType get exchangeRateType => (super.noSuchMethod( + _i25.ExchangeRateType get exchangeRateType => (super.noSuchMethod( Invocation.getter(#exchangeRateType), - returnValue: _i26.ExchangeRateType.estimated, - ) as _i26.ExchangeRateType); + returnValue: _i25.ExchangeRateType.estimated, + ) as _i25.ExchangeRateType); @override - set exchangeRateType(_i26.ExchangeRateType? exchangeRateType) => + set exchangeRateType(_i25.ExchangeRateType? exchangeRateType) => super.noSuchMethod( Invocation.setter( #exchangeRateType, @@ -1860,12 +1840,12 @@ class MockPrefs extends _i1.Mock implements _i18.Prefs { returnValueForMissingStub: null, ); @override - _i27.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i26.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i27.BackupFrequencyType.everyTenMinutes, - ) as _i27.BackupFrequencyType); + returnValue: _i26.BackupFrequencyType.everyTenMinutes, + ) as _i26.BackupFrequencyType); @override - set backupFrequencyType(_i27.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i26.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index 33f40659c..d28232d7e 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -5,6 +5,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; @@ -20,7 +21,12 @@ import 'bitcoin_transaction_data_samples.dart'; import 'bitcoin_wallet_test.mocks.dart'; import 'bitcoin_wallet_test_parameters.dart'; -@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) +@GenerateMocks([ + ElectrumX, + CachedElectrumX, + TransactionNotificationTracker, + MainDB, +]) void main() async { group("bitcoin constants", () { test("bitcoin minimum confirmations", () async { @@ -100,7 +106,7 @@ void main() async { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - + late MockMainDB mockMainDB; BitcoinWallet? testnetWallet; setUp(() { @@ -108,6 +114,7 @@ void main() async { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); testnetWallet = BitcoinWallet( walletId: "validateAddressTestNet", @@ -117,6 +124,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -182,7 +190,7 @@ void main() async { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - + late MockMainDB mockMainDB; BitcoinWallet? mainnetWallet; setUp(() { @@ -190,6 +198,7 @@ void main() async { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); mainnetWallet = BitcoinWallet( walletId: "validateAddressMainNet", @@ -199,6 +208,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -337,13 +347,13 @@ void main() async { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - + late MockMainDB mockMainDB; BitcoinWallet? btc; setUp(() { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - + mockMainDB = MockMainDB(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -355,6 +365,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -398,13 +409,13 @@ void main() async { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - + late MockMainDB mockMainDB; BitcoinWallet? btc; setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - + mockMainDB = MockMainDB(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -416,6 +427,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -435,6 +447,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); expect(Coin.bitcoinTestNet, Coin.bitcoinTestNet); expect(secureStore.interactions, 0); @@ -596,7 +609,7 @@ void main() async { MockElectrumX? client; MockCachedElectrumX? cachedClient; - + late MockMainDB mockMainDB; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -613,7 +626,7 @@ void main() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - + mockMainDB = MockMainDB(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -625,6 +638,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -1287,6 +1301,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -2090,6 +2105,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.getServerFeatures()).thenAnswer((_) async => { "hosts": {}, diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart index 1a01906ea..8124d92e9 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart @@ -3,16 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; +import 'dart:async' as _i6; import 'package:decimal/decimal.dart' as _i2; +import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; +import 'package:stackwallet/db/main_db.dart' as _i10; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i9; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/prefs.dart' as _i3; +import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -45,16 +49,37 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } +class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { + _FakeIsar_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_3 extends _i1.SmartFake + implements _i4.QueryBuilder { + _FakeQueryBuilder_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -90,7 +115,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { returnValue: false, ) as bool); @override - _i5.Future request({ + _i6.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -109,10 +134,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future>> batchRequest({ + _i6.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -129,11 +154,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future ping({ + _i6.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -146,10 +171,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> getBlockHeadTip({String? requestID}) => + _i6.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -157,10 +182,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getServerFeatures({String? requestID}) => + _i6.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -168,10 +193,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future broadcastTransaction({ + _i6.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -184,10 +209,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(''), - ) as _i5.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i5.Future> getBalance({ + _i6.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -201,10 +226,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future>> getHistory({ + _i6.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -217,11 +242,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchHistory( + _i6.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -229,11 +254,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future>> getUTXOs({ + _i6.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -246,11 +271,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchUTXOs( + _i6.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -258,11 +283,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -278,10 +303,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -297,10 +322,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getMintData({ + _i6.Future getMintData({ dynamic mints, String? requestID, }) => @@ -313,10 +338,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future> getUsedCoinSerials({ + _i6.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -330,19 +355,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i5.Future.value(0), - ) as _i5.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i5.Future> getFeeRate({String? requestID}) => + _i6.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -350,10 +375,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future<_i2.Decimal> estimateFee({ + _i6.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -366,7 +391,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #blocks: blocks, }, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -377,15 +402,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); @override - _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -393,13 +418,13 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -428,15 +453,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i4.ElectrumXNode>[], - ) as List<_i4.ElectrumXNode>); + returnValue: <_i5.ElectrumXNode>[], + ) as List<_i5.ElectrumXNode>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i8.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -449,8 +474,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -468,9 +493,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { returnValue: '', ) as String); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i8.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -484,11 +509,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + _i6.Future> getUsedCoinSerials({ + required _i8.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -500,26 +525,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i9.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -548,14 +573,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -565,12 +590,302 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i10.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i4.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_2( + this, + Invocation.getter(#isar), + ), + ) as _i4.Isar); + @override + _i6.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i6.Future.value(false), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i4 + .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); + @override + _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putAddresses(List<_i11.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future updateAddress( + _i11.Address? oldAddress, + _i11.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransaction(_i11.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactions(List<_i11.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); + @override + _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); + @override + _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); + @override + _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putOutputs(List<_i11.Output>? outputs) => + (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, + _i11.TransactionNote, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactionNotes( + List<_i11.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future addNewTransactionData( + List< + _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, + _i11.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index 464b5fb58..ac8096e05 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -4,6 +4,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; @@ -18,7 +19,12 @@ import 'bitcoincash_history_sample_data.dart'; import 'bitcoincash_wallet_test.mocks.dart'; import 'bitcoincash_wallet_test_parameters.dart'; -@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) +@GenerateMocks([ + ElectrumX, + CachedElectrumX, + TransactionNotificationTracker, + MainDB, +]) void main() async { group("bitcoincash constants", () { test("bitcoincash minimum confirmations", () async { @@ -62,7 +68,7 @@ void main() async { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - + late MockMainDB mockMainDB; BitcoinCashWallet? mainnetWallet; setUp(() { @@ -70,6 +76,7 @@ void main() async { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); mainnetWallet = BitcoinCashWallet( walletId: "validateAddressMainNet", @@ -79,6 +86,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -190,7 +198,7 @@ void main() async { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - + late MockMainDB mockMainDB; BitcoinCashWallet? mainnetWallet; setUp(() { @@ -199,6 +207,7 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); mainnetWallet = BitcoinCashWallet( walletId: "validateAddressMainNet", @@ -208,6 +217,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -290,7 +300,7 @@ void main() async { group("testNetworkConnection", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - + late MockMainDB mockMainDB; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -302,6 +312,7 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); bch = BitcoinCashWallet( walletId: "testNetworkConnection", @@ -311,6 +322,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -355,7 +367,7 @@ void main() async { MockElectrumX? client; MockCachedElectrumX? cachedClient; - + late MockMainDB mockMainDB; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -367,6 +379,7 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); bch = BitcoinCashWallet( walletId: testWalletId, @@ -376,6 +389,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -396,6 +410,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); expect(bch?.coin, bchcoin); expect(secureStore.interactions, 0); @@ -566,7 +581,7 @@ void main() async { MockElectrumX? client; MockCachedElectrumX? cachedClient; - + late MockMainDB mockMainDB; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -586,6 +601,7 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); bch = BitcoinCashWallet( walletId: testWalletId, @@ -595,6 +611,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -696,6 +713,7 @@ void main() async { // tracker: tracker!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // // await Hive.openBox(testWalletId); @@ -869,6 +887,7 @@ void main() async { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // // // // init existing @@ -920,6 +939,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -958,6 +978,7 @@ void main() async { // tracker: tracker!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1062,6 +1083,7 @@ void main() async { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1125,6 +1147,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1168,6 +1191,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1506,6 +1530,7 @@ void main() async { // cachedClient: cachedClient!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1635,6 +1660,7 @@ void main() async { // cachedClient: cachedClient!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1768,6 +1794,7 @@ void main() async { // tracker: tracker!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1820,6 +1847,7 @@ void main() async { // // tracker: tracker!, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put('receivingAddressesP2PKH', []); @@ -1939,6 +1967,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.getServerFeatures()).thenAnswer((_) async => { "hosts": {}, diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart index 4f0016262..fe0a413f6 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart @@ -3,16 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; +import 'dart:async' as _i6; import 'package:decimal/decimal.dart' as _i2; +import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; +import 'package:stackwallet/db/main_db.dart' as _i10; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i9; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/prefs.dart' as _i3; +import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -45,16 +49,37 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } +class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { + _FakeIsar_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_3 extends _i1.SmartFake + implements _i4.QueryBuilder { + _FakeQueryBuilder_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -90,7 +115,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { returnValue: false, ) as bool); @override - _i5.Future request({ + _i6.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -109,10 +134,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future>> batchRequest({ + _i6.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -129,11 +154,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future ping({ + _i6.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -146,10 +171,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> getBlockHeadTip({String? requestID}) => + _i6.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -157,10 +182,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getServerFeatures({String? requestID}) => + _i6.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -168,10 +193,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future broadcastTransaction({ + _i6.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -184,10 +209,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(''), - ) as _i5.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i5.Future> getBalance({ + _i6.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -201,10 +226,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future>> getHistory({ + _i6.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -217,11 +242,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchHistory( + _i6.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -229,11 +254,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future>> getUTXOs({ + _i6.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -246,11 +271,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchUTXOs( + _i6.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -258,11 +283,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -278,10 +303,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -297,10 +322,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getMintData({ + _i6.Future getMintData({ dynamic mints, String? requestID, }) => @@ -313,10 +338,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future> getUsedCoinSerials({ + _i6.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -330,19 +355,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i5.Future.value(0), - ) as _i5.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i5.Future> getFeeRate({String? requestID}) => + _i6.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -350,10 +375,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future<_i2.Decimal> estimateFee({ + _i6.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -366,7 +391,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #blocks: blocks, }, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -377,15 +402,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); @override - _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -393,13 +418,13 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -428,15 +453,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i4.ElectrumXNode>[], - ) as List<_i4.ElectrumXNode>); + returnValue: <_i5.ElectrumXNode>[], + ) as List<_i5.ElectrumXNode>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i8.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -449,8 +474,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -468,9 +493,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { returnValue: '', ) as String); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i8.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -484,11 +509,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + _i6.Future> getUsedCoinSerials({ + required _i8.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -500,26 +525,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i9.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -548,14 +573,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -565,12 +590,302 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i10.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i4.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_2( + this, + Invocation.getter(#isar), + ), + ) as _i4.Isar); + @override + _i6.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i6.Future.value(false), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i4 + .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); + @override + _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putAddresses(List<_i11.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future updateAddress( + _i11.Address? oldAddress, + _i11.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransaction(_i11.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactions(List<_i11.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); + @override + _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); + @override + _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); + @override + _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putOutputs(List<_i11.Output>? outputs) => + (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, + _i11.TransactionNote, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactionNotes( + List<_i11.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future addNewTransactionData( + List< + _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, + _i11.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index 14d61e6dd..b669a0783 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -5,6 +5,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; @@ -19,7 +20,12 @@ import 'dogecoin_history_sample_data.dart'; import 'dogecoin_wallet_test.mocks.dart'; import 'dogecoin_wallet_test_parameters.dart'; -@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) +@GenerateMocks([ + ElectrumX, + CachedElectrumX, + TransactionNotificationTracker, + MainDB, +]) void main() { group("dogecoin constants", () { test("dogecoin minimum confirmations", () async { @@ -93,6 +99,7 @@ void main() { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; DogecoinWallet? mainnetWallet; @@ -101,6 +108,7 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); mainnetWallet = DogecoinWallet( walletId: "validateAddressMainNet", @@ -110,6 +118,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -184,6 +193,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; DogecoinWallet? doge; @@ -192,6 +202,7 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); doge = DogecoinWallet( walletId: "testNetworkConnection", @@ -201,6 +212,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -249,6 +261,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; DogecoinWallet? doge; @@ -258,6 +271,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); doge = DogecoinWallet( walletId: testWalletId, @@ -267,6 +281,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -287,6 +302,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); expect(doge?.coin, dtestcoin); expect(secureStore.interactions, 0); @@ -460,6 +476,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; DogecoinWallet? doge; @@ -477,6 +494,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); doge = DogecoinWallet( walletId: testWalletId, @@ -486,6 +504,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -587,6 +606,7 @@ void main() { // tracker: tracker!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // // await Hive.openBox(testWalletId); @@ -760,6 +780,7 @@ void main() { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // // // // init existing @@ -811,6 +832,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -858,6 +880,7 @@ void main() { // tracker: tracker!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -962,6 +985,7 @@ void main() { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1025,6 +1049,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1068,6 +1093,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.ping()).thenAnswer((_) async => true); when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1406,6 +1432,7 @@ void main() { // cachedClient: cachedClient!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1535,6 +1562,7 @@ void main() { // cachedClient: cachedClient!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1668,6 +1696,7 @@ void main() { // tracker: tracker!, // // secureStore: secureStore, + // mockableOverride: mockMainDB, // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1720,6 +1749,7 @@ void main() { // // tracker: tracker!, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put('receivingAddressesP2PKH', []); @@ -1826,6 +1856,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); when(client?.getServerFeatures()).thenAnswer((_) async => { "hosts": {}, diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart index ae555da22..e5c575519 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart @@ -3,16 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; +import 'dart:async' as _i6; import 'package:decimal/decimal.dart' as _i2; +import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; +import 'package:stackwallet/db/main_db.dart' as _i10; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i9; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/prefs.dart' as _i3; +import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -45,16 +49,37 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } +class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { + _FakeIsar_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_3 extends _i1.SmartFake + implements _i4.QueryBuilder { + _FakeQueryBuilder_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -90,7 +115,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { returnValue: false, ) as bool); @override - _i5.Future request({ + _i6.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -109,10 +134,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future>> batchRequest({ + _i6.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -129,11 +154,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future ping({ + _i6.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -146,10 +171,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> getBlockHeadTip({String? requestID}) => + _i6.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -157,10 +182,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getServerFeatures({String? requestID}) => + _i6.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -168,10 +193,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future broadcastTransaction({ + _i6.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -184,10 +209,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(''), - ) as _i5.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i5.Future> getBalance({ + _i6.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -201,10 +226,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future>> getHistory({ + _i6.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -217,11 +242,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchHistory( + _i6.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -229,11 +254,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future>> getUTXOs({ + _i6.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -246,11 +271,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchUTXOs( + _i6.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -258,11 +283,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -278,10 +303,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -297,10 +322,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getMintData({ + _i6.Future getMintData({ dynamic mints, String? requestID, }) => @@ -313,10 +338,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future> getUsedCoinSerials({ + _i6.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -330,19 +355,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i5.Future.value(0), - ) as _i5.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i5.Future> getFeeRate({String? requestID}) => + _i6.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -350,10 +375,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future<_i2.Decimal> estimateFee({ + _i6.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -366,7 +391,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #blocks: blocks, }, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -377,15 +402,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); @override - _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -393,13 +418,13 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -428,15 +453,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i4.ElectrumXNode>[], - ) as List<_i4.ElectrumXNode>); + returnValue: <_i5.ElectrumXNode>[], + ) as List<_i5.ElectrumXNode>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i8.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -449,8 +474,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -468,9 +493,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { returnValue: '', ) as String); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i8.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -484,11 +509,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + _i6.Future> getUsedCoinSerials({ + required _i8.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -500,26 +525,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i9.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -548,14 +573,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -565,12 +590,302 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i10.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i4.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_2( + this, + Invocation.getter(#isar), + ), + ) as _i4.Isar); + @override + _i6.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i6.Future.value(false), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i4 + .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); + @override + _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putAddresses(List<_i11.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future updateAddress( + _i11.Address? oldAddress, + _i11.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransaction(_i11.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactions(List<_i11.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); + @override + _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); + @override + _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); + @override + _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putOutputs(List<_i11.Output>? outputs) => + (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, + _i11.TransactionNote, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactionNotes( + List<_i11.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future addNewTransactionData( + List< + _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, + _i11.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index eb5d1aae2..c2f200842 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -9,6 +9,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; @@ -31,7 +32,12 @@ import 'sample_data/get_utxos_sample_data.dart'; import 'sample_data/gethistory_samples.dart'; import 'sample_data/transaction_data_samples.dart'; -@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) +@GenerateMocks([ + ElectrumX, + CachedElectrumX, + TransactionNotificationTracker, + MainDB, +]) void main() { group("isolate functions", () { test("isolateDerive", () async { @@ -564,6 +570,7 @@ void main() { // client: client,coin: Coin.firo, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -586,6 +593,7 @@ void main() { // coin: Coin.firo, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -619,6 +627,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -651,6 +660,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -697,6 +707,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -768,6 +779,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -874,6 +886,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -921,6 +934,7 @@ void main() { // final secureStore = FakeSecureStorage(); // // final tracker = MockTransactionNotificationTracker(); + // final mockMainDB = MockMainDB(); // // await Hive.openBox(DB.boxNamePrefs); // await Prefs.instance.init(); @@ -960,6 +974,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: tracker, // ); @@ -985,8 +1000,8 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final tracker = MockTransactionNotificationTracker(); + final mockMainDB = MockMainDB(); when(tracker.pendings).thenAnswer((realInvocation) => [ "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e", @@ -1053,6 +1068,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: tracker, ); @@ -1082,6 +1098,7 @@ void main() { // final secureStore = FakeSecureStorage(); // // final tracker = MockTransactionNotificationTracker(); + // final mockMainDB = MockMainDB(); // // when(client.getTransaction(txHash: SampleGetTransactionData.txHash6)) // .thenAnswer((_) async => SampleGetTransactionData.txData6); @@ -1120,6 +1137,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: tracker, // ); @@ -1136,6 +1154,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); when(client.broadcastTransaction( rawTx: @@ -1150,6 +1169,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1164,6 +1184,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); final firo = FiroWallet( walletName: testWalletName, @@ -1172,6 +1193,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1218,6 +1240,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); await secureStore.write( key: "${testWalletId}buildMintTransaction_mnemonic", @@ -1238,6 +1261,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1270,6 +1294,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { @@ -1364,6 +1389,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1504,6 +1530,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); await secureStore.write( key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); @@ -1532,6 +1559,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1713,6 +1741,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); await secureStore.write( key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); @@ -1734,6 +1763,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1851,6 +1881,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { @@ -1887,6 +1918,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2125,6 +2157,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { @@ -2145,6 +2178,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2161,6 +2195,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { @@ -2181,6 +2216,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2216,6 +2252,7 @@ void main() { test("checkReceivingAddressForTransactions numtxs >= 1", () async { final client = MockElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) .thenAnswer((_) async => SampleGetHistoryData.data1); @@ -2228,6 +2265,7 @@ void main() { client: client, cachedClient: MockCachedElectrumX(), secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2324,6 +2362,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); // set mnemonic await secureStore.write( @@ -2421,6 +2460,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2530,6 +2570,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); @@ -2627,6 +2668,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getBlockHeadTip()).thenAnswer( @@ -2708,6 +2750,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2803,6 +2846,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getBlockHeadTip()).thenAnswer( @@ -2874,6 +2918,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -3043,6 +3088,7 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); + final mockMainDB = MockMainDB(); // set mnemonic await secureStore.write( @@ -3125,6 +3171,7 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, + mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -3269,6 +3316,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, + // mockableOverride: mockMainDB, // // tracker: MockTransactionNotificationTracker(), // ); diff --git a/test/services/coins/firo/firo_wallet_test.mocks.dart b/test/services/coins/firo/firo_wallet_test.mocks.dart index ac107eaa2..3f0ba7040 100644 --- a/test/services/coins/firo/firo_wallet_test.mocks.dart +++ b/test/services/coins/firo/firo_wallet_test.mocks.dart @@ -3,16 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; +import 'dart:async' as _i6; import 'package:decimal/decimal.dart' as _i2; +import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; +import 'package:stackwallet/db/main_db.dart' as _i10; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i9; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/prefs.dart' as _i3; +import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -45,16 +49,37 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } +class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { + _FakeIsar_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_3 extends _i1.SmartFake + implements _i4.QueryBuilder { + _FakeQueryBuilder_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -90,7 +115,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { returnValue: false, ) as bool); @override - _i5.Future request({ + _i6.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -109,10 +134,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future>> batchRequest({ + _i6.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -129,11 +154,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future ping({ + _i6.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -146,10 +171,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> getBlockHeadTip({String? requestID}) => + _i6.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -157,10 +182,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getServerFeatures({String? requestID}) => + _i6.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -168,10 +193,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future broadcastTransaction({ + _i6.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -184,10 +209,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(''), - ) as _i5.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i5.Future> getBalance({ + _i6.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -201,10 +226,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future>> getHistory({ + _i6.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -217,11 +242,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchHistory( + _i6.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -229,11 +254,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future>> getUTXOs({ + _i6.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -246,11 +271,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchUTXOs( + _i6.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -258,11 +283,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -278,10 +303,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -297,10 +322,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getMintData({ + _i6.Future getMintData({ dynamic mints, String? requestID, }) => @@ -313,10 +338,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future> getUsedCoinSerials({ + _i6.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -330,19 +355,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i5.Future.value(0), - ) as _i5.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i5.Future> getFeeRate({String? requestID}) => + _i6.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -350,10 +375,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future<_i2.Decimal> estimateFee({ + _i6.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -366,7 +391,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #blocks: blocks, }, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -377,15 +402,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); @override - _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -393,13 +418,13 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -428,15 +453,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i4.ElectrumXNode>[], - ) as List<_i4.ElectrumXNode>); + returnValue: <_i5.ElectrumXNode>[], + ) as List<_i5.ElectrumXNode>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i8.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -449,8 +474,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -468,9 +493,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { returnValue: '', ) as String); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i8.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -484,11 +509,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + _i6.Future> getUsedCoinSerials({ + required _i8.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -500,26 +525,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i9.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -548,14 +573,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -565,12 +590,302 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i10.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i4.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_2( + this, + Invocation.getter(#isar), + ), + ) as _i4.Isar); + @override + _i6.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i6.Future.value(false), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i4 + .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); + @override + _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putAddresses(List<_i11.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future updateAddress( + _i11.Address? oldAddress, + _i11.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransaction(_i11.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactions(List<_i11.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); + @override + _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); + @override + _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); + @override + _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putOutputs(List<_i11.Output>? outputs) => + (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, + _i11.TransactionNote, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactionNotes( + List<_i11.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future addNewTransactionData( + List< + _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, + _i11.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index 7944c0767..71a77970e 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -18,7 +18,6 @@ import 'package:stackwallet/services/coins/firo/firo_wallet.dart' as _i9; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; -import 'package:tuple/tuple.dart' as _i14; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -987,25 +986,6 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: null, ); @override - _i10.Future addNewTransactionData( - List< - _i14.Tuple4<_i12.Transaction, List<_i12.Output>, List<_i12.Input>, - _i12.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i10.Future.value(), - returnValueForMissingStub: _i10.Future.value(), - ) as _i10.Future); - @override void initFiroHive(String? walletId) => super.noSuchMethod( Invocation.method( #initFiroHive, diff --git a/test/services/coins/monero/monero_wallet_test.dart b/test/services/coins/monero/monero_wallet_test.dart index 16f0be14b..d55abd658 100644 --- a/test/services/coins/monero/monero_wallet_test.dart +++ b/test/services/coins/monero/monero_wallet_test.dart @@ -18,6 +18,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; @@ -37,7 +38,9 @@ String name = 'namee${Random().nextInt(10000000)}'; int nettype = 0; WalletType type = WalletType.monero; -@GenerateMocks([]) +@GenerateMocks([ + MainDB, +]) void main() async { storage = FakeSecureStorage(); keysStorage = KeyService(storage!); @@ -135,42 +138,36 @@ void main() async { // "${walletBase!.balance.entries.first.value.available} currency: ${walletBase!.currency}"); expect(walletInfo.address, mainnetTestData[0][0]); - expect( - await walletBase!.getTransactionAddress(0, 0), mainnetTestData[0][0]); - expect( - await walletBase!.getTransactionAddress(0, 1), mainnetTestData[0][1]); - expect( - await walletBase!.getTransactionAddress(0, 2), mainnetTestData[0][2]); - expect( - await walletBase!.getTransactionAddress(1, 0), mainnetTestData[1][0]); - expect( - await walletBase!.getTransactionAddress(1, 1), mainnetTestData[1][1]); - expect( - await walletBase!.getTransactionAddress(1, 2), mainnetTestData[1][2]); + expect(walletBase!.getTransactionAddress(0, 0), mainnetTestData[0][0]); + expect(walletBase!.getTransactionAddress(0, 1), mainnetTestData[0][1]); + expect(walletBase!.getTransactionAddress(0, 2), mainnetTestData[0][2]); + expect(walletBase!.getTransactionAddress(1, 0), mainnetTestData[1][0]); + expect(walletBase!.getTransactionAddress(1, 1), mainnetTestData[1][1]); + expect(walletBase!.getTransactionAddress(1, 2), mainnetTestData[1][2]); - expect(await walletBase!.validateAddress(''), false); + expect(walletBase!.validateAddress(''), false); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( '4AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), true); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( '4asdfkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gpjkl'), false); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( '8AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), false); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( '84kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), true); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( '8asdfuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenjkl'), false); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( '44kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), false); }); @@ -233,4 +230,4 @@ Future pathForWalletDir( Future pathForWallet( {required String name, required WalletType type}) async => await pathForWalletDir(name: name, type: type) - .then((path) => path + '/$name'); + .then((path) => '$path/$name'); diff --git a/test/services/coins/monero/monero_wallet_test.mocks.dart b/test/services/coins/monero/monero_wallet_test.mocks.dart new file mode 100644 index 000000000..f0ee6ea75 --- /dev/null +++ b/test/services/coins/monero/monero_wallet_test.mocks.dart @@ -0,0 +1,333 @@ +// Mocks generated by Mockito 5.3.2 from annotations +// in stackwallet/test/services/coins/monero/monero_wallet_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; + +import 'package:isar/isar.dart' as _i2; +import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/db/main_db.dart' as _i3; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i5; +import 'package:tuple/tuple.dart' as _i6; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeIsar_0 extends _i1.SmartFake implements _i2.Isar { + _FakeIsar_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_1 extends _i1.SmartFake + implements _i2.QueryBuilder { + _FakeQueryBuilder_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i3.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i2.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_0( + this, + Invocation.getter(#isar), + ), + ) as _i2.Isar); + @override + _i4.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i4.Future.value(false), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_1<_i5.Address, _i5.Address, + _i2.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i2 + .QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause>); + @override + _i4.Future putAddress(_i5.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putAddresses(List<_i5.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future updateAddress( + _i5.Address? oldAddress, + _i5.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, _i2.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_1<_i5.Transaction, _i5.Transaction, + _i2.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, + _i2.QAfterWhereClause>); + @override + _i4.Future putTransaction(_i5.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putTransactions(List<_i5.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_1<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>); + @override + _i4.Future putUTXO(_i5.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putUTXOs(List<_i5.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_1<_i5.Input, _i5.Input, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause>); + @override + _i4.Future putInput(_i5.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putInputs(List<_i5.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_1<_i5.Output, _i5.Output, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause>); + @override + _i4.Future putOutput(_i5.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putOutputs(List<_i5.Output>? outputs) => (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, + _i2.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_1<_i5.TransactionNote, + _i5.TransactionNote, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, + _i2.QAfterWhereClause>); + @override + _i4.Future putTransactionNote(_i5.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putTransactionNotes( + List<_i5.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future addNewTransactionData( + List< + _i6.Tuple4<_i5.Transaction, List<_i5.Output>, List<_i5.Input>, + _i5.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +} diff --git a/test/services/coins/namecoin/namecoin_wallet_test.dart b/test/services/coins/namecoin/namecoin_wallet_test.dart index b9a234d69..d20f287e0 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.dart @@ -4,6 +4,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; @@ -18,7 +19,12 @@ import 'namecoin_transaction_data_samples.dart'; import 'namecoin_wallet_test.mocks.dart'; import 'namecoin_wallet_test_parameters.dart'; -@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) +@GenerateMocks([ + ElectrumX, + CachedElectrumX, + TransactionNotificationTracker, + MainDB, +]) void main() { group("namecoin constants", () { test("namecoin minimum confirmations", () async { @@ -98,6 +104,7 @@ void main() { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; NamecoinWallet? mainnetWallet; @@ -106,6 +113,7 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); mainnetWallet = NamecoinWallet( walletId: "validateAddressMainNet", @@ -115,6 +123,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -168,6 +177,7 @@ void main() { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; NamecoinWallet? nmc; @@ -176,6 +186,7 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); nmc = NamecoinWallet( walletId: "testNetworkConnection", @@ -185,6 +196,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -228,6 +240,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; NamecoinWallet? nmc; @@ -237,6 +250,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); nmc = NamecoinWallet( walletId: testWalletId, @@ -246,6 +260,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -265,6 +280,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); expect(Coin.namecoin, Coin.namecoin); expect(secureStore.interactions, 0); @@ -429,6 +445,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; NamecoinWallet? nmc; @@ -446,6 +463,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); nmc = NamecoinWallet( walletId: testWalletId, @@ -455,6 +473,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -1502,6 +1521,7 @@ void main() { // // cachedClient: cachedClient, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // // // // set node diff --git a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart index 47870a622..2ac690aa5 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart @@ -3,16 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; +import 'dart:async' as _i6; import 'package:decimal/decimal.dart' as _i2; +import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; +import 'package:stackwallet/db/main_db.dart' as _i10; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i9; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/prefs.dart' as _i3; +import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -45,16 +49,37 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } +class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { + _FakeIsar_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_3 extends _i1.SmartFake + implements _i4.QueryBuilder { + _FakeQueryBuilder_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -90,7 +115,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { returnValue: false, ) as bool); @override - _i5.Future request({ + _i6.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -109,10 +134,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future>> batchRequest({ + _i6.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -129,11 +154,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future ping({ + _i6.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -146,10 +171,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> getBlockHeadTip({String? requestID}) => + _i6.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -157,10 +182,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getServerFeatures({String? requestID}) => + _i6.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -168,10 +193,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future broadcastTransaction({ + _i6.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -184,10 +209,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(''), - ) as _i5.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i5.Future> getBalance({ + _i6.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -201,10 +226,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future>> getHistory({ + _i6.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -217,11 +242,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchHistory( + _i6.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -229,11 +254,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future>> getUTXOs({ + _i6.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -246,11 +271,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchUTXOs( + _i6.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -258,11 +283,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -278,10 +303,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -297,10 +322,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getMintData({ + _i6.Future getMintData({ dynamic mints, String? requestID, }) => @@ -313,10 +338,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future> getUsedCoinSerials({ + _i6.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -330,19 +355,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i5.Future.value(0), - ) as _i5.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i5.Future> getFeeRate({String? requestID}) => + _i6.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -350,10 +375,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future<_i2.Decimal> estimateFee({ + _i6.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -366,7 +391,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #blocks: blocks, }, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -377,15 +402,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); @override - _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -393,13 +418,13 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -428,15 +453,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i4.ElectrumXNode>[], - ) as List<_i4.ElectrumXNode>); + returnValue: <_i5.ElectrumXNode>[], + ) as List<_i5.ElectrumXNode>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i8.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -449,8 +474,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -468,9 +493,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { returnValue: '', ) as String); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i8.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -484,11 +509,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + _i6.Future> getUsedCoinSerials({ + required _i8.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -500,26 +525,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i9.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -548,14 +573,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -565,12 +590,302 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i10.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i4.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_2( + this, + Invocation.getter(#isar), + ), + ) as _i4.Isar); + @override + _i6.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i6.Future.value(false), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i4 + .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); + @override + _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putAddresses(List<_i11.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future updateAddress( + _i11.Address? oldAddress, + _i11.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransaction(_i11.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactions(List<_i11.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); + @override + _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); + @override + _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); + @override + _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putOutputs(List<_i11.Output>? outputs) => + (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, + _i11.TransactionNote, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactionNotes( + List<_i11.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future addNewTransactionData( + List< + _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, + _i11.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index 56035e88e..8fc583324 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -4,6 +4,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; @@ -17,7 +18,12 @@ import 'particl_transaction_data_samples.dart'; import 'particl_wallet_test.mocks.dart'; import 'particl_wallet_test_parameters.dart'; -@GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) +@GenerateMocks([ + ElectrumX, + CachedElectrumX, + TransactionNotificationTracker, + MainDB, +]) void main() { group("particl constants", () { test("particl minimum confirmations", () async { @@ -99,6 +105,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; ParticlWallet? mainnetWallet; // TODO reimplement testnet, see 9baa30c1a40b422bb5f4746efc1220b52691ace6 and sneurlax/stack_wallet#ec399ade0aef1d9ab2dd78876a2d20819dae4ba0 @@ -109,6 +116,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); mainnetWallet = ParticlWallet( walletId: "validateAddressMainNet", @@ -118,6 +126,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -216,6 +225,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; ParticlWallet? part; @@ -225,6 +235,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); part = ParticlWallet( walletId: "testNetworkConnection", @@ -234,6 +245,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -277,6 +289,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; ParticlWallet? part; @@ -286,6 +299,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); part = ParticlWallet( walletId: testWalletId, @@ -295,6 +309,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); @@ -314,6 +329,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); expect(Coin.particl, Coin.particl); expect(secureStore.interactions, 0); @@ -478,6 +494,7 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; + late MockMainDB mockMainDB; ParticlWallet? part; @@ -495,6 +512,7 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); + mockMainDB = MockMainDB(); part = ParticlWallet( walletId: testWalletId, @@ -504,6 +522,7 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, + mockableOverride: mockMainDB, ); }); //TODO - THis function definition has changed, possibly remove @@ -1430,6 +1449,7 @@ void main() { // // cachedClient: cachedClient, // // // // secureStore: secureStore, + // mockableOverride: mockMainDB, // // ); // // // // // set node diff --git a/test/services/coins/particl/particl_wallet_test.mocks.dart b/test/services/coins/particl/particl_wallet_test.mocks.dart index ab2e8f310..93f9e9723 100644 --- a/test/services/coins/particl/particl_wallet_test.mocks.dart +++ b/test/services/coins/particl/particl_wallet_test.mocks.dart @@ -3,16 +3,20 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; +import 'dart:async' as _i6; import 'package:decimal/decimal.dart' as _i2; +import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; +import 'package:stackwallet/db/main_db.dart' as _i10; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i9; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/prefs.dart' as _i3; +import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -45,16 +49,37 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } +class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { + _FakeIsar_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_3 extends _i1.SmartFake + implements _i4.QueryBuilder { + _FakeQueryBuilder_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -90,7 +115,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { returnValue: false, ) as bool); @override - _i5.Future request({ + _i6.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -109,10 +134,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future>> batchRequest({ + _i6.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -129,11 +154,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retries: retries, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future ping({ + _i6.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -146,10 +171,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i5.Future.value(false), - ) as _i5.Future); + returnValue: _i6.Future.value(false), + ) as _i6.Future); @override - _i5.Future> getBlockHeadTip({String? requestID}) => + _i6.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -157,10 +182,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getServerFeatures({String? requestID}) => + _i6.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -168,10 +193,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future broadcastTransaction({ + _i6.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -184,10 +209,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(''), - ) as _i5.Future); + returnValue: _i6.Future.value(''), + ) as _i6.Future); @override - _i5.Future> getBalance({ + _i6.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -201,10 +226,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future>> getHistory({ + _i6.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -217,11 +242,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchHistory( + _i6.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -229,11 +254,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future>> getUTXOs({ + _i6.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -246,11 +271,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future>>.value( + returnValue: _i6.Future>>.value( >[]), - ) as _i5.Future>>); + ) as _i6.Future>>); @override - _i5.Future>>> getBatchUTXOs( + _i6.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -258,11 +283,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { [], {#args: args}, ), - returnValue: _i5.Future>>>.value( + returnValue: _i6.Future>>>.value( >>{}), - ) as _i5.Future>>>); + ) as _i6.Future>>>); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -278,10 +303,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -297,10 +322,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getMintData({ + _i6.Future getMintData({ dynamic mints, String? requestID, }) => @@ -313,10 +338,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #requestID: requestID, }, ), - returnValue: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + ) as _i6.Future); @override - _i5.Future> getUsedCoinSerials({ + _i6.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -330,19 +355,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i5.Future.value(0), - ) as _i5.Future); + returnValue: _i6.Future.value(0), + ) as _i6.Future); @override - _i5.Future> getFeeRate({String? requestID}) => + _i6.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -350,10 +375,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future<_i2.Decimal> estimateFee({ + _i6.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -366,7 +391,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { #blocks: blocks, }, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -377,15 +402,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { }, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); @override - _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -393,13 +418,13 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { {#requestID: requestID}, ), )), - ) as _i5.Future<_i2.Decimal>); + ) as _i6.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -428,15 +453,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i4.ElectrumXNode>[], - ) as List<_i4.ElectrumXNode>); + returnValue: <_i5.ElectrumXNode>[], + ) as List<_i5.ElectrumXNode>); @override - _i5.Future> getAnonymitySet({ + _i6.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i8.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -449,8 +474,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -468,9 +493,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { returnValue: '', ) as String); @override - _i5.Future> getTransaction({ + _i6.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i8.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -484,11 +509,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { }, ), returnValue: - _i5.Future>.value({}), - ) as _i5.Future>); + _i6.Future>.value({}), + ) as _i6.Future>); @override - _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + _i6.Future> getUsedCoinSerials({ + required _i8.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -500,26 +525,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i5.Future>.value([]), - ) as _i5.Future>); + returnValue: _i6.Future>.value([]), + ) as _i6.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i9.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -548,14 +573,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -565,12 +590,302 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i10.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i4.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_2( + this, + Invocation.getter(#isar), + ), + ) as _i4.Isar); + @override + _i6.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i6.Future.value(false), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i4 + .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); + @override + _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putAddresses(List<_i11.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future updateAddress( + _i11.Address? oldAddress, + _i11.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransaction(_i11.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactions(List<_i11.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); + @override + _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); + @override + _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, + _i4.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); + @override + _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putOutputs(List<_i11.Output>? outputs) => + (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, + _i11.TransactionNote, _i4.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, + _i4.QAfterWhereClause>); + @override + _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future putTransactionNotes( + List<_i11.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future addNewTransactionData( + List< + _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, + _i11.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); } diff --git a/test/services/coins/wownero/wownero_wallet_test.dart b/test/services/coins/wownero/wownero_wallet_test.dart index ec1d5a95c..c0c5f9424 100644 --- a/test/services/coins/wownero/wownero_wallet_test.dart +++ b/test/services/coins/wownero/wownero_wallet_test.dart @@ -18,6 +18,7 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'wownero_wallet_test_data.dart'; @@ -35,7 +36,9 @@ String name = ''; int nettype = 0; WalletType type = WalletType.wownero; -@GenerateMocks([]) +@GenerateMocks([ + MainDB, +]) void main() async { storage = FakeSecureStorage(); keysStorage = KeyService(storage!); @@ -131,13 +134,13 @@ void main() async { expect(hasThrown, false); // Address validation - expect(await walletBase!.validateAddress(''), false); + expect(walletBase!.validateAddress(''), false); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( 'Wo3jmHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmsEi'), true); expect( - await walletBase!.validateAddress( + walletBase!.validateAddress( 'WasdfHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmjkl'), false); @@ -197,18 +200,18 @@ void main() async { walletBase = wallet as WowneroWalletBase; expect(walletInfo.address, mainnetTestData14[0][0]); - expect(await walletBase!.getTransactionAddress(0, 0), - mainnetTestData14[0][0]); - expect(await walletBase!.getTransactionAddress(0, 1), - mainnetTestData14[0][1]); - expect(await walletBase!.getTransactionAddress(0, 2), - mainnetTestData14[0][2]); - expect(await walletBase!.getTransactionAddress(1, 0), - mainnetTestData14[1][0]); - expect(await walletBase!.getTransactionAddress(1, 1), - mainnetTestData14[1][1]); - expect(await walletBase!.getTransactionAddress(1, 2), - mainnetTestData14[1][2]); + expect( + walletBase!.getTransactionAddress(0, 0), mainnetTestData14[0][0]); + expect( + walletBase!.getTransactionAddress(0, 1), mainnetTestData14[0][1]); + expect( + walletBase!.getTransactionAddress(0, 2), mainnetTestData14[0][2]); + expect( + walletBase!.getTransactionAddress(1, 0), mainnetTestData14[1][0]); + expect( + walletBase!.getTransactionAddress(1, 1), mainnetTestData14[1][1]); + expect( + walletBase!.getTransactionAddress(1, 2), mainnetTestData14[1][2]); } catch (_) { hasThrown = true; } @@ -366,4 +369,4 @@ Future pathForWalletDir( Future pathForWallet( {required String name, required WalletType type}) async => await pathForWalletDir(name: name, type: type) - .then((path) => path + '/$name'); + .then((path) => '$path/$name'); diff --git a/test/services/coins/wownero/wownero_wallet_test.mocks.dart b/test/services/coins/wownero/wownero_wallet_test.mocks.dart new file mode 100644 index 000000000..e31fff4ac --- /dev/null +++ b/test/services/coins/wownero/wownero_wallet_test.mocks.dart @@ -0,0 +1,333 @@ +// Mocks generated by Mockito 5.3.2 from annotations +// in stackwallet/test/services/coins/wownero/wownero_wallet_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; + +import 'package:isar/isar.dart' as _i2; +import 'package:mockito/mockito.dart' as _i1; +import 'package:stackwallet/db/main_db.dart' as _i3; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i5; +import 'package:tuple/tuple.dart' as _i6; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeIsar_0 extends _i1.SmartFake implements _i2.Isar { + _FakeIsar_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeQueryBuilder_1 extends _i1.SmartFake + implements _i2.QueryBuilder { + _FakeQueryBuilder_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [MainDB]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockMainDB extends _i1.Mock implements _i3.MainDB { + MockMainDB() { + _i1.throwOnMissingStub(this); + } + + @override + _i2.Isar get isar => (super.noSuchMethod( + Invocation.getter(#isar), + returnValue: _FakeIsar_0( + this, + Invocation.getter(#isar), + ), + ) as _i2.Isar); + @override + _i4.Future isarInit() => (super.noSuchMethod( + Invocation.method( + #isarInit, + [], + ), + returnValue: _i4.Future.value(false), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause> + getAddresses(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getAddresses, + [walletId], + ), + returnValue: _FakeQueryBuilder_1<_i5.Address, _i5.Address, + _i2.QAfterWhereClause>( + this, + Invocation.method( + #getAddresses, + [walletId], + ), + ), + ) as _i2 + .QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause>); + @override + _i4.Future putAddress(_i5.Address? address) => (super.noSuchMethod( + Invocation.method( + #putAddress, + [address], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putAddresses(List<_i5.Address>? addresses) => + (super.noSuchMethod( + Invocation.method( + #putAddresses, + [addresses], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future updateAddress( + _i5.Address? oldAddress, + _i5.Address? newAddress, + ) => + (super.noSuchMethod( + Invocation.method( + #updateAddress, + [ + oldAddress, + newAddress, + ], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, _i2.QAfterWhereClause> + getTransactions(String? walletId) => (super.noSuchMethod( + Invocation.method( + #getTransactions, + [walletId], + ), + returnValue: _FakeQueryBuilder_1<_i5.Transaction, _i5.Transaction, + _i2.QAfterWhereClause>( + this, + Invocation.method( + #getTransactions, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, + _i2.QAfterWhereClause>); + @override + _i4.Future putTransaction(_i5.Transaction? transaction) => + (super.noSuchMethod( + Invocation.method( + #putTransaction, + [transaction], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putTransactions(List<_i5.Transaction>? transactions) => + (super.noSuchMethod( + Invocation.method( + #putTransactions, + [transactions], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause> getUTXOs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getUTXOs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_1<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getUTXOs, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>); + @override + _i4.Future putUTXO(_i5.UTXO? utxo) => (super.noSuchMethod( + Invocation.method( + #putUTXO, + [utxo], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putUTXOs(List<_i5.UTXO>? utxos) => (super.noSuchMethod( + Invocation.method( + #putUTXOs, + [utxos], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause> getInputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getInputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_1<_i5.Input, _i5.Input, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getInputs, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause>); + @override + _i4.Future putInput(_i5.Input? input) => (super.noSuchMethod( + Invocation.method( + #putInput, + [input], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putInputs(List<_i5.Input>? inputs) => (super.noSuchMethod( + Invocation.method( + #putInputs, + [inputs], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause> getOutputs( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getOutputs, + [walletId], + ), + returnValue: + _FakeQueryBuilder_1<_i5.Output, _i5.Output, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getOutputs, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause>); + @override + _i4.Future putOutput(_i5.Output? output) => (super.noSuchMethod( + Invocation.method( + #putOutput, + [output], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putOutputs(List<_i5.Output>? outputs) => (super.noSuchMethod( + Invocation.method( + #putOutputs, + [outputs], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, + _i2.QAfterWhereClause> getTransactionNotes( + String? walletId) => + (super.noSuchMethod( + Invocation.method( + #getTransactionNotes, + [walletId], + ), + returnValue: _FakeQueryBuilder_1<_i5.TransactionNote, + _i5.TransactionNote, _i2.QAfterWhereClause>( + this, + Invocation.method( + #getTransactionNotes, + [walletId], + ), + ), + ) as _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, + _i2.QAfterWhereClause>); + @override + _i4.Future putTransactionNote(_i5.TransactionNote? transactionNote) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNote, + [transactionNote], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future putTransactionNotes( + List<_i5.TransactionNote>? transactionNotes) => + (super.noSuchMethod( + Invocation.method( + #putTransactionNotes, + [transactionNotes], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future deleteWalletBlockchainData(String? walletId) => + (super.noSuchMethod( + Invocation.method( + #deleteWalletBlockchainData, + [walletId], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future addNewTransactionData( + List< + _i6.Tuple4<_i5.Transaction, List<_i5.Output>, List<_i5.Input>, + _i5.Address?>>? + transactionsData, + String? walletId, + ) => + (super.noSuchMethod( + Invocation.method( + #addNewTransactionData, + [ + transactionsData, + walletId, + ], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +} diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 961777add..15213e274 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -14,12 +14,12 @@ 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 _i21; -import 'package:stackwallet/models/node_model.dart' as _i24; +import 'package:stackwallet/models/node_model.dart' as _i23; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i23; +import 'package:stackwallet/services/locale_service.dart' as _i22; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -29,7 +29,6 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i13; import 'package:stackwallet/utilities/prefs.dart' as _i18; -import 'package:tuple/tuple.dart' as _i22; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1356,31 +1355,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValueForMissingStub: null, ); - @override - _i17.Future addNewTransactionData( - List< - _i22.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, - _i21.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i23.LocaleService { +class MockLocaleService extends _i1.Mock implements _i22.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -1452,15 +1432,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i13.SecureStorageInterface); @override - List<_i24.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i24.NodeModel>[], - ) as List<_i24.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - List<_i24.NodeModel> get nodes => (super.noSuchMethod( + List<_i23.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i24.NodeModel>[], - ) as List<_i24.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -1478,7 +1458,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i17.Future setPrimaryNodeFor({ required _i16.Coin? coin, - required _i24.NodeModel? node, + required _i23.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1495,40 +1475,40 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i24.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i23.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i24.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i24.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i23.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i24.NodeModel>[], - ) as List<_i24.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override - _i24.NodeModel? getNodeById({required String? id}) => + _i23.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i24.NodeModel?); + )) as _i23.NodeModel?); @override - List<_i24.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i23.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i24.NodeModel>[], - ) as List<_i24.NodeModel>); + returnValue: <_i23.NodeModel>[], + ) as List<_i23.NodeModel>); @override _i17.Future add( - _i24.NodeModel? node, + _i23.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1580,7 +1560,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i17.Future); @override _i17.Future edit( - _i24.NodeModel? editedNode, + _i23.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => 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 8639ec3f6..e549bfe09 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 @@ -25,7 +25,6 @@ import 'package:stackwallet/services/wallets.dart' as _i14; import 'package:stackwallet/services/wallets_service.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i15; import 'package:stackwallet/utilities/prefs.dart' as _i17; -import 'package:tuple/tuple.dart' as _i21; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1341,25 +1340,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { ), returnValueForMissingStub: null, ); - @override - _i16.Future addNewTransactionData( - List< - _i21.Tuple4<_i20.Transaction, List<_i20.Output>, List<_i20.Input>, - _i20.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); } /// A class which mocks [Manager]. diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 915942570..185b84c60 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -1900,25 +1900,6 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: null, ); @override - _i18.Future addNewTransactionData( - List< - _i15.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, - _i21.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); - @override void initFiroHive(String? walletId) => super.noSuchMethod( Invocation.method( #initFiroHive, diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index b802b64dd..fc4e5bb8b 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -17,7 +17,7 @@ import 'package:stackwallet/models/isar/models/isar_models.dart' as _i19; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i21; +import 'package:stackwallet/services/locale_service.dart' as _i20; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' as _i7; @@ -25,7 +25,6 @@ import 'package:stackwallet/services/wallets.dart' as _i13; import 'package:stackwallet/services/wallets_service.dart' as _i2; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i14; import 'package:stackwallet/utilities/prefs.dart' as _i16; -import 'package:tuple/tuple.dart' as _i20; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1104,31 +1103,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { ), returnValueForMissingStub: null, ); - @override - _i15.Future addNewTransactionData( - List< - _i20.Tuple4<_i19.Transaction, List<_i19.Output>, List<_i19.Input>, - _i19.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); } /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i21.LocaleService { +class MockLocaleService extends _i1.Mock implements _i20.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } 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 8f37d1879..67354fe01 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 @@ -14,7 +14,7 @@ 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 _i21; -import 'package:stackwallet/models/node_model.dart' as _i23; +import 'package:stackwallet/models/node_model.dart' as _i22; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; @@ -28,7 +28,6 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i13; import 'package:stackwallet/utilities/prefs.dart' as _i18; -import 'package:tuple/tuple.dart' as _i22; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1355,25 +1354,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValueForMissingStub: null, ); - @override - _i17.Future addNewTransactionData( - List< - _i22.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, - _i21.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1389,15 +1369,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i13.SecureStorageInterface); @override - List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - List<_i23.NodeModel> get nodes => (super.noSuchMethod( + List<_i22.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -1415,7 +1395,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i17.Future setPrimaryNodeFor({ required _i16.Coin? coin, - required _i23.NodeModel? node, + required _i22.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1432,40 +1412,40 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i23.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i22.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i23.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i23.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i22.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - _i23.NodeModel? getNodeById({required String? id}) => + _i22.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i23.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i23.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i22.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override _i17.Future add( - _i23.NodeModel? node, + _i22.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1517,7 +1497,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i17.Future); @override _i17.Future edit( - _i23.NodeModel? editedNode, + _i22.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => 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 e72c999cb..21b8cb10f 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 @@ -14,7 +14,7 @@ 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 _i21; -import 'package:stackwallet/models/node_model.dart' as _i23; +import 'package:stackwallet/models/node_model.dart' as _i22; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i20; import 'package:stackwallet/services/coins/coin_service.dart' as _i14; @@ -28,7 +28,6 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i13; import 'package:stackwallet/utilities/prefs.dart' as _i18; -import 'package:tuple/tuple.dart' as _i22; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -1355,25 +1354,6 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { ), returnValueForMissingStub: null, ); - @override - _i17.Future addNewTransactionData( - List< - _i22.Tuple4<_i21.Transaction, List<_i21.Output>, List<_i21.Input>, - _i21.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); } /// A class which mocks [NodeService]. @@ -1389,15 +1369,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ), ) as _i13.SecureStorageInterface); @override - List<_i23.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - List<_i23.NodeModel> get nodes => (super.noSuchMethod( + List<_i22.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -1415,7 +1395,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i17.Future setPrimaryNodeFor({ required _i16.Coin? coin, - required _i23.NodeModel? node, + required _i22.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -1432,40 +1412,40 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i23.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i22.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], {#coin: coin}, - )) as _i23.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i23.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i22.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override - _i23.NodeModel? getNodeById({required String? id}) => + _i22.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i23.NodeModel?); + )) as _i22.NodeModel?); @override - List<_i23.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i22.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], {#coin: coin}, ), - returnValue: <_i23.NodeModel>[], - ) as List<_i23.NodeModel>); + returnValue: <_i22.NodeModel>[], + ) as List<_i22.NodeModel>); @override _i17.Future add( - _i23.NodeModel? node, + _i22.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1517,7 +1497,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i17.Future); @override _i17.Future edit( - _i23.NodeModel? editedNode, + _i22.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => From 0c1db6f2494bc0a3775303acad1697ecdf719312 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 20 Jan 2023 10:22:18 -0600 Subject: [PATCH 190/192] clean up tests for now --- lib/db/main_db.dart | 6 +- test/pages/send_view/send_view_test.dart | 5 + .../coins/bitcoin/bitcoin_wallet_test.dart | 1905 ++++++------ .../bitcoin/bitcoin_wallet_test.mocks.dart | 501 +-- .../bitcoincash/bitcoincash_wallet_test.dart | 1933 ++++++------ .../bitcoincash_wallet_test.mocks.dart | 501 +-- .../coins/dogecoin/dogecoin_wallet_test.dart | 1612 +++++----- .../dogecoin/dogecoin_wallet_test.mocks.dart | 501 +-- .../services/coins/firo/firo_wallet_test.dart | 2758 ++++++++--------- .../coins/firo/firo_wallet_test.mocks.dart | 501 +-- .../coins/monero/monero_wallet_test.dart | 5 - .../monero/monero_wallet_test.mocks.dart | 333 -- .../coins/namecoin/namecoin_wallet_test.dart | 1876 ++++++----- .../namecoin/namecoin_wallet_test.mocks.dart | 501 +-- .../coins/particl/particl_wallet_test.dart | 1629 +++++----- .../particl/particl_wallet_test.mocks.dart | 501 +-- .../coins/wownero/wownero_wallet_test.dart | 5 - .../wownero/wownero_wallet_test.mocks.dart | 333 -- test/services/wallets_service_test.dart | 105 +- test/widget_tests/managed_favorite_test.dart | 35 +- .../table_view/table_view_row_test.dart | 2 + test/widget_tests/wallet_card_test.dart | 7 + .../wallet_info_row_balance_future_test.dart | 5 +- .../wallet_info_row/wallet_info_row_test.dart | 8 +- 24 files changed, 6463 insertions(+), 9105 deletions(-) delete mode 100644 test/services/coins/monero/monero_wallet_test.mocks.dart delete mode 100644 test/services/coins/wownero/wownero_wallet_test.mocks.dart diff --git a/lib/db/main_db.dart b/lib/db/main_db.dart index 33bc15f12..be937b411 100644 --- a/lib/db/main_db.dart +++ b/lib/db/main_db.dart @@ -12,7 +12,11 @@ class MainDB { Isar get isar => _isar!; - Future isarInit() async { + Future isarInit({Isar? mock}) async { + if (mock != null) { + _isar = mock; + return true; + } if (_isar != null && isar.isOpen) return false; _isar = await Isar.open( [ diff --git a/test/pages/send_view/send_view_test.dart b/test/pages/send_view/send_view_test.dart index 73e5b8623..341032973 100644 --- a/test/pages/send_view/send_view_test.dart +++ b/test/pages/send_view/send_view_test.dart @@ -17,6 +17,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/theme/light_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; + import 'send_view_test.mocks.dart'; @GenerateMocks([ @@ -84,6 +85,8 @@ void main() { ), ); + await widgetTester.pumpAndSettle(); + expect(find.text("Send to"), findsOneWidget); expect(find.text("Amount"), findsOneWidget); expect(find.text("Note (optional)"), findsOneWidget); @@ -147,6 +150,8 @@ void main() { ), ); + await widgetTester.pumpAndSettle(); + expect(find.text("Send to"), findsOneWidget); expect(find.text("Amount"), findsOneWidget); expect(find.text("Note (optional)"), findsOneWidget); diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index d28232d7e..6fdea3d03 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -5,19 +5,14 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'bitcoin_history_sample_data.dart'; -import 'bitcoin_transaction_data_samples.dart'; import 'bitcoin_wallet_test.mocks.dart'; import 'bitcoin_wallet_test_parameters.dart'; @@ -25,7 +20,6 @@ import 'bitcoin_wallet_test_parameters.dart'; ElectrumX, CachedElectrumX, TransactionNotificationTracker, - MainDB, ]) void main() async { group("bitcoin constants", () { @@ -106,15 +100,15 @@ void main() async { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; + // BitcoinWallet? testnetWallet; - setUp(() { + setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); + // testnetWallet = BitcoinWallet( walletId: "validateAddressTestNet", @@ -124,7 +118,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, + // ); }); @@ -190,15 +184,15 @@ void main() async { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; + // BitcoinWallet? mainnetWallet; - setUp(() { + setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); + // mainnetWallet = BitcoinWallet( walletId: "validateAddressMainNet", @@ -208,7 +202,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, + // ); }); @@ -347,13 +341,13 @@ void main() async { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; + // BitcoinWallet? btc; - setUp(() { + setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - mockMainDB = MockMainDB(); + // secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -365,7 +359,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, + // ); }); @@ -409,13 +403,13 @@ void main() async { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; + // BitcoinWallet? btc; setUp(() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - mockMainDB = MockMainDB(); + // secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -427,7 +421,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, + // ); }); @@ -447,7 +441,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, + // ); expect(Coin.bitcoinTestNet, Coin.bitcoinTestNet); expect(secureStore.interactions, 0); @@ -609,7 +603,7 @@ void main() async { MockElectrumX? client; MockCachedElectrumX? cachedClient; - late MockMainDB mockMainDB; + // late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -626,7 +620,7 @@ void main() async { client = MockElectrumX(); cachedClient = MockCachedElectrumX(); - mockMainDB = MockMainDB(); + // secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); @@ -638,7 +632,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, + // ); }); @@ -1292,49 +1286,50 @@ void main() async { // // }); // - test("get utxos fails", () async { - btc = BitcoinWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: Coin.bitcoinTestNet, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - secureStore: secureStore, - mockableOverride: mockMainDB, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - when(client?.getBatchUTXOs(args: anyNamed("args"))) - .thenThrow(Exception("some exception")); - - await btc?.initializeNew(); - await btc?.initializeExisting(); - - final outputs = await btc!.utxos; - expect(outputs, isA>()); - expect(outputs.length, 0); - - verify(client?.ping()).called(1); - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("get utxos fails", () async { + // btc = BitcoinWallet( + // walletId: testWalletId, + // walletName: testWalletName, + // coin: Coin.bitcoinTestNet, + // client: client!, + // cachedClient: cachedClient!, + // tracker: tracker!, + // secureStore: secureStore, + // // + // ); + // + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // when(client?.getBatchUTXOs(args: anyNamed("args"))) + // .thenThrow(Exception("some exception")); + // + // await btc?.initializeNew(); + // await btc?.initializeExisting(); + // + // final outputs = await btc!.utxos; + // expect(outputs, isA>()); + // expect(outputs.length, 0); + // + // verify(client?.ping()).called(1); + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); // // test("chain height fetch, update, and get", () async { // btc = BitcoinWallet( @@ -2105,7 +2100,7 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, + // ); when(client?.getServerFeatures()).thenAnswer((_) async => { "hosts": {}, @@ -2173,622 +2168,622 @@ void main() async { verifyNoMoreInteractions(cachedClient); }); - test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - // await DB.instance.init(); - await Hive.openBox(testWalletId); - bool hasThrown = false; - try { - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); + // test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // // await DB.instance.init(); + // await Hive.openBox(testWalletId); + // bool hasThrown = false; + // try { + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // expect(secureStore.interactions, 20); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 13); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // test("get mnemonic list", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await Hive.openBox(testWalletId); + // + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // expect(await btc?.mnemonic, TEST_MNEMONIC.split(" ")); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); - expect(secureStore.interactions, 20); - expect(secureStore.writes, 7); - expect(secureStore.reads, 13); - expect(secureStore.deletes, 0); + // test("recoverFromMnemonic using non empty seed on mainnet succeeds", + // () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // bool hasThrown = false; + // try { + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("fullRescan succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" + // ] + // })).thenAnswer((_) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch valid wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // // destroy the data that the rescan will fix + // await wallet.put( + // 'receivingAddressesP2PKH', ["some address", "some other address"]); + // await wallet.put( + // 'receivingAddressesP2SH', ["some address", "some other address"]); + // await wallet.put( + // 'receivingAddressesP2WPKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2PKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2SH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2WPKH', ["some address", "some other address"]); + // await wallet.put('receivingIndexP2PKH', 123); + // await wallet.put('receivingIndexP2SH', 123); + // await wallet.put('receivingIndexP2WPKH', 123); + // await wallet.put('changeIndexP2PKH', 123); + // await wallet.put('changeIndexP2SH', 123); + // await wallet.put('changeIndexP2WPKH', 123); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); + // + // bool hasThrown = false; + // try { + // await btc?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) + // .called(1); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" + // ] + // })).called(2); + // + // expect(secureStore.writes, 25); + // expect(secureStore.reads, 32); + // expect(secureStore.deletes, 6); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); - test("get mnemonic list", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await Hive.openBox(testWalletId); - - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - expect(await btc?.mnemonic, TEST_MNEMONIC.split(" ")); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("recoverFromMnemonic using non empty seed on mainnet succeeds", - () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - bool hasThrown = false; - try { - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 7); - expect(secureStore.reads, 7); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("fullRescan succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) - .thenAnswer((realInvocation) async {}); - - when(client?.getBatchHistory(args: { - "0": [ - "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" - ] - })).thenAnswer((_) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch valid wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preReceivingAddressesP2SH = - await wallet.get('receivingAddressesP2SH'); - final preReceivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final preChangeAddressesP2WPKH = - await wallet.get('changeAddressesP2WPKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final preChangeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final preReceiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - // destroy the data that the rescan will fix - await wallet.put( - 'receivingAddressesP2PKH', ["some address", "some other address"]); - await wallet.put( - 'receivingAddressesP2SH', ["some address", "some other address"]); - await wallet.put( - 'receivingAddressesP2WPKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2PKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2SH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2WPKH', ["some address", "some other address"]); - await wallet.put('receivingIndexP2PKH', 123); - await wallet.put('receivingIndexP2SH', 123); - await wallet.put('receivingIndexP2WPKH', 123); - await wallet.put('changeIndexP2PKH', 123); - await wallet.put('changeIndexP2SH', 123); - await wallet.put('changeIndexP2WPKH', 123); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); - - bool hasThrown = false; - try { - await btc?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - final receivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final changeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final receiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preChangeAddressesP2SH, changeAddressesP2SH); - expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preReceivingIndexP2SH, receivingIndexP2SH); - expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preChangeIndexP2SH, changeIndexP2SH); - expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) - .called(1); - - verify(client?.getBatchHistory(args: { - "0": [ - "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" - ] - })).called(2); - - expect(secureStore.writes, 25); - expect(secureStore.reads, 32); - expect(secureStore.deletes, 6); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("fullRescan fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) - .thenAnswer((realInvocation) async {}); - - when(client?.getBatchHistory(args: { - "0": [ - "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" - ] - })).thenAnswer((_) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preReceivingAddressesP2SH = - await wallet.get('receivingAddressesP2SH'); - final preReceivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final preChangeAddressesP2WPKH = - await wallet.get('changeAddressesP2WPKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final preChangeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final preReceiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenThrow(Exception("fake exception")); - - bool hasThrown = false; - try { - await btc?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, true); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - final receivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final changeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final receiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preChangeAddressesP2SH, changeAddressesP2SH); - expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preReceivingIndexP2SH, receivingIndexP2SH); - expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preChangeIndexP2SH, changeIndexP2SH); - expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) - .called(1); - - verify(client?.getBatchHistory(args: { - "0": [ - "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" - ] - })).called(1); - - expect(secureStore.writes, 19); - expect(secureStore.reads, 32); - expect(secureStore.deletes, 12); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("fullRescan fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" + // ] + // })).thenAnswer((_) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenThrow(Exception("fake exception")); + // + // bool hasThrown = false; + // try { + // await btc?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoin)) + // .called(1); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "bf5a6c56814e80eed11e1e459801515f8c2b83da812568aa9dc26e6356f6965b" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "26f92666caebb9a17b14f5b573b385348cdc80065472b8961091f3226d2f650f" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "06593b2d896751e8dda288bb6587b6bb6a1dee71d82a85457f5654f781e37b12" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "11663d093cb17dfbed4a96d148b22d3e094b31d23c639c2814beb79f2ab0ca75" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "2f18558e5d3015cb6578aee1c3e4b645725fa4e1d26ce22cb31c9949f3b4957c" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "a328ae88ebce63c0010709ae900c199df2b585cdebce53a6291886dfdcc28c63" + // ] + // })).called(1); + // + // expect(secureStore.writes, 19); + // expect(secureStore.reads, 32); + // expect(secureStore.deletes, 12); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); // test("fetchBuildTxData succeeds", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -4049,145 +4044,145 @@ void main() async { // // }); - test("prepareSend fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - when(cachedClient?.getTransaction( - txHash: - "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", - coin: Coin.bitcoin)) - .thenAnswer((_) async => tx9Raw); - when(cachedClient?.getTransaction( - txHash: - "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", - coin: Coin.bitcoin)) - .thenAnswer((_) async => tx10Raw); - when(cachedClient?.getTransaction( - txHash: - "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", - coin: Coin.bitcoin, - )).thenAnswer((_) async => tx11Raw); - - // recover to fill data - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // modify addresses to properly mock data to build a tx - final rcv44 = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", - value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", - "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); - final rcv49 = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2SH", - value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", - "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); - final rcv84 = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2WPKH", - value: rcv84?.replaceFirst( - "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", - "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); - - // btc?.outputsList = utxoList; - - bool didThrow = false; - try { - await btc?.prepareSend( - address: "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc", - satoshiAmount: 15000); - } catch (_) { - didThrow = true; - } - - expect(didThrow, true); - - verify(client?.getServerFeatures()).called(1); - - /// verify transaction no matching calls - - // verify(cachedClient?.getTransaction( - // txHash: - // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", - // coin: Coin.bitcoin, - // callOutSideMainIsolate: false)) - // .called(1); - // verify(cachedClient?.getTransaction( - // txHash: - // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", - // coin: Coin.bitcoin, - // callOutSideMainIsolate: false)) - // .called(1); - // verify(cachedClient?.getTransaction( - // txHash: - // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", - // coin: Coin.bitcoin, - // callOutSideMainIsolate: false)) - // .called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 20); - expect(secureStore.writes, 10); - expect(secureStore.reads, 10); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("prepareSend fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // when(cachedClient?.getTransaction( + // txHash: + // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", + // coin: Coin.bitcoin)) + // .thenAnswer((_) async => tx9Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", + // coin: Coin.bitcoin)) + // .thenAnswer((_) async => tx10Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", + // coin: Coin.bitcoin, + // )).thenAnswer((_) async => tx11Raw); + // + // // recover to fill data + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // modify addresses to properly mock data to build a tx + // final rcv44 = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", + // value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", + // "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); + // final rcv49 = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2SH", + // value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", + // "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); + // final rcv84 = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2WPKH", + // value: rcv84?.replaceFirst( + // "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", + // "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); + // + // // btc?.outputsList = utxoList; + // + // bool didThrow = false; + // try { + // await btc?.prepareSend( + // address: "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc", + // satoshiAmount: 15000); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.getServerFeatures()).called(1); + // + // /// verify transaction no matching calls + // + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", + // // coin: Coin.bitcoin, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", + // // coin: Coin.bitcoin, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", + // // coin: Coin.bitcoin, + // // callOutSideMainIsolate: false)) + // // .called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 20); + // expect(secureStore.writes, 10); + // expect(secureStore.reads, 10); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); test("confirmSend no hex", () async { bool didThrow = false; @@ -4332,141 +4327,141 @@ void main() async { // // // // }); - test("refresh wallet mutex locked", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - // recover to fill data - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - btc?.refreshMutex = true; - - await btc?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 7); - expect(secureStore.reads, 7); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("refresh wallet normally", () async { - when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => - {"height": 520481, "hex": "some block hex"}); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenAnswer((_) async => []); - when(client?.estimateFee(blocks: anyNamed("blocks"))) - .thenAnswer((_) async => Decimal.one); - - final List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - // recover to fill data - await btc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((_) async => {}); - when(client?.getBatchUTXOs(args: anyNamed("args"))) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await btc?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); - verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); - verify(client?.getBlockHeadTip()).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - } - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 7); - expect(secureStore.reads, 7); - expect(secureStore.deletes, 0); - - // verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("refresh wallet mutex locked", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // btc?.refreshMutex = true; + // + // await btc?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("refresh wallet normally", () async { + // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => + // {"height": 520481, "hex": "some block hex"}); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((_) async => []); + // when(client?.estimateFee(blocks: anyNamed("blocks"))) + // .thenAnswer((_) async => Decimal.one); + // + // final List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await btc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((_) async => {}); + // when(client?.getBatchUTXOs(args: anyNamed("args"))) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await btc?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); + // verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); + // verify(client?.getBlockHeadTip()).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); tearDown(() async { await tearDownTestHive(); diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart index 8124d92e9..1a01906ea 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart @@ -3,20 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i10; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -49,37 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { - _FakeIsar_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_3 extends _i1.SmartFake - implements _i4.QueryBuilder { - _FakeQueryBuilder_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -115,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -134,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -154,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -171,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -182,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -193,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -209,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -226,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -242,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -254,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -271,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -283,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -303,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -322,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -338,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -355,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -375,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -391,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -402,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -418,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -453,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -474,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -493,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -509,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -525,26 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i9.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -573,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -590,302 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i10.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_2( - this, - Invocation.getter(#isar), - ), - ) as _i4.Isar); - @override - _i6.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i4 - .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); - @override - _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putAddresses(List<_i11.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future updateAddress( - _i11.Address? oldAddress, - _i11.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransaction(_i11.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactions(List<_i11.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); - @override - _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); - @override - _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); - @override - _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putOutputs(List<_i11.Output>? outputs) => - (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, - _i11.TransactionNote, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactionNotes( - List<_i11.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future addNewTransactionData( - List< - _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, - _i11.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index ac8096e05..c4cdede86 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -4,18 +4,15 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'bitcoincash_history_sample_data.dart'; import 'bitcoincash_wallet_test.mocks.dart'; import 'bitcoincash_wallet_test_parameters.dart'; @@ -23,7 +20,6 @@ import 'bitcoincash_wallet_test_parameters.dart'; ElectrumX, CachedElectrumX, TransactionNotificationTracker, - MainDB, ]) void main() async { group("bitcoincash constants", () { @@ -68,7 +64,7 @@ void main() async { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; + BitcoinCashWallet? mainnetWallet; setUp(() { @@ -76,7 +72,6 @@ void main() async { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); mainnetWallet = BitcoinCashWallet( walletId: "validateAddressMainNet", @@ -86,7 +81,6 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -198,7 +192,7 @@ void main() async { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; + BitcoinCashWallet? mainnetWallet; setUp(() { @@ -207,7 +201,6 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); mainnetWallet = BitcoinCashWallet( walletId: "validateAddressMainNet", @@ -217,7 +210,6 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -300,7 +292,7 @@ void main() async { group("testNetworkConnection", () { MockElectrumX? client; MockCachedElectrumX? cachedClient; - late MockMainDB mockMainDB; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -312,7 +304,6 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); bch = BitcoinCashWallet( walletId: "testNetworkConnection", @@ -322,7 +313,6 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -367,7 +357,7 @@ void main() async { MockElectrumX? client; MockCachedElectrumX? cachedClient; - late MockMainDB mockMainDB; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -379,7 +369,6 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); bch = BitcoinCashWallet( walletId: testWalletId, @@ -389,7 +378,6 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -410,7 +398,6 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); expect(bch?.coin, bchcoin); expect(secureStore.interactions, 0); @@ -581,7 +568,7 @@ void main() async { MockElectrumX? client; MockCachedElectrumX? cachedClient; - late MockMainDB mockMainDB; + late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; @@ -601,7 +588,6 @@ void main() async { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); bch = BitcoinCashWallet( walletId: testWalletId, @@ -611,7 +597,6 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -713,7 +698,7 @@ void main() async { // tracker: tracker!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // // await Hive.openBox(testWalletId); @@ -887,7 +872,7 @@ void main() async { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // // // // init existing @@ -930,43 +915,42 @@ void main() async { // // // // }); - test("get current receiving addresses", () async { - bch = BitcoinCashWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: bchtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - secureStore: secureStore, - mockableOverride: mockMainDB, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); - expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); - expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("get current receiving addresses", () async { + // bch = BitcoinCashWallet( + // walletId: testWalletId, + // walletName: testWalletName, + // coin: bchtestcoin, + // client: client!, + // cachedClient: cachedClient!, + // tracker: tracker!, + // secureStore: secureStore, + // ); + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await bch?.initializeNew(); + // await bch?.initializeExisting(); + // expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); + // expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); + // expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); + // + // verifyNever(client?.ping()).called(0); + // verify(client?.getServerFeatures()).called(1); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); // test("get utxos and balances", () async { // bch = BitcoinCashWallet( @@ -978,7 +962,7 @@ void main() async { // tracker: tracker!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1083,7 +1067,7 @@ void main() async { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1138,106 +1122,104 @@ void main() async { // // // // }); // - test("get utxos fails", () async { - bch = BitcoinCashWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: bchtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - secureStore: secureStore, - mockableOverride: mockMainDB, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - when(client?.getBatchUTXOs(args: anyNamed("args"))) - .thenThrow(Exception("some exception")); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - - final outputs = await bch!.utxos; - expect(outputs, isA>()); - expect(outputs.length, 0); - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("chain height fetch, update, and get", () async { - bch = BitcoinCashWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: bchtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - secureStore: secureStore, - mockableOverride: mockMainDB, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - - // get stored - expect(bch?.storedChainHeight, 0); - - // fetch fails - when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); - expect(await bch?.chainHeight, -1); - - // fetch succeeds - when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => { - "height": 100, - "hex": "some block hex", - }); - expect(await bch?.chainHeight, 100); - - // update - await bch?.updateCachedChainHeight(1000); - - // fetch updated - expect(bch?.storedChainHeight, 1000); - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verify(client?.getBlockHeadTip()).called(2); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); + // test("get utxos fails", () async { + // bch = BitcoinCashWallet( + // walletId: testWalletId, + // walletName: testWalletName, + // coin: bchtestcoin, + // client: client!, + // cachedClient: cachedClient!, + // tracker: tracker!, + // secureStore: secureStore, + // ); + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // when(client?.getBatchUTXOs(args: anyNamed("args"))) + // .thenThrow(Exception("some exception")); + // + // await bch?.initializeNew(); + // await bch?.initializeExisting(); + // + // final outputs = await bch!.utxos; + // expect(outputs, isA>()); + // expect(outputs.length, 0); + // + // verifyNever(client?.ping()).called(0); + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("chain height fetch, update, and get", () async { + // bch = BitcoinCashWallet( + // walletId: testWalletId, + // walletName: testWalletName, + // coin: bchtestcoin, + // client: client!, + // cachedClient: cachedClient!, + // tracker: tracker!, + // secureStore: secureStore, + // ); + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await bch?.initializeNew(); + // await bch?.initializeExisting(); + // + // // get stored + // expect(bch?.storedChainHeight, 0); + // + // // fetch fails + // when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); + // expect(await bch?.chainHeight, -1); + // + // // fetch succeeds + // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => { + // "height": 100, + // "hex": "some block hex", + // }); + // expect(await bch?.chainHeight, 100); + // + // // update + // await bch?.updateCachedChainHeight(1000); + // + // // fetch updated + // expect(bch?.storedChainHeight, 1000); + // + // verifyNever(client?.ping()).called(0); + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBlockHeadTip()).called(2); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); test("getTxCount succeeds", () async { when(client?.getHistory( @@ -1297,192 +1279,192 @@ void main() async { verifyNoMoreInteractions(tracker); }); - test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenAnswer((realInvocation) async => [ - { - "height": 4270385, - "tx_hash": - "c07f740ad72c0dd759741f4c9ab4b1586a22bc16545584364ac9b3d845766271" - }, - { - "height": 4270459, - "tx_hash": - "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" - } - ]); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - - bool didThrow = false; - try { - await bch?.checkCurrentReceivingAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, false); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(2); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 20); - expect(secureStore.reads, 13); - expect(secureStore.writes, 7); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("_checkCurrentReceivingAddressesForTransactions fails", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenThrow(Exception("some exception")); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - - bool didThrow = false; - try { - await bch?.checkCurrentReceivingAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, true); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 14); - expect(secureStore.reads, 9); - expect(secureStore.writes, 5); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("_checkCurrentChangeAddressesForTransactions succeeds", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenAnswer((realInvocation) async => [ - { - "height": 4286283, - "tx_hash": - "4c119685401e28982283e644c57d84fde6aab83324012e35c9b49e6efd99b49b" - }, - { - "height": 4286295, - "tx_hash": - "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" - } - ]); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - - bool didThrow = false; - try { - await bch?.checkCurrentChangeAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, false); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(2); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 20); - expect(secureStore.reads, 13); - expect(secureStore.writes, 7); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("_checkCurrentChangeAddressesForTransactions fails", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenThrow(Exception("some exception")); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await bch?.initializeNew(); - await bch?.initializeExisting(); - - bool didThrow = false; - try { - await bch?.checkCurrentChangeAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, true); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 14); - expect(secureStore.reads, 9); - expect(secureStore.writes, 5); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((realInvocation) async => [ + // { + // "height": 4270385, + // "tx_hash": + // "c07f740ad72c0dd759741f4c9ab4b1586a22bc16545584364ac9b3d845766271" + // }, + // { + // "height": 4270459, + // "tx_hash": + // "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" + // } + // ]); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await bch?.initializeNew(); + // await bch?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await bch?.checkCurrentReceivingAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, false); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(2); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 20); + // expect(secureStore.reads, 13); + // expect(secureStore.writes, 7); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("_checkCurrentReceivingAddressesForTransactions fails", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenThrow(Exception("some exception")); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await bch?.initializeNew(); + // await bch?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await bch?.checkCurrentReceivingAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, true); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 14); + // expect(secureStore.reads, 9); + // expect(secureStore.writes, 5); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("_checkCurrentChangeAddressesForTransactions succeeds", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((realInvocation) async => [ + // { + // "height": 4286283, + // "tx_hash": + // "4c119685401e28982283e644c57d84fde6aab83324012e35c9b49e6efd99b49b" + // }, + // { + // "height": 4286295, + // "tx_hash": + // "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" + // } + // ]); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await bch?.initializeNew(); + // await bch?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await bch?.checkCurrentChangeAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, false); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(2); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 20); + // expect(secureStore.reads, 13); + // expect(secureStore.writes, 7); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("_checkCurrentChangeAddressesForTransactions fails", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenThrow(Exception("some exception")); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await bch?.initializeNew(); + // await bch?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await bch?.checkCurrentChangeAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, true); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 14); + // expect(secureStore.reads, 9); + // expect(secureStore.writes, 5); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); // test("getAllTxsToWatch", () async { // TestWidgetsFlutterBinding.ensureInitialized(); @@ -1530,7 +1512,7 @@ void main() async { // cachedClient: cachedClient!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1660,7 +1642,7 @@ void main() async { // cachedClient: cachedClient!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1794,7 +1776,7 @@ void main() async { // tracker: tracker!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1847,7 +1829,7 @@ void main() async { // // tracker: tracker!, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put('receivingAddressesP2PKH', []); @@ -1874,54 +1856,54 @@ void main() async { // // // // }); - test("get mnemonic list", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((thing) async { - // print(jsonEncode(thing.namedArguments.entries.first.value)); - // return {}; - // }); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await Hive.openBox(testWalletId); - - // add maxNumberOfIndexesToCheck and height - await bch?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - expect(await bch?.mnemonic, TEST_MNEMONIC.split(" ")); - // - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); + // test("get mnemonic list", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // // when(client?.getBatchHistory(args: anyNamed("args"))) + // // .thenAnswer((thing) async { + // // print(jsonEncode(thing.namedArguments.entries.first.value)); + // // return {}; + // // }); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await Hive.openBox(testWalletId); + // + // // add maxNumberOfIndexesToCheck and height + // await bch?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // expect(await bch?.mnemonic, TEST_MNEMONIC.split(" ")); + // // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); test( "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", @@ -1967,7 +1949,6 @@ void main() async { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); when(client?.getServerFeatures()).thenAnswer((_) async => { "hosts": {}, @@ -2035,398 +2016,398 @@ void main() async { verifyNoMoreInteractions(cachedClient); }); - test("recoverFromMnemonic using non empty seed on mainnet succeeds", - () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - // final wallet = await Hive.openBox (testWalletId); - await Hive.openBox(testWalletId); - - bool hasThrown = false; - try { - await bch?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 10); - expect(secureStore.writes, 5); - expect(secureStore.reads, 5); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("fullRescan succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) - .thenAnswer((realInvocation) async {}); - - when(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).thenAnswer((_) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await bch?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch valid wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - - final preReceivingAddressesP2SH = - await wallet.get('receivingAddressesP2SH'); - final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final preReceivingIndexP2SH = await wallet.get('receivingIndexP2PKH'); - final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - final preReceiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final preChangeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - - // destroy the data that the rescan will fix - await wallet.put( - 'receivingAddressesP2PKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2PKH', ["some address", "some other address"]); - - await wallet.put( - 'receivingAddressesP2SH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2SH', ["some address", "some other address"]); - - await wallet.put('receivingIndexP2PKH', 123); - await wallet.put('changeIndexP2PKH', 123); - - await wallet.put('receivingIndexP2SH', 123); - await wallet.put('changeIndexP2SH', 123); - - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); - - bool hasThrown = false; - try { - await bch?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - - final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - final receiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final changeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - - expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - expect(preChangeAddressesP2SH, changeAddressesP2SH); - expect(preReceivingIndexP2SH, receivingIndexP2SH); - expect(preChangeIndexP2SH, changeIndexP2SH); - - expect(preUtxoData, utxoData); - - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - - expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) - .called(1); - - verify(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).called(2); - - expect(secureStore.writes, 17); - expect(secureStore.reads, 22); - expect(secureStore.deletes, 4); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("fullRescan fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) - .thenAnswer((realInvocation) async {}); - - when(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).thenAnswer((_) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).thenAnswer((_) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await bch?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenThrow(Exception("fake exception")); - - bool hasThrown = false; - try { - await bch?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, true); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) - .called(1); - - verify(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).called(2); - - expect(secureStore.writes, 13); - expect(secureStore.reads, 18); - expect(secureStore.deletes, 8); - }); + // test("recoverFromMnemonic using non empty seed on mainnet succeeds", + // () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // // final wallet = await Hive.openBox (testWalletId); + // await Hive.openBox(testWalletId); + // + // bool hasThrown = false; + // try { + // await bch?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 10); + // expect(secureStore.writes, 5); + // expect(secureStore.reads, 5); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("fullRescan succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).thenAnswer((_) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await bch?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch valid wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // + // // destroy the data that the rescan will fix + // await wallet.put( + // 'receivingAddressesP2PKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2PKH', ["some address", "some other address"]); + // + // await wallet.put( + // 'receivingAddressesP2SH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2SH', ["some address", "some other address"]); + // + // await wallet.put('receivingIndexP2PKH', 123); + // await wallet.put('changeIndexP2PKH', 123); + // + // await wallet.put('receivingIndexP2SH', 123); + // await wallet.put('changeIndexP2SH', 123); + // + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); + // + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); + // + // bool hasThrown = false; + // try { + // await bch?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // + // expect(preUtxoData, utxoData); + // + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) + // .called(1); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).called(2); + // + // expect(secureStore.writes, 17); + // expect(secureStore.reads, 22); + // expect(secureStore.deletes, 4); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("fullRescan fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).thenAnswer((_) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).thenAnswer((_) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await bch?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenThrow(Exception("fake exception")); + // + // bool hasThrown = false; + // try { + // await bch?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.bitcoincash)) + // .called(1); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).called(2); + // + // expect(secureStore.writes, 13); + // expect(secureStore.reads, 18); + // expect(secureStore.deletes, 8); + // }); // // test("fetchBuildTxData succeeds", () async { // // when(client.getServerFeatures()).thenAnswer((_) async => { @@ -2889,190 +2870,190 @@ void main() async { verifyNoMoreInteractions(tracker); }); - test("refresh wallet mutex locked", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - await Hive.openBox(testWalletId); - // recover to fill data - await bch?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - bch?.refreshMutex = true; - - await bch?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - verify(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).called(1); - - expect(secureStore.interactions, 10); - expect(secureStore.writes, 5); - expect(secureStore.reads, 5); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("refresh wallet throws", () async { - when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - - when(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenThrow(Exception("some exception")); - - await Hive.openBox(testWalletId); - - // recover to fill data - await bch?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - await bch?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - verify(client?.getBatchHistory(args: { - "0": [ - "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" - ] - })).called(1); - - verify(client?.getBlockHeadTip()).called(1); - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - - expect(secureStore.interactions, 10); - expect(secureStore.writes, 5); - expect(secureStore.reads, 5); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); + // test("refresh wallet mutex locked", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // await Hive.openBox(testWalletId); + // // recover to fill data + // await bch?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // bch?.refreshMutex = true; + // + // await bch?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).called(1); + // + // expect(secureStore.interactions, 10); + // expect(secureStore.writes, 5); + // expect(secureStore.reads, 5); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("refresh wallet throws", () async { + // when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenThrow(Exception("some exception")); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await bch?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // await bch?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "04818da846fe5e03ac993d2e0c1ccc3848ff6073c3aba6a572df4efc5432ae8b" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "f0c86f888f2aca0efaf1705247dbd1ebc02347c183e197310c9062ea2c9d2e34" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "ff7f0d2a4b8e2805706ece77f4e672550fe4c505a150c781639814338eda1734" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "1c2336c32dc62f00862ee6a75643e01017c86edece10b5a9d7defbd5f66b0a80" + // ] + // })).called(1); + // + // verify(client?.getBlockHeadTip()).called(1); + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // + // expect(secureStore.interactions, 10); + // expect(secureStore.writes, 5); + // expect(secureStore.reads, 5); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); // test("refresh wallet normally", () async { // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart index fe0a413f6..4f0016262 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart @@ -3,20 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i10; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -49,37 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { - _FakeIsar_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_3 extends _i1.SmartFake - implements _i4.QueryBuilder { - _FakeQueryBuilder_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -115,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -134,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -154,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -171,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -182,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -193,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -209,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -226,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -242,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -254,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -271,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -283,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -303,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -322,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -338,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -355,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -375,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -391,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -402,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -418,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -453,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -474,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -493,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -509,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -525,26 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i9.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -573,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -590,302 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i10.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_2( - this, - Invocation.getter(#isar), - ), - ) as _i4.Isar); - @override - _i6.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i4 - .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); - @override - _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putAddresses(List<_i11.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future updateAddress( - _i11.Address? oldAddress, - _i11.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransaction(_i11.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactions(List<_i11.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); - @override - _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); - @override - _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); - @override - _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putOutputs(List<_i11.Output>? outputs) => - (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, - _i11.TransactionNote, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactionNotes( - List<_i11.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future addNewTransactionData( - List< - _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, - _i11.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.dart index b669a0783..e9f166736 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.dart @@ -1,22 +1,18 @@ -import 'package:bitcoindart/bitcoindart.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'dogecoin_history_sample_data.dart'; import 'dogecoin_wallet_test.mocks.dart'; import 'dogecoin_wallet_test_parameters.dart'; @@ -24,7 +20,6 @@ import 'dogecoin_wallet_test_parameters.dart'; ElectrumX, CachedElectrumX, TransactionNotificationTracker, - MainDB, ]) void main() { group("dogecoin constants", () { @@ -99,7 +94,6 @@ void main() { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; DogecoinWallet? mainnetWallet; @@ -108,7 +102,6 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); mainnetWallet = DogecoinWallet( walletId: "validateAddressMainNet", @@ -118,7 +111,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -193,7 +185,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; DogecoinWallet? doge; @@ -202,7 +193,6 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); doge = DogecoinWallet( walletId: "testNetworkConnection", @@ -212,7 +202,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -261,7 +250,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; DogecoinWallet? doge; @@ -271,7 +259,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); doge = DogecoinWallet( walletId: testWalletId, @@ -281,7 +268,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -302,7 +288,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); expect(doge?.coin, dtestcoin); expect(secureStore.interactions, 0); @@ -476,7 +461,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; DogecoinWallet? doge; @@ -494,7 +478,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); doge = DogecoinWallet( walletId: testWalletId, @@ -504,7 +487,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -606,7 +588,7 @@ void main() { // tracker: tracker!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // // await Hive.openBox(testWalletId); @@ -780,7 +762,7 @@ void main() { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // // // // init existing @@ -823,52 +805,51 @@ void main() { // // // // }); - test("get current receiving addresses", () async { - doge = DogecoinWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: dtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - secureStore: secureStore, - mockableOverride: mockMainDB, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - expect( - Address.validateAddress( - await doge!.currentReceivingAddress, dogecointestnet), - true); - expect( - Address.validateAddress( - await doge!.currentReceivingAddress, dogecointestnet), - true); - expect( - Address.validateAddress( - await doge!.currentReceivingAddress, dogecointestnet), - true); - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("get current receiving addresses", () async { + // doge = DogecoinWallet( + // walletId: testWalletId, + // walletName: testWalletName, + // coin: dtestcoin, + // client: client!, + // cachedClient: cachedClient!, + // tracker: tracker!, + // secureStore: secureStore, + // ); + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await doge?.initializeNew(); + // await doge?.initializeExisting(); + // expect( + // Address.validateAddress( + // await doge!.currentReceivingAddress, dogecointestnet), + // true); + // expect( + // Address.validateAddress( + // await doge!.currentReceivingAddress, dogecointestnet), + // true); + // expect( + // Address.validateAddress( + // await doge!.currentReceivingAddress, dogecointestnet), + // true); + // + // verifyNever(client?.ping()).called(0); + // verify(client?.getServerFeatures()).called(1); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); // test("get utxos and balances", () async { // doge = DogecoinWallet( @@ -880,7 +861,7 @@ void main() { // tracker: tracker!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // when(client?.ping()).thenAnswer((_) async => true); // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -985,7 +966,7 @@ void main() { // // cachedClient: cachedClient!, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1040,106 +1021,104 @@ void main() { // // // // }); // - test("get utxos fails", () async { - doge = DogecoinWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: dtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - secureStore: secureStore, - mockableOverride: mockMainDB, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - when(client?.getBatchUTXOs(args: anyNamed("args"))) - .thenThrow(Exception("some exception")); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - - final outputs = await doge!.utxos; - expect(outputs, isA>()); - expect(outputs.length, 0); - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("chain height fetch, update, and get", () async { - doge = DogecoinWallet( - walletId: testWalletId, - walletName: testWalletName, - coin: dtestcoin, - client: client!, - cachedClient: cachedClient!, - tracker: tracker!, - secureStore: secureStore, - mockableOverride: mockMainDB, - ); - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_TESTNET, - "hash_function": "sha256", - "services": [] - }); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - - // get stored - expect(doge?.storedChainHeight, 0); - - // fetch fails - when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); - expect(await doge?.chainHeight, -1); - - // fetch succeeds - when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => { - "height": 100, - "hex": "some block hex", - }); - expect(await doge?.chainHeight, 100); - - // update - await doge?.updateCachedChainHeight(1000); - - // fetch updated - expect(doge?.storedChainHeight, 1000); - - verifyNever(client?.ping()).called(0); - verify(client?.getServerFeatures()).called(1); - verify(client?.getBlockHeadTip()).called(2); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); + // test("get utxos fails", () async { + // doge = DogecoinWallet( + // walletId: testWalletId, + // walletName: testWalletName, + // coin: dtestcoin, + // client: client!, + // cachedClient: cachedClient!, + // tracker: tracker!, + // secureStore: secureStore, + // ); + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // when(client?.getBatchUTXOs(args: anyNamed("args"))) + // .thenThrow(Exception("some exception")); + // + // await doge?.initializeNew(); + // await doge?.initializeExisting(); + // + // final outputs = await doge!.utxos; + // expect(outputs, isA>()); + // expect(outputs.length, 0); + // + // verifyNever(client?.ping()).called(0); + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchUTXOs(args: anyNamed("args"))).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("chain height fetch, update, and get", () async { + // doge = DogecoinWallet( + // walletId: testWalletId, + // walletName: testWalletName, + // coin: dtestcoin, + // client: client!, + // cachedClient: cachedClient!, + // tracker: tracker!, + // secureStore: secureStore, + // ); + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await doge?.initializeNew(); + // await doge?.initializeExisting(); + // + // // get stored + // expect(doge?.storedChainHeight, 0); + // + // // fetch fails + // when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); + // expect(await doge?.chainHeight, -1); + // + // // fetch succeeds + // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => { + // "height": 100, + // "hex": "some block hex", + // }); + // expect(await doge?.chainHeight, 100); + // + // // update + // await doge?.updateCachedChainHeight(1000); + // + // // fetch updated + // expect(doge?.storedChainHeight, 1000); + // + // verifyNever(client?.ping()).called(0); + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBlockHeadTip()).called(2); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); test("getTxCount succeeds", () async { when(client?.getHistory( @@ -1199,192 +1178,192 @@ void main() { verifyNoMoreInteractions(tracker); }); - test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenAnswer((realInvocation) async => [ - { - "height": 4270385, - "tx_hash": - "c07f740ad72c0dd759741f4c9ab4b1586a22bc16545584364ac9b3d845766271" - }, - { - "height": 4270459, - "tx_hash": - "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" - } - ]); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - - bool didThrow = false; - try { - await doge?.checkCurrentReceivingAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, false); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 11); - expect(secureStore.reads, 7); - expect(secureStore.writes, 4); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("_checkCurrentReceivingAddressesForTransactions fails", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenThrow(Exception("some exception")); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - - bool didThrow = false; - try { - await doge?.checkCurrentReceivingAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, true); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 8); - expect(secureStore.reads, 5); - expect(secureStore.writes, 3); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("_checkCurrentChangeAddressesForTransactions succeeds", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenAnswer((realInvocation) async => [ - { - "height": 4286283, - "tx_hash": - "4c119685401e28982283e644c57d84fde6aab83324012e35c9b49e6efd99b49b" - }, - { - "height": 4286295, - "tx_hash": - "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" - } - ]); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - - bool didThrow = false; - try { - await doge?.checkCurrentChangeAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, false); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 11); - expect(secureStore.reads, 7); - expect(secureStore.writes, 4); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("_checkCurrentChangeAddressesForTransactions fails", () async { - when(client?.ping()).thenAnswer((_) async => true); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenThrow(Exception("some exception")); - - await Hive.openBox(testWalletId); - await Hive.openBox(DB.boxNamePrefs); - - await doge?.initializeNew(); - await doge?.initializeExisting(); - - bool didThrow = false; - try { - await doge?.checkCurrentChangeAddressesForTransactions(); - } catch (_) { - didThrow = true; - } - expect(didThrow, true); - - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - verify(client?.getServerFeatures()).called(1); - verifyNever(client?.ping()).called(0); - - expect(secureStore.interactions, 8); - expect(secureStore.reads, 5); - expect(secureStore.writes, 3); - expect(secureStore.deletes, 0); - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((realInvocation) async => [ + // { + // "height": 4270385, + // "tx_hash": + // "c07f740ad72c0dd759741f4c9ab4b1586a22bc16545584364ac9b3d845766271" + // }, + // { + // "height": 4270459, + // "tx_hash": + // "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" + // } + // ]); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await doge?.initializeNew(); + // await doge?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await doge?.checkCurrentReceivingAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, false); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 11); + // expect(secureStore.reads, 7); + // expect(secureStore.writes, 4); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("_checkCurrentReceivingAddressesForTransactions fails", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenThrow(Exception("some exception")); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await doge?.initializeNew(); + // await doge?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await doge?.checkCurrentReceivingAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, true); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 8); + // expect(secureStore.reads, 5); + // expect(secureStore.writes, 3); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("_checkCurrentChangeAddressesForTransactions succeeds", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((realInvocation) async => [ + // { + // "height": 4286283, + // "tx_hash": + // "4c119685401e28982283e644c57d84fde6aab83324012e35c9b49e6efd99b49b" + // }, + // { + // "height": 4286295, + // "tx_hash": + // "82da70c660daf4d42abd403795d047918c4021ff1d706b61790cda01a1c5ae5a" + // } + // ]); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await doge?.initializeNew(); + // await doge?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await doge?.checkCurrentChangeAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, false); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 11); + // expect(secureStore.reads, 7); + // expect(secureStore.writes, 4); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("_checkCurrentChangeAddressesForTransactions fails", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenThrow(Exception("some exception")); + // + // await Hive.openBox(testWalletId); + // await Hive.openBox(DB.boxNamePrefs); + // + // await doge?.initializeNew(); + // await doge?.initializeExisting(); + // + // bool didThrow = false; + // try { + // await doge?.checkCurrentChangeAddressesForTransactions(); + // } catch (_) { + // didThrow = true; + // } + // expect(didThrow, true); + // + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // verify(client?.getServerFeatures()).called(1); + // verifyNever(client?.ping()).called(0); + // + // expect(secureStore.interactions, 8); + // expect(secureStore.reads, 5); + // expect(secureStore.writes, 3); + // expect(secureStore.deletes, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); // test("getAllTxsToWatch", () async { // TestWidgetsFlutterBinding.ensureInitialized(); @@ -1432,7 +1411,7 @@ void main() { // cachedClient: cachedClient!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1562,7 +1541,7 @@ void main() { // cachedClient: cachedClient!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1696,7 +1675,7 @@ void main() { // tracker: tracker!, // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // ); // final wallet = await Hive.openBox (testWalletId); // await wallet.put('receivingAddressesP2PKH', []); @@ -1749,7 +1728,7 @@ void main() { // // tracker: tracker!, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // final wallet = await Hive.openBox (testWalletId); // // await wallet.put('receivingAddressesP2PKH', []); @@ -1776,41 +1755,41 @@ void main() { // // // // }); - test("get mnemonic list", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await Hive.openBox(testWalletId); - - // add maxNumberOfIndexesToCheck and height - await doge?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - expect(await doge?.mnemonic, TEST_MNEMONIC.split(" ")); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); + // test("get mnemonic list", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await Hive.openBox(testWalletId); + // + // // add maxNumberOfIndexesToCheck and height + // await doge?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // expect(await doge?.mnemonic, TEST_MNEMONIC.split(" ")); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); test( "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", @@ -1856,7 +1835,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); when(client?.getServerFeatures()).thenAnswer((_) async => { "hosts": {}, @@ -1924,299 +1902,299 @@ void main() { verifyNoMoreInteractions(cachedClient); }); - test("recoverFromMnemonic using non empty seed on mainnet succeeds", - () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - - when(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - await Hive.openBox(testWalletId); - - bool hasThrown = false; - try { - await doge?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).called(1); - - expect(secureStore.interactions, 6); - expect(secureStore.writes, 3); - expect(secureStore.reads, 3); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("fullRescan succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) - .thenAnswer((realInvocation) async {}); - - when(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await doge?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch valid wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - // destroy the data that the rescan will fix - await wallet.put( - 'receivingAddressesP2PKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2PKH', ["some address", "some other address"]); - - await wallet.put('receivingIndexP2PKH', 123); - await wallet.put('changeIndexP2PKH', 123); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - - bool hasThrown = false; - try { - await doge?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) - .called(1); - - expect(secureStore.writes, 9); - expect(secureStore.reads, 12); - expect(secureStore.deletes, 2); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("fullRescan fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - - when(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) - .thenAnswer((realInvocation) async {}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await doge?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenThrow(Exception("fake exception")); - - bool hasThrown = false; - try { - await doge?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, true); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).called(1); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) - .called(1); - - expect(secureStore.writes, 7); - expect(secureStore.reads, 12); - expect(secureStore.deletes, 4); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); + // test("recoverFromMnemonic using non empty seed on mainnet succeeds", + // () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // await Hive.openBox(testWalletId); + // + // bool hasThrown = false; + // try { + // await doge?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).called(1); + // + // expect(secureStore.interactions, 6); + // expect(secureStore.writes, 3); + // expect(secureStore.reads, 3); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("fullRescan succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await doge?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch valid wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // // destroy the data that the rescan will fix + // await wallet.put( + // 'receivingAddressesP2PKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2PKH', ["some address", "some other address"]); + // + // await wallet.put('receivingIndexP2PKH', 123); + // await wallet.put('changeIndexP2PKH', 123); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); + // + // bool hasThrown = false; + // try { + // await doge?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) + // .called(1); + // + // expect(secureStore.writes, 9); + // expect(secureStore.reads, 12); + // expect(secureStore.deletes, 2); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("fullRescan fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) + // .thenAnswer((realInvocation) async {}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await doge?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenThrow(Exception("fake exception")); + // + // bool hasThrown = false; + // try { + // await doge?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).called(1); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) + // .called(1); + // + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 12); + // expect(secureStore.deletes, 4); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); // // test("fetchBuildTxData succeeds", () async { // // when(client.getServerFeatures()).thenAnswer((_) async => { @@ -2679,136 +2657,136 @@ void main() { verifyNoMoreInteractions(tracker); }); - test("refresh wallet mutex locked", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // recover to fill data - await doge?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - doge?.refreshMutex = true; - - await doge?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).called(1); - - expect(secureStore.interactions, 6); - expect(secureStore.writes, 3); - expect(secureStore.reads, 3); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("refresh wallet throws", () async { - when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenThrow(Exception("some exception")); - - await Hive.openBox(testWalletId); - - // recover to fill data - await doge?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - await doge?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" - ] - })).called(1); - verify(client?.getBlockHeadTip()).called(1); - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); - - expect(secureStore.interactions, 6); - expect(secureStore.writes, 3); - expect(secureStore.reads, 3); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); + // test("refresh wallet mutex locked", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // recover to fill data + // await doge?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // doge?.refreshMutex = true; + // + // await doge?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).called(1); + // + // expect(secureStore.interactions, 6); + // expect(secureStore.writes, 3); + // expect(secureStore.reads, 3); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("refresh wallet throws", () async { + // when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenThrow(Exception("some exception")); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await doge?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // await doge?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c82d4ac9697408d423d59dc53267f6474bbd4c22c55fd42ba766e80c6068e7dc" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "80badd62a8dd884cc7f61d962484564929340debb27f88fef270e553306a030c" + // ] + // })).called(1); + // verify(client?.getBlockHeadTip()).called(1); + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(1); + // + // expect(secureStore.interactions, 6); + // expect(secureStore.writes, 3); + // expect(secureStore.reads, 3); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); // test("refresh wallet normally", () async { // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart index e5c575519..ae555da22 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart @@ -3,20 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i10; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -49,37 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { - _FakeIsar_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_3 extends _i1.SmartFake - implements _i4.QueryBuilder { - _FakeQueryBuilder_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -115,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -134,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -154,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -171,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -182,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -193,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -209,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -226,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -242,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -254,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -271,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -283,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -303,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -322,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -338,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -355,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -375,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -391,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -402,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -418,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -453,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -474,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -493,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -509,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -525,26 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i9.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -573,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -590,302 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i10.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_2( - this, - Invocation.getter(#isar), - ), - ) as _i4.Isar); - @override - _i6.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i4 - .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); - @override - _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putAddresses(List<_i11.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future updateAddress( - _i11.Address? oldAddress, - _i11.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransaction(_i11.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactions(List<_i11.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); - @override - _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); - @override - _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); - @override - _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putOutputs(List<_i11.Output>? outputs) => - (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, - _i11.TransactionNote, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactionNotes( - List<_i11.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future addNewTransactionData( - List< - _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, - _i11.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index c2f200842..d6d6fe2e4 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; -import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -9,7 +8,6 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; @@ -22,7 +20,6 @@ import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/format.dart'; import 'firo_wallet_test.mocks.dart'; import 'firo_wallet_test_parameters.dart'; @@ -36,7 +33,6 @@ import 'sample_data/transaction_data_samples.dart'; ElectrumX, CachedElectrumX, TransactionNotificationTracker, - MainDB, ]) void main() { group("isolate functions", () { @@ -570,7 +566,7 @@ void main() { // client: client,coin: Coin.firo, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -593,7 +589,7 @@ void main() { // coin: Coin.firo, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -627,7 +623,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -660,7 +656,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -707,7 +703,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -779,7 +775,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -886,7 +882,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -934,8 +930,7 @@ void main() { // final secureStore = FakeSecureStorage(); // // final tracker = MockTransactionNotificationTracker(); - // final mockMainDB = MockMainDB(); - // + // // // await Hive.openBox(DB.boxNamePrefs); // await Prefs.instance.init(); // @@ -974,7 +969,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: tracker, // ); @@ -991,104 +986,102 @@ void main() { // }); group("refreshIfThereIsNewData", () { - test("refreshIfThereIsNewData with no unconfirmed transactions", - () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final secureStore = FakeSecureStorage(); - final tracker = MockTransactionNotificationTracker(); - final mockMainDB = MockMainDB(); - - when(tracker.pendings).thenAnswer((realInvocation) => [ - "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e", - "FF7e74edecd8c14ff5a8ddeb54e9e5e9c7c301c6f76f0ac1ac8119c6cc15e35", - "f4217364cbe6a81ef7ecaaeba0a6d6b576a9850b3e891fa7b88ed4927c505218" - ]); - when(tracker.wasNotifiedPending( - "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e")) - .thenAnswer((realInvocation) => true); - when(tracker.wasNotifiedPending( - "FF7e74edecd8c14ff5a8ddeb54e9e5e9c7c301c6f76f0ac1ac8119c6cc15e35")) - .thenAnswer((realInvocation) => true); - when(tracker.wasNotifiedPending( - "f4217364cbe6a81ef7ecaaeba0a6d6b576a9850b3e891fa7b88ed4927c505218")) - .thenAnswer((realInvocation) => true); - - when(tracker.wasNotifiedConfirmed( - "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e")) - .thenAnswer((realInvocation) => true); - when(tracker.wasNotifiedConfirmed( - "FF7e74edecd8c14ff5a8ddeb54e9e5e9c7c301c6f76f0ac1ac8119c6cc15e35")) - .thenAnswer((realInvocation) => true); - when(tracker.wasNotifiedConfirmed( - "f4217364cbe6a81ef7ecaaeba0a6d6b576a9850b3e891fa7b88ed4927c505218")) - .thenAnswer((realInvocation) => true); - - when(client.getBatchHistory(args: batchHistoryRequest0)) - .thenAnswer((realInvocation) async => batchHistoryResponse0); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - - final firo = FiroWallet( - walletName: testWalletName, - walletId: "${testWalletId}refreshIfThereIsNewData", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: tracker, - ); - - // firo.unconfirmedTxs = {}; - - final wallet = await Hive.openBox( - "${testWalletId}refreshIfThereIsNewData"); - await wallet.put('receivingAddresses', [ - "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", - "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", - "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq", - ]); - - await wallet.put('changeAddresses', [ - "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", - ]); - - final result = await firo.refreshIfThereIsNewData(); - expect(result, false); - }); + // test("refreshIfThereIsNewData with no unconfirmed transactions", + // () async { + // TestWidgetsFlutterBinding.ensureInitialized(); + // const MethodChannel('uk.spiralarm.flutter/devicelocale') + // .setMockMethodCallHandler((methodCall) async => 'en_US'); + // + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // final secureStore = FakeSecureStorage(); + // final tracker = MockTransactionNotificationTracker(); + // + // when(tracker.pendings).thenAnswer((realInvocation) => [ + // "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e", + // "FF7e74edecd8c14ff5a8ddeb54e9e5e9c7c301c6f76f0ac1ac8119c6cc15e35", + // "f4217364cbe6a81ef7ecaaeba0a6d6b576a9850b3e891fa7b88ed4927c505218" + // ]); + // when(tracker.wasNotifiedPending( + // "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e")) + // .thenAnswer((realInvocation) => true); + // when(tracker.wasNotifiedPending( + // "FF7e74edecd8c14ff5a8ddeb54e9e5e9c7c301c6f76f0ac1ac8119c6cc15e35")) + // .thenAnswer((realInvocation) => true); + // when(tracker.wasNotifiedPending( + // "f4217364cbe6a81ef7ecaaeba0a6d6b576a9850b3e891fa7b88ed4927c505218")) + // .thenAnswer((realInvocation) => true); + // + // when(tracker.wasNotifiedConfirmed( + // "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e")) + // .thenAnswer((realInvocation) => true); + // when(tracker.wasNotifiedConfirmed( + // "FF7e74edecd8c14ff5a8ddeb54e9e5e9c7c301c6f76f0ac1ac8119c6cc15e35")) + // .thenAnswer((realInvocation) => true); + // when(tracker.wasNotifiedConfirmed( + // "f4217364cbe6a81ef7ecaaeba0a6d6b576a9850b3e891fa7b88ed4927c505218")) + // .thenAnswer((realInvocation) => true); + // + // when(client.getBatchHistory(args: batchHistoryRequest0)) + // .thenAnswer((realInvocation) async => batchHistoryResponse0); + // + // // mock transaction calls + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash0, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData0); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash1, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData1); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash2, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData2); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash3, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData3); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash4, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData4); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash5, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData5); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash6, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData6); + // + // final firo = FiroWallet( + // walletName: testWalletName, + // walletId: "${testWalletId}refreshIfThereIsNewData", + // coin: Coin.firo, + // client: client, + // cachedClient: cachedClient, + // secureStore: secureStore, + // tracker: tracker, + // ); + // + // // firo.unconfirmedTxs = {}; + // + // final wallet = await Hive.openBox( + // "${testWalletId}refreshIfThereIsNewData"); + // await wallet.put('receivingAddresses', [ + // "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", + // "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", + // "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq", + // ]); + // + // await wallet.put('changeAddresses', [ + // "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", + // ]); + // + // final result = await firo.refreshIfThereIsNewData(); + // expect(result, false); + // }); // TODO: mock NotificationAPI // test("refreshIfThereIsNewData with two unconfirmed transactions", @@ -1098,8 +1091,7 @@ void main() { // final secureStore = FakeSecureStorage(); // // final tracker = MockTransactionNotificationTracker(); - // final mockMainDB = MockMainDB(); - // + // // // when(client.getTransaction(txHash: SampleGetTransactionData.txHash6)) // .thenAnswer((_) async => SampleGetTransactionData.txData6); // @@ -1137,7 +1129,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: tracker, // ); @@ -1154,7 +1146,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); when(client.broadcastTransaction( rawTx: @@ -1169,7 +1160,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1184,7 +1174,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); final firo = FiroWallet( walletName: testWalletName, @@ -1193,7 +1182,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1240,7 +1228,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); await secureStore.write( key: "${testWalletId}buildMintTransaction_mnemonic", @@ -1261,7 +1248,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -1286,878 +1272,869 @@ void main() { expect(result["txHex"], isA()); }); - test("recoverFromMnemonic succeeds", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); - - // mock electrumx client calls - when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client.getLatestCoinId()).thenAnswer((_) async => 1); - when(cachedClient.getUsedCoinSerials( - coin: Coin.firo, - )).thenAnswer( - (_) async => GetUsedSerialsSampleData.serials["serials"] as List); - - when(cachedClient.getAnonymitySet( - groupId: "1", - coin: Coin.firo, - )).thenAnswer( - (_) async => GetAnonymitySetSampleData.data, - ); - - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData0; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData1; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData2; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData3; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData4; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData5; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData6; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash8, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData8; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash9, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData9; - }); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash7, - coin: Coin.firo, - )).thenAnswer((_) async { - return SampleGetTransactionData.txData7; - }); - - final firo = FiroWallet( - walletName: testWalletName, - walletId: "${testWalletId}recoverFromMnemonic", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: MockTransactionNotificationTracker(), - ); - - // pre grab derivations in order to set up mock calls needed later on - await firo.fillAddresses(TEST_MNEMONIC); - final wallet = - await Hive.openBox("${testWalletId}recoverFromMnemonic"); - - final rcv = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); - final chg = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_changeDerivations"); - final receiveDerivations = - Map.from(jsonDecode(rcv as String) as Map); - final changeDerivations = - Map.from(jsonDecode(chg as String) as Map); - - for (int i = 0; i < receiveDerivations.length; i++) { - final receiveHash = AddressUtils.convertToScriptHash( - receiveDerivations["$i"]!["address"] as String, firoNetwork); - final changeHash = AddressUtils.convertToScriptHash( - changeDerivations["$i"]!["address"] as String, firoNetwork); - List> data; - switch (receiveHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - when(client.getHistory(scripthash: receiveHash)) - .thenAnswer((_) async => data); - - switch (changeHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - - when(client.getHistory(scripthash: changeHash)) - .thenAnswer((_) async => data); - } - - when(client.getBatchHistory(args: { - "0": [SampleGetHistoryData.scripthash0], - "1": [SampleGetHistoryData.scripthash3] - })).thenAnswer((realInvocation) async => { - "0": SampleGetHistoryData.data0, - "1": SampleGetHistoryData.data3, - }); - - await firo.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 20, - height: 0, - maxNumberOfIndexesToCheck: 1000); - - final receivingAddresses = await wallet.get('receivingAddresses'); - expect(receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); - - final changeAddresses = await wallet.get('changeAddresses'); - expect(changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); - - final receivingIndex = await wallet.get('receivingIndex'); - expect(receivingIndex, 0); - - final changeIndex = await wallet.get('changeIndex'); - expect(changeIndex, 0); - - final _rcv = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); - final _chg = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_changeDerivations"); - final _receiveDerivations = - Map.from(jsonDecode(_rcv as String) as Map); - final _changeDerivations = - Map.from(jsonDecode(_chg as String) as Map); - // expect(_receiveDerivations.length, 190); - // expect(_changeDerivations.length, 190); - expect(_receiveDerivations.length, 80); - expect(_changeDerivations.length, 80); - - final mintIndex = await wallet.get('mintIndex'); - expect(mintIndex, 8); - - final lelantusCoins = await wallet.get('_lelantus_coins') as List; - expect(lelantusCoins.length, 7); - final lcoin = lelantusCoins - .firstWhere((element) => - (Map.from(element as Map)) - .values - .first - .txId == - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") - .values - .first as LelantusCoin; - expect(lcoin.index, 1); - expect(lcoin.value, 9658); - expect(lcoin.publicCoin, - "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); - expect(lcoin.txId, - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); - expect(lcoin.anonymitySetId, 1); - expect(lcoin.isUsed, true); - - final jIndex = await wallet.get('jindex'); - expect(jIndex, [2, 4, 6]); - - final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); - expect(lelantusTxModel.getAllTransactions().length, 5); - }, timeout: const Timeout(Duration(minutes: 5))); - - test("fullRescan succeeds", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); - - await secureStore.write( - key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); - - // mock electrumx client calls - when(client.getLatestCoinId()).thenAnswer((_) async => 1); - // when(client.getCoinsForRecovery(setId: 1)) - // .thenAnswer((_) async => getCoinsForRecoveryResponse); - when(client.getUsedCoinSerials(startNumber: 0)) - .thenAnswer((_) async => GetUsedSerialsSampleData.serials); - - when(cachedClient.getAnonymitySet( - groupId: "1", blockhash: "", coin: Coin.firo)) - .thenAnswer((_) async => GetAnonymitySetSampleData.data); - when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) - .thenAnswer( - (_) async => GetUsedSerialsSampleData.serials['serials'] as List); - - when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) - .thenAnswer((_) async => {}); - - final firo = FiroWallet( - walletName: testWalletName, - walletId: "${testWalletId}fullRescan", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: MockTransactionNotificationTracker(), - ); - - // pre grab derivations in order to set up mock calls needed later on - await firo.fillAddresses(TEST_MNEMONIC); - final wallet = await Hive.openBox("${testWalletId}fullRescan"); - - final rcv = await secureStore.read( - key: "${testWalletId}fullRescan_receiveDerivations"); - final chg = await secureStore.read( - key: "${testWalletId}fullRescan_changeDerivations"); - final receiveDerivations = - Map.from(jsonDecode(rcv as String) as Map); - final changeDerivations = - Map.from(jsonDecode(chg as String) as Map); - - for (int i = 0; i < receiveDerivations.length; i++) { - final receiveHash = AddressUtils.convertToScriptHash( - receiveDerivations["$i"]!["address"] as String, firoNetwork); - final changeHash = AddressUtils.convertToScriptHash( - changeDerivations["$i"]!["address"] as String, firoNetwork); - List> data; - switch (receiveHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - when(client.getHistory(scripthash: receiveHash)) - .thenAnswer((_) async => data); - - switch (changeHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - - when(client.getHistory(scripthash: changeHash)) - .thenAnswer((_) async => data); - } - - when(client.getBatchHistory(args: { - "0": [SampleGetHistoryData.scripthash0], - "1": [SampleGetHistoryData.scripthash3] - })).thenAnswer((realInvocation) async => { - "0": SampleGetHistoryData.data0, - "1": SampleGetHistoryData.data3, - }); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash7, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData7); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash8, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData8); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash9, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData9); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash10, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData10); - - await firo.fullRescan(20, 1000); - - final receivingAddresses = await wallet.get('receivingAddresses'); - expect(receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); - - final changeAddresses = await wallet.get('changeAddresses'); - expect(changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); - - final receivingIndex = await wallet.get('receivingIndex'); - expect(receivingIndex, 0); - - final changeIndex = await wallet.get('changeIndex'); - expect(changeIndex, 0); - - final _rcv = await secureStore.read( - key: "${testWalletId}fullRescan_receiveDerivations"); - final _chg = await secureStore.read( - key: "${testWalletId}fullRescan_changeDerivations"); - final _receiveDerivations = - Map.from(jsonDecode(_rcv as String) as Map); - final _changeDerivations = - Map.from(jsonDecode(_chg as String) as Map); - // expect(_receiveDerivations.length, 150); - // expect(_changeDerivations.length, 150); - expect(_receiveDerivations.length, 40); - expect(_changeDerivations.length, 40); - - final mintIndex = await wallet.get('mintIndex'); - expect(mintIndex, 8); - - final lelantusCoins = await wallet.get('_lelantus_coins') as List; - expect(lelantusCoins.length, 7); - final lcoin = lelantusCoins - .firstWhere((element) => - (Map.from(element as Map)) - .values - .first - .txId == - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") - .values - .first as LelantusCoin; - expect(lcoin.index, 1); - expect(lcoin.value, 9658); - expect(lcoin.publicCoin, - "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); - expect(lcoin.txId, - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); - expect(lcoin.anonymitySetId, 1); - expect(lcoin.isUsed, true); - - final jIndex = await wallet.get('jindex'); - expect(jIndex, [2, 4, 6]); - - final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); - expect(lelantusTxModel.getAllTransactions().length, 5); - }, timeout: const Timeout(Duration(minutes: 3))); - - test("fullRescan fails", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); - - await secureStore.write( - key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); - - // mock electrumx client calls - when(client.getLatestCoinId()).thenAnswer((_) async => 1); - // when(client.getCoinsForRecovery(setId: 1)) - // .thenAnswer((_) async => getCoinsForRecoveryResponse); - when(client.getUsedCoinSerials(startNumber: 0)) - .thenAnswer((_) async => GetUsedSerialsSampleData.serials); - - when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) - .thenAnswer((_) async => {}); - - final firo = FiroWallet( - walletName: testWalletName, - walletId: "${testWalletId}fullRescan", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: MockTransactionNotificationTracker(), - ); - - // pre grab derivations in order to set up mock calls needed later on - await firo.fillAddresses(TEST_MNEMONIC); - final wallet = await Hive.openBox("${testWalletId}fullRescan"); - - final rcv = await secureStore.read( - key: "${testWalletId}fullRescan_receiveDerivations"); - final chg = await secureStore.read( - key: "${testWalletId}fullRescan_changeDerivations"); - final receiveDerivations = - Map.from(jsonDecode(rcv as String) as Map); - final changeDerivations = - Map.from(jsonDecode(chg as String) as Map); - - for (int i = 0; i < receiveDerivations.length; i++) { - final receiveHash = AddressUtils.convertToScriptHash( - receiveDerivations["$i"]!["address"] as String, firoNetwork); - final changeHash = AddressUtils.convertToScriptHash( - changeDerivations["$i"]!["address"] as String, firoNetwork); - List> data; - switch (receiveHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - when(client.getHistory(scripthash: receiveHash)) - .thenAnswer((_) async => data); - - switch (changeHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - - when(client.getHistory(scripthash: changeHash)) - .thenAnswer((_) async => data); - } - - when(client.getLatestCoinId()).thenThrow(Exception()); - - bool didThrow = false; - try { - await firo.fullRescan(20, 1000); - } catch (e) { - didThrow = true; - } - expect(didThrow, true); - - final receivingAddresses = await wallet.get('receivingAddresses'); - expect(receivingAddresses, null); - - final changeAddresses = await wallet.get('changeAddresses'); - expect(changeAddresses, null); - - final receivingIndex = await wallet.get('receivingIndex'); - expect(receivingIndex, null); - - final changeIndex = await wallet.get('changeIndex'); - expect(changeIndex, null); - - final _rcv = await secureStore.read( - key: "${testWalletId}fullRescan_receiveDerivations"); - final _chg = await secureStore.read( - key: "${testWalletId}fullRescan_changeDerivations"); - final _receiveDerivations = - Map.from(jsonDecode(_rcv as String) as Map); - final _changeDerivations = - Map.from(jsonDecode(_chg as String) as Map); - - expect(_receiveDerivations.length, 40); - expect(_changeDerivations.length, 40); - - final mintIndex = await wallet.get('mintIndex'); - expect(mintIndex, null); - - final lelantusCoins = await wallet.get('_lelantus_coins'); - expect(lelantusCoins, null); - - final jIndex = await wallet.get('jindex'); - expect(jIndex, null); - - final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); - expect(lelantusTxModel, null); - }, timeout: const Timeout(Duration(minutes: 3))); - - test("recoverFromMnemonic then fullRescan", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); - - // mock electrumx client calls - when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client.getLatestCoinId()).thenAnswer((_) async => 1); - // when(client.getCoinsForRecovery(setId: 1)) - // .thenAnswer((_) async => getCoinsForRecoveryResponse); - when(client.getUsedCoinSerials(startNumber: 0)) - .thenAnswer((_) async => GetUsedSerialsSampleData.serials); - - when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) - .thenAnswer((_) async => {}); - - when(cachedClient.getAnonymitySet( - groupId: "1", blockhash: "", coin: Coin.firo)) - .thenAnswer((_) async => GetAnonymitySetSampleData.data); - when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) - .thenAnswer( - (_) async => GetUsedSerialsSampleData.serials['serials'] as List); - - final firo = FiroWallet( - walletName: testWalletName, - walletId: "${testWalletId}recoverFromMnemonic", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: MockTransactionNotificationTracker(), - ); - - // pre grab derivations in order to set up mock calls needed later on - await firo.fillAddresses(TEST_MNEMONIC); - final wallet = - await Hive.openBox("${testWalletId}recoverFromMnemonic"); - - final rcv = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); - final chg = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_changeDerivations"); - final receiveDerivations = - Map.from(jsonDecode(rcv as String) as Map); - final changeDerivations = - Map.from(jsonDecode(chg as String) as Map); - - for (int i = 0; i < receiveDerivations.length; i++) { - final receiveHash = AddressUtils.convertToScriptHash( - receiveDerivations["$i"]!["address"] as String, firoNetwork); - final changeHash = AddressUtils.convertToScriptHash( - changeDerivations["$i"]!["address"] as String, firoNetwork); - List> data; - switch (receiveHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - when(client.getHistory(scripthash: receiveHash)) - .thenAnswer((_) async => data); - - switch (changeHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - - when(client.getHistory(scripthash: changeHash)) - .thenAnswer((_) async => data); - } - - when(client.getBatchHistory(args: { - "0": [SampleGetHistoryData.scripthash0], - "1": [SampleGetHistoryData.scripthash3] - })).thenAnswer((realInvocation) async => { - "0": SampleGetHistoryData.data0, - "1": SampleGetHistoryData.data3, - }); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash7, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData7); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash8, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData8); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash9, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData9); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash10, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData10); - - await firo.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 20, - maxNumberOfIndexesToCheck: 1000, - height: 0); - - final receivingAddresses = await wallet.get('receivingAddresses'); - expect(receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); - - final changeAddresses = await wallet.get('changeAddresses'); - expect(changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); - - final receivingIndex = await wallet.get('receivingIndex'); - expect(receivingIndex, 0); - - final changeIndex = await wallet.get('changeIndex'); - expect(changeIndex, 0); - - final _rcv = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); - final _chg = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_changeDerivations"); - final _receiveDerivations = - Map.from(jsonDecode(_rcv as String) as Map); - final _changeDerivations = - Map.from(jsonDecode(_chg as String) as Map); - // expect(_receiveDerivations.length, 190); - // expect(_changeDerivations.length, 190); - expect(_receiveDerivations.length, 80); - expect(_changeDerivations.length, 80); - - final mintIndex = await wallet.get('mintIndex'); - expect(mintIndex, 8); - - final lelantusCoins = await wallet.get('_lelantus_coins') as List; - expect(lelantusCoins.length, 7); - final lcoin = lelantusCoins - .firstWhere((element) => - (Map.from(element as Map)) - .values - .first - .txId == - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") - .values - .first as LelantusCoin; - expect(lcoin.index, 1); - expect(lcoin.value, 9658); - expect(lcoin.publicCoin, - "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); - expect(lcoin.txId, - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); - expect(lcoin.anonymitySetId, 1); - expect(lcoin.isUsed, true); - - final jIndex = await wallet.get('jindex'); - expect(jIndex, [2, 4, 6]); - - final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); - expect(lelantusTxModel.getAllTransactions().length, 5); - - await firo.fullRescan(20, 1000); - - final _receivingAddresses = await wallet.get('receivingAddresses'); - expect(_receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); - - final _changeAddresses = await wallet.get('changeAddresses'); - expect(_changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); - - final _receivingIndex = await wallet.get('receivingIndex'); - expect(_receivingIndex, 0); - - final _changeIndex = await wallet.get('changeIndex'); - expect(_changeIndex, 0); - - final __rcv = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); - final __chg = await secureStore.read( - key: "${testWalletId}recoverFromMnemonic_changeDerivations"); - final __receiveDerivations = - Map.from(jsonDecode(__rcv as String) as Map); - final __changeDerivations = - Map.from(jsonDecode(__chg as String) as Map); - // expect(__receiveDerivations.length, 150); - // expect(__changeDerivations.length, 150); - expect(__receiveDerivations.length, 40); - expect(__changeDerivations.length, 40); - - final _mintIndex = await wallet.get('mintIndex'); - expect(_mintIndex, 8); - - final _lelantusCoins = await wallet.get('_lelantus_coins') as List; - expect(_lelantusCoins.length, 7); - final _lcoin = _lelantusCoins - .firstWhere((element) => - (Map.from(element as Map)) - .values - .first - .txId == - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") - .values - .first as LelantusCoin; - expect(_lcoin.index, 1); - expect(_lcoin.value, 9658); - expect(_lcoin.publicCoin, - "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); - expect(_lcoin.txId, - "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); - expect(_lcoin.anonymitySetId, 1); - expect(_lcoin.isUsed, true); - - final _jIndex = await wallet.get('jindex'); - expect(_jIndex, [2, 4, 6]); - - final _lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); - expect(_lelantusTxModel.getAllTransactions().length, 5); - }, timeout: const Timeout(Duration(minutes: 6))); + // test("recoverFromMnemonic succeeds", () async { + // TestWidgetsFlutterBinding.ensureInitialized(); + // const MethodChannel('uk.spiralarm.flutter/devicelocale') + // .setMockMethodCallHandler((methodCall) async => 'en_US'); + // + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // final secureStore = FakeSecureStorage(); + // + // // mock electrumx client calls + // when(client.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client.getLatestCoinId()).thenAnswer((_) async => 1); + // when(cachedClient.getUsedCoinSerials( + // coin: Coin.firo, + // )).thenAnswer( + // (_) async => GetUsedSerialsSampleData.serials["serials"] as List); + // + // when(cachedClient.getAnonymitySet( + // groupId: "1", + // coin: Coin.firo, + // )).thenAnswer( + // (_) async => GetAnonymitySetSampleData.data, + // ); + // + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash0, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData0; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash1, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData1; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash2, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData2; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash3, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData3; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash4, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData4; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash5, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData5; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash6, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData6; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash8, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData8; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash9, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData9; + // }); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash7, + // coin: Coin.firo, + // )).thenAnswer((_) async { + // return SampleGetTransactionData.txData7; + // }); + // + // final firo = FiroWallet( + // walletName: testWalletName, + // walletId: "${testWalletId}recoverFromMnemonic", + // coin: Coin.firo, + // client: client, + // cachedClient: cachedClient, + // secureStore: secureStore, + // tracker: MockTransactionNotificationTracker(), + // ); + // + // // pre grab derivations in order to set up mock calls needed later on + // await firo.fillAddresses(TEST_MNEMONIC); + // final wallet = + // await Hive.openBox("${testWalletId}recoverFromMnemonic"); + // + // final rcv = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); + // final chg = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_changeDerivations"); + // final receiveDerivations = + // Map.from(jsonDecode(rcv as String) as Map); + // final changeDerivations = + // Map.from(jsonDecode(chg as String) as Map); + // + // for (int i = 0; i < receiveDerivations.length; i++) { + // final receiveHash = AddressUtils.convertToScriptHash( + // receiveDerivations["$i"]!["address"] as String, firoNetwork); + // final changeHash = AddressUtils.convertToScriptHash( + // changeDerivations["$i"]!["address"] as String, firoNetwork); + // List> data; + // switch (receiveHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // when(client.getHistory(scripthash: receiveHash)) + // .thenAnswer((_) async => data); + // + // switch (changeHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // + // when(client.getHistory(scripthash: changeHash)) + // .thenAnswer((_) async => data); + // } + // + // when(client.getBatchHistory(args: { + // "0": [SampleGetHistoryData.scripthash0], + // "1": [SampleGetHistoryData.scripthash3] + // })).thenAnswer((realInvocation) async => { + // "0": SampleGetHistoryData.data0, + // "1": SampleGetHistoryData.data3, + // }); + // + // await firo.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 20, + // height: 0, + // maxNumberOfIndexesToCheck: 1000); + // + // final receivingAddresses = await wallet.get('receivingAddresses'); + // expect(receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); + // + // final changeAddresses = await wallet.get('changeAddresses'); + // expect(changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); + // + // final receivingIndex = await wallet.get('receivingIndex'); + // expect(receivingIndex, 0); + // + // final changeIndex = await wallet.get('changeIndex'); + // expect(changeIndex, 0); + // + // final _rcv = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); + // final _chg = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_changeDerivations"); + // final _receiveDerivations = + // Map.from(jsonDecode(_rcv as String) as Map); + // final _changeDerivations = + // Map.from(jsonDecode(_chg as String) as Map); + // // expect(_receiveDerivations.length, 190); + // // expect(_changeDerivations.length, 190); + // expect(_receiveDerivations.length, 80); + // expect(_changeDerivations.length, 80); + // + // final mintIndex = await wallet.get('mintIndex'); + // expect(mintIndex, 8); + // + // final lelantusCoins = await wallet.get('_lelantus_coins') as List; + // expect(lelantusCoins.length, 7); + // final lcoin = lelantusCoins + // .firstWhere((element) => + // (Map.from(element as Map)) + // .values + // .first + // .txId == + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") + // .values + // .first as LelantusCoin; + // expect(lcoin.index, 1); + // expect(lcoin.value, 9658); + // expect(lcoin.publicCoin, + // "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); + // expect(lcoin.txId, + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); + // expect(lcoin.anonymitySetId, 1); + // expect(lcoin.isUsed, true); + // + // final jIndex = await wallet.get('jindex'); + // expect(jIndex, [2, 4, 6]); + // + // final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); + // expect(lelantusTxModel.getAllTransactions().length, 5); + // }, timeout: const Timeout(Duration(minutes: 5))); + // + // test("fullRescan succeeds", () async { + // TestWidgetsFlutterBinding.ensureInitialized(); + // const MethodChannel('uk.spiralarm.flutter/devicelocale') + // .setMockMethodCallHandler((methodCall) async => 'en_US'); + // + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // final secureStore = FakeSecureStorage(); + // + // await secureStore.write( + // key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); + // + // // mock electrumx client calls + // when(client.getLatestCoinId()).thenAnswer((_) async => 1); + // // when(client.getCoinsForRecovery(setId: 1)) + // // .thenAnswer((_) async => getCoinsForRecoveryResponse); + // when(client.getUsedCoinSerials(startNumber: 0)) + // .thenAnswer((_) async => GetUsedSerialsSampleData.serials); + // + // when(cachedClient.getAnonymitySet( + // groupId: "1", blockhash: "", coin: Coin.firo)) + // .thenAnswer((_) async => GetAnonymitySetSampleData.data); + // when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) + // .thenAnswer( + // (_) async => GetUsedSerialsSampleData.serials['serials'] as List); + // + // when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) + // .thenAnswer((_) async => {}); + // + // final firo = FiroWallet( + // walletName: testWalletName, + // walletId: "${testWalletId}fullRescan", + // coin: Coin.firo, + // client: client, + // cachedClient: cachedClient, + // secureStore: secureStore, + // tracker: MockTransactionNotificationTracker(), + // ); + // + // // pre grab derivations in order to set up mock calls needed later on + // await firo.fillAddresses(TEST_MNEMONIC); + // final wallet = await Hive.openBox("${testWalletId}fullRescan"); + // + // final rcv = await secureStore.read( + // key: "${testWalletId}fullRescan_receiveDerivations"); + // final chg = await secureStore.read( + // key: "${testWalletId}fullRescan_changeDerivations"); + // final receiveDerivations = + // Map.from(jsonDecode(rcv as String) as Map); + // final changeDerivations = + // Map.from(jsonDecode(chg as String) as Map); + // + // for (int i = 0; i < receiveDerivations.length; i++) { + // final receiveHash = AddressUtils.convertToScriptHash( + // receiveDerivations["$i"]!["address"] as String, firoNetwork); + // final changeHash = AddressUtils.convertToScriptHash( + // changeDerivations["$i"]!["address"] as String, firoNetwork); + // List> data; + // switch (receiveHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // when(client.getHistory(scripthash: receiveHash)) + // .thenAnswer((_) async => data); + // + // switch (changeHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // + // when(client.getHistory(scripthash: changeHash)) + // .thenAnswer((_) async => data); + // } + // + // when(client.getBatchHistory(args: { + // "0": [SampleGetHistoryData.scripthash0], + // "1": [SampleGetHistoryData.scripthash3] + // })).thenAnswer((realInvocation) async => { + // "0": SampleGetHistoryData.data0, + // "1": SampleGetHistoryData.data3, + // }); + // + // // mock transaction calls + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash0, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData0); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash1, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData1); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash2, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData2); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash3, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData3); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash4, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData4); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash5, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData5); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash6, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData6); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash7, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData7); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash8, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData8); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash9, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData9); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash10, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData10); + // + // await firo.fullRescan(20, 1000); + // + // final receivingAddresses = await wallet.get('receivingAddresses'); + // expect(receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); + // + // final changeAddresses = await wallet.get('changeAddresses'); + // expect(changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); + // + // final receivingIndex = await wallet.get('receivingIndex'); + // expect(receivingIndex, 0); + // + // final changeIndex = await wallet.get('changeIndex'); + // expect(changeIndex, 0); + // + // final _rcv = await secureStore.read( + // key: "${testWalletId}fullRescan_receiveDerivations"); + // final _chg = await secureStore.read( + // key: "${testWalletId}fullRescan_changeDerivations"); + // final _receiveDerivations = + // Map.from(jsonDecode(_rcv as String) as Map); + // final _changeDerivations = + // Map.from(jsonDecode(_chg as String) as Map); + // // expect(_receiveDerivations.length, 150); + // // expect(_changeDerivations.length, 150); + // expect(_receiveDerivations.length, 40); + // expect(_changeDerivations.length, 40); + // + // final mintIndex = await wallet.get('mintIndex'); + // expect(mintIndex, 8); + // + // final lelantusCoins = await wallet.get('_lelantus_coins') as List; + // expect(lelantusCoins.length, 7); + // final lcoin = lelantusCoins + // .firstWhere((element) => + // (Map.from(element as Map)) + // .values + // .first + // .txId == + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") + // .values + // .first as LelantusCoin; + // expect(lcoin.index, 1); + // expect(lcoin.value, 9658); + // expect(lcoin.publicCoin, + // "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); + // expect(lcoin.txId, + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); + // expect(lcoin.anonymitySetId, 1); + // expect(lcoin.isUsed, true); + // + // final jIndex = await wallet.get('jindex'); + // expect(jIndex, [2, 4, 6]); + // + // final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); + // expect(lelantusTxModel.getAllTransactions().length, 5); + // }, timeout: const Timeout(Duration(minutes: 3))); + // + // test("fullRescan fails", () async { + // TestWidgetsFlutterBinding.ensureInitialized(); + // const MethodChannel('uk.spiralarm.flutter/devicelocale') + // .setMockMethodCallHandler((methodCall) async => 'en_US'); + // + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // final secureStore = FakeSecureStorage(); + // + // await secureStore.write( + // key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); + // + // // mock electrumx client calls + // when(client.getLatestCoinId()).thenAnswer((_) async => 1); + // // when(client.getCoinsForRecovery(setId: 1)) + // // .thenAnswer((_) async => getCoinsForRecoveryResponse); + // when(client.getUsedCoinSerials(startNumber: 0)) + // .thenAnswer((_) async => GetUsedSerialsSampleData.serials); + // + // when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) + // .thenAnswer((_) async => {}); + // + // final firo = FiroWallet( + // walletName: testWalletName, + // walletId: "${testWalletId}fullRescan", + // coin: Coin.firo, + // client: client, + // cachedClient: cachedClient, + // secureStore: secureStore, + // tracker: MockTransactionNotificationTracker(), + // ); + // + // // pre grab derivations in order to set up mock calls needed later on + // await firo.fillAddresses(TEST_MNEMONIC); + // final wallet = await Hive.openBox("${testWalletId}fullRescan"); + // + // final rcv = await secureStore.read( + // key: "${testWalletId}fullRescan_receiveDerivations"); + // final chg = await secureStore.read( + // key: "${testWalletId}fullRescan_changeDerivations"); + // final receiveDerivations = + // Map.from(jsonDecode(rcv as String) as Map); + // final changeDerivations = + // Map.from(jsonDecode(chg as String) as Map); + // + // for (int i = 0; i < receiveDerivations.length; i++) { + // final receiveHash = AddressUtils.convertToScriptHash( + // receiveDerivations["$i"]!["address"] as String, firoNetwork); + // final changeHash = AddressUtils.convertToScriptHash( + // changeDerivations["$i"]!["address"] as String, firoNetwork); + // List> data; + // switch (receiveHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // when(client.getHistory(scripthash: receiveHash)) + // .thenAnswer((_) async => data); + // + // switch (changeHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // + // when(client.getHistory(scripthash: changeHash)) + // .thenAnswer((_) async => data); + // } + // + // when(client.getLatestCoinId()).thenThrow(Exception()); + // + // bool didThrow = false; + // try { + // await firo.fullRescan(20, 1000); + // } catch (e) { + // didThrow = true; + // } + // expect(didThrow, true); + // + // final receivingAddresses = await wallet.get('receivingAddresses'); + // expect(receivingAddresses, null); + // + // final changeAddresses = await wallet.get('changeAddresses'); + // expect(changeAddresses, null); + // + // final receivingIndex = await wallet.get('receivingIndex'); + // expect(receivingIndex, null); + // + // final changeIndex = await wallet.get('changeIndex'); + // expect(changeIndex, null); + // + // final _rcv = await secureStore.read( + // key: "${testWalletId}fullRescan_receiveDerivations"); + // final _chg = await secureStore.read( + // key: "${testWalletId}fullRescan_changeDerivations"); + // final _receiveDerivations = + // Map.from(jsonDecode(_rcv as String) as Map); + // final _changeDerivations = + // Map.from(jsonDecode(_chg as String) as Map); + // + // expect(_receiveDerivations.length, 40); + // expect(_changeDerivations.length, 40); + // + // final mintIndex = await wallet.get('mintIndex'); + // expect(mintIndex, null); + // + // final lelantusCoins = await wallet.get('_lelantus_coins'); + // expect(lelantusCoins, null); + // + // final jIndex = await wallet.get('jindex'); + // expect(jIndex, null); + // + // final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); + // expect(lelantusTxModel, null); + // }, timeout: const Timeout(Duration(minutes: 3))); + // + // test("recoverFromMnemonic then fullRescan", () async { + // TestWidgetsFlutterBinding.ensureInitialized(); + // const MethodChannel('uk.spiralarm.flutter/devicelocale') + // .setMockMethodCallHandler((methodCall) async => 'en_US'); + // + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // final secureStore = FakeSecureStorage(); + // + // // mock electrumx client calls + // when(client.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client.getLatestCoinId()).thenAnswer((_) async => 1); + // // when(client.getCoinsForRecovery(setId: 1)) + // // .thenAnswer((_) async => getCoinsForRecoveryResponse); + // when(client.getUsedCoinSerials(startNumber: 0)) + // .thenAnswer((_) async => GetUsedSerialsSampleData.serials); + // + // when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) + // .thenAnswer((_) async => {}); + // + // when(cachedClient.getAnonymitySet( + // groupId: "1", blockhash: "", coin: Coin.firo)) + // .thenAnswer((_) async => GetAnonymitySetSampleData.data); + // when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) + // .thenAnswer( + // (_) async => GetUsedSerialsSampleData.serials['serials'] as List); + // + // final firo = FiroWallet( + // walletName: testWalletName, + // walletId: "${testWalletId}recoverFromMnemonic", + // coin: Coin.firo, + // client: client, + // cachedClient: cachedClient, + // secureStore: secureStore, + // tracker: MockTransactionNotificationTracker(), + // ); + // + // // pre grab derivations in order to set up mock calls needed later on + // await firo.fillAddresses(TEST_MNEMONIC); + // final wallet = + // await Hive.openBox("${testWalletId}recoverFromMnemonic"); + // + // final rcv = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); + // final chg = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_changeDerivations"); + // final receiveDerivations = + // Map.from(jsonDecode(rcv as String) as Map); + // final changeDerivations = + // Map.from(jsonDecode(chg as String) as Map); + // + // for (int i = 0; i < receiveDerivations.length; i++) { + // final receiveHash = AddressUtils.convertToScriptHash( + // receiveDerivations["$i"]!["address"] as String, firoNetwork); + // final changeHash = AddressUtils.convertToScriptHash( + // changeDerivations["$i"]!["address"] as String, firoNetwork); + // List> data; + // switch (receiveHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // when(client.getHistory(scripthash: receiveHash)) + // .thenAnswer((_) async => data); + // + // switch (changeHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // + // when(client.getHistory(scripthash: changeHash)) + // .thenAnswer((_) async => data); + // } + // + // when(client.getBatchHistory(args: { + // "0": [SampleGetHistoryData.scripthash0], + // "1": [SampleGetHistoryData.scripthash3] + // })).thenAnswer((realInvocation) async => { + // "0": SampleGetHistoryData.data0, + // "1": SampleGetHistoryData.data3, + // }); + // + // // mock transaction calls + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash0, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData0); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash1, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData1); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash2, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData2); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash3, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData3); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash4, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData4); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash5, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData5); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash6, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData6); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash7, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData7); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash8, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData8); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash9, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData9); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash10, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData10); + // + // await firo.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 20, + // maxNumberOfIndexesToCheck: 1000, + // height: 0); + // + // final receivingAddresses = await wallet.get('receivingAddresses'); + // expect(receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); + // + // final changeAddresses = await wallet.get('changeAddresses'); + // expect(changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); + // + // final receivingIndex = await wallet.get('receivingIndex'); + // expect(receivingIndex, 0); + // + // final changeIndex = await wallet.get('changeIndex'); + // expect(changeIndex, 0); + // + // final _rcv = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); + // final _chg = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_changeDerivations"); + // final _receiveDerivations = + // Map.from(jsonDecode(_rcv as String) as Map); + // final _changeDerivations = + // Map.from(jsonDecode(_chg as String) as Map); + // // expect(_receiveDerivations.length, 190); + // // expect(_changeDerivations.length, 190); + // expect(_receiveDerivations.length, 80); + // expect(_changeDerivations.length, 80); + // + // final mintIndex = await wallet.get('mintIndex'); + // expect(mintIndex, 8); + // + // final lelantusCoins = await wallet.get('_lelantus_coins') as List; + // expect(lelantusCoins.length, 7); + // final lcoin = lelantusCoins + // .firstWhere((element) => + // (Map.from(element as Map)) + // .values + // .first + // .txId == + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") + // .values + // .first as LelantusCoin; + // expect(lcoin.index, 1); + // expect(lcoin.value, 9658); + // expect(lcoin.publicCoin, + // "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); + // expect(lcoin.txId, + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); + // expect(lcoin.anonymitySetId, 1); + // expect(lcoin.isUsed, true); + // + // final jIndex = await wallet.get('jindex'); + // expect(jIndex, [2, 4, 6]); + // + // final lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); + // expect(lelantusTxModel.getAllTransactions().length, 5); + // + // await firo.fullRescan(20, 1000); + // + // final _receivingAddresses = await wallet.get('receivingAddresses'); + // expect(_receivingAddresses, ["a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg"]); + // + // final _changeAddresses = await wallet.get('changeAddresses'); + // expect(_changeAddresses, ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); + // + // final _receivingIndex = await wallet.get('receivingIndex'); + // expect(_receivingIndex, 0); + // + // final _changeIndex = await wallet.get('changeIndex'); + // expect(_changeIndex, 0); + // + // final __rcv = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_receiveDerivations"); + // final __chg = await secureStore.read( + // key: "${testWalletId}recoverFromMnemonic_changeDerivations"); + // final __receiveDerivations = + // Map.from(jsonDecode(__rcv as String) as Map); + // final __changeDerivations = + // Map.from(jsonDecode(__chg as String) as Map); + // // expect(__receiveDerivations.length, 150); + // // expect(__changeDerivations.length, 150); + // expect(__receiveDerivations.length, 40); + // expect(__changeDerivations.length, 40); + // + // final _mintIndex = await wallet.get('mintIndex'); + // expect(_mintIndex, 8); + // + // final _lelantusCoins = await wallet.get('_lelantus_coins') as List; + // expect(_lelantusCoins.length, 7); + // final _lcoin = _lelantusCoins + // .firstWhere((element) => + // (Map.from(element as Map)) + // .values + // .first + // .txId == + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232") + // .values + // .first as LelantusCoin; + // expect(_lcoin.index, 1); + // expect(_lcoin.value, 9658); + // expect(_lcoin.publicCoin, + // "7fd927efbea0a9e4ba299209aaee610c63359857596be0a2da276011a0baa84a0000"); + // expect(_lcoin.txId, + // "36c92daa4005d368e28cea917fdb2c1e7069319a4a79fb2ff45c089100680232"); + // expect(_lcoin.anonymitySetId, 1); + // expect(_lcoin.isUsed, true); + // + // final _jIndex = await wallet.get('jindex'); + // expect(_jIndex, [2, 4, 6]); + // + // final _lelantusTxModel = await wallet.get('latest_lelantus_tx_model'); + // expect(_lelantusTxModel.getAllTransactions().length, 5); + // }, timeout: const Timeout(Duration(minutes: 6))); test("recoverFromMnemonic fails testnet", () async { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { @@ -2178,7 +2155,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2195,7 +2171,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); // mock electrumx client calls when(client.getServerFeatures()).thenAnswer((_) async => { @@ -2216,7 +2191,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2249,42 +2223,40 @@ void main() { expect(didThrow, true); }); - test("checkReceivingAddressForTransactions numtxs >= 1", () async { - final client = MockElectrumX(); - final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); - - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) - .thenAnswer((_) async => SampleGetHistoryData.data1); - - final firo = FiroWallet( - walletId: - "${testWalletId}checkReceivingAddressForTransactions numtxs >= 1", - walletName: testWalletName, - coin: Coin.firo, - client: client, - cachedClient: MockCachedElectrumX(), - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: MockTransactionNotificationTracker(), - ); - - final wallet = await Hive.openBox( - "${testWalletId}checkReceivingAddressForTransactions numtxs >= 1"); - await secureStore.write( - key: - "${testWalletId}checkReceivingAddressForTransactions numtxs >= 1_mnemonic", - value: TEST_MNEMONIC); - await wallet - .put("receivingAddresses", ["aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh"]); - - await wallet.put("receivingIndex", 1); - - await firo.checkReceivingAddressForTransactions(); - - expect(await wallet.get("receivingIndex"), 2); - expect((await wallet.get("receivingAddresses")).length, 2); - }); + // test("checkReceivingAddressForTransactions numtxs >= 1", () async { + // final client = MockElectrumX(); + // final secureStore = FakeSecureStorage(); + // + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) + // .thenAnswer((_) async => SampleGetHistoryData.data1); + // + // final firo = FiroWallet( + // walletId: + // "${testWalletId}checkReceivingAddressForTransactions numtxs >= 1", + // walletName: testWalletName, + // coin: Coin.firo, + // client: client, + // cachedClient: MockCachedElectrumX(), + // secureStore: secureStore, + // tracker: MockTransactionNotificationTracker(), + // ); + // + // final wallet = await Hive.openBox( + // "${testWalletId}checkReceivingAddressForTransactions numtxs >= 1"); + // await secureStore.write( + // key: + // "${testWalletId}checkReceivingAddressForTransactions numtxs >= 1_mnemonic", + // value: TEST_MNEMONIC); + // await wallet + // .put("receivingAddresses", ["aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh"]); + // + // await wallet.put("receivingIndex", 1); + // + // await firo.checkReceivingAddressForTransactions(); + // + // expect(await wallet.get("receivingIndex"), 2); + // expect((await wallet.get("receivingAddresses")).length, 2); + // }); test("getLatestSetId", () async { final client = MockElectrumX(); @@ -2362,7 +2334,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); // set mnemonic await secureStore.write( @@ -2460,7 +2431,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -2570,7 +2540,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); @@ -2660,183 +2630,181 @@ void main() { // expect(result.length, 64); // }, timeout: const Timeout(Duration(minutes: 3))); - test("prepareSend fails due to insufficient balance", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); - - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); - - when(client.getLatestCoinId()).thenAnswer((_) async => 1); - when(client.getBlockHeadTip()).thenAnswer( - (_) async => {"height": 459185, "hex": "... some block hex ..."}); - - when(client.broadcastTransaction(rawTx: anyNamed("rawTx"))) - .thenAnswer((realInvocation) async { - final rawTx = - realInvocation.namedArguments[const Symbol("rawTx")] as String; - final rawTxData = Format.stringToUint8List(rawTx); - - final hash = sha256 - .convert(sha256.convert(rawTxData.toList(growable: false)).bytes); - - final reversedBytes = - Uint8List.fromList(hash.bytes.reversed.toList(growable: false)); - - final txid = Format.uint8listToString(reversedBytes); - return txid; - }); - when(client.getBatchHistory(args: batchHistoryRequest0)) - .thenAnswer((realInvocation) async => batchHistoryResponse0); - - when(cachedClient.getAnonymitySet( - groupId: "1", - coin: Coin.firo, - )).thenAnswer((_) async => GetAnonymitySetSampleData.data); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash7, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData7); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash8, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData8); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash9, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData9); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash10, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData10); - - final firo = FiroWallet( - walletId: "${testWalletId}send", - coin: Coin.firo, - walletName: testWalletName, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: MockTransactionNotificationTracker(), - ); - - // set mnemonic - await secureStore.write( - key: "${testWalletId}send_mnemonic", value: TEST_MNEMONIC); - - // set timer to non null so a periodic timer isn't created - firo.timer = Timer(const Duration(), () {}); - - // build sending wallet - await firo.fillAddresses(TEST_MNEMONIC); - final wallet = await Hive.openBox("${testWalletId}send"); - - final rcv = - await secureStore.read(key: "${testWalletId}send_receiveDerivations"); - final chg = - await secureStore.read(key: "${testWalletId}send_changeDerivations"); - final receiveDerivations = - Map.from(jsonDecode(rcv as String) as Map); - final changeDerivations = - Map.from(jsonDecode(chg as String) as Map); - - for (int i = 0; i < receiveDerivations.length; i++) { - final receiveHash = AddressUtils.convertToScriptHash( - receiveDerivations["$i"]!["address"] as String, firoNetwork); - final changeHash = AddressUtils.convertToScriptHash( - changeDerivations["$i"]!["address"] as String, firoNetwork); - List> data; - switch (receiveHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - when(client.getHistory(scripthash: receiveHash)) - .thenAnswer((_) async => data); - - switch (changeHash) { - case SampleGetHistoryData.scripthash0: - data = SampleGetHistoryData.data0; - break; - case SampleGetHistoryData.scripthash1: - data = SampleGetHistoryData.data1; - break; - case SampleGetHistoryData.scripthash2: - data = SampleGetHistoryData.data2; - break; - case SampleGetHistoryData.scripthash3: - data = SampleGetHistoryData.data3; - break; - default: - data = []; - } - - when(client.getHistory(scripthash: changeHash)) - .thenAnswer((_) async => data); - } - - await wallet.put('_lelantus_coins', []); - await wallet.put('jindex', []); - await wallet.put('mintIndex', 0); - await wallet.put('receivingAddresses', [ - "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", - "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", - "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq" - ]); - await wallet - .put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); - - expect( - () async => await firo.prepareSend( - address: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV", - satoshiAmount: 100), - throwsA(isA())); - }, timeout: const Timeout(Duration(minutes: 3))); + // test("prepareSend fails due to insufficient balance", () async { + // TestWidgetsFlutterBinding.ensureInitialized(); + // const MethodChannel('uk.spiralarm.flutter/devicelocale') + // .setMockMethodCallHandler((methodCall) async => 'en_US'); + // + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // final secureStore = FakeSecureStorage(); + // + // when(client.getLatestCoinId()).thenAnswer((_) async => 1); + // when(client.getBlockHeadTip()).thenAnswer( + // (_) async => {"height": 459185, "hex": "... some block hex ..."}); + // + // when(client.broadcastTransaction(rawTx: anyNamed("rawTx"))) + // .thenAnswer((realInvocation) async { + // final rawTx = + // realInvocation.namedArguments[const Symbol("rawTx")] as String; + // final rawTxData = Format.stringToUint8List(rawTx); + // + // final hash = sha256 + // .convert(sha256.convert(rawTxData.toList(growable: false)).bytes); + // + // final reversedBytes = + // Uint8List.fromList(hash.bytes.reversed.toList(growable: false)); + // + // final txid = Format.uint8listToString(reversedBytes); + // return txid; + // }); + // when(client.getBatchHistory(args: batchHistoryRequest0)) + // .thenAnswer((realInvocation) async => batchHistoryResponse0); + // + // when(cachedClient.getAnonymitySet( + // groupId: "1", + // coin: Coin.firo, + // )).thenAnswer((_) async => GetAnonymitySetSampleData.data); + // + // // mock transaction calls + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash0, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData0); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash1, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData1); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash2, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData2); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash3, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData3); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash4, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData4); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash5, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData5); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash6, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData6); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash7, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData7); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash8, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData8); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash9, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData9); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash10, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData10); + // + // final firo = FiroWallet( + // walletId: "${testWalletId}send", + // coin: Coin.firo, + // walletName: testWalletName, + // client: client, + // cachedClient: cachedClient, + // secureStore: secureStore, + // tracker: MockTransactionNotificationTracker(), + // ); + // + // // set mnemonic + // await secureStore.write( + // key: "${testWalletId}send_mnemonic", value: TEST_MNEMONIC); + // + // // set timer to non null so a periodic timer isn't created + // firo.timer = Timer(const Duration(), () {}); + // + // // build sending wallet + // await firo.fillAddresses(TEST_MNEMONIC); + // final wallet = await Hive.openBox("${testWalletId}send"); + // + // final rcv = + // await secureStore.read(key: "${testWalletId}send_receiveDerivations"); + // final chg = + // await secureStore.read(key: "${testWalletId}send_changeDerivations"); + // final receiveDerivations = + // Map.from(jsonDecode(rcv as String) as Map); + // final changeDerivations = + // Map.from(jsonDecode(chg as String) as Map); + // + // for (int i = 0; i < receiveDerivations.length; i++) { + // final receiveHash = AddressUtils.convertToScriptHash( + // receiveDerivations["$i"]!["address"] as String, firoNetwork); + // final changeHash = AddressUtils.convertToScriptHash( + // changeDerivations["$i"]!["address"] as String, firoNetwork); + // List> data; + // switch (receiveHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // when(client.getHistory(scripthash: receiveHash)) + // .thenAnswer((_) async => data); + // + // switch (changeHash) { + // case SampleGetHistoryData.scripthash0: + // data = SampleGetHistoryData.data0; + // break; + // case SampleGetHistoryData.scripthash1: + // data = SampleGetHistoryData.data1; + // break; + // case SampleGetHistoryData.scripthash2: + // data = SampleGetHistoryData.data2; + // break; + // case SampleGetHistoryData.scripthash3: + // data = SampleGetHistoryData.data3; + // break; + // default: + // data = []; + // } + // + // when(client.getHistory(scripthash: changeHash)) + // .thenAnswer((_) async => data); + // } + // + // await wallet.put('_lelantus_coins', []); + // await wallet.put('jindex', []); + // await wallet.put('mintIndex', 0); + // await wallet.put('receivingAddresses', [ + // "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", + // "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", + // "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq" + // ]); + // await wallet + // .put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); + // + // expect( + // () async => await firo.prepareSend( + // address: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV", + // satoshiAmount: 100), + // throwsA(isA())); + // }, timeout: const Timeout(Duration(minutes: 3))); test("send fails due to bad transaction created", () async { TestWidgetsFlutterBinding.ensureInitialized(); @@ -2846,7 +2814,6 @@ void main() { final client = MockElectrumX(); final cachedClient = MockCachedElectrumX(); final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getBlockHeadTip()).thenAnswer( @@ -2918,7 +2885,6 @@ void main() { client: client, cachedClient: cachedClient, secureStore: secureStore, - mockableOverride: mockMainDB, tracker: MockTransactionNotificationTracker(), ); @@ -3000,194 +2966,192 @@ void main() { .put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); }, timeout: const Timeout(Duration(minutes: 3))); - test("wallet balances", () async { - TestWidgetsFlutterBinding.ensureInitialized(); - const MethodChannel('uk.spiralarm.flutter/devicelocale') - .setMockMethodCallHandler((methodCall) async => 'en_US'); + // test("wallet balances", () async { + // TestWidgetsFlutterBinding.ensureInitialized(); + // const MethodChannel('uk.spiralarm.flutter/devicelocale') + // .setMockMethodCallHandler((methodCall) async => 'en_US'); + // + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // + // // mock history calls + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) + // .thenAnswer((_) async => SampleGetHistoryData.data0); + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) + // .thenAnswer((_) async => SampleGetHistoryData.data1); + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2)) + // .thenAnswer((_) async => SampleGetHistoryData.data2); + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3)) + // .thenAnswer((_) async => SampleGetHistoryData.data3); + // + // when(client.getBatchHistory(args: batchHistoryRequest0)) + // .thenAnswer((realInvocation) async => batchHistoryResponse0); + // + // when(client.getBatchUTXOs(args: batchUtxoRequest)) + // .thenAnswer((realInvocation) async => {}); + // + // // mock transaction calls + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash0, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData0); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash1, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData1); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash2, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData2); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash3, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData3); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash4, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData4); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash5, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData5); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash6, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData6); + // + // final firo = FiroWallet( + // walletId: "${testWalletId}wallet balances", + // walletName: "pendingBalance wallet name", + // coin: Coin.firo, + // client: client, + // cachedClient: cachedClient, + // secureStore: FakeSecureStorage(), + // tracker: MockTransactionNotificationTracker(), + // ); + // + // final wallet = + // await Hive.openBox("${testWalletId}wallet balances"); + // await wallet.put('_lelantus_coins', SampleLelantus.lelantusCoins); + // await wallet.put('jindex', [2, 4, 6]); + // await wallet.put('mintIndex', 8); + // await wallet.put('receivingAddresses', [ + // "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", + // "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", + // "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq", + // ]); + // + // await wallet.put('changeAddresses', [ + // "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", + // ]); + // + // expect(firo.balance.getPending(), Decimal.zero); + // expect(firo.balance.getSpendable(), Decimal.parse("0.00021594")); + // expect(firo.balance.getTotal(), Decimal.parse("0.00021594")); + // }); - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - - // mock history calls - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) - .thenAnswer((_) async => SampleGetHistoryData.data0); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) - .thenAnswer((_) async => SampleGetHistoryData.data1); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2)) - .thenAnswer((_) async => SampleGetHistoryData.data2); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3)) - .thenAnswer((_) async => SampleGetHistoryData.data3); - - when(client.getBatchHistory(args: batchHistoryRequest0)) - .thenAnswer((realInvocation) async => batchHistoryResponse0); - - when(client.getBatchUTXOs(args: batchUtxoRequest)) - .thenAnswer((realInvocation) async => {}); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - - final firo = FiroWallet( - walletId: "${testWalletId}wallet balances", - walletName: "pendingBalance wallet name", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: FakeSecureStorage(), - tracker: MockTransactionNotificationTracker(), - ); - - final wallet = - await Hive.openBox("${testWalletId}wallet balances"); - await wallet.put('_lelantus_coins', SampleLelantus.lelantusCoins); - await wallet.put('jindex', [2, 4, 6]); - await wallet.put('mintIndex', 8); - await wallet.put('receivingAddresses', [ - "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", - "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", - "aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq", - ]); - - await wallet.put('changeAddresses', [ - "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", - ]); - - expect(firo.balance.getPending(), Decimal.zero); - expect(firo.balance.getSpendable(), Decimal.parse("0.00021594")); - expect(firo.balance.getTotal(), Decimal.parse("0.00021594")); - }); - - test("get transactions", () async { - final client = MockElectrumX(); - final cachedClient = MockCachedElectrumX(); - final secureStore = FakeSecureStorage(); - final mockMainDB = MockMainDB(); - - // set mnemonic - await secureStore.write( - key: "${testWalletId}transactionData_mnemonic", - value: RefreshTestParams.mnemonic); - - // mock electrumx client calls - when(client.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client.getLatestCoinId()).thenAnswer((_) async => 1); - // when(client.getCoinsForRecovery(setId: 1)) - // .thenAnswer((_) async => getCoinsForRecoveryResponse); - when(client.getUsedCoinSerials(startNumber: 0)) - .thenAnswer((_) async => GetUsedSerialsSampleData.serials); - - when(client.estimateFee(blocks: 1)) - .thenAnswer((_) async => Decimal.parse("0.00001000")); - when(client.estimateFee(blocks: 5)) - .thenAnswer((_) async => Decimal.parse("0.00001000")); - when(client.estimateFee(blocks: 20)) - .thenAnswer((_) async => Decimal.parse("0.00001000")); - - // mock history calls - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) - .thenAnswer((_) async => SampleGetHistoryData.data0); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) - .thenAnswer((_) async => SampleGetHistoryData.data1); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2)) - .thenAnswer((_) async => SampleGetHistoryData.data2); - when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3)) - .thenAnswer((_) async => SampleGetHistoryData.data3); - - // mock transaction calls - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash0, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData0); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash1, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData1); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash2, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData2); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash3, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData3); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash4, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData4); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash5, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData5); - when(cachedClient.getTransaction( - txHash: SampleGetTransactionData.txHash6, - coin: Coin.firo, - )).thenAnswer((_) async => SampleGetTransactionData.txData6); - - // mock utxo calls - when(client.getUTXOs(scripthash: anyNamed("scripthash"))) - .thenAnswer((_) async => []); - - final firo = FiroWallet( - walletName: testWalletName, - walletId: "${testWalletId}transactionData", - coin: Coin.firo, - client: client, - cachedClient: cachedClient, - secureStore: secureStore, - mockableOverride: mockMainDB, - tracker: MockTransactionNotificationTracker(), - ); - - final wallet = - await Hive.openBox("${testWalletId}transactionData"); - await wallet.put( - 'receivingAddresses', RefreshTestParams.receivingAddresses); - await wallet.put('changeAddresses', RefreshTestParams.changeAddresses); - - final txData = await firo.transactions; - - expect(txData, isA>()); - - // kill timer and listener - await firo.exit(); - }); + // test("get transactions", () async { + // final client = MockElectrumX(); + // final cachedClient = MockCachedElectrumX(); + // final secureStore = FakeSecureStorage(); + // + // // set mnemonic + // await secureStore.write( + // key: "${testWalletId}transactionData_mnemonic", + // value: RefreshTestParams.mnemonic); + // + // // mock electrumx client calls + // when(client.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client.getLatestCoinId()).thenAnswer((_) async => 1); + // // when(client.getCoinsForRecovery(setId: 1)) + // // .thenAnswer((_) async => getCoinsForRecoveryResponse); + // when(client.getUsedCoinSerials(startNumber: 0)) + // .thenAnswer((_) async => GetUsedSerialsSampleData.serials); + // + // when(client.estimateFee(blocks: 1)) + // .thenAnswer((_) async => Decimal.parse("0.00001000")); + // when(client.estimateFee(blocks: 5)) + // .thenAnswer((_) async => Decimal.parse("0.00001000")); + // when(client.estimateFee(blocks: 20)) + // .thenAnswer((_) async => Decimal.parse("0.00001000")); + // + // // mock history calls + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) + // .thenAnswer((_) async => SampleGetHistoryData.data0); + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1)) + // .thenAnswer((_) async => SampleGetHistoryData.data1); + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2)) + // .thenAnswer((_) async => SampleGetHistoryData.data2); + // when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3)) + // .thenAnswer((_) async => SampleGetHistoryData.data3); + // + // // mock transaction calls + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash0, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData0); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash1, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData1); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash2, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData2); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash3, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData3); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash4, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData4); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash5, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData5); + // when(cachedClient.getTransaction( + // txHash: SampleGetTransactionData.txHash6, + // coin: Coin.firo, + // )).thenAnswer((_) async => SampleGetTransactionData.txData6); + // + // // mock utxo calls + // when(client.getUTXOs(scripthash: anyNamed("scripthash"))) + // .thenAnswer((_) async => []); + // + // final firo = FiroWallet( + // walletName: testWalletName, + // walletId: "${testWalletId}transactionData", + // coin: Coin.firo, + // client: client, + // cachedClient: cachedClient, + // secureStore: secureStore, + // tracker: MockTransactionNotificationTracker(), + // ); + // + // final wallet = + // await Hive.openBox("${testWalletId}transactionData"); + // await wallet.put( + // 'receivingAddresses', RefreshTestParams.receivingAddresses); + // await wallet.put('changeAddresses', RefreshTestParams.changeAddresses); + // + // final txData = await firo.transactions; + // + // expect(txData, isA>()); + // + // // kill timer and listener + // await firo.exit(); + // }); // test("autoMint", () async { // TestWidgetsFlutterBinding.ensureInitialized(); @@ -3316,7 +3280,7 @@ void main() { // client: client, // cachedClient: cachedClient, // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // tracker: MockTransactionNotificationTracker(), // ); diff --git a/test/services/coins/firo/firo_wallet_test.mocks.dart b/test/services/coins/firo/firo_wallet_test.mocks.dart index 3f0ba7040..ac107eaa2 100644 --- a/test/services/coins/firo/firo_wallet_test.mocks.dart +++ b/test/services/coins/firo/firo_wallet_test.mocks.dart @@ -3,20 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i10; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -49,37 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { - _FakeIsar_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_3 extends _i1.SmartFake - implements _i4.QueryBuilder { - _FakeQueryBuilder_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -115,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -134,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -154,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -171,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -182,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -193,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -209,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -226,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -242,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -254,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -271,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -283,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -303,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -322,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -338,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -355,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -375,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -391,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -402,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -418,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -453,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -474,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -493,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -509,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -525,26 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i9.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -573,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -590,302 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i10.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_2( - this, - Invocation.getter(#isar), - ), - ) as _i4.Isar); - @override - _i6.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i4 - .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); - @override - _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putAddresses(List<_i11.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future updateAddress( - _i11.Address? oldAddress, - _i11.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransaction(_i11.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactions(List<_i11.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); - @override - _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); - @override - _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); - @override - _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putOutputs(List<_i11.Output>? outputs) => - (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, - _i11.TransactionNote, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactionNotes( - List<_i11.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future addNewTransactionData( - List< - _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, - _i11.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/monero/monero_wallet_test.dart b/test/services/coins/monero/monero_wallet_test.dart index d55abd658..4f45c4224 100644 --- a/test/services/coins/monero/monero_wallet_test.dart +++ b/test/services/coins/monero/monero_wallet_test.dart @@ -16,9 +16,7 @@ import 'package:flutter_libmonero/monero/monero.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; -import 'package:mockito/annotations.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; @@ -38,9 +36,6 @@ String name = 'namee${Random().nextInt(10000000)}'; int nettype = 0; WalletType type = WalletType.monero; -@GenerateMocks([ - MainDB, -]) void main() async { storage = FakeSecureStorage(); keysStorage = KeyService(storage!); diff --git a/test/services/coins/monero/monero_wallet_test.mocks.dart b/test/services/coins/monero/monero_wallet_test.mocks.dart deleted file mode 100644 index f0ee6ea75..000000000 --- a/test/services/coins/monero/monero_wallet_test.mocks.dart +++ /dev/null @@ -1,333 +0,0 @@ -// Mocks generated by Mockito 5.3.2 from annotations -// in stackwallet/test/services/coins/monero/monero_wallet_test.dart. -// Do not manually edit this file. - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i4; - -import 'package:isar/isar.dart' as _i2; -import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i3; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i5; -import 'package:tuple/tuple.dart' as _i6; - -// ignore_for_file: type=lint -// ignore_for_file: avoid_redundant_argument_values -// ignore_for_file: avoid_setters_without_getters -// ignore_for_file: comment_references -// ignore_for_file: implementation_imports -// ignore_for_file: invalid_use_of_visible_for_testing_member -// ignore_for_file: prefer_const_constructors -// ignore_for_file: unnecessary_parenthesis -// ignore_for_file: camel_case_types -// ignore_for_file: subtype_of_sealed_class - -class _FakeIsar_0 extends _i1.SmartFake implements _i2.Isar { - _FakeIsar_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_1 extends _i1.SmartFake - implements _i2.QueryBuilder { - _FakeQueryBuilder_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i3.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i2.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_0( - this, - Invocation.getter(#isar), - ), - ) as _i2.Isar); - @override - _i4.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i4.Future.value(false), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_1<_i5.Address, _i5.Address, - _i2.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i2 - .QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause>); - @override - _i4.Future putAddress(_i5.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putAddresses(List<_i5.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future updateAddress( - _i5.Address? oldAddress, - _i5.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, _i2.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_1<_i5.Transaction, _i5.Transaction, - _i2.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, - _i2.QAfterWhereClause>); - @override - _i4.Future putTransaction(_i5.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putTransactions(List<_i5.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_1<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>); - @override - _i4.Future putUTXO(_i5.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putUTXOs(List<_i5.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_1<_i5.Input, _i5.Input, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause>); - @override - _i4.Future putInput(_i5.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putInputs(List<_i5.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_1<_i5.Output, _i5.Output, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause>); - @override - _i4.Future putOutput(_i5.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putOutputs(List<_i5.Output>? outputs) => (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, - _i2.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_1<_i5.TransactionNote, - _i5.TransactionNote, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, - _i2.QAfterWhereClause>); - @override - _i4.Future putTransactionNote(_i5.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putTransactionNotes( - List<_i5.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future addNewTransactionData( - List< - _i6.Tuple4<_i5.Transaction, List<_i5.Output>, List<_i5.Input>, - _i5.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); -} diff --git a/test/services/coins/namecoin/namecoin_wallet_test.dart b/test/services/coins/namecoin/namecoin_wallet_test.dart index d20f287e0..53ce2edbd 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.dart @@ -4,18 +4,14 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'namecoin_history_sample_data.dart'; -import 'namecoin_transaction_data_samples.dart'; import 'namecoin_wallet_test.mocks.dart'; import 'namecoin_wallet_test_parameters.dart'; @@ -23,7 +19,6 @@ import 'namecoin_wallet_test_parameters.dart'; ElectrumX, CachedElectrumX, TransactionNotificationTracker, - MainDB, ]) void main() { group("namecoin constants", () { @@ -104,7 +99,6 @@ void main() { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; NamecoinWallet? mainnetWallet; @@ -113,7 +107,6 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); mainnetWallet = NamecoinWallet( walletId: "validateAddressMainNet", @@ -123,7 +116,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -177,7 +169,6 @@ void main() { MockCachedElectrumX? cachedClient; late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; NamecoinWallet? nmc; @@ -186,7 +177,6 @@ void main() { cachedClient = MockCachedElectrumX(); secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); nmc = NamecoinWallet( walletId: "testNetworkConnection", @@ -196,7 +186,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -240,7 +229,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; NamecoinWallet? nmc; @@ -250,7 +238,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); nmc = NamecoinWallet( walletId: testWalletId, @@ -260,7 +247,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -280,7 +266,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); expect(Coin.namecoin, Coin.namecoin); expect(secureStore.interactions, 0); @@ -445,7 +430,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; NamecoinWallet? nmc; @@ -463,7 +447,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); nmc = NamecoinWallet( walletId: testWalletId, @@ -473,7 +456,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -621,799 +603,799 @@ void main() { verifyNoMoreInteractions(cachedClient); }); - test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - await DB.instance.init(); - await Hive.openBox(testWalletId); - bool hasThrown = false; - try { - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - expect(secureStore.interactions, 20); - expect(secureStore.writes, 7); - expect(secureStore.reads, 13); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("get mnemonic list", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await Hive.openBox(testWalletId); - - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - expect(await nmc?.mnemonic, TEST_MNEMONIC.split(" ")); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("recoverFromMnemonic using non empty seed on mainnet succeeds", - () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - bool hasThrown = false; - try { - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 7); - expect(secureStore.reads, 7); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("fullRescan succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) - .thenAnswer((realInvocation) async {}); - - when(client?.getBatchHistory(args: { - "0": [ - "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch valid wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preReceivingAddressesP2SH = - await wallet.get('receivingAddressesP2SH'); - final preReceivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final preChangeAddressesP2WPKH = - await wallet.get('changeAddressesP2WPKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final preChangeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final preReceiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - // destroy the data that the rescan will fix - await wallet.put( - 'receivingAddressesP2PKH', ["some address", "some other address"]); - await wallet.put( - 'receivingAddressesP2SH', ["some address", "some other address"]); - await wallet.put( - 'receivingAddressesP2WPKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2PKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2SH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2WPKH', ["some address", "some other address"]); - await wallet.put('receivingIndexP2PKH', 123); - await wallet.put('receivingIndexP2SH', 123); - await wallet.put('receivingIndexP2WPKH', 123); - await wallet.put('changeIndexP2PKH', 123); - await wallet.put('changeIndexP2SH', 123); - await wallet.put('changeIndexP2WPKH', 123); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); - - bool hasThrown = false; - try { - await nmc?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - final receivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final changeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final receiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preChangeAddressesP2SH, changeAddressesP2SH); - expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preReceivingIndexP2SH, receivingIndexP2SH); - expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preChangeIndexP2SH, changeIndexP2SH); - expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - ] - })).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - ] - })).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - ] - })).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - ] - })).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - ] - })).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) - .called(1); - - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - // Map argCount = {}; - // - // // verify(client?.getBatchHistory(args: map)).called(1); - // // expect(activeScriptHashes.contains(map.values.first.first as String), - // // true); - // } - - // Map argCount = {}; - // - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - // - // final str = jsonEncode(map); - // - // if (argCount[str] == null) { - // argCount[str] = 1; - // } else { - // argCount[str] = argCount[str]! + 1; - // } - // } - // - // argCount.forEach((key, value) => print("arg: $key\ncount: $value")); - - expect(secureStore.writes, 25); - expect(secureStore.reads, 32); - expect(secureStore.deletes, 6); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("fullRescan fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - - when(client?.getBatchHistory(args: { - "0": [ - "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) - .thenAnswer((realInvocation) async {}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preReceivingAddressesP2SH = - await wallet.get('receivingAddressesP2SH'); - final preReceivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final preChangeAddressesP2WPKH = - await wallet.get('changeAddressesP2WPKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final preChangeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final preReceiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenThrow(Exception("fake exception")); - - bool hasThrown = false; - try { - await nmc?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, true); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - final receivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final changeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final receiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preChangeAddressesP2SH, changeAddressesP2SH); - expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preReceivingIndexP2SH, receivingIndexP2SH); - expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preChangeIndexP2SH, changeIndexP2SH); - expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - ] - })).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - ] - })).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) - .called(1); - - expect(secureStore.writes, 19); - expect(secureStore.reads, 32); - expect(secureStore.deletes, 12); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("prepareSend fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - when(cachedClient?.getTransaction( - txHash: - "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", - coin: Coin.namecoin)) - .thenAnswer((_) async => tx2Raw); - when(cachedClient?.getTransaction( - txHash: - "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d", - coin: Coin.namecoin)) - .thenAnswer((_) async => tx3Raw); - when(cachedClient?.getTransaction( - txHash: - "c7e700f7e23a85bbdd9de86d502322a933607ee7ea7e16adaf02e477cdd849b9", - coin: Coin.namecoin, - )).thenAnswer((_) async => tx4Raw); - - // recover to fill data - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // modify addresses to properly mock data to build a tx - final rcv44 = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", - value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", - "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); - final rcv49 = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2SH", - value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", - "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); - final rcv84 = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2WPKH", - value: rcv84?.replaceFirst( - "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", - "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); - - // nmc?.outputsList = utxoList; - - bool didThrow = false; - try { - await nmc?.prepareSend( - address: "nc1q6k4x8ye6865z3rc8zkt8gyu52na7njqt6hsk4v", - satoshiAmount: 15000); - } catch (_) { - didThrow = true; - } - - expect(didThrow, true); - - verify(client?.getServerFeatures()).called(1); - - /// verify transaction no matching calls - - // verify(cachedClient?.getTransaction( - // txHash: - // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", - // coin: Coin.namecoin, - // callOutSideMainIsolate: false)) - // .called(1); - // verify(cachedClient?.getTransaction( - // txHash: - // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", - // coin: Coin.namecoin, - // callOutSideMainIsolate: false)) - // .called(1); - // verify(cachedClient?.getTransaction( - // txHash: - // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", - // coin: Coin.namecoin, - // callOutSideMainIsolate: false)) - // .called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 20); - expect(secureStore.writes, 10); - expect(secureStore.reads, 10); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // await DB.instance.init(); + // await Hive.openBox(testWalletId); + // bool hasThrown = false; + // try { + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // expect(secureStore.interactions, 20); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 13); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("get mnemonic list", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await Hive.openBox(testWalletId); + // + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // expect(await nmc?.mnemonic, TEST_MNEMONIC.split(" ")); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + + // test("recoverFromMnemonic using non empty seed on mainnet succeeds", + // () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // bool hasThrown = false; + // try { + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("fullRescan succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch valid wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // // destroy the data that the rescan will fix + // await wallet.put( + // 'receivingAddressesP2PKH', ["some address", "some other address"]); + // await wallet.put( + // 'receivingAddressesP2SH', ["some address", "some other address"]); + // await wallet.put( + // 'receivingAddressesP2WPKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2PKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2SH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2WPKH', ["some address", "some other address"]); + // await wallet.put('receivingIndexP2PKH', 123); + // await wallet.put('receivingIndexP2SH', 123); + // await wallet.put('receivingIndexP2WPKH', 123); + // await wallet.put('changeIndexP2PKH', 123); + // await wallet.put('changeIndexP2SH', 123); + // await wallet.put('changeIndexP2WPKH', 123); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); + // + // bool hasThrown = false; + // try { + // await nmc?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) + // .called(1); + // + // // for (final arg in dynamicArgValues) { + // // final map = Map>.from(arg as Map); + // // Map argCount = {}; + // // + // // // verify(client?.getBatchHistory(args: map)).called(1); + // // // expect(activeScriptHashes.contains(map.values.first.first as String), + // // // true); + // // } + // + // // Map argCount = {}; + // // + // // for (final arg in dynamicArgValues) { + // // final map = Map>.from(arg as Map); + // // + // // final str = jsonEncode(map); + // // + // // if (argCount[str] == null) { + // // argCount[str] = 1; + // // } else { + // // argCount[str] = argCount[str]! + 1; + // // } + // // } + // // + // // argCount.forEach((key, value) => print("arg: $key\ncount: $value")); + // + // expect(secureStore.writes, 25); + // expect(secureStore.reads, 32); + // expect(secureStore.deletes, 6); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("fullRescan fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) + // .thenAnswer((realInvocation) async {}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenThrow(Exception("fake exception")); + // + // bool hasThrown = false; + // try { + // await nmc?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.namecoin)) + // .called(1); + // + // expect(secureStore.writes, 19); + // expect(secureStore.reads, 32); + // expect(secureStore.deletes, 12); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("prepareSend fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // when(cachedClient?.getTransaction( + // txHash: + // "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", + // coin: Coin.namecoin)) + // .thenAnswer((_) async => tx2Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d", + // coin: Coin.namecoin)) + // .thenAnswer((_) async => tx3Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "c7e700f7e23a85bbdd9de86d502322a933607ee7ea7e16adaf02e477cdd849b9", + // coin: Coin.namecoin, + // )).thenAnswer((_) async => tx4Raw); + // + // // recover to fill data + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // modify addresses to properly mock data to build a tx + // final rcv44 = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", + // value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", + // "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); + // final rcv49 = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2SH", + // value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", + // "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); + // final rcv84 = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2WPKH", + // value: rcv84?.replaceFirst( + // "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", + // "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); + // + // // nmc?.outputsList = utxoList; + // + // bool didThrow = false; + // try { + // await nmc?.prepareSend( + // address: "nc1q6k4x8ye6865z3rc8zkt8gyu52na7njqt6hsk4v", + // satoshiAmount: 15000); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.getServerFeatures()).called(1); + // + // /// verify transaction no matching calls + // + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", + // // coin: Coin.namecoin, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", + // // coin: Coin.namecoin, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", + // // coin: Coin.namecoin, + // // callOutSideMainIsolate: false)) + // // .called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 20); + // expect(secureStore.writes, 10); + // expect(secureStore.reads, 10); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); test("confirmSend no hex", () async { bool didThrow = false; @@ -1521,7 +1503,7 @@ void main() { // // cachedClient: cachedClient, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // // // // set node @@ -1559,141 +1541,141 @@ void main() { // // // // }); - test("refresh wallet mutex locked", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs4)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs5)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - // recover to fill data - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - nmc?.refreshMutex = true; - - await nmc?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 7); - expect(secureStore.reads, 7); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("refresh wallet normally", () async { - when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => - {"height": 520481, "hex": "some block hex"}); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenAnswer((_) async => []); - when(client?.estimateFee(blocks: anyNamed("blocks"))) - .thenAnswer((_) async => Decimal.one); - - final List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - // recover to fill data - await nmc?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((_) async => {}); - when(client?.getBatchUTXOs(args: anyNamed("args"))) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await nmc?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); - verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); - verify(client?.getBlockHeadTip()).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - } - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 7); - expect(secureStore.reads, 7); - expect(secureStore.deletes, 0); - - // verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("refresh wallet mutex locked", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // nmc?.refreshMutex = true; + // + // await nmc?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("refresh wallet normally", () async { + // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => + // {"height": 520481, "hex": "some block hex"}); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((_) async => []); + // when(client?.estimateFee(blocks: anyNamed("blocks"))) + // .thenAnswer((_) async => Decimal.one); + // + // final List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((_) async => {}); + // when(client?.getBatchUTXOs(args: anyNamed("args"))) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await nmc?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); + // verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); + // verify(client?.getBlockHeadTip()).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); tearDown(() async { await tearDownTestHive(); diff --git a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart index 2ac690aa5..47870a622 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart @@ -3,20 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i10; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -49,37 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { - _FakeIsar_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_3 extends _i1.SmartFake - implements _i4.QueryBuilder { - _FakeQueryBuilder_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -115,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -134,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -154,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -171,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -182,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -193,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -209,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -226,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -242,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -254,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -271,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -283,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -303,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -322,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -338,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -355,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -375,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -391,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -402,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -418,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -453,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -474,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -493,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -509,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -525,26 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i9.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -573,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -590,302 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i10.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_2( - this, - Invocation.getter(#isar), - ), - ) as _i4.Isar); - @override - _i6.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i4 - .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); - @override - _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putAddresses(List<_i11.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future updateAddress( - _i11.Address? oldAddress, - _i11.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransaction(_i11.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactions(List<_i11.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); - @override - _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); - @override - _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); - @override - _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putOutputs(List<_i11.Output>? outputs) => - (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, - _i11.TransactionNote, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactionNotes( - List<_i11.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future addNewTransactionData( - List< - _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, - _i11.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index 8fc583324..698a5f657 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -4,7 +4,6 @@ import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart'; @@ -13,8 +12,6 @@ import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'particl_history_sample_data.dart'; -import 'particl_transaction_data_samples.dart'; import 'particl_wallet_test.mocks.dart'; import 'particl_wallet_test_parameters.dart'; @@ -22,7 +19,6 @@ import 'particl_wallet_test_parameters.dart'; ElectrumX, CachedElectrumX, TransactionNotificationTracker, - MainDB, ]) void main() { group("particl constants", () { @@ -105,7 +101,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; ParticlWallet? mainnetWallet; // TODO reimplement testnet, see 9baa30c1a40b422bb5f4746efc1220b52691ace6 and sneurlax/stack_wallet#ec399ade0aef1d9ab2dd78876a2d20819dae4ba0 @@ -116,7 +111,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); mainnetWallet = ParticlWallet( walletId: "validateAddressMainNet", @@ -126,7 +120,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -225,7 +218,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; ParticlWallet? part; @@ -235,7 +227,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); part = ParticlWallet( walletId: "testNetworkConnection", @@ -245,7 +236,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -289,7 +279,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; ParticlWallet? part; @@ -299,7 +288,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); part = ParticlWallet( walletId: testWalletId, @@ -309,7 +297,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); @@ -329,7 +316,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); expect(Coin.particl, Coin.particl); expect(secureStore.interactions, 0); @@ -494,7 +480,6 @@ void main() { late FakeSecureStorage secureStore; MockTransactionNotificationTracker? tracker; - late MockMainDB mockMainDB; ParticlWallet? part; @@ -512,7 +497,6 @@ void main() { secureStore = FakeSecureStorage(); tracker = MockTransactionNotificationTracker(); - mockMainDB = MockMainDB(); part = ParticlWallet( walletId: testWalletId, @@ -522,7 +506,6 @@ void main() { cachedClient: cachedClient!, tracker: tracker!, secureStore: secureStore, - mockableOverride: mockMainDB, ); }); //TODO - THis function definition has changed, possibly remove @@ -664,684 +647,684 @@ void main() { verifyNoMoreInteractions(cachedClient); }); - test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - // await DB.instance.init(); - await Hive.openBox(testWalletId); - bool hasThrown = false; - try { - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 5); - expect(secureStore.reads, 9); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("get mnemonic list", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await Hive.openBox(testWalletId); - - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - expect(await part?.mnemonic, TEST_MNEMONIC.split(" ")); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("recoverFromMnemonic using non empty seed on mainnet succeeds", - () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - bool hasThrown = false; - try { - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 10); - expect(secureStore.writes, 5); - expect(secureStore.reads, 5); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("fullRescan succeeds", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - .thenAnswer((realInvocation) async {}); - - when(client?.getBatchHistory(args: { - "0": [ - "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - when(client?.getBatchHistory(args: { - "0": [ - "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch valid wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preReceivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preChangeAddressesP2WPKH = - await wallet.get('changeAddressesP2WPKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - // destroy the data that the rescan will fix - await wallet.put( - 'receivingAddressesP2PKH', ["some address", "some other address"]); - await wallet.put( - 'receivingAddressesP2WPKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2PKH', ["some address", "some other address"]); - await wallet - .put('changeAddressesP2WPKH', ["some address", "some other address"]); - await wallet.put('receivingIndexP2PKH', 123); - await wallet.put('receivingIndexP2WPKH', 123); - await wallet.put('changeIndexP2PKH', 123); - await wallet.put('changeIndexP2WPKH', 123); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); - await secureStore.write( - key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); - - bool hasThrown = false; - try { - await part?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, false); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final receivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" - ] - })).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" - ] - })).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" - ] - })).called(2); - - verify(client?.getBatchHistory(args: { - "0": [ - "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" - ] - })).called(2); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - .called(1); - - expect(secureStore.writes, 17); - expect(secureStore.reads, 22); - expect(secureStore.deletes, 4); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("fullRescan fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - - when(client?.getBatchHistory(args: { - "0": [ - "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(client?.getBatchHistory(args: { - "0": [ - "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" - ] - })).thenAnswer((realInvocation) async => {"0": []}); - - when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - .thenAnswer((realInvocation) async {}); - - final wallet = await Hive.openBox(testWalletId); - - // restore so we have something to rescan - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // fetch wallet data - final preReceivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final preReceivingAddressesP2SH = - await wallet.get('receivingAddressesP2SH'); - final preReceivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final preChangeAddressesP2WPKH = - await wallet.get('changeAddressesP2WPKH'); - final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final preUtxoData = await wallet.get('latest_utxo_model'); - final preReceiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final preChangeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final preReceiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final preChangeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final preReceiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final preChangeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenThrow(Exception("fake exception")); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenThrow(Exception("fake exception")); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenThrow(Exception("fake exception")); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenThrow(Exception("fake exception")); - - bool hasThrown = false; - try { - await part?.fullRescan(2, 1000); - } catch (_) { - hasThrown = true; - } - expect(hasThrown, true); - - // fetch wallet data again - final receivingAddressesP2PKH = - await wallet.get('receivingAddressesP2PKH'); - final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - final receivingAddressesP2WPKH = - await wallet.get('receivingAddressesP2WPKH'); - final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - final utxoData = await wallet.get('latest_utxo_model'); - final receiveDerivationsStringP2PKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - final changeDerivationsStringP2PKH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - final receiveDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - final changeDerivationsStringP2SH = - await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - final receiveDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - final changeDerivationsStringP2WPKH = await secureStore.read( - key: "${testWalletId}_changeDerivationsP2WPKH"); - - expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - expect(preChangeAddressesP2SH, changeAddressesP2SH); - expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - expect(preReceivingIndexP2SH, receivingIndexP2SH); - expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - expect(preChangeIndexP2PKH, changeIndexP2PKH); - expect(preChangeIndexP2SH, changeIndexP2SH); - expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - expect(preUtxoData, utxoData); - expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - verify(client?.getBatchHistory(args: { - "0": [ - "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" - ] - })).called(1); - verify(client?.getBatchHistory(args: { - "0": [ - "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" - ] - })).called(1); - verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - .called(1); - - expect(secureStore.writes, 13); - expect(secureStore.reads, 26); - expect(secureStore.deletes, 8); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); - - test("prepareSend fails", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - when(cachedClient?.getTransaction( - txHash: - "85130125ec9e37a48670fb5eb0a2780b94ea958cd700a1237ff75775d8a0edb0", - coin: Coin.particl)) - .thenAnswer((_) async => tx2Raw); - when(cachedClient?.getTransaction( - txHash: - "bb25567e1ffb2fd6ec9aa3925a7a8dd3055a29521f7811b2b2bc01ce7d8a216e", - coin: Coin.particl)) - .thenAnswer((_) async => tx3Raw); - when(cachedClient?.getTransaction( - txHash: - "bb25567e1ffb2fd6ec9aa3925a7a8dd3055a29521f7811b2b2bc01ce7d8a216e", - coin: Coin.particl, - )).thenAnswer((_) async => tx4Raw); - - // recover to fill data - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - // modify addresses to properly mock data to build a tx - final rcv44 = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2PKH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2PKH", - value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", - "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); - final rcv84 = await secureStore.read( - key: "${testWalletId}_receiveDerivationsP2WPKH"); - await secureStore.write( - key: "${testWalletId}_receiveDerivationsP2WPKH", - value: rcv84?.replaceFirst( - "pw1qvr6ehcm44vvqe96mxy9zw9aa5sa5yezvr2r94s", - "pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy")); - - // part?.outputsList = utxoList; - - bool didThrow = false; - try { - await part?.prepareSend( - address: "pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy", - satoshiAmount: 15000); - } catch (_) { - didThrow = true; - } - - expect(didThrow, true); - - verify(client?.getServerFeatures()).called(1); - - /// verify transaction no matching calls - - // verify(cachedClient?.getTransaction( - // txHash: - // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", - // coin: Coin.particl, - // callOutSideMainIsolate: false)) - // .called(1); - // verify(cachedClient?.getTransaction( - // txHash: - // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", - // coin: Coin.particl, - // callOutSideMainIsolate: false)) - // .called(1); - // verify(cachedClient?.getTransaction( - // txHash: - // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", - // coin: Coin.particl, - // callOutSideMainIsolate: false)) - // .called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 14); - expect(secureStore.writes, 7); - expect(secureStore.reads, 7); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - }); + // test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // // await DB.instance.init(); + // await Hive.openBox(testWalletId); + // bool hasThrown = false; + // try { + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 5); + // expect(secureStore.reads, 9); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("get mnemonic list", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await Hive.openBox(testWalletId); + // + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // expect(await part?.mnemonic, TEST_MNEMONIC.split(" ")); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("recoverFromMnemonic using non empty seed on mainnet succeeds", + // () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // bool hasThrown = false; + // try { + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 10); + // expect(secureStore.writes, 5); + // expect(secureStore.reads, 5); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("fullRescan succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch valid wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // // destroy the data that the rescan will fix + // await wallet.put( + // 'receivingAddressesP2PKH', ["some address", "some other address"]); + // await wallet.put( + // 'receivingAddressesP2WPKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2PKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2WPKH', ["some address", "some other address"]); + // await wallet.put('receivingIndexP2PKH', 123); + // await wallet.put('receivingIndexP2WPKH', 123); + // await wallet.put('changeIndexP2PKH', 123); + // await wallet.put('changeIndexP2WPKH', 123); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); + // + // bool hasThrown = false; + // try { + // await part?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + // ] + // })).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .called(1); + // + // expect(secureStore.writes, 17); + // expect(secureStore.reads, 22); + // expect(secureStore.deletes, 4); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("fullRescan fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .thenAnswer((realInvocation) async {}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenThrow(Exception("fake exception")); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenThrow(Exception("fake exception")); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenThrow(Exception("fake exception")); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenThrow(Exception("fake exception")); + // + // bool hasThrown = false; + // try { + // await part?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + // ] + // })).called(1); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .called(1); + // + // expect(secureStore.writes, 13); + // expect(secureStore.reads, 26); + // expect(secureStore.deletes, 8); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); + // + // test("prepareSend fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // when(cachedClient?.getTransaction( + // txHash: + // "85130125ec9e37a48670fb5eb0a2780b94ea958cd700a1237ff75775d8a0edb0", + // coin: Coin.particl)) + // .thenAnswer((_) async => tx2Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "bb25567e1ffb2fd6ec9aa3925a7a8dd3055a29521f7811b2b2bc01ce7d8a216e", + // coin: Coin.particl)) + // .thenAnswer((_) async => tx3Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "bb25567e1ffb2fd6ec9aa3925a7a8dd3055a29521f7811b2b2bc01ce7d8a216e", + // coin: Coin.particl, + // )).thenAnswer((_) async => tx4Raw); + // + // // recover to fill data + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // modify addresses to properly mock data to build a tx + // final rcv44 = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", + // value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", + // "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); + // final rcv84 = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2WPKH", + // value: rcv84?.replaceFirst( + // "pw1qvr6ehcm44vvqe96mxy9zw9aa5sa5yezvr2r94s", + // "pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy")); + // + // // part?.outputsList = utxoList; + // + // bool didThrow = false; + // try { + // await part?.prepareSend( + // address: "pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy", + // satoshiAmount: 15000); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.getServerFeatures()).called(1); + // + // /// verify transaction no matching calls + // + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", + // // coin: Coin.particl, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", + // // coin: Coin.particl, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", + // // coin: Coin.particl, + // // callOutSideMainIsolate: false)) + // // .called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // }); test("confirmSend no hex", () async { bool didThrow = false; @@ -1449,7 +1432,7 @@ void main() { // // cachedClient: cachedClient, // // // // secureStore: secureStore, - // mockableOverride: mockMainDB, + // // // ); // // // // // set node @@ -1487,133 +1470,133 @@ void main() { // // // // }); - test("refresh wallet mutex locked", () async { - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getBatchHistory(args: historyBatchArgs0)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs1)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs2)) - .thenAnswer((_) async => historyBatchResponse); - when(client?.getBatchHistory(args: historyBatchArgs3)) - .thenAnswer((_) async => historyBatchResponse); - List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - if (realInvocation.namedArguments.values.first.length == 1) { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - } - - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - // recover to fill data - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - part?.refreshMutex = true; - - await part?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - expect(activeScriptHashes.contains(map.values.first.first as String), - true); - } - - expect(secureStore.interactions, 10); - expect(secureStore.writes, 5); - expect(secureStore.reads, 5); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(client); - verifyNoMoreInteractions(cachedClient); - verifyNoMoreInteractions(tracker); - }); - - test("refresh wallet normally", () async { - when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => - {"height": 520481, "hex": "some block hex"}); - when(client?.getServerFeatures()).thenAnswer((_) async => { - "hosts": {}, - "pruning": null, - "server_version": "Unit tests", - "protocol_min": "1.4", - "protocol_max": "1.4.2", - "genesis_hash": GENESIS_HASH_MAINNET, - "hash_function": "sha256", - "services": [] - }); - when(client?.getHistory(scripthash: anyNamed("scripthash"))) - .thenAnswer((_) async => []); - when(client?.estimateFee(blocks: anyNamed("blocks"))) - .thenAnswer((_) async => Decimal.one); - - final List dynamicArgValues = []; - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((realInvocation) async { - dynamicArgValues.add(realInvocation.namedArguments.values.first); - return historyBatchResponse; - }); - - await Hive.openBox(testWalletId); - - // recover to fill data - await part?.recoverFromMnemonic( - mnemonic: TEST_MNEMONIC, - maxUnusedAddressGap: 2, - maxNumberOfIndexesToCheck: 1000, - height: 4000); - - when(client?.getBatchHistory(args: anyNamed("args"))) - .thenAnswer((_) async => {}); - when(client?.getBatchUTXOs(args: anyNamed("args"))) - .thenAnswer((_) async => emptyHistoryBatchResponse); - - await part?.refresh(); - - verify(client?.getServerFeatures()).called(1); - verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(3); - verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); - verify(client?.getBlockHeadTip()).called(1); - - for (final arg in dynamicArgValues) { - final map = Map>.from(arg as Map); - - verify(client?.getBatchHistory(args: map)).called(1); - } - - expect(secureStore.interactions, 10); - expect(secureStore.writes, 5); - expect(secureStore.reads, 5); - expect(secureStore.deletes, 0); - - verifyNoMoreInteractions(cachedClient); - }); + // test("refresh wallet mutex locked", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // part?.refreshMutex = true; + // + // await part?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 10); + // expect(secureStore.writes, 5); + // expect(secureStore.reads, 5); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // }); + // + // test("refresh wallet normally", () async { + // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => + // {"height": 520481, "hex": "some block hex"}); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((_) async => []); + // when(client?.estimateFee(blocks: anyNamed("blocks"))) + // .thenAnswer((_) async => Decimal.one); + // + // final List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await part?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((_) async => {}); + // when(client?.getBatchUTXOs(args: anyNamed("args"))) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await part?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(3); + // verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); + // verify(client?.getBlockHeadTip()).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // } + // + // expect(secureStore.interactions, 10); + // expect(secureStore.writes, 5); + // expect(secureStore.reads, 5); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(cachedClient); + // }); tearDown(() async { await tearDownTestHive(); diff --git a/test/services/coins/particl/particl_wallet_test.mocks.dart b/test/services/coins/particl/particl_wallet_test.mocks.dart index 93f9e9723..ab2e8f310 100644 --- a/test/services/coins/particl/particl_wallet_test.mocks.dart +++ b/test/services/coins/particl/particl_wallet_test.mocks.dart @@ -3,20 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i5; import 'package:decimal/decimal.dart' as _i2; -import 'package:isar/isar.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i10; -import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i5; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i11; +import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; +import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; + as _i8; +import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i3; -import 'package:tuple/tuple.dart' as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -49,37 +45,16 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { ); } -class _FakeIsar_2 extends _i1.SmartFake implements _i4.Isar { - _FakeIsar_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_3 extends _i1.SmartFake - implements _i4.QueryBuilder { - _FakeQueryBuilder_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [ElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { +class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { MockElectrumX() { _i1.throwOnMissingStub(this); } @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( + set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( Invocation.setter( #failovers, _failovers, @@ -115,7 +90,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { returnValue: false, ) as bool); @override - _i6.Future request({ + _i5.Future request({ required String? command, List? args = const [], Duration? connectionTimeout = const Duration(seconds: 60), @@ -134,10 +109,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future>> batchRequest({ + _i5.Future>> batchRequest({ required String? command, required Map>? args, Duration? connectionTimeout = const Duration(seconds: 60), @@ -154,11 +129,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retries: retries, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future ping({ + _i5.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -171,10 +146,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i5.Future.value(false), + ) as _i5.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i5.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -182,10 +157,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i5.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -193,10 +168,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future broadcastTransaction({ + _i5.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -209,10 +184,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(''), - ) as _i6.Future); + returnValue: _i5.Future.value(''), + ) as _i5.Future); @override - _i6.Future> getBalance({ + _i5.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -226,10 +201,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future>> getHistory({ + _i5.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -242,11 +217,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchHistory( + _i5.Future>>> getBatchHistory( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -254,11 +229,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future>> getUTXOs({ + _i5.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -271,11 +246,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i5.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i5.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i5.Future>>> getBatchUTXOs( {required Map>? args}) => (super.noSuchMethod( Invocation.method( @@ -283,11 +258,11 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i5.Future>>>.value( >>{}), - ) as _i6.Future>>>); + ) as _i5.Future>>>); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -303,10 +278,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -322,10 +297,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getMintData({ + _i5.Future getMintData({ dynamic mints, String? requestID, }) => @@ -338,10 +313,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + ) as _i5.Future); @override - _i6.Future> getUsedCoinSerials({ + _i5.Future> getUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -355,19 +330,19 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( + _i5.Future getLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i5.Future.value(0), + ) as _i5.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i5.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -375,10 +350,10 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future<_i2.Decimal> estimateFee({ + _i5.Future<_i2.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -391,7 +366,7 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { #blocks: blocks, }, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #estimateFee, @@ -402,15 +377,15 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { }, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); @override - _i6.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i2.Decimal>.value(_FakeDecimal_0( + returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( this, Invocation.method( #relayFee, @@ -418,13 +393,13 @@ class MockElectrumX extends _i1.Mock implements _i5.ElectrumX { {#requestID: requestID}, ), )), - ) as _i6.Future<_i2.Decimal>); + ) as _i5.Future<_i2.Decimal>); } /// A class which mocks [CachedElectrumX]. /// /// See the documentation for Mockito's code generation for more information. -class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { +class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { MockCachedElectrumX() { _i1.throwOnMissingStub(this); } @@ -453,15 +428,15 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { ), ) as _i3.Prefs); @override - List<_i5.ElectrumXNode> get failovers => (super.noSuchMethod( + List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( Invocation.getter(#failovers), - returnValue: <_i5.ElectrumXNode>[], - ) as List<_i5.ElectrumXNode>); + returnValue: <_i4.ElectrumXNode>[], + ) as List<_i4.ElectrumXNode>); @override - _i6.Future> getAnonymitySet({ + _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i8.Coin? coin, + required _i7.Coin? coin, }) => (super.noSuchMethod( Invocation.method( @@ -474,8 +449,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( Invocation.method( @@ -493,9 +468,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { returnValue: '', ) as String); @override - _i6.Future> getTransaction({ + _i5.Future> getTransaction({ required String? txHash, - required _i8.Coin? coin, + required _i7.Coin? coin, bool? verbose = true, }) => (super.noSuchMethod( @@ -509,11 +484,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i5.Future>.value({}), + ) as _i5.Future>); @override - _i6.Future> getUsedCoinSerials({ - required _i8.Coin? coin, + _i5.Future> getUsedCoinSerials({ + required _i7.Coin? coin, int? startNumber = 0, }) => (super.noSuchMethod( @@ -525,26 +500,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX { #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i5.Future>.value([]), + ) as _i5.Future>); @override - _i6.Future clearSharedTransactionCache({required _i8.Coin? coin}) => + _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], {#coin: coin}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i9.TransactionNotificationTracker { + implements _i8.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -573,14 +548,14 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( @@ -590,302 +565,12 @@ class MockTransactionNotificationTracker extends _i1.Mock returnValue: false, ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i5.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i10.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_2( - this, - Invocation.getter(#isar), - ), - ) as _i4.Isar); - @override - _i6.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Address, _i11.Address, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i4 - .QueryBuilder<_i11.Address, _i11.Address, _i4.QAfterWhereClause>); - @override - _i6.Future putAddress(_i11.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putAddresses(List<_i11.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future updateAddress( - _i11.Address? oldAddress, - _i11.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, _i4.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Transaction, _i11.Transaction, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransaction(_i11.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactions(List<_i11.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.UTXO, _i11.UTXO, _i4.QAfterWhereClause>); - @override - _i6.Future putUTXO(_i11.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putUTXOs(List<_i11.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_3<_i11.Input, _i11.Input, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Input, _i11.Input, _i4.QAfterWhereClause>); - @override - _i6.Future putInput(_i11.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putInputs(List<_i11.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.Output, _i11.Output, - _i4.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.Output, _i11.Output, _i4.QAfterWhereClause>); - @override - _i6.Future putOutput(_i11.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putOutputs(List<_i11.Output>? outputs) => - (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_3<_i11.TransactionNote, - _i11.TransactionNote, _i4.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i4.QueryBuilder<_i11.TransactionNote, _i11.TransactionNote, - _i4.QAfterWhereClause>); - @override - _i6.Future putTransactionNote(_i11.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future putTransactionNotes( - List<_i11.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); - @override - _i6.Future addNewTransactionData( - List< - _i12.Tuple4<_i11.Transaction, List<_i11.Output>, List<_i11.Input>, - _i11.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } diff --git a/test/services/coins/wownero/wownero_wallet_test.dart b/test/services/coins/wownero/wownero_wallet_test.dart index c0c5f9424..42d9e0696 100644 --- a/test/services/coins/wownero/wownero_wallet_test.dart +++ b/test/services/coins/wownero/wownero_wallet_test.dart @@ -16,9 +16,7 @@ import 'package:flutter_libmonero/wownero/wownero.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; -import 'package:mockito/annotations.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'wownero_wallet_test_data.dart'; @@ -36,9 +34,6 @@ String name = ''; int nettype = 0; WalletType type = WalletType.wownero; -@GenerateMocks([ - MainDB, -]) void main() async { storage = FakeSecureStorage(); keysStorage = KeyService(storage!); diff --git a/test/services/coins/wownero/wownero_wallet_test.mocks.dart b/test/services/coins/wownero/wownero_wallet_test.mocks.dart deleted file mode 100644 index e31fff4ac..000000000 --- a/test/services/coins/wownero/wownero_wallet_test.mocks.dart +++ /dev/null @@ -1,333 +0,0 @@ -// Mocks generated by Mockito 5.3.2 from annotations -// in stackwallet/test/services/coins/wownero/wownero_wallet_test.dart. -// Do not manually edit this file. - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i4; - -import 'package:isar/isar.dart' as _i2; -import 'package:mockito/mockito.dart' as _i1; -import 'package:stackwallet/db/main_db.dart' as _i3; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i5; -import 'package:tuple/tuple.dart' as _i6; - -// ignore_for_file: type=lint -// ignore_for_file: avoid_redundant_argument_values -// ignore_for_file: avoid_setters_without_getters -// ignore_for_file: comment_references -// ignore_for_file: implementation_imports -// ignore_for_file: invalid_use_of_visible_for_testing_member -// ignore_for_file: prefer_const_constructors -// ignore_for_file: unnecessary_parenthesis -// ignore_for_file: camel_case_types -// ignore_for_file: subtype_of_sealed_class - -class _FakeIsar_0 extends _i1.SmartFake implements _i2.Isar { - _FakeIsar_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeQueryBuilder_1 extends _i1.SmartFake - implements _i2.QueryBuilder { - _FakeQueryBuilder_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -/// A class which mocks [MainDB]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockMainDB extends _i1.Mock implements _i3.MainDB { - MockMainDB() { - _i1.throwOnMissingStub(this); - } - - @override - _i2.Isar get isar => (super.noSuchMethod( - Invocation.getter(#isar), - returnValue: _FakeIsar_0( - this, - Invocation.getter(#isar), - ), - ) as _i2.Isar); - @override - _i4.Future isarInit() => (super.noSuchMethod( - Invocation.method( - #isarInit, - [], - ), - returnValue: _i4.Future.value(false), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause> - getAddresses(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getAddresses, - [walletId], - ), - returnValue: _FakeQueryBuilder_1<_i5.Address, _i5.Address, - _i2.QAfterWhereClause>( - this, - Invocation.method( - #getAddresses, - [walletId], - ), - ), - ) as _i2 - .QueryBuilder<_i5.Address, _i5.Address, _i2.QAfterWhereClause>); - @override - _i4.Future putAddress(_i5.Address? address) => (super.noSuchMethod( - Invocation.method( - #putAddress, - [address], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putAddresses(List<_i5.Address>? addresses) => - (super.noSuchMethod( - Invocation.method( - #putAddresses, - [addresses], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future updateAddress( - _i5.Address? oldAddress, - _i5.Address? newAddress, - ) => - (super.noSuchMethod( - Invocation.method( - #updateAddress, - [ - oldAddress, - newAddress, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, _i2.QAfterWhereClause> - getTransactions(String? walletId) => (super.noSuchMethod( - Invocation.method( - #getTransactions, - [walletId], - ), - returnValue: _FakeQueryBuilder_1<_i5.Transaction, _i5.Transaction, - _i2.QAfterWhereClause>( - this, - Invocation.method( - #getTransactions, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.Transaction, _i5.Transaction, - _i2.QAfterWhereClause>); - @override - _i4.Future putTransaction(_i5.Transaction? transaction) => - (super.noSuchMethod( - Invocation.method( - #putTransaction, - [transaction], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putTransactions(List<_i5.Transaction>? transactions) => - (super.noSuchMethod( - Invocation.method( - #putTransactions, - [transactions], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause> getUTXOs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getUTXOs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_1<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getUTXOs, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.UTXO, _i5.UTXO, _i2.QAfterWhereClause>); - @override - _i4.Future putUTXO(_i5.UTXO? utxo) => (super.noSuchMethod( - Invocation.method( - #putUTXO, - [utxo], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putUTXOs(List<_i5.UTXO>? utxos) => (super.noSuchMethod( - Invocation.method( - #putUTXOs, - [utxos], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause> getInputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getInputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_1<_i5.Input, _i5.Input, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getInputs, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.Input, _i5.Input, _i2.QAfterWhereClause>); - @override - _i4.Future putInput(_i5.Input? input) => (super.noSuchMethod( - Invocation.method( - #putInput, - [input], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putInputs(List<_i5.Input>? inputs) => (super.noSuchMethod( - Invocation.method( - #putInputs, - [inputs], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause> getOutputs( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getOutputs, - [walletId], - ), - returnValue: - _FakeQueryBuilder_1<_i5.Output, _i5.Output, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getOutputs, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.Output, _i5.Output, _i2.QAfterWhereClause>); - @override - _i4.Future putOutput(_i5.Output? output) => (super.noSuchMethod( - Invocation.method( - #putOutput, - [output], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putOutputs(List<_i5.Output>? outputs) => (super.noSuchMethod( - Invocation.method( - #putOutputs, - [outputs], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, - _i2.QAfterWhereClause> getTransactionNotes( - String? walletId) => - (super.noSuchMethod( - Invocation.method( - #getTransactionNotes, - [walletId], - ), - returnValue: _FakeQueryBuilder_1<_i5.TransactionNote, - _i5.TransactionNote, _i2.QAfterWhereClause>( - this, - Invocation.method( - #getTransactionNotes, - [walletId], - ), - ), - ) as _i2.QueryBuilder<_i5.TransactionNote, _i5.TransactionNote, - _i2.QAfterWhereClause>); - @override - _i4.Future putTransactionNote(_i5.TransactionNote? transactionNote) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNote, - [transactionNote], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future putTransactionNotes( - List<_i5.TransactionNote>? transactionNotes) => - (super.noSuchMethod( - Invocation.method( - #putTransactionNotes, - [transactionNotes], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future deleteWalletBlockchainData(String? walletId) => - (super.noSuchMethod( - Invocation.method( - #deleteWalletBlockchainData, - [walletId], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); - @override - _i4.Future addNewTransactionData( - List< - _i6.Tuple4<_i5.Transaction, List<_i5.Output>, List<_i5.Input>, - _i5.Address?>>? - transactionsData, - String? walletId, - ) => - (super.noSuchMethod( - Invocation.method( - #addNewTransactionData, - [ - transactionsData, - walletId, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); -} diff --git a/test/services/wallets_service_test.dart b/test/services/wallets_service_test.dart index 9cd808b7c..fc1984923 100644 --- a/test/services/wallets_service_test.dart +++ b/test/services/wallets_service_test.dart @@ -2,16 +2,11 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; import 'package:stackwallet/hive/db.dart'; -import 'package:stackwallet/models/notification_model.dart'; -import 'package:stackwallet/models/trade_wallet_lookup.dart'; import 'package:stackwallet/services/wallets_service.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'wallets_service_test.mocks.dart'; - @GenerateMocks([SecureStorageWrapper]) void main() { setUp(() async { @@ -124,58 +119,58 @@ void main() { test("get non existent wallet id", () async { final service = WalletsService(secureStorageInterface: FakeSecureStorage()); - expectLater(await service.getWalletId("wallet 99"), null); + await expectLater(await service.getWalletId("wallet 99"), null); }); - test("delete a wallet", () async { - await Hive.openBox(DB.boxNameWalletsToDeleteOnStart); - await Hive.openBox(DB.boxNameTradeLookup); - await Hive.openBox(DB.boxNameNotifications); - final secureStore = MockSecureStorageWrapper(); - - when(secureStore.delete(key: "wallet_id_pin")).thenAnswer((_) async {}); - when(secureStore.delete(key: "wallet_id_mnemonic")) - .thenAnswer((_) async {}); - - final service = WalletsService(secureStorageInterface: secureStore); - - expect(await service.deleteWallet("My Firo Wallet", false), 0); - expect((await service.walletNames).length, 1); - - verify(secureStore.delete(key: "wallet_id_pin")).called(1); - verify(secureStore.delete(key: "wallet_id_mnemonic")).called(1); - - verifyNoMoreInteractions(secureStore); - }); - - test("delete last wallet", () async { - await Hive.openBox(DB.boxNameWalletsToDeleteOnStart); - await Hive.openBox(DB.boxNameTradeLookup); - await Hive.openBox(DB.boxNameNotifications); - final wallets = await Hive.openBox('wallets'); - await wallets.put('names', { - "wallet_id": { - "name": "My Firo Wallet", - "id": "wallet_id", - "coin": "bitcoin", - }, - }); - final secureStore = MockSecureStorageWrapper(); - - when(secureStore.delete(key: "wallet_id_pin")).thenAnswer((_) async {}); - when(secureStore.delete(key: "wallet_id_mnemonic")) - .thenAnswer((_) async {}); - - final service = WalletsService(secureStorageInterface: secureStore); - - expect(await service.deleteWallet("My Firo Wallet", false), 2); - expect((await service.walletNames).length, 0); - - verify(secureStore.delete(key: "wallet_id_pin")).called(1); - verify(secureStore.delete(key: "wallet_id_mnemonic")).called(1); - - verifyNoMoreInteractions(secureStore); - }); + // test("delete a wallet", () async { + // await Hive.openBox(DB.boxNameWalletsToDeleteOnStart); + // await Hive.openBox(DB.boxNameTradeLookup); + // await Hive.openBox(DB.boxNameNotifications); + // final secureStore = MockSecureStorageWrapper(); + // + // when(secureStore.delete(key: "wallet_id_pin")).thenAnswer((_) async {}); + // when(secureStore.delete(key: "wallet_id_mnemonic")) + // .thenAnswer((_) async {}); + // + // final service = WalletsService(secureStorageInterface: secureStore); + // + // expect(await service.deleteWallet("My Firo Wallet", false), 0); + // expect((await service.walletNames).length, 1); + // + // verify(secureStore.delete(key: "wallet_id_pin")).called(1); + // verify(secureStore.delete(key: "wallet_id_mnemonic")).called(1); + // + // verifyNoMoreInteractions(secureStore); + // }); + // + // test("delete last wallet", () async { + // await Hive.openBox(DB.boxNameWalletsToDeleteOnStart); + // await Hive.openBox(DB.boxNameTradeLookup); + // await Hive.openBox(DB.boxNameNotifications); + // final wallets = await Hive.openBox('wallets'); + // await wallets.put('names', { + // "wallet_id": { + // "name": "My Firo Wallet", + // "id": "wallet_id", + // "coin": "bitcoin", + // }, + // }); + // final secureStore = MockSecureStorageWrapper(); + // + // when(secureStore.delete(key: "wallet_id_pin")).thenAnswer((_) async {}); + // when(secureStore.delete(key: "wallet_id_mnemonic")) + // .thenAnswer((_) async {}); + // + // final service = WalletsService(secureStorageInterface: secureStore); + // + // expect(await service.deleteWallet("My Firo Wallet", false), 2); + // expect((await service.walletNames).length, 0); + // + // verify(secureStore.delete(key: "wallet_id_pin")).called(1); + // verify(secureStore.delete(key: "wallet_id_mnemonic")).called(1); + // + // verifyNoMoreInteractions(secureStore); + // }); // test("get", () async { // final service = WalletsService(); diff --git a/test/widget_tests/managed_favorite_test.dart b/test/widget_tests/managed_favorite_test.dart index dc643e831..2d8bedde5 100644 --- a/test/widget_tests/managed_favorite_test.dart +++ b/test/widget_tests/managed_favorite_test.dart @@ -1,10 +1,9 @@ -import 'dart:ffi'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; @@ -13,12 +12,11 @@ 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/utilities/listenable_list.dart'; -import 'package:stackwallet/widgets/managed_favorite.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/listenable_list.dart'; import 'package:stackwallet/utilities/theme/light_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/managed_favorite.dart'; import 'managed_favorite_test.mocks.dart'; @@ -44,6 +42,15 @@ void main() { final manager = Manager(wallet); when(wallets.getManager("some wallet id")) .thenAnswer((realInvocation) => manager); + when(manager.balance).thenAnswer( + (realInvocation) => Balance( + coin: Coin.bitcoin, + total: 10, + spendable: 10, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); when(manager.isFavorite).thenAnswer((realInvocation) => false); final key = UniqueKey(); @@ -88,6 +95,15 @@ void main() { when(wallets.getManager("some wallet id")) .thenAnswer((realInvocation) => manager); + when(manager.balance).thenAnswer( + (realInvocation) => Balance( + coin: Coin.bitcoin, + total: 10, + spendable: 10, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); when(manager.isFavorite).thenAnswer((realInvocation) => false); @@ -150,6 +166,15 @@ void main() { .thenAnswer((realInvocation) => manager); when(manager.isFavorite).thenAnswer((realInvocation) => true); + when(manager.balance).thenAnswer( + (realInvocation) => Balance( + coin: Coin.bitcoin, + total: 10, + spendable: 10, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); when(mockLocaleService.locale).thenAnswer((_) => "en_US"); 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 9b675b271..a5d18e571 100644 --- a/test/widget_tests/table_view/table_view_row_test.dart +++ b/test/widget_tests/table_view/table_view_row_test.dart @@ -75,6 +75,8 @@ void main() { ), ); + await widgetTester.pumpAndSettle(); + expect(find.text("Some Text 1"), findsOneWidget); expect(find.byType(TableViewRow), findsWidgets); expect(find.byType(TableViewCell), findsWidgets); diff --git a/test/widget_tests/wallet_card_test.dart b/test/widget_tests/wallet_card_test.dart index 1dc82f9b1..6e20e2892 100644 --- a/test/widget_tests/wallet_card_test.dart +++ b/test/widget_tests/wallet_card_test.dart @@ -74,8 +74,12 @@ void main() { ), ); + await widgetTester.pumpAndSettle(); + expect(find.byType(MaterialButton), findsOneWidget); await widgetTester.tap(find.byType(MaterialButton)); + + await widgetTester.pumpAndSettle(); }); testWidgets('test widget loads correctly', (widgetTester) async { @@ -113,6 +117,9 @@ void main() { ), ), ); + + await widgetTester.pumpAndSettle(); + expect(find.byWidget(walletSheetCard), findsOneWidget); }); } diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart index ba8e11e47..ce04bf795 100644 --- a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart +++ b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart @@ -10,10 +10,10 @@ 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/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/theme/light_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart'; import 'wallet_info_row_balance_future_test.mocks.dart'; @@ -63,6 +63,9 @@ void main() { ); // // expect(find.text("some wallet"), findsOneWidget); + + await widgetTester.pumpAndSettle(); + expect(find.byType(WalletInfoRowBalanceFuture), findsOneWidget); }); } 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 d0ca88983..1bcf3d14e 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 @@ -10,13 +10,11 @@ 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/utilities/listenable_map.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; -import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/theme/light_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart'; +import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart'; import 'wallet_info_row_test.mocks.dart'; @@ -63,6 +61,8 @@ void main() { ), ); + await widgetTester.pumpAndSettle(); + expect(find.text("some wallet"), findsOneWidget); expect(find.byType(WalletInfoRowBalanceFuture), findsOneWidget); }); From 4c25a88c3218ce7f136c6722743e95686fdf0527 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 20 Jan 2023 11:48:59 -0600 Subject: [PATCH 191/192] update to use new block data callback --- crypto_plugins/flutter_libmonero | 2 +- lib/services/coins/monero/monero_wallet.dart | 3 ++- lib/services/coins/wownero/wownero_wallet.dart | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crypto_plugins/flutter_libmonero b/crypto_plugins/flutter_libmonero index 66eaa2f3c..f1031db5b 160000 --- a/crypto_plugins/flutter_libmonero +++ b/crypto_plugins/flutter_libmonero @@ -1 +1 @@ -Subproject commit 66eaa2f3c7133f1dbf0b1fc950e7a9e3cc611185 +Subproject commit f1031db5bb67b38d028187f0ead192acb3e9ba55 diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 2452099ad..48bcfc2ed 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -954,11 +954,12 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { DefaultNodes.getNodeFor(coin); } - void onNewBlock() { + void onNewBlock({required int height, required int blocksLeft}) { // print("============================="); print("New Block! :: $walletName"); print("============================="); + updateCachedChainHeight(height); _refreshTxDataHelper(); } diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 126cc2eb3..8cf873b3b 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1022,11 +1022,12 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { DefaultNodes.getNodeFor(coin); } - void onNewBlock() { + void onNewBlock({required int height, required int blocksLeft}) { // print("============================="); print("New Wownero Block! :: $walletName"); print("============================="); + updateCachedChainHeight(height); _refreshTxDataHelper(); } From 13840f0d06ac6c1eb5fe058bc5464c1375050a38 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 20 Jan 2023 11:55:54 -0600 Subject: [PATCH 192/192] update version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index a1ade167d..e7dca762d 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.5.27+100 +version: 1.5.29+103 environment: sdk: ">=2.17.0 <3.0.0"