Skip to content

feat(wallet): DashDEX ui and logic improvements - #797

Merged
romchornyi merged 13 commits into
feat/dash-dex-submit-transactionfrom
feat/dash-dex-impr
Jul 16, 2026
Merged

romchornyi merged 13 commits into
feat/dash-dex-submit-transactionfrom
feat/dash-dex-impr

Conversation

@romchornyi

@romchornyi romchornyi commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Implements swap order tracking infrastructure and improves DEX flow with metadata display for better user experience and transaction monitoring.

What was done?

  • Added SwapOrder model and SwapOrdersDAO for persistent swap transaction tracking
  • Implemented SwapTrackingService for monitoring swap status and updates
  • Added SwapOrderMetadataProvider for displaying swap metadata in transaction history
  • Implemented NetworkStatusService for connectivity state monitoring
  • Created database migration for swap_orders table schema
  • Enhanced SwapProvider protocol with improved provider-specific implementations
  • Updated BuyEnterAmountView, BuyReceiveView, RefundAddressView with improved UX
  • Improved SwapConvertView and order preview flow
  • Updated HomeView with swap order metadata display
  • Enhanced MayaPortalView and SwapKit integration
  • Added DEXOfflineToastModifier for offline state handling
  • Created IconName+DashIconSource extension for icon mapping

How Has This Been Tested?

  • Verified database migration creates swap_orders table correctly
  • Tested swap order tracking through complete buy/convert flows
  • Confirmed metadata displays correctly in transaction history
  • Validated offline state detection and toast notifications
  • Tested SwapProvider protocol dispatch with different providers

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Added persistent swap tracking, including progress, completion, expiration, refunds, and failures.
    • Buy flows now create and save orders before displaying receive details and QR codes.
    • Added support for Solana, Cardano, and Sui payment URIs.
    • Added transaction history labeling for swap and Coinbase activity.
    • Added explorer links on successful swaps.
  • Bug Fixes

    • Improved offline handling with clear notifications and disabled actions.
    • Improved validation for Bitcoin-family and refund addresses.
    • Improved QR generation, transaction matching, and Coinbase success navigation.

…ndling

- Enhance SwapAddressValidator with better address validation
- Improve SwapCryptoCurrency for consistent currency handling
- Refine SwapDepositURIBuilder for accurate deposit address generation
- Enhance BuySellPortalView with better layout and navigation
- Improve ShortcutsBarView for better shortcut display
- Refine BuyReceiveView with better UX and messaging
- Update RefundAddressView for NEAR address handling
- Improve SelectCoinView with better coin selection UX
- Enhance SwapPortalScaffold for consistent portal layout
- Enhance SwapKitQuoteDecodingTests for better quote validation
- Add BuyReceiveFlowUITests for buy flow screenshot testing
- Comprehensive test coverage for swap operations
- Update .gitignore for build artifacts
- Update project.pbxproj with test file references
- Maintain DWUpholdMainnetConstants.m configuration
- Ensure clean build environment
- Add SwapOrder model and SwapOrdersDAO for transaction tracking
- Implement SwapTrackingService for monitoring swap status
- Add SwapOrderMetadataProvider for displaying swap metadata in transactions
- Implement NetworkStatusService for connectivity monitoring
- Add database migration for swap_orders table
- Enhance SwapProvider protocol with provider-specific implementations
- Update BuyEnterAmountView, BuyReceiveView, RefundAddressView with improved UX
- Improve SwapConvertView and order preview flow
- Update HomeView with swap order metadata display
- Enhance MayaPortalView and SwapKit integration
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

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.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b39571fa-43c2-40f0-a38c-068f99a40a0f

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds persisted Dash DEX swap orders with background tracking, refactors buy flow order creation and receive rendering, introduces centralized network monitoring and offline UI, expands chain URI/address support, adds Coinbase and swap transaction metadata, updates transaction rendering, and adds buy-receive UI automation.

Changes

Dash DEX swap lifecycle

