Skip to content

feat(dashpay): resolve the DashConnect contract per network - #1133

Closed
romchornyi wants to merge 2 commits into
developfrom
feat/dashconnect-network-contracts
Closed

romchornyi wants to merge 2 commits into
developfrom
feat/dashconnect-network-contracts

Conversation

@romchornyi

@romchornyi romchornyi commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

DashConnect's availability was decided by whether the app is on a test network. What it actually needs is the key-exchange data contract. Logging in to an app publishes a loginKeyResponse document to that contract, and a contract id only exists on the chain it was registered on.

The test-network check was spread across five places: isTestNetwork, two testnet/devnet asserts, and a runtime-network mapping that treated every non-devnet network as testnet. Enabling mainnet would have meant editing all five, and the mapping would have expected a testnet runtime for a mainnet data source.

This stays a draft, and the reason is external to the code. The key-exchange contract is not deployed on mainnet, so this PR deliberately leaves DashConnect unavailable there. A contract id is per-network — it is derived from the owner identity and its nonce at registration — so there is no id to look up until someone registers the contract on mainnet; the deployment is being coordinated with the Yappr developer. Once an id exists, pinning it in one constant makes the feature available, subject to product and security sign-off and parity with Android. Android gates DashConnect off in production today (SUPPORTS_CONNECT = !IS_PROD_BUILD).

#1106, which this was previously stacked on, has merged; this branch now carries develop and targets it directly.

What was done?

  • DashConnectNetworkConfiguration is the single per-network source of truth:
    • the loginKeyResponse contract id: testnet pinned; devnet from Devnet Settings, with the existing devnetLoginContractNotConfigured error while it is unset; mainnet nil with TODO(dashconnect-mainnet), which throws loginContractUnavailable and never guesses an id;
    • isAvailable(on:): whether the network has a key-exchange contract;
    • runtimeNetwork(for:), currentNetwork();
    • per-network app branding: knownApps is keyed by network, and only the testnet Yappr contract is listed.
  • The gates now read that configuration: ConnectionsViewModel.featureUnavailable and its data-source assert, the PlatformDashConnectDataSource initializer assert and default network, loginKeyExchangeContractId(), and the runtime-network check in requireContext. ConnectionRequest(loginRequest:) and the platform metadata fallback resolve branding for the request's own network.
  • Behaviour today is unchanged: available on testnet and devnet, unavailable on mainnet with the existing copy.
  • Per-network connection storage (including devnet naming) came from feat(wallet): make devnet a selectable network #1106 and is now in develop. This PR does not touch DashConnectStore, and after merging develop the devnet id still resolves through DevnetConfiguration.dashConnectContractId, which loginKeyExchangeContractId(for:devnetContractId:) takes as its default.

How Has This Been Tested?

  • develop is merged in (684f9305f, which carries feat(wallet): make devnet a selectable network #1106) with no conflicts. The dashpay test target builds on the first attempt, and every DashConnect class passes on the simulator in Debug — 111 tests, 0 failures: DashConnectDataSourceTests, DashConnectStoreTests, DashConnectUriTests, KeyExchangeCryptoTests, LoginKeyDerivationTests, PlatformDashConnectDataSourceTests, Secp256k1Tests.

  • A clean merge can still hide a semantic clash, so the contract-id path was re-read after merging rather than assumed: every lookup in PlatformDashConnectDataSource still routes through DashConnectNetworkConfiguration.loginKeyExchangeContractId(for:), and the devnet id still comes from DevnetConfiguration.dashConnectContractId, which that method takes as its default argument.

  • New tests in PlatformDashConnectDataSourceTests:

    • testnet resolves the pinned id;
    • devnet resolves a configured id, and reports not configured for a missing or invalid id;
    • mainnet has no id and is unavailable;
    • availability follows the contract;
    • runtime network mapping;
    • branding does not leak across networks;
    • a mainnet login QR is rejected by a testnet data source.
  • scripts/a11y_audit.py --check: no new findings.

  • Not tested on a device. Behaviour on testnet and devnet is unchanged by construction.

Breaking Changes

None.

Checklist:

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

**DashConnect's availability was a test-network check, but what it needs is a
contract.** Logging in to an app publishes a `loginKeyResponse` document to the
key-exchange data contract, and a contract id only exists on the chain it was
registered on. The gates asked `isTestNetwork` instead, asserted testnet or
devnet, and mapped every non-devnet network to a testnet runtime — so mainnet
could only ever be switched on by editing five places at once, and the mapping
would have silently expected a testnet runtime for a mainnet data source.

`DashConnectNetworkConfiguration` is now the one place that answers it: testnet
has the pinned key-exchange contract, a devnet takes its id from Devnet
Settings and reports a normal error while it is unset, and mainnet has no id —
the contract is not deployed there yet — so DashConnect stays unavailable on
mainnet exactly as before. Availability, the data source's contract id, and the
runtime network it expects all come from that configuration. Pinning the
mainnet id there is what will make the feature available.

**App branding is per network.** The fallback name for a known app was keyed by
its contract id alone; an app's id differs on every chain, so the table is now
keyed by network, and a testnet id no longer brands a request on another
network.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@thepastaclaw

thepastaclaw commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 5cbfedc. Normal review starts when eligible; priority review starts as soon as a slot is available.

Base automatically changed from feat/devnet-support to develop September 16, 2026 09:15
@romchornyi

Copy link
Copy Markdown
Contributor Author

Closing: superseded by #1202. Since protocol 14 the key-exchange documents go to the App Connect system contract (platform#4869), whose id is the same on every network, so there is no per-network contract id left to resolve. Whether DashConnect is offered on mainnet stays a product decision, gated in one place in #1202 (ConnectionsViewModel).

@romchornyi romchornyi closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants