Skip to content

fix(nft): add nft v2 and hd wallet support#2566

Merged
CharlVS merged 22 commits intodevfrom
bugfix/nft-hd-support
Apr 25, 2025
Merged

fix(nft): add nft v2 and hd wallet support#2566
CharlVS merged 22 commits intodevfrom
bugfix/nft-hd-support

Conversation

@takenagain
Copy link
Copy Markdown
Contributor

@takenagain takenagain commented Mar 11, 2025

Changes

  • Fixes the infinite loading screen on the NFT page when signed in with HD mode (multi-address support enabled), and
  • Adds address selection dropdown to the "Receive NFT" button page.
  • Merged in updates from dev branch, including KDF update to f3f4bc35a358c15007eb624928e87458ed15f38a

NOTE: the NFT spam filter is always enabled, so some NFTs may not be visible in the list.

image

Summary by CodeRabbit

  • New Features

    • Introduced a unified NFT receiving interface delivering a consistent experience across devices.
    • Added improved asset ticker labeling for NFT assets.
    • Enhanced functionality for asset visibility, ensuring only relevant assets are displayed.
    • Added a copyable address dialog with address search and selection capabilities.
  • Refactor

    • Streamlined asset management to display only relevant items while automatically enabling necessary NFT assets.
    • Enhanced address handling and authentication checks to ensure smoother asset transactions.
    • Updated event handling and state management for improved clarity and robustness.
    • Replaced legacy event names with clearer, descriptive ones for NFT-related flows.
    • Consolidated mobile and desktop NFT receive views into a single component.
    • Shifted address and asset handling from simple strings to structured public key info models.
    • Improved logging and error handling across NFT and SDK integrations.
  • Chores

    • Upgraded error logging and overall code organization to boost application stability and maintainability.
    • Removed unused imports and redundant code for cleaner codebase.

@takenagain takenagain added the bug Something isn't working label Mar 11, 2025
@takenagain takenagain self-assigned this Mar 11, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 11, 2025

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

The changes introduce a series of refactorings and enhancements to the asset and NFT management logic. New constants and getters have been added to manage asset visibility, while several blocs and repositories have been refactored to improve error handling, logging, and dependency usage. Event and state names have been updated for clarity, and UI components for NFT receipt have been consolidated and modernized by changing model types and input handling. Additionally, some deprecated methods and redundant imports were removed, and the address handling was shifted from simple strings to structured public key info objects.

Changes

File(s) Change Summary
lib/app_config/app_config.dart Added new constant excludedAssetList and getter enabledByDefaultCoins for asset management.
lib/bloc/app_bloc_root.dart, lib/bloc/coins_bloc/coins_bloc.dart Removed unused imports and parameters; updated instantiation and renamed parameters (e.g., kdfSdksdk).
lib/bloc/coins_bloc/coins_state.dart Enhanced state initialization by filtering excluded assets, updated constructor/factory methods, and added a copyWith method.
lib/bloc/nft_receive/bloc/nft_receive_bloc.dart, nft_receive_event.dart, nft_receive_state.dart Renamed events and state classes (e.g., NftReceiveEventInitialNftReceiveStarted), restructured event handling, improved logging, and updated state management.
lib/bloc/nft_withdraw/nft_withdraw_repo.dart, lib/bloc/nfts/nft_main_bloc.dart, lib/bloc/nfts/nft_main_repo.dart Refactored authentication handling (removing isLoggedIn checks), updated parameter names, and refined error logging.
lib/main.dart, lib/mm2/mm2.dart, lib/mm2/mm2_api/mm2_api.dart, lib/mm2/mm2_api/mm2_api_nft.dart Adjusted dependency injection by removing coinsRepo, deprecated legacy methods, restructured constructor parameters, and updated logging/error handling in API classes.
lib/model/nft.dart Modified NftToken.imageUrl to standardize gateway URLs and added nftAssetTicker method to NftBlockchains enum.
lib/views/nfts/nft_main/nft_main_controls.dart Changed authentication check from NftMainBloc to AuthBloc; updated event dispatched for NFT chain update.
lib/views/nfts/nft_receive/nft_receive_page.dart, nft_receive_view.dart Updated event dispatch to use renamed events; consolidated mobile and desktop receive views into a single NftReceiveCard component with updated types.
lib/views/nfts/nft_receive/common/nft_receive_card.dart Changed properties from Coin and String? to Asset, PubkeyInfo?, and added pubkeys; updated related methods accordingly.
lib/views/nfts/nft_receive/desktop/nft_receive_desktop_view.dart, mobile/nft_receive_mobile_view.dart Removed these files, consolidating receive UI into unified component.
lib/views/wallet/coin_details/receive/receive_address.dart, receive_address_trezor.dart, receive_details.dart, request_address_button.dart Shifted from Coin and String address types to Asset, AssetPubkeys, and PubkeyInfo?; updated constructors, callbacks, and UI components accordingly.
lib/bloc/trezor_bloc/trezor_repo.dart, lib/blocs/trezor_coins_bloc.dart Changed parameter types from Coin to Asset; commented out balance update logic in getNewAddressStatus with TODO note.
lib/bloc/withdraw_form/withdraw_form_bloc.dart Changed address format parameter from 'checksummed' to 'mixedcase' in address conversion; removed helper method for mixed-case detection.
lib/mm2/mm2_api/rpc/nft/refresh_nft_metadata/refresh_nft_metadata_req.dart, update_nft_req.dart Renamed JSON key "proxy_auth" to "komodo_proxy" in request payloads.
lib/model/hd_account/hd_account.dart Added method toPubkeyInfo() to convert HdAddress to PubkeyInfo.
lib/shared/widgets/copyable_address_dialog.dart Added new widget for displaying and copying addresses with support for address search and selection.
lib/views/nfts/common/widgets/nft_image.dart Added GIF detection to enable gapless playback; improved error logging on image load failure.
lib/views/nfts/nft_main/nft_main_failure.dart, nft_refresh_button.dart, nft_tabs/nft_tabs.dart, nft_page.dart Updated event names to renamed equivalents for consistency (e.g., UpdateChainNftsEventNftMainChainUpdateRequested).
lib/views/wallet/coin_details/coin_details.dart Removed unused import of receive_details.dart.
lib/views/wallet/coin_details/coin_details_info/charts/animated_portfolio_charts.dart Removed duplicated import statements.
lib/views/wallets_manager/widgets/wallet_creation.dart Removed unused import statement.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant View as NftReceiveView
    participant Bloc as NftReceiveBloc
    participant Logger as Logger

    User->>View: Initiate address change
    View->>Bloc: Dispatch NftReceiveAddressChanged event
    Bloc->>Logger: Log event details
    Bloc-->>Bloc: Process event & validate state
    Bloc->>View: Emit NftReceiveLoadSuccess state
    View->>User: Update UI with new address
