Skip to content

Conversation

gemdev111
Copy link
Contributor

@gemdev111 gemdev111 commented Sep 25, 2025

Summary

Refactored ConfirmTransferScene to use a sectioned list architecture with dedicated view models for each component, improving modularity, testability, and maintainability.

Changes

Architecture Improvements

  • Adopted ListSectionProvideable pattern: Replaced the legacy transaction list with ListSectionView for better organization
  • Created dedicated view models: Introduced 9 specialized view models for different transfer components:
    • ConfirmHeaderViewModel - Transfer header display
    • ConfirmAppViewModel - WalletConnect app information
    • ConfirmSenderViewModel - Sender account details
    • ConfirmNetworkViewModel - Network information
    • ConfirmRecipientViewModel - Recipient address handling
    • ConfirmMemoViewModel - Memo field logic
    • ConfirmSwapDetailsViewModel - Swap-specific details
    • ConfirmNetworkFeeViewModel - Network fee display and selection
    • ConfirmErrorViewModel - Error state handling

Code Quality

  • Simplified main view model: Reduced ConfirmTransferSceneViewModel complexity by extracting component-specific logic
  • Cleaned up legacy code: Removed unused methods and properties from TransferDataViewModel
  • Centralized memo logic: Created shared MemoViewModel used by both Transfer and Transactions features
  • Improved type safety: Introduced ConfirmTransferSection and ConfirmTransferItem enums for type-safe section/item modeling

Testing

  • Added TransferTestKit target: New testing utilities package
  • Comprehensive unit tests: Added 268+ test cases covering all new view models
  • Enhanced test helpers: Created mock extensions for BlockExplorerLink, TransactionData, and TransactionInputViewModel

UI/UX

  • Maintained identical user-facing behavior
  • Better separation of concerns for future enhancements
  • More maintainable sheet/alert handling

Files Changed

  • 40 files modified: 1,642 insertions, 475 deletions
  • Key additions: 9 new view model files, 1 new TestKit target, 10 new test files
  • Key modifications: Simplified scene view, refactored main view model

Test Plan

  • ✅ All existing unit tests passing
  • ✅ New unit tests for all view models
  • ✅ Manual testing of transfer confirmation flow
  • ✅ Verified all transfer types (send, swap, stake, etc.)

🤖 Generated with Claude Code

closes #1145
closes #1216

Replaces legacy transaction list with a sectioned ListSectionView in ConfirmTransferScene. Introduces ConfirmTransferSection, ConfirmTransferItem, and related view models for header, app, and sender items. Updates ConfirmTransferSceneViewModel to provide sectioned data and item models. Cleans up TransferDataViewModel by removing app-related properties now handled by dedicated view models. Adds convenience initializer to ListItemImageView.
Introduces dedicated view models for ConfirmTransfer items (network, recipient, memo, network fee, error, swap details) and updates ConfirmTransferScene and related types to use them. Removes legacy code and centralizes item model logic, improving modularity and maintainability. Also updates ListItemImageView and ListSectionView initializers for consistency.
Moved memo formatting and list item model logic from individual view models and the deleted MemoListItemView to a new MemoViewModel in PrimitivesComponents. Updated TransactionMemoViewModel and ConfirmTransferMemoViewModel to use MemoViewModel for memo display. Cleaned up redundant code and improved consistency in memo handling.
Replaces direct construction of SwapDetailsViewModel with ConfirmTransferSwapDetailsViewModel in ConfirmTransferSceneViewModel. Moves swap details logic into a computed property for better encapsulation and maintainability.
Expanded and refactored tests in ConfirmTransferSceneViewModelTests to verify item model outputs for all relevant cases, improving coverage and clarity. Removed redundant memo visibility test from TransferDataViewModelTests.
@gemdev111 gemdev111 marked this pull request as ready for review September 29, 2025 14:33
@gemdev111 gemdev111 self-assigned this Sep 29, 2025
Renamed all ConfirmTransfer*ViewModel files and types to more concise names (e.g., ConfirmAppViewModel, ConfirmErrorViewModel, etc.) for improved clarity and consistency. Updated all references in ConfirmTransferSceneViewModel and related tests to use the new names.
Introduces the TransferTestKit target with mock helpers for testing, updates Package.swift to include TransferTestKit, and adds comprehensive unit tests for Confirm* and TransactionInputViewModel-related ViewModels. Also refactors TransactionInputViewModel for public access and corrects asset selection logic. Updates PrimitivesTestKit mocks and adds SwapData mock helper.
Fixed To Should not be shown for empty transaction, added tests
}

@Test
func transfer() {
Copy link
Contributor

Choose a reason for hiding this comment

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

useless unit tests transfer, deposit ...

}

@Test
func swap() {
Copy link
Contributor

Choose a reason for hiding this comment

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

useless unit tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants