Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions DashWallet/Sources/Models/DashConnect/AppConnectLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ enum AppConnect {
case .unresolved, .refused: return false
}
}

/// Whether approving finishes the sign-in on the wallet's side. The
/// two-QR login still needs the app's key-registration code scanned.
var signsInAtApproval: Bool {
switch self {
case .oneQR, .appConnect: return true
case .twoQR, .unresolved, .refused: return false
}
}
}

/// The login a network at `protocolVersion` gets.
Expand Down
11 changes: 10 additions & 1 deletion DashWallet/Sources/Models/DashConnect/DashConnectDeepLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ final class DashConnectDeepLink: NSObject {
/// `absoluteString` returns what the app emitted.
@objc(uriFromURL:)
static func uri(from url: URL) -> String? {
let candidate = url.absoluteString.trimmingCharacters(in: .whitespacesAndNewlines)
uri(from: url.absoluteString)
}

/// The DashConnect URI `string` holds, or `nil` when it is not one.
///
/// For a carrier that hands over text rather than a `URL`: the Home
/// scanner reads the same payload off a QR code.
@objc(uriFromString:)
static func uri(from string: String) -> String? {
let candidate = string.trimmingCharacters(in: .whitespacesAndNewlines)

guard DashConnectUri.isKeyUri(candidate) || DashConnectUri.isStUri(candidate) else {
return nil
Expand Down
12 changes: 12 additions & 0 deletions DashWallet/Sources/UI/DashConnect/ConnectionsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ final class ConnectionsViewModel: ObservableObject {
self.pendingRequest = nil
self.pendingLoginRequest = nil
self.approveError = nil
// A link goes back through its callback; a scanned code's app
// is on another screen, so the user is told to go back to it.
if consent.login.signsInAtApproval, !pendingRequestArrivedByLink {
message = ConnectionsScreenMessage(
kind: .success,
text: String(
format: NSLocalizedString(
"Connected to %@. Go back to your browser to continue.",
comment: "DashConnect: a sign-in finished at approval; the placeholder is the app's name"),
consent.appLabel)
Comment on lines +242 to +249

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Cover the scan-only success message with approval regression tests

The new success message depends on both the approved login kind and whether the request arrived by scan or link, but no test asserts this behavior. The callback tests only inspect opened URLs, and testOnlyTheOneQrLoginSignsInAtApproval covers oneQR, twoQR, and unresolved while omitting appConnect and refused. Extend the existing LoginApprovalSpy-based tests to verify that successful scanned oneQR and appConnect approvals publish a success message containing the app label, linked and twoQR approvals do not publish that message, and failed approvals do not report success. Complete the classification assertions for appConnect and refused as well. This protects the PR's new user-visible behavior without introducing new test infrastructure.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

)
}
} catch DashConnectPlatformError.approvalOutOfDate {
// Another identity, wallet or network became active, or the
// network now answers with the other login: what the sheet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ import SwiftUI
import UIKit

/// Hosts `ConnectionsScreen` and keeps a handle on its view model, so a
/// `dash-key:` / `dash-st:` link that arrives while the screen is already on
/// the stack is routed into it instead of pushing a second copy.
/// `dash-key:` / `dash-st:` request that arrives while the screen is already
/// on the stack is routed into it instead of pushing a second copy.
final class DashConnectHostingController: UIHostingController<ConnectionsScreen> {
private let viewModel: ConnectionsViewModel
/// Held until `viewDidAppear`: the approval sheet is presented from the
/// screen, which cannot present while it is still being pushed.
private var pendingURI: String?
/// Whether `pendingURI` was read off a QR code rather than opened as a
/// link. A scanned code goes in as a scan, the way the screen's own
/// scanner hands one over.
private var pendingURIWasScanned = false

init(navigationController: UINavigationController, uri: String? = nil) {
init(navigationController: UINavigationController, uri: String? = nil, scanned: Bool = false) {
let viewModel = ConnectionsViewModel()
self.viewModel = viewModel
pendingURI = uri
pendingURIWasScanned = scanned

super.init(rootView: ConnectionsScreen(vc: navigationController, viewModel: viewModel))
}
Expand All @@ -46,9 +51,11 @@ final class DashConnectHostingController: UIHostingController<ConnectionsScreen>
consumePendingURI()
}

/// Handles a link that arrived for a screen that is already on the stack.
func handle(uri: String) {
/// Handles a request that arrived for a screen that is already on the
/// stack: a link, or with `scanned` a code another screen's scanner read.
func handle(uri: String, scanned: Bool = false) {
pendingURI = uri
pendingURIWasScanned = scanned

if isViewLoaded, view.window != nil {
consumePendingURI()
Expand All @@ -58,6 +65,10 @@ final class DashConnectHostingController: UIHostingController<ConnectionsScreen>
private func consumePendingURI() {
guard let uri = pendingURI else { return }
pendingURI = nil
viewModel.onURIReceived(uri)
if pendingURIWasScanned {
viewModel.onQRScanned(uri)
} else {
viewModel.onURIReceived(uri)
}
}
}
18 changes: 18 additions & 0 deletions DashWallet/Sources/UI/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,24 @@ extension HomeViewController: ShortcutsActionDelegate {
}
}

// MARK: - DWQRScanModelDelegate

extension HomeViewController {
/// The Home scanner (the Scan shortcut, `dashwallet://scanqr`) also reads
/// DashConnect codes, and opens the Connections screen with them — the
/// same place a tapped `dash-key:` / `dash-st:` link goes, but as a scan.
///
/// The scan delegate is `DWBasePayViewController`; only Home answers this
/// optional half, so the lock screen and the Send scanners keep treating
/// these codes as not-a-payment.
@objc(qrScanModel:didScanDashConnectURI:)
func qrScanModel(_ viewModel: DWQRScanModel, didScanDashConnectURI uri: String) {
dismiss(animated: true) { [weak self] in
(self?.tabBarController as? MainTabbarController)?.openDashConnect(uri, scanned: true)
}
}
}

// MARK: - SyncingActivityMonitorObserver

extension HomeViewController: SyncingActivityMonitorObserver {
Expand Down
14 changes: 10 additions & 4 deletions DashWallet/Sources/UI/Main/MainTabbarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,17 @@ extension MainTabbarController {
}

/// Opens the Connections screen for a `dash-key:` / `dash-st:` link.
@objc
public func openDashConnect(_ uri: String) {
openDashConnect(uri, scanned: false)
}

/// Opens the Connections screen for a `dash-key:` / `dash-st:` request:
/// a link, or with `scanned` a code the Home scanner read.
///
/// The More tab's index moves with the DashPay layout, so it comes from
/// `moreTabIndex` rather than from the tab enum.
@objc
public func openDashConnect(_ uri: String) {
func openDashConnect(_ uri: String, scanned: Bool) {
dismiss(animated: false, completion: nil)

guard let menuNav = menuNavigationController?.navigationController else { return }
Expand All @@ -559,11 +565,11 @@ extension MainTabbarController {
}

if let connections = menuNav.topViewController as? DashConnectHostingController {
connections.handle(uri: uri)
connections.handle(uri: uri, scanned: scanned)
return
}

let controller = DashConnectHostingController(navigationController: menuNav, uri: uri)
let controller = DashConnectHostingController(navigationController: menuNav, uri: uri, scanned: scanned)
controller.hidesBottomBarWhenPushed = true
menuNav.pushViewController(controller, animated: true)
}
Expand Down
8 changes: 8 additions & 0 deletions DashWallet/Sources/UI/Payments/ScanQR/DWQRScanModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ typedef NS_ENUM(NSUInteger, QRCodeObjectType) {
- (void)qrScanModel:(DWQRScanModel *)viewModel didScanPaymentInput:(DWPaymentInput *)paymentInput;
- (void)qrScanModelDidCancel:(DWQRScanModel *)viewModel;

@optional

/// A DashConnect request (`dash-key:` / `dash-st:`) was scanned.
///
/// Only a delegate that implements this is handed one. Every other scanner
/// reads the code as before: not a payment, so "Not a Dash QR code".
- (void)qrScanModel:(DWQRScanModel *)viewModel didScanDashConnectURI:(NSString *)uri;

@end

NS_ASSUME_NONNULL_END
16 changes: 16 additions & 0 deletions DashWallet/Sources/UI/Payments/ScanQR/DWQRScanModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@ - (void)didOutputMetadataObjects:(NSArray<__kindof AVMetadataObject *> *)metadat
NSAssert(![NSThread isMainThread], nil);

NSString *addr = [codeObject.stringValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

// A DashConnect request is not a payment: hand it over whole before the payment parse below
// rejects it. Malformed payloads are reported by the Connections screen, as for a tapped link.
NSString *dashConnectURI = [DWDashConnectDeepLink uriFromString:addr];
if (dashConnectURI && [self.delegate respondsToSelector:@selector(qrScanModel:didScanDashConnectURI:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
QRCodeObject *qrCodeObject = [[QRCodeObject alloc] initWithMetadataObject:codeObject];
[qrCodeObject setValid];
self.qrCodeObject = qrCodeObject;

[self.delegate qrScanModel:self didScanDashConnectURI:dashConnectURI];
});

return;
}

DWParsedPaymentURI *parsed = [DWParsedPaymentURI parsePaymentString:addr];
// The URI parse, `pay:` normalization and address validity are app-side now (the box). (Paper-wallet
// sweep — the old WIF/BIP38 arm — was dropped in C8 step 5.)
Expand Down
1 change: 1 addition & 0 deletions DashWallet/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/bg.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/ca.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/da.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6357,6 +6357,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/el.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6357,6 +6357,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6239,6 +6239,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/eo.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
1 change: 1 addition & 0 deletions DashWallet/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6357,6 +6357,7 @@
"Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset." = "Confirming saves birth height %u and clears this network's chain data at the next app launch, re-downloading it and rescanning filters from that height. Fully close and relaunch the app to start; the in-app Restart button does not apply this reset.";
"Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts" = "Connect your DashPay username to apps on the Dash network to sign in without passwords or accounts";
"Connected since %@" = "Connected since %@";
"Connected to %@. Go back to your browser to continue." = "Connected to %@. Go back to your browser to continue.";
"Connections" = "Connections";
"Contact is no longer available" = "Contact is no longer available";
"Contender details" = "Contender details";
Expand Down
Loading
Loading