Loading

Possibly related PRs

Suggested labels

enhancement, QA

Suggested reviewers

  • smk762
  • AndrewDelaney
  • CharlVS

Poem

I'm a bunny on the run,
Hopping through code under the sun,
New constants and features in sight,
Refactored blocs making things just right,
With a twitch of my nose, I celebrate the flow,
Dig these changes deep—off I go!
🐇💻✨


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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@takenagain takenagain marked this pull request as draft March 11, 2025 16:31
@takenagain takenagain force-pushed the bugfix/nft-hd-support branch from 5cb7ccb to dffb9b8 Compare April 1, 2025 13:54
@takenagain
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 1

🔭 Outside diff range comments (1)
lib/views/wallet/coin_details/receive/receive_details.dart (1)

169-173: ⚠️ Potential issue

Potential mismatch between callback implementation and usage.

The _onAddressChanged method still accepts a String parameter, but according to the summary, the ReceiveAddress callback type has changed from Function(String) to void Function(PubkeyInfo?). This may cause a type mismatch when the callback is invoked.

-void _onAddressChanged(String address) {
+void _onAddressChanged(PubkeyInfo? pubkeyInfo) {
  setState(() {
-    _currentAddress = address;
+    _currentAddress = pubkeyInfo?.address;
  });
}
🧹 Nitpick comments (4)
lib/mm2/mm2_api/mm2_api_nft.dart (2)

151-157: Optional error handling in enableNft.
Currently, if _sdk.client.rpc.nft.enableNft(...) fails, the method will throw without logging. Consider wrapping it for better context around the failure or at least adding a local try/catch to log the failure message.


159-181: Enhance fault tolerance in _tryEnableNftChains.
If enabling one chain fails, the current design aborts enabling for any remaining chains. Consider a more granular error handling strategy (e.g., continuing attempts for remaining chains) to avoid partial enablement failures from blocking others.

lib/views/wallet/coin_details/receive/receive_address_trezor.dart (2)

56-67: Consider providing real derivation path and chain information

The PubkeyInfo is created with empty strings for derivationPath and chain. Consider deriving these values from the asset or the provided address for better data integrity.

final newPubkey = PubkeyInfo(
  address: newAddress,
-  derivationPath: '',
-  chain: '',
+  derivationPath: asset.derivationPath ?? '',
+  chain: asset.id.chain ?? '',
  balance: BalanceInfo.zero(),
);

56-57: Remove TODO comment after implementing the feature

The TODO comment about updating to use asset instead of coin should be removed since the implementation now uses the asset parameter.

-  // TODO: update to use asset instead of coin
  return RequestAddressButton(
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aa70cae and dffb9b8.

📒 Files selected for processing (25)
  • lib/app_config/app_config.dart (4 hunks)
  • lib/bloc/app_bloc_root.dart (1 hunks)
  • lib/bloc/coins_bloc/coins_bloc.dart (1 hunks)
  • lib/bloc/coins_bloc/coins_state.dart (2 hunks)
  • lib/bloc/nft_receive/bloc/nft_receive_bloc.dart (2 hunks)
  • lib/bloc/nft_receive/bloc/nft_receive_event.dart (1 hunks)
  • lib/bloc/nft_receive/bloc/nft_receive_state.dart (1 hunks)
  • lib/bloc/nft_transactions/nft_txn_repository.dart (4 hunks)
  • lib/bloc/nft_withdraw/nft_withdraw_repo.dart (2 hunks)
  • lib/bloc/nfts/nft_main_bloc.dart (8 hunks)
  • lib/bloc/nfts/nft_main_repo.dart (3 hunks)
  • lib/main.dart (1 hunks)
  • lib/mm2/mm2.dart (1 hunks)
  • lib/mm2/mm2_api/mm2_api.dart (4 hunks)
  • lib/mm2/mm2_api/mm2_api_nft.dart (6 hunks)
  • lib/model/nft.dart (2 hunks)
  • lib/views/nfts/nft_main/nft_main_controls.dart (2 hunks)
  • lib/views/nfts/nft_receive/common/nft_receive_card.dart (5 hunks)
  • lib/views/nfts/nft_receive/desktop/nft_receive_desktop_view.dart (0 hunks)
  • lib/views/nfts/nft_receive/mobile/nft_receive_mobile_view.dart (0 hunks)
  • lib/views/nfts/nft_receive/nft_receive_page.dart (1 hunks)
  • lib/views/nfts/nft_receive/nft_receive_view.dart (3 hunks)
  • lib/views/wallet/coin_details/receive/receive_address.dart (1 hunks)
  • lib/views/wallet/coin_details/receive/receive_address_trezor.dart (4 hunks)
  • lib/views/wallet/coin_details/receive/receive_details.dart (1 hunks)
💤 Files with no reviewable changes (2)
  • lib/views/nfts/nft_receive/mobile/nft_receive_mobile_view.dart
  • lib/views/nfts/nft_receive/desktop/nft_receive_desktop_view.dart
🔇 Additional comments (78)
lib/main.dart (1)

69-69:

Details

✅ Verification successful

Dependency injection simplified by removing coinsRepo parameter.

The Mm2Api initialization has been refactored to remove the coinsRepo dependency, now using only mm2 and sdk parameters. This is a good architectural improvement that reduces dependency coupling.


🏁 Script executed:

#!/bin/bash
# Verify that Mm2Api constructor no longer requires coinsRepo parameter

# Check the Mm2Api constructor definition
rg -A 10 "class Mm2Api" lib/mm2/mm2_api/mm2_api.dart

Length of output: 273


Dependency Injection Simplification Confirmed

We verified that the Mm2Api constructor in lib/mm2/mm2_api/mm2_api.dart now only requires the mm2 and sdk parameters, with no reference to a coinsRepo parameter. This aligns with the instantiation in lib/main.dart (line 69), confirming the intended simplification and reduced dependency coupling.

lib/views/wallet/coin_details/receive/receive_details.dart (1)

141-141:

Details

✅ Verification successful

Parameter name updated from 'coin' to 'asset'.

The parameter name change from coin to asset aligns with changes in the ReceiveAddress component that now accepts assets and pubkeys instead of coins. This change supports NFT v2 and HD wallet compatibility.


🏁 Script executed:

#!/bin/bash
# Check if ReceiveAddress component now accepts 'asset' parameter instead of 'coin'

# Look at the ReceiveAddress constructor
rg -A 10 "class ReceiveAddress" lib/views/wallet/coin_details/receive/receive_address.dart

Length of output: 349


Re: Parameter Name Update Verified

The change from using the coin parameter to asset was correctly applied. The ReceiveAddress constructor now requires an asset parameter (as verified in lib/views/wallet/coin_details/receive/receive_address.dart), so updating the argument in lib/views/wallet/coin_details/receive/receive_details.dart to:

                  asset: widget.asset.toCoin(),

is consistent with the new implementation supporting NFT v2 and HD wallet compatibility. No further changes are required.

lib/views/nfts/nft_receive/nft_receive_page.dart (1)

20-20:

Details

✅ Verification successful

Event name updated for better clarity.

The event name has been updated from NftReceiveEventInitial to NftReceiveStarted, which follows a clearer naming convention. This improves code readability and maintains consistency with the event naming pattern in the rest of the application.


🏁 Script executed:

#!/bin/bash
# Verify that the NftReceiveEventInitial class has been renamed to NftReceiveStarted

# Look for both event names in the NftReceiveBloc file
rg "NftReceiveEventInitial|NftReceiveStarted" lib/bloc/nft_receive/bloc/nft_receive_bloc.dart

Length of output: 212


Event Renaming Verified: The update to NftReceiveStarted is correctly applied.

The verification confirms that all references to the initial event have been updated. In particular, the file lib/bloc/nft_receive/bloc/nft_receive_bloc.dart shows:

  • The use of <NftReceiveStarted> for the event handler.
  • The addition of NftReceiveStarted(chain: localChain) in the bloc.

This update maintains consistency with the naming pattern throughout the codebase and improves clarity.

lib/app_config/app_config.dart (2)

79-81: Well-documented NFT v2 implementation

Good job adding clear documentation explaining that NFT v2 coins will be used in the background and don't need to be visible to users. This helps maintain code clarity for future development.


127-133: NFT v2 coins correctly added to enabledByDefaultCoins

The addition of NFT v2 coins to the default enabled coins list is an essential change to ensure NFT v2 functionality works properly. The comment clearly explains that these coins are required for the NFT v2 methods.

lib/views/nfts/nft_main/nft_main_controls.dart (2)

9-9: Properly imported AuthBloc

Adding this import is necessary for accessing the centralized authentication state.


73-74: Improved authentication handling

Good refactoring to use the centralized AuthBloc for authentication checks instead of the NftMainBloc. This change improves the architecture by properly separating concerns and will help resolve the infinite loading issue with HD wallets and multi-address support.

lib/bloc/app_bloc_root.dart (1)

264-264: Updated NftMainBloc initialization

Good update to the NftMainBloc initialization to align with the architectural changes. Removing the isLoggedIn parameter and renaming kdfSdk to sdk matches the changes in the bloc implementation and improves consistency.

lib/mm2/mm2.dart (1)

58-61: Properly deprecated legacy method

The deprecation annotation is well-documented, clearly explaining why developers should use the new methods instead. The message provides specific alternatives (KomodoDefiSdk.client.rpc or KomodoDefiSdk.client.executeRpc) and explains the issues with the current implementation (injecting empty user passwords into legacy models).

lib/bloc/nft_transactions/nft_txn_repository.dart (5)

16-18: Clean code reorganization!

Moving member variables from constructor assignments to class-level declarations improves readability and follows Dart best practices.


21-28: Improved parameter formatting and error handling

The function parameter formatting has been improved for readability, and the mapping in line 27 has been properly aligned.


38-42: Better error handling with explicit type casting

Good improvement to explicitly cast the error message to String before logging and throwing an ApiError. This reduces the risk of unexpected type errors.


72-74: Improved parameter alignment

The parameters for getNftTxDetailsByHash have been nicely aligned for better readability.


100-100: Good use of final for loop variable

Changing from var to final for the loop variable enforces immutability and is a good practice.

lib/model/nft.dart (2)

83-83: Code simplification in uuid getter

Removing the redundant .toString() call on chain simplifies the code without changing functionality, as string interpolation already calls toString() implicitly.


243-256: Well-implemented nftAssetTicker() method

The new method provides a clear mapping from blockchain types to NFT asset tickers, following the same pattern as existing methods like toString() and coinAbbr(). This will be useful for consistent asset identification throughout the application.

lib/bloc/nft_withdraw/nft_withdraw_repo.dart (3)

37-40: Improved error handling with null fallback

Good improvement to handle potential null error messages by adding a fallback. The use of .ignore() on the log is also consistent with other error handling in the codebase.


59-62: Better parameter formatting

The parameters for confirmSend have been reformatted to use a multi-line declaration style, which improves readability.


69-71: Improved response formatting

The SendRawTransactionResponse creation has been reformatted to a multi-line style for better readability.

lib/views/nfts/nft_receive/nft_receive_view.dart (6)

4-4: Added required import for PubkeyInfo

The import for komodo_defi_types is correctly added to support the PubkeyInfo type used in the new _onAddressChanged method.


12-12: Updated import for consolidated NFT receive card

The import has been updated to use the new consolidated NftReceiveCard component.


40-42: Updated state type checks for improved clarity

The state type checks have been updated to use more descriptive state names:

  • NftReceiveHasBackupNftReceiveBackupSuccess
  • NftReceiveFailureNftReceiveLoadFailure
  • NftReceiveAddressNftReceiveLoadSuccess

This makes the code more self-documenting and easier to understand.

Also applies to: 52-52


49-49: Updated event name for consistency

The event name has been updated to NftReceiveRefreshRequested() to match the naming convention in the bloc.


54-76: UI refactoring with consolidated component

Excellent refactoring to use a single NftReceiveCard component for both mobile and desktop layouts with appropriate configuration differences. This reduces code duplication and improves maintainability.


87-91: Well-implemented address change handler

The new _onAddressChanged method follows good practices for event dispatching and keeps the UI component clean by separating the event logic.

lib/bloc/nfts/nft_main_repo.dart (5)

25-30: Improved error handling in updateNft method.

The error handling has been enhanced by explicitly casting the error to a String type and using the .ignore() method on the log statement. This helps prevent potential type errors and follows the project's updated logging pattern.


37-38: Enhanced type safety with explicit nullable typing.

Explicitly typing jsonError as String? improves code clarity and type safety by making the nullability of this variable explicit.


43-44: Streamlined error handling condition.

The error condition check has been simplified to directly verify if the error message starts with 'transport' rather than first checking if it's a String. This cleaner approach is possible because of the explicit typing above.


58-58: Added 'final' keyword to loop variable.

Adding the 'final' keyword to the loop variable enforces immutability within the loop scope, which is a good practice for preventing accidental modifications.


67-67: Simplified error message construction.

The error message string interpolation has been simplified by directly using the exception variable without an explicit toString() call, which makes the code more concise and readable.

lib/mm2/mm2_api/mm2_api.dart (4)

58-66: Updated constructor to use KomodoDefiSdk instead of CoinsRepo.

The constructor has been simplified by removing the coinsRepo parameter and now properly initializes the nft property with the sdk parameter instead. This matches the PR objective to add support for HD wallet and multi-address capabilities.


107-109: Improved logging pattern in _fallbackToBalanceTaker method.

The log statement now uses the .ignore() method, following a consistent pattern across the codebase for handling log statements.


441-441: Removed unnecessary await keyword.

The await keyword was removed from the _fallbackToBalanceTaker call in the catch block, which is appropriate since the method is already returning a Future that doesn't need to be awaited in this context.


606-606: Simplified error logging in showPrivKey method.

The error message now directly uses the exception object without an explicit toString() call, which makes the code more concise while maintaining the same functionality.

lib/bloc/nft_receive/bloc/nft_receive_state.dart (3)

12-12: Renamed state class for better semantic clarity.

Renaming NftReceiveHasBackup to NftReceiveBackupSuccess provides better semantic clarity by indicating the successful state of the backup operation.


14-43: Enhanced NFT receive state with richer model.

The NftReceiveLoadSuccess state now contains more comprehensive data with asset, pubkeys, and optional selectedAddress properties. This provides better support for HD wallets and multi-address functionality as mentioned in the PR objectives. The properly implemented copyWith method and props list ensure correct state handling and equality comparison.


45-49: Renamed failure state for consistency.

Renaming NftReceiveFailure to NftReceiveLoadFailure brings consistency to the state naming convention, clearly indicating it's related to the loading process.

lib/bloc/coins_bloc/coins_state.dart (4)

4-14: Added asset filtering to exclude NFT assets from display.

The constructor now includes clear documentation and applies filtering to exclude assets not intended for user display, such as NFTs. This directly addresses the issue mentioned in the PR objective of fixing the infinite loading screen when accessing the NFT page with HD mode and multi-address support.


16-22: Updated initial factory method to use non-const constructor.

The initial factory method was modified to use a non-const constructor, which is necessary to support the filtering logic in the constructor.


34-61: Enhanced copyWith method with filtering logic.

The copyWith method now includes detailed comments explaining the filtering process and applies the _filterExcludedAssets function to both coins and walletCoins. This ensures that any state modifications maintain the exclusion of assets that shouldn't be displayed to users.


63-70: Added helper method for filtering excluded assets.

The new _filterExcludedAssets method encapsulates the filtering logic in a reusable way, ensuring consistent filtering of excluded assets throughout the class. This is an excellent example of code reuse and clean architecture.

lib/mm2/mm2_api/mm2_api_nft.dart (10)

4-5: Imports look good.
These additions provide necessary references to Komodo Defi packages and logging utilities.

Also applies to: 7-8


19-23: Constructor dependency injection is well-structured.
Switching from a CoinsRepo to a KomodoDefiSdk dependency aligns well with the broader refactor toward the SDK-based approach, and leveraging Logger for _log is neatly done.


37-37: Enabling NFT chains prior to updating the NFT list.
Calling _tryEnableNftChains ensures chains are activated before fetching. This is a logical improvement that prevents possible empty or invalid returns.


41-43: Verbose logging of requests and responses.
Using _log.fine for request/response data is appropriate for debugging without cluttering higher log levels.


46-46: Logging error at shout level.
The usage of _log.shout('Error updating nfts', e, s); provides a clear high-level alert for runtime failures.


64-65: Consistent logging style.
Catching the exception and using _log.shout(e.toString(), e, s); is consistent with the rest of your error logging.


83-85: Controller logs for GetNftList request.
Logging the request and response offers better traceability in diagnosing NFT chain issues.


88-89: Error handling for getNftList.
Raising a TransportError after logging the failure ensures consistent downstream handling of errors.


133-147: Active NFT chains derivation logic.
Extracting _sdk.assets.getActivatedAssets() and filtering by enabledCoinIds produces a neat approach to ensuring only recognized chains are processed. The additional debug logs for enabledCoinIds, nftCoins, activeChains, and nftChains are informative for troubleshooting.


186-186: Error base message added.
This constant clarifies the origin of thrown exceptions in ProxyApiNft usage and aids debugging.

lib/bloc/nft_receive/bloc/nft_receive_event.dart (4)

7-7: Switching to nullable type in base event props.
Using List<Object?> in props facilitates improved event property handling when dealing with potential nulls.


10-12: Renamed and refined event for receiving NFTs.
Introducing NftReceiveStarted with a required chain is clearer than a generic initialization event.


19-20: Concise refresh event name.
NftReceiveRefreshRequested is consistent with the typical “Requested” naming pattern in bloc events.


26-29: Address property updated to PubkeyInfo?.
Switching from a String? to PubkeyInfo? better expresses the structure of NFT addresses and supports more robust data. The props override correctly returns this value for equality checks.

Also applies to: 32-32

lib/views/wallet/coin_details/receive/receive_address.dart (6)

4-4: New import for asset types.
Importing komodo_defi_types.dart is correct for referencing Asset and PubkeyInfo classes.


15-21: Constructor signature now accepts Asset and pubkeys.
This transition from a coin-centric model to asset-based parameters, plus a new pubkeys field, clarifies usage and is consistent with the broader shift to Asset references.


23-27: New fields for asset-based handling.
Defining asset, pubkeys, and selectedAddress significantly improves clarity, ensuring the widget works with strongly typed data.


34-36: Passing asset and pubkeys to Trezor flow.
Providing the correct asset data for Trezor usage ensures the appropriate address context is available.


41-41: Safeguard for missing address.
Early return when selectedAddress is null prevents null pointer issues and displays a user-friendly message.


46-46: Using selectedAddress!.address.
After the null check, force-unwrapping is safe here. The approach remains consistent for both mobile and desktop.

Also applies to: 53-53

lib/bloc/nfts/nft_main_bloc.dart (5)

18-20: Clean parameter renaming from kdfSdk to sdk

This change improves code clarity and consistency by using a more concise and appropriate variable name.


29-36: Improved authentication state management

Good refactoring that removes the need for an internal _isLoggedIn variable by directly subscribing to _sdk.auth.authStateChanges. This approach is more reliable as it directly reflects the actual authentication state from the SDK.


49-51: Replaced boolean flag with direct authentication check

The code now properly uses await _sdk.auth.isSignedIn() instead of relying on an internal state variable. This makes the authentication check more accurate and reduces potential state synchronization issues.

Also applies to: 76-78, 111-113


151-153: Enhanced method signature with optional parameter

Adding an optional parameter with a default value to _getAllNfts improves the method's flexibility while maintaining backward compatibility.


59-64: Improved code formatting with consistent indentation

The code now follows better formatting practices with properly indented multi-line method calls, making the code more readable.

Also applies to: 84-93, 123-129

lib/views/wallet/coin_details/receive/receive_address_trezor.dart (2)

13-24: Updated parameter types to support HD wallet functionality

Constructor parameters have been updated to work with Asset and AssetPubkeys instead of Coin, aligning with the changes needed to support HD wallets and multi-address functionality.


39-44: Replaced custom widget with reusable component

Using the SourceAddressField component instead of a custom implementation improves code reusability and consistency across the application.

lib/bloc/nft_receive/bloc/nft_receive_bloc.dart (6)

22-25: Improved event naming for better clarity

Event names have been updated to follow better naming conventions: NftReceiveStarted, NftReceiveRefreshRequested, and NftReceiveAddressChanged. This improves code readability and understanding.


29-29: Added logging for better debugging

The addition of a Logger instance enhances the debuggability of the NFT receive workflow. This is particularly valuable for diagnosing issues with HD wallet and multi-address support.


36-40: Added state validation to prevent redundant initialization

Now checking if already in the success state before proceeding with initialization, which prevents unnecessary processing and potential state flicker.


44-47: Enhanced error handling with logging

Added proper logging and error state emission when a coin isn't found for the given chain, improving error traceability and user experience.


98-115: Improved address change handling with better validation

The address change logic now properly checks the current state and provides detailed logging about the selected address, making the code more robust and maintainable.


83-91: Improved refresh handling with better logging and error handling

The refresh logic now includes proper logging and handles the null chain case explicitly, preventing potential issues with the NFT receive workflow.

lib/views/nfts/nft_receive/common/nft_receive_card.dart (4)

18-32: Updated component to support HD wallet functionality

Component parameters have been updated to work with PubkeyInfo and AssetPubkeys instead of string addresses, supporting the multi-address functionality needed for HD wallets.


88-88: Fixed QR code generation to use address property

The QR code address is now correctly extracted from the PubkeyInfo object's address property, ensuring that the QR code represents the actual address.


118-119: Updated chain detection to work with Asset type

The fromCoinToChain method has been modified to work with the Asset type instead of Coin, using coin.id.id as the identifier for chain detection.


105-108: Updated ReceiveAddress integration

The ReceiveAddress component is now correctly configured with the asset and pubkeys parameters, aligning with the changes in that component.

@takenagain takenagain changed the title fix(nft): add nft v2 and hd wallet (single, swap address) support fix(nft): add nft v2 and hd wallet support Apr 3, 2025
@takenagain
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 2

🧹 Nitpick comments (2)
lib/views/wallet/coin_details/receive/receive_address_trezor.dart (1)

63-63: Null safety check may be redundant.

The code uses the null assertion operator (!) on selectedAddress, which is safe in this context because _buildCopyButton appears to only be called when selectedAddress is non-null (based on the conditional in the build method). However, for additional safety, consider adding a null check within the onTap callback.

onTap: () {
-  copyToClipBoard(context, selectedAddress!.address);
+  if (selectedAddress != null) {
+    copyToClipBoard(context, selectedAddress.address);
+  }
},
lib/bloc/nfts/nft_main_bloc.dart (1)

7-7: Addition of logging capabilities is beneficial.
Importing package:logging/logging.dart helps improve observability. Ensure that log levels are appropriately configured for production.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dffb9b8 and 4a4cfb2.

📒 Files selected for processing (23)
  • lib/bloc/nft_receive/bloc/nft_receive_bloc.dart (2 hunks)
  • lib/bloc/nfts/nft_main_bloc.dart (3 hunks)
  • lib/bloc/nfts/nft_main_event.dart (1 hunks)
  • lib/bloc/nfts/nft_main_state.dart (1 hunks)
  • lib/bloc/trezor_bloc/trezor_repo.dart (1 hunks)
  • lib/bloc/withdraw_form/withdraw_form_bloc.dart (1 hunks)
  • lib/blocs/trezor_coins_bloc.dart (1 hunks)
  • lib/mm2/mm2_api/mm2_api_nft.dart (6 hunks)
  • lib/mm2/mm2_api/rpc/nft/refresh_nft_metadata/refresh_nft_metadata_req.dart (1 hunks)
  • lib/mm2/mm2_api/rpc/nft/update_nft/update_nft_req.dart (1 hunks)
  • lib/model/hd_account/hd_account.dart (2 hunks)
  • lib/model/nft.dart (2 hunks)
  • lib/shared/widgets/copyable_address_dialog.dart (1 hunks)
  • lib/views/nfts/common/widgets/nft_image.dart (2 hunks)
  • lib/views/nfts/nft_main/nft_main_controls.dart (3 hunks)
  • lib/views/nfts/nft_main/nft_main_failure.dart (1 hunks)
  • lib/views/nfts/nft_main/nft_refresh_button.dart (1 hunks)
  • lib/views/nfts/nft_page.dart (1 hunks)
  • lib/views/nfts/nft_tabs/nft_tabs.dart (1 hunks)
  • lib/views/wallet/coin_details/receive/receive_address.dart (1 hunks)
  • lib/views/wallet/coin_details/receive/receive_address_trezor.dart (3 hunks)
  • lib/views/wallet/coin_details/receive/receive_details.dart (6 hunks)
  • lib/views/wallet/coin_details/receive/request_address_button.dart (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • lib/views/nfts/nft_main/nft_main_controls.dart
  • lib/model/nft.dart
  • lib/mm2/mm2_api/mm2_api_nft.dart
  • lib/bloc/nft_receive/bloc/nft_receive_bloc.dart
🔇 Additional comments (64)
lib/mm2/mm2_api/rpc/nft/refresh_nft_metadata/refresh_nft_metadata_req.dart (1)

32-32: Parameter name changed from "proxy_auth" to "komodo_proxy"

The parameter has been renamed from "proxy_auth" to "komodo_proxy" while maintaining the same boolean value (false). This change appears to be part of the fix for NFT page loading issues with HD wallet mode, likely aligning with updated backend API requirements.

lib/mm2/mm2_api/rpc/nft/update_nft/update_nft_req.dart (1)

26-26: Parameter name changed from "proxy_auth" to "komodo_proxy"

The parameter has been renamed from "proxy_auth" to "komodo_proxy" while maintaining the same boolean value (false). This change is consistent with the same update in the RefreshNftMetadataRequest class, ensuring uniform parameter naming across NFT-related API calls.

lib/model/hd_account/hd_account.dart (2)

1-1: LGTM: Importing necessary package.

The import of komodo_defi_types package is necessary to support the newly added functionality.


69-76: LGTM: Well-implemented conversion method.

This method provides a clean way to convert an HdAddress instance to a PubkeyInfo object, which is essential for NFT functionality to work with HD wallets. The implementation correctly maps all required fields.

Note that the balance conversion uses JSON serialization/deserialization (balance.toJson() followed by BalanceInfo.fromJson()). While this works, direct conversion methods are generally more efficient if they become available in the future.

lib/bloc/trezor_bloc/trezor_repo.dart (1)

169-172: Updated parameter type from Coin to Asset

Parameter type has been updated from Coin to Asset to align with the broader transition from coin-based to asset-based model throughout the application.

lib/blocs/trezor_coins_bloc.dart (2)

31-37: Updated method signature and implementation to use Asset instead of Coin

The initNewAddress method has been updated to use Asset instead of Coin, and now retrieves the address using asset.id.id instead of coin.abbr. This change aligns with the transition to asset-based model throughout the application.


39-50: Updated parameter types and improved callback type safety

The changes include:

  1. Updated parameter type from Coin to Asset to align with the asset-based model
  2. Improved type safety by explicitly defining the callback as void Function(GetNewAddressResponse) rather than using the more generic Function
  3. Updated the parameter passed to getNewAddressStatus to use the new asset parameter

These changes improve type safety and maintain consistency with the asset-based model transition.

lib/shared/widgets/copyable_address_dialog.dart (2)

7-136: New CopyableAddressDialog widget for handling addresses

This new widget provides a well-structured way to display, copy, and select cryptocurrency addresses. The implementation includes:

  1. A flexible UI that supports address truncation for better display
  2. Address selection functionality via showAddressSearch
  3. Copy-to-clipboard functionality
  4. Customizable styling options

The code is well-organized with clean separation of UI and functionality.

A few suggestions for improvements:

-  // Handle null address case
+  // Return empty widget if address is null
   if (address == null) {
     return const SizedBox.shrink();
   }

Consider adding error handling for the copy operation and providing user feedback when the copy operation succeeds.


123-134: Address search with proper context validation

The _showAddressSearch method correctly checks if the context is still mounted before attempting to show the dialog, which prevents potential issues if the widget is disposed before the async operation completes.

lib/views/wallet/coin_details/receive/request_address_button.dart (4)

7-7: Import looks good.

The new import for komodo_defi_types is necessary for PubkeyInfo. No concerns here.


19-25: Constructor refactor appears consistent.

Switching from (Coin coin, Function(String) onSuccess) to (Asset asset, void Function(PubkeyInfo) onSuccess) aligns with the broader Asset-centric approach. Parameter naming is clear and types are well-defined.


99-103: Good subscription handling.

Initializes the request with initNewAddress() and then subscribes to status updates. The null check on taskId ensures the flow terminates gracefully if address initialization fails. This prevents unintended subscriptions.


154-154: Callback update is well-handled.

Passing details.newAddress.toPubkeyInfo() to the success callback reflects the new approach for handling addresses. This ensures the rest of the app receives the correct, structured data.

lib/views/wallet/coin_details/receive/receive_details.dart (11)

24-26: New constructor arguments.

Introducing pubkeys and positioning super.key in the constructor are consistent with the revised design. No issues found.


30-30: Additional field for AssetPubkeys.

Declaring final AssetPubkeys pubkeys; provides the needed reference for the new functionality. Looks good.


56-56: Child widget instantiation.

Passing pubkeys to _ReceiveDetailsContent ensures consistent use of the new data model within child components.


67-70: Stateful content widget.

The _ReceiveDetailsContent constructor requiring both asset and pubkeys is coherent with the rest of the refactor. This enforces data consistency.


77-77: _currentAddress now uses PubkeyInfo?.

Migrating from a String? to PubkeyInfo? approach properly reflects the richer address data model. This helps avoid repeated string-to-object conversions.


98-100: Card styling changes.

Applying a conditional background color and border radius is a reasonable UI enhancement. No concerns about performance or complexity here.


116-127: Container decoration block.

These lines set up the address display card with shadow and color. Straightforward and coherent with Flutter design patterns.


135-142: Text style adjustments.

Updating the network label style is consistent with app theming. Clear usage of themeData.textTheme is good practice.


148-150: Refined parameter usage in ReceiveAddress.

Passing both asset and pubkeys ensures the widget can retrieve correct address data. The consistent naming improves readability.


157-157: Safe null-check.

Using _currentAddress! is protected by the preceding if (_currentAddress != null). Good handling of nullability.


177-180: Address change callback.

The setter for _currentAddress is straightforward and ensures state updates are triggered correctly. No concerns.

lib/views/wallet/coin_details/receive/receive_address.dart (8)

4-4: komodo_defi_types import is aligned with changes.

We need PubkeyInfo types. No further issues.


10-10: copyable_address_dialog.dart import is correct.

This aligns with the replacement of the old CopiedText widget. Looks good.


16-22: Constructor parameters updated.

Switching from coin to asset, alongside pubkeys and onChanged(PubkeyInfo?), is consistent with the new data model across the codebase.


24-29: Field additions reflect refactor.

Defining asset, pubkeys, and a nullable selectedAddress of type PubkeyInfo? ensures the widget can correctly manage address data.


35-39: ReceiveAddressTrezor updates.

Passing asset, selectedAddress, pubkeys, onChanged matches the Trezor flow with the new data types. No concerns here.


42-44: Handling absence of selectedAddress.

Returning a message when no address is available is user-friendly and avoids null reference errors. Good fallback.


46-52: Mobile UI with CopyableAddressDialog.

Replacing CopiedText with a dialog-based approach is more flexible. The constructor usage is correct, and onAddressChanged is passed properly.


54-63: Desktop UI with CopyableAddressDialog.

Similarly, the non-mobile layout constraints and usage are consistent with the mobile approach. Good user experience design.

lib/views/wallet/coin_details/receive/receive_address_trezor.dart (5)

4-6: Well-structured import organization.

The imports have been updated to include the necessary types from komodo_defi_types and UI components from the Komodo UI libraries, which aligns with the modernization of the component to support HD wallets and NFT v2.


12-17: Constructor parameters updated appropriately for HD wallet support.

The constructor has been refactored to accept asset and pubkeys instead of a coin parameter, allowing for more structured handling of cryptocurrency assets and their associated public keys, which is essential for HD wallet support.


19-22: Type changes improve code safety and structure.

The transition from string-based to object-oriented data types (Asset, AssetPubkeys, PubkeyInfo) enhances type safety and provides more structured data handling. This is a significant improvement for maintaining the relationship between assets and their addresses in an HD wallet context.


38-42: Good component refactoring.

Replacing the custom _BuildSelect widget with the more standardized SourceAddressField improves code maintainability and reusability. This change aligns with modern component-based architecture principles.


55-55: API consistency maintained.

The request button implementation has been updated to use the new asset parameter while maintaining the same callback pattern, ensuring consistent behavior with the updated data model.

lib/views/nfts/nft_tabs/nft_tabs.dart (1)

40-40: Event naming convention update looks good

The event dispatch has been updated from ChangeNftTabEvent to NftMainTabChanged, which follows a better naming convention pattern (entity + past tense verb). This aligns with what appears to be a broader effort to standardize event naming across the application.

lib/views/nfts/nft_main/nft_main_failure.dart (1)

30-30: Event naming improved for clarity

The event dispatch has been updated from UpdateChainNftsEvent to NftMainChainUpdateRequested, which is more descriptive and follows a consistent naming pattern. This change maintains the same functionality while improving code readability.

lib/views/nfts/nft_main/nft_refresh_button.dart (1)

30-30: Event naming standardization applied

The event dispatch has been updated from RefreshNFTsForChainEvent to NftMainChainNftsRefreshed, maintaining the same functionality while adopting a more consistent naming convention. The change correctly passes the selected chain parameter to the new event.

lib/views/nfts/common/widgets/nft_image.dart (2)

52-53: Good addition of GIF detection

Adding a specific check for GIF files will allow for special handling of this image format, which is often used for animated NFTs.


62-67: Enhanced image handling with proper error reporting

These changes bring two significant improvements:

  1. The gaplessPlayback: isGif parameter ensures smoother GIF animation playback
  2. The enhanced error handling now logs detailed information when image loading fails

This will greatly help with debugging image loading failures while providing a better user experience for animated NFTs.

lib/views/nfts/nft_page.dart (2)

68-69: Use of descriptive event names is commendable.
Replacing generic event names with NftMainChainUpdateRequested and NftMainUpdateNftsStarted clarifies the intent and flow of updates, making the code more readable and maintainable.


75-75: Good practice to stop updates upon disposal.
Dispatching NftMainUpdateNftsStopped() in dispose ensures that any ongoing timers or NFT update processes are safely terminated, preventing potential memory leaks or unwanted background tasks.

lib/bloc/nfts/nft_main_state.dart (1)

14-14: Switch to factory constructor is a clean approach.
Converting initial() into a factory constructor can help streamline state instantiation logic. This also aligns well if future changes require more complex initialization.

lib/bloc/nfts/nft_main_event.dart (6)

7-8: Improved naming clarifies the event's purpose.
NftMainChainUpdateRequested better conveys the underlying action than a generic “update” event name.


11-12: Stopping event name is straightforward.
NftMainUpdateNftsStopped succinctly indicates the update process has been halted. Clear naming aids maintainability.


15-16: Starting event name is more explicit.
NftMainUpdateNftsStarted clearly indicates the commencement of an NFT update loop or timer, improving code clarity.


19-20: Reset event name is self-descriptive.
NftMainResetRequested provides a clear entry point for resetting state without ambiguity.


23-24: Tab change event naming is coherent.
NftMainTabChanged clarifies that it specifically relates to a UI or internal tab selection event.


28-29: Refreshed event name is more meaningful.
NftMainChainNftsRefreshed indicates that the chain’s NFTs are being fetched fresh, benefiting code traceability.

lib/bloc/nfts/nft_main_bloc.dart (13)

19-21: Constructor changes streamline authentication logic.
Introducing sdk directly (instead of a separate kdfSdk and isLoggedIn) centralizes auth checks in _sdk.auth. This reduces coupling and clarifies responsibilities.


23-28: Registering new event handlers is well-structured.
These additions ensure the NftMainBloc cleanly responds to the newly named events without leftover references to removed ones.


30-38: Listening to auth state changes is robust.
Automatically updating or resetting NFTs upon sign-in or sign-out ensures the UI remains consistent. Be mindful of possible race conditions if multiple events arrive quickly.

Would you like to check that multiple sign-ins or sign-outs in quick succession do not interrupt ongoing NFT-related operations? I can provide a script for scanning concurrency patterns or add tests to confirm.


41-41: Encapsulating SDK reference is concise.
Storing KomodoDefiSdk as a final field fosters clarity about its immutability.


44-44: Logger instantiation is good practice.
Having a dedicated logger for this bloc provides fine-grained logging control.


46-76: _onTabChanged ensures chain-specific NFTs are fetched.
The logic checks if the user is signed in and if the state is initialized before fetching NFTs, which prevents unnecessary calls. The error handling and logging also look solid.


116-120: Reset logic is clear.
Emitting NftMainState.initial() after a reset event reverts the bloc to a known baseline. This helps prevent stale data if the user signs out.


121-157: _onRefreshForChain safely updates a single chain.
Using updatingChains to track refresh states is a good approach to guard concurrency. The error handling, logging, and final block for toggling updatingChains are well-structured.


159-164: _onStopUpdate gracefully cancels timers.
Invoking _stopUpdate() helps avoid background processes continuing after the user leaves the relevant screen.


165-173: _onStartUpdate sets up periodic updates.
A 1-minute interval for NFT updates seems reasonable, but verify that repeated calls don’t stack if the user quickly toggles navigation.

I can prepare a script to grep for multiple timer creations, ensuring _onStartUpdate is invoked only once per relevant scenario. Let me know if you’d like me to generate it.


174-193: _getAllNfts is well-factored.
Updating the repo before retrieving NFTs ensures fresh data. The usage of a fold operation for grouping by chain is concise and clear.


196-210: _calculateNftCount includes a chain sort feature.
Grouping NFT counts and sorting the chains by descending count is clean and tight. The use of pattern tuples helps with well-structured data returns.


78-114:

Details

❓ Verification inconclusive

_onChainNftsUpdateRequested robustly updates all chains.
The final finally sets isInitialized to true regardless of errors, ensuring the UI won't remain stuck. Consider verifying if partial errors on one chain can block updates for others.

Use the snippet below to search for references to _onChainNftsUpdateRequested calls in case partial chain failures need additional merging logic:


🏁 Script executed:

#!/bin/bash
rg -A 3 "_onChainNftsUpdateRequested"

Length of output: 635


Partial Chain Error Handling in _onChainNftsUpdateRequested

  • Verified that _onChainNftsUpdateRequested is only used as an event handler in lib/bloc/nfts/nft_main_bloc.dart (via on<NftMainChainUpdateRequested>(_onChainNftsUpdateRequested)).
  • The finally block unconditionally sets isInitialized to true, ensuring the UI remains responsive even on errors.
  • Please review if this approach might inadvertently mask partial failures on individual chains. Partial errors during NFT updates may require more granular handling or merging logic to ensure that a failure in one chain doesn't prevent successful updates from others.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2025

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

https://walletrc--pull-2566-merge-x1f3mv8p.web.app

(expires Fri, 02 May 2025 10:41:47 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc

@takenagain
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@takenagain takenagain marked this pull request as ready for review April 16, 2025 20:58
@takenagain takenagain added the QA Ready for QA Testing label Apr 16, 2025
@CharlVS CharlVS requested a review from smk762 April 18, 2025 13:59
@CharlVS
Copy link
Copy Markdown
Collaborator

CharlVS commented Apr 18, 2025

@smk762 I've pushed a fix for #2566. Address conversion happens automatically, but I decided against re-using the address input from the withdrawal form, which has some nice goodies. It's a simple task, but it wasn't a drop-in replacement, and the last thing I want now is to introduce a weird edge-case bug

I also fixed a bug in NFT withdrawal form, which also extends to the coin withdrawal form that fixes the regression where withdrawal-related errors were always showing as “Something wrong happened” instead of the specific error e.g. “FTM balance not sufficient to pay transaction fees.”. This regression has been around for a few months.

  • I suspect an overzelous "check and retry" on rapid fire which could be contributing to app slowness during activation

@smk762, please test if the performance is still acceptable in the release mode build on both web and desktop builds.

The issue may not be straightforward to trace. Since the SDK is now handling activation and the SDK example app handles activations without slowdown, I suspect it may be related to some of the legacy code interacting directly with mm2 which has not yet been migrated to the SDK. The activation error may also be the same.

If there's still a significant slowdown, I will do a search for any low-hanging fruit. But regardless, I'll revisit it in-depth post-release.

@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Apr 21, 2025

image
This happens in HD mode with both lowercase and mixed case addresses when clicking the "send" button. Lowercase addresses do not appear to be converting when changing focus.

If there's still a significant slowdown, I will do a search for any low-hanging fruit. But regardless, I'll revisit it in-depth post-release.

It varies, and though better to release than delay without clear solution, it would be great to invesigate and mitigate before the next release after this one.

@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Apr 22, 2025

Still fails. I can see the address change to mixed case when I click send, though there is no warning etc. When the send fails, it reverts back to lowercase.
In app, the error is Something went wrong!.
In console error is KDF: 22 05:08:17, mm2_main::rpc::dispatcher:125] ERROR RPC error response: eth:1171] eth:2281] Internal error: 'my_address' is deprecated for HD wallets

vokoscreenNG-2025-04-22_13-08-00.mp4

@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Apr 22, 2025

Related KDF issue: GLEECBTC/komodo-defi-framework#2421

@CharlVS CharlVS added P0 Blocker / critical defect blocked QA Ready for QA Testing and removed QA Ready for QA Testing blocked labels Apr 24, 2025
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.

Tested and confirmed to be working in HD mode. cc @smk762

image image

When selecting the non-swap address:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working P0 Blocker / critical defect QA Ready for QA Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NFT send form fails to convert lowercase addresses to mixed case

3 participants