From bd659d92c001e0ba551c9398f07d4bb0bc8da2d9 Mon Sep 17 00:00:00 2001 From: Patrick Niemeyer Date: Wed, 2 Oct 2024 14:39:25 -0500 Subject: [PATCH] dapp: Improve UI feedback during pending transactions. --- gui-orchid/lib/util/format_decimal.dart | 2 - .../lib/dapp/orchid/dapp_button.dart | 44 ++++++++++++++- .../dapp/orchid/dapp_transaction_list.dart | 2 - .../lib/dapp/orchid_web3/orchid_erc20.dart | 23 ++++++-- .../dapp/orchid_web3/v0/orchid_web3_v0.dart | 10 ++-- .../dapp/orchid_web3/v1/orchid_web3_v1.dart | 4 +- .../lib/pages/dapp_add_funds.dart | 56 ++++++++++++++----- .../lib/pages/v0/dapp_lock_warn_v0.dart | 35 +++++++----- .../lib/pages/v0/dapp_move_funds_v0.dart | 12 ++-- .../lib/pages/v0/dapp_tabs_v0.dart | 5 +- .../lib/pages/v0/dapp_withdraw_funds_v0.dart | 8 ++- .../lib/pages/v1/dapp_advanced_funds_v1.dart | 6 +- .../lib/pages/v1/dapp_tabs_v1.dart | 8 ++- .../lib/pages/v1/dapp_withdraw_funds_v1.dart | 8 ++- .../lib/pages/tabs/add_stake_panel.dart | 20 +++---- .../lib/pages/tabs/location_panel.dart | 3 +- .../lib/pages/tabs/pull_stake_panel.dart | 3 +- .../lib/pages/tabs/withdraw_stake_panel.dart | 3 +- 18 files changed, 178 insertions(+), 74 deletions(-) diff --git a/gui-orchid/lib/util/format_decimal.dart b/gui-orchid/lib/util/format_decimal.dart index 7243b4e28..fa074deef 100644 --- a/gui-orchid/lib/util/format_decimal.dart +++ b/gui-orchid/lib/util/format_decimal.dart @@ -107,7 +107,6 @@ String formatDecimal( // Implement the min/max manually restricted = trimAndPadDecimal(restricted, minPrecision, maxPrecision); - print("XXX: restricted: $restricted"); var precisionIndicator = ''; if (showPrecisionIndicator) { @@ -122,7 +121,6 @@ String formatDecimal( // Workaround: no internationalization at this stage final unrestricted = value.toString(); - print("XXX: unrestricted: $unrestricted"); precisionIndicator = restricted.length < unrestricted.length ? ellipsis : ''; } diff --git a/web-ethereum/account_dapp/lib/dapp/orchid/dapp_button.dart b/web-ethereum/account_dapp/lib/dapp/orchid/dapp_button.dart index 12001889e..3f0c644b2 100644 --- a/web-ethereum/account_dapp/lib/dapp/orchid/dapp_button.dart +++ b/web-ethereum/account_dapp/lib/dapp/orchid/dapp_button.dart @@ -1,4 +1,6 @@ +import 'package:orchid/orchid/orchid.dart'; import 'package:flutter/material.dart'; +import 'package:orchid/gui-orchid/lib/orchid/orchid_circular_progress.dart'; import 'package:orchid/orchid/orchid_action_button.dart'; class DappButton extends StatelessWidget { @@ -19,7 +21,8 @@ class DappButton extends StatelessWidget { /// use double.infinity for an expandable button, null for the default width this.width, - this.backgroundColor, this.height, + this.backgroundColor, + this.height, }) : super(key: key); @override @@ -36,3 +39,42 @@ class DappButton extends StatelessWidget { ); } } + +// Extend DappButton with a transaction status indicator. +class DappTransactionButton extends DappButton { + final bool txPending; + + const DappTransactionButton({ + Key? key, + required String text, + required VoidCallback? onPressed, + Widget? trailing, + TextStyle? textStyle, + double? width, + double? height, + Color? backgroundColor, + required this.txPending, + }) : super( + key: key, + text: text, + onPressed: onPressed, + trailing: trailing, + textStyle: textStyle, + width: width, + height: height, + backgroundColor: backgroundColor, + ); + + @override + Widget build(BuildContext context) { + return DappButton( + text: txPending ? "Waiting for Transaction" : text, + trailing: txPending ? OrchidCircularProgressIndicator.smallIndeterminate().left(16) : trailing, + onPressed: onPressed, + textStyle: textStyle, + width: width, + height: height, + backgroundColor: backgroundColor, + ); + } +} diff --git a/web-ethereum/account_dapp/lib/dapp/orchid/dapp_transaction_list.dart b/web-ethereum/account_dapp/lib/dapp/orchid/dapp_transaction_list.dart index bad0fd2e4..fd7f97adc 100644 --- a/web-ethereum/account_dapp/lib/dapp/orchid/dapp_transaction_list.dart +++ b/web-ethereum/account_dapp/lib/dapp/orchid/dapp_transaction_list.dart @@ -1,6 +1,4 @@ import 'dart:math'; -import 'package:orchid/api/orchid_eth/chains.dart'; -import 'package:orchid/dapp/preferences/dapp_transaction.dart'; import 'package:orchid/orchid/orchid.dart'; import 'package:orchid/dapp/orchid_web3/orchid_web3_context.dart'; import 'package:orchid/dapp/preferences/user_preferences_dapp.dart'; diff --git a/web-ethereum/account_dapp/lib/dapp/orchid_web3/orchid_erc20.dart b/web-ethereum/account_dapp/lib/dapp/orchid_web3/orchid_erc20.dart index 281a36ef4..cd973b79c 100644 --- a/web-ethereum/account_dapp/lib/dapp/orchid_web3/orchid_erc20.dart +++ b/web-ethereum/account_dapp/lib/dapp/orchid_web3/orchid_erc20.dart @@ -74,11 +74,26 @@ class OrchidERC20 { // For a transaction that uses an ERC20 token, the transaction may require an approval class ERC20PayableTransactionCallbacks { - final Future Function(String approvalHash) onApproval; - final Future Function(String txHash) onTransaction; + final Future Function(String txHash, int seriesIndex, int seriesTotal) onApprovalCallback; + final Future Function(String txHash, int seriesIndex, int seriesTotal) onTransactionCallback; + + bool _hasApproval = false; ERC20PayableTransactionCallbacks({ - required this.onApproval, - required this.onTransaction, + required this.onApprovalCallback, + required this.onTransactionCallback, }); + + Future onApproval(String txHash) async { + _hasApproval = true; + return onApprovalCallback(txHash, 1, 2); // Approval is the first in the series (1 of 2) + } + + Future onTransaction(String txHash) async { + if (_hasApproval) { + return onTransactionCallback(txHash, 2, 2); // If approval has happened, this is the second in the series (2 of 2) + } else { + return onTransactionCallback(txHash, 1, 1); // No approval needed, this is the only transaction (1 of 1) + } + } } \ No newline at end of file diff --git a/web-ethereum/account_dapp/lib/dapp/orchid_web3/v0/orchid_web3_v0.dart b/web-ethereum/account_dapp/lib/dapp/orchid_web3/v0/orchid_web3_v0.dart index 3a01d77e9..e92816d9e 100644 --- a/web-ethereum/account_dapp/lib/dapp/orchid_web3/v0/orchid_web3_v0.dart +++ b/web-ethereum/account_dapp/lib/dapp/orchid_web3/v0/orchid_web3_v0.dart @@ -37,11 +37,12 @@ class OrchidWeb3V0 { /// Transfer the int amount from the user to the specified lottery pot address. /// If the total exceeds walletBalance the amount value is automatically reduced. - Future /*TransactionId*/ > orchidAddFunds({ + Future orchidAddFunds({ required OrchidWallet wallet, required EthereumAddress signer, required Token addBalance, required Token addEscrow, + required ERC20PayableTransactionCallbacks? callbacks, }) async { if (wallet.address == null) { throw Exception("Wallet address is null"); @@ -55,8 +56,6 @@ class OrchidWeb3V0 { var totalOXT = Token.min(addBalance.add(addEscrow), walletBalance); log("Add funds: signer: $signer, amount: ${totalOXT.subtract(addEscrow)}, escrow: $addEscrow"); - List txHashes = []; - // Check allowance and skip approval if sufficient. // function allowance(address owner, address spender) external view returns (uint256) Token oxtAllowance = await _oxt.getERC20Allowance( @@ -69,7 +68,7 @@ class OrchidWeb3V0 { owner: wallet.address!, spender: OrchidContractV0.lotteryContractAddressV0, amount: totalOXT); - txHashes.add(approveTxHash); + callbacks?.onApproval(approveTxHash); } else { log("Add funds: oxtAllowance already sufficient: $oxtAllowance"); } @@ -87,8 +86,7 @@ class OrchidWeb3V0 { TransactionOverride( gasLimit: BigInt.from(OrchidContractV0.gasLimitLotteryPush)), ); - txHashes.add(tx.hash); - return txHashes; + callbacks?.onTransaction(tx.hash); } /// Withdraw from balance and escrow to the wallet address. diff --git a/web-ethereum/account_dapp/lib/dapp/orchid_web3/v1/orchid_web3_v1.dart b/web-ethereum/account_dapp/lib/dapp/orchid_web3/v1/orchid_web3_v1.dart index bca8bf2cb..c47854aee 100644 --- a/web-ethereum/account_dapp/lib/dapp/orchid_web3/v1/orchid_web3_v1.dart +++ b/web-ethereum/account_dapp/lib/dapp/orchid_web3/v1/orchid_web3_v1.dart @@ -30,7 +30,7 @@ class OrchidWeb3V1 { /// Transfer the amount from the user to the specified lottery pot address. /// If the total exceeds walletBalance the balance value is reduced. - Future /*TransactionId*/ > orchidAddFunds({ + Future /*TransactionId*/ orchidAddFunds({ required OrchidWallet wallet, required EthereumAddress signer, required Token addBalance, @@ -64,7 +64,7 @@ class OrchidWeb3V1 { retrieve: retrieve, totalPayable: totalPayable, ); - return [tx.hash]; + return tx.hash; } /// Withdraw funds by moving the specified withdrawEscrow amount from escrow diff --git a/web-ethereum/account_dapp/lib/pages/dapp_add_funds.dart b/web-ethereum/account_dapp/lib/pages/dapp_add_funds.dart index 888320d33..af680ecbb 100644 --- a/web-ethereum/account_dapp/lib/pages/dapp_add_funds.dart +++ b/web-ethereum/account_dapp/lib/pages/dapp_add_funds.dart @@ -1,3 +1,4 @@ +import 'package:orchid/dapp/orchid_web3/orchid_erc20.dart'; import 'package:orchid/orchid/orchid.dart'; import 'package:orchid/api/orchid_crypto.dart'; import 'package:orchid/api/orchid_eth/token_type.dart'; @@ -22,11 +23,12 @@ class AddFundsPane extends StatefulWidget { final tokenType; // Callback to add the funds - final Future> Function({ + final Future Function({ required OrchidWallet? wallet, required EthereumAddress? signer, required Token addBalance, required Token addEscrow, + required ERC20PayableTransactionCallbacks? callbacks, }) addFunds; const AddFundsPane({ @@ -100,9 +102,11 @@ class _AddFundsPaneState extends State with DappTabWalletContext { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - DappButton( - text: s.addFunds, - onPressed: _addFundsFormEnabled ? _addFunds : null), + DappTransactionButton( + text: s.addFunds, + onPressed: _addFundsFormEnabled ? _addFunds : null, + txPending: txPending, + ), ], ), pady(32), @@ -133,7 +137,8 @@ class _AddFundsPaneState extends State with DappTabWalletContext { bool get _addBalanceFieldValid { var value = _addBalanceField.value; - return value != null && value <= (walletBalanceOf(tokenType) ?? tokenType.zero); + return value != null && + value <= (walletBalanceOf(tokenType) ?? tokenType.zero); } bool get _addBalanceFieldError { @@ -142,7 +147,8 @@ class _AddFundsPaneState extends State with DappTabWalletContext { bool get _addDepositFieldValid { var value = _addDepositField.value; - return value != null && value <= (walletBalanceOf(tokenType) ?? tokenType.zero); + return value != null && + value <= (walletBalanceOf(tokenType) ?? tokenType.zero); } bool get _addDepositFieldError { @@ -176,6 +182,8 @@ class _AddFundsPaneState extends State with DappTabWalletContext { _totalAdd.gtZero(); } + // This generic add funds method can be delegated to either the V0 or V1 impls and so must accommodate + // ERC20 token approvals and transactions. void _addFunds() async { if (!_addBalanceFieldValid) { return; @@ -183,22 +191,42 @@ class _AddFundsPaneState extends State with DappTabWalletContext { setState(() { txPending = true; }); + + final progress = ERC20PayableTransactionCallbacks( + onApprovalCallback: (txHash, seriesIndex, seriesTotal) async { + await UserPreferencesDapp().addTransaction(DappTransaction( + transactionHash: txHash, + chainId: web3Context!.chain.chainId /*always Ethereum*/, + type: DappTransactionType.addFunds, + subtype: "approve", + series_index: seriesIndex, + series_total: seriesTotal, + )); + }, + onTransactionCallback: (txHash, seriesIndex, seriesTotal) async { + await UserPreferencesDapp().addTransaction(DappTransaction( + transactionHash: txHash, + chainId: web3Context!.chain.chainId, + // always Ethereum + type: DappTransactionType.addFunds, + // TODO: Localize + subtype: "push", + series_index: seriesIndex, + series_total: seriesTotal, + )); + }, + ); + try { - final txHashes = await widget.addFunds( + await widget.addFunds( wallet: wallet, signer: widget.signer, // nulls guarded by _addBalanceFieldValid and _addDepositFieldValid addBalance: _addBalanceField.value!, addEscrow: _addDepositField.value!, + callbacks: progress, ); - // Persisting the transaction(s) will update the UI elsewhere. - UserPreferencesDapp().addTransactions(txHashes.map((hash) => DappTransaction( - transactionHash: hash, - chainId: widget.context!.chain.chainId, - type: DappTransactionType.addFunds, - ))); - _addBalanceField.clear(); _addDepositField.clear(); setState(() {}); diff --git a/web-ethereum/account_dapp/lib/pages/v0/dapp_lock_warn_v0.dart b/web-ethereum/account_dapp/lib/pages/v0/dapp_lock_warn_v0.dart index 4809481dd..bffbd486f 100644 --- a/web-ethereum/account_dapp/lib/pages/v0/dapp_lock_warn_v0.dart +++ b/web-ethereum/account_dapp/lib/pages/v0/dapp_lock_warn_v0.dart @@ -56,7 +56,8 @@ class _LockWarnPaneV0State extends State { pot!.isUnlocking ? s.unlocking : s.locked); statusText += pot!.isUnlocking ? '\n' + - s.theFundsWillBeAvailableForWithdrawalInTime(pot!.unlockInString()) + s.theFundsWillBeAvailableForWithdrawalInTime( + pot!.unlockInString()) : ''; isUnlockedOrUnlocking = (pot!.isUnlocked || pot!.isUnlocking); } @@ -75,21 +76,25 @@ class _LockWarnPaneV0State extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ if (isUnlockedOrUnlocking) - DappButton( - text: s.lockDeposit, - onPressed: _formEnabled() - ? () { - _lockOrUnlock(lock: true); - } - : null) + DappTransactionButton( + text: s.lockDeposit, + onPressed: _formEnabled() + ? () { + _lockOrUnlock(lock: true); + } + : null, + txPending: _txPending, + ) else - DappButton( - text: s.unlockDeposit, - onPressed: _formEnabled() - ? () { - _lockOrUnlock(lock: false); - } - : null), + DappTransactionButton( + text: s.unlockDeposit, + onPressed: _formEnabled() + ? () { + _lockOrUnlock(lock: false); + } + : null, + txPending: _txPending, + ), ], ), ], diff --git a/web-ethereum/account_dapp/lib/pages/v0/dapp_move_funds_v0.dart b/web-ethereum/account_dapp/lib/pages/v0/dapp_move_funds_v0.dart index e71c6913a..0c10ff3d5 100644 --- a/web-ethereum/account_dapp/lib/pages/v0/dapp_move_funds_v0.dart +++ b/web-ethereum/account_dapp/lib/pages/v0/dapp_move_funds_v0.dart @@ -19,7 +19,7 @@ class MoveFundsPaneV0 extends StatefulWidget { final bool enabled; const MoveFundsPaneV0({ - Key? key, + Key? key, required this.context, required this.pot, required this.signer, @@ -65,8 +65,11 @@ class _MoveFundsPaneV0State extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - DappButton( - text: buttonTitle, onPressed: _formEnabled ? _moveFunds : null), + DappTransactionButton( + text: buttonTitle, + onPressed: _formEnabled ? _moveFunds : null, + txPending: _txPending, + ), ], ), ], @@ -94,7 +97,8 @@ class _MoveFundsPaneV0State extends State { _txPending = true; }); try { - var txHash = await OrchidWeb3V0(widget.context!).orchidMoveBalanceToEscrow( + var txHash = + await OrchidWeb3V0(widget.context!).orchidMoveBalanceToEscrow( signer: widget.signer!, pot: pot!, moveAmount: _moveBalanceField.value!, diff --git a/web-ethereum/account_dapp/lib/pages/v0/dapp_tabs_v0.dart b/web-ethereum/account_dapp/lib/pages/v0/dapp_tabs_v0.dart index ceb968204..c11e77e1e 100644 --- a/web-ethereum/account_dapp/lib/pages/v0/dapp_tabs_v0.dart +++ b/web-ethereum/account_dapp/lib/pages/v0/dapp_tabs_v0.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:orchid/api/orchid_crypto.dart'; import 'package:orchid/api/orchid_eth/token_type.dart'; import 'package:orchid/api/orchid_eth/tokens.dart'; +import 'package:orchid/dapp/orchid_web3/orchid_erc20.dart'; import 'package:orchid/dapp/orchid_web3/orchid_web3_context.dart'; import 'package:orchid/dapp/orchid_web3/v0/orchid_web3_v0.dart'; import 'package:orchid/api/orchid_eth/orchid_account_detail.dart'; @@ -119,11 +120,12 @@ class _DappTabsV0State extends State { } // Defers construction of the contract until needed - Future /*TransactionId*/ > _orchidAddFunds({ + Future _orchidAddFunds({ required OrchidWallet? wallet, required EthereumAddress? signer, required Token addBalance, required Token addEscrow, + required ERC20PayableTransactionCallbacks? callbacks, }) async { if (widget.web3Context == null || signer == null || wallet == null) { throw Exception('No web3 context or null signer'); @@ -133,6 +135,7 @@ class _DappTabsV0State extends State { signer: signer, addBalance: addBalance, addEscrow: addEscrow, + callbacks: callbacks, ); } } diff --git a/web-ethereum/account_dapp/lib/pages/v0/dapp_withdraw_funds_v0.dart b/web-ethereum/account_dapp/lib/pages/v0/dapp_withdraw_funds_v0.dart index 1e2efb5fe..96c97a8f3 100644 --- a/web-ethereum/account_dapp/lib/pages/v0/dapp_withdraw_funds_v0.dart +++ b/web-ethereum/account_dapp/lib/pages/v0/dapp_withdraw_funds_v0.dart @@ -73,9 +73,11 @@ class _WithdrawFundsPaneV0State extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - DappButton( - text: buttonTitle, - onPressed: _withdrawFundsFormEnabled ? _withdrawFunds : null), + DappTransactionButton( + text: buttonTitle, + onPressed: _withdrawFundsFormEnabled ? _withdrawFunds : null, + txPending: _txPending, + ), ], ), ], diff --git a/web-ethereum/account_dapp/lib/pages/v1/dapp_advanced_funds_v1.dart b/web-ethereum/account_dapp/lib/pages/v1/dapp_advanced_funds_v1.dart index ff3fc50e6..1e2f9ecc8 100644 --- a/web-ethereum/account_dapp/lib/pages/v1/dapp_advanced_funds_v1.dart +++ b/web-ethereum/account_dapp/lib/pages/v1/dapp_advanced_funds_v1.dart @@ -116,7 +116,11 @@ class _AdvancedFundsPaneV1State extends State return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - DappButton(text: buttonTitle, onPressed: _formEnabled ? _doTx : null), + DappTransactionButton( + text: buttonTitle, + onPressed: _formEnabled ? _doTx : null, + txPending: txPending, + ), ], ); } diff --git a/web-ethereum/account_dapp/lib/pages/v1/dapp_tabs_v1.dart b/web-ethereum/account_dapp/lib/pages/v1/dapp_tabs_v1.dart index 776d7aa77..390ba6b33 100644 --- a/web-ethereum/account_dapp/lib/pages/v1/dapp_tabs_v1.dart +++ b/web-ethereum/account_dapp/lib/pages/v1/dapp_tabs_v1.dart @@ -1,4 +1,5 @@ import 'package:orchid/api/orchid_eth/tokens.dart'; +import 'package:orchid/dapp/orchid_web3/orchid_erc20.dart'; import 'package:orchid/orchid/orchid.dart'; import 'package:orchid/api/orchid_crypto.dart'; import 'package:orchid/api/orchid_eth/token_type.dart'; @@ -138,20 +139,23 @@ class _DappTabsV1State extends State with TickerProviderStateMixin { } // Defers construction of the contract until needed - Future /*TransactionId*/ > _orchidAddFunds({ + Future _orchidAddFunds({ required OrchidWallet? wallet, required EthereumAddress? signer, required Token addBalance, required Token addEscrow, + required ERC20PayableTransactionCallbacks? callbacks, }) async { if (signer == null || wallet == null) { throw Exception("No signer"); } - return OrchidWeb3V1(widget.web3Context!).orchidAddFunds( + // V1 does not support ERC20 tokens at the moment. + String txHash = await OrchidWeb3V1(widget.web3Context!).orchidAddFunds( wallet: wallet, signer: signer, addBalance: addBalance, addEscrow: addEscrow, ); + callbacks?.onTransaction(txHash); } } diff --git a/web-ethereum/account_dapp/lib/pages/v1/dapp_withdraw_funds_v1.dart b/web-ethereum/account_dapp/lib/pages/v1/dapp_withdraw_funds_v1.dart index 85a089725..36f359f87 100644 --- a/web-ethereum/account_dapp/lib/pages/v1/dapp_withdraw_funds_v1.dart +++ b/web-ethereum/account_dapp/lib/pages/v1/dapp_withdraw_funds_v1.dart @@ -122,9 +122,11 @@ class _WithdrawFundsPaneV1State extends State Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - DappButton( - text: buttonTitle, - onPressed: _formEnabled ? _withdrawFunds : null), + DappTransactionButton( + text: buttonTitle, + onPressed: _formEnabled ? _withdrawFunds : null, + txPending: txPending, + ), ], ), // pady(32), diff --git a/web-ethereum/stake_dapp/lib/pages/tabs/add_stake_panel.dart b/web-ethereum/stake_dapp/lib/pages/tabs/add_stake_panel.dart index 7200ca056..ddd124b83 100644 --- a/web-ethereum/stake_dapp/lib/pages/tabs/add_stake_panel.dart +++ b/web-ethereum/stake_dapp/lib/pages/tabs/add_stake_panel.dart @@ -84,9 +84,10 @@ class _AddStakePanelState extends State .error .top(24), - DappButton( + DappTransactionButton( text: s.addFunds, onPressed: _formEnabled ? _addStake : null, + txPending: txPending, ).top(32), ], ).width(double.infinity); @@ -129,31 +130,28 @@ class _AddStakePanelState extends State txPending = true; }); - bool hasApproval = false; final progress = ERC20PayableTransactionCallbacks( - onApproval: (txHash) async { - hasApproval = true; + onApprovalCallback: (txHash, seriesIndex, seriesTotal) async { await UserPreferencesDapp().addTransaction(DappTransaction( transactionHash: txHash, chainId: web3Context!.chain.chainId, // always Ethereum type: DappTransactionType.addFunds, subtype: "approve", - // TODO: Localize - series_index: 1, - series_total: 2, + series_index: seriesIndex, + series_total: seriesTotal, )); }, - onTransaction: (txHash) async { + onTransactionCallback: (txHash, seriesIndex, seriesTotal) async { await UserPreferencesDapp().addTransaction(DappTransaction( transactionHash: txHash, chainId: web3Context!.chain.chainId, // always Ethereum type: DappTransactionType.addFunds, - subtype: "push", // TODO: Localize - series_index: hasApproval ? 2 : null, - series_total: hasApproval ? 2 : null, + subtype: "push", + series_index: seriesIndex, + series_total: seriesTotal, )); }, ); diff --git a/web-ethereum/stake_dapp/lib/pages/tabs/location_panel.dart b/web-ethereum/stake_dapp/lib/pages/tabs/location_panel.dart index ab4d5bb6a..27f5f651d 100644 --- a/web-ethereum/stake_dapp/lib/pages/tabs/location_panel.dart +++ b/web-ethereum/stake_dapp/lib/pages/tabs/location_panel.dart @@ -72,11 +72,12 @@ class _LocationPanelState extends State .padx(8), ], ), - DappButton( + DappTransactionButton( text: _isPoke ? "POKE" : "UPDATE", onPressed: _isPoke ? (_formEnabled ? _poke : null) : (_formEnabled ? _updateLocation : null), + txPending: txPending, ).top(32), ], ).width(double.infinity); diff --git a/web-ethereum/stake_dapp/lib/pages/tabs/pull_stake_panel.dart b/web-ethereum/stake_dapp/lib/pages/tabs/pull_stake_panel.dart index fd1b6da45..bb3543b1d 100644 --- a/web-ethereum/stake_dapp/lib/pages/tabs/pull_stake_panel.dart +++ b/web-ethereum/stake_dapp/lib/pages/tabs/pull_stake_panel.dart @@ -71,9 +71,10 @@ class _PullStakePanelState extends State showPaste: false, backgroundColor: OrchidColors.dark_background_2, ).top(16).padx(8), - DappButton( + DappTransactionButton( text: "PULL FUNDS", onPressed: _formEnabled ? _pullStake : null, + txPending: txPending, ).top(32), ], ).width(double.infinity); diff --git a/web-ethereum/stake_dapp/lib/pages/tabs/withdraw_stake_panel.dart b/web-ethereum/stake_dapp/lib/pages/tabs/withdraw_stake_panel.dart index 010a8db18..c040b7d62 100644 --- a/web-ethereum/stake_dapp/lib/pages/tabs/withdraw_stake_panel.dart +++ b/web-ethereum/stake_dapp/lib/pages/tabs/withdraw_stake_panel.dart @@ -82,9 +82,10 @@ class _WithdrawStakePanelState extends State contentPadding: EdgeInsets.only(top: 8, bottom: 18, left: 16, right: 16), ).top(16).padx(8), - DappButton( + DappTransactionButton( text: "PULL FUNDS", onPressed: _formEnabled ? _withdrawStake : null, + txPending: txPending, ).top(32), ], ).width(double.infinity);