From 3d77c37771efa06327a373176ba82509345b4a3b Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 6 Oct 2022 16:41:24 -0500 Subject: [PATCH 01/44] Add @msalazarm's setup script Love this thing --- README.md | 41 ++++++++++++++++++++++++++++++++++------ scripts/setup.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 scripts/setup.sh diff --git a/README.md b/README.md index fe380e5ab..9df469563 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,22 @@ Highlights include: - Custom Nodes. - Open source software. -## Build and run +## Building ### Prerequisites - The only OS supported for building is Ubuntu 20.04 - A machine with at least 100 GB of Storage + +The following prerequisities can be installed with the setup script `scripts/setup.sh` or manually as described below: + - Flutter 3.0.5 [(install manually or with git, do not install with snap)](https://docs.flutter.dev/get-started/install) - Dart SDK Requirement (>=2.17.0, up until <3.0.0) - Android setup ([Android Studio](https://developer.android.com/studio) and subsequent dependencies) -After that download the project and init the submodules +### Scripted setup +`scripts/setup.sh` is provided as a tool to set up a stock Ubuntu 20.04 installation for building. This script should skip the entire [Manual setup](#manual-setup) section below and prepare you for [running](#running) + +### Manual setup +After installing the prerequisites listed above, download the code and init the submodules ``` git clone https://github.com/cypherstack/stack_wallet.git cd stack_wallet @@ -57,7 +64,6 @@ cd scripts cd .. ``` - Remove pre-installed system libraries for the following packages built by cryptography plugins in the crypto_plugins folder: `boost iconv libjson-dev libsecret openssl sodium unbound zmq`. You can use ``` sudo apt list --installed | grep boost @@ -76,7 +82,7 @@ cd scripts/android/ cd ../.. ``` -Building plugins for testing on Linux +Building plugins for Linux ``` cd scripts/linux/ @@ -85,10 +91,33 @@ cd scripts/linux/ cd ../.. ``` -Finally, plug in your android device or use the emulator available via Android Studio and then run the following commands: +## Running +### Android +Plug in your android device or use the emulator available via Android Studio and then run the following commands: ``` flutter pub get -flutter run +flutter run android ``` Note on Emulators: Only x86_64 emulators are supported, x86 emulators will not work + +### Linux +Plug in your android device or use the emulator available via Android Studio and then run the following commands: +``` +flutter pub get Linux +flutter run linux +``` + +## Android Studio +Android Studio is the recommended IDE for development, not just for launching on Android devices and emulators but also for Linux desktop development. Install it and configure it as follows: +``` +# setup android studio +sudo apt install -y openjdk-11-jdk +sudo snap install android-studio --classic +``` + +Use Tools > SDK Manager to install the Android SDK, NDK, Android SDK command line tools, and cmake + +Then install the Flutter plugin. In Android Studio's options for the Flutter language, enable auto format on save to match the project's code style + +Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100644 index 000000000..aad8cccaa --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade -y +mkdir "$HOME/development" +mkdir "$HOME/projects" +sudo apt install -y git build-essential curl +export DEVELOPMENT=$HOME/development +export PROJECTS=$HOME/projects + +# setup flutter +sudo apt install -y unzip pkg-config clang cmake ninja-build libgtk-3-dev +cd $DEVELOPMENT +git clone https://github.com/flutter/flutter.git +cd flutter +git checkout 3.0.3 +export FLUTTER_DIR=$(pwd)/bin +echo 'export PATH="$PATH:'${FLUTTER_DIR}'"' >> ~/.bashrc +source ~/.bashrc +flutter doctor + +# setup stack_wallet github +cd $PROJECTS +git clone https://github.com/cypherstack/stack_wallet.git +cd stack_wallet +export STACK_WALLET=$(pwd) +git submodule update --init --recursive + +# create template lib/external_api_keys.dart file if it doesn't already exist +cd $STACK_WALLET +cd scripts +./prebuild.sh + +#install stack wallet dependencies +sudo apt-get install -y unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake openjdk-8-jre-headless libgit2-dev clang libncurses5-dev libncursesw5-dev zlib1g-dev llvm + +sudo apt-get install -y debhelper libclang-dev cargo rustc opencl-headers libssl-dev ocl-icd-opencl-dev + +sudo apt-get install -y unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake openjdk-8-jre-headless + +sudo apt install -y libc6-dev-i386 + +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +cargo install cargo-ndk +rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android + +# build stack wallet plugins +cd $STACK_WALLET +cd scripts/android +./build_all.sh From 0b6b92df8668bf17358014719375736f58fe409f Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 6 Oct 2022 16:52:57 -0500 Subject: [PATCH 02/44] Give advice to download script and run it vs. pulling repo then running --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9df469563..450f5d0bc 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The following prerequisities can be installed with the setup script `scripts/set - Android setup ([Android Studio](https://developer.android.com/studio) and subsequent dependencies) ### Scripted setup -`scripts/setup.sh` is provided as a tool to set up a stock Ubuntu 20.04 installation for building. This script should skip the entire [Manual setup](#manual-setup) section below and prepare you for [running](#running) +[`scripts/setup.sh`](https://github.com/cypherstack/stack_wallet/blob/main/scripts/setup.sh) is provided as a tool to set up a stock Ubuntu 20.04 installation for building: download the script and run it anywhere. This script should skip the entire [Manual setup](#manual-setup) section below and prepare you for [running](#running). It will set up the stack_wallet repository in `~/projects/stack_wallet` and build it there. ### Manual setup After installing the prerequisites listed above, download the code and init the submodules From 832804606cf6115b57b2677cea8fd8bd39705cb5 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 6 Oct 2022 17:25:29 -0500 Subject: [PATCH 03/44] Be more specific about Android Studio configuration --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 450f5d0bc..8cb767010 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ sudo apt install -y openjdk-11-jdk sudo snap install android-studio --classic ``` -Use Tools > SDK Manager to install the Android SDK, NDK, Android SDK command line tools, and cmake +Use Tools > SDK Manager to install the SDK Tools > Android SDK (API 30), SDK Tools > NDK, SDK Tools > Android SDK command line tools, and SDK Tools > CMake Then install the Flutter plugin. In Android Studio's options for the Flutter language, enable auto format on save to match the project's code style From 1d205d274898b21f27fbf33b0bac4ef1a45c2c40 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 6 Oct 2022 18:39:33 -0500 Subject: [PATCH 04/44] Note to restart the IDE --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cb767010..320234a87 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,6 @@ sudo snap install android-studio --classic Use Tools > SDK Manager to install the SDK Tools > Android SDK (API 30), SDK Tools > NDK, SDK Tools > Android SDK command line tools, and SDK Tools > CMake -Then install the Flutter plugin. In Android Studio's options for the Flutter language, enable auto format on save to match the project's code style +Then install the Flutter plugin and restart the IDE. In Android Studio's options for the Flutter language, enable auto format on save to match the project's code style Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation From 33f3cc0c0b25fc98c8dc6e1fb95be9366cc89acc Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 6 Oct 2022 19:48:25 -0500 Subject: [PATCH 05/44] Dart SDK tip --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 320234a87..37321c848 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,6 @@ sudo snap install android-studio --classic Use Tools > SDK Manager to install the SDK Tools > Android SDK (API 30), SDK Tools > NDK, SDK Tools > Android SDK command line tools, and SDK Tools > CMake -Then install the Flutter plugin and restart the IDE. In Android Studio's options for the Flutter language, enable auto format on save to match the project's code style +Then install the Flutter plugin and restart the IDE. In Android Studio's options for the Flutter language, enable auto format on save to match the project's code style. If you have problems with the Dart SDK, make sure to run `flutter` in a terminal to download it (use `source ~/.bashrc` to update your environment variables if you're still using the same terminal from which you ran `setup.sh`) Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation From 297204d200f630e591929d680a06992e965c0eb3 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 6 Oct 2022 20:01:19 -0500 Subject: [PATCH 06/44] don't call prebuild.sh, just do what it does --- scripts/setup.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index aad8cccaa..f65e6640f 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -25,10 +25,12 @@ cd stack_wallet export STACK_WALLET=$(pwd) git submodule update --init --recursive -# create template lib/external_api_keys.dart file if it doesn't already exist -cd $STACK_WALLET -cd scripts -./prebuild.sh +# Create template lib/external_api_keys.dart file if it doesn't already exist +KEYS="$HOME/projects/stack_wallet/lib/external_api_keys.dart" +if ! test -f "$KEYS"; then + echo 'prebuild.sh: creating template lib/external_api_keys.dart file' + echo 'const kChangeNowApiKey = "";' > $KEYS +fi #install stack wallet dependencies sudo apt-get install -y unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake openjdk-8-jre-headless libgit2-dev clang libncurses5-dev libncursesw5-dev zlib1g-dev llvm From 764c66ee084e7c5f427bfd797aac4b604bd480e1 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 12 Oct 2022 18:09:17 -0600 Subject: [PATCH 07/44] fix ui bug where chosen fee field doesnt show the updated user fee --- lib/pages/send_view/send_view.dart | 6 ++ .../transaction_fee_selection_sheet.dart | 56 +++++++++++++++++++ .../coins/wownero/wownero_wallet.dart | 2 +- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 25264e19c..17dd9219d 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -1319,6 +1319,12 @@ class _SendViewState extends ConsumerState { cryptoAmountController .text) ?? Decimal.zero, + updateChosen: (String fee) { + setState(() { + _calculateFeesFuture = + Future(() => fee); + }); + }, ), ); }, diff --git a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart index 05644cf70..982086d3c 100644 --- a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart +++ b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart @@ -32,10 +32,12 @@ class TransactionFeeSelectionSheet extends ConsumerStatefulWidget { Key? key, required this.walletId, required this.amount, + required this.updateChosen, }) : super(key: key); final String walletId; final Decimal amount; + final Function updateChosen; @override ConsumerState createState() => @@ -223,6 +225,10 @@ class _TransactionFeeSelectionSheetState ref.read(feeRateTypeStateProvider.state).state = FeeRateType.fast; } + String? fee = getAmount(FeeRateType.fast); + if (fee != null) { + widget.updateChosen(fee); + } Navigator.of(context).pop(); }, child: Container( @@ -352,6 +358,10 @@ class _TransactionFeeSelectionSheetState ref.read(feeRateTypeStateProvider.state).state = FeeRateType.average; } + String? fee = getAmount(FeeRateType.average); + if (fee != null) { + widget.updateChosen(fee); + } Navigator.of(context).pop(); }, child: Container( @@ -479,6 +489,11 @@ class _TransactionFeeSelectionSheetState ref.read(feeRateTypeStateProvider.state).state = FeeRateType.slow; } + String? fee = getAmount(FeeRateType.slow); + print("fee $fee"); + if (fee != null) { + widget.updateChosen(fee); + } Navigator.of(context).pop(); }, child: Container( @@ -608,4 +623,45 @@ class _TransactionFeeSelectionSheetState ), ); } + + String? getAmount(FeeRateType feeRateType) { + try { + print(feeRateType); + var amount = Format.decimalAmountToSatoshis(this.amount); + print(amount); + print(ref.read(feeSheetSessionCacheProvider).fast); + print(ref.read(feeSheetSessionCacheProvider).average); + print(ref.read(feeSheetSessionCacheProvider).slow); + switch (feeRateType) { + case FeeRateType.fast: + if (ref.read(feeSheetSessionCacheProvider).fast[amount] != null) { + return (ref.read(feeSheetSessionCacheProvider).fast[amount] + as Decimal) + .toString(); + } + return null; + + case FeeRateType.average: + if (ref.read(feeSheetSessionCacheProvider).average[amount] != null) { + return (ref.read(feeSheetSessionCacheProvider).average[amount] + as Decimal) + .toString(); + } + return null; + + case FeeRateType.slow: + print(ref.read(feeSheetSessionCacheProvider).slow); + print(ref.read(feeSheetSessionCacheProvider).slow[amount]); + if (ref.read(feeSheetSessionCacheProvider).slow[amount] != null) { + return (ref.read(feeSheetSessionCacheProvider).slow[amount] + as Decimal) + .toString(); + } + return null; + } + } catch (e, s) { + print("$e $s"); + return null; + } + } } diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index afdc49117..d3aba5bbb 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1558,7 +1558,7 @@ class WowneroWallet extends CoinServiceAPI { "WW3iVcnoAY6K9zNdU4qmdvZELefx6xZz4PMpTwUifRkvMQckyadhSPYMVPJhBdYE8P9c27fg9RPmVaWNFx1cDaj61HnetqBiy", satoshiAmount: satoshiAmount, args: {"feeRate": feeRateType}))['fee']; - await Future.delayed(const Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 500)); } catch (e, s) { aprox = -9999999999999999; } From 3c29b9acdf752aa3f4d7b03c5090d794ab2d7003 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 13 Oct 2022 13:01:49 -0600 Subject: [PATCH 08/44] temp fix for firo infinite fee estimate --- lib/services/coins/firo/firo_wallet.dart | 80 ++++++++++++++++-------- 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index aafa5e6f2..3a925f015 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -4493,6 +4493,7 @@ class FiroWallet extends CoinServiceAPI { } } + // TODO: investigate the bug here where chosen is null, conditions, given one mint spendVal += chosen!.amount; coinsToSpend.insert(coinsToSpend.length, chosen); } @@ -4514,36 +4515,61 @@ class FiroWallet extends CoinServiceAPI { Future estimateJoinSplitFee( int spendAmount, ) async { - int fee; - int size; - - for (fee = 0;;) { - int currentRequired = spendAmount; - - var map = await getCoinsToJoinSplit(currentRequired); - if (map is bool && !map) { - return 0; - } - - List coinsToBeSpent = - map['coinsToSpend'] as List; - - // 1054 is constant part, mainly Schnorr and Range proofs, 2560 is for each sigma/aux data - // 179 other parts of tx, assuming 1 utxo and 1 jmint - size = 1054 + 2560 * coinsToBeSpent.length + 180; - // uint64_t feeNeeded = GetMinimumFee(size, DEFAULT_TX_CONFIRM_TARGET); - int feeNeeded = - size; //TODO(Levon) temporary, use real estimation methods here - - if (fee >= feeNeeded) { - break; - } - - fee = feeNeeded; + var lelantusEntry = await _getLelantusEntry(); + final balance = await availableBalance; + int spendAmount = + (balance * Decimal.fromInt(Constants.satsPerCoin)).toBigInt().toInt(); + if (spendAmount == 0 || lelantusEntry.isEmpty) { + return LelantusFeeData(0, 0, []).fee; } + ReceivePort receivePort = await getIsolate({ + "function": "estimateJoinSplit", + "spendAmount": spendAmount, + "subtractFeeFromAmount": true, + "lelantusEntries": lelantusEntry, + "coin": coin, + }); - return fee; + final message = await receivePort.first; + if (message is String) { + Logging.instance.log("this is a string", level: LogLevel.Error); + stop(receivePort); + throw Exception("_fetchMaxFee isolate failed"); + } + stop(receivePort); + Logging.instance.log('Closing estimateJoinSplit!', level: LogLevel.Info); + return (message as LelantusFeeData).fee; } + // int fee; + // int size; + // + // for (fee = 0;;) { + // int currentRequired = spendAmount; + // + // TODO: investigate the bug here + // var map = await getCoinsToJoinSplit(currentRequired); + // if (map is bool && !map) { + // return 0; + // } + // + // List coinsToBeSpent = + // map['coinsToSpend'] as List; + // + // // 1054 is constant part, mainly Schnorr and Range proofs, 2560 is for each sigma/aux data + // // 179 other parts of tx, assuming 1 utxo and 1 jmint + // size = 1054 + 2560 * coinsToBeSpent.length + 180; + // // uint64_t feeNeeded = GetMinimumFee(size, DEFAULT_TX_CONFIRM_TARGET); + // int feeNeeded = + // size; //TODO(Levon) temporary, use real estimation methods here + // + // if (fee >= feeNeeded) { + // break; + // } + // + // fee = feeNeeded; + // } + // + // return fee; @override Future estimateFeeFor(int satoshiAmount, int feeRate) async { From a30ee6f32980994e3b7384f7d59cb095d97dae09 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 13 Oct 2022 13:31:24 -0600 Subject: [PATCH 09/44] increase firo gap check to 50 from 20 --- .../restore_wallet_view.dart | 2 +- .../helpers/restore_create_backup.dart | 2 +- .../sub_widgets/restoring_wallet_card.dart | 19 ++++++++++++++----- .../wallet_network_settings_view.dart | 10 +++++++++- .../services/coins/firo/firo_wallet_test.dart | 4 ++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart index 68f116a95..def0724b5 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart @@ -275,7 +275,7 @@ class _RestoreWalletViewState extends ConsumerState { // without using them await manager.recoverFromMnemonic( mnemonic: mnemonic, - maxUnusedAddressGap: 20, + maxUnusedAddressGap: widget.coin == Coin.firo ? 50 : 20, maxNumberOfIndexesToCheck: 1000, height: height, ); diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart index bf964fec4..9c75f36e6 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart @@ -402,7 +402,7 @@ abstract class SWB { // without using them await manager.recoverFromMnemonic( mnemonic: mnemonic, - maxUnusedAddressGap: 20, + maxUnusedAddressGap: manager.coin == Coin.firo ? 50 : 20, maxNumberOfIndexesToCheck: 1000, height: restoreHeight, ); diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart index 8f9890a6a..55f0588d2 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart @@ -35,7 +35,8 @@ class _RestoringWalletCardState extends ConsumerState { case StackRestoringStatus.waiting: return SvgPicture.asset( Assets.svg.loader, - color: Theme.of(context).extension()!.buttonBackSecondary, + color: + Theme.of(context).extension()!.buttonBackSecondary, ); case StackRestoringStatus.restoring: return const LoadingIndicator(); @@ -95,7 +96,10 @@ class _RestoringWalletCardState extends ConsumerState { try { final mnemonicList = await manager.mnemonic; - const maxUnusedAddressGap = 20; + int maxUnusedAddressGap = 20; + if (coin == Coin.firo) { + maxUnusedAddressGap = 50; + } const maxNumberOfIndexesToCheck = 1000; if (mnemonicList.isEmpty) { @@ -155,14 +159,17 @@ class _RestoringWalletCardState extends ConsumerState { ? Container( height: 20, decoration: BoxDecoration( - color: Theme.of(context).extension()!.buttonBackSecondary, + color: Theme.of(context) + .extension()! + .buttonBackSecondary, borderRadius: BorderRadius.circular( 1000, ), ), child: RawMaterialButton( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - splashColor: Theme.of(context).extension()!.highlight, + splashColor: + Theme.of(context).extension()!.highlight, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 1000, @@ -187,7 +194,9 @@ class _RestoringWalletCardState extends ConsumerState { child: Text( "Show recovery phrase", style: STextStyles.infoSmall(context).copyWith( - color: Theme.of(context).extension()!.accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark), ), ), ), 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 c4045dc9b..5b1c57214 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 @@ -77,7 +77,8 @@ class _WalletNetworkSettingsViewState Future _attemptRescan() async { if (!Platform.isLinux) Wakelock.enable(); - const int maxUnusedAddressGap = 20; + int maxUnusedAddressGap = 20; + const int maxNumberOfIndexesToCheck = 1000; showDialog( @@ -88,6 +89,13 @@ class _WalletNetworkSettingsViewState ); try { + if (ref + .read(walletsChangeNotifierProvider) + .getManager(widget.walletId) + .coin == + Coin.firo) { + maxUnusedAddressGap = 50; + } await ref .read(walletsChangeNotifierProvider) .getManager(widget.walletId) diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index b309044b8..22a505adf 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -3283,9 +3283,9 @@ void main() { "a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w", ]); - expect(await firo.maxFee, 1234); // ??? + expect(await firo.maxFee, 0); // ??? - expect(await firo.balanceMinusMaxFee, Decimal.parse("-0.00001234")); + expect(await firo.balanceMinusMaxFee, Decimal.parse("0")); }); test("wallet balance minus maxfee - wallet balance is not zero", () async { From 3bd0fca7378b71c13b0441626f16e32724f664de Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 13 Oct 2022 16:19:25 -0600 Subject: [PATCH 10/44] fix stack backup saving issues. android 10 still not working --- .../stack_backup_views/helpers/stack_file_system.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart index 3196938da..e57c5493f 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/stack_file_system.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:permission_handler/permission_handler.dart'; class StackFileSystem { Directory? rootPath; @@ -14,6 +15,9 @@ class StackFileSystem { final bool isDesktop = !(Platform.isAndroid || Platform.isIOS); Future prepareStorage() async { + if (Platform.isAndroid) { + await Permission.storage.request(); + } rootPath = (await getApplicationDocumentsDirectory()); debugPrint(rootPath!.absolute.toString()); if (Platform.isAndroid) { @@ -22,13 +26,13 @@ class StackFileSystem { debugPrint(rootPath!.absolute.toString()); Directory sampleFolder = - Directory('${rootPath!.path}/Documents/Stack_backups'); + Directory('${rootPath!.path}Documents/Stack_backups'); if (Platform.isIOS) { sampleFolder = Directory(rootPath!.path); } try { if (!sampleFolder.existsSync()) { - sampleFolder.createSync(); + sampleFolder.createSync(recursive: true); } } catch (e, s) { debugPrint("$e $s"); @@ -65,8 +69,7 @@ class StackFileSystem { result = await FilePicker.platform.pickFiles( dialogTitle: "Load backup file", initialDirectory: startPath!.path, - type: FileType.custom, - allowedExtensions: ['bin'], + type: FileType.any, allowCompression: false, lockParentWindow: true, ); From 907f55a418afd2dcb19a31ac9ce53c09d0b3f16e Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 14 Oct 2022 11:30:36 -0600 Subject: [PATCH 11/44] fixed rate currency selection ui update fix --- lib/models/exchange/exchange_form_state.dart | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/models/exchange/exchange_form_state.dart b/lib/models/exchange/exchange_form_state.dart index 892149f3f..4568dc6c9 100644 --- a/lib/models/exchange/exchange_form_state.dart +++ b/lib/models/exchange/exchange_form_state.dart @@ -5,6 +5,7 @@ import 'package:stackwallet/models/exchange/response_objects/currency.dart'; import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.dart'; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart'; +import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; import 'package:stackwallet/services/exchange/exchange.dart'; import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart'; import 'package:stackwallet/utilities/logger.dart'; @@ -41,12 +42,24 @@ class ExchangeFormState extends ChangeNotifier { Currency? _from; Currency? _to; + @override + String toString() { + return 'ExchangeFormState: {_exchange: $_exchange, _exchangeType: $_exchangeType, reversed: $reversed, fromAmount: $fromAmount, toAmount: $toAmount, minAmount: $minAmount, maxAmount: $maxAmount, rate: $rate, estimate: $estimate, _market: $_market, _from: $_from, _to: $_to, _onError: $_onError}'; + } + String? get fromTicker { switch (exchangeType) { case ExchangeRateType.estimated: return _from?.ticker; case ExchangeRateType.fixed: - return _market?.from; + switch (exchange?.name) { + case SimpleSwapExchange.exchangeName: + return _from?.ticker; + case ChangeNowExchange.exchangeName: + return market?.from; + default: + return null; + } } } @@ -55,7 +68,14 @@ class ExchangeFormState extends ChangeNotifier { case ExchangeRateType.estimated: return _to?.ticker; case ExchangeRateType.fixed: - return _market?.to; + switch (exchange?.name) { + case SimpleSwapExchange.exchangeName: + return _to?.ticker; + case ChangeNowExchange.exchangeName: + return market?.to; + default: + return null; + } } } From b7d8e5db637b16471608ac9b968465ecb456ea57 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 14 Oct 2022 11:41:10 -0600 Subject: [PATCH 12/44] exchange swap currency fix --- lib/models/exchange/exchange_form_state.dart | 28 +++++++------- lib/pages/exchange_view/exchange_form.dart | 39 ++++++++------------ 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/lib/models/exchange/exchange_form_state.dart b/lib/models/exchange/exchange_form_state.dart index 4568dc6c9..72d84e2a9 100644 --- a/lib/models/exchange/exchange_form_state.dart +++ b/lib/models/exchange/exchange_form_state.dart @@ -395,24 +395,22 @@ class ExchangeFormState extends ChangeNotifier { minAmount = null; maxAmount = null; - switch (exchangeType) { - case ExchangeRateType.estimated: - final Currency? newTo = from; - final Currency? newFrom = to; + if (exchangeType == ExchangeRateType.fixed && + exchange?.name == ChangeNowExchange.exchangeName) { + await updateMarket(market, false); + } else { + final Currency? newTo = from; + final Currency? newFrom = to; - _to = newTo; - _from = newFrom; + _to = newTo; + _from = newFrom; - await updateRanges(shouldNotifyListeners: false); + await updateRanges(shouldNotifyListeners: false); - await updateEstimate( - shouldNotifyListeners: false, - reversed: reversed, - ); - break; - case ExchangeRateType.fixed: - await updateMarket(market, false); - break; + await updateEstimate( + shouldNotifyListeners: false, + reversed: reversed, + ); } notifyListeners(); diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index 4085ed401..045170952 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -294,33 +294,24 @@ class _ExchangeFormState extends ConsumerState { ); if (ref.read(prefsChangeNotifierProvider).exchangeRateType == - ExchangeRateType.estimated) { - await ref.read(exchangeFormStateProvider).swap(); - } else { - switch (ref.read(currentExchangeNameStateProvider.state).state) { - case ChangeNowExchange.exchangeName: - final from = ref.read(exchangeFormStateProvider).fromTicker; - final to = ref.read(exchangeFormStateProvider).toTicker; + ExchangeRateType.fixed && + ref.read(exchangeFormStateProvider).exchange?.name == + ChangeNowExchange.exchangeName) { + final from = ref.read(exchangeFormStateProvider).fromTicker; + final to = ref.read(exchangeFormStateProvider).toTicker; - if (to != null && from != null) { - final markets = ref - .read(availableChangeNowCurrenciesProvider) - .markets - .where((e) => e.from == to && e.to == from); + if (to != null && from != null) { + final markets = ref + .read(availableChangeNowCurrenciesProvider) + .markets + .where((e) => e.from == to && e.to == from); - if (markets.isNotEmpty) { - await ref - .read(exchangeFormStateProvider) - .swap(market: markets.first); - } - } - break; - case SimpleSwapExchange.exchangeName: - await ref.read(exchangeFormStateProvider).swap(); - break; - default: - // + if (markets.isNotEmpty) { + await ref.read(exchangeFormStateProvider).swap(market: markets.first); + } } + } else { + await ref.read(exchangeFormStateProvider).swap(); } if (mounted) { Navigator.of(context).pop(); From cd40c9f0f9c29430cc523e8796796457d871c84e Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Fri, 14 Oct 2022 12:20:43 -0600 Subject: [PATCH 13/44] change build --- ios/Runner.xcodeproj/project.pbxproj | 14 +++++++------- pubspec.yaml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 98c80851c..356e1aa28 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -451,7 +451,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 72; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -505,7 +505,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.4.48; + MARKETING_VERSION = 1.5.2; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -635,7 +635,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 72; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -689,7 +689,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.4.48; + MARKETING_VERSION = 1.5.2; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -711,7 +711,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 63; + CURRENT_PROJECT_VERSION = 72; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -765,7 +765,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.4.48; + MARKETING_VERSION = 1.5.2; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/pubspec.yaml b/pubspec.yaml index 829143345..9d3205b72 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.1+71 +version: 1.5.2+72 environment: sdk: ">=2.17.0 <3.0.0" From 8f2567f340522c0a13f318660dfcdcd230ca43e9 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 14 Oct 2022 12:21:00 -0600 Subject: [PATCH 14/44] can exchange check updated --- lib/models/exchange/exchange_form_state.dart | 24 +++++++++---------- lib/pages/exchange_view/exchange_form.dart | 6 +++++ .../exchange/simpleswap/simpleswap_api.dart | 9 +++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/models/exchange/exchange_form_state.dart b/lib/models/exchange/exchange_form_state.dart index 72d84e2a9..645642b9d 100644 --- a/lib/models/exchange/exchange_form_state.dart +++ b/lib/models/exchange/exchange_form_state.dart @@ -115,18 +115,18 @@ class ExchangeFormState extends ChangeNotifier { String get toAmountString => toAmount?.toStringAsFixed(8) ?? ""; bool get canExchange { - switch (exchangeType) { - case ExchangeRateType.estimated: - return fromAmount != null && - fromAmount != Decimal.zero && - toAmount != null && - rate != null && - warning.isEmpty; - case ExchangeRateType.fixed: - return _market != null && - fromAmount != null && - toAmount != null && - warning.isEmpty; + if (exchange?.name == ChangeNowExchange.exchangeName && + exchangeType == ExchangeRateType.fixed) { + return _market != null && + fromAmount != null && + toAmount != null && + warning.isEmpty; + } else { + return fromAmount != null && + fromAmount != Decimal.zero && + toAmount != null && + rate != null && + warning.isEmpty; } } diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index 045170952..d5fa29b62 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -24,6 +24,7 @@ import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dar import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.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/custom_loading_overlay.dart'; @@ -308,6 +309,11 @@ class _ExchangeFormState extends ConsumerState { if (markets.isNotEmpty) { await ref.read(exchangeFormStateProvider).swap(market: markets.first); + } else { + Logging.instance.log( + "swap to fixed rate market failed", + level: LogLevel.Warning, + ); } } } else { diff --git a/lib/services/exchange/simpleswap/simpleswap_api.dart b/lib/services/exchange/simpleswap/simpleswap_api.dart index addf732de..3d626b2eb 100644 --- a/lib/services/exchange/simpleswap/simpleswap_api.dart +++ b/lib/services/exchange/simpleswap/simpleswap_api.dart @@ -32,17 +32,22 @@ class SimpleSwapAPI { Future _makeGetRequest(Uri uri) async { final client = this.client ?? http.Client(); + int code = -1; try { final response = await client.get( uri, ); + code = response.statusCode; + final parsed = jsonDecode(response.body); return parsed; } catch (e, s) { - Logging.instance - .log("_makeRequest($uri) threw: $e\n$s", level: LogLevel.Error); + Logging.instance.log( + "_makeRequest($uri) HTTP:$code threw: $e\n$s", + level: LogLevel.Error, + ); rethrow; } } From 6245f0f23260a88eae3f4070b6a70b15933467c2 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Fri, 14 Oct 2022 18:48:00 -0500 Subject: [PATCH 15/44] Add template/default SimpleSwap API key const a --- scripts/prebuild.sh | 2 +- scripts/setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 scripts/prebuild.sh diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh old mode 100644 new mode 100755 index 31acfa82c..d24076666 --- a/scripts/prebuild.sh +++ b/scripts/prebuild.sh @@ -2,5 +2,5 @@ KEYS=../lib/external_api_keys.dart if ! test -f "$KEYS"; then echo 'prebuild.sh: creating template lib/external_api_keys.dart file' - echo 'const kChangeNowApiKey = "";' > $KEYS + printf 'const kChangeNowApiKey = "";\nconst kSimpleSwapApiKey = "";' > $KEYS fi diff --git a/scripts/setup.sh b/scripts/setup.sh index f65e6640f..5525d7814 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -29,7 +29,7 @@ git submodule update --init --recursive KEYS="$HOME/projects/stack_wallet/lib/external_api_keys.dart" if ! test -f "$KEYS"; then echo 'prebuild.sh: creating template lib/external_api_keys.dart file' - echo 'const kChangeNowApiKey = "";' > $KEYS + printf 'const kChangeNowApiKey = "";\nconst kSimpleSwapApiKey = "";' > $KEYS fi #install stack wallet dependencies From b4b9e09a0e3c7796fef0bb9b9d124ebcc5ed75e4 Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 15 Oct 2022 11:57:00 -0600 Subject: [PATCH 16/44] firo mint notification description --- lib/services/coins/firo/firo_wallet.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 3a925f015..af3d93445 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -2040,7 +2040,8 @@ class FiroWallet extends CoinServiceAPI { case "Sent": unawaited( NotificationApi.showNotification( - title: "Outgoing transaction", + title: + tx.subType == "mint" ? "Anonymizing" : "Outgoing transaction", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), @@ -2076,7 +2077,9 @@ class FiroWallet extends CoinServiceAPI { } else if (tx.txType == "Sent" && tx.subType == "join") { unawaited( NotificationApi.showNotification( - title: "Outgoing transaction confirmed", + title: tx.subType == "mint" + ? "Anonymized" + : "Outgoing transaction confirmed", body: walletName, walletId: walletId, iconAssetName: Assets.svg.iconFor(coin: coin), From 5f804b3e69a8e41d2dfc1a9d752048374700f0bf Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 15 Oct 2022 14:25:14 -0600 Subject: [PATCH 17/44] hide fiat currency picker when in incognito and calls are broken --- lib/pages/send_view/send_view.dart | 206 +++++++++++++++-------------- lib/pages/stack_privacy_calls.dart | 8 +- 2 files changed, 108 insertions(+), 106 deletions(-) diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 17dd9219d..5e689a580 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -27,6 +27,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/animated_text.dart'; @@ -1107,115 +1108,120 @@ class _SendViewState extends ConsumerState { ), ), ), - const SizedBox( - height: 8, - ), - TextField( - style: STextStyles.smallMed14(context).copyWith( - color: Theme.of(context) - .extension()! - .textDark, + if (Prefs.instance.externalCalls) + const SizedBox( + height: 8, ), - key: const Key("amountInputFieldFiatTextFieldKey"), - controller: baseAmountController, - focusNode: _baseFocus, - keyboardType: const TextInputType.numberWithOptions( - signed: false, - decimal: true, - ), - textAlign: TextAlign.right, - inputFormatters: [ - // regex to validate a fiat amount with 2 decimal places - TextInputFormatter.withFunction((oldValue, - newValue) => - RegExp(r'^([0-9]*[,.]?[0-9]{0,2}|[,.][0-9]{0,2})$') - .hasMatch(newValue.text) - ? newValue - : oldValue), - ], - onChanged: (baseAmountString) { - if (baseAmountString.isNotEmpty && - baseAmountString != "." && - baseAmountString != ",") { - final baseAmount = baseAmountString.contains(",") - ? Decimal.parse( - baseAmountString.replaceFirst(",", ".")) - : Decimal.parse(baseAmountString); + if (Prefs.instance.externalCalls) + TextField( + style: STextStyles.smallMed14(context).copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + key: const Key("amountInputFieldFiatTextFieldKey"), + controller: baseAmountController, + focusNode: _baseFocus, + keyboardType: const TextInputType.numberWithOptions( + signed: false, + decimal: true, + ), + textAlign: TextAlign.right, + inputFormatters: [ + // regex to validate a fiat amount with 2 decimal places + TextInputFormatter.withFunction((oldValue, + newValue) => + RegExp(r'^([0-9]*[,.]?[0-9]{0,2}|[,.][0-9]{0,2})$') + .hasMatch(newValue.text) + ? newValue + : oldValue), + ], + onChanged: (baseAmountString) { + if (baseAmountString.isNotEmpty && + baseAmountString != "." && + baseAmountString != ",") { + final baseAmount = baseAmountString + .contains(",") + ? Decimal.parse( + baseAmountString.replaceFirst(",", ".")) + : Decimal.parse(baseAmountString); - var _price = ref - .read(priceAnd24hChangeNotifierProvider) - .getPrice(coin) - .item1; + var _price = ref + .read(priceAnd24hChangeNotifierProvider) + .getPrice(coin) + .item1; - if (_price == Decimal.zero) { - _amountToSend = Decimal.zero; + if (_price == Decimal.zero) { + _amountToSend = Decimal.zero; + } else { + _amountToSend = baseAmount <= Decimal.zero + ? Decimal.zero + : (baseAmount / _price).toDecimal( + scaleOnInfinitePrecision: + Constants.decimalPlaces); + } + if (_cachedAmountToSend != null && + _cachedAmountToSend == _amountToSend) { + return; + } + _cachedAmountToSend = _amountToSend; + Logging.instance.log( + "it changed $_amountToSend $_cachedAmountToSend", + level: LogLevel.Info); + + final amountString = + Format.localizedStringAsFixed( + value: _amountToSend!, + locale: ref + .read(localeServiceChangeNotifierProvider) + .locale, + decimalPlaces: Constants.decimalPlaces, + ); + + _cryptoAmountChangeLock = true; + cryptoAmountController.text = amountString; + _cryptoAmountChangeLock = false; } else { - _amountToSend = baseAmount <= Decimal.zero - ? Decimal.zero - : (baseAmount / _price).toDecimal( - scaleOnInfinitePrecision: - Constants.decimalPlaces); + _amountToSend = Decimal.zero; + _cryptoAmountChangeLock = true; + cryptoAmountController.text = ""; + _cryptoAmountChangeLock = false; } - if (_cachedAmountToSend != null && - _cachedAmountToSend == _amountToSend) { - return; - } - _cachedAmountToSend = _amountToSend; - Logging.instance.log( - "it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info); - - final amountString = - Format.localizedStringAsFixed( - value: _amountToSend!, - locale: ref - .read(localeServiceChangeNotifierProvider) - .locale, - decimalPlaces: Constants.decimalPlaces, - ); - - _cryptoAmountChangeLock = true; - cryptoAmountController.text = amountString; - _cryptoAmountChangeLock = false; - } else { - _amountToSend = Decimal.zero; - _cryptoAmountChangeLock = true; - cryptoAmountController.text = ""; - _cryptoAmountChangeLock = false; - } - // setState(() { - // _calculateFeesFuture = calculateFees( - // Format.decimalAmountToSatoshis( - // _amountToSend!)); - // }); - _updatePreviewButtonState(_address, _amountToSend); - }, - decoration: InputDecoration( - contentPadding: const EdgeInsets.only( - top: 12, - right: 12, - ), - hintText: "0", - hintStyle: STextStyles.fieldLabel(context).copyWith( - fontSize: 14, - ), - prefixIcon: FittedBox( - fit: BoxFit.scaleDown, - child: Padding( - padding: const EdgeInsets.all(12), - child: Text( - ref.watch(prefsChangeNotifierProvider - .select((value) => value.currency)), - style: STextStyles.smallMed14(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + // setState(() { + // _calculateFeesFuture = calculateFees( + // Format.decimalAmountToSatoshis( + // _amountToSend!)); + // }); + _updatePreviewButtonState( + _address, _amountToSend); + }, + decoration: InputDecoration( + contentPadding: const EdgeInsets.only( + top: 12, + right: 12, + ), + hintText: "0", + hintStyle: + STextStyles.fieldLabel(context).copyWith( + fontSize: 14, + ), + prefixIcon: FittedBox( + fit: BoxFit.scaleDown, + child: Padding( + padding: const EdgeInsets.all(12), + child: Text( + ref.watch(prefsChangeNotifierProvider + .select((value) => value.currency)), + style: STextStyles.smallMed14(context) + .copyWith( + color: Theme.of(context) + .extension()! + .accentColorDark), + ), ), ), ), ), - ), const SizedBox( height: 12, ), diff --git a/lib/pages/stack_privacy_calls.dart b/lib/pages/stack_privacy_calls.dart index 841dacf9e..6065c90dc 100644 --- a/lib/pages/stack_privacy_calls.dart +++ b/lib/pages/stack_privacy_calls.dart @@ -408,12 +408,11 @@ class ContinueButton extends StatelessWidget { .extension()! .getPrimaryEnabledButtonColor(context), onPressed: () { - print("Output of isEasy:"); - print(isEasy); - Prefs.instance.externalCalls = isEasy; if (!isSettings) { Navigator.of(context).pushNamed(CreatePinView.routeName); + } else { + Navigator.pop(context); } }, child: Text( @@ -429,9 +428,6 @@ class ContinueButton extends StatelessWidget { .extension()! .getPrimaryEnabledButtonColor(context), onPressed: () { - print("Output of isEasy:"); - print(isEasy); - Prefs.instance.externalCalls = isEasy; if (!isSettings) { From 49c252b7f153f9d5e3a067bded70ee2acdb6c11e Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 15 Oct 2022 14:32:17 -0600 Subject: [PATCH 18/44] watch variable so page can be refreshed correctly --- .../sub_widgets/wallet_list_item.dart | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart index 842b1f4c4..e3fd5d614 100644 --- a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart +++ b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart @@ -7,6 +7,7 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/format.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; @@ -67,6 +68,8 @@ class WalletListItem extends ConsumerWidget { builder: (_, ref, __) { final tuple = ref.watch(priceAnd24hChangeNotifierProvider .select((value) => value.getPrice(coin))); + final calls = + ref.watch(prefsChangeNotifierProvider).externalCalls; final priceString = Format.localizedStringAsFixed( value: tuple.item1, @@ -100,10 +103,11 @@ class WalletListItem extends ConsumerWidget { style: STextStyles.titleBold12(context), ), const Spacer(), - Text( - "$priceString $currency/${coin.ticker}", - style: STextStyles.itemSubtitle(context), - ), + if (calls) + Text( + "$priceString $currency/${coin.ticker}", + style: STextStyles.itemSubtitle(context), + ), ], ), const SizedBox( @@ -116,12 +120,13 @@ class WalletListItem extends ConsumerWidget { style: STextStyles.itemSubtitle(context), ), const Spacer(), - Text( - "${percentChange.toStringAsFixed(2)}%", - style: STextStyles.itemSubtitle(context).copyWith( - color: percentChangedColor, + if (calls) + Text( + "${percentChange.toStringAsFixed(2)}%", + style: STextStyles.itemSubtitle(context).copyWith( + color: percentChangedColor, + ), ), - ), ], ), ], From c7d4c4fc70aaf117abbeceb4f66632479e71e24b Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 15 Oct 2022 14:49:52 -0600 Subject: [PATCH 19/44] fix null error bug, firo restores faster again --- lib/services/coins/firo/firo_wallet.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 3a925f015..2b423a818 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -753,10 +753,11 @@ Future?> getInitialAnonymitySetCache( ); final response = jsonDecode(anonSetResult.body.toString()); + Logging.instance.log(response, level: LogLevel.Info); if (response['status'] == 'success') { final anonResponse = jsonDecode(response['result'] as String); - final setData = Map.from(anonResponse["result"] as Map); + final setData = Map.from(anonResponse as Map); return setData; } else { return null; From ac849c71fceee09da5e4c5235d219a76fc542085 Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 15 Oct 2022 14:54:00 -0600 Subject: [PATCH 20/44] should fix #109, for coins that dont exist --- .../helpers/restore_create_backup.dart | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart index 9c75f36e6..84dd2b5d9 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart @@ -997,10 +997,14 @@ abstract class SWB { // primary nodes if (primaryNodes != null) { for (var node in primaryNodes) { - await nodeService.setPrimaryNodeFor( - coin: coinFromPrettyName(node['coinName'] as String), - node: nodeService.getNodeById(id: node['id'] as String)!, - ); + try { + await nodeService.setPrimaryNodeFor( + coin: coinFromPrettyName(node['coinName'] as String), + node: nodeService.getNodeById(id: node['id'] as String)!, + ); + } catch (e, s) { + Logging.instance.log("$e $s", level: LogLevel.Error); + } } } await nodeService.updateDefaults(); @@ -1175,10 +1179,14 @@ abstract class SWB { } if (primaryNodes != null) { for (var node in primaryNodes) { - await nodeService.setPrimaryNodeFor( - coin: coinFromPrettyName(node['coinName'] as String), - node: nodeService.getNodeById(id: node['id'] as String)!, - ); + try { + await nodeService.setPrimaryNodeFor( + coin: coinFromPrettyName(node['coinName'] as String), + node: nodeService.getNodeById(id: node['id'] as String)!, + ); + } catch (e, s) { + Logging.instance.log("$e $s", level: LogLevel.Error); + } } } await nodeService.updateDefaults(); From d26ea4c284b199cd10c7b13ebde9e2933fe4f5b2 Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 15 Oct 2022 17:56:59 -0600 Subject: [PATCH 21/44] hide exchange options until amount is entered --- lib/pages/exchange_view/exchange_form.dart | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index d5fa29b62..785fae49e 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -1308,20 +1308,24 @@ class _ExchangeFormState extends ConsumerState { RateTypeToggle( onChanged: onRateTypeChanged, ), - const SizedBox( - height: 8, - ), - ExchangeProviderOptions( - from: ref.watch(exchangeFormStateProvider).fromTicker, - to: ref.watch(exchangeFormStateProvider).toTicker, - fromAmount: ref.watch(exchangeFormStateProvider).fromAmount, - toAmount: ref.watch(exchangeFormStateProvider).toAmount, - fixedRate: ref.watch(prefsChangeNotifierProvider - .select((value) => value.exchangeRateType)) == - ExchangeRateType.fixed, - reversed: ref.watch( - exchangeFormStateProvider.select((value) => value.reversed)), - ), + if (ref.read(exchangeFormStateProvider).fromAmount != null && + ref.read(exchangeFormStateProvider).fromAmount != Decimal.zero) + const SizedBox( + height: 8, + ), + if (ref.read(exchangeFormStateProvider).fromAmount != null && + ref.read(exchangeFormStateProvider).fromAmount != Decimal.zero) + ExchangeProviderOptions( + from: ref.watch(exchangeFormStateProvider).fromTicker, + to: ref.watch(exchangeFormStateProvider).toTicker, + fromAmount: ref.watch(exchangeFormStateProvider).fromAmount, + toAmount: ref.watch(exchangeFormStateProvider).toAmount, + fixedRate: ref.watch(prefsChangeNotifierProvider + .select((value) => value.exchangeRateType)) == + ExchangeRateType.fixed, + reversed: ref.watch( + exchangeFormStateProvider.select((value) => value.reversed)), + ), const SizedBox( height: 12, ), From 3dd27d9b5313c945b005c47ab58101f76365cdbe Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 15 Oct 2022 18:03:58 -0600 Subject: [PATCH 22/44] fix bug for privacy settings --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index d01e0e2a7..04c48ae49 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -231,7 +231,7 @@ class _MaterialAppWithThemeState extends ConsumerState // unawaited(_nodeService.updateCommunityNodes()); // run without awaiting - if (Constants.enableExchange) { + if (Constants.enableExchange && _prefs.externalCalls) { unawaited(ExchangeDataLoadingService().loadAll(ref)); } From 45ebc0707d7ae8e18025c46cf603c0f400c05585 Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Sat, 15 Oct 2022 20:00:33 -0600 Subject: [PATCH 23/44] change build --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 9d3205b72..3bc356ec5 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.2+72 +version: 1.5.3+73 environment: sdk: ">=2.17.0 <3.0.0" From dd00e766230dd76720ee5061f51d7deb3d9156da Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 15 Oct 2022 20:47:59 -0600 Subject: [PATCH 24/44] red warnings not on 0 for exchange --- lib/models/exchange/exchange_form_state.dart | 8 ++++++-- lib/pages/exchange_view/exchange_form.dart | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/models/exchange/exchange_form_state.dart b/lib/models/exchange/exchange_form_state.dart index 645642b9d..2e237dd1c 100644 --- a/lib/models/exchange/exchange_form_state.dart +++ b/lib/models/exchange/exchange_form_state.dart @@ -92,7 +92,9 @@ class ExchangeFormState extends ChangeNotifier { String get warning { if (reversed) { if (toTicker != null && toAmount != null) { - if (minAmount != null && toAmount! < minAmount!) { + if (minAmount != null && + toAmount! < minAmount! && + toAmount! > Decimal.zero) { return "Minimum amount ${minAmount!.toString()} ${toTicker!.toUpperCase()}"; } else if (maxAmount != null && toAmount! > maxAmount!) { return "Maximum amount ${maxAmount!.toString()} ${toTicker!.toUpperCase()}"; @@ -100,7 +102,9 @@ class ExchangeFormState extends ChangeNotifier { } } else { if (fromTicker != null && fromAmount != null) { - if (minAmount != null && fromAmount! < minAmount!) { + if (minAmount != null && + fromAmount! < minAmount! && + fromAmount! > Decimal.zero) { return "Minimum amount ${minAmount!.toString()} ${fromTicker!.toUpperCase()}"; } else if (maxAmount != null && fromAmount! > maxAmount!) { return "Maximum amount ${maxAmount!.toString()} ${fromTicker!.toUpperCase()}"; diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index 785fae49e..7b04f90b3 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -572,14 +572,16 @@ class _ExchangeFormState extends ConsumerState { if (mounted) { Navigator.of(context).pop(); } - unawaited( - showFloatingFlushBar( - type: FlushBarType.warning, - message: - "Estimated rate trade pair \"$fromTicker-$toTicker\" unavailable. Reverting to last estimated rate pair.", - context: context, - ), - ); + if (!(fromTicker == "-" || toTicker == "-")) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: + "Estimated rate trade pair \"$fromTicker-$toTicker\" unavailable. Reverting to last estimated rate pair.", + context: context, + ), + ); + } break; case ExchangeRateType.fixed: if (!(toTicker == "-" || fromTicker == "-")) { From fd9b09d37a15cc5293ab518aa878ef48ca70ddfc Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 16 Oct 2022 12:54:52 -0600 Subject: [PATCH 25/44] show the balances when toggle switching --- .../wallet_balance_toggle_sheet.dart | 171 ++++++++++++++---- 1 file changed, 135 insertions(+), 36 deletions(-) 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 afdac6d8e..c9ff64393 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 @@ -1,3 +1,4 @@ +import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/providers/providers.dart'; @@ -8,6 +9,8 @@ import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; + class WalletBalanceToggleSheet extends ConsumerWidget { const WalletBalanceToggleSheet({ Key? key, @@ -23,6 +26,22 @@ class WalletBalanceToggleSheet extends ConsumerWidget { final coin = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId).coin)); + Future? totalBalanceFuture; + Future? availableBalanceFuture; + if (coin == Coin.firo || coin == Coin.firoTestNet) { + final firoWallet = ref + .watch(walletsChangeNotifierProvider + .select((value) => value.getManager(walletId))) + .wallet as FiroWallet; + totalBalanceFuture = firoWallet.availablePublicBalance(); + availableBalanceFuture = firoWallet.availablePrivateBalance(); + } else { + final wallet = ref.watch(walletsChangeNotifierProvider + .select((value) => value.getManager(walletId))); + totalBalanceFuture = wallet.totalBalance; + availableBalanceFuture = wallet.availableBalance; + } + return Container( decoration: BoxDecoration( color: Theme.of(context).extension()!.popupBG, @@ -125,15 +144,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget { const SizedBox( height: 2, ), - Text( - "Current spendable (unlocked) balance", - style: - STextStyles.itemSubtitle12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ), - ), + FutureBuilder( + future: availableBalanceFuture, + builder: (fbContext, + AsyncSnapshot snapshot) { + if (snapshot.connectionState == + ConnectionState.done && + snapshot.hasData && + snapshot.data != null) { + return Text( + "${snapshot.data!}", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } else { + return Text( + "", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } + }), ], ), if (coin == Coin.firo || coin == Coin.firoTestNet) @@ -147,15 +186,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget { const SizedBox( height: 2, ), - Text( - "Current private spendable (unlocked) balance", - style: - STextStyles.itemSubtitle12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ), - ), + FutureBuilder( + future: availableBalanceFuture, + builder: (fbContext, + AsyncSnapshot snapshot) { + if (snapshot.connectionState == + ConnectionState.done && + snapshot.hasData && + snapshot.data != null) { + return Text( + "${snapshot.data!}", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } else { + return Text( + "", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } + }), ], ), ], @@ -219,15 +278,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget { const SizedBox( height: 2, ), - Text( - "Total wallet balance", - style: - STextStyles.itemSubtitle12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ), - ), + FutureBuilder( + future: totalBalanceFuture, + builder: (fbContext, + AsyncSnapshot snapshot) { + if (snapshot.connectionState == + ConnectionState.done && + snapshot.hasData && + snapshot.data != null) { + return Text( + "${snapshot.data!}", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } else { + return Text( + "", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } + }), ], ), if (coin == Coin.firo || coin == Coin.firoTestNet) @@ -241,15 +320,35 @@ class WalletBalanceToggleSheet extends ConsumerWidget { const SizedBox( height: 2, ), - Text( - "Current public spendable (unlocked) balance", - style: - STextStyles.itemSubtitle12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ), - ), + FutureBuilder( + future: totalBalanceFuture, + builder: (fbContext, + AsyncSnapshot snapshot) { + if (snapshot.connectionState == + ConnectionState.done && + snapshot.hasData && + snapshot.data != null) { + return Text( + "${snapshot.data!}", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } else { + return Text( + "", + style: STextStyles.itemSubtitle12(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + ); + } + }), ], ), ], From cd14f899618ca04f12cb60055f8ade40afc775cf Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Sun, 16 Oct 2022 17:10:54 -0600 Subject: [PATCH 26/44] change build --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 356e1aa28..ea5b8b126 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -451,7 +451,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 74; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -505,7 +505,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.2; + MARKETING_VERSION = 1.5.4; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -635,7 +635,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 74; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -689,7 +689,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.2; + MARKETING_VERSION = 1.5.4; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -711,7 +711,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 74; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -765,7 +765,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.2; + MARKETING_VERSION = 1.5.4; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/pubspec.yaml b/pubspec.yaml index 3bc356ec5..a34e300a9 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.3+73 +version: 1.5.4+74 environment: sdk: ">=2.17.0 <3.0.0" From 3a2042eb9268be56d93c53e392f9aa29953e8c83 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 16 Oct 2022 17:40:33 -0600 Subject: [PATCH 27/44] quick fix for isar async write problem --- lib/utilities/logger.dart | 69 +++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/lib/utilities/logger.dart b/lib/utilities/logger.dart index 0771d5350..6a5083cbc 100644 --- a/lib/utilities/logger.dart +++ b/lib/utilities/logger.dart @@ -12,8 +12,7 @@ import 'package:stackwallet/utilities/enums/log_level_enum.dart'; export 'enums/log_level_enum.dart'; class Logging { - static const isArmLinux = - bool.fromEnvironment("IS_ARM"); + static const isArmLinux = bool.fromEnvironment("IS_ARM"); static final isTestEnv = Platform.environment["FLUTTER_TEST"] == "true"; Logging._(); static final Logging _instance = Logging._(); @@ -45,41 +44,47 @@ class Logging { core.bool printToConsole = true, core.bool printFullLength = false, }) { - if (isTestEnv || isArmLinux) { - Logger.print(object, normalLength: !printFullLength); - return; - } - final now = core.DateTime.now().toUtc(); - final log = Log() - ..message = object.toString() - ..logLevel = level - ..timestampInMillisUTC = now.millisecondsSinceEpoch; - if (level == LogLevel.Error || level == LogLevel.Fatal) { - printFullLength = true; - } + try { + if (isTestEnv || isArmLinux) { + Logger.print(object, normalLength: !printFullLength); + return; + } + final now = core.DateTime.now().toUtc(); + final log = Log() + ..message = object.toString() + ..logLevel = level + ..timestampInMillisUTC = now.millisecondsSinceEpoch; + if (level == LogLevel.Error || level == LogLevel.Fatal) { + printFullLength = true; + } - isar!.writeTxnSync(() => log.id = isar!.logs.putSync(log)); + isar!.writeTxnSync(() => log.id = isar!.logs.putSync(log)); - if (printToConsole) { - final core.String logStr = "Log: ${log.toString()}"; - final core.int logLength = logStr.length; + if (printToConsole) { + final core.String logStr = "Log: ${log.toString()}"; + final core.int logLength = logStr.length; - if (!printFullLength || logLength <= defaultPrintLength) { - debugPrint(logStr); - } else { - core.int start = 0; - core.int endIndex = defaultPrintLength; - core.int tmpLogLength = logLength; - while (endIndex < logLength) { - debugPrint(logStr.substring(start, endIndex)); - endIndex += defaultPrintLength; - start += defaultPrintLength; - tmpLogLength -= defaultPrintLength; - } - if (tmpLogLength > 0) { - debugPrint(logStr.substring(start, logLength)); + if (!printFullLength || logLength <= defaultPrintLength) { + debugPrint(logStr); + } else { + core.int start = 0; + core.int endIndex = defaultPrintLength; + core.int tmpLogLength = logLength; + while (endIndex < logLength) { + debugPrint(logStr.substring(start, endIndex)); + endIndex += defaultPrintLength; + start += defaultPrintLength; + tmpLogLength -= defaultPrintLength; + } + if (tmpLogLength > 0) { + debugPrint(logStr.substring(start, logLength)); + } } } + } catch (e, s) { + print("problem trying to log"); + print("$e $s"); + Logger.print(object); } } } From d8fa93b06b0820247323a7f13a819ce9a6d153ac Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 16 Oct 2022 20:23:48 -0600 Subject: [PATCH 28/44] default settings --- lib/utilities/prefs.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 7e1096550..cc818f982 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -546,7 +546,7 @@ class Prefs extends ChangeNotifier { boxName: DB.boxNamePrefs, key: "startupWalletId") as String?; } - bool _externalCalls = false; + bool _externalCalls = true; bool get externalCalls => _externalCalls; From 1e2f71cb6e7f6f5e30bfb9b5c35d1f4ca2eb8d45 Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Mon, 17 Oct 2022 08:29:41 -0600 Subject: [PATCH 29/44] change build --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index ea5b8b126..c76f92b0e 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -451,7 +451,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -505,7 +505,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.4; + MARKETING_VERSION = 1.5.5; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -635,7 +635,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -689,7 +689,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.4; + MARKETING_VERSION = 1.5.5; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -711,7 +711,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -765,7 +765,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.4; + MARKETING_VERSION = 1.5.5; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/pubspec.yaml b/pubspec.yaml index a34e300a9..f21127507 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.4+74 +version: 1.5.5+75 environment: sdk: ">=2.17.0 <3.0.0" From e984a7f09e8300c82446dc8f9459d63386696e8b Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Mon, 17 Oct 2022 09:21:45 -0600 Subject: [PATCH 30/44] change build --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f21127507..de8a71101 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.5+75 +version: 1.5.6+76 environment: sdk: ">=2.17.0 <3.0.0" From a62d8f49a82c6696c461a17760566f090b483367 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 13:42:10 -0600 Subject: [PATCH 31/44] load exchange data everytime on button or swipe to exchange screen --- lib/pages/home_view/home_view.dart | 13 ++++--- .../sub_widgets/home_view_button_bar.dart | 38 ++++--------------- lib/utilities/prefs.dart | 2 + 3 files changed, 16 insertions(+), 37 deletions(-) diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index 2bdcbace0..2e7c38202 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -16,15 +16,13 @@ import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/logger.dart'; +import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/utilities/logger.dart'; - -import 'package:stackwallet/utilities/prefs.dart'; - class HomeView extends ConsumerStatefulWidget { const HomeView({Key? key}) : super(key: key); @@ -45,7 +43,7 @@ class _HomeViewState extends ConsumerState { bool _exitEnabled = false; - final _cnLoadingService = ExchangeDataLoadingService(); + final _exchangeDataLoadingService = ExchangeDataLoadingService(); Future _onWillPop() async { // go to home view when tapping back on the main exchange view @@ -88,7 +86,7 @@ class _HomeViewState extends ConsumerState { // final externalCalls = Prefs.instance.externalCalls; if (externalCalls) { - _cnLoadingService.loadAll(ref); + _exchangeDataLoadingService.loadAll(ref); } else { Logging.instance.log("User does not want to use external calls", level: LogLevel.Info); @@ -290,6 +288,9 @@ class _HomeViewState extends ConsumerState { _ref.listen(homeViewPageIndexStateProvider, (previous, next) { if (next is int) { + if (next == 1) { + _loadCNData(); + } if (next >= 0 && next <= 1) { _pageController.animateToPage( next, diff --git a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart index e502d4537..61a6c4185 100644 --- a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart +++ b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/providers/providers.dart'; @@ -8,8 +6,6 @@ import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/utilities/prefs.dart'; - class HomeViewButtonBar extends ConsumerStatefulWidget { const HomeViewButtonBar({Key? key}) : super(key: key); @@ -18,8 +14,8 @@ class HomeViewButtonBar extends ConsumerStatefulWidget { } class _HomeViewButtonBarState extends ConsumerState { - final DateTime _lastRefreshed = DateTime.now(); - final Duration _refreshInterval = const Duration(hours: 1); + // final DateTime _lastRefreshed = DateTime.now(); + // final Duration _refreshInterval = const Duration(hours: 1); @override void initState() { @@ -104,34 +100,14 @@ class _HomeViewButtonBarState extends ConsumerState { if (selectedIndex != 1) { ref.read(homeViewPageIndexStateProvider.state).state = 1; } - DateTime now = DateTime.now(); - final _cnLoadingService = ExchangeDataLoadingService(); - final externalCalls = Prefs.instance.externalCalls; - if (!externalCalls) { + // DateTime now = DateTime.now(); + if (ref.read(prefsChangeNotifierProvider).externalCalls) { print("loading?"); - unawaited(_cnLoadingService.loadAll(ref)); - } - if (now.difference(_lastRefreshed) > _refreshInterval) { - // bool okPressed = false; - // showDialog( - // context: context, - // barrierDismissible: false, - // builder: (_) => const StackDialog( - // // builder: (_) => StackOkDialog( - // title: "Refreshing ChangeNOW data", - // message: "This may take a while", - // // onOkPressed: (value) { - // // if (value == "OK") { - // // okPressed = true; - // // } - // // }, - // ), - // ); await ExchangeDataLoadingService().loadAll(ref); - // if (!okPressed && mounted) { - // Navigator.of(context).pop(); - // } } + // if (now.difference(_lastRefreshed) > _refreshInterval) { + // await ExchangeDataLoadingService().loadAll(ref); + // } }, child: Text( "Exchange", diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index cc818f982..0109755f7 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -546,6 +546,8 @@ class Prefs extends ChangeNotifier { boxName: DB.boxNamePrefs, key: "startupWalletId") as String?; } + // incognito mode off by default + // allow external network calls such as exchange data and price info bool _externalCalls = true; bool get externalCalls => _externalCalls; From 78b6d096fe29164e887024cdaebeeb4524c20355 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 14:15:25 -0600 Subject: [PATCH 32/44] only save incognito setting on explicit button press --- lib/pages/stack_privacy_calls.dart | 404 ++++++++++++++--------------- 1 file changed, 201 insertions(+), 203 deletions(-) diff --git a/lib/pages/stack_privacy_calls.dart b/lib/pages/stack_privacy_calls.dart index 6065c90dc..2aa2a5c8a 100644 --- a/lib/pages/stack_privacy_calls.dart +++ b/lib/pages/stack_privacy_calls.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; +import 'package:stackwallet/pages_desktop_specific/create_password/create_password_view.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -12,9 +12,6 @@ import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/utilities/prefs.dart'; - class StackPrivacyCalls extends ConsumerStatefulWidget { const StackPrivacyCalls({ Key? key, @@ -31,19 +28,19 @@ class StackPrivacyCalls extends ConsumerStatefulWidget { class _StackPrivacyCalls extends ConsumerState { late final bool isDesktop; - bool isEasy = Prefs.instance.externalCalls; - final PageController _pageController = - PageController(initialPage: 0, keepPage: true); + late bool isEasy; + late bool infoToggle; @override void initState() { isDesktop = Util.isDesktop; + isEasy = ref.read(prefsChangeNotifierProvider).externalCalls; + infoToggle = isEasy; super.initState(); } @override void dispose() { - _pageController.dispose(); super.dispose(); } @@ -59,135 +56,161 @@ class _StackPrivacyCalls extends ConsumerState { ), ), body: SafeArea( - child: PageView( - controller: _pageController, - physics: const NeverScrollableScrollPhysics(), - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(0, 40, 0, 0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Choose your Stack experience", - style: STextStyles.pageTitleH1(context), - ), - const SizedBox( - height: 8, - ), - Text( - "You can change it later in Settings", - style: STextStyles.subtitle(context), - ), - const SizedBox( - height: 36, - ), - const Padding( - padding: EdgeInsets.symmetric( - horizontal: 16, - ), - child: PrivacyToggle(), - ), - const SizedBox( - height: 36, - ), - Padding( - padding: const EdgeInsets.all(16.0), - child: RoundedWhiteContainer( - child: Center( - child: RichText( - textAlign: TextAlign.left, - text: TextSpan( - style: STextStyles.label(context) - .copyWith(fontSize: 12.0), - children: ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - ) - ? [ - const TextSpan( - text: - "Exchange data preloaded for a seamless experience."), - const TextSpan( - text: - "\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."), - TextSpan( - text: - "\n\nRecommended for most crypto users.", - style: TextStyle( - color: Theme.of(context) - .extension()! - .textDark, - fontWeight: FontWeight.w600, - ), - ), - ] - : [ - const TextSpan( - text: - "Exchange data not preloaded (slower experience)."), - const TextSpan( - text: - "\n\nCoinGecko disabled (price changes not shown, no wallet value shown in other currencies)."), - TextSpan( - text: - "\n\nRecommended for the privacy conscious.", - style: TextStyle( - color: Theme.of(context) - .extension()! - .textDark, - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), + child: Padding( + padding: const EdgeInsets.fromLTRB(0, 40, 0, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Choose your Stack experience", + style: STextStyles.pageTitleH1(context), + ), + const SizedBox( + height: 8, + ), + Text( + "You can change it later in Settings", + style: STextStyles.subtitle(context), + ), + const SizedBox( + height: 36, + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), + child: PrivacyToggle( + externalCallsEnabled: isEasy, + onChanged: (externalCalls) { + isEasy = externalCalls; + setState(() { + infoToggle = isEasy; + }); + }, + ), + ), + const SizedBox( + height: 36, + ), + Padding( + padding: const EdgeInsets.all(16.0), + child: RoundedWhiteContainer( + child: Center( + child: RichText( + textAlign: TextAlign.left, + text: TextSpan( + style: + STextStyles.label(context).copyWith(fontSize: 12.0), + children: infoToggle + ? [ + const TextSpan( + text: + "Exchange data preloaded for a seamless experience."), + const TextSpan( + text: + "\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."), + TextSpan( + text: + "\n\nRecommended for most crypto users.", + style: TextStyle( + color: Theme.of(context) + .extension()! + .textDark, + fontWeight: FontWeight.w600, + ), + ), + ] + : [ + const TextSpan( + text: + "Exchange data not preloaded (slower experience)."), + const TextSpan( + text: + "\n\nCoinGecko disabled (price changes not shown, no wallet value shown in other currencies)."), + TextSpan( + text: + "\n\nRecommended for the privacy conscious.", + style: TextStyle( + color: Theme.of(context) + .extension()! + .textDark, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), - const Spacer( - flex: 4, - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16, - vertical: 16, - ), - child: Row( - children: [ - Expanded( - child: ContinueButton( - isDesktop: isDesktop, - isSettings: widget.isSettings, - isEasy: ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - ), - ), - ), - ], - ), - ), - ], + ), ), - ), - ], + const Spacer( + flex: 4, + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 16, + ), + child: Row( + children: [ + Expanded( + child: ContinueButton( + isDesktop: isDesktop, + label: !widget.isSettings ? "Continue" : "Save changes", + onPressed: () { + ref.read(prefsChangeNotifierProvider).externalCalls = + isEasy; + if (!widget.isSettings) { + if (isDesktop) { + Navigator.of(context).pushNamed( + CreatePasswordView.routeName, + ); + } else { + Navigator.of(context).pushNamed( + CreatePinView.routeName, + ); + } + } else { + Navigator.pop(context); + } + }, + ), + ), + ], + ), + ), + ], + ), ), ), ); } } -class PrivacyToggle extends ConsumerStatefulWidget { - const PrivacyToggle({Key? key}) : super(key: key); +class PrivacyToggle extends StatefulWidget { + const PrivacyToggle({ + Key? key, + required this.externalCallsEnabled, + this.onChanged, + }) : super(key: key); + + final bool externalCallsEnabled; + final void Function(bool)? onChanged; @override - ConsumerState createState() => _PrivacyToggleState(); + State createState() => _PrivacyToggleState(); } -class _PrivacyToggleState extends ConsumerState { +class _PrivacyToggleState extends State { + late bool externalCallsEnabled; + + @override + void initState() { + // initial toggle state + externalCallsEnabled = widget.externalCallsEnabled; + super.initState(); + } + @override Widget build(BuildContext context) { return Row( @@ -196,11 +219,7 @@ class _PrivacyToggleState extends ConsumerState { child: RawMaterialButton( fillColor: Theme.of(context).extension()!.popupBG, shape: RoundedRectangleBorder( - side: !ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - ) + side: !externalCallsEnabled ? BorderSide.none : BorderSide( color: Theme.of(context) @@ -213,7 +232,12 @@ class _PrivacyToggleState extends ConsumerState { ), ), onPressed: () { - ref.read(prefsChangeNotifierProvider).externalCalls = true; + setState(() { + // update toggle state + externalCallsEnabled = true; + }); + // call callback with newly set value + widget.onChanged?.call(externalCallsEnabled); }, child: Padding( padding: const EdgeInsets.all( @@ -244,11 +268,7 @@ class _PrivacyToggleState extends ConsumerState { ), ], ), - if (ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - )) + if (externalCallsEnabled) Positioned( top: 4, right: 4, @@ -261,11 +281,7 @@ class _PrivacyToggleState extends ConsumerState { .infoItemIcons, ), ), - if (!ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - )) + if (!externalCallsEnabled) Positioned( top: 4, right: 4, @@ -293,11 +309,7 @@ class _PrivacyToggleState extends ConsumerState { elevation: 0, fillColor: Theme.of(context).extension()!.popupBG, shape: RoundedRectangleBorder( - side: ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - ) + side: externalCallsEnabled ? BorderSide.none : BorderSide( color: Theme.of(context) @@ -310,7 +322,12 @@ class _PrivacyToggleState extends ConsumerState { ), ), onPressed: () { - ref.read(prefsChangeNotifierProvider).externalCalls = false; + setState(() { + // update toggle state + externalCallsEnabled = false; + }); + // call callback with newly set value + widget.onChanged?.call(externalCallsEnabled); }, child: Padding( padding: const EdgeInsets.all( @@ -342,11 +359,7 @@ class _PrivacyToggleState extends ConsumerState { ), ], ), - if (!ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - )) + if (!externalCallsEnabled) Positioned( top: 4, right: 4, @@ -359,11 +372,7 @@ class _PrivacyToggleState extends ConsumerState { .infoItemIcons, ), ), - if (ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls, - ), - )) + if (externalCallsEnabled) Positioned( top: 4, right: 4, @@ -388,58 +397,47 @@ class _PrivacyToggleState extends ConsumerState { } } -class ContinueButton extends StatelessWidget { - const ContinueButton( - {Key? key, - required this.isDesktop, - required this.isSettings, - required this.isEasy}) - : super(key: key); +class ContinueButton extends ConsumerWidget { + const ContinueButton({ + Key? key, + required this.isDesktop, + required this.onPressed, + required this.label, + }) : super(key: key); + final String label; final bool isDesktop; - final bool isSettings; - final bool isEasy; + final VoidCallback onPressed; @override - Widget build(BuildContext context) { - return !isDesktop - ? TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonColor(context), - onPressed: () { - Prefs.instance.externalCalls = isEasy; - if (!isSettings) { - Navigator.of(context).pushNamed(CreatePinView.routeName); - } else { - Navigator.pop(context); - } - }, - child: Text( - !isSettings ? "Continue" : "Save changes", - style: STextStyles.button(context), - ), - ) - : SizedBox( - width: 328, - height: 70, - child: TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonColor(context), - onPressed: () { - Prefs.instance.externalCalls = isEasy; - - if (!isSettings) { - Navigator.of(context).pushNamed(CreatePinView.routeName); - } - }, - child: Text( - !isSettings ? "Continue" : "Save changes", - style: STextStyles.button(context).copyWith(fontSize: 20), - ), - ), - ); + Widget build(BuildContext context, WidgetRef ref) { + if (isDesktop) { + return SizedBox( + width: 328, + height: 70, + child: TextButton( + style: Theme.of(context) + .extension()! + .getPrimaryEnabledButtonColor(context), + onPressed: onPressed, + child: Text( + label, + style: STextStyles.button(context).copyWith(fontSize: 20), + ), + ), + ); + } else { + return TextButton( + style: Theme.of(context) + .extension()! + .getPrimaryEnabledButtonColor(context), + onPressed: onPressed, + child: Text( + label, + style: STextStyles.button(context), + ), + ); + } } } From 77174d58fea94115a584157f7f273fb79021171f Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Mon, 17 Oct 2022 14:32:24 -0600 Subject: [PATCH 33/44] change build --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index de8a71101..7a25796c0 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.6+76 +version: 1.5.7+77 environment: sdk: ">=2.17.0 <3.0.0" From 23c2b2f50f7d06c455a8b5821b4907da0303ef42 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 15:41:58 -0600 Subject: [PATCH 34/44] read from provider instead of directly from prefs singleton --- lib/pages/home_view/home_view.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index 2e7c38202..b4c643b65 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -11,13 +11,13 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/global_set import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart'; import 'package:stackwallet/pages/wallets_view/wallets_view.dart'; import 'package:stackwallet/providers/global/notifications_provider.dart'; +import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/ui/home_view_index_provider.dart'; import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; @@ -83,9 +83,7 @@ class _HomeViewState extends ConsumerState { void _loadCNData() { // unawaited future - // - final externalCalls = Prefs.instance.externalCalls; - if (externalCalls) { + if (ref.read(prefsChangeNotifierProvider).externalCalls) { _exchangeDataLoadingService.loadAll(ref); } else { Logging.instance.log("User does not want to use external calls", From cfc8f2ab9df36726e9c9747974078e22288a9c37 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 15:56:03 -0600 Subject: [PATCH 35/44] hide price values on favorite card when incognito mode enabled --- .../sub_widgets/favorite_card.dart | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/lib/pages/wallets_view/sub_widgets/favorite_card.dart b/lib/pages/wallets_view/sub_widgets/favorite_card.dart index bc95d51b5..924e904f3 100644 --- a/lib/pages/wallets_view/sub_widgets/favorite_card.dart +++ b/lib/pages/wallets_view/sub_widgets/favorite_card.dart @@ -49,6 +49,8 @@ class _FavoriteCardState extends ConsumerState { @override Widget build(BuildContext context) { final coin = ref.watch(managerProvider.select((value) => value.coin)); + final externalCalls = ref.watch( + prefsChangeNotifierProvider.select((value) => value.externalCalls)); return GestureDetector( onTap: () { @@ -70,7 +72,9 @@ class _FavoriteCardState extends ConsumerState { width: widget.width, height: widget.height, decoration: BoxDecoration( - color: Theme.of(context).extension()!.colorForCoin(coin), + color: Theme.of(context) + .extension()! + .colorForCoin(coin), borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), @@ -138,7 +142,9 @@ class _FavoriteCardState extends ConsumerState { ref.watch(managerProvider .select((value) => value.walletName)), style: STextStyles.itemSubtitle12(context).copyWith( - color: Theme.of(context).extension()!.textFavoriteCard, + color: Theme.of(context) + .extension()! + .textFavoriteCard, ), overflow: TextOverflow.fade, ), @@ -159,14 +165,16 @@ class _FavoriteCardState extends ConsumerState { snapshot.hasData) { if (snapshot.data != null) { _cachedBalance = snapshot.data!; - _cachedFiatValue = _cachedBalance * - ref - .watch( - priceAnd24hChangeNotifierProvider.select( - (value) => value.getPrice(coin), - ), - ) - .item1; + if (externalCalls) { + _cachedFiatValue = _cachedBalance * + ref + .watch( + priceAnd24hChangeNotifierProvider.select( + (value) => value.getPrice(coin), + ), + ) + .item1; + } } } return Column( @@ -185,30 +193,36 @@ class _FavoriteCardState extends ConsumerState { )} ${coin.ticker}", style: STextStyles.titleBold12(context).copyWith( fontSize: 16, - color: Theme.of(context).extension()!.textFavoriteCard, + color: Theme.of(context) + .extension()! + .textFavoriteCard, ), ), ), - const SizedBox( - height: 4, - ), - Text( - "${Format.localizedStringAsFixed( - decimalPlaces: 2, - value: _cachedFiatValue, - locale: ref.watch( - localeServiceChangeNotifierProvider - .select((value) => value.locale), - ), - )} ${ref.watch( - prefsChangeNotifierProvider - .select((value) => value.currency), - )}", - style: STextStyles.itemSubtitle12(context).copyWith( - fontSize: 10, - color: Theme.of(context).extension()!.textFavoriteCard, + if (externalCalls) + const SizedBox( + height: 4, + ), + if (externalCalls) + Text( + "${Format.localizedStringAsFixed( + decimalPlaces: 2, + value: _cachedFiatValue, + locale: ref.watch( + localeServiceChangeNotifierProvider + .select((value) => value.locale), + ), + )} ${ref.watch( + prefsChangeNotifierProvider + .select((value) => value.currency), + )}", + style: STextStyles.itemSubtitle12(context).copyWith( + fontSize: 10, + color: Theme.of(context) + .extension()! + .textFavoriteCard, + ), ), - ), ], ); }, From 44523427e094ec3bbf052e4f74503c24dbfd66b2 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 16:00:26 -0600 Subject: [PATCH 36/44] hide price values on wallet summary card when incognito mode enabled --- .../sub_widgets/wallet_summary_info.dart | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) 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 853e4dd9b..0d6ddd305 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart @@ -70,6 +70,8 @@ class _WalletSummaryInfoState extends State { builder: (_, ref, __) { final Coin coin = ref.watch(managerProvider.select((value) => value.coin)); + final externalCalls = ref.watch(prefsChangeNotifierProvider + .select((value) => value.externalCalls)); Future? totalBalanceFuture; Future? availableBalanceFuture; @@ -176,18 +178,19 @@ class _WalletSummaryInfoState extends State { ), ), ), - Text( - "${Format.localizedStringAsFixed( - value: priceTuple.item1 * balanceToShow, - locale: locale, - decimalPlaces: 2, - )} $baseCurrency", - style: STextStyles.subtitle500(context).copyWith( - color: Theme.of(context) - .extension()! - .textFavoriteCard, + if (externalCalls) + Text( + "${Format.localizedStringAsFixed( + value: priceTuple.item1 * balanceToShow, + locale: locale, + decimalPlaces: 2, + )} $baseCurrency", + style: STextStyles.subtitle500(context).copyWith( + color: Theme.of(context) + .extension()! + .textFavoriteCard, + ), ), - ), ], ); } else { From 643e0640c9668893b4f8f73ed4ac932240e651ca Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 16:07:40 -0600 Subject: [PATCH 37/44] hide price values on tx card+details view when incognito mode enabled --- .../transaction_details_view.dart | 24 ++++---- lib/widgets/transaction_card.dart | 56 ++++++++++--------- 2 files changed, 43 insertions(+), 37 deletions(-) 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 fdb8bf1a9..8d7aac85f 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -255,17 +255,19 @@ class _TransactionDetailsViewState const SizedBox( height: 2, ), - SelectableText( - "${Format.localizedStringAsFixed(value: (coin == Coin.monero ? (amount / 10000.toDecimal()).toDecimal() : coin == Coin.wownero ? (amount / 1000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch( - localeServiceChangeNotifierProvider - .select((value) => value.locale), - ), decimalPlaces: 2)} ${ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.currency, - ), - )}", - style: STextStyles.itemSubtitle(context), - ), + if (ref.watch(prefsChangeNotifierProvider + .select((value) => value.externalCalls))) + SelectableText( + "${Format.localizedStringAsFixed(value: (coin == Coin.monero ? (amount / 10000.toDecimal()).toDecimal() : coin == Coin.wownero ? (amount / 1000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch( + localeServiceChangeNotifierProvider + .select((value) => value.locale), + ), decimalPlaces: 2)} ${ref.watch( + prefsChangeNotifierProvider.select( + (value) => value.currency, + ), + )}", + style: STextStyles.itemSubtitle(context), + ), ], ), TxIcon( diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index b2feaca7a..cb737ae08 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -202,35 +202,39 @@ class _TransactionCardState extends ConsumerState { ), ), ), - const SizedBox( - width: 10, - ), - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Builder( - builder: (_) { - // TODO: modify Format. to take optional Coin parameter so this type oif check isn't done in ui - int value = _transaction.amount; - if (coin == Coin.monero) { - value = (value ~/ 10000); - } else if (coin == Coin.wownero) { - value = (value ~/ 1000); - } + 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: (_) { + // TODO: modify Format. to take optional Coin parameter so this type oif check isn't done in ui + int value = _transaction.amount; + if (coin == Coin.monero) { + value = (value ~/ 10000); + } else if (coin == Coin.wownero) { + value = (value ~/ 1000); + } - return Text( - "${Format.localizedStringAsFixed( - value: Format.satoshisToAmount(value) * - price, - locale: locale, - decimalPlaces: 2, - )} $baseCurrency", - style: STextStyles.label(context), - ); - }, + return Text( + "${Format.localizedStringAsFixed( + value: Format.satoshisToAmount(value) * + price, + locale: locale, + decimalPlaces: 2, + )} $baseCurrency", + style: STextStyles.label(context), + ); + }, + ), ), ), - ), ], ), ], From 86646994842edf639f4cbe373f34418a471b3d2a Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 16:37:47 -0600 Subject: [PATCH 38/44] default incognito mode fix --- lib/utilities/prefs.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 0109755f7..2fc21a78d 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -569,6 +569,6 @@ class Prefs extends ChangeNotifier { Future _getHasExternalCalls() async { return await DB.instance.get( boxName: DB.boxNamePrefs, key: "externalCalls") as bool? ?? - false; + true; } } From e1e9cb71267c971bc67261f91c1c2ec1c3aa5c5a Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 17:20:08 -0600 Subject: [PATCH 39/44] disable checking trade history for updates in incognito mode --- .../exchange_view/trade_details_view.dart | 30 ++++++++++--------- lib/services/notifications_service.dart | 4 ++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index bba561ead..76c845027 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -79,23 +79,25 @@ class _TradeDetailsViewState extends ConsumerState { transactionIfSentFromStack = widget.transactionIfSentFromStack; walletId = widget.walletId; - WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { - final trade = ref - .read(tradesServiceProvider) - .trades - .firstWhere((e) => e.tradeId == tradeId); + if (ref.read(prefsChangeNotifierProvider).externalCalls) { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { + final trade = ref + .read(tradesServiceProvider) + .trades + .firstWhere((e) => e.tradeId == tradeId); - if (mounted) { - final exchange = Exchange.fromName(trade.exchangeName); - final response = await exchange.updateTrade(trade); + if (mounted) { + final exchange = Exchange.fromName(trade.exchangeName); + final response = await exchange.updateTrade(trade); - if (mounted && response.value != null) { - await ref - .read(tradesServiceProvider) - .edit(trade: response.value!, shouldNotifyListeners: true); + if (mounted && response.value != null) { + await ref + .read(tradesServiceProvider) + .edit(trade: response.value!, shouldNotifyListeners: true); + } } - } - }); + }); + } super.initState(); } diff --git a/lib/services/notifications_service.dart b/lib/services/notifications_service.dart index 8ade3e969..2368adeab 100644 --- a/lib/services/notifications_service.dart +++ b/lib/services/notifications_service.dart @@ -84,7 +84,9 @@ class NotificationsService extends ChangeNotifier { _timer = Timer.periodic(notificationRefreshInterval, (_) { Logging.instance .log("Periodic notifications update check", level: LogLevel.Info); - _checkTrades(); + if (prefs.externalCalls) { + _checkTrades(); + } _checkTransactions(); }); } From c0e143b89b9e5eb6a048d88809b7fa85c8d069cb Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Tue, 18 Oct 2022 07:58:42 -0700 Subject: [PATCH 40/44] Change default bitcoincash testnet electrum node to stackwallet. --- lib/utilities/default_nodes.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index 2ffd6f307..b09787d33 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -159,8 +159,8 @@ abstract class DefaultNodes { ); static NodeModel get bitcoincashTestnet => NodeModel( - host: "testnet.hsmiths.com", - port: 53012, + host: "bitcoincash-testnet.stackwallet.com", + port: 60002, name: defaultName, id: _nodeId(Coin.bitcoincashTestnet), useSSL: true, From cd0fdad1f6555cfbdf281ec57c5c12e41ff986f8 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 18 Oct 2022 10:36:25 -0600 Subject: [PATCH 41/44] init prefs before doing any network calls --- lib/main.dart | 2 +- lib/services/price.dart | 3 +-- lib/services/price_service.dart | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 04c48ae49..ad1ef9b7f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -207,6 +207,7 @@ class _MaterialAppWithThemeState extends ConsumerState didLoad = true; await DB.instance.init(); + await _prefs.init(); _notificationsService = ref.read(notificationsProvider); _nodeService = ref.read(nodeServiceChangeNotifierProvider); @@ -223,7 +224,6 @@ class _MaterialAppWithThemeState extends ConsumerState tradesService: _tradesService, prefs: _prefs, ); - await _prefs.init(); ref.read(priceAnd24hChangeNotifierProvider).start(true); await _wallets.load(_prefs); loadingCompleter.complete(); diff --git a/lib/services/price.dart b/lib/services/price.dart index 924c77f74..4f6650b06 100644 --- a/lib/services/price.dart +++ b/lib/services/price.dart @@ -7,9 +7,8 @@ import 'package:http/http.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; -import 'package:tuple/tuple.dart'; - import 'package:stackwallet/utilities/prefs.dart'; +import 'package:tuple/tuple.dart'; class PriceAPI { static const refreshInterval = 60; diff --git a/lib/services/price_service.dart b/lib/services/price_service.dart index 8986d25e5..eb2b1eba4 100644 --- a/lib/services/price_service.dart +++ b/lib/services/price_service.dart @@ -19,9 +19,7 @@ class PriceService extends ChangeNotifier { Tuple2 getPrice(Coin coin) => _cachedPrices[coin]!; - PriceService(this.baseTicker) { - start(true); - } + PriceService(this.baseTicker); Future updatePrice() async { final priceMap = From 6e56690bf5bd7861cdc82bb00a58ae7da79ad9d0 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 18 Oct 2022 11:12:43 -0600 Subject: [PATCH 42/44] load exchange data on user opened exchange --- lib/pages/home_view/home_view.dart | 2 +- .../sub_widgets/home_view_button_bar.dart | 8 ++++---- lib/pages/wallet_view/wallet_view.dart | 19 ++++--------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index b4c643b65..33744570b 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -287,7 +287,7 @@ class _HomeViewState extends ConsumerState { (previous, next) { if (next is int) { if (next == 1) { - _loadCNData(); + _exchangeDataLoadingService.loadAll(ref); } if (next >= 0 && next <= 1) { _pageController.animateToPage( diff --git a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart index 61a6c4185..341fc35da 100644 --- a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart +++ b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart @@ -101,10 +101,10 @@ class _HomeViewButtonBarState extends ConsumerState { ref.read(homeViewPageIndexStateProvider.state).state = 1; } // DateTime now = DateTime.now(); - if (ref.read(prefsChangeNotifierProvider).externalCalls) { - print("loading?"); - await ExchangeDataLoadingService().loadAll(ref); - } + // if (ref.read(prefsChangeNotifierProvider).externalCalls) { + // print("loading?"); + await ExchangeDataLoadingService().loadAll(ref); + // } // if (now.difference(_lastRefreshed) > _refreshInterval) { // await ExchangeDataLoadingService().loadAll(ref); // } diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 488ed19cd..c84ddf2b9 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -37,6 +37,7 @@ 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'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; @@ -45,12 +46,6 @@ import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; -import 'package:stackwallet/hive/db.dart'; - -import 'package:stackwallet/utilities/logger.dart'; - -import 'package:stackwallet/utilities/prefs.dart'; - /// [eventBus] should only be set during testing class WalletView extends ConsumerStatefulWidget { const WalletView({ @@ -235,12 +230,8 @@ class _WalletViewState extends ConsumerState { } void _onExchangePressed(BuildContext context) async { - final _cnLoadingService = ExchangeDataLoadingService(); - final externalCalls = Prefs.instance.externalCalls; - if (!externalCalls) { - print("loading?"); - unawaited(_cnLoadingService.loadAll(ref)); - } + unawaited(_cnLoadingService.loadAll(ref)); + final coin = ref.read(managerProvider).coin; if (coin == Coin.epicCash) { @@ -371,9 +362,7 @@ class _WalletViewState extends ConsumerState { void _loadCNData() { // unawaited future - final externalCalls = DB.instance - .get(boxName: DB.boxNamePrefs, key: "externalCalls") as bool?; - if (externalCalls ?? false) { + if (ref.read(prefsChangeNotifierProvider).externalCalls) { _cnLoadingService.loadAll(ref, coin: ref.read(managerProvider).coin); } else { Logging.instance.log("User does not want to use external calls", From 604c2b4a639b8053eba13b07b0c8b30eed067cac Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 18 Oct 2022 11:28:14 -0600 Subject: [PATCH 43/44] increase firo mint search gap --- lib/services/coins/firo/firo_wallet.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 79fe27bad..b8d7a87b8 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -254,7 +254,7 @@ Future> isolateRestore( } final root = getBip32Root(mnemonic, network); - while (currentIndex < lastFoundIndex + 20) { + while (currentIndex < lastFoundIndex + 50) { final mintKeyPair = getBip32NodeFromRoot(MINT_INDEX, currentIndex, root); final mintTag = CreateTag( Format.uint8listToString(mintKeyPair.privateKey!), From d2120cd1714fa47a8259a56137f4e101a15a5aea Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 18 Oct 2022 13:15:57 -0600 Subject: [PATCH 44/44] firo public send fix --- lib/services/coins/firo/firo_wallet.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index b8d7a87b8..61ef2e9de 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -1356,7 +1356,7 @@ class FiroWallet extends CoinServiceAPI { List utxoObjectsToUse = []; for (var i = 0; - satoshisBeingUsed < satoshiAmountToSend && i < spendableOutputs.length; + satoshisBeingUsed <= satoshiAmountToSend && i < spendableOutputs.length; i++) { utxoObjectsToUse.add(spendableOutputs[i]); satoshisBeingUsed += spendableOutputs[i].value;