Repository navigation
feat(wallet): dash dex entry point - #782
Conversation
…der routing Implement DashDEX feature entry-point with protocol-driven swap provider dispatch: - Add SwapDirection enum (buy/sell) for directional swap flows - Add RouteProvider protocol for swap provider selection logic - Implement SwapKit and Maya as SwapProvider conformers via protocol requirements - Update SwapBackend to dispatch based on protocol requirements, not extension fallbacks - Migrate Maya coin icons to dynamic loading with fallback UI support - Remove static Maya coin PNG assets (now loaded from API) - Add DashDEX entry icons and illustrations to asset catalog This ensures SwapKit overrides work correctly through proper protocol dispatch instead of being skipped by static method resolution.
Update Maya and Swap UI components with improved icon handling and display: - Refactor MayaCoinIconLoader for dynamic icon loading with fallback support - Update MayaCryptoCurrency icon mapping for efficient loading - Enhance SwapProvider protocol with better icon URL handling - Update SwapKitModels for improved asset representation - Optimize SwapKitSwapProvider icon URL construction - Improve SwapCoinIconView with better fallback UI - Update SelectCoinViewModel with enhanced icon loading logic - Refine SwapPortalScaffold UI layout - Update MayaPortalView for better icon display - Improve ShortcutAction with DashDEX shortcut icon - Add shortcut-dash-dex PNG assets to asset catalog - Update project configuration for asset changes
|
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:
📝 WalkthroughWalkthroughAdds direction-aware Dash DEX swap flow, including new routing and token metadata models, remote coin icon loading from SwapKit logo URLs, updated coin selection presentation, and portal/shortcut wiring for buy and sell actions. ChangesDash DEX swap flow
Sequence Diagram(s)sequenceDiagram
participant "HomeViewController+Shortcuts" as HomeShortcuts
participant "DSAuthenticationManager" as Auth
participant "SwapKitPortalViewController" as PortalVC
participant "SwapFlowCoordinator" as Flow
participant "SelectCoinHostingController" as Host
participant "SelectCoinViewModel" as Model
participant "SwapKitSwapProvider" as Provider
participant "SwapKitAPIService" as API
HomeShortcuts->>Auth: authenticate dashDEXAction()
Auth-->>HomeShortcuts: authenticated
HomeShortcuts->>PortalVC: present SwapKitPortalViewController
PortalVC->>Flow: start(direction)
Flow->>Host: create SelectCoinHostingController(direction)
Host->>Model: init(swapProvider, direction)
Model->>Provider: fetchPools(direction)
Provider->>API: tokens(provider)
API-->>Provider: token lists
Provider-->>Model: pools, labels, halted assets, logo URLs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 8
🧹 Nitpick comments (3)
DashWallet/Sources/UI/Swap/SwapFlowCoordinator.swift (1)
36-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMisleading log prefix for the SwapKit flow.
This coordinator is also driven by
SwapKitPortalViewController(provider =SwapBackend.swapKit.makeProvider()), so the hardcoded"Maya:"prefix will mislabel SwapKit selections. Consider a provider-agnostic prefix and an emoji marker for log filtering.♻️ Suggested tweak
- DSLogger.log("Maya: Selected coin \(coin.code) (\(coin.name)) direction=\(self.direction)") + DSLogger.log("🔍 Swap: Selected coin \(coin.code) (\(coin.name)) direction=\(self.direction)")As per coding guidelines: "Use emoji debug markers for easy log filtering: 🎯 🌐 💾 🎨 🔍 📍 🗺️".
🤖 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/SwapFlowCoordinator.swift` at line 36, The log message in SwapFlowCoordinator’s coin selection path is hardcoded with the “Maya:” prefix, which mislabels selections when the coordinator is used by SwapKit. Update the DSLogger.log call in the coin-selection flow to use a provider-agnostic message and add one of the approved emoji debug markers for filtering, keeping the rest of the selection details intact.Source: Coding guidelines
DashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swift (2)
372-396: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd DSLogger emoji prefixes.
These new
DSLoggermessages omit the repo’s required emoji markers for filtering. As per coding guidelines, “Use emoji logging prefixes (🔍 for search, 📍 for location, 🗺️ for map) with DSLogger for easier debugging and log filtering.”Proposed fix
- DSLogger.log("SwapKit: classification produced empty token lists — marking unusable") + DSLogger.log("🔍 SwapKit: classification produced empty token lists — marking unusable") @@ - DSLogger.log("SwapKit: classification built — mayaOnly=\(mayaOnlyAssets.count) nearOnly=\(nearOnlyAssets.count) both=\(bothAssets.count)") + DSLogger.log("🔍 SwapKit: classification built — mayaOnly=\(mayaOnlyAssets.count) nearOnly=\(nearOnlyAssets.count) both=\(bothAssets.count)") } catch { classificationUsable = false - DSLogger.log("SwapKit: classification fetch failed: \(error) — Buy will show error state") + DSLogger.log("🔍 SwapKit: classification fetch failed: \(error) — Buy will show error state") }🤖 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/SwapKit/SwapKitSwapProvider.swift` around lines 372 - 396, The new DSLogger messages in the SwapKit classification flow are missing the required emoji prefixes for log filtering. Update the logs in the classification path inside SwapKitSwapProvider’s token classification block, including the empty-list, successful build, and catch/error cases, to use the repo’s emoji markers (🔍, 📍, or 🗺️) consistently with the existing DSLogger conventions.Source: Coding guidelines
400-402: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winRestrict remote icon URLs to HTTP(S).
URL(string:)accepts non-image/non-network schemes; returning nil for non-HTTP(S) lets the UI fall back cleanly instead of passing unsupported token-list data downstream.Proposed fix
func logoURL(for mayaAsset: String) -> URL? { - guard let s = logoURIByIdentifier[mayaAsset.uppercased()], let url = URL(string: s) else { return nil } + guard let s = logoURIByIdentifier[mayaAsset.uppercased()], + let url = URL(string: s), + let scheme = url.scheme?.lowercased(), + ["http", "https"].contains(scheme) + else { return nil } return url }🤖 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/SwapKit/SwapKitSwapProvider.swift` around lines 400 - 402, Restrict remote icon URLs to HTTP(S) in logoURL(for mayaAsset:) by validating the parsed URL’s scheme before returning it. Keep the existing lookup in logoURIByIdentifier, but only return the URL when URL(string:) succeeds and the scheme is http or https; otherwise return nil so unsupported token-list values don’t propagate downstream.
🤖 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.xcodeproj/project.pbxproj`:
- Around line 559-560: The project file contains duplicate
PBXBuildFile/PBXFileReference entries for MayaSwapPendingGate.swift, causing the
same source to be added twice to the Sources phase and Transactions group. In
DashWallet.xcodeproj/project.pbxproj, keep only one reference set for
MayaSwapPendingGate.swift across the relevant target entries and remove the
extra PBXBuildFile/PBXFileReference lines so the file is compiled once per
target.
In
`@DashWallet/Resources/AppAssets.xcassets/Shortcuts/shortcut-bar-dash-dex.imageset/Contents.json`:
- Around line 2-7: The shortcut-bar Dash Dex imageset now references an SVG, but
its Contents.json is missing the required vector metadata. Update the imageset’s
Contents.json for shortcut-bar-dash-dex to include the info/properties block
with preserves-vector-representation and set template-rendering-intent to the
correct value for this asset, using either template or original based on how the
icon should render.
In `@DashWallet/Sources/Models/Maya/MayaCryptoCurrency.swift`:
- Line 36: The stored property in MayaCryptoCurrency is redundantly initialized
to nil, triggering SwiftLint’s implicit_optional_initialization warning. Update
the iconURL declaration to rely on Swift’s default optional initialization while
keeping the memberwise initializer behavior unchanged. Use the
MayaCryptoCurrency property definition as the location to make this cleanup.
In `@DashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swift`:
- Around line 371-375: The unusable classification path in SwapKitSwapProvider
is leaving stale cached state behind because it only flips classificationUsable
to false while classificationBuilt stays true, so later networkLabels and
haltedAssets reads can reuse outdated data. Update the empty-token and any other
unusable refresh branches to also clear/reset the built classification state and
any derived cached labels/asset lists before returning, using the existing
classificationUsable, classificationBuilt, networkLabels, and haltedAssets flow
as the touchpoints.
- Around line 123-142: The Buy-asset filtering in filteredPools(_:for:) is
currently failing open because it only removes known mayaOnlyAssets, letting
unclassified assets through. Update the SwapKitSwapProvider logic so Buy results
include only assets explicitly classified as nearOnly or both, using the
existing classification data built by buildClassification() and gated by
classificationUsable. Keep the error path in filteredPools(_:for:) unchanged,
but replace the final pools.filter check with a whitelist based on the asset
classification maps/sets rather than a blacklist.
In `@DashWallet/Sources/UI/Swap/SelectCoin/Components/SwapCoinIconView.swift`:
- Around line 51-54: The loading task in SwapCoinIconView should be keyed by the
actual image source instead of coin.mayaAsset, since a changed iconURL for the
same asset must cancel and reload the task. Update the .task identifier in the
SwapCoinIconView body so it tracks coin.iconURL, and keep the existing
reset/load/withAnimation flow in the task closure.
In `@DashWallet/Sources/UI/Swap/SelectCoin/SelectCoinViewModel.swift`:
- Around line 88-90: In SelectCoinViewModel’s pool-loading flow,
fetchPools(direction:) and fetchInboundAddresses() are currently started
together, which can let fetchInboundAddresses() read
SwapKitSwapProvider.cachedPools before it is populated and return an empty list.
Update the async flow so fetchPools(direction:) completes first, then call
fetchInboundAddresses(), and keep the later inboundChains filtering aligned with
the now-populated pools.
In `@DashWallet/Sources/UI/SwapKit/SwapKitPortalView.swift`:
- Line 27: The SwapKitPortalView logo is pointing to a non-existent asset name,
so update the logoIcon configuration to use the existing dash-dex-illustration
asset instead of the current custom("illustration-dash-dex", bundle: .dashUIKit)
reference. Keep the fix local to SwapKitPortalView so the image resolves to the
asset already present in the app resources.
---
Nitpick comments:
In `@DashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swift`:
- Around line 372-396: The new DSLogger messages in the SwapKit classification
flow are missing the required emoji prefixes for log filtering. Update the logs
in the classification path inside SwapKitSwapProvider’s token classification
block, including the empty-list, successful build, and catch/error cases, to use
the repo’s emoji markers (🔍, 📍, or 🗺️) consistently with the existing
DSLogger conventions.
- Around line 400-402: Restrict remote icon URLs to HTTP(S) in logoURL(for
mayaAsset:) by validating the parsed URL’s scheme before returning it. Keep the
existing lookup in logoURIByIdentifier, but only return the URL when
URL(string:) succeeds and the scheme is http or https; otherwise return nil so
unsupported token-list values don’t propagate downstream.
In `@DashWallet/Sources/UI/Swap/SwapFlowCoordinator.swift`:
- Line 36: The log message in SwapFlowCoordinator’s coin selection path is
hardcoded with the “Maya:” prefix, which mislabels selections when the
coordinator is used by SwapKit. Update the DSLogger.log call in the
coin-selection flow to use a provider-agnostic message and add one of the
approved emoji debug markers for filtering, keeping the rest of the selection
details intact.
🪄 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: 9860bf94-9329-4ee6-a707-6f1c3271cdb9
⛔ Files ignored due to path filters (22)
DashWallet/Resources/AppAssets.xcassets/Shortcuts/shortcut-bar-dash-dex.imageset/shortcut-bar-dash-dex.svgis excluded by!**/*.svgDashWallet/Resources/AppAssets.xcassets/Shortcuts/shortcut-dash-dex.imageset/shortcut-dash-dex.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/Shortcuts/shortcut-dash-dex.imageset/[email protected]is excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/Shortcuts/shortcut-dash-dex.imageset/[email protected]is excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/dash-dex-buy.imageset/dash-dex-buy.svgis excluded by!**/*.svgDashWallet/Resources/AppAssets.xcassets/dash-dex-illustration.imageset/dash-dex-illustration.svgis excluded by!**/*.svgDashWallet/Resources/AppAssets.xcassets/dash-dex-sell.imageset/dash-dex-sell.svgis excluded by!**/*.svgDashWallet/Resources/AppAssets.xcassets/maya.coin.arb.imageset/maya.coin.arb.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.btc.imageset/maya.coin.btc.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.dai.imageset/maya.coin.dai.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.eth.imageset/maya.coin.eth.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.gld.imageset/maya.coin.gld.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.kuji.imageset/maya.coin.kuji.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.leo.imageset/maya.coin.leo.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.link.imageset/maya.coin.link.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.pepe.imageset/maya.coin.pepe.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.rune.imageset/maya.coin.rune.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.tgt.imageset/maya.coin.tgt.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.usdc.imageset/maya.coin.usdc.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.usdt.imageset/maya.coin.usdt.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.wbtc.imageset/maya.coin.wbtc.pngis excluded by!**/*.pngDashWallet/Resources/AppAssets.xcassets/maya.coin.wsteth.imageset/maya.coin.wsteth.pngis excluded by!**/*.png
📒 Files selected for processing (39)
DashWallet.xcodeproj/project.pbxprojDashWallet/Resources/AppAssets.xcassets/Shortcuts/shortcut-bar-dash-dex.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/Shortcuts/shortcut-dash-dex.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/dash-dex-buy.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/dash-dex-illustration.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/dash-dex-sell.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.gld.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.kuji.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.leo.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.link.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.pepe.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.rune.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.tgt.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.usdc.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.usdt.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.wbtc.imageset/Contents.jsonDashWallet/Resources/AppAssets.xcassets/maya.coin.wsteth.imageset/Contents.jsonDashWallet/Sources/Models/Maya/MayaCoinIconLoader.swiftDashWallet/Sources/Models/Maya/MayaCryptoCurrency.swiftDashWallet/Sources/Models/Swap/RouteProvider.swiftDashWallet/Sources/Models/Swap/SwapBackend.swiftDashWallet/Sources/Models/Swap/SwapDirection.swiftDashWallet/Sources/Models/Swap/SwapProvider.swiftDashWallet/Sources/Models/SwapKit/SwapKitAPIService.swiftDashWallet/Sources/Models/SwapKit/SwapKitConstants.swiftDashWallet/Sources/Models/SwapKit/SwapKitEndpoint.swiftDashWallet/Sources/Models/SwapKit/SwapKitModels.swiftDashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swiftDashWallet/Sources/UI/Home/HomeViewController+Shortcuts.swiftDashWallet/Sources/UI/Home/Views/Shortcuts/Models/ShortcutAction.swiftDashWallet/Sources/UI/Maya/MayaPortalView.swiftDashWallet/Sources/UI/Swap/SelectCoin/Components/SwapCoinIconView.swiftDashWallet/Sources/UI/Swap/SelectCoin/SelectCoinHostingController.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/SwapKit/SwapKitPortalView.swiftDashWallet/Sources/UI/SwapKit/SwapKitPortalViewController.swift
💤 Files with no reviewable changes (11)
- DashWallet/Resources/AppAssets.xcassets/maya.coin.usdc.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.gld.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.wsteth.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.wbtc.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.tgt.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.leo.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.link.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.kuji.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.usdt.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.pepe.imageset/Contents.json
- DashWallet/Resources/AppAssets.xcassets/maya.coin.rune.imageset/Contents.json
| /// remote loading in that case. | ||
| let iconAssetName: String | ||
| /// Remote icon URL string sourced from SwapKit `logoURI`. Nil when not yet loaded or unavailable. | ||
| var iconURL: String? = nil |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Let Swift initialize the optional to nil.
SwiftLint flags this as implicit_optional_initialization; dropping = nil preserves the same memberwise-init behavior.
Proposed fix
- var iconURL: String? = nil
+ var iconURL: String?As per coding guidelines, **/*.swift: Use SwiftFormat and SwiftLint for Swift code formatting and linting as configured in .swiftformat and .swiftlint.yml files.
📝 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.
| var iconURL: String? = nil | |
| var iconURL: String? |
🧰 Tools
🪛 SwiftLint (0.64.0)
[Warning] 36-36: Optional should be implicitly initialized without nil
(implicit_optional_initialization)
🤖 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/Maya/MayaCryptoCurrency.swift` at line 36, The
stored property in MayaCryptoCurrency is redundantly initialized to nil,
triggering SwiftLint’s implicit_optional_initialization warning. Update the
iconURL declaration to rely on Swift’s default optional initialization while
keeping the memberwise initializer behavior unchanged. Use the
MayaCryptoCurrency property definition as the location to make this cleanup.
Sources: Coding guidelines, Linters/SAST tools
| .task(id: coin.mayaAsset) { | ||
| remoteImage = nil | ||
| guard needsRemoteIcon else { return } | ||
|
|
||
| var loaded = await MayaCoinIconLoader.shared.loadSwapKitIcon(for: coin.mayaAsset) | ||
| if loaded == nil { | ||
| loaded = await MayaCoinIconLoader.shared.loadJsupaIcon(for: coin.code) | ||
| } | ||
| withAnimation(.easeIn(duration: 0.15)) { | ||
| remoteImage = loaded | ||
| } | ||
| let loaded = await MayaCoinIconLoader.shared.loadIcon(logoURI: coin.iconURL, ticker: coin.code) | ||
| withAnimation(.easeIn(duration: 0.15)) { remoteImage = loaded } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Key the loading task by the URL it actually loads.
Line 51 still uses coin.mayaAsset, so a changed iconURL for the same asset will not cancel/reload and can leave a stale icon.
Proposed fix
- .task(id: coin.mayaAsset) {
+ .task(id: coin.iconURL) {📝 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.
| .task(id: coin.mayaAsset) { | |
| remoteImage = nil | |
| guard needsRemoteIcon else { return } | |
| var loaded = await MayaCoinIconLoader.shared.loadSwapKitIcon(for: coin.mayaAsset) | |
| if loaded == nil { | |
| loaded = await MayaCoinIconLoader.shared.loadJsupaIcon(for: coin.code) | |
| } | |
| withAnimation(.easeIn(duration: 0.15)) { | |
| remoteImage = loaded | |
| } | |
| let loaded = await MayaCoinIconLoader.shared.loadIcon(logoURI: coin.iconURL, ticker: coin.code) | |
| withAnimation(.easeIn(duration: 0.15)) { remoteImage = loaded } | |
| .task(id: coin.iconURL) { | |
| remoteImage = nil | |
| let loaded = await MayaCoinIconLoader.shared.loadIcon(logoURI: coin.iconURL, ticker: coin.code) | |
| withAnimation(.easeIn(duration: 0.15)) { remoteImage = loaded } |
🤖 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/SelectCoin/Components/SwapCoinIconView.swift`
around lines 51 - 54, The loading task in SwapCoinIconView should be keyed by
the actual image source instead of coin.mayaAsset, since a changed iconURL for
the same asset must cancel and reload the task. Update the .task identifier in
the SwapCoinIconView body so it tracks coin.iconURL, and keep the existing
reset/load/withAnimation flow in the task closure.
| async let poolsRequest = swapProvider.fetchPools(direction: direction) | ||
| async let inboundRequest = swapProvider.fetchInboundAddresses() | ||
| let (pools, inboundAddresses) = try await (poolsRequest, inboundRequest) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Fetch pools before inbound addresses to avoid empty-list races.
fetchInboundAddresses() depends on SwapKitSwapProvider.cachedPools; running it concurrently with fetchPools(direction:) can hit the empty-cache fallback and return [], after which Line 131 filters out every pool via inboundChains.
Proposed fix
- async let poolsRequest = swapProvider.fetchPools(direction: direction)
- async let inboundRequest = swapProvider.fetchInboundAddresses()
- let (pools, inboundAddresses) = try await (poolsRequest, inboundRequest)
+ let pools = try await swapProvider.fetchPools(direction: direction)
+ let inboundAddresses = try await swapProvider.fetchInboundAddresses()📝 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.
| async let poolsRequest = swapProvider.fetchPools(direction: direction) | |
| async let inboundRequest = swapProvider.fetchInboundAddresses() | |
| let (pools, inboundAddresses) = try await (poolsRequest, inboundRequest) | |
| let pools = try await swapProvider.fetchPools(direction: direction) | |
| let inboundAddresses = try await swapProvider.fetchInboundAddresses() |
🤖 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/SelectCoin/SelectCoinViewModel.swift` around lines
88 - 90, In SelectCoinViewModel’s pool-loading flow, fetchPools(direction:) and
fetchInboundAddresses() are currently started together, which can let
fetchInboundAddresses() read SwapKitSwapProvider.cachedPools before it is
populated and return an empty list. Update the async flow so
fetchPools(direction:) completes first, then call fetchInboundAddresses(), and
keep the later inboundChains filtering aligned with the now-populated pools.
… integration Improve swap UI components and Maya provider icon loading: - Enhance MayaCryptoCurrency icon mapping with better fallback support - Optimize SwapKitSwapProvider icon URL handling - Improve SwapCoinIconView with better image loading and fallback UI - Update SelectCoinViewModel with enhanced icon loading logic - Refine SwapKitPortalView icon display - Update project configuration This improves the user experience when displaying swap provider icons and coin assets.
feat(wallet): dash dex entry point
Issue being fixed or feature implemented
Implement DashDEX entry-point with protocol-driven swap provider dispatch to enable proper routing between SwapKit and Maya providers. This ensures correct provider selection at runtime through proper protocol requirements instead of static method dispatch fallbacks.
What was done?
SwapDirectionenum (buy/sell) for directional swap flowsRouteProviderprotocol for swap provider selection logicSwapProviderconformers via protocol requirementsSwapBackendto dispatch based on protocol requirements instead of extension-only methodsHow Has This Been Tested?
Ran
xcodebuildfor thedashwalletscheme to verify build integrityNo new Swift compile errors in the DashDEX entry-point and swap provider flow
Verified swap provider selection works correctly between SwapKit and Maya
Confirmed icon loading with fallbacks for missing Maya coin assets
Full build still hits existing repository SwiftLint and TodayExtension linker issues outside this change
Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Bug Fixes