mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
add token tx send support to gui
This commit is contained in:
parent
b3c4e690c7
commit
42d168dc57
2 changed files with 28 additions and 12 deletions
|
@ -8,6 +8,7 @@ import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
|
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
|
||||||
import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart';
|
import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart';
|
||||||
|
import 'package:stackwallet/pages/token_view/token_view.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart';
|
import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart';
|
||||||
|
@ -46,6 +47,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
||||||
this.isTradeTransaction = false,
|
this.isTradeTransaction = false,
|
||||||
this.isPaynymTransaction = false,
|
this.isPaynymTransaction = false,
|
||||||
this.isPaynymNotificationTransaction = false,
|
this.isPaynymNotificationTransaction = false,
|
||||||
|
this.isTokenTx = false,
|
||||||
this.onSuccessInsteadOfRouteOnSuccess,
|
this.onSuccessInsteadOfRouteOnSuccess,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@ -57,6 +59,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
||||||
final bool isTradeTransaction;
|
final bool isTradeTransaction;
|
||||||
final bool isPaynymTransaction;
|
final bool isPaynymTransaction;
|
||||||
final bool isPaynymNotificationTransaction;
|
final bool isPaynymNotificationTransaction;
|
||||||
|
final bool isTokenTx;
|
||||||
final VoidCallback? onSuccessInsteadOfRouteOnSuccess;
|
final VoidCallback? onSuccessInsteadOfRouteOnSuccess;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -102,7 +105,11 @@ class _ConfirmTransactionViewState
|
||||||
final note = noteController.text;
|
final note = noteController.text;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (widget.isPaynymNotificationTransaction) {
|
if (widget.isTokenTx) {
|
||||||
|
txidFuture = ref
|
||||||
|
.read(tokenServiceProvider)!
|
||||||
|
.confirmSend(txData: transactionInfo);
|
||||||
|
} else if (widget.isPaynymNotificationTransaction) {
|
||||||
txidFuture = (manager.wallet as PaynymWalletInterface)
|
txidFuture = (manager.wallet as PaynymWalletInterface)
|
||||||
.broadcastNotificationTx(preparedTx: transactionInfo);
|
.broadcastNotificationTx(preparedTx: transactionInfo);
|
||||||
} else if (widget.isPaynymTransaction) {
|
} else if (widget.isPaynymTransaction) {
|
||||||
|
@ -132,7 +139,11 @@ class _ConfirmTransactionViewState
|
||||||
.read(notesServiceChangeNotifierProvider(walletId))
|
.read(notesServiceChangeNotifierProvider(walletId))
|
||||||
.editOrAddNote(txid: txid, note: note);
|
.editOrAddNote(txid: txid, note: note);
|
||||||
|
|
||||||
|
if (widget.isTokenTx) {
|
||||||
|
unawaited(ref.read(tokenServiceProvider)!.refresh());
|
||||||
|
} else {
|
||||||
unawaited(manager.refresh());
|
unawaited(manager.refresh());
|
||||||
|
}
|
||||||
|
|
||||||
// pop back to wallet
|
// pop back to wallet
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
@ -258,6 +269,15 @@ class _ConfirmTransactionViewState
|
||||||
final managerProvider = ref.watch(walletsChangeNotifierProvider
|
final managerProvider = ref.watch(walletsChangeNotifierProvider
|
||||||
.select((value) => value.getManagerProvider(walletId)));
|
.select((value) => value.getManagerProvider(walletId)));
|
||||||
|
|
||||||
|
final String unit;
|
||||||
|
if (widget.isTokenTx) {
|
||||||
|
unit = ref.watch(
|
||||||
|
tokenServiceProvider.select((value) => value!.tokenContract.symbol));
|
||||||
|
} else {
|
||||||
|
unit = ref.watch(walletsChangeNotifierProvider
|
||||||
|
.select((value) => value.getManager(walletId).coin.ticker));
|
||||||
|
}
|
||||||
|
|
||||||
return ConditionalParent(
|
return ConditionalParent(
|
||||||
condition: !isDesktop,
|
condition: !isDesktop,
|
||||||
builder: (child) => Background(
|
builder: (child) => Background(
|
||||||
|
@ -324,7 +344,7 @@ class _ConfirmTransactionViewState
|
||||||
).pop(),
|
).pop(),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"Confirm ${ref.watch(managerProvider.select((value) => value.coin.ticker.toUpperCase()))} transaction",
|
"Confirm $unit transaction",
|
||||||
style: STextStyles.desktopH3(context),
|
style: STextStyles.desktopH3(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -341,7 +361,7 @@ class _ConfirmTransactionViewState
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Send ${ref.watch(managerProvider.select((value) => value.coin)).ticker}",
|
"Send $unit",
|
||||||
style: STextStyles.pageTitleH1(context),
|
style: STextStyles.pageTitleH1(context),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -388,9 +408,7 @@ class _ConfirmTransactionViewState
|
||||||
.select((value) => value.locale),
|
.select((value) => value.locale),
|
||||||
), ref.watch(
|
), ref.watch(
|
||||||
managerProvider.select((value) => value.coin),
|
managerProvider.select((value) => value.coin),
|
||||||
))} ${ref.watch(
|
))} $unit",
|
||||||
managerProvider.select((value) => value.coin),
|
|
||||||
).ticker}",
|
|
||||||
style: STextStyles.itemSubtitle12(context),
|
style: STextStyles.itemSubtitle12(context),
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
),
|
),
|
||||||
|
@ -492,10 +510,7 @@ class _ConfirmTransactionViewState
|
||||||
width: 16,
|
width: 16,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"Send ${ref.watch(
|
"Send $unit",
|
||||||
managerProvider
|
|
||||||
.select((value) => value.coin),
|
|
||||||
).ticker}",
|
|
||||||
style: STextStyles.desktopTextMedium(context),
|
style: STextStyles.desktopTextMedium(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -559,7 +574,7 @@ class _ConfirmTransactionViewState
|
||||||
.select((value) => value.locale),
|
.select((value) => value.locale),
|
||||||
),
|
),
|
||||||
coin,
|
coin,
|
||||||
)} ${coin.ticker}",
|
)} $unit",
|
||||||
style: STextStyles
|
style: STextStyles
|
||||||
.desktopTextExtraExtraSmall(
|
.desktopTextExtraExtraSmall(
|
||||||
context)
|
context)
|
||||||
|
|
|
@ -513,6 +513,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
||||||
builder: (_) => ConfirmTransactionView(
|
builder: (_) => ConfirmTransactionView(
|
||||||
transactionInfo: txData,
|
transactionInfo: txData,
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
|
isTokenTx: true,
|
||||||
),
|
),
|
||||||
settings: const RouteSettings(
|
settings: const RouteSettings(
|
||||||
name: ConfirmTransactionView.routeName,
|
name: ConfirmTransactionView.routeName,
|
||||||
|
|
Loading…
Reference in a new issue