Skip to content

feat(wallet): restore Dash DEX on SwiftDashSDK (memo-less NEAR swaps) - #851

Merged
romchornyi merged 5 commits into
swift-sdk-integrationfrom
feat/dashdex-integration
Jul 22, 2026
Merged

romchornyi merged 5 commits into
swift-sdk-integrationfrom
feat/dashdex-integration

Conversation

@romchornyi

@romchornyi romchornyi commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Memo-less SDK send. Force NEAR-intents routing on Sell quotes so the DASH deposit is a plain, memo-less send; hide MAYACHAIN-only coins in the picker and reject any residual memo-bearing quote as a fund-loss safety net. SendCoinsService reduced to one memo-less deposit send via WalletSendService (returns the wire-order txid; all OP_RETURN / DSTransaction builders removed).
  • Off DashSync. IS-lock gate + OrderPreview observation re-plumbed from DS* notifications onto NSManagedObjectContextDidSave + SwiftDashSDKWalletSource. Balance / receive-address reads moved to SwiftDashSDK. Buy SwapBuyTransactionMatcher migrated to the app Transaction model; tracking + metadata read SwiftDashSDKWalletSource.fetchAll(). Swap-row metadata refreshes on SwiftDashSDKWalletState.balanceDidChange (the legacy DSWalletBalanceDidChange is frozen). Zero DashSync reads remain in the swap flow.
  • Entry points. Lifted the three withhold gates (Buy & Sell card, customizable shortcut, saved-shortcut degrade), keeping Dash DEX mainnet-only (real assets) and consistently gated on !isTestnet && SwapKitConstants.isConfigured.
  • Fixes. Start SwapTrackingService at 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?

  • Clean dashpay build on iOS Simulator (ARCHS=arm64), the working scheme for this branch.
  • On-device manual testing on mainnet: Buy (crypto→DASH) and Sell (DASH→crypto) swaps end-to-end; verified the "Converted · A/B" history rows, status advancing off "Pending", and the NEAR explorer link in transaction details.
  • The unit-test target is currently broken on this branch (pre-existing), so no new automated tests were added.

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:

  • 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

jeanpierreroma and others added 4 commits July 21, 2026 11:35
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]>
@romchornyi romchornyi changed the title feat(dashdex): restore Dash DEX on SwiftDashSDK (memo-less NEAR swaps) feat(wallet): restore Dash DEX on SwiftDashSDK (memo-less NEAR swaps) Jul 21, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 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 commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Dash 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.

Changes

Dash DEX swap flow

Layer / File(s) Summary
NEAR routing and wallet contracts
DashWallet/Sources/Models/Swap/..., DashWallet/Sources/Models/SwapKit/..., DashWallet/Sources/UI/Swap/...
Quotes are constrained to NEAR routes, memo-bearing responses are rejected, deposit addresses and balances use SwiftDash SDK sources, and network labels normalize to NEAR.
Memo-less deposit submission and lock tracking
DashWallet/Sources/Models/Swap/SwapPendingGate.swift, DashWallet/Sources/Models/Transactions/SendCoinsService.swift, DashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewViewModel.swift
Swap deposits use plain sends, return wire-order transaction IDs, persist swap state, and wait for SwiftDash SDK transaction state .ok.
SDK transaction matching and metadata refresh
DashWallet/AppDelegate.m, DashWallet/Sources/Models/Swap/..., DashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swift
Swap tracking and buy-order matching use SwiftDash SDK transactions and balance-change notifications.
Swap visibility and wallet UI availability
DashWallet/Sources/UI/Buy Sell/..., DashWallet/Sources/UI/Home/..., DashWallet/Sources/UI/Swap/...
Dash DEX visibility and shortcuts are gated by network and configuration, while displayed and validated balances use SDK max-sendable values.
Swap explorer transaction actions
DashWallet/Sources/UI/Tx/Details/...
Transaction details resolve Maya or NEAR explorer links and present them as selectable Safari actions.

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
Loading

Possibly related PRs

Suggested reviewers: jeanpierreroma, hashengineering

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: restoring Dash DEX on SwiftDashSDK with memo-less NEAR-based swaps.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dashdex-integration

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.

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d786d4 and 517a6a9.

📒 Files selected for processing (18)
  • DashWallet/AppDelegate.m
  • DashWallet/Sources/Models/Swap/SwapBuyTransactionMatcher.swift
  • DashWallet/Sources/Models/Swap/SwapExecutionData.swift
  • DashWallet/Sources/Models/Swap/SwapPendingGate.swift
  • DashWallet/Sources/Models/Swap/SwapTrackingService.swift
  • DashWallet/Sources/Models/SwapKit/SwapKitSwapProvider.swift
  • DashWallet/Sources/Models/Transactions/SendCoinsService.swift
  • DashWallet/Sources/UI/Buy Sell/BuySellPortalView.swift
  • DashWallet/Sources/UI/Buy Sell/BuySellPortalViewController.swift
  • DashWallet/Sources/UI/Home/Tx Metadata/SwapOrderMetadataProvider.swift
  • DashWallet/Sources/UI/Home/Views/HomeViewModel.swift
  • DashWallet/Sources/UI/Home/Views/Shortcuts/Models/ShortcutAction.swift
  • DashWallet/Sources/UI/Swap/Buy/RefundAddress/RefundAddressViewModel.swift
  • DashWallet/Sources/UI/Swap/Convert/SwapConvertViewModel.swift
  • DashWallet/Sources/UI/Swap/OrderPreview/OrderPreviewViewModel.swift
  • DashWallet/Sources/UI/Swap/SelectCoin/SelectCoinViewModel.swift
  • DashWallet/Sources/UI/Tx/Details/Model/TxDetailModel.swift
  • DashWallet/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]>
@romchornyi

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 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.

@romchornyi

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 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.

@romchornyi

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 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.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good

@romchornyi
romchornyi merged commit 27c3f30 into swift-sdk-integration Jul 22, 2026
4 checks passed

@Awesome195 Awesome195 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.

Apple TV

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.

4 participants