fix preview button label (refactor mwc tx type provider)
What changed, and why it matters
This commit is a code cleanup and UI consistency change for the Stack Wallet app. It replaces repeated checks of a global Mimblewimblecoin transaction method with a single wallet-scoped helper. The visible effect is making sure the preview/send button shows the correct label ("Create slatepack" vs "Preview") based on whether the current wallet is using slatepack transactions. There is no obvious security vulnerability in the diff itself.
No security action required. Treat as a normal UI refactor/code-quality commit. Reviewers may optionally verify that pIsSlatepack returns false for non-MWC wallets and that the button label/behavior remains consistent across mobile and desktop send/receive flows.
Security signals we found
No memory-safety issues, injection points, or cryptographic changes present
No new network, storage, or permission code introduced
Refactor centralizes UI state logic but does not change authorization or transaction flow
Diff is dominated by formatting and provider substitution
Evidence from the diff
The change refactors how the UI determines whether Mimblewimblecoin (MWC) transactions are in slatepack mode. Previously, several widgets directly watched pSelectedMwcTransactionMethod and compared it to MwcTransactionMethod.slatepack. The patch introduces a new Provider.family
Changed components
lib/pages/send_view/send_view.dartlib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dartlib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dartlib/providers/ui/preview_tx_button_state_provider.dartInspect captured patch +553 / −608
diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart
index 855d1bd..52f44de 100644
--- a/lib/pages/send_view/send_view.dart
+++ b/lib/pages/send_view/send_view.dart
@@ -41,7 +41,6 @@ import '../../utilities/barcode_scanner_interface.dart';
import '../../utilities/clipboard_interface.dart';
import '../../utilities/constants.dart';
import '../../utilities/enums/fee_rate_type_enum.dart';
-import '../../utilities/enums/mwc_transaction_method.dart';
import '../../utilities/eth_commons.dart';
import '../../utilities/extensions/extensions.dart';
import '../../utilities/logger.dart';
@@ -1377,9 +1376,7 @@ class _SendViewState extends ConsumerState<SendView> {
}
final isMwcSlatepack =
- coin is Mimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack;
+ coin is Mimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId));
return Background(
child: Scaffold(
@@ -2622,8 +2619,7 @@ class _SendViewState extends ConsumerState<SendView> {
TextButton(
onPressed:
ref.watch(pPreviewTxButtonEnabled(coin))
- ? ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack
+ ? ref.watch(pIsSlatepack(widget.walletId))
? _createSlatepack
: _previewTransaction
: null,
@@ -2635,8 +2631,7 @@ class _SendViewState extends ConsumerState<SendView> {
.extension<StackColors>()!
.getPrimaryDisabledButtonStyle(context),
child: Text(
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack
+ ref.watch(pIsSlatepack(widget.walletId))
? "Create slatepack"
: "Preview",
style: STextStyles.button(context),
diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart
index 27d9f75..607bf3f 100644
--- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart
+++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart
@@ -32,7 +32,6 @@ import '../../../../utilities/assets.dart';
import '../../../../utilities/clipboard_interface.dart';
import '../../../../utilities/constants.dart';
import '../../../../utilities/enums/derive_path_type_enum.dart';
-import '../../../../utilities/enums/mwc_transaction_method.dart';
import '../../../../utilities/show_loading.dart';
import '../../../../utilities/text_styles.dart';
import '../../../../utilities/util.dart';
@@ -128,14 +127,12 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
await showDialog<void>(
context: context,
useRootNavigator: true,
- builder:
- (context) => StackOkDialog(
- desktopPopRootNavigator: true,
- title: "Slatepack receive error",
- message:
- ex?.toString() ?? "Unexpected result without exception",
- maxWidth: 400,
- ),
+ builder: (context) => StackOkDialog(
+ desktopPopRootNavigator: true,
+ title: "Slatepack receive error",
+ message: ex?.toString() ?? "Unexpected result without exception",
+ maxWidth: 400,
+ ),
);
}
return;
@@ -145,30 +142,28 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
final response =
await showDialog<({String responseSlatepack, bool wasEncrypted})>(
context: context,
- builder:
- (context) => SDialog(
- child: SizedBox(
- width: 700,
- child: MwcSlatepackImportDialog(
- walletId: widget.walletId,
- clipboard: widget.clipboard,
- rawSlatepack: result.raw,
- decoded: result.result,
- slatepackType: result.type,
- ),
- ),
+ builder: (context) => SDialog(
+ child: SizedBox(
+ width: 700,
+ child: MwcSlatepackImportDialog(
+ walletId: widget.walletId,
+ clipboard: widget.clipboard,
+ rawSlatepack: result.raw,
+ decoded: result.result,
+ slatepackType: result.type,
),
+ ),
+ ),
);
if (mounted && response != null) {
await showDialog<void>(
context: context,
barrierDismissible: false,
- builder:
- (context) => SlatepackResponseDialog(
- responseSlatepack: response.responseSlatepack,
- wasEncrypted: response.wasEncrypted,
- ),
+ builder: (context) => SlatepackResponseDialog(
+ responseSlatepack: response.responseSlatepack,
+ wasEncrypted: response.wasEncrypted,
+ ),
);
}
}
@@ -517,94 +512,85 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
),
),
),
- if (!(isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack))
+ if (!(isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId))))
const SizedBox(height: 20),
- if (!(isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack))
+ if (!(isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId))))
ConditionalParent(
condition: showMultiType,
- builder:
- (child) => Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- DropdownButtonHideUnderline(
- child: DropdownButton2<int>(
- value: _currentIndex,
- items: [
- for (int i = 0; i < _walletAddressTypes.length; i++)
- DropdownMenuItem(
- value: i,
- child: Text(
- supportsSpark &&
- _walletAddressTypes[i] ==
- AddressType.p2pkh
- ? "Transparent address"
- : "${_walletAddressTypes[i].readableName} address",
- style: STextStyles.w500_14(context),
- ),
- ),
- ],
- onChanged: (value) {
- if (value != null && value != _currentIndex) {
- setState(() {
- _currentIndex = value;
- });
- }
- },
- isExpanded: true,
- iconStyleData: IconStyleData(
- icon: Padding(
- padding: const EdgeInsets.only(right: 10),
- child: SvgPicture.asset(
- Assets.svg.chevronDown,
- width: 12,
- height: 6,
- color:
- Theme.of(context)
- .extension<StackColors>()!
- .textFieldActiveSearchIconRight,
- ),
+ builder: (child) => Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ DropdownButtonHideUnderline(
+ child: DropdownButton2<int>(
+ value: _currentIndex,
+ items: [
+ for (int i = 0; i < _walletAddressTypes.length; i++)
+ DropdownMenuItem(
+ value: i,
+ child: Text(
+ supportsSpark &&
+ _walletAddressTypes[i] == AddressType.p2pkh
+ ? "Transparent address"
+ : "${_walletAddressTypes[i].readableName} address",
+ style: STextStyles.w500_14(context),
),
),
- buttonStyleData: ButtonStyleData(
- decoration: BoxDecoration(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldDefaultBG,
- borderRadius: BorderRadius.circular(
- Constants.size.circularBorderRadius,
- ),
- ),
+ ],
+ onChanged: (value) {
+ if (value != null && value != _currentIndex) {
+ setState(() {
+ _currentIndex = value;
+ });
+ }
+ },
+ isExpanded: true,
+ iconStyleData: IconStyleData(
+ icon: Padding(
+ padding: const EdgeInsets.only(right: 10),
+ child: SvgPicture.asset(
+ Assets.svg.chevronDown,
+ width: 12,
+ height: 6,
+ color: Theme.of(context)
+ .extension<StackColors>()!
+ .textFieldActiveSearchIconRight,
),
- dropdownStyleData: DropdownStyleData(
- offset: const Offset(0, -10),
- elevation: 0,
- decoration: BoxDecoration(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldDefaultBG,
- borderRadius: BorderRadius.circular(
- Constants.size.circularBorderRadius,
- ),
- ),
+ ),
+ ),
+ buttonStyleData: ButtonStyleData(
+ decoration: BoxDecoration(
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldDefaultBG,
+ borderRadius: BorderRadius.circular(
+ Constants.size.circularBorderRadius,
),
- menuItemStyleData: const MenuItemStyleData(
- padding: EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 8,
- ),
+ ),
+ ),
+ dropdownStyleData: DropdownStyleData(
+ offset: const Offset(0, -10),
+ elevation: 0,
+ decoration: BoxDecoration(
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldDefaultBG,
+ borderRadius: BorderRadius.circular(
+ Constants.size.circularBorderRadius,
),
),
),
- const SizedBox(height: 12),
- child,
- ],
+ menuItemStyleData: const MenuItemStyleData(
+ padding: EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 8,
+ ),
+ ),
+ ),
),
+ const SizedBox(height: 12),
+ child,
+ ],
+ ),
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
@@ -620,10 +606,9 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
child: Container(
decoration: BoxDecoration(
border: Border.all(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.backgroundAppBar,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.backgroundAppBar,
width: 1,
),
borderRadius: BorderRadius.circular(
@@ -646,10 +631,9 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
Assets.svg.copy,
width: 15,
height: 15,
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.infoItemIcons,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.infoItemIcons,
),
const SizedBox(width: 4),
Text("Copy", style: STextStyles.link2(context)),
@@ -663,14 +647,14 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
Expanded(
child: Text(
address,
- style: STextStyles.desktopTextExtraExtraSmall(
- context,
- ).copyWith(
- color:
- Theme.of(
+ style:
+ STextStyles.desktopTextExtraExtraSmall(
+ context,
+ ).copyWith(
+ color: Theme.of(
context,
).extension<StackColors>()!.textDark,
- ),
+ ),
),
),
],
@@ -690,18 +674,16 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
buttonHeight: ButtonHeight.l,
onPressed:
supportsMweb &&
- _walletAddressTypes[_currentIndex] == AddressType.mweb
- ? generateNewMwebAddress
- : supportsSpark &&
- _walletAddressTypes[_currentIndex] == AddressType.spark
- ? generateNewSparkAddress
- : generateNewAddress,
+ _walletAddressTypes[_currentIndex] == AddressType.mweb
+ ? generateNewMwebAddress
+ : supportsSpark &&
+ _walletAddressTypes[_currentIndex] == AddressType.spark
+ ? generateNewSparkAddress
+ : generateNewAddress,
label: "Generate new address",
),
const SizedBox(height: 20),
- if (isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack)
+ if (isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId)))
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -709,10 +691,9 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
Text(
"Receive Slatepack",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(context)
- .extension<StackColors>()!
- .textFieldActiveSearchIconRight,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveSearchIconRight,
),
textAlign: TextAlign.left,
),
@@ -743,61 +724,60 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
},
focusNode: _slateFocusNode,
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveText,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveText,
height: 1.8,
),
- decoration: standardInputDecoration(
- "Enter Slatepack Message",
- _slateFocusNode,
- context,
- desktopMed: true,
- ).copyWith(
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical:
- 12, // Adjust vertical padding for better alignment
- ),
- suffixIcon: Padding(
- padding:
- _receiveSlateController.text.isEmpty
+ decoration:
+ standardInputDecoration(
+ "Enter Slatepack Message",
+ _slateFocusNode,
+ context,
+ desktopMed: true,
+ ).copyWith(
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical:
+ 12, // Adjust vertical padding for better alignment
+ ),
+ suffixIcon: Padding(
+ padding: _receiveSlateController.text.isEmpty
? const EdgeInsets.only(right: 8)
: const EdgeInsets.only(right: 0),
- child: UnconstrainedBox(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- _slateToggleFlag
- ? TextFieldIconButton(
- key: const Key(
- "receiveViewClearSlatepackFieldButtonKey",
- ),
- onTap: () {
- _receiveSlateController.text = "";
- _slate = "";
- setState(() {
- _slateToggleFlag = false;
- });
- },
- child: const XIcon(),
- )
- : TextFieldIconButton(
- key: const Key(
- "receiveViewPasteSlatepackFieldButtonKey",
- ),
- onTap: _pasteSlatepack,
- child:
- _receiveSlateController.text.isEmpty
- ? const ClipboardIcon()
- : const XIcon(),
- ),
- ],
+ child: UnconstrainedBox(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
+ children: [
+ _slateToggleFlag
+ ? TextFieldIconButton(
+ key: const Key(
+ "receiveViewClearSlatepackFieldButtonKey",
+ ),
+ onTap: () {
+ _receiveSlateController.text = "";
+ _slate = "";
+ setState(() {
+ _slateToggleFlag = false;
+ });
+ },
+ child: const XIcon(),
+ )
+ : TextFieldIconButton(
+ key: const Key(
+ "receiveViewPasteSlatepackFieldButtonKey",
+ ),
+ onTap: _pasteSlatepack,
+ child:
+ _receiveSlateController.text.isEmpty
+ ? const ClipboardIcon()
+ : const XIcon(),
+ ),
+ ],
+ ),
+ ),
),
),
- ),
- ),
),
),
],
@@ -834,9 +814,7 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
// TODO: create transparent button class to account for hover
// Conditional logic for 'Submit' button or QR code
- if (isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack)
+ if (isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId)))
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: PrimaryButton(
@@ -852,38 +830,36 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
if (Util.isDesktop) {
await showDialog<void>(
context: context,
- builder:
- (context) => DesktopDialog(
- maxHeight: double.infinity,
- maxWidth: 580,
- child: Column(
+ builder: (context) => DesktopDialog(
+ maxHeight: double.infinity,
+ maxWidth: 580,
+ child: Column(
+ children: [
+ Row(
children: [
- Row(
- children: [
- const AppBarBackButton(size: 40, iconSize: 24),
- Text(
- "Generate QR code",
- style: STextStyles.desktopH3(context),
- ),
- ],
- ),
- IntrinsicHeight(
- child: Navigator(
- onGenerateRoute: RouteGenerator.generateRoute,
- onGenerateInitialRoutes:
- (_, __) => [
- RouteGenerator.generateRoute(
- RouteSettings(
- name: GenerateUriQrCodeView.routeName,
- arguments: Tuple2(coin, address),
- ),
- ),
- ],
- ),
+ const AppBarBackButton(size: 40, iconSize: 24),
+ Text(
+ "Generate QR code",
+ style: STextStyles.desktopH3(context),
),
],
),
- ),
+ IntrinsicHeight(
+ child: Navigator(
+ onGenerateRoute: RouteGenerator.generateRoute,
+ onGenerateInitialRoutes: (_, __) => [
+ RouteGenerator.generateRoute(
+ RouteSettings(
+ name: GenerateUriQrCodeView.routeName,
+ arguments: Tuple2(coin, address),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
);
} else {
unawaited(
@@ -891,11 +867,10 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
RouteGenerator.getRoute(
shouldUseMaterialRoute:
RouteGenerator.useMaterialPageRoute,
- builder:
- (_) => GenerateUriQrCodeView(
- coin: coin,
- receivingAddress: address,
- ),
+ builder: (_) => GenerateUriQrCodeView(
+ coin: coin,
+ receivingAddress: address,
+ ),
settings: const RouteSettings(
name: GenerateUriQrCodeView.routeName,
),
@@ -914,19 +889,17 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
Assets.svg.qrcode,
width: 14,
height: 16,
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.accentColorBlue,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.accentColorBlue,
),
const SizedBox(width: 8),
Text(
"Create new QR code",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.accentColorBlue,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.accentColorBlue,
),
),
],
diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart
index ac30df2..c476879 100644
--- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart
+++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart
@@ -42,7 +42,6 @@ import '../../../../utilities/amount/amount_unit.dart';
import '../../../../utilities/assets.dart';
import '../../../../utilities/clipboard_interface.dart';
import '../../../../utilities/constants.dart';
-import '../../../../utilities/enums/mwc_transaction_method.dart';
import '../../../../utilities/logger.dart';
import '../../../../utilities/prefs.dart';
import '../../../../utilities/show_loading.dart';
@@ -220,12 +219,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
await showDialog<void>(
context: context,
barrierDismissible: false,
- builder:
- (context) => DesktopDialog(
- maxHeight: double.infinity,
- maxWidth: 700,
- child: MwcSlatepackDialog(slatepackResult: slatepackResult),
- ),
+ builder: (context) => DesktopDialog(
+ maxHeight: double.infinity,
+ maxWidth: 700,
+ child: MwcSlatepackDialog(slatepackResult: slatepackResult),
+ ),
);
// Clear form after slatepack dialog is closed.
@@ -241,55 +239,54 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (mounted) {
await showDialog<void>(
context: context,
- builder:
- (context) => DesktopDialog(
- maxWidth: 450,
- maxHeight: double.infinity,
- child: Padding(
- padding: const EdgeInsets.only(left: 32, bottom: 32),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ builder: (context) => DesktopDialog(
+ maxWidth: 450,
+ maxHeight: double.infinity,
+ child: Padding(
+ padding: const EdgeInsets.only(left: 32, bottom: 32),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- 'Slatepack Creation Failed',
- style: STextStyles.desktopH3(context),
- ),
- const DesktopDialogCloseButton(),
- ],
- ),
- const SizedBox(height: 12),
- Padding(
- padding: const EdgeInsets.only(right: 32),
- child: Text(
- 'Failed to create slatepack: $e',
- textAlign: TextAlign.left,
- style: STextStyles.desktopTextExtraExtraSmall(
- context,
- ).copyWith(fontSize: 18),
- ),
- ),
- const SizedBox(height: 40),
- Padding(
- padding: const EdgeInsets.only(right: 32),
- child: Row(
- children: [
- Expanded(
- child: PrimaryButton(
- buttonHeight: ButtonHeight.l,
- label: 'OK',
- onPressed: () => Navigator.of(context).pop(),
- ),
- ),
- ],
- ),
+ Text(
+ 'Slatepack Creation Failed',
+ style: STextStyles.desktopH3(context),
),
+ const DesktopDialogCloseButton(),
],
),
- ),
+ const SizedBox(height: 12),
+ Padding(
+ padding: const EdgeInsets.only(right: 32),
+ child: Text(
+ 'Failed to create slatepack: $e',
+ textAlign: TextAlign.left,
+ style: STextStyles.desktopTextExtraExtraSmall(
+ context,
+ ).copyWith(fontSize: 18),
+ ),
+ ),
+ const SizedBox(height: 40),
+ Padding(
+ padding: const EdgeInsets.only(right: 32),
+ child: Row(
+ children: [
+ Expanded(
+ child: PrimaryButton(
+ buttonHeight: ButtonHeight.l,
+ label: 'OK',
+ onPressed: () => Navigator.of(context).pop(),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
),
+ ),
+ ),
);
}
}
@@ -299,9 +296,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final wallet = ref.read(pWallets).getWallet(walletId);
// Handle MWC slatepack transactions directly.
- if (isMimblewimblecoin &&
- ref.read(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack) {
+ if (isMimblewimblecoin && ref.read(pIsSlatepack(widget.walletId))) {
await _handleDesktopSlatepackCreation(wallet as MimblewimblecoinWallet);
return;
}
@@ -314,18 +309,18 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
availableBalance = wallet.info.cachedBalance.spendable;
break;
case BalanceType.private:
- availableBalance =
- coin is Firo
- ? wallet.info.cachedBalanceTertiary.spendable
- : wallet.info.cachedBalanceSecondary.spendable;
+ availableBalance = coin is Firo
+ ? wallet.info.cachedBalanceTertiary.spendable
+ : wallet.info.cachedBalanceSecondary.spendable;
break;
}
} else {
availableBalance = wallet.info.cachedBalance.spendable;
}
- final coinControlEnabled =
- ref.read(prefsChangeNotifierProvider).enableCoinControl;
+ final coinControlEnabled = ref
+ .read(prefsChangeNotifierProvider)
+ .enableCoinControl;
if (!(wallet is CoinControlInterface && coinControlEnabled) ||
(coinControlEnabled && ref.read(desktopUseUTXOs).isEmpty)) {
@@ -466,10 +461,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
feeRateType: feeRate,
utxos:
(wallet is CoinControlInterface &&
- coinControlEnabled &&
- ref.read(pDesktopUseUTXOs).isNotEmpty)
- ? ref.read(pDesktopUseUTXOs)
- : null,
+ coinControlEnabled &&
+ ref.read(pDesktopUseUTXOs).isNotEmpty)
+ ? ref.read(pDesktopUseUTXOs)
+ : null,
),
);
} else if (wallet is FiroWallet) {
@@ -490,9 +485,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
satsPerVByte: isCustomFee ? customFeeRate : null,
utxos:
(coinControlEnabled &&
- ref.read(pDesktopUseUTXOs).isNotEmpty)
- ? ref.read(pDesktopUseUTXOs)
- : null,
+ ref.read(pDesktopUseUTXOs).isNotEmpty)
+ ? ref.read(pDesktopUseUTXOs)
+ : null,
),
);
} else {
@@ -503,17 +498,18 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
address: _address!,
amount: amount,
isChange: false,
- addressType:
- wallet.cryptoCurrency.getAddressType(_address!)!,
+ addressType: wallet.cryptoCurrency.getAddressType(
+ _address!,
+ )!,
),
],
feeRateType: ref.read(feeRateTypeDesktopStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null,
utxos:
(coinControlEnabled &&
- ref.read(pDesktopUseUTXOs).isNotEmpty)
- ? ref.read(pDesktopUseUTXOs)
- : null,
+ ref.read(pDesktopUseUTXOs).isNotEmpty)
+ ? ref.read(pDesktopUseUTXOs)
+ : null,
),
);
}
@@ -522,31 +518,28 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
case BalanceType.private:
txDataFuture = wallet.prepareSendSpark(
txData: TxData(
- recipients:
- ref.read(pValidSparkSendToAddress)
- ? null
- : [
- TxRecipient(
- address: _address!,
- amount: amount,
- isChange: false,
- addressType:
- wallet.cryptoCurrency.getAddressType(
- _address!,
- )!,
- ),
- ],
- sparkRecipients:
- ref.read(pValidSparkSendToAddress)
- ? [
- (
- address: _address!,
- amount: amount,
- memo: memoController.text,
- isChange: false,
- ),
- ]
- : null,
+ recipients: ref.read(pValidSparkSendToAddress)
+ ? null
+ : [
+ TxRecipient(
+ address: _address!,
+ amount: amount,
+ isChange: false,
+ addressType: wallet.cryptoCurrency.getAddressType(
+ _address!,
+ )!,
+ ),
+ ],
+ sparkRecipients: ref.read(pValidSparkSendToAddress)
+ ? [
+ (
+ address: _address!,
+ amount: amount,
+ memo: memoController.text,
+ isChange: false,
+ ),
+ ]
+ : null,
),
);
break;
@@ -590,16 +583,15 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
memo: memo,
feeRateType: ref.read(feeRateTypeDesktopStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null,
- nonce:
- wallet.cryptoCurrency is Ethereum
- ? int.tryParse(nonceController.text)
- : null,
+ nonce: wallet.cryptoCurrency is Ethereum
+ ? int.tryParse(nonceController.text)
+ : null,
utxos:
(wallet is CoinControlInterface &&
- coinControlEnabled &&
- ref.read(pDesktopUseUTXOs).isNotEmpty)
- ? ref.read(pDesktopUseUTXOs)
- : null,
+ coinControlEnabled &&
+ ref.read(pDesktopUseUTXOs).isNotEmpty)
+ ? ref.read(pDesktopUseUTXOs)
+ : null,
ethEIP1559Fee: ethFee,
),
);
@@ -630,18 +622,17 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
unawaited(
showDialog(
context: context,
- builder:
- (context) => DesktopDialog(
- maxHeight: MediaQuery.of(context).size.height - 64,
- maxWidth: 580,
- child: ConfirmTransactionView(
- txData: txData,
- walletId: walletId,
- onSuccess: clearSendForm,
- isPaynymTransaction: isPaynymSend,
- routeOnSuccessName: DesktopHomeView.routeName,
- ),
- ),
+ builder: (context) => DesktopDialog(
+ maxHeight: MediaQuery.of(context).size.height - 64,
+ maxWidth: 580,
+ child: ConfirmTransactionView(
+ txData: txData,
+ walletId: walletId,
+ onSuccess: clearSendForm,
+ isPaynymTransaction: isPaynymSend,
+ routeOnSuccessName: DesktopHomeView.routeName,
+ ),
+ ),
),
);
}
@@ -740,8 +731,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
_cachedAmountToSend = amount;
- final price =
- ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin)?.value;
+ final price = ref
+ .read(priceAnd24hChangeNotifierProvider)
+ .getPrice(coin)
+ ?.value;
if (price != null && price > Decimal.zero) {
final String fiatAmountString = (amount.decimal * price)
@@ -979,18 +972,19 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
);
final Amount? amount;
if (baseAmount != null) {
- final _price =
- ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin)?.value;
+ final _price = ref
+ .read(priceAnd24hChangeNotifierProvider)
+ .getPrice(coin)
+ ?.value;
if (_price == null || _price == Decimal.zero) {
amount = Decimal.zero.toAmount(fractionDigits: coin.fractionDigits);
} else {
- amount =
- baseAmount <= Amount.zero
- ? Decimal.zero.toAmount(fractionDigits: coin.fractionDigits)
- : (baseAmount.decimal / _price)
- .toDecimal(scaleOnInfinitePrecision: coin.fractionDigits)
- .toAmount(fractionDigits: coin.fractionDigits);
+ amount = baseAmount <= Amount.zero
+ ? Decimal.zero.toAmount(fractionDigits: coin.fractionDigits)
+ : (baseAmount.decimal / _price)
+ .toDecimal(scaleOnInfinitePrecision: coin.fractionDigits)
+ .toAmount(fractionDigits: coin.fractionDigits);
}
if (_cachedAmountToSend != null && _cachedAmountToSend == amount) {
return;
@@ -1042,10 +1036,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
amount = ref.read(pWalletBalance(walletId)).spendable;
break;
case BalanceType.private:
- amount =
- coin is Firo
- ? ref.read(pWalletBalanceTertiary(walletId)).spendable
- : ref.read(pWalletBalanceSecondary(walletId)).spendable;
+ amount = coin is Firo
+ ? ref.read(pWalletBalanceTertiary(walletId)).spendable
+ : ref.read(pWalletBalanceSecondary(walletId)).spendable;
break;
}
} else {
@@ -1061,11 +1054,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final amount = ref.read(pSendAmount);
await showDialog<void>(
context: context,
- builder:
- (context) => DesktopCoinControlUseDialog(
- walletId: widget.walletId,
- amountToSend: amount,
- ),
+ builder: (context) => DesktopCoinControlUseDialog(
+ walletId: widget.walletId,
+ amountToSend: amount,
+ ),
);
}
@@ -1261,10 +1253,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Text(
"Send from",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveSearchIconRight,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveSearchIconRight,
),
textAlign: TextAlign.left,
),
@@ -1345,10 +1336,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
offset: const Offset(0, -10),
elevation: 0,
decoration: BoxDecoration(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldDefaultBG,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
@@ -1390,10 +1380,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Text(
"Amount",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveSearchIconRight,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveSearchIconRight,
),
textAlign: TextAlign.left,
),
@@ -1417,13 +1406,12 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
key: const Key("amountInputFieldCryptoTextFieldKey"),
controller: cryptoAmountController,
focusNode: _cryptoFocus,
- keyboardType:
- Util.isDesktop
- ? null
- : const TextInputType.numberWithOptions(
- signed: false,
- decimal: true,
- ),
+ keyboardType: Util.isDesktop
+ ? null
+ : const TextInputType.numberWithOptions(
+ signed: false,
+ decimal: true,
+ ),
textAlign: TextAlign.right,
inputFormatters: [
AmountInputFormatter(
@@ -1447,10 +1435,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
hintText: "0",
hintStyle: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldDefaultText,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldDefaultText,
),
prefixIcon: FittedBox(
fit: BoxFit.scaleDown,
@@ -1459,10 +1446,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
child: Text(
ref.watch(pAmountUnit(coin)).unitForCoin(coin),
style: STextStyles.smallMed14(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.accentColorDark,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.accentColorDark,
),
),
),
@@ -1480,13 +1466,12 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
key: const Key("amountInputFieldFiatTextFieldKey"),
controller: baseAmountController,
focusNode: _baseFocus,
- keyboardType:
- Util.isDesktop
- ? null
- : const TextInputType.numberWithOptions(
- signed: false,
- decimal: true,
- ),
+ keyboardType: Util.isDesktop
+ ? null
+ : const TextInputType.numberWithOptions(
+ signed: false,
+ decimal: true,
+ ),
textAlign: TextAlign.right,
inputFormatters: [
AmountInputFormatter(decimals: 2, locale: locale),
@@ -1506,10 +1491,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
hintText: "0",
hintStyle: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldDefaultText,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldDefaultText,
),
prefixIcon: FittedBox(
fit: BoxFit.scaleDown,
@@ -1522,10 +1506,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
),
style: STextStyles.smallMed14(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.accentColorDark,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.accentColorDark,
),
),
),
@@ -1536,8 +1519,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (showCoinControl)
RoundedContainer(
color: Colors.transparent,
- borderColor:
- Theme.of(context).extension<StackColors>()!.textFieldDefaultBG,
+ borderColor: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldDefaultBG,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -1546,10 +1530,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
style: STextStyles.desktopTextExtraExtraSmall(context),
),
CustomTextButton(
- text:
- ref.watch(desktopUseUTXOs.state).state.isEmpty
- ? "Select coins"
- : "Selected coins (${ref.watch(desktopUseUTXOs.state).state.length})",
+ text: ref.watch(desktopUseUTXOs.state).state.isEmpty
+ ? "Select coins"
+ : "Selected coins (${ref.watch(desktopUseUTXOs.state).state.length})",
onTap: _showDesktopCoinControl,
),
],
@@ -1557,28 +1540,21 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
const SizedBox(height: 20),
if (!isPaynymSend &&
- !(isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack))
+ !(isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId))))
Text(
"Send to",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveSearchIconRight,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveSearchIconRight,
),
textAlign: TextAlign.left,
),
if (!isPaynymSend &&
- !(isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack))
+ !(isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId))))
const SizedBox(height: 10),
if (!isPaynymSend &&
- !(isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack))
+ !(isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId))))
ClipRRect(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
@@ -1629,138 +1605,135 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
},
focusNode: _addressFocusNode,
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveText,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveText,
height: 1.8,
),
- decoration: standardInputDecoration(
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack
- ? "Enter ${coin.ticker} address (optional)"
- : "Enter ${coin.ticker} address",
- _addressFocusNode,
- context,
- desktopMed: true,
- ).copyWith(
- contentPadding: const EdgeInsets.only(
- left: 16,
- top: 11,
- bottom: 12,
- right: 5,
- ),
- suffixIcon: Padding(
- padding:
- sendToController.text.isEmpty
+ decoration:
+ standardInputDecoration(
+ ref.watch(pIsSlatepack(widget.walletId))
+ ? "Enter ${coin.ticker} address (optional)"
+ : "Enter ${coin.ticker} address",
+ _addressFocusNode,
+ context,
+ desktopMed: true,
+ ).copyWith(
+ contentPadding: const EdgeInsets.only(
+ left: 16,
+ top: 11,
+ bottom: 12,
+ right: 5,
+ ),
+ suffixIcon: Padding(
+ padding: sendToController.text.isEmpty
? const EdgeInsets.only(right: 8)
: const EdgeInsets.only(right: 0),
- child: UnconstrainedBox(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- _addressToggleFlag
- ? TextFieldIconButton(
- key: const Key(
- "sendViewClearAddressFieldButtonKey",
- ),
- onTap: () {
- sendToController.text = "";
- _address = "";
- _setValidAddressProviders(_address);
- setState(() {
- _addressToggleFlag = false;
- });
- },
- child: const XIcon(),
- )
- : TextFieldIconButton(
- key: const Key(
- "sendViewPasteAddressFieldButtonKey",
- ),
- onTap: pasteAddress,
- child:
- sendToController.text.isEmpty
- ? const ClipboardIcon()
- : const XIcon(),
- ),
- if (sendToController.text.isEmpty)
- TextFieldIconButton(
- key: const Key("sendViewAddressBookButtonKey"),
- onTap: () async {
- final entry = await showDialog<
- ContactAddressEntry?
- >(
- context: context,
- builder:
- (context) => DesktopDialog(
- maxWidth: 696,
- maxHeight: 600,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
+ child: UnconstrainedBox(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
+ children: [
+ _addressToggleFlag
+ ? TextFieldIconButton(
+ key: const Key(
+ "sendViewClearAddressFieldButtonKey",
+ ),
+ onTap: () {
+ sendToController.text = "";
+ _address = "";
+ _setValidAddressProviders(_address);
+ setState(() {
+ _addressToggleFlag = false;
+ });
+ },
+ child: const XIcon(),
+ )
+ : TextFieldIconButton(
+ key: const Key(
+ "sendViewPasteAddressFieldButtonKey",
+ ),
+ onTap: pasteAddress,
+ child: sendToController.text.isEmpty
+ ? const ClipboardIcon()
+ : const XIcon(),
+ ),
+ if (sendToController.text.isEmpty)
+ TextFieldIconButton(
+ key: const Key("sendViewAddressBookButtonKey"),
+ onTap: () async {
+ final entry =
+ await showDialog<ContactAddressEntry?>(
+ context: context,
+ builder: (context) => DesktopDialog(
+ maxWidth: 696,
+ maxHeight: 600,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
children: [
- Padding(
- padding: const EdgeInsets.only(
- left: 32,
- ),
- child: Text(
- "Address book",
- style: STextStyles.desktopH3(
- context,
+ Row(
+ mainAxisAlignment:
+ MainAxisAlignment
+ .spaceBetween,
+ children: [
+ Padding(
+ padding:
+ const EdgeInsets.only(
+ left: 32,
+ ),
+ child: Text(
+ "Address book",
+ style:
+ STextStyles.desktopH3(
+ context,
+ ),
+ ),
),
- ),
+ const DesktopDialogCloseButton(),
+ ],
+ ),
+ Expanded(
+ child:
+ AddressBookAddressChooser(
+ coin: coin,
+ ),
),
- const DesktopDialogCloseButton(),
],
),
- Expanded(
- child: AddressBookAddressChooser(
- coin: coin,
- ),
- ),
- ],
- ),
- ),
- );
+ ),
+ );
- if (entry != null) {
- sendToController.text =
- entry.other ?? entry.label;
+ if (entry != null) {
+ sendToController.text =
+ entry.other ?? entry.label;
- _address = entry.address;
+ _address = entry.address;
- _setValidAddressProviders(_address);
+ _setValidAddressProviders(_address);
- setState(() {
- _addressToggleFlag = true;
- });
- }
- },
- child: const AddressBookIcon(),
- ),
- if (sendToController.text.isEmpty)
- TextFieldIconButton(
- semanticsLabel:
- "Scan QR Button. Opens Camera For Scanning QR Code.",
- key: const Key("sendViewScanQrButtonKey"),
- onTap: scanWebcam,
- child: const QrCodeIcon(),
- ),
- ],
+ setState(() {
+ _addressToggleFlag = true;
+ });
+ }
+ },
+ child: const AddressBookIcon(),
+ ),
+ if (sendToController.text.isEmpty)
+ TextFieldIconButton(
+ semanticsLabel:
+ "Scan QR Button. Opens Camera For Scanning QR Code.",
+ key: const Key("sendViewScanQrButtonKey"),
+ onTap: scanWebcam,
+ child: const QrCodeIcon(),
+ ),
+ ],
+ ),
+ ),
),
),
- ),
- ),
),
),
if (!isPaynymSend &&
- !(isMimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack))
+ !(isMimblewimblecoin && ref.watch(pIsSlatepack(widget.walletId))))
Builder(
builder: (_) {
final String? error;
@@ -1780,8 +1753,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (_data != null && _data.contactLabel == _address) {
error = null;
} else if (coin is Mimblewimblecoin &&
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack) {
+ ref.watch(pIsSlatepack(widget.walletId))) {
// For MWC slatepack transactions, address validation is not required.
// TODO: When implementing encrypted slatepacks, address validation will be required.
error = null;
@@ -1803,10 +1775,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
error,
textAlign: TextAlign.left,
style: STextStyles.label(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textError,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textError,
),
),
),
@@ -1835,47 +1806,45 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
setState(() {});
},
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveText,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveText,
height: 1.8,
),
- decoration: standardInputDecoration(
- "Enter memo (optional)",
- _memoFocus,
- context,
- desktopMed: true,
- ).copyWith(
- counterText: '',
- contentPadding: const EdgeInsets.only(
- left: 16,
- top: 11,
- bottom: 12,
- right: 5,
- ),
- suffixIcon: Padding(
- padding:
- memoController.text.isEmpty
+ decoration:
+ standardInputDecoration(
+ "Enter memo (optional)",
+ _memoFocus,
+ context,
+ desktopMed: true,
+ ).copyWith(
+ counterText: '',
+ contentPadding: const EdgeInsets.only(
+ left: 16,
+ top: 11,
+ bottom: 12,
+ right: 5,
+ ),
+ suffixIcon: Padding(
+ padding: memoController.text.isEmpty
? const EdgeInsets.only(right: 8)
: const EdgeInsets.only(right: 0),
- child: UnconstrainedBox(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- TextFieldIconButton(
- key: const Key("sendViewPasteMemoButtonKey"),
- onTap: pasteMemo,
- child:
- memoController.text.isEmpty
+ child: UnconstrainedBox(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
+ children: [
+ TextFieldIconButton(
+ key: const Key("sendViewPasteMemoButtonKey"),
+ onTap: pasteMemo,
+ child: memoController.text.isEmpty
? const ClipboardIcon()
: const XIcon(),
+ ),
+ ],
),
- ],
+ ),
),
),
- ),
- ),
),
),
if (!isPaynymSend) const SizedBox(height: 20),
@@ -1899,10 +1868,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Text(
"Nonce",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveSearchIconRight,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveSearchIconRight,
),
textAlign: TextAlign.left,
),
@@ -1923,38 +1891,37 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
keyboardType: const TextInputType.numberWithOptions(),
focusNode: _nonceFocusNode,
style: STextStyles.desktopTextExtraSmall(context).copyWith(
- color:
- Theme.of(
- context,
- ).extension<StackColors>()!.textFieldActiveText,
+ color: Theme.of(
+ context,
+ ).extension<StackColors>()!.textFieldActiveText,
height: 1.8,
),
- decoration: standardInputDecoration(
- "Leave empty to auto select nonce",
- _nonceFocusNode,
- context,
- desktopMed: true,
- ).copyWith(
- contentPadding: const EdgeInsets.only(
- left: 16,
- top: 11,
- bottom: 12,
- right: 5,
- ),
- ),
+ decoration:
+ standardInputDecoration(
+ "Leave empty to auto select nonce",
+ _nonceFocusNode,
+ context,
+ desktopMed: true,
+ ).copyWith(
+ contentPadding: const EdgeInsets.only(
+ left: 16,
+ top: 11,
+ bottom: 12,
+ right: 5,
+ ),
+ ),
),
),
const SizedBox(height: 36),
PrimaryButton(
buttonHeight: ButtonHeight.l,
- label:
- ref.watch(pSelectedMwcTransactionMethod) ==
- MwcTransactionMethod.slatepack
- ? "Create slatepack"
- : "Preview send",
+ label: ref.watch(pIsSlatepack(widget.walletId))
+ ? "Create slatepack"
+ : "Preview send",
enabled: ref.watch(pPreviewTxButtonEnabled(coin)),
- onPressed:
- ref.watch(pPreviewTxButtonEnabled(coin)) ? previewSend : null,
+ onPressed: ref.watch(pPreviewTxButtonEnabled(coin))
+ ? previewSend
+ : null,
),
],
);
diff --git a/lib/providers/ui/preview_tx_button_state_provider.dart b/lib/providers/ui/preview_tx_button_state_provider.dart
index de20131..e800869 100644
--- a/lib/providers/ui/preview_tx_button_state_provider.dart
+++ b/lib/providers/ui/preview_tx_button_state_provider.dart
@@ -13,6 +13,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../utilities/amount/amount.dart';
import '../../utilities/enums/mwc_transaction_method.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
+import '../../wallets/isar/providers/wallet_info_provider.dart';
import '../wallet/public_private_balance_state_provider.dart';
final pSendAmount = StateProvider.autoDispose<Amount?>((_) => null);
@@ -26,6 +27,15 @@ final pSelectedMwcTransactionMethod = StateProvider<MwcTransactionMethod>(
(_) => MwcTransactionMethod.slatepack,
);
+final pIsSlatepack = Provider.family<bool, String>((ref, walletId) {
+ if (ref.watch(pWalletCoin(walletId)) is Mimblewimblecoin) {
+ return ref.watch(pSelectedMwcTransactionMethod) ==
+ MwcTransactionMethod.slatepack;
+ }
+
+ return false;
+});
+
final pPreviewTxButtonEnabled = Provider.autoDispose
.family<bool, CryptoCurrency>((ref, coin) {
final amount = ref.watch(pSendAmount) ?? Amount.zero;
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.