Repository navigation
feat(wallet): DashDEX ui and logic improvements - #797
Conversation
…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
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe 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. ChangesDash DEX swap lifecycle
Network and UI integration
Supporting changes
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (10)
DashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swift (1)
18-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSort 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 winRemove the guarded force unwraps.
Lines 102 and 131 violate the configured
force_unwrappingrule. Bind the existing metadata withif 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 winPrefix 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 winResolve the configured SwiftLint violations.
Line 24 needs the attribute on its own line, and
pollOrderexceeds the configured cyclomatic-complexity limit. Extract provider status resolution frompollOrder.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 liftInject 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 winApply 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 winReduce
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 winExtract
#if SNAPSHOTfrom the ViewBuilder switch body into a helper function.The
#if SNAPSHOT/#elseblock inside the.secureWalletswitch case is conditional compilation within a SwiftUI ViewBuilder body. As per coding guidelines, this should be avoided to prevent potentialbuildExpressionerrors. Extract the.secureWalletcase to a helper function so the#ifsits at the top level of a separate function instead of nested inside aswitchwithin 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 winConsider extracting the network status tracking pattern.
The
@State+.onReceive(NetworkStatusService.shared.statusPublisher)pattern is duplicated inMayaPortalView.swift(lines 27 and 41-43). A sharedViewModifieror a smallObservableObjectwrapper aroundNetworkStatusServicewould 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 winConsider extracting
subscribeToNetworkStatusinto 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
📒 Files selected for processing (57)
.gitignoreDashWallet.xcodeproj/project.pbxprojDashWallet/AppDelegate.mDashWallet/Sources/Infrastructure/Database/DatabaseConnection.swiftDashWallet/Sources/Infrastructure/Database/Migrations/AddSwapOrdersTable.swiftDashWallet/Sources/Infrastructure/NetworkStatusService.swiftDashWallet/Sources/Models/Maya/MayaConstants.swiftDashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swiftDashWallet/Sources/Models/Swap/SwapAddressValidator.swiftDashWallet/Sources/Models/Swap/SwapCryptoCurrency.swiftDashWallet/Sources/Models/Swap/SwapDepositURIBuilder.swiftDashWallet/Sources/Models/Swap/SwapKitErrorCopy.swiftDashWallet/Sources/Models/Swap/SwapOrder.swiftDashWallet/Sources/Models/Swap/SwapProvider.swiftDashWallet/Sources/Models/Swap/SwapTrackingService.swiftDashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swiftDashWallet/Sources/Models/Uphold/DWUpholdMainnetConstants.mDashWallet/Sources/UI/Buy Sell/BuySellPortalView.swiftDashWallet/Sources/UI/Home/Tx Metadata/GiftCardMetadataProvider.swiftDashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swiftDashWallet/Sources/UI/Home/Views/HomeView.swiftDashWallet/Sources/UI/Home/Views/HomeViewModel.swiftDashWallet/Sources/UI/Home/Views/MetadataProvider.swiftDashWallet/Sources/UI/Home/Views/Shortcuts/ShortcutsBarView.swiftDashWallet/Sources/UI/Maya/MayaPortalView.swiftDashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountView.swiftDashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountViewModel.swiftDashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveHostingController.swiftDashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveView.swiftDashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveViewModel.swiftDashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressHostingController.swiftDashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressView.swiftDashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swiftDashWallet/Sources/UI/Swap/Convert/SwapConvertView.swiftDashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swiftDashWallet/Sources/UI/Swap/DEXOfflineToastModifier.swiftDashWallet/Sources/UI/Swap/EnterAddress/Components/AddressSourceView.swiftDashWallet/Sources/UI/Swap/EnterAddress/EnterAddressView.swiftDashWallet/Sources/UI/Swap/EnterAddress/EnterAddressViewModel.swiftDashWallet/Sources/UI/Swap/OrderPreview/Components/SwapFeeInfoSheet.swiftDashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewView.swiftDashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewViewModel.swiftDashWallet/Sources/UI/Swap/QRScanner/GenericQRScannerView.swiftDashWallet/Sources/UI/Swap/SelectCoin/SelectCoinView.swiftDashWallet/Sources/UI/Swap/SelectCoin/SelectCoinViewModel.swiftDashWallet/Sources/UI/Swap/SwapFlowCoordinator.swiftDashWallet/Sources/UI/Swap/SwapPortalScaffold.swiftDashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionFailureView.swiftDashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionPendingView.swiftDashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionStatusHostingController.swiftDashWallet/Sources/UI/Swap/TransactionStatus/SwapTransactionSuccessView.swiftDashWallet/Sources/UI/SwapKit/SwapKitPortalView.swiftDashWallet/Sources/UI/SwiftUI Components/Dialogs/ModalDialog.swiftDashWallet/Sources/UI/SwiftUI Components/Icon.swiftDashWallet/Sources/UI/SwiftUI Components/IconName+DashIconSource.swiftDashWalletScreenshotsUITests/BuyReceiveFlowUITests.swiftDashWalletTests/SwapKitQuoteDecodingTests.swift
| + (NSString *)clientSecret { | ||
| return @""; | ||
| return @"da72feee8236f7709df6d0c235a8896ad45f2a91"; | ||
| } |
There was a problem hiding this comment.
🔒 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/UpholdRepository: 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.
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.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift (2)
300-330: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThree
applyQuoteErrorbranches set the identical message.
"not enough asset to pay for fees","noRoutesFound", and the finalelseall assign the same localized string. OnlyinvalidDestinationAddressneeds its own branch; the rest can collapse into a singleelse.♻️ 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 winDuplicated "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 thiserrorMessageassignment 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
📒 Files selected for processing (19)
DashWallet.xcodeproj/project.pbxprojDashWallet/Sources/Models/Coinbase/Coinbase.swiftDashWallet/Sources/Models/Maya/MayaConstants.swiftDashWallet/Sources/Models/Swap/DAO/SwapOrdersDAO.swiftDashWallet/Sources/Models/Swap/SwapBuyTransactionMatcher.swiftDashWallet/Sources/Models/Swap/SwapTrackingService.swiftDashWallet/Sources/UI/Coinbase/Base/UIViewController+Coinbase.swiftDashWallet/Sources/UI/Coinbase/Transfer Amount/TransferAmountViewController.swiftDashWallet/Sources/UI/Home/Tx Metadata/CoinbaseMetadataProvider.swiftDashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swiftDashWallet/Sources/UI/Home/Views/HomeView.swiftDashWallet/Sources/UI/Home/Views/HomeViewModel.swiftDashWallet/Sources/UI/Swap/Buy/EnterAmount/BuyEnterAmountViewModel.swiftDashWallet/Sources/UI/Swap/Buy/Receive/BuyReceiveView.swiftDashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swiftDashWallet/Sources/UI/Swap/Convert/SwapConvertView.swiftDashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swiftDashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewView.swiftDashWallet/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 |
There was a problem hiding this comment.
🎯 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.
| 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.
| 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 | ||
| ) |
There was a problem hiding this comment.
📐 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
| 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 = [:] | ||
| } |
There was a problem hiding this comment.
🎯 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.
| 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.
fix(ui): address review findings and improve UI contrast
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?
How Has This Been Tested?
Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Bug Fixes