Skip to content

Only show memo input for Tendermint & ZHTLC#2998

Merged
CharlVS merged 6 commits intodevfrom
selective-memo-input
Aug 12, 2025
Merged

Only show memo input for Tendermint & ZHTLC#2998
CharlVS merged 6 commits intodevfrom
selective-memo-input

Conversation

@smk762
Copy link
Copy Markdown
Collaborator

@smk762 smk762 commented Jul 26, 2025

Closes #2997

To Test:

  • For EVM & UTXO go to a funded coin page, then open the withdraw form. Memo field should not be visible.
  • For Tendermint, go to a funded coin page, then open the withdraw form. Memo field should be visible.

Summary by CodeRabbit

  • Bug Fixes

    • Memo input now appears only for Tendermint and ZHTLC assets; it is hidden for other networks to prevent irrelevant input.
  • Style

    • Minor UI text and layout refinements in withdraw form fields for improved readability and consistency; no functional changes to validation or event handling.

@smk762 smk762 requested review from CharlVS and takenagain July 26, 2025 09:18
@smk762 smk762 linked an issue Jul 26, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Conditional rendering added to show the memo field only for Tendermint and Zhtlc protocols. MemoField class removed from fill_form fields. Remaining changes are formatting and minor UI text restructuring without altering event payloads or behavior.

Changes

