diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 59e89ecd..7b36b759 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -15,24 +15,6 @@ struct Defaults { } } - static var shouldPromptSafariForLegacyUsers: Bool { - get { - return userDefaults.bool(forKey: "shouldPromptSafariForLegacyUsers") - } - set { - userDefaults.set(newValue, forKey: "shouldPromptSafariForLegacyUsers") - } - } - - static var didMigrateKeychainFromTokenaryV1: Bool { - get { - return userDefaults.bool(forKey: "didMigrateKeychainFromTokenaryV1") - } - set { - userDefaults.set(newValue, forKey: "didMigrateKeychainFromTokenaryV1") - } - } - static var reviewRequestsGoodMomentsCount: Int { get { return userDefaults.integer(forKey: "reviewRequestsGoodMomentsCount") diff --git a/Shared/Services/Keychain.swift b/Shared/Services/Keychain.swift index f1f44782..af810cd7 100644 --- a/Shared/Services/Keychain.swift +++ b/Shared/Services/Keychain.swift @@ -15,14 +15,12 @@ struct Keychain { private enum ItemKey { case password case wallet(id: String) - case legacyPassword case raw(key: String) private static let commonPrefix = "io.tokenary.macos." private static let walletPrefix = "wallet." private static let fullWalletPrefix = commonPrefix + walletPrefix private static let fullWalletPrefixCount = fullWalletPrefix.count - private static let legacyWalletPrefix = "io.tokenary.accountstorage." var stringValue: String { switch self { @@ -30,8 +28,6 @@ struct Keychain { return ItemKey.commonPrefix + "password" case let .wallet(id: id): return ItemKey.commonPrefix + ItemKey.walletPrefix + id - case .legacyPassword: - return "io.tokenary.local.passphrase" case let .raw(key: key): return key } @@ -42,10 +38,6 @@ struct Keychain { return String(key.dropFirst(fullWalletPrefixCount)) } - static func isLegacyWallet(key: String) -> Bool { - return key.hasPrefix(legacyWalletPrefix) - } - } var password: String? { @@ -91,20 +83,6 @@ struct Keychain { } } - // MARK: - Migration - - func getLegacyKeystores() -> [Data] { - return allStoredItemsKeys().filter { ItemKey.isLegacyWallet(key: $0) }.compactMap { get(key: .raw(key: $0)) } - } - - var legacyPassword: String? { - if let data = get(key: .legacyPassword), let password = String(data: data, encoding: .utf8) { - return password - } else { - return nil - } - } - // MARK: - Private private func update(data: Data, key: ItemKey) throws { diff --git a/Shared/Wallets/WalletsManager.swift b/Shared/Wallets/WalletsManager.swift index 0a801b77..6bf6eb1e 100644 --- a/Shared/Wallets/WalletsManager.swift +++ b/Shared/Wallets/WalletsManager.swift @@ -25,26 +25,6 @@ final class WalletsManager { try? loadWalletsFromKeychain() } - #if os(macOS) - func migrateFromLegacyIfNeeded() { - guard !Defaults.didMigrateKeychainFromTokenaryV1 else { return } - let legacyKeystores = keychain.getLegacyKeystores() - if !legacyKeystores.isEmpty, let legacyPassword = keychain.legacyPassword { - keychain.save(password: legacyPassword) - for keystore in legacyKeystores { - _ = try? importJSON(keystore, - name: defaultWalletName, - password: legacyPassword, - newPassword: legacyPassword, - coin: .ethereum, - onlyToKeychain: true) - } - Defaults.shouldPromptSafariForLegacyUsers = true - } - Defaults.didMigrateKeychainFromTokenaryV1 = true - } - #endif - func validateWalletInput(_ input: String) -> InputValidationResult { if Mnemonic.isValid(mnemonic: input) { return .valid diff --git a/Tokenary macOS/AppDelegate.swift b/Tokenary macOS/AppDelegate.swift index 709ecd97..cfd6b855 100644 --- a/Tokenary macOS/AppDelegate.swift +++ b/Tokenary macOS/AppDelegate.swift @@ -30,9 +30,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { processInput(url: event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue) } - func applicationDidFinishLaunching(_ aNotification: Notification) { - walletsManager.migrateFromLegacyIfNeeded() - + func applicationDidFinishLaunching(_ aNotification: Notification) { agent.start() gasService.start() priceService.start() diff --git a/Tokenary macOS/Screens/AccountsListViewController.swift b/Tokenary macOS/Screens/AccountsListViewController.swift index d6dca621..434000b5 100644 --- a/Tokenary macOS/Screens/AccountsListViewController.swift +++ b/Tokenary macOS/Screens/AccountsListViewController.swift @@ -98,7 +98,6 @@ class AccountsListViewController: NSViewController { getBackToRectIfNeeded() blinkNewWalletCellIfNeeded() view.window?.delegate = self - promptSafariForLegacyUsersIfNeeded() if !didAppear { didAppear = true @@ -108,12 +107,6 @@ class AccountsListViewController: NSViewController { } } - private func promptSafariForLegacyUsersIfNeeded() { - guard Defaults.shouldPromptSafariForLegacyUsers else { return } - Defaults.shouldPromptSafariForLegacyUsers = false - Alert.showSafariPrompt() - } - private func callCompletion(specificWalletAccounts: [SpecificWalletAccount]?) { if !didCallCompletion { didCallCompletion = true diff --git a/Tokenary macOS/Views/Alert.swift b/Tokenary macOS/Views/Alert.swift index 389f2f7d..2544df61 100644 --- a/Tokenary macOS/Views/Alert.swift +++ b/Tokenary macOS/Views/Alert.swift @@ -20,15 +20,4 @@ class Alert: NSAlert { _ = alert.runModal() } - static func showSafariPrompt() { - let alert = Alert() - alert.messageText = "Tokenary now works great in Safari." - alert.alertStyle = .informational - alert.addButton(withTitle: "Enable Safari extension") - alert.addButton(withTitle: Strings.ok) - if alert.runModal() == .alertFirstButtonReturn { - Agent.shared.enableSafariExtension() - } - } - }