Layer / File(s) Summary
Swap order persistence and tracking
DashWallet/Sources/Models/Swap/*, DashWallet/Sources/Infrastructure/Database/*, DashWallet/AppDelegate.m
Adds the SwapOrder model/table, actor-based DAO, transaction matching, provider tracking, and startup polling.
Buy order creation and receive flow
DashWallet/Sources/UI/Swap/Buy/*, DashWallet/Sources/UI/Swap/SwapFlowCoordinator.swift
Creates and persists buy orders from the refund screen and passes the resulting order into the receive flow.

Network and UI integration

Layer / File(s) Summary
Network-aware DEX screens
DashWallet/Sources/Infrastructure/NetworkStatusService.swift, DashWallet/Sources/UI/Swap/*
Replaces local reachability handling with shared network state, offline gating, and a reusable offline toast.
Chain validation and URI support
DashWallet/Sources/Models/Maya/MayaConstants.swift, DashWallet/Sources/Models/Swap/*
Adds chain-specific address validation and Solana, Cardano, and Sui deposit URIs while hardening URL construction.
Transaction metadata and rendering
DashWallet/Sources/UI/Home/*, DashWallet/Sources/Models/Coinbase/*, DashWallet/Sources/Models/Swap/*
Adds Coinbase and swap-order metadata providers and renders transaction rows using DashUIKit components.

Supporting changes

Layer / File(s) Summary
Status, accessibility, and test coverage
DashWallet/Sources/UI/Swap/TransactionStatus/*, DashWalletScreenshotsUITests/*, DashWallet.xcodeproj/project.pbxproj
Updates swap status screens, accessibility identifiers, build registration, project versions, and buy-receive UI automation with CSV-driven cases.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested reviewers: hashengineering, micaela12-22

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the PR, but "ui and logic improvements" is too generic to describe the main changes clearly. Rename it to mention the core changes, such as swap tracking, offline handling, and DEX metadata updates.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dash-dex-impr

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

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

@romchornyi

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (10)
DashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swift (1)

18-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Sort imports with the configured linter.

SwiftLint reports the current import ordering as invalid.

As per coding guidelines, “Use SwiftFormat and SwiftLint for Swift code formatting and linting as configured in .swiftformat and .swiftlint.yml files.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Home/Tx` Metadata/SwapOrderMetadataProvider.swift
around lines 18 - 20, Reorder the imports in SwapOrderMetadataProvider.swift
according to the project’s configured SwiftLint import-ordering rule, without
changing the implementation.

Sources: Coding guidelines, Linters/SAST tools

DashWallet/Sources/UI/Home/Tx Metadata/GiftCardMetadataProvider.swift (1)

100-107: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the guarded force unwraps.

Lines 102 and 131 violate the configured force_unwrapping rule. Bind the existing metadata with if var existingMetadata = txRowMetadata, mutate it, then assign it back.

As per coding guidelines, “Use SwiftFormat and SwiftLint for Swift code formatting and linting as configured in .swiftformat and .swiftlint.yml files.”

Also applies to: 129-136

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Home/Tx` Metadata/GiftCardMetadataProvider.swift around
lines 100 - 107, Remove the force unwraps in the metadata update branches of the
transaction metadata provider. In both affected branches, bind txRowMetadata
with if var existingMetadata, update its title and secondaryIcon, then assign
the modified value back to txRowMetadata; preserve the existing creation path
when metadata is absent.

Sources: Coding guidelines, Linters/SAST tools

DashWallet/Sources/Models/Swap/SwapTrackingService.swift (3)

65-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefix DSLogger diagnostics with an emoji marker.

Use a consistent marker such as 🔍 so these polling logs remain filterable.

As per coding guidelines, “Use emoji debug markers for easy log filtering.”

Also applies to: 73-73, 159-159, 169-169, 188-188

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Swap/SwapTrackingService.swift` at line 65, Update
the DSLogger diagnostics in SwapTrackingService, including the logs at the
referenced polling and lifecycle points, to prefix each message with the
consistent 🔍 emoji marker while preserving their existing log content.

Source: Coding guidelines


22-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Resolve the configured SwiftLint violations.

Line 24 needs the attribute on its own line, and pollOrder exceeds the configured cyclomatic-complexity limit. Extract provider status resolution from pollOrder.

As per coding guidelines, “Use SwiftFormat and SwiftLint for Swift code formatting and linting as configured in .swiftformat and .swiftlint.yml files.”

Also applies to: 85-190

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Swap/SwapTrackingService.swift` around lines 22 -
24, Resolve the SwiftLint violations in SwapTrackingServiceObjcWrapper.start and
pollOrder: place the required attribute on its own line according to the
configured SwiftFormat rules, then extract the provider-status resolution logic
from pollOrder into a focused helper so pollOrder falls within the configured
cyclomatic-complexity limit while preserving existing behavior.

Sources: Coding guidelines, Linters/SAST tools


39-56: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Inject the tracking collaborators.

The new tracker constructs concrete DAO/providers and reads the wallet and clock directly. Introduce protocols for storage, status lookup, wallet lookup, and time so route selection, API-error handling, and 24-hour expiry can be tested deterministically.

As per coding guidelines, “Use protocol-based design with extensive use of protocols for dependency injection.”

Also applies to: 92-143, 212-218

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Swap/SwapTrackingService.swift` around lines 39 -
56, Refactor SwapTrackingService to use injected protocols for order storage,
swap-status lookup, wallet lookup, and clock access instead of constructing
concrete collaborators or reading global wallet/time state directly. Add
protocol abstractions and initializer dependencies, update route selection,
API-error handling, and 24-hour expiry logic to use those dependencies, while
preserving the shared production instance through default concrete
implementations.

Source: Coding guidelines

DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift (1)

18-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Apply the configured SwiftLint layout.

SwiftLint reports unsorted imports and vertical parameter-alignment violations in the insert call.

As per coding guidelines, “Use SwiftFormat and SwiftLint for Swift code formatting and linting as configured in .swiftformat and .swiftlint.yml files.”

Also applies to: 51-67

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift` around lines 18 - 20,
Apply the repository’s configured SwiftLint/SwiftFormat layout in SwapOrdersDAO:
sort the Foundation, SQLite, and Combine imports according to the configured
rule, then correct vertical parameter alignment in the insert call around the
affected DAO method. Preserve all existing behavior and values.

Sources: Coding guidelines, Linters/SAST tools

DashWallet/Sources/Models/Swap/SwapKitErrorCopy.swift (1)

25-100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reduce message(for:coin:) complexity to satisfy SwiftLint.

SwiftLint reports complexity 13 versus the configured maximum of 10. Move fixed error-code mappings into a lookup table and retain only the coin-formatted cases as branches.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Swap/SwapKitErrorCopy.swift` around lines 25 - 100,
Reduce complexity in message(for:coin:) by moving fixed localized error messages
into a lookup table keyed by normalized error codes, leaving only coin-dependent
cases such as blacklistasset and invalidsourceaddress in the switch. Preserve
all existing mappings and the generic fallback behavior.

Sources: Coding guidelines, Linters/SAST tools

DashWallet/Sources/UI/Home/Views/Shortcuts/ShortcutsBarView.swift (1)

135-142: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract #if SNAPSHOT from the ViewBuilder switch body into a helper function.

The #if SNAPSHOT / #else block inside the .secureWallet switch case is conditional compilation within a SwiftUI ViewBuilder body. As per coding guidelines, this should be avoided to prevent potential buildExpression errors. Extract the .secureWallet case to a helper function so the #if sits at the top level of a separate function instead of nested inside a switch within the ViewBuilder.

♻️ Proposed refactor
     case .secureWallet:
-        `#if` SNAPSHOT
-        content
-            .accessibilityElement(children: .combine)
-            .accessibilityIdentifier("shortcut_secure_wallet")
-        `#else`
-        content
-        `#endif`
+        secureWalletContent(content)
     default:
         content
     }
+}
+
+private func secureWalletContent(_ content: Content) -> some View {
+    `#if` SNAPSHOT
+    content
+        .accessibilityElement(children: .combine)
+        .accessibilityIdentifier("shortcut_secure_wallet")
+    `#else`
+    content
+    `#endif`
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Home/Views/Shortcuts/ShortcutsBarView.swift` around
lines 135 - 142, Extract the .secureWallet switch-case content from the
ViewBuilder into a dedicated helper function, and move the SNAPSHOT conditional
compilation block to the top level of that helper. Update the switch to call the
helper while preserving the existing accessibility identifier and
combined-children behavior under SNAPSHOT, and the unchanged content rendering
otherwise.

Source: Coding guidelines

DashWallet/Sources/UI/SwapKit/SwapKitPortalView.swift (1)

25-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting the network status tracking pattern.

The @State + .onReceive(NetworkStatusService.shared.statusPublisher) pattern is duplicated in MayaPortalView.swift (lines 27 and 41-43). A shared ViewModifier or a small ObservableObject wrapper around NetworkStatusService would centralize the subscription logic and reduce duplication across portal views.

Also applies to: 41-43

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/SwapKit/SwapKitPortalView.swift` at line 25, Extract
the duplicated network-status state and subscription logic from
SwapKitPortalView and MayaPortalView into a shared ViewModifier or
ObservableObject wrapper around NetworkStatusService. Update both portal views
to use the shared abstraction while preserving their existing isOnline
initialization and statusPublisher-driven updates.
DashWallet/Sources/UI/Swap/EnterAddress/EnterAddressViewModel.swift (1)

97-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting subscribeToNetworkStatus into a shared protocol extension.

This 7-line implementation is identical across at least 6 ViewModels (EnterAddressViewModel, RefundAddressViewModel, SwapConvertViewModel, BuyEnterAmountViewModel, OrderPreviewViewModel, SelectCoinViewModel). A protocol with default implementation could eliminate the duplication:

protocol NetworkStatusSubscribing: AnyObject {
    var networkStatus: NetworkStatusProviding { get }
    var cancellables: Set<AnyCancellable> { get set }
    var isOnline: Bool { get set }
}

extension NetworkStatusSubscribing {
    func subscribeToNetworkStatus() {
        networkStatus.statusPublisher
            .sink { [weak self] status in
                self?.isOnline = status == .online
            }
            .store(in: &cancellables)
    }
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Swap/EnterAddress/EnterAddressViewModel.swift` around
lines 97 - 103, Extract the duplicated subscribeToNetworkStatus implementation
into a shared NetworkStatusSubscribing protocol with the required networkStatus,
cancellables, and isOnline properties, then provide the default subscription
implementation in its protocol extension. Update EnterAddressViewModel and the
other identified ViewModels to conform and remove their local implementations
while preserving existing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DashWallet/Sources/Models/Maya/MayaConstants.swift`:
- Around line 40-42: Update MayaConstants.explorerTransactionURL to avoid
force-unwrapping URL(string:) with the interpolated depositAddress. Safely
handle URL construction failure by returning the explorer home URL as the
fallback, while preserving the transaction URL for valid addresses.

In `@DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift`:
- Around line 39-45: Serialize all SwapOrdersDAO state access through a single
executor, such as an actor or equivalent private synchronization mechanism,
covering loadAll, create/update, delete, cache mutations, and allOrdersSubject
publication. Ensure initial hydration completes before accepting or applying
writes, or otherwise merge hydration with intervening writes so a stale loadAll
snapshot cannot overwrite newly cached orders; update the DAO methods around
private init, loadAll, and the referenced create/update/delete paths
consistently.
- Around line 92-100: Update SwapOrdersDAO.delete(byId:) to remove the cache
entry only after execute(deleteQuery) completes successfully. Keep emitUpdate()
on the successful path, and leave the cache unchanged when the database delete
throws.

In `@DashWallet/Sources/Models/Uphold/DWUpholdMainnetConstants.m`:
- Around line 36-38: The Uphold OAuth client secret is hardcoded in
DWUpholdMainnetConstants.clientSecret and exposed in the app. Remove the
embedded secret and update DWUpholdAPIProvider’s code-exchange flow to use
PKCE/public-client authentication or delegate the exchange to a backend,
ensuring no client secret is shipped or used as the Basic Auth password.

In `@DashWallet/Sources/UI/Home/Tx` Metadata/SwapOrderMetadataProvider.swift:
- Around line 63-75: Update updateMetadata(from:) to diff the currently tracked
metadata keys against the keys derived from the latest orders, removing stale
entries from _availableMetadata and publishing metadataUpdated for each removed
key. Preserve the existing asynchronous add/update behavior for current orders,
and ensure stale-key removal and notifications use metadataQueue safely.

In `@DashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountViewModel.swift`:
- Around line 347-350: Update validationMessage(from:) to either rename its
unused error parameter to _ or use the Error value for debugging; preserve the
prior noRoutesFound-specific minimum-amount message behavior if retaining
error-based validation, while keeping the generic message for other errors.

In `@DashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swift`:
- Around line 165-166: Update submitOrder() to persist the buy order through an
injected SwapOrdersDAO using an async throws save operation, and await that
operation before returning the order. Propagate DAO write failures instead of
allowing them to be swallowed, while preserving the existing successful return
path only after persistence completes.

---

Nitpick comments:
In `@DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift`:
- Around line 18-20: Apply the repository’s configured SwiftLint/SwiftFormat
layout in SwapOrdersDAO: sort the Foundation, SQLite, and Combine imports
according to the configured rule, then correct vertical parameter alignment in
the insert call around the affected DAO method. Preserve all existing behavior
and values.

In `@DashWallet/Sources/Models/Swap/SwapKitErrorCopy.swift`:
- Around line 25-100: Reduce complexity in message(for:coin:) by moving fixed
localized error messages into a lookup table keyed by normalized error codes,
leaving only coin-dependent cases such as blacklistasset and
invalidsourceaddress in the switch. Preserve all existing mappings and the
generic fallback behavior.

In `@DashWallet/Sources/Models/Swap/SwapTrackingService.swift`:
- Line 65: Update the DSLogger diagnostics in SwapTrackingService, including the
logs at the referenced polling and lifecycle points, to prefix each message with
the consistent 🔍 emoji marker while preserving their existing log content.
- Around line 22-24: Resolve the SwiftLint violations in
SwapTrackingServiceObjcWrapper.start and pollOrder: place the required attribute
on its own line according to the configured SwiftFormat rules, then extract the
provider-status resolution logic from pollOrder into a focused helper so
pollOrder falls within the configured cyclomatic-complexity limit while
preserving existing behavior.
- Around line 39-56: Refactor SwapTrackingService to use injected protocols for
order storage, swap-status lookup, wallet lookup, and clock access instead of
constructing concrete collaborators or reading global wallet/time state
directly. Add protocol abstractions and initializer dependencies, update route
selection, API-error handling, and 24-hour expiry logic to use those
dependencies, while preserving the shared production instance through default
concrete implementations.

In `@DashWallet/Sources/UI/Home/Tx` Metadata/GiftCardMetadataProvider.swift:
- Around line 100-107: Remove the force unwraps in the metadata update branches
of the transaction metadata provider. In both affected branches, bind
txRowMetadata with if var existingMetadata, update its title and secondaryIcon,
then assign the modified value back to txRowMetadata; preserve the existing
creation path when metadata is absent.

In `@DashWallet/Sources/UI/Home/Tx` Metadata/SwapOrderMetadataProvider.swift:
- Around line 18-20: Reorder the imports in SwapOrderMetadataProvider.swift
according to the project’s configured SwiftLint import-ordering rule, without
changing the implementation.

In `@DashWallet/Sources/UI/Home/Views/Shortcuts/ShortcutsBarView.swift`:
- Around line 135-142: Extract the .secureWallet switch-case content from the
ViewBuilder into a dedicated helper function, and move the SNAPSHOT conditional
compilation block to the top level of that helper. Update the switch to call the
helper while preserving the existing accessibility identifier and
combined-children behavior under SNAPSHOT, and the unchanged content rendering
otherwise.

In `@DashWallet/Sources/UI/Swap/EnterAddress/EnterAddressViewModel.swift`:
- Around line 97-103: Extract the duplicated subscribeToNetworkStatus
implementation into a shared NetworkStatusSubscribing protocol with the required
networkStatus, cancellables, and isOnline properties, then provide the default
subscription implementation in its protocol extension. Update
EnterAddressViewModel and the other identified ViewModels to conform and remove
their local implementations while preserving existing behavior.

In `@DashWallet/Sources/UI/SwapKit/SwapKitPortalView.swift`:
- Line 25: Extract the duplicated network-status state and subscription logic
from SwapKitPortalView and MayaPortalView into a shared ViewModifier or
ObservableObject wrapper around NetworkStatusService. Update both portal views
to use the shared abstraction while preserving their existing isOnline
initialization and statusPublisher-driven updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb2c53ba-f654-49b9-9cdf-503afcd3f622

📥 Commits

Reviewing files that changed from the base of the PR and between 60c8690 and 939c4fd.

📒 Files selected for processing (57)
  • .gitignore
  • DashWallet.xcodeproj/project.pbxproj
  • DashWallet/AppDelegate.m
  • DashWallet/Sources/Infrastructure/Database/DatabaseConnection.swift
  • DashWallet/Sources/Infrastructure/Database/Migrations/AddSwapOrdersTable.swift
  • DashWallet/Sources/Infrastructure/NetworkStatusService.swift
  • DashWallet/Sources/Models/Maya/MayaConstants.swift
  • DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift
  • DashWallet/Sources/Models/Swap/SwapAddressValidator.swift
  • DashWallet/Sources/Models/Swap/SwapCryptoCurrency.swift
  • DashWallet/Sources/Models/Swap/SwapDepositURIBuilder.swift
  • DashWallet/Sources/Models/Swap/SwapKitErrorCopy.swift
  • DashWallet/Sources/Models/Swap/SwapOrder.swift
  • DashWallet/Sources/Models/Swap/SwapProvider.swift
  • DashWallet/Sources/Models/Swap/SwapTrackingService.swift
  • DashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swift
  • DashWallet/Sources/Models/Uphold/DWUpholdMainnetConstants.m
  • DashWallet/Sources/UI/Buy Sell/BuySellPortalView.swift
  • DashWallet/Sources/UI/Home/Tx Metadata/GiftCardMetadataProvider.swift
  • DashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swift
  • DashWallet/Sources/UI/Home/Views/HomeView.swift
  • DashWallet/Sources/UI/Home/Views/HomeViewModel.swift
  • DashWallet/Sources/UI/Home/Views/MetadataProvider.swift
  • DashWallet/Sources/UI/Home/Views/Shortcuts/ShortcutsBarView.swift
  • DashWallet/Sources/UI/Maya/MayaPortalView.swift
  • DashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountView.swift
  • DashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountViewModel.swift
  • DashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveHostingController.swift
  • DashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveView.swift
  • DashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveViewModel.swift
  • DashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressHostingController.swift
  • DashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressView.swift
  • DashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swift
  • DashWallet/Sources/UI/Swap/Convert/SwapConvertView.swift
  • DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift
  • DashWallet/Sources/UI/Swap/DEXOfflineToastModifier.swift
  • DashWallet/Sources/UI/Swap/EnterAddress/Components/AddressSourceView.swift
  • DashWallet/Sources/UI/Swap/EnterAddress/EnterAddressView.swift
  • DashWallet/Sources/UI/Swap/EnterAddress/EnterAddressViewModel.swift
  • DashWallet/Sources/UI/Swap/OrderPreview/Components/SwapFeeInfoSheet.swift
  • DashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewView.swift
  • DashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewViewModel.swift
  • DashWallet/Sources/UI/Swap/QRScanner/GenericQRScannerView.swift
  • DashWallet/Sources/UI/Swap/SelectCoin/SelectCoinView.swift
  • DashWallet/Sources/UI/Swap/SelectCoin/SelectCoinViewModel.swift
  • DashWallet/Sources/UI/Swap/SwapFlowCoordinator.swift
  • DashWallet/Sources/UI/Swap/SwapPortalScaffold.swift
  • DashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionFailureView.swift
  • DashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionPendingView.swift
  • DashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionStatusHostingController.swift
  • DashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionSuccessView.swift
  • DashWallet/Sources/UI/SwapKit/SwapKitPortalView.swift
  • DashWallet/Sources/UI/SwiftUI Components/Dialogs/ModalDialog.swift
  • DashWallet/Sources/UI/SwiftUI Components/Icon.swift
  • DashWallet/Sources/UI/SwiftUI Components/IconName+DashIconSource.swift
  • DashWalletScreenshotsUITests/BuyReceiveFlowUITests.swift
  • DashWalletTests/SwapKitQuoteDecodingTests.swift

Comment on lines 36 to 38
+ (NSString *)clientSecret {
return @"";
return @"da72feee8236f7709df6d0c235a8896ad45f2a91";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for usages of clientSecret to understand the OAuth flow
rg -nC5 'clientSecret' --type=objc --type=swift DashWallet/Sources/

# Check if PKCE is implemented
rg -n 'code_challenge|code_verifier|PKCE|pkce' --type=objc --type=swift DashWallet/Sources/

Repository: dashpay/dashwallet-ios

Length of output: 13467


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== DWUpholdMainnetConstants.m ==\n'
sed -n '1,120p' DashWallet/Sources/Models/Uphold/DWUpholdMainnetConstants.m

printf '\n== DWUpholdAPIProvider.m ==\n'
sed -n '1,180p' DashWallet/Sources/Models/Uphold/DWUpholdAPIProvider.m

printf '\n== PKCE / code_challenge search in Uphold sources ==\n'
rg -n 'code_challenge|code_verifier|PKCE|pkce' DashWallet/Sources/Models/Uphold

Repository: dashpay/dashwallet-ios

Length of output: 12511


Hardcoded Uphold OAuth client secret. DWUpholdAPIProvider sends this as the Basic Auth password during the code exchange, so it can be extracted from the app. Use PKCE/public-client auth or move the exchange behind a backend.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Uphold/DWUpholdMainnetConstants.m` around lines 36
- 38, The Uphold OAuth client secret is hardcoded in
DWUpholdMainnetConstants.clientSecret and exposed in the app. Remove the
embedded secret and update DWUpholdAPIProvider’s code-exchange flow to use
PKCE/public-client authentication or delegate the exchange to a backend,
ensuring no client secret is shipped or used as the Basic Auth password.

jeanpierreroma and others added 3 commits July 13, 2026 01:25
DWUpholdMainnetConstants.m was committed with real Uphold clientID/clientSecret
(populated locally by the Release build phase). Restore it to master's blanked
(@"") state; real values belong only in the out-of-repo DWUpholdMainnetConstants__Release.m.
The leaked secret must be rotated separately in the Uphold developer dashboard.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…transfer icons

- SwapTrackingService: route-aware status polling and expiry handling
- SwapBuyTransactionMatcher: precise buy DASH-arrival matching (amount+time+received)
- SwapOrderMetadataProvider: guard against mislabeling non-DEX receives as "Converted"
- CoinbaseMetadataProvider: Coinbase transfer tx icon via service tagging
- SwapOrdersDAO: actor-based serialization
- OrderPreview / Convert / Buy flow refinements

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Processing shows a text label only; completed shows nothing extra; failed
(refunded/failed/expired) shows the error corner badge. Drops the ellipsis
placeholder badge for pending states.
@romchornyi

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift (2)

300-330: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Three applyQuoteError branches set the identical message.

"not enough asset to pay for fees", "noRoutesFound", and the final else all assign the same localized string. Only invalidDestinationAddress needs its own branch; the rest can collapse into a single else.

♻️ Proposed simplification
     private func applyQuoteError(_ apiError: String) {
         latestQuote = nil
         receiveAmount = nil
-        if apiError.contains("not enough asset to pay for fees") {
-            errorMessage = NSLocalizedString(
-                "This amount can't be swapped right now. Routes can be briefly unavailable — try again shortly, or try a different amount.",
-                comment: "Dash DEX / dex_error_no_route"
-            )
-        } else if apiError.localizedCaseInsensitiveContains("noRoutesFound") {
-            errorMessage = NSLocalizedString(
-                "This amount can't be swapped right now. Routes can be briefly unavailable — try again shortly, or try a different amount.",
-                comment: "Dash DEX / dex_error_no_route"
-            )
-        } else if apiError.localizedCaseInsensitiveContains("invalidDestinationAddress") {
+        if apiError.localizedCaseInsensitiveContains("invalidDestinationAddress") {
             let chainLabel = SwapCryptoCurrency.chainDisplayName(coin.chain)
             errorMessage = String(
                 format: NSLocalizedString(
                     "The destination address isn’t valid for %@ (%@). Go back and enter a %@ address.",
                     comment: "Swap"
                 ),
                 coin.name,
                 chainLabel,
                 chainLabel
             )
         } else {
             errorMessage = NSLocalizedString(
                 "This amount can't be swapped right now. Routes can be briefly unavailable — try again shortly, or try a different amount.",
                 comment: "Dash DEX / dex_error_no_route"
             )
         }
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift` around lines
300 - 330, Update applyQuoteError so the fee-related and noRoutesFound checks no
longer have separate branches; retain only the invalidDestinationAddress branch
with its address-specific message, and move the shared no-route localized
message into the single fallback else.

265-271: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated "maximum transaction amount" error message. Both sites build the identical String(format: NSLocalizedString("The maximum transaction amount is %@", ...), maximumTransactionAmountText()); extract a shared helper (e.g. insufficientBalanceMessage()) so the two call sites can't drift.

  • DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift#L265-L271: replace the ternary's true-branch with a call to the new shared helper.
  • DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift#L392-L398: replace this errorMessage assignment with the same shared helper call.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift` around lines
265 - 271, Extract the duplicated maximum-transaction-amount formatting into a
shared helper in SwapConvertViewModel.swift, such as
insufficientBalanceMessage(). Update the ternary true branch at
DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift#L265-L271 and the
errorMessage assignment at
DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift#L392-L398 to call
the helper, preserving the existing localized text and amount formatting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DashWallet/Sources/Models/Coinbase/Coinbase.swift`:
- Line 345: Update the minimumTimestamp fallback in the transaction-fetching
flow to use a bounded historical lookback instead of the current time, ensuring
transactions received before the API response are not excluded by the timestamp
comparison near line 395. Preserve the parsed Coinbase timestamp when available
and use the existing time/date utilities or constants for the lookback.

In `@DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift`:
- Around line 62-78: Apply the configured SwiftFormat alignment to the multiline
SwapOrder.table.insert call in the SwapOrdersDAO persistence method, resolving
the vertical_parameter_alignment_on_call warnings while preserving the existing
insert arguments and behavior.
- Around line 137-145: Update observeAll and observeActive to trigger the DAO’s
hydration flow when observation begins, ensuring observer-only consumers receive
persisted orders without requiring CRUD or all() calls. Reuse the existing
hydration mechanism and preserve each publisher’s current output behavior.

In `@DashWallet/Sources/UI/Home/Tx` Metadata/CoinbaseMetadataProvider.swift:
- Around line 53-66: Update the .deleted and .deletedAll branches in
CoinbaseMetadataProvider so _availableMetadata is mutated synchronously through
metadataQueue before metadataUpdated.send publishes the affected hashes.
Preserve the existing weak-self capture where needed, and ensure observers
receive updates only after the deletion state has been committed.

In `@DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift`:
- Around line 703-722: Update maximumTransactionAmountText() so the .coin case
never displays a DASH-denominated fallback when amount.cryptoDashRate is
unavailable; instead return a coin-unit fallback or suppress the maximum value
until the rate is available, while preserving the existing converted coin amount
behavior when the rate is valid.

---

Nitpick comments:
In `@DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift`:
- Around line 300-330: Update applyQuoteError so the fee-related and
noRoutesFound checks no longer have separate branches; retain only the
invalidDestinationAddress branch with its address-specific message, and move the
shared no-route localized message into the single fallback else.
- Around line 265-271: Extract the duplicated maximum-transaction-amount
formatting into a shared helper in SwapConvertViewModel.swift, such as
insufficientBalanceMessage(). Update the ternary true branch at
DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift#L265-L271 and the
errorMessage assignment at
DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift#L392-L398 to call
the helper, preserving the existing localized text and amount formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 22773d48-f6a1-44d7-94a8-db2295a9e8ca

📥 Commits

Reviewing files that changed from the base of the PR and between 939c4fd and 194ea60.

📒 Files selected for processing (19)
  • DashWallet.xcodeproj/project.pbxproj
  • DashWallet/Sources/Models/Coinbase/Coinbase.swift
  • DashWallet/Sources/Models/Maya/MayaConstants.swift
  • DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift
  • DashWallet/Sources/Models/Swap/SwapBuyTransactionMatcher.swift
  • DashWallet/Sources/Models/Swap/SwapTrackingService.swift
  • DashWallet/Sources/UI/Coinbase/Base/UIViewController+Coinbase.swift
  • DashWallet/Sources/UI/Coinbase/Transfer Amount/TransferAmountViewController.swift
  • DashWallet/Sources/UI/Home/Tx Metadata/CoinbaseMetadataProvider.swift
  • DashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swift
  • DashWallet/Sources/UI/Home/Views/HomeView.swift
  • DashWallet/Sources/UI/Home/Views/HomeViewModel.swift
  • DashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountViewModel.swift
  • DashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveView.swift
  • DashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swift
  • DashWallet/Sources/UI/Swap/Convert/SwapConvertView.swift
  • DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift
  • DashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewView.swift
  • DashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewViewModel.swift
🚧 Files skipped from review as they are similar to previous changes (8)
  • DashWallet/Sources/UI/Home/Views/HomeViewModel.swift
  • DashWallet/Sources/Models/Swap/SwapTrackingService.swift
  • DashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountViewModel.swift
  • DashWallet/Sources/UI/Swap/Convert/SwapConvertView.swift
  • DashWallet/Sources/UI/Home/Views/HomeView.swift
  • DashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveView.swift
  • DashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swift
  • DashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewViewModel.swift

return
}

let minimumTimestamp = coinbaseTimestamp(from: transaction.createdAt) ?? Date().timeIntervalSince1970

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use a bounded lookback when Coinbase’s timestamp is unavailable.

Falling back to the current time can permanently miss a wallet transaction received before the API response completed, because Line 395 requires its timestamp to be newer.

Proposed fix
-        let minimumTimestamp = coinbaseTimestamp(from: transaction.createdAt) ?? Date().timeIntervalSince1970
+        let fallbackTimestamp = Date().timeIntervalSince1970 - 300
+        let minimumTimestamp = coinbaseTimestamp(from: transaction.createdAt) ?? fallbackTimestamp
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let minimumTimestamp = coinbaseTimestamp(from: transaction.createdAt) ?? Date().timeIntervalSince1970
let fallbackTimestamp = Date().timeIntervalSince1970 - 300
let minimumTimestamp = coinbaseTimestamp(from: transaction.createdAt) ?? fallbackTimestamp
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Coinbase/Coinbase.swift` at line 345, Update the
minimumTimestamp fallback in the transaction-fetching flow to use a bounded
historical lookback instead of the current time, ensuring transactions received
before the API response are not excluded by the timestamp comparison near line
395. Preserve the parsed Coinbase timestamp when available and use the existing
time/date utilities or constants for the lookback.

Comment on lines +62 to +78
let insert = SwapOrder.table.insert(or: .replace,
SwapOrder.colId <- dto.id,
SwapOrder.colDirection <- dto.direction,
SwapOrder.colService <- dto.service,
SwapOrder.colProvider <- dto.provider,
SwapOrder.colFromAsset <- dto.fromAsset,
SwapOrder.colToAsset <- dto.toAsset,
SwapOrder.colToAddress <- dto.toAddress,
SwapOrder.colDepositAddress <- dto.depositAddress,
SwapOrder.colExpectedToAmount <- dto.expectedToAmount,
SwapOrder.colActualToAmount <- dto.actualToAmount,
SwapOrder.colStatus <- dto.status.rawValue,
SwapOrder.colOutboundTxHash <- dto.outboundTxHash,
SwapOrder.colTimestamp <- dto.timestamp,
SwapOrder.colFinalisedAt <- dto.finalisedAt,
SwapOrder.colLastChecked <- dto.lastChecked
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Apply SwiftFormat to the multiline insert call.

Lines 63–77 trigger vertical_parameter_alignment_on_call warnings. As per coding guidelines, Swift files must use the configured SwiftFormat and SwiftLint rules.

🧰 Tools
🪛 SwiftLint (0.65.0)

[Warning] 63-63: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 64-64: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 65-65: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 66-66: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 67-67: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 68-68: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 69-69: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 70-70: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 71-71: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 72-72: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 73-73: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 74-74: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 75-75: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 76-76: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)


[Warning] 77-77: Function parameters should be aligned vertically if they're in multiple lines in a method call

(vertical_parameter_alignment_on_call)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swift` around lines 62 - 78,
Apply the configured SwiftFormat alignment to the multiline
SwapOrder.table.insert call in the SwapOrdersDAO persistence method, resolving
the vertical_parameter_alignment_on_call warnings while preserving the existing
insert arguments and behavior.

Sources: Coding guidelines, Linters/SAST tools

Comment on lines +53 to +66
case .deleted(let metadata):
metadataQueue.async { [weak self] in
self?._availableMetadata.removeValue(forKey: metadata.txHash)
}
metadataUpdated.send(metadata.txHash)

case .deletedAll:
let keys = metadataQueue.sync { self._availableMetadata.keys }
for key in keys {
metadataUpdated.send(key)
}
metadataQueue.async { [weak self] in
self?._availableMetadata = [:]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Commit deletion state before publishing the update.

The asynchronous mutation can run after metadataUpdated is consumed, so observers may read stale metadata. Clear the queue-protected state synchronously, then publish.

Proposed fix
                 case .deleted(let metadata):
-                    metadataQueue.async { [weak self] in
-                        self?._availableMetadata.removeValue(forKey: metadata.txHash)
+                    metadataQueue.sync {
+                        self._availableMetadata.removeValue(forKey: metadata.txHash)
                     }
                     metadataUpdated.send(metadata.txHash)

                 case .deletedAll:
-                    let keys = metadataQueue.sync { self._availableMetadata.keys }
+                    let keys = metadataQueue.sync {
+                        let keys = Array(self._availableMetadata.keys)
+                        self._availableMetadata.removeAll()
+                        return keys
+                    }
                     for key in keys {
                         metadataUpdated.send(key)
                     }
-                    metadataQueue.async { [weak self] in
-                        self?._availableMetadata = [:]
-                    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case .deleted(let metadata):
metadataQueue.async { [weak self] in
self?._availableMetadata.removeValue(forKey: metadata.txHash)
}
metadataUpdated.send(metadata.txHash)
case .deletedAll:
let keys = metadataQueue.sync { self._availableMetadata.keys }
for key in keys {
metadataUpdated.send(key)
}
metadataQueue.async { [weak self] in
self?._availableMetadata = [:]
}
case .deleted(let metadata):
metadataQueue.sync {
self._availableMetadata.removeValue(forKey: metadata.txHash)
}
metadataUpdated.send(metadata.txHash)
case .deletedAll:
let keys = metadataQueue.sync {
let keys = Array(self._availableMetadata.keys)
self._availableMetadata.removeAll()
return keys
}
for key in keys {
metadataUpdated.send(key)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DashWallet/Sources/UI/Home/Tx` Metadata/CoinbaseMetadataProvider.swift around
lines 53 - 66, Update the .deleted and .deletedAll branches in
CoinbaseMetadataProvider so _availableMetadata is mutated synchronously through
metadataQueue before metadataUpdated.send publishes the affected hashes.
Preserve the existing weak-self capture where needed, and ensure observers
receive updates only after the deletion state has been committed.

@romchornyi
romchornyi merged commit 667a653 into feat/dash-dex-submit-transaction Jul 16, 2026
1 check passed
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.

3 participants