Cohort / File(s) Summary
Withdraw form fields formatting and cleanup
lib/views/wallet/coin_details/withdraw_form/widgets/fill_form/fields/fields.dart
Formatting-only adjustments to various fields; removed exported MemoField class; no functional changes to bloc events or state handling.
Memo field gating by protocol
lib/views/wallet/coin_details/withdraw_form/withdraw_form.dart
Render WithdrawMemoField only when asset.protocol is TendermintProtocol or ZhtlcProtocol; unchanged onChanged dispatch.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant WF as WithdrawForm (UI)
  participant B as WithdrawFormBloc

  U->>WF: Open Withdraw Form
  WF->>WF: Check asset.protocol
  alt protocol is Tendermint or Zhtlc
    WF-->>U: Show Memo Field
    U->>WF: Edit Memo
    WF->>B: Dispatch WithdrawFormMemoChanged
  else
    WF-->>U: Hide Memo Field
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Hide memo field for coins that do not support memos (#2997)
Remove duplicated placeholder; keep only the smaller floating label (#2997) No changes observed to placeholder behavior or textarea placeholder removal.
Fix alignment of active memo textarea within rounded box (#2997) No explicit styling/layout changes found affecting alignment.

Suggested labels

bug, QA

Suggested reviewers

  • takenagain
  • AndrewDelaney

Poem

A tap of the paw on the protocol gate,
The memo peeks in—only where it’s fate.
No double whispers, no muddled view,
Just tidy fields in a cleaner hue.
Hop-hop hooray, I ship with delight—
Bugs take flight in the afternoon light! 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch selective-memo-input

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 26, 2025

Visit the preview URL for this PR (updated for commit 19b95ef):

https://walletrc--pull-2998-merge-ans3luob.web.app

(expires Tue, 19 Aug 2025 18:11:12 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc

@CharlVS
Copy link
Copy Markdown
Collaborator

CharlVS commented Jul 27, 2025

@smk762 are ZHTLC and Tendermint the only coins with memo support?

Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smk762 there are indeed no references to MemoField. Please could you delete it?

@smk762
Copy link
Copy Markdown
Collaborator Author

smk762 commented Aug 1, 2025

@smk762 are ZHTLC and Tendermint the only coins with memo support?

yes

This was confirmed via the KDF deepwiki (though others may accept the field without error, they dont do anything with it).

@CharlVS CharlVS force-pushed the selective-memo-input branch from 21d2faa to 49948d0 Compare August 1, 2025 14:39
@smk762 smk762 requested a review from CharlVS August 8, 2025 04:50
@smk762 smk762 force-pushed the selective-memo-input branch from ccaec3c to 8f9de44 Compare August 12, 2025 06:05
@CharlVS
Copy link
Copy Markdown
Collaborator

CharlVS commented Aug 12, 2025

@coderabbitai review

@CharlVS
Copy link
Copy Markdown
Collaborator

CharlVS commented Aug 12, 2025

@cursor review

@CharlVS
Copy link
Copy Markdown
Collaborator

CharlVS commented Aug 12, 2025

@copilot review

@GLEECBTC GLEECBTC deleted a comment from coderabbitai bot Aug 12, 2025
@CharlVS CharlVS requested a review from Copilot August 12, 2025 16:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements conditional visibility for the memo input field in the withdraw form, restricting it to only appear for Tendermint and ZHTLC protocols while hiding it for EVM and UTXO networks.

  • Added protocol-specific conditional rendering for the memo field
  • Removed unused MemoField class from the codebase
  • Applied code formatting improvements throughout the file

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
withdraw_form.dart Added conditional rendering logic to show memo field only for Tendermint and ZHTLC protocols
fields.dart Removed unused MemoField class and applied code formatting improvements

],
],
const SizedBox(height: 16),
if (state.asset.protocol is TendermintProtocol || state.asset.protocol is ZhtlcProtocol) ...[
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The protocol type checking logic should be extracted to a helper method or the asset model to improve maintainability and reduce duplication if this logic is needed elsewhere.

Suggested change
if (state.asset.protocol is TendermintProtocol || state.asset.protocol is ZhtlcProtocol) ...[
if (_isMemoSupportedProtocol(state.asset)) ...[

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent please implement this

Copy link
Copy Markdown

@cursor cursor bot Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the memo field visibility logic within the withdraw form by extracting the protocol check into a dedicated helper function. This improves code readability and maintainability by centralizing the condition for memo support.

  • I introduced a new private helper function, _isMemoSupportedProtocol(Asset asset), in lib/views/wallet/coin_details/withdraw_form/withdraw_form.dart. This function encapsulates the logic to determine if an asset's protocol (TendermintProtocol or ZhtlcProtocol) supports a memo field.
  • I updated the WithdrawFormFillSection widget in lib/views/wallet/coin_details/withdraw_form/withdraw_form.dart to use the new _isMemoSupportedProtocol(state.asset) function. This replaced the inline if condition previously used to conditionally render the WithdrawMemoField, making the code cleaner and more explicit.

Open in Cursor Open in Web

Learn more about Cursor Agents

cursor[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
lib/views/wallet/coin_details/withdraw_form/widgets/fill_form/fields/fields.dart (1)

1-10: Remove unused widgets in fields.dart

RG search shows that ConfirmationPage, SuccessPage, and FailurePage are only defined (no instantiations or references elsewhere). To reduce confusion and maintenance overhead, remove these dead widgets or extract them into separate files if needed later.

• lib/views/wallet/coin_details/withdraw_form/widgets/fill_form/fields/fields.dart
– ConfirmationPage (starts at line 293)
– SuccessPage (starts at line 409)
– FailurePage (starts at line 450)

🧹 Nitpick comments (4)
lib/views/wallet/coin_details/withdraw_form/withdraw_form.dart (2)

446-453: Memo field correctly gated to Tendermint and ZHTLC protocols (aligns with PR objective).

This conditional render meets the requirement to show the memo only for Tendermint and ZHTLC assets. Nice.

Optionally, encapsulate the check to avoid future duplication and make it easier to extend (e.g., if other memo-capable protocols are added).

Apply this diff here:

-if (state.asset.protocol is TendermintProtocol || state.asset.protocol is ZhtlcProtocol) ...[
+if (_supportsMemo(state.asset.protocol)) ...[
   WithdrawMemoField(
     memo: state.memo,
     onChanged: (value) => context
           .read<WithdrawFormBloc>()
           .add(WithdrawFormMemoChanged(value)),
   ),
 ],

Add this helper inside WithdrawFormFillSection:

bool _supportsMemo(Protocol protocol) =>
    protocol is TendermintProtocol || protocol is ZhtlcProtocol;

446-453: Verify coverage of all Tendermint-based protocol variants

I searched the local code for any additional Tendermint*Protocol or *HTLC*Protocol classes and found none. Since protocol implementations may live in dependencies or use different naming (e.g. token-specific or IBC variants), please manually confirm that all Tendermint-based asset protocols requiring a withdrawal memo are covered by this check. If you identify extra variants, update this condition accordingly:

if (state.asset.protocol is TendermintProtocol ||
    state.asset.protocol is ZhtlcProtocol) …[
  WithdrawMemoField(...),
]
lib/views/wallet/coin_details/withdraw_form/widgets/fill_form/fields/fields.dart (2)

196-224: EVM fee updates: consider input validation and keyboard/input formatters.

Currently, negative or zero gas price/limit can be entered; also the gas price field uses a non-decimal keyboard. Small UX/validation improvements:

  • Gas Price: allow decimals and restrict input to digits and a single dot.
  • Gas Limit: restrict to digits only.
  • Optionally validate min values (e.g., gas > 0, gasPrice > 0).

Apply these diffs:

 UiTextFormField(
   labelText: 'Gas Price (Gwei)',
-  keyboardType: TextInputType.number,
+  keyboardType: const TextInputType.numberWithOptions(decimal: true),
+  inputFormatters: [
+    FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d{0,18}$')),
+  ],
   initialValue: evmFee?.gasPrice.toString(),
   onChanged: (value) {
     final gasPrice = Decimal.tryParse(value ?? '');
     if (gasPrice != null) {
       context.read<WithdrawFormBloc>().add(
         WithdrawFormCustomFeeChanged(
           FeeInfoEthGas(
             coin: state.asset.id.id,
             gasPrice: gasPrice,
             gas: evmFee?.gas ?? 21000,
           ),
         ),
       );
     }
   },
   helperText: 'Higher gas price = faster confirmation',
 ),
 ...
 UiTextFormField(
   labelText: 'Gas Limit',
-  keyboardType: TextInputType.number,
+  keyboardType: TextInputType.number,
+  inputFormatters: [FilteringTextInputFormatter.digitsOnly],
   initialValue: evmFee?.gas.toString() ?? '21000',
   onChanged: (value) {
     final gas = int.tryParse(value ?? '');
-    if (gas != null) {
+    if (gas != null && gas > 0) {
       context.read<WithdrawFormBloc>().add(
         WithdrawFormCustomFeeChanged(
           FeeInfoEthGas(
             coin: state.asset.id.id,
             gasPrice: evmFee?.gasPrice ?? Decimal.one,
             gas: gas,
           ),
         ),
       );
     }
   },
   helperText: 'Estimated: 21000',
 ),

315-361: Also gate memo display on confirmation to supported protocols.

Even if this page is not the active confirm screen, it’s safer to avoid showing memo details for assets that don’t support memos. Gate by protocol, and optionally require non-empty memo.

Apply this diff:

-                    if (state.memo != null) ...[
+                    if ((state.memo?.isNotEmpty ?? false) &&
+                        (state.asset.protocol is TendermintProtocol ||
+                         state.asset.protocol is ZhtlcProtocol)) ...[
                       const SizedBox(height: 12),
                       _ConfirmationItem(label: 'Memo', value: state.memo!),
                     ],

If we adopt the helper suggested in withdraw_form.dart, we can reuse it here too.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 649001d and 8f9de44.

📒 Files selected for processing (2)
  • lib/views/wallet/coin_details/withdraw_form/widgets/fill_form/fields/fields.dart (18 hunks)
  • lib/views/wallet/coin_details/withdraw_form/withdraw_form.dart (1 hunks)
🔇 Additional comments (10)
lib/views/wallet/coin_details/withdraw_form/withdraw_form.dart (1)

19-20: No stale MemoField references detected

I ran a project-wide search for MemoField and only found the new WithdrawMemoField usages. There are no lingering imports or references to the old MemoField, so this is safe to resolve.

lib/views/wallet/coin_details/withdraw_form/widgets/fill_form/fields/fields.dart (9)

30-33: Event dispatch formatting change is fine.

No behavior change; dispatch remains the same.


66-97: Decimal keyboard for Amount + event dispatch refactor look good.

  • Enabling decimal input on Amount is correct for most assets.
  • Dispatch logic is unchanged, now cleaner.

118-121: Network fee title refactor is fine.

Semantics preserved with better readability.


166-167: Custom fee toggle dispatch formatting is fine.

No behavioral change.


266-276: UTXO fee selection mapping looks correct.

  • Selected set reflects current or default fee.
  • Event payload uses Decimal.fromInt, which is appropriate for satoshi-like integers.

386-403: Style update reads well.

Using colorScheme.onSurface with a reduced alpha for the label is consistent with other components. Approved.


468-485: Failure styling + event dispatch formatting are fine.

No semantic change; readability improved.


507-509: IBC toggle event dispatch formatting is fine.

No behavior change.


532-533: IBC channel onChanged formatting is fine.

No behavior change.

Co-authored-by: charl <charl@vanstaden.info>
@CharlVS
Copy link
Copy Markdown
Collaborator

CharlVS commented Aug 12, 2025

@cursoragent resolve the cause of the build failures

@cursor
Copy link
Copy Markdown

cursor bot commented Aug 12, 2025

I refactored the pubkey watching mechanism within the CoinAddressesBloc to ensure more immediate UI updates and a robust fallback for pubkey synchronization. This improves how the application fetches and displays coin addresses.

  • Modified _startWatchingPubkeys in lib/bloc/coin_addresses/bloc/coin_addresses_bloc.dart:
    • I removed the previous sdk.pubkeys.preCachePubkeys and sdk.pubkeys.watchPubkeys logic.
    • I implemented an immediate fetch of pubkeys using asset.getPubkeys(sdk) to ensure the UI is updated with the latest addresses right away, preventing flickering.
    • I replaced the pubkey stream with a periodic polling mechanism using Stream<void>.periodic(const Duration(seconds: 10)).asyncMap((_) => asset.getPubkeys(sdk)). This acts as a reliable fallback to keep pubkeys synchronized every 10 seconds.
  • Added new project dependencies: I included the flutter subproject commit fcf2c11572af6f390246c056bc905eca609533a0 and the flutter-sdk.tar.xz archive, likely for updated SDK integration or build processes.

Open in Cursor Open in Web

Learn more about Cursor Agents

@CharlVS CharlVS force-pushed the selective-memo-input branch from 4652c04 to e3cfe79 Compare August 12, 2025 17:37
@CharlVS CharlVS merged commit 2ee41c3 into dev Aug 12, 2025
10 of 14 checks passed
@CharlVS CharlVS deleted the selective-memo-input branch August 12, 2025 18:15
cursor bot pushed a commit that referenced this pull request Aug 20, 2025
* limit memo field to supporting protocols

* add TODO for unused component

* removes obsolete `MemoField`

* Add helper function to check memo support for specific protocols

Co-authored-by: charl <charl@vanstaden.info>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: charl <charl@vanstaden.info>
Co-authored-by: CharlVS <77973576+CharlVS@users.noreply.github.com>
@CharlVS CharlVS mentioned this pull request Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memo field present where not applicable

4 participants