Repository navigation
feat(wallet): restore Dash DEX on SwiftDashSDK (memo-less NEAR swaps) - #851
Conversation
DashDEX swaps previously built an OP_RETURN memo tx via frozen DashSync, which SwiftDashSDK cannot express. Restore the flow without OP_RETURN: - Force NEAR-intents routing on Sell quotes so the deposit is memo-less; hide MAYACHAIN-only coins in the picker and reject any residual memo. - Reduce SendCoinsService to a single memo-less deposit send via WalletSendService (returns the wire-order txid; drops DSTransaction and every OP_RETURN builder). - Re-plumb the IS-lock gate and OrderPreview observation off DS* notifications onto NSManagedObjectContextDidSave + SwiftDashSDKWalletSource state. - Read balance / receive address from SwiftDashSDK (frozen DashSync reads zero). Co-Authored-By: Claude Opus 4.8 <[email protected]>
The buy-flow matcher and swap-row metadata still read the frozen DashSync wallet, so incoming-DASH buys never matched and swap rows lost their labels. - SwapBuyTransactionMatcher now takes the app Transaction model; tracking and metadata read SwiftDashSDKWalletSource.fetchAll(). - SwapOrderMetadataProvider refreshes on SwiftDashSDKWalletState.balanceDidChange (the legacy DSWalletBalanceDidChange is frozen and never fires), so a buy that lands after its order is stored gets labelled "Converted". Co-Authored-By: Claude Opus 4.8 <[email protected]>
DashDEX was withheld for the migration; now that swaps run on SwiftDashSDK, lift the three gates that hid it, keeping it mainnet-only (real assets): - BuySellPortalView: hardcoded showsSwapKit=false becomes a controller-supplied flag (isMainnet && SwapKit configured). - ShortcutAction: offer Dash DEX as a customizable shortcut on mainnet. - HomeViewModel: a saved Dash DEX shortcut degrades to Spend only on testnet. Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Start SwapTrackingService at launch (the AppDelegate call was missing, so order statuses never advanced and completed swaps stayed "Pending"). - Normalize the "Multiple networks" coin label to NEAR for both directions, since every route now resolves to a single provider. - Add a "View NEAR/Maya Explorer" action to transaction details for swap legs, resolving the order (sell by id, buy by matcher) to build the provider URL. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@coderabbitai review |
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughDash DEX swaps now use memo-less NEAR-intents deposits, wire-order transaction IDs, SwiftDash SDK wallet state, updated transaction tracking, configuration-based visibility, and swap explorer actions. ChangesDash DEX swap flow
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant OrderPreviewViewModel
participant SendCoinsService
participant SwiftDashSDKWalletSource
participant SwapExplorer
User->>OrderPreviewViewModel: confirm swap
OrderPreviewViewModel->>SendCoinsService: send memo-less DASH deposit
SendCoinsService-->>OrderPreviewViewModel: return wire-order txid
OrderPreviewViewModel->>SwiftDashSDKWalletSource: observe transaction state
SwiftDashSDKWalletSource-->>OrderPreviewViewModel: transaction reaches .ok
User->>SwapExplorer: open resolved explorer link
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/SwapKit/SwapKitSwapProvider.swift`:
- Around line 934-939: Update walletSourceAddress() to fail explicitly when
SwiftDashSDKReceiveAddressReader.receiveAddress() returns nil instead of
returning an empty string. Propagate a clear wallet-unavailable error through
fetchQuote and the validateBuyOrder/createBuyOrder paths so
SwapKitSwapRequest.sourceAddress and destination are only populated with a real
address.
In `@DashWallet/Sources/UI/Home/Views/HomeViewModel.swift`:
- Around line 973-978: Update the saved-shortcut degradation logic around the
.dashDEX case to use the same availability gate as
ShortcutActionType.customizableActions and
ServiceDataProvider.shouldShow(.swapKit): treat Dash DEX as unavailable when
WalletEnvironment.isTestnet or SwapKitConstants.isConfigured is false, and fall
back to .spend while preserving the saved configuration.
🪄 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: e1d2425f-eefc-422b-b52b-b25c42d29b90
📒 Files selected for processing (18)
DashWallet/AppDelegate.mDashWallet/Sources/Models/Swap/SwapBuyTransactionMatcher.swiftDashWallet/Sources/Models/Swap/SwapExecutionData.swiftDashWallet/Sources/Models/Swap/SwapPendingGate.swiftDashWallet/Sources/Models/Swap/SwapTrackingService.swiftDashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swiftDashWallet/Sources/Models/Transactions/SendCoinsService.swiftDashWallet/Sources/UI/Buy Sell/BuySellPortalView.swiftDashWallet/Sources/UI/Buy Sell/BuySellPortalViewController.swiftDashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swiftDashWallet/Sources/UI/Home/Views/HomeViewModel.swiftDashWallet/Sources/UI/Home/Views/Shortcuts/Models/ShortcutAction.swiftDashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swiftDashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swiftDashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewViewModel.swiftDashWallet/Sources/UI/Swap/SelectCoin/SelectCoinViewModel.swiftDashWallet/Sources/UI/Tx/Details/Model/TxDetailModel.swiftDashWallet/Sources/UI/Tx/Details/TxDetailViewController.swift
…ortcut gate - walletSourceAddress() returns nil instead of "" when the SwiftDashSDK wallet isn't bound; fetchQuote and validateBuyOrder now surface a clear "wallet not ready" error instead of sending an empty source address into the swap request. - The saved Dash DEX shortcut degradation now mirrors the full availability gate (!isTestnet && SwapKitConstants.isConfigured), matching customizableActions and ServiceDataProvider.shouldShow so the entry points can't disagree. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Issue being fixed or feature implemented
Dash DEX (SwapKit swaps) was withheld for the SwiftDashSDK migration: its swap path built an OP_RETURN memo transaction through frozen DashSync, which SwiftDashSDK cannot express, and its balance/address/tx reads all went through the now-frozen DashSync wallet. This restores Dash DEX without OP_RETURN and moves the whole flow onto SwiftDashSDK.
What was done?
Restored the flow memo-less by dropping the routes that need OP_RETURN and running everything on the SDK:
SendCoinsServicereduced to one memo-less deposit send viaWalletSendService(returns the wire-order txid; all OP_RETURN /DSTransactionbuilders removed).DS*notifications ontoNSManagedObjectContextDidSave+SwiftDashSDKWalletSource. Balance / receive-address reads moved to SwiftDashSDK. BuySwapBuyTransactionMatchermigrated to the appTransactionmodel; tracking + metadata readSwiftDashSDKWalletSource.fetchAll(). Swap-row metadata refreshes onSwiftDashSDKWalletState.balanceDidChange(the legacyDSWalletBalanceDidChangeis frozen). Zero DashSync reads remain in the swap flow.!isTestnet && SwapKitConstants.isConfigured.SwapTrackingServiceat launch (the AppDelegate call was missing → statuses never advanced → completed swaps stuck at "Pending"); normalize the "Multiple networks" coin label to NEAR; add a "View NEAR/Maya Explorer" action to transaction details for swap legs; fail fast on an unavailable wallet source address instead of substituting"".How Has This Been Tested?
dashpaybuild on iOS Simulator (ARCHS=arm64), the working scheme for this branch.Breaking Changes
None. Dash DEX stays mainnet-only and off by default on testnet; no public API or on-chain format changes for existing transactions.
Checklist:
For repository code-owners and collaborators only