diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletFlow.swift b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletFlow.swift index 7ad535dc9..0abac1ab2 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletFlow.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletFlow.swift @@ -21,7 +21,6 @@ extension ActivateMPCWalletFlow { enum FlowResult { case activated(UDWallet) - case restart } static let viewsTopOffset: CGFloat = 30 diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletRootView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletRootView.swift index 8f260e076..9f230c86c 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletRootView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletRootView.swift @@ -15,7 +15,7 @@ struct ActivateMPCWalletRootView: View { var body: some View { NavigationViewWithCustomTitle(content: { ZStack { - MPCEnterCredentialsInAppView() + MPCEnterCredentialsInAppView(preFilledEmail: viewModel.preFilledEmail) .environmentObject(viewModel) .navigationBarTitleDisplayMode(.inline) .navigationDestination(for: ActivateMPCWalletFlow.NavigationDestination.self) { destination in @@ -39,8 +39,10 @@ struct ActivateMPCWalletRootView: View { .allowsHitTesting(!viewModel.isLoading) } - init(activationResultCallback: @escaping ActivateMPCWalletFlow.FlowResultCallback) { - self._viewModel = StateObject(wrappedValue: ActivateMPCWalletViewModel(activationResultCallback: activationResultCallback)) + init(preFilledEmail: String?, + activationResultCallback: @escaping ActivateMPCWalletFlow.FlowResultCallback) { + self._viewModel = StateObject(wrappedValue: ActivateMPCWalletViewModel(preFilledEmail: preFilledEmail, + activationResultCallback: activationResultCallback)) } } @@ -55,5 +57,6 @@ private extension ActivateMPCWalletRootView { } #Preview { - ActivateMPCWalletRootView(activationResultCallback: { _ in }) + ActivateMPCWalletRootView(preFilledEmail: nil, + activationResultCallback: { _ in }) } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletViewModel.swift b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletViewModel.swift index 455a9a790..fbd89f30d 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletViewModel.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/ActivateMPCWalletViewModel.swift @@ -10,6 +10,7 @@ import SwiftUI @MainActor final class ActivateMPCWalletViewModel: ObservableObject { + let preFilledEmail: String? let activationResultCallback: ActivateMPCWalletFlow.FlowResultCallback @Published var navPath: [ActivateMPCWalletFlow.NavigationDestination] = [] @Published var navigationState: NavigationStateManager? @@ -17,7 +18,9 @@ final class ActivateMPCWalletViewModel: ObservableObject { @Published var error: Error? private var credentials: MPCActivateCredentials? - init(activationResultCallback: @escaping ActivateMPCWalletFlow.FlowResultCallback) { + init(preFilledEmail: String?, + activationResultCallback: @escaping ActivateMPCWalletFlow.FlowResultCallback) { + self.preFilledEmail = preFilledEmail self.activationResultCallback = activationResultCallback } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/MPCEnterCredentialsInAppView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/MPCEnterCredentialsInAppView.swift index 4589cb28a..070633f5a 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/MPCEnterCredentialsInAppView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/MPC/ActivateMPCWalletFlow/MPCEnterCredentialsInAppView.swift @@ -10,9 +10,12 @@ import SwiftUI struct MPCEnterCredentialsInAppView: View { @EnvironmentObject var viewModel: ActivateMPCWalletViewModel - + + let preFilledEmail: String? + var body: some View { - MPCEnterCredentialsView(analyticsName: .mpcEnterCredentialsInApp, + MPCEnterCredentialsView(mode: preFilledEmail == nil ? .freeInput : .strictEmail(preFilledEmail!), + analyticsName: .mpcEnterCredentialsInApp, credentialsCallback: didEnterCredentials) .padding(.top, ActivateMPCWalletFlow.viewsTopOffset) } @@ -26,5 +29,5 @@ private extension MPCEnterCredentialsInAppView { } #Preview { - MPCEnterCredentialsInAppView() + MPCEnterCredentialsInAppView(preFilledEmail: nil) } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Settings/SettingsView.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Settings/SettingsView.swift index e5fd3b2e9..276ce1aba 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Settings/SettingsView.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Settings/SettingsView.swift @@ -504,8 +504,8 @@ private extension SettingsView { connectNewWallet() case .createNewWallet: createNewWallet() - case .activateMPC: - activateMPCWallet() + case .activateMPC(let preFilledEmail): + activateMPCWallet(preFilledEmail: preFilledEmail) } } @@ -545,7 +545,7 @@ private extension SettingsView { case .connect: connectNewWallet() case .mpc: - activateMPCWallet() + activateMPCWallet(preFilledEmail: nil) } } } @@ -578,24 +578,18 @@ private extension SettingsView { } } - func activateMPCWallet() { + func activateMPCWallet(preFilledEmail: String?) { guard udFeatureFlagsService.valueFor(flag: .isMPCWalletEnabled), let view = appContext.coreAppCoordinator.topVC else { return } - UDRouter().showActivateMPCWalletScreen(activationResultCallback: handleMPCActivationResult, in: view) + UDRouter().showActivateMPCWalletScreen(preFilledEmail: preFilledEmail, + activationResultCallback: handleMPCActivationResult, in: view) } func handleMPCActivationResult(_ result: ActivateMPCWalletFlow.FlowResult) { switch result { case .activated(let wallet): addWalletAfterAdded(wallet) - case .restart: - Task { - guard let view = appContext.coreAppCoordinator.topVC else { return } - - await view.presentingViewController?.dismiss(animated: true) - activateMPCWallet() - } } } @@ -630,7 +624,7 @@ private extension SettingsView { extension SettingsView { enum InitialAction { case none - case importWallet, connectWallet, createNewWallet, activateMPC + case importWallet, connectWallet, createNewWallet, activateMPC(preFilledEmail: String?) case showAllAddWalletOptionsPullUp, showImportWalletOptionsPullUp } } diff --git a/unstoppable-ios-app/domains-manager-ios/Services/CoreAppCoordinator/CoreAppCoordinator.swift b/unstoppable-ios-app/domains-manager-ios/Services/CoreAppCoordinator/CoreAppCoordinator.swift index d7e6cfd5a..a378bca81 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/CoreAppCoordinator/CoreAppCoordinator.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/CoreAppCoordinator/CoreAppCoordinator.swift @@ -324,8 +324,8 @@ private extension CoreAppCoordinator { Task { await router.showDomainProfile(domain, wallet: wallet, preRequestedAction: action) } case .showPublicDomainProfile(let publicDomainDisplayInfo, let wallet, let action): Task { await router.showPublicDomainProfileFromDeepLink(of: publicDomainDisplayInfo, by: wallet, preRequestedAction: action) } - case .activateMPCWallet: - router.runAddWalletFlow(initialAction: .activateMPC) + case .activateMPCWallet(let email): + router.runAddWalletFlow(initialAction: .activateMPC(preFilledEmail: email)) } default: return } diff --git a/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksService.swift b/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksService.swift index 14d1b9a37..f0baed9ce 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksService.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksService.swift @@ -39,9 +39,9 @@ extension DeepLinksService: DeepLinksServiceProtocol { } } else if let domainName = DomainProfileLinkValidator.getUDmeDomainName(in: components) { tryHandleUDDomainProfileDeepLink(domainName: domainName, params: components.queryItems, receivedState: receivedState) - } else if isActivateMPCWalletDeepLink(components: components) { - notifyWaitersWith(event: .activateMPCWallet, - receivedState: receivedState) + } else if tryHandleActivateMPCWalletDeepLink(components: components, + receivedState: receivedState) { + return } else { tryHandleWCDeepLink(from: components, incomingURL: incomingURL, receivedState: receivedState) } @@ -194,7 +194,8 @@ private extension DeepLinksService { receivedState: receivedState) } - func isActivateMPCWalletDeepLink(components: NSURLComponents) -> Bool { + func tryHandleActivateMPCWalletDeepLink(components: NSURLComponents, + receivedState: ExternalEventReceivedState) -> Bool { guard let path = components.path, let host = components.host else { return false } @@ -202,6 +203,9 @@ private extension DeepLinksService { if Constants.udMeHosts.contains(host), pathComponents.last == ud_me_MPC_path { + let email = components.queryItems?.first(where: { $0.name == "email" })?.value + notifyWaitersWith(event: .activateMPCWallet(email: email), + receivedState: receivedState) return true } return false diff --git a/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksServiceProtocol.swift b/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksServiceProtocol.swift index fb7587817..a62291f2f 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksServiceProtocol.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/DeepLinksService/DeepLinksServiceProtocol.swift @@ -11,7 +11,7 @@ enum DeepLinkEvent: Equatable { case mintDomainsVerificationCode(email: String, code: String) case showUserDomainProfile(domain: DomainDisplayInfo, wallet: WalletEntity, action: PreRequestedProfileAction?) case showPublicDomainProfile(publicDomainDisplayInfo: PublicDomainDisplayInfo, wallet: WalletEntity, action: PreRequestedProfileAction?) - case activateMPCWallet + case activateMPCWallet(email: String?) } protocol DeepLinksServiceProtocol { diff --git a/unstoppable-ios-app/domains-manager-ios/Services/UDRouter.swift b/unstoppable-ios-app/domains-manager-ios/Services/UDRouter.swift index da36df63e..0e825f77b 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/UDRouter.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/UDRouter.swift @@ -435,9 +435,11 @@ class UDRouter: DomainProfileSignatureValidator { viewController.present(vc, animated: true) } - func showActivateMPCWalletScreen(activationResultCallback: @escaping ActivateMPCWalletFlow.FlowResultCallback, + func showActivateMPCWalletScreen(preFilledEmail: String?, + activationResultCallback: @escaping ActivateMPCWalletFlow.FlowResultCallback, in viewController: UIViewController) { - let view = ActivateMPCWalletRootView(activationResultCallback: activationResultCallback) + let view = ActivateMPCWalletRootView(preFilledEmail: preFilledEmail, + activationResultCallback: activationResultCallback) let vc = UIHostingController(rootView: view) viewController.present(vc, animated: true) }