From be300d9027bc8409424614775b2be28ebade82aa Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 11:25:32 -0600 Subject: [PATCH 1/8] OLED Black color fixes --- lib/pages/loading_view.dart | 28 +++++++++++++++++----- lib/utilities/theme/oled_black_colors.dart | 5 ++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/pages/loading_view.dart b/lib/pages/loading_view.dart index b7db1aa58..6c4b611ee 100644 --- a/lib/pages/loading_view.dart +++ b/lib/pages/loading_view.dart @@ -3,8 +3,11 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/background.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/rounded_container.dart'; class LoadingView extends StatelessWidget { const LoadingView({Key? key}) : super(key: key); @@ -12,18 +15,31 @@ class LoadingView extends StatelessWidget { @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; + final width = min(size.width, size.height) * 0.5; return Background( child: Scaffold( backgroundColor: Theme.of(context).extension()!.background, body: Container( color: Theme.of(context).extension()!.background, child: Center( - child: SizedBox( - width: min(size.width, size.height) * 0.5, - child: Lottie.asset( - Assets.lottie.test2, - animate: true, - repeat: true, + child: ConditionalParent( + condition: + Theme.of(context).extension()!.themeType == + ThemeType.oledBlack, + builder: (child) => RoundedContainer( + color: const Color(0xFFDEDEDE), + radiusMultiplier: 100, + width: width * 1.35, + height: width * 1.35, + child: child, + ), + child: SizedBox( + width: width, + child: Lottie.asset( + Assets.lottie.test2, + animate: true, + repeat: true, + ), ), ), // child: Image( diff --git a/lib/utilities/theme/oled_black_colors.dart b/lib/utilities/theme/oled_black_colors.dart index 97fd6ad5f..3a7ba8126 100644 --- a/lib/utilities/theme/oled_black_colors.dart +++ b/lib/utilities/theme/oled_black_colors.dart @@ -283,7 +283,7 @@ class OledBlackColors extends StackColorTheme { @override Color get infoItemText => const Color(0xFFDEDEDE); @override - Color get infoItemIcons => const Color(0xFF5C94F4); + Color get infoItemIcons => const Color(0xFFF26822); //const Color(0xFF5C94F4); // popup @override @@ -321,7 +321,8 @@ class OledBlackColors extends StackColorTheme { @override Color get myStackContactIconBG => const Color(0xFF747778); @override - Color get textConfirmTotalAmount => const Color(0xFF144D35); + Color get textConfirmTotalAmount => + textFieldSuccessLabel; //const Color(0xFF144D35); @override Color get textSelectedWordTableItem => const Color(0xFF143D8E); From 9ae95b3591eabb7920ca937031f784f10cec45cc Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 11:26:48 -0600 Subject: [PATCH 2/8] add firo to majestic bank hard coded map --- lib/services/exchange/majestic_bank/majestic_bank_exchange.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart index 67012ad9b..2976e2897 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart @@ -23,6 +23,7 @@ class MajesticBankExchange extends Exchange { static const kMajesticBankCurrencyNames = { "BTC": "Bitcoin", + "FIRO": "Firo", "LTC": "Litecoin", "WOW": "Wownero", "XMR": "Monero", From 97f36e6f049659b1e751a8bb01b9e40ed700ce5b Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 11:36:47 -0600 Subject: [PATCH 3/8] show sum of total firo public and private balance on wallet select sheet --- .../wallet_info_row_balance_future.dart | 58 ++++++------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart index 174e251cf..542cb545a 100644 --- a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart +++ b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart @@ -2,12 +2,13 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/services/coins/firo/firo_wallet.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/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; class WalletInfoRowBalanceFuture extends ConsumerWidget { const WalletInfoRowBalanceFuture({Key? key, required this.walletId}) @@ -27,44 +28,23 @@ class WalletInfoRowBalanceFuture extends ConsumerWidget { ), ); - // TODO redo this widget now that its not actually a future - return FutureBuilder( - future: Future(() => manager.balance.getTotal()), - builder: (builderContext, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - return Text( - "${Format.localizedStringAsFixed( - value: snapshot.data!, - locale: locale, - decimalPlaces: 8, - )} ${manager.coin.ticker}", - style: Util.isDesktop - ? STextStyles.desktopTextExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ) - : STextStyles.itemSubtitle(context), - ); - } else { - return AnimatedText( - stringsToLoopThrough: const [ - "Loading balance", - "Loading balance.", - "Loading balance..", - "Loading balance..." - ], - style: Util.isDesktop - ? STextStyles.desktopTextExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, - ) - : STextStyles.itemSubtitle(context), - ); - } - }, + Decimal balance = manager.balance.getTotal(); + + if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) { + balance += (manager.wallet as FiroWallet).balancePrivate.getTotal(); + } + + return Text( + "${Format.localizedStringAsFixed( + value: balance, + locale: locale, + decimalPlaces: Constants.decimalPlacesForCoin(manager.coin), + )} ${manager.coin.ticker}", + style: Util.isDesktop + ? STextStyles.desktopTextExtraSmall(context).copyWith( + color: Theme.of(context).extension()!.textSubtitle1, + ) + : STextStyles.itemSubtitle(context), ); } } From a63af1787a42bd30d1c3cd382a16d44d31291682 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 13:49:27 -0600 Subject: [PATCH 4/8] explicitly check p2pkh change address on refresh --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 4b9d51508..44c600f39 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -1016,6 +1016,7 @@ class BitcoinWallet extends CoinServiceAPI if (currentHeight != storedHeight) { GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); await _checkChangeAddressForTransactions(); + await _checkP2PKHChangeAddressForTransactions(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); await _checkCurrentReceivingAddressesForTransactions(); From a57cd886962e398f231bae114a612cf9b4cab39a Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 14:01:36 -0600 Subject: [PATCH 5/8] use segwit change address for notification tx --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 44c600f39..25a74e7b9 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -125,14 +125,16 @@ class BitcoinWallet extends CoinServiceAPI getMnemonicString: () => mnemonicString, getMnemonicPassphrase: () => mnemonicPassphrase, getChainHeight: () => chainHeight, - getCurrentChangeAddress: () => currentChangeAddressP2PKH, + // getCurrentChangeAddress: () => currentChangeAddressP2PKH, + getCurrentChangeAddress: () => currentChangeAddress, estimateTxFee: estimateTxFee, prepareSend: prepareSend, getTxCount: getTxCount, fetchBuildTxData: fetchBuildTxData, refresh: refresh, - checkChangeAddressForTransactions: - _checkP2PKHChangeAddressForTransactions, + checkChangeAddressForTransactions: _checkChangeAddressForTransactions, + // checkChangeAddressForTransactions: + // _checkP2PKHChangeAddressForTransactions, addDerivation: addDerivation, dustLimitP2PKH: DUST_LIMIT_P2PKH, minConfirms: MINIMUM_CONFIRMATIONS, From fd0400e7f72b1811ca8ac7002f940c904b6a3b20 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 14:08:07 -0600 Subject: [PATCH 6/8] update mock calls --- .../table_view/table_view_row_test.dart | 10 ++++++++++ test/widget_tests/wallet_card_test.dart | 19 +++++++++++++++++++ .../wallet_info_row_balance_future_test.dart | 10 ++++++++++ .../wallet_info_row/wallet_info_row_test.dart | 10 ++++++++++ 4 files changed, 49 insertions(+) diff --git a/test/widget_tests/table_view/table_view_row_test.dart b/test/widget_tests/table_view/table_view_row_test.dart index a5d18e571..26292b7e5 100644 --- a/test/widget_tests/table_view/table_view_row_test.dart +++ b/test/widget_tests/table_view/table_view_row_test.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/coin_wallets_table.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; @@ -34,6 +35,15 @@ void main() { when(wallet.walletName).thenAnswer((_) => "some wallet"); when(wallet.walletId).thenAnswer((_) => "Wallet id 1"); + when(wallet.balance).thenAnswer( + (_) => Balance( + coin: Coin.bitcoin, + total: 0, + spendable: 0, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); final manager = Manager(wallet); diff --git a/test/widget_tests/wallet_card_test.dart b/test/widget_tests/wallet_card_test.dart index 6e20e2892..b2197d88a 100644 --- a/test/widget_tests/wallet_card_test.dart +++ b/test/widget_tests/wallet_card_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockingjay/mockingjay.dart' as mockingjay; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart' as mockito; +import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; @@ -29,6 +30,15 @@ void main() { mockito .when(wallet.walletName) .thenAnswer((realInvocation) => "wallet name"); + mockito.when(wallet.balance).thenAnswer( + (_) => Balance( + coin: Coin.bitcoin, + total: 0, + spendable: 0, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); final wallets = MockWallets(); final locale = MockLocaleService(); @@ -89,6 +99,15 @@ void main() { mockito .when(wallet.walletName) .thenAnswer((realInvocation) => "wallet name"); + mockito.when(wallet.balance).thenAnswer( + (_) => Balance( + coin: Coin.bitcoin, + total: 0, + spendable: 0, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); final wallets = MockWallets(); final manager = Manager(wallet); diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart index ce04bf795..5747020ce 100644 --- a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart +++ b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; @@ -35,6 +36,15 @@ void main() { when(wallet.coin).thenAnswer((_) => Coin.bitcoin); when(wallet.walletName).thenAnswer((_) => "some wallet"); when(wallet.walletId).thenAnswer((_) => "some-wallet-id"); + when(wallet.balance).thenAnswer( + (_) => Balance( + coin: Coin.bitcoin, + total: 0, + spendable: 0, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); final manager = Manager(wallet); when(wallets.getManagerProvider("some-wallet-id")).thenAnswer( diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.dart index 1bcf3d14e..67f7527be 100644 --- a/test/widget_tests/wallet_info_row/wallet_info_row_test.dart +++ b/test/widget_tests/wallet_info_row/wallet_info_row_test.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; +import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart'; import 'package:stackwallet/services/coins/coin_service.dart'; @@ -35,6 +36,15 @@ void main() { when(wallet.coin).thenAnswer((_) => Coin.bitcoin); when(wallet.walletName).thenAnswer((_) => "some wallet"); when(wallet.walletId).thenAnswer((_) => "some-wallet-id"); + when(wallet.balance).thenAnswer( + (_) => Balance( + coin: Coin.bitcoin, + total: 0, + spendable: 0, + blockedTotal: 0, + pendingSpendable: 0, + ), + ); final manager = Manager(wallet); when(wallets.getManagerProvider("some-wallet-id")).thenAnswer( From 3f80c1777785328a14bfbe07e4a294db6484acf7 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 14:11:14 -0600 Subject: [PATCH 7/8] added bch to MB map as well as some other wallet coins preemptively --- .../exchange/majestic_bank/majestic_bank_exchange.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart index 2976e2897..acb881c31 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart @@ -22,9 +22,14 @@ class MajesticBankExchange extends Exchange { static const exchangeName = "Majestic Bank"; static const kMajesticBankCurrencyNames = { + "BCH": "Bitcoin Cash", "BTC": "Bitcoin", + "DOGE": "Dogecoin", + "EPIC": "Epic Cash", "FIRO": "Firo", "LTC": "Litecoin", + "NMC": "Namecoin", + "PART": "Particl", "WOW": "Wownero", "XMR": "Monero", }; From ba137742fa4b8781a98ffb05d7e14a35389e63d1 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Feb 2023 14:18:47 -0600 Subject: [PATCH 8/8] exchange currency select coin list sorting fix --- .../exchange_currency_selection_view.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart index aa1683c3f..1b2376b4c 100644 --- a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart +++ b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart @@ -338,6 +338,7 @@ class _ExchangeCurrencySelectionViewState coin.ticker.toLowerCase() == e.ticker.toLowerCase()) .isNotEmpty) .toList(growable: false); + items.sort((a, b) => a.name.compareTo(b.name)); return RoundedWhiteContainer( padding: const EdgeInsets.all(0), @@ -427,6 +428,7 @@ class _ExchangeCurrencySelectionViewState Flexible( child: Builder(builder: (context) { final filtered = filter(_searchString); + filtered.sort((a, b) => a.name.compareTo(b.name)); return RoundedWhiteContainer( padding: const EdgeInsets.all(0), child: ListView.builder(