From 9a2589b4c3e73cff74d9bfa2b4e2e452cbea1bbb Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 22 Nov 2024 13:01:23 -0600 Subject: [PATCH] disable segwit paynym claiming and disable follow/unfollow due to server token signing not working --- .../paynym/dialogs/paynym_details_popup.dart | 16 +- lib/pages/paynym/paynym_claim_view.dart | 75 ++++---- lib/pages/paynym/paynym_home_view.dart | 165 +++++++++--------- .../subwidgets/desktop_paynym_details.dart | 18 +- lib/pages/paynym/subwidgets/paynym_card.dart | 12 +- lib/pages/wallet_view/wallet_view.dart | 6 +- .../sub_widgets/desktop_wallet_features.dart | 9 +- .../paynym_follow_toggle_button.dart | 16 +- 8 files changed, 167 insertions(+), 150 deletions(-) diff --git a/lib/pages/paynym/dialogs/paynym_details_popup.dart b/lib/pages/paynym/dialogs/paynym_details_popup.dart index 693061482..b3e800a17 100644 --- a/lib/pages/paynym/dialogs/paynym_details_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_details_popup.dart @@ -382,13 +382,15 @@ class _PaynymDetailsPopupState extends ConsumerState { ), child: Row( children: [ - Expanded( - child: PaynymFollowToggleButton( - walletId: widget.walletId, - paymentCodeStringToFollow: widget.accountLite.code, - style: PaynymFollowToggleButtonStyle.detailsPopup, - ), - ), + kDisableFollowing + ? const Spacer() + : Expanded( + child: PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: widget.accountLite.code, + style: PaynymFollowToggleButtonStyle.detailsPopup, + ), + ), const SizedBox( width: 12, ), diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index acabb388d..8d61e139c 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -14,7 +14,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import '../../models/paynym/paynym_account.dart'; import '../../providers/global/paynym_api_provider.dart'; import '../../providers/global/wallets_provider.dart'; import '../../providers/wallet/my_paynym_account_state_provider.dart'; @@ -47,25 +46,25 @@ class PaynymClaimView extends ConsumerStatefulWidget { } class _PaynymClaimViewState extends ConsumerState { - Future _addSegwitCode(PaynymAccount myAccount) async { - final wallet = - ref.read(pWallets).getWallet(widget.walletId) as PaynymInterface; - - final token = await ref - .read(paynymAPIProvider) - .token(myAccount.nonSegwitPaymentCode.code); - final signature = await wallet.signStringWithNotificationKey(token.value!); - - final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true); - final addResult = await ref.read(paynymAPIProvider).add( - token.value!, - signature, - myAccount.nymID, - pCodeSegwit.toString(), - ); - - return addResult.value ?? false; - } + // Future _addSegwitCode(PaynymAccount myAccount) async { + // final wallet = + // ref.read(pWallets).getWallet(widget.walletId) as PaynymInterface; + // + // final token = await ref + // .read(paynymAPIProvider) + // .token(myAccount.nonSegwitPaymentCode.code); + // final signature = await wallet.signStringWithNotificationKey(token.value!); + // + // final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true); + // final addResult = await ref.read(paynymAPIProvider).add( + // token.value!, + // signature, + // myAccount.nymID, + // pCodeSegwit.toString(), + // ); + // + // return addResult.value ?? false; + // } @override Widget build(BuildContext context) { @@ -210,16 +209,16 @@ class _PaynymClaimViewState extends ConsumerState { // payment code already claimed debugPrint("pcode already claimed!!"); - final account = - await ref.read(paynymAPIProvider).nym(pCode.toString()); - if (!account.value!.segwit) { - for (int i = 0; i < 100; i++) { - final result = await _addSegwitCode(account.value!); - if (result == true) { - break; - } - } - } + // final account = + // await ref.read(paynymAPIProvider).nym(pCode.toString()); + // if (!account.value!.segwit) { + // for (int i = 0; i < 100; i++) { + // final result = await _addSegwitCode(account.value!); + // if (result == true) { + // break; + // } + // } + // } if (mounted) { if (isDesktop) { @@ -259,14 +258,14 @@ class _PaynymClaimViewState extends ConsumerState { if (claim.value?.claimed == pCode.toString()) { final account = await ref.read(paynymAPIProvider).nym(pCode.toString()); - if (!account.value!.segwit) { - for (int i = 0; i < 100; i++) { - final result = await _addSegwitCode(account.value!); - if (result == true) { - break; - } - } - } + // if (!account.value!.segwit) { + // for (int i = 0; i < 100; i++) { + // final result = await _addSegwitCode(account.value!); + // if (result == true) { + // break; + // } + // } + // } ref.read(myPaynymAccountStateProvider.state).state = account.value!; diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 8c3c6419d..d27a8ae42 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -27,6 +27,7 @@ import '../../utilities/text_styles.dart'; import '../../utilities/util.dart'; import '../../widgets/conditional_parent.dart'; import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/paynym_follow_toggle_button.dart'; import '../../widgets/desktop/desktop_app_bar.dart'; import '../../widgets/desktop/desktop_scaffold.dart'; import '../../widgets/desktop/secondary_button.dart'; @@ -121,72 +122,75 @@ class _PaynymHomeViewState extends ConsumerState { ), ], ), - trailing: Padding( - padding: const EdgeInsets.only(right: 12), - child: SizedBox( - height: 56, - child: MouseRegion( - cursor: SystemMouseCursors.click, - onEnter: (_) => setState(() { - _followButtonHoverState = true; - }), - onExit: (_) => setState(() { - _followButtonHoverState = false; - }), - child: GestureDetector( - onTap: () { - showDialog( - context: context, - builder: (context) => AddNewPaynymFollowView( - walletId: widget.walletId, - ), - ); - }, - child: RoundedContainer( - padding: const EdgeInsets.symmetric(horizontal: 24.0), - color: _followButtonHoverState - ? Theme.of(context) - .extension()! - .highlight - : Colors.transparent, - radiusMultiplier: 100, - child: Row( - children: [ - SvgPicture.asset( - Assets.svg.plus, - width: 16, - height: 16, - color: Theme.of(context) - .extension()! - .textDark, - ), - const SizedBox( - width: 8, - ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Follow", - style: - STextStyles.desktopButtonSecondaryEnabled( - context, - ).copyWith( - fontSize: 16, + trailing: kDisableFollowing + ? null + : Padding( + padding: const EdgeInsets.only(right: 12), + child: SizedBox( + height: 56, + child: MouseRegion( + cursor: SystemMouseCursors.click, + onEnter: (_) => setState(() { + _followButtonHoverState = true; + }), + onExit: (_) => setState(() { + _followButtonHoverState = false; + }), + child: GestureDetector( + onTap: () { + showDialog( + context: context, + builder: (context) => AddNewPaynymFollowView( + walletId: widget.walletId, + ), + ); + }, + child: RoundedContainer( + padding: + const EdgeInsets.symmetric(horizontal: 24.0), + color: _followButtonHoverState + ? Theme.of(context) + .extension()! + .highlight + : Colors.transparent, + radiusMultiplier: 100, + child: Row( + children: [ + SvgPicture.asset( + Assets.svg.plus, + width: 16, + height: 16, + color: Theme.of(context) + .extension()! + .textDark, ), - ), - const SizedBox( - height: 2, - ), - ], + const SizedBox( + width: 8, + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Follow", + style: STextStyles + .desktopButtonSecondaryEnabled( + context, + ).copyWith( + fontSize: 16, + ), + ), + const SizedBox( + height: 2, + ), + ], + ), + ], + ), ), - ], + ), ), ), ), - ), - ), - ), ) : AppBar( leading: AppBarBackButton( @@ -201,28 +205,29 @@ class _PaynymHomeViewState extends ConsumerState { overflow: TextOverflow.ellipsis, ), actions: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 6), - child: AspectRatio( - aspectRatio: 1, - child: AppBarIconButton( - icon: SvgPicture.asset( - Assets.svg.circlePlusFilled, - width: 20, - height: 20, - color: Theme.of(context) - .extension()! - .accentColorDark, + if (!kDisableFollowing) + Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: AspectRatio( + aspectRatio: 1, + child: AppBarIconButton( + icon: SvgPicture.asset( + Assets.svg.circlePlusFilled, + width: 20, + height: 20, + color: Theme.of(context) + .extension()! + .accentColorDark, + ), + onPressed: () { + Navigator.of(context).pushNamed( + AddNewPaynymFollowView.routeName, + arguments: widget.walletId, + ); + }, ), - onPressed: () { - Navigator.of(context).pushNamed( - AddNewPaynymFollowView.routeName, - arguments: widget.walletId, - ); - }, ), ), - ), Padding( padding: const EdgeInsets.symmetric(vertical: 6), child: AspectRatio( diff --git a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart index 1c2b0cb81..6b08b84db 100644 --- a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart +++ b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart @@ -284,13 +284,17 @@ class _PaynymDetailsPopupState extends ConsumerState { const SizedBox( width: 20, ), - Expanded( - child: PaynymFollowToggleButton( - walletId: widget.walletId, - paymentCodeStringToFollow: widget.accountLite.code, - style: PaynymFollowToggleButtonStyle.detailsDesktop, - ), - ), + kDisableFollowing + ? const Spacer() + : Expanded( + child: PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: + widget.accountLite.code, + style: + PaynymFollowToggleButtonStyle.detailsDesktop, + ), + ), ], ), if (_showInsufficientFundsInfo) diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index 32422a740..da71905f2 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -9,12 +9,13 @@ */ import 'package:flutter/material.dart'; -import 'paynym_bot.dart'; + import '../../../themes/stack_colors.dart'; import '../../../utilities/format.dart'; import '../../../utilities/text_styles.dart'; import '../../../utilities/util.dart'; import '../../../widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import 'paynym_bot.dart'; class PaynymCard extends StatefulWidget { const PaynymCard({ @@ -84,10 +85,11 @@ class _PaynymCardState extends State { ], ), ), - PaynymFollowToggleButton( - walletId: widget.walletId, - paymentCodeStringToFollow: widget.paymentCodeString, - ), + if (!kDisableFollowing) + PaynymFollowToggleButton( + walletId: widget.walletId, + paymentCodeStringToFollow: widget.paymentCodeString, + ), ], ), ); diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 346a4b730..d3a98ef16 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -1175,8 +1175,10 @@ class _WalletViewState extends ConsumerState { // check if account exists and for matching code to see if claimed if (account.value != null && - account.value!.nonSegwitPaymentCode.claimed && - account.value!.segwit) { + account.value!.nonSegwitPaymentCode.claimed + // && + // account.value!.segwit + ) { ref.read(myPaynymAccountStateProvider.state).state = account.value!; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart index 4639bc7e5..2499d4754 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart @@ -302,13 +302,14 @@ class _DesktopWalletFeaturesState extends ConsumerState { level: LogLevel.Info, ); - if (context.mounted) { + if (mounted) { Navigator.of(context, rootNavigator: true).pop(); // check if account exists and for matching code to see if claimed - if (account.value != null && - account.value!.nonSegwitPaymentCode.claimed && - account.value!.segwit) { + if (account.value != null && account.value!.nonSegwitPaymentCode.claimed + // && + // account.value!.segwit + ) { ref.read(myPaynymAccountStateProvider.state).state = account.value!; await Navigator.of(context).pushNamed( diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index 5bc6143d1..daa87415c 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -34,6 +34,8 @@ enum PaynymFollowToggleButtonStyle { detailsDesktop, } +const kDisableFollowing = true; + class PaynymFollowToggleButton extends ConsumerStatefulWidget { const PaynymFollowToggleButton({ super.key, @@ -55,7 +57,7 @@ class _PaynymFollowToggleButtonState extends ConsumerState { final isDesktop = Util.isDesktop; - Future follow() async { + Future _follow() async { bool loadingPopped = false; unawaited( showDialog( @@ -160,7 +162,7 @@ class _PaynymFollowToggleButtonState } } - Future unfollow() async { + Future _unfollow() async { bool loadingPopped = false; unawaited( showDialog( @@ -264,9 +266,9 @@ class _PaynymFollowToggleButtonState if (!_lock) { _lock = true; if (isFollowing) { - await unfollow(); + await _unfollow(); } else { - await follow(); + await _follow(); } _lock = false; } @@ -291,7 +293,7 @@ class _PaynymFollowToggleButtonState width: isDesktop ? 120 : 100, buttonHeight: isDesktop ? ButtonHeight.s : ButtonHeight.xl, label: isFollowing ? "Unfollow" : "Follow", - onPressed: _onPressed, + onPressed: kDisableFollowing ? null : _onPressed, ); case PaynymFollowToggleButtonStyle.detailsPopup: @@ -306,7 +308,7 @@ class _PaynymFollowToggleButtonState color: Theme.of(context).extension()!.buttonTextSecondary, ), - onPressed: _onPressed, + onPressed: kDisableFollowing ? null : _onPressed, ); case PaynymFollowToggleButtonStyle.detailsDesktop: @@ -321,7 +323,7 @@ class _PaynymFollowToggleButtonState Theme.of(context).extension()!.buttonTextSecondary, ), iconSpacing: 6, - onPressed: _onPressed, + onPressed: kDisableFollowing ? null : _onPressed, ); } }