Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rommex committed Dec 15, 2024
2 parents 4955fd5 + b0f961b commit 1227715
Show file tree
Hide file tree
Showing 72 changed files with 1,840 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import UIKit


final class CoreAppCoordinator: CoreAppCoordinatorProtocol {
func askForMPC2FACode() async -> String? {
""
}

private var window: UIWindow?

func askToReconnectMPCWallet(_ reconnectData: MPCWalletReconnectData) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ final class ImageLoadingService: ImageLoadingServiceProtocol {
}
case .wcApp:
return UIImage.Preview.previewSquare
case .qrCode(_ , _):
await Task.sleep(seconds: 1)
return UIImage.Preview.previewSquare
default:
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extension FB_UD_MPC {
}

struct DefaultMPCConnectionNetworkService: MPCConnectionNetworkService {
var otpProvider: FB_UD_MPC.MPCOTPProvider?

func getAssetTransferEstimations(accessToken: String, accountId: String, assetId: String, destinationAddress: String, amount: String) async throws -> FB_UD_MPC.NetworkFeeResponse {
.init(priority: "", status: "", networkFee: nil)
}
Expand Down Expand Up @@ -142,6 +144,31 @@ extension FB_UD_MPC {
func requestRecovery(_ accessToken: String, password: String) async throws {
await Task.sleep(seconds: 0.5)
}

func resetPassword(accessToken: String,
recoveryToken: String,
newRecoveryPhrase: String,
requestId: String) async throws {
await Task.sleep(seconds: 0.5)
}

func get2FAStatus(accessToken: String) async throws -> Bool {
await Task.sleep(seconds: 0.5)
return false
}

func enable2FA(accessToken: String) async throws -> String {
await Task.sleep(seconds: 0.5)
return ""
}

func verify2FAToken(accessToken: String, token: String) async throws {
await Task.sleep(seconds: 0.5)
}

func disable2FA(accessToken: String, token: String) async throws {
await Task.sleep(seconds: 0.5)
}
}

struct MPCWalletsDefaultDataStorage: MPCWalletsDataStorage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct UDWallet: Codable, Hashable {
var address: String = "0xc4a748796805dfa42cafe0901ec182936584cc6e"
var type: WalletType = .generatedLocally
var hasBeenBackedUp: Bool? = false
private(set) var mpcMetadata: MPCWalletMetadata?
var mpcMetadata: MPCWalletMetadata?

struct WalletConnectionInfo: Codable {
var externalWallet: WCWalletsProvider.WalletRecord
Expand Down
102 changes: 101 additions & 1 deletion unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/fireblocks/ncw-ios-sdk.git",
"state" : {
"revision" : "c71c7fd281ec3edba921a72d8adab7fabcf5c9bb",
"version" : "2.8.2"
"revision" : "9ed23d0128b2f86c5bfa080cf7822b4ed6a27f04",
"version" : "2.9.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ extension MockEntitiesFabric {

}
}

static func mockMPC() -> WalletEntity {
let address = "0xmpcwallet"
let udWallet = UDWallet.createMPC(address: address,
aliasName: "Lite Wallet",
mpcMetadata: .init(provider: .fireblocksUD,
metadata: Data()))
let displayInfo = WalletDisplayInfo(wallet: udWallet,
domainsCount: 0,
udDomainsCount: 0)!
return WalletEntity(udWallet: udWallet,
displayInfo: displayInfo,
domains: [],
nfts: [],
balance: [],
rrDomain: nil,
portfolioRecords: [])
}

static func createFrom(udWallet: UDWallet,
hasRRDomain: Bool = true) -> WalletEntity {
Expand Down
11 changes: 8 additions & 3 deletions unstoppable-ios-app/domains-manager-ios/Entities/Toast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum Toast: Hashable {
case followedProfileAs(DomainName)
case domainRemoved
case cartCleared
case enabled2FA

var message: String {
switch self {
Expand Down Expand Up @@ -74,12 +75,14 @@ enum Toast: Hashable {
return String.Constants.domainRemoved.localized()
case .cartCleared:
return String.Constants.cartCleared.localized()
case .enabled2FA:
return String.Constants.enabled2FAToastMessage.localized()
}
}

var secondaryMessage: String? {
switch self {
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .noInternetConnection, .changesConfirmed, .mintingSuccessful, .mintingUnavailable, .updatingRecords, .domainCopied, .failedToRefreshBadges, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs, .domainRemoved, .cartCleared:
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .noInternetConnection, .changesConfirmed, .mintingSuccessful, .mintingUnavailable, .updatingRecords, .domainCopied, .failedToRefreshBadges, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs, .domainRemoved, .cartCleared, .enabled2FA:
return nil
case .failedToFetchDomainProfileData:
return String.Constants.refresh.localized()
Expand All @@ -90,7 +93,7 @@ enum Toast: Hashable {

var style: Style {
switch self {
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs, .domainRemoved, .cartCleared:
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs, .domainRemoved, .cartCleared, .enabled2FA:
return .success
case .noInternetConnection, .updatingRecords, .mintingUnavailable, .failedToFetchDomainProfileData, .failedToUpdateProfile:
return .dark
Expand All @@ -101,7 +104,7 @@ enum Toast: Hashable {

var image: UIImage {
switch self {
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs, .domainRemoved, .cartCleared:
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs, .domainRemoved, .cartCleared, .enabled2FA:
return .checkCircleWhite
case .noInternetConnection:
return .cloudOfflineIcon
Expand Down Expand Up @@ -162,6 +165,8 @@ enum Toast: Hashable {
return true
case (.cartCleared, .cartCleared):
return true
case (.enabled2FA, .enabled2FA):
return true
default:
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,19 @@ extension String {
static let addToBackupNewWalletSubtitle = "ADD_TO_BACKUP_NEW_WALLET_SUBTITLE"
static let addToCurrentBackupNewWalletTitle = "ADD_TO_CURRENT_BACKUP_NEW_WALLET_TITLE"
static let createVault = "CREATE_VAULT"
static let mpc2FAEnabled = "MPC_2FA_ENABLED"
static let mpc2FAEnable = "MPC_2FA_ENABLE"
static let enable2FATitle = "ENABLE_2FA_TITLE"
static let enable2FASubtitle = "ENABLE_2FA_SUBTITLE"
static let enable2FACopySecretTitle = "ENABLE_2FA_COPY_SECRET_TITLE"
static let enable2FAOrScanQRCode = "ENABLE_2FA_OR_SCAN_QR_CODE"
static let enable2FAConfirmTitle = "ENABLE_2FA_CONFIRM_TITLE"
static let enable2FAConfirmSubtitle = "ENABLE_2FA_CONFIRM_SUBTITLE"
static let disable2FA = "DISABLE_2FA"
static let mpc2FAEnabledPullUpTitle = "MPC_2FA_ENABLED_PULLUP_TITLE"
static let mpc2FAEnabledPullUpSubtitle = "MPC_2FA_ENABLED_PULLUP_SUBTITLE"
static let mpc2FADisableConfirmationPullUpTitle = "MPC_2FA_DISABLE_CONFIRMATION_PULLUP_TITLE"
static let mpc2FADisableConfirmationPullUpSubtitle = "MPC_2FA_DISABLE_CONFIRMATION_PULLUP_SUBTITLE"

// Toast messages
static let toastWalletAddressCopied = "TOAST_WALLET_ADDRESS_COPIED"
Expand Down Expand Up @@ -1113,6 +1126,7 @@ extension String {
static let endings = "ENDINGS"
static let suggestions = "SUGGESTIONS"
static let domainsPurchasedSummaryMessage = "DOMAINS_PURCHASED_SUMMARY_MESSAGE"
static let enabled2FAToastMessage = "ENABLED_2FA_TOAST_MESSAGE"

// Home
static let homeWalletTokensComeTitle = "HOME_WALLET_TOKENS_COME_TITLE"
Expand Down Expand Up @@ -1321,6 +1335,8 @@ extension String {
static let mpcRecoveryRequestedSubtitleHighlights = "MPC_RECOVERY_REQUESTED_SUBTITLE_HIGHLIGHTS"
static let mpcRecoveryRequestedHintNotShare = "MPC_RECOVERY_REQUESTED_HINT_NOT_SHARE"
static let mpcRecoveryRequestedHintPreviousInactive = "MPC_RECOVERY_REQUESTED_HINT_PREVIOUS_INACTIVE"
static let mpcResetPasswordTitle = "MPC_RESET_PASSWORD_TITLE"
static let mpcResetPasswordSubtitle = "MPC_RESET_PASSWORD_SUBTITLE"

// Send crypto first time
static let sendCryptoFirstTimePullUpTitle = "SEND_CRYPTO_FIRST_TIME_PULL_UP_TITLE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ extension UIImage {
static let unsTLDLogo = UIImage(named: "unsTLDLogo")!
static let ensTLDLogo = UIImage(named: "ensTLDLogo")!
static let dnsTLDLogo = UIImage(named: "dnsTLDLogo")!
static let shieldCheckmarkFilled = UIImage(named: "shieldCheckmarkFilled")!

static let twitterIcon24 = UIImage(named: "twitterIcon24")!
static let discordIcon24 = UIImage(named: "discordIcon24")!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ final class HomeTabRouter: ObservableObject {
@Published var resolvingPrimaryDomainWallet: SelectRRPresentationDetails?
@Published var showingWalletInfo: WalletEntity?
@Published var sendCryptoInitialData: SendCryptoAsset.InitialData?
@Published var mpcResetPasswordData: MPCResetPasswordData? = nil
weak var mintingNav: MintDomainsNavigationController?
weak var chatsListCoordinator: ChatsListCoordinator?
weak var homeWalletViewCoordinator: HomeWalletViewCoordinator?
Expand Down Expand Up @@ -306,6 +307,7 @@ extension HomeTabRouter {
showingWalletInfo = nil
sendCryptoInitialData = nil
requestingRecoveryMPC = nil
mpcResetPasswordData = nil
walletViewNavPath.removeAll()
chatTabNavPath.removeAll()
exploreTabNavPath.removeAll()
Expand Down Expand Up @@ -348,6 +350,27 @@ extension HomeTabRouter {

appContext.pullUpViewService.showMessageSigningInMaintenancePullUp(in: topVC)
}

func runResetMPCWalletPasswordFlow(_ mpcResetPasswordData: MPCResetPasswordData) {
self.mpcResetPasswordData = mpcResetPasswordData
}

func didAddNewWallet(_ wallet: UDWallet) {
let profiles = appContext.userProfilesService.profiles
for profile in profiles {
if case .wallet(let walletEntity) = profile,
walletEntity.address == wallet.address {
let walletName = walletEntity.displayInfo.walletSourceName
appContext.toastMessageService.showToast(.walletAdded(walletName: walletName), isSticky: false)
Task {
await popToRootAndWait()
walletViewNavPath.append(.walletDetails(walletEntity))
}
break
}
}
AppReviewService.shared.appReviewEventDidOccurs(event: .walletAdded)
}
}

// MARK: - Pull up related
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ struct HomeTabView: View {
ShareWalletInfoView(wallet: $0)
.presentationDetents([.large])
})
.sheet(item: $router.mpcResetPasswordData, content: {
MPCResetPasswordRootView(resetPasswordData: $0, resetResultCallback: { result in
switch result {
case .restored(let wallet):
router.didAddNewWallet(wallet)
}
})
})
.sheet(item: $router.sendCryptoInitialData, content: { initialData in
SendCryptoAssetRootView(viewModel: SendCryptoAssetViewModel(initialData: initialData))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ struct NavigationPathWrapper<Data> where Data : Hashable {
navigationPath.removeLast()
}

mutating func removeLast(_ num: Int) {
navigationPath.removeLast(num)
}

func first(where isIncluded: (Data) -> Bool) -> Data? {
navigationTypedPath.first(where: isIncluded)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ enum HomeWalletNavigationDestination: Hashable {
case walletDetails(WalletEntity)
case securitySettings
case setupPasscode(SetupPasscodeViewController.Mode)
case mpcSetup2FAEnable(mpcMetadata: MPCWalletMetadata)
case mpcSetup2FAEnableConfirm(mpcMetadata: MPCWalletMetadata)

static func == (lhs: Self, rhs: Self) -> Bool {
switch (lhs, rhs) {
Expand All @@ -38,6 +40,10 @@ enum HomeWalletNavigationDestination: Hashable {
return true
case (.setupPasscode, .setupPasscode):
return true
case (.mpcSetup2FAEnable, .mpcSetup2FAEnable):
return true
case (.mpcSetup2FAEnableConfirm, .mpcSetup2FAEnableConfirm):
return true
default:
return false
}
Expand All @@ -61,6 +67,10 @@ enum HomeWalletNavigationDestination: Hashable {
hasher.combine("securitySettings")
case .setupPasscode:
hasher.combine("setupPasscode")
case .mpcSetup2FAEnable:
hasher.combine("mpcSetup2FAEnable")
case .mpcSetup2FAEnableConfirm:
hasher.combine("mpcSetup2FAEnable")
}
}

Expand Down Expand Up @@ -95,6 +105,10 @@ struct HomeWalletLinkNavigationDestination {
.ignoresSafeArea()
case .walletDetails(let wallet):
WalletDetailsView(wallet: wallet, source: .settings)
case .mpcSetup2FAEnable(let mpcMetadata):
MPCSetup2FAEnableView(mpcMetadata: mpcMetadata)
case .mpcSetup2FAEnableConfirm(let mpcMetadata):
MPCSetup2FAConfirmCodeView(verificationPurpose: .enable(mpcMetadata))
case .securitySettings:
SecuritySettingsView()
case .setupPasscode(let mode):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct MPCActivateWalletInAppView: View {

var body: some View {
MPCActivateWalletView(analyticsName: .mpcActivationInApp,
credentials: credentials,
flow: .activate(credentials),
code: code,
mpcWalletCreatedCallback: didCreateMPCWallet,
changeEmailCallback: didRequestToChangeEmail)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct MPCActivateWalletView: View, ViewAnalyticsLogger {
@Environment(\.mpcWalletsService) private var mpcWalletsService

let analyticsName: Analytics.ViewName
@State var credentials: MPCActivateCredentials
@State var flow: SetupMPCFlow
@State var code: String
var canGoBack: Bool = true
let mpcWalletCreatedCallback: (UDWallet)->()
Expand Down Expand Up @@ -48,20 +48,30 @@ struct MPCActivateWalletView: View, ViewAnalyticsLogger {
.onAppear(perform: onAppear)
.sheet(item: $enterDataType) { dataType in
MPCActivateWalletEnterView(dataType: dataType,
email: credentials.email,
email: flow.email,
confirmationCallback: { value in
switch dataType {
case .passcode:
self.code = value
case .password:
self.credentials.password = value
didEnterNewPassword(value)
}
activateMPCWallet()
}, changeEmailCallback: changeEmailCallback)
.presentationDetents([.medium])
}
.navigationBarBackButtonHidden(isBackButtonHidden)
}

func didEnterNewPassword(_ password: String) {
switch self.flow {
case .activate(var credentials):
credentials.password = password
self.flow = .activate(credentials)
case .resetPassword:
Debugger.printFailure("Incorrect state, new password can't be incorrect", critical: true)
}
}
}

// MARK: - Private methods
Expand Down Expand Up @@ -97,8 +107,8 @@ private extension MPCActivateWalletView {

isLoading = true
do {
let mpcWalletStepsStream = mpcWalletsService.setupMPCWalletWith(code: code,
credentials: credentials)
let mpcWalletStepsStream: AsyncThrowingStream<SetupMPCWalletStep, Error> = mpcWalletsService.setupMPCWalletWith(code: code,
flow: flow)

for try await step in mpcWalletStepsStream {
updateForSetupMPCWalletStep(step)
Expand Down Expand Up @@ -239,8 +249,8 @@ private extension MPCActivateWalletView {

#Preview {
MPCActivateWalletView(analyticsName: .mpcActivationOnboarding,
credentials: .init(email: "qq@qq.qq",
password: ""),
flow: .activate(.init(email: "qq@qq.qq",
password: "")),
code: "",
mpcWalletCreatedCallback: { _ in },
changeEmailCallback: { })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private extension MPCOnboardingActivateWalletViewController {
return
}
let mpcView = MPCActivateWalletView(analyticsName: .mpcActivationOnboarding,
credentials: credentials,
flow: .activate(credentials),
code: code, mpcWalletCreatedCallback: { [weak self] wallet in
DispatchQueue.main.async {
self?.handleAction(.didImportWallet(wallet))
Expand Down
Loading

0 comments on commit 1227715

Please sign in to comment.