mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-03 17:29:23 +00:00
disable segwit paynym claiming and disable follow/unfollow due to server token signing not working
This commit is contained in:
parent
7511ce2ac3
commit
9a2589b4c3
8 changed files with 167 additions and 150 deletions
|
@ -382,13 +382,15 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
kDisableFollowing
|
||||||
child: PaynymFollowToggleButton(
|
? const Spacer()
|
||||||
walletId: widget.walletId,
|
: Expanded(
|
||||||
paymentCodeStringToFollow: widget.accountLite.code,
|
child: PaynymFollowToggleButton(
|
||||||
style: PaynymFollowToggleButtonStyle.detailsPopup,
|
walletId: widget.walletId,
|
||||||
),
|
paymentCodeStringToFollow: widget.accountLite.code,
|
||||||
),
|
style: PaynymFollowToggleButtonStyle.detailsPopup,
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 12,
|
width: 12,
|
||||||
),
|
),
|
||||||
|
|
|
@ -14,7 +14,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
import '../../models/paynym/paynym_account.dart';
|
|
||||||
import '../../providers/global/paynym_api_provider.dart';
|
import '../../providers/global/paynym_api_provider.dart';
|
||||||
import '../../providers/global/wallets_provider.dart';
|
import '../../providers/global/wallets_provider.dart';
|
||||||
import '../../providers/wallet/my_paynym_account_state_provider.dart';
|
import '../../providers/wallet/my_paynym_account_state_provider.dart';
|
||||||
|
@ -47,25 +46,25 @@ class PaynymClaimView extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
|
class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
|
||||||
Future<bool> _addSegwitCode(PaynymAccount myAccount) async {
|
// Future<bool> _addSegwitCode(PaynymAccount myAccount) async {
|
||||||
final wallet =
|
// final wallet =
|
||||||
ref.read(pWallets).getWallet(widget.walletId) as PaynymInterface;
|
// ref.read(pWallets).getWallet(widget.walletId) as PaynymInterface;
|
||||||
|
//
|
||||||
final token = await ref
|
// final token = await ref
|
||||||
.read(paynymAPIProvider)
|
// .read(paynymAPIProvider)
|
||||||
.token(myAccount.nonSegwitPaymentCode.code);
|
// .token(myAccount.nonSegwitPaymentCode.code);
|
||||||
final signature = await wallet.signStringWithNotificationKey(token.value!);
|
// final signature = await wallet.signStringWithNotificationKey(token.value!);
|
||||||
|
//
|
||||||
final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true);
|
// final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true);
|
||||||
final addResult = await ref.read(paynymAPIProvider).add(
|
// final addResult = await ref.read(paynymAPIProvider).add(
|
||||||
token.value!,
|
// token.value!,
|
||||||
signature,
|
// signature,
|
||||||
myAccount.nymID,
|
// myAccount.nymID,
|
||||||
pCodeSegwit.toString(),
|
// pCodeSegwit.toString(),
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
return addResult.value ?? false;
|
// return addResult.value ?? false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -210,16 +209,16 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
|
||||||
// payment code already claimed
|
// payment code already claimed
|
||||||
debugPrint("pcode already claimed!!");
|
debugPrint("pcode already claimed!!");
|
||||||
|
|
||||||
final account =
|
// final account =
|
||||||
await ref.read(paynymAPIProvider).nym(pCode.toString());
|
// await ref.read(paynymAPIProvider).nym(pCode.toString());
|
||||||
if (!account.value!.segwit) {
|
// if (!account.value!.segwit) {
|
||||||
for (int i = 0; i < 100; i++) {
|
// for (int i = 0; i < 100; i++) {
|
||||||
final result = await _addSegwitCode(account.value!);
|
// final result = await _addSegwitCode(account.value!);
|
||||||
if (result == true) {
|
// if (result == true) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
|
@ -259,14 +258,14 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
|
||||||
if (claim.value?.claimed == pCode.toString()) {
|
if (claim.value?.claimed == pCode.toString()) {
|
||||||
final account =
|
final account =
|
||||||
await ref.read(paynymAPIProvider).nym(pCode.toString());
|
await ref.read(paynymAPIProvider).nym(pCode.toString());
|
||||||
if (!account.value!.segwit) {
|
// if (!account.value!.segwit) {
|
||||||
for (int i = 0; i < 100; i++) {
|
// for (int i = 0; i < 100; i++) {
|
||||||
final result = await _addSegwitCode(account.value!);
|
// final result = await _addSegwitCode(account.value!);
|
||||||
if (result == true) {
|
// if (result == true) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
ref.read(myPaynymAccountStateProvider.state).state =
|
ref.read(myPaynymAccountStateProvider.state).state =
|
||||||
account.value!;
|
account.value!;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import '../../utilities/text_styles.dart';
|
||||||
import '../../utilities/util.dart';
|
import '../../utilities/util.dart';
|
||||||
import '../../widgets/conditional_parent.dart';
|
import '../../widgets/conditional_parent.dart';
|
||||||
import '../../widgets/custom_buttons/app_bar_icon_button.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_app_bar.dart';
|
||||||
import '../../widgets/desktop/desktop_scaffold.dart';
|
import '../../widgets/desktop/desktop_scaffold.dart';
|
||||||
import '../../widgets/desktop/secondary_button.dart';
|
import '../../widgets/desktop/secondary_button.dart';
|
||||||
|
@ -121,72 +122,75 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
trailing: Padding(
|
trailing: kDisableFollowing
|
||||||
padding: const EdgeInsets.only(right: 12),
|
? null
|
||||||
child: SizedBox(
|
: Padding(
|
||||||
height: 56,
|
padding: const EdgeInsets.only(right: 12),
|
||||||
child: MouseRegion(
|
child: SizedBox(
|
||||||
cursor: SystemMouseCursors.click,
|
height: 56,
|
||||||
onEnter: (_) => setState(() {
|
child: MouseRegion(
|
||||||
_followButtonHoverState = true;
|
cursor: SystemMouseCursors.click,
|
||||||
}),
|
onEnter: (_) => setState(() {
|
||||||
onExit: (_) => setState(() {
|
_followButtonHoverState = true;
|
||||||
_followButtonHoverState = false;
|
}),
|
||||||
}),
|
onExit: (_) => setState(() {
|
||||||
child: GestureDetector(
|
_followButtonHoverState = false;
|
||||||
onTap: () {
|
}),
|
||||||
showDialog<void>(
|
child: GestureDetector(
|
||||||
context: context,
|
onTap: () {
|
||||||
builder: (context) => AddNewPaynymFollowView(
|
showDialog<void>(
|
||||||
walletId: widget.walletId,
|
context: context,
|
||||||
),
|
builder: (context) => AddNewPaynymFollowView(
|
||||||
);
|
walletId: widget.walletId,
|
||||||
},
|
),
|
||||||
child: RoundedContainer(
|
);
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
},
|
||||||
color: _followButtonHoverState
|
child: RoundedContainer(
|
||||||
? Theme.of(context)
|
padding:
|
||||||
.extension<StackColors>()!
|
const EdgeInsets.symmetric(horizontal: 24.0),
|
||||||
.highlight
|
color: _followButtonHoverState
|
||||||
: Colors.transparent,
|
? Theme.of(context)
|
||||||
radiusMultiplier: 100,
|
.extension<StackColors>()!
|
||||||
child: Row(
|
.highlight
|
||||||
children: [
|
: Colors.transparent,
|
||||||
SvgPicture.asset(
|
radiusMultiplier: 100,
|
||||||
Assets.svg.plus,
|
child: Row(
|
||||||
width: 16,
|
children: [
|
||||||
height: 16,
|
SvgPicture.asset(
|
||||||
color: Theme.of(context)
|
Assets.svg.plus,
|
||||||
.extension<StackColors>()!
|
width: 16,
|
||||||
.textDark,
|
height: 16,
|
||||||
),
|
color: Theme.of(context)
|
||||||
const SizedBox(
|
.extension<StackColors>()!
|
||||||
width: 8,
|
.textDark,
|
||||||
),
|
|
||||||
Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Follow",
|
|
||||||
style:
|
|
||||||
STextStyles.desktopButtonSecondaryEnabled(
|
|
||||||
context,
|
|
||||||
).copyWith(
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
const SizedBox(
|
width: 8,
|
||||||
height: 2,
|
),
|
||||||
),
|
Column(
|
||||||
],
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Follow",
|
||||||
|
style: STextStyles
|
||||||
|
.desktopButtonSecondaryEnabled(
|
||||||
|
context,
|
||||||
|
).copyWith(
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
: AppBar(
|
: AppBar(
|
||||||
leading: AppBarBackButton(
|
leading: AppBarBackButton(
|
||||||
|
@ -201,28 +205,29 @@ class _PaynymHomeViewState extends ConsumerState<PaynymHomeView> {
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
Padding(
|
if (!kDisableFollowing)
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
Padding(
|
||||||
child: AspectRatio(
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||||
aspectRatio: 1,
|
child: AspectRatio(
|
||||||
child: AppBarIconButton(
|
aspectRatio: 1,
|
||||||
icon: SvgPicture.asset(
|
child: AppBarIconButton(
|
||||||
Assets.svg.circlePlusFilled,
|
icon: SvgPicture.asset(
|
||||||
width: 20,
|
Assets.svg.circlePlusFilled,
|
||||||
height: 20,
|
width: 20,
|
||||||
color: Theme.of(context)
|
height: 20,
|
||||||
.extension<StackColors>()!
|
color: Theme.of(context)
|
||||||
.accentColorDark,
|
.extension<StackColors>()!
|
||||||
|
.accentColorDark,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
AddNewPaynymFollowView.routeName,
|
||||||
|
arguments: widget.walletId,
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pushNamed(
|
|
||||||
AddNewPaynymFollowView.routeName,
|
|
||||||
arguments: widget.walletId,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
|
|
|
@ -284,13 +284,17 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 20,
|
width: 20,
|
||||||
),
|
),
|
||||||
Expanded(
|
kDisableFollowing
|
||||||
child: PaynymFollowToggleButton(
|
? const Spacer()
|
||||||
walletId: widget.walletId,
|
: Expanded(
|
||||||
paymentCodeStringToFollow: widget.accountLite.code,
|
child: PaynymFollowToggleButton(
|
||||||
style: PaynymFollowToggleButtonStyle.detailsDesktop,
|
walletId: widget.walletId,
|
||||||
),
|
paymentCodeStringToFollow:
|
||||||
),
|
widget.accountLite.code,
|
||||||
|
style:
|
||||||
|
PaynymFollowToggleButtonStyle.detailsDesktop,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (_showInsufficientFundsInfo)
|
if (_showInsufficientFundsInfo)
|
||||||
|
|
|
@ -9,12 +9,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'paynym_bot.dart';
|
|
||||||
import '../../../themes/stack_colors.dart';
|
import '../../../themes/stack_colors.dart';
|
||||||
import '../../../utilities/format.dart';
|
import '../../../utilities/format.dart';
|
||||||
import '../../../utilities/text_styles.dart';
|
import '../../../utilities/text_styles.dart';
|
||||||
import '../../../utilities/util.dart';
|
import '../../../utilities/util.dart';
|
||||||
import '../../../widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
import '../../../widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
||||||
|
import 'paynym_bot.dart';
|
||||||
|
|
||||||
class PaynymCard extends StatefulWidget {
|
class PaynymCard extends StatefulWidget {
|
||||||
const PaynymCard({
|
const PaynymCard({
|
||||||
|
@ -84,10 +85,11 @@ class _PaynymCardState extends State<PaynymCard> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PaynymFollowToggleButton(
|
if (!kDisableFollowing)
|
||||||
walletId: widget.walletId,
|
PaynymFollowToggleButton(
|
||||||
paymentCodeStringToFollow: widget.paymentCodeString,
|
walletId: widget.walletId,
|
||||||
),
|
paymentCodeStringToFollow: widget.paymentCodeString,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1175,8 +1175,10 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
||||||
|
|
||||||
// check if account exists and for matching code to see if claimed
|
// check if account exists and for matching code to see if claimed
|
||||||
if (account.value != null &&
|
if (account.value != null &&
|
||||||
account.value!.nonSegwitPaymentCode.claimed &&
|
account.value!.nonSegwitPaymentCode.claimed
|
||||||
account.value!.segwit) {
|
// &&
|
||||||
|
// account.value!.segwit
|
||||||
|
) {
|
||||||
ref.read(myPaynymAccountStateProvider.state).state =
|
ref.read(myPaynymAccountStateProvider.state).state =
|
||||||
account.value!;
|
account.value!;
|
||||||
|
|
||||||
|
|
|
@ -302,13 +302,14 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (context.mounted) {
|
if (mounted) {
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
|
||||||
// check if account exists and for matching code to see if claimed
|
// check if account exists and for matching code to see if claimed
|
||||||
if (account.value != null &&
|
if (account.value != null && account.value!.nonSegwitPaymentCode.claimed
|
||||||
account.value!.nonSegwitPaymentCode.claimed &&
|
// &&
|
||||||
account.value!.segwit) {
|
// account.value!.segwit
|
||||||
|
) {
|
||||||
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
|
ref.read(myPaynymAccountStateProvider.state).state = account.value!;
|
||||||
|
|
||||||
await Navigator.of(context).pushNamed(
|
await Navigator.of(context).pushNamed(
|
||||||
|
|
|
@ -34,6 +34,8 @@ enum PaynymFollowToggleButtonStyle {
|
||||||
detailsDesktop,
|
detailsDesktop,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const kDisableFollowing = true;
|
||||||
|
|
||||||
class PaynymFollowToggleButton extends ConsumerStatefulWidget {
|
class PaynymFollowToggleButton extends ConsumerStatefulWidget {
|
||||||
const PaynymFollowToggleButton({
|
const PaynymFollowToggleButton({
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -55,7 +57,7 @@ class _PaynymFollowToggleButtonState
|
||||||
extends ConsumerState<PaynymFollowToggleButton> {
|
extends ConsumerState<PaynymFollowToggleButton> {
|
||||||
final isDesktop = Util.isDesktop;
|
final isDesktop = Util.isDesktop;
|
||||||
|
|
||||||
Future<bool> follow() async {
|
Future<bool> _follow() async {
|
||||||
bool loadingPopped = false;
|
bool loadingPopped = false;
|
||||||
unawaited(
|
unawaited(
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
|
@ -160,7 +162,7 @@ class _PaynymFollowToggleButtonState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> unfollow() async {
|
Future<bool> _unfollow() async {
|
||||||
bool loadingPopped = false;
|
bool loadingPopped = false;
|
||||||
unawaited(
|
unawaited(
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
|
@ -264,9 +266,9 @@ class _PaynymFollowToggleButtonState
|
||||||
if (!_lock) {
|
if (!_lock) {
|
||||||
_lock = true;
|
_lock = true;
|
||||||
if (isFollowing) {
|
if (isFollowing) {
|
||||||
await unfollow();
|
await _unfollow();
|
||||||
} else {
|
} else {
|
||||||
await follow();
|
await _follow();
|
||||||
}
|
}
|
||||||
_lock = false;
|
_lock = false;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +293,7 @@ class _PaynymFollowToggleButtonState
|
||||||
width: isDesktop ? 120 : 100,
|
width: isDesktop ? 120 : 100,
|
||||||
buttonHeight: isDesktop ? ButtonHeight.s : ButtonHeight.xl,
|
buttonHeight: isDesktop ? ButtonHeight.s : ButtonHeight.xl,
|
||||||
label: isFollowing ? "Unfollow" : "Follow",
|
label: isFollowing ? "Unfollow" : "Follow",
|
||||||
onPressed: _onPressed,
|
onPressed: kDisableFollowing ? null : _onPressed,
|
||||||
);
|
);
|
||||||
|
|
||||||
case PaynymFollowToggleButtonStyle.detailsPopup:
|
case PaynymFollowToggleButtonStyle.detailsPopup:
|
||||||
|
@ -306,7 +308,7 @@ class _PaynymFollowToggleButtonState
|
||||||
color:
|
color:
|
||||||
Theme.of(context).extension<StackColors>()!.buttonTextSecondary,
|
Theme.of(context).extension<StackColors>()!.buttonTextSecondary,
|
||||||
),
|
),
|
||||||
onPressed: _onPressed,
|
onPressed: kDisableFollowing ? null : _onPressed,
|
||||||
);
|
);
|
||||||
|
|
||||||
case PaynymFollowToggleButtonStyle.detailsDesktop:
|
case PaynymFollowToggleButtonStyle.detailsDesktop:
|
||||||
|
@ -321,7 +323,7 @@ class _PaynymFollowToggleButtonState
|
||||||
Theme.of(context).extension<StackColors>()!.buttonTextSecondary,
|
Theme.of(context).extension<StackColors>()!.buttonTextSecondary,
|
||||||
),
|
),
|
||||||
iconSpacing: 6,
|
iconSpacing: 6,
|
||||||
onPressed: _onPressed,
|
onPressed: kDisableFollowing ? null : _onPressed,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue