Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-2053 Remove Legacy Wallets handling #578

Merged
merged 2 commits into from
Jun 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
29DE3B1328913DF500655675 /* Env.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29DE3B1228913DF500655675 /* Env.swift */; };
29EDB61E28FED24D00A0BD08 /* NetworkService+ProfilesApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EDB61D28FED24D00A0BD08 /* NetworkService+ProfilesApi.swift */; };
29EDB623290A94E700A0BD08 /* ProfilesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EDB622290A94E700A0BD08 /* ProfilesTests.swift */; };
3004E32726D528D300B9CB6A /* LegacyUnitaryWallet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3004E32626D528D300B9CB6A /* LegacyUnitaryWallet.swift */; };
3004E32C26D53F1D00B9CB6A /* UDWalletStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3004E32B26D53F1D00B9CB6A /* UDWalletStorage.swift */; };
3018AEAE27E9D50A00E8C37D /* RestoreWalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3018AEAD27E9D50A00E8C37D /* RestoreWalletViewController.swift */; };
3018AEB327EA091000E8C37D /* EnterBackupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3018AEB227EA091000E8C37D /* EnterBackupViewController.swift */; };
Expand Down Expand Up @@ -2616,7 +2615,6 @@
29DE3B1228913DF500655675 /* Env.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Env.swift; sourceTree = "<group>"; };
29EDB61D28FED24D00A0BD08 /* NetworkService+ProfilesApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NetworkService+ProfilesApi.swift"; sourceTree = "<group>"; };
29EDB622290A94E700A0BD08 /* ProfilesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilesTests.swift; sourceTree = "<group>"; };
3004E32626D528D300B9CB6A /* LegacyUnitaryWallet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyUnitaryWallet.swift; sourceTree = "<group>"; };
3004E32B26D53F1D00B9CB6A /* UDWalletStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UDWalletStorage.swift; sourceTree = "<group>"; };
300F291525CFEBEC007EEAD1 /* TransactionsStorageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionsStorageTests.swift; sourceTree = "<group>"; };
300F291B25D3D4A1007EEAD1 /* DomainRecordsViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainRecordsViewModelTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4928,7 +4926,6 @@
29BECD21297ABF3C00662FC1 /* UDWalletWithPrivateSeed.swift */,
29AEA05429367785003BB5B4 /* UDWallet+Signing.swift */,
307B1D382603C0C4007B14C3 /* UDWalletEthereum.swift */,
3004E32626D528D300B9CB6A /* LegacyUnitaryWallet.swift */,
C616C2D72806DBC600C212DC /* ExternalWalletMake.swift */,
C617FDA02B58E75B00B93433 /* WalletEntity.swift */,
);
Expand Down Expand Up @@ -8807,7 +8804,6 @@
C62900EE2BAAC5C0008B35A2 /* BalanceTokenIconsView.swift in Sources */,
29BECD0E2979BD7B00662FC1 /* CloudStorage.swift in Sources */,
C6D0F438283F7DFF00444921 /* MintDomainsConfigurationSelectionCell.swift in Sources */,
3004E32726D528D300B9CB6A /* LegacyUnitaryWallet.swift in Sources */,
C6B65F722B550F6B006D1812 /* DomainNFTsStorage.swift in Sources */,
307B1D392603C0C4007B14C3 /* UDWalletEthereum.swift in Sources */,
C60EE80F2ACD203000D699C7 /* NetworkService+MessagingApi.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ final class UDWalletsStorage {

extension UDWalletsStorage {
func initialWalletsCheck() async throws {
if let legacyWallets = LegacyWalletStorage.instance.getWalletsList(ownedBy: User.defaultId) {
try await appContext.udWalletsService.migrateToUdWallets(from: legacyWallets)
}
removeReadOnlyUnverifiedWallets()
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,6 @@ struct UDWallet: Codable, @unchecked Sendable {
}
}

static func createUnverified(response: NetworkService.TxCryptoWalletResponse) -> UDWallet? {
let aliasName = response.humanAddress
guard let type = try? BlockchainType.getType(abbreviation: response.blockchain) else {
return nil
}

switch type {
case .Ethereum, .Matic: let wallet = UDWalletEthereum.createUnverified(address: response.address)
return UDWallet(aliasName: aliasName,
walletType: .importedUnverified,
ethWallet: wallet)
}
}

static func createUnverified(aliasName: String? = nil,
address: HexAddress) -> UDWallet? {
let name = aliasName == nil ? address : aliasName!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ extension MockUDWalletsService: UDWalletsServiceProtocol {
func restoreAndInjectWallets(using password: String) async throws -> [UDWallet] { [] }
func eraseAllBackupClusters() { }

// Migration
func migrateToUdWallets(from legacyWallets: [LegacyUnitaryWallet]) async throws { }

// Listeners
func addListener(_ listener: UDWalletsServiceListener) {
if !listenerHolders.contains(where: { $0.listener === listener }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,39 +314,7 @@ extension UDWalletsService: UDWalletsServiceProtocol {
.build()
return request
}

// Migrate
func migrateToUdWallets(from legacyWallets: [LegacyUnitaryWallet]) async throws {
Debugger.printInfo(topic: .Wallet, "Migration from Legacy Wallets Storage started")
do {
var udWallets = [UDWallet]()

try await withThrowingTaskGroup(of: UDWallet.self, body: { group in
for legacyWallet in legacyWallets {
group.addTask {
return try await legacyWallet.convertToUDWallet()
}
}

do {
for try await udWallet in group {
udWallets.append(udWallet)
}
} catch WalletError.ethWalletAlreadyExists {
Void() /// Ignore this error.
} catch {
throw error
}

})
store(wallets: udWallets, shouldNotify: true)
LegacyWalletStorage.instance.remove()
} catch {
Debugger.printFailure("Not all Wallets are migrated to UDWallets", critical: true)
throw WalletError.migrationError
}
}


// Listeners
func addListener(_ listener: UDWalletsServiceListener) {
if !listenerHolders.contains(where: { $0.listener === listener }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ protocol UDWalletsServiceProtocol {
func setReverseResolution(to domain: DomainItem,
paymentConfirmationHandler: PaymentConfirmationHandler) async throws

// Migration
func migrateToUdWallets(from legacyWallets: [LegacyUnitaryWallet]) async throws

// Listeners
func addListener(_ listener: UDWalletsServiceListener)
func removeListener(_ listener: UDWalletsServiceListener)
Expand Down