// // CaseWalletService.swift // Malinka // // Created by Juraldinio on 25.08.2022. // Copyright © 2022 NUT.Tech. All rights reserved. // import Foundation import WalletKit import UIKit final class CaseWalletService { enum ServiceError: Error { case controller case exists } private let village: Village private let cetrifiedDevice: CertifiedDevice init(village: Village, certified device: CertifiedDevice) { self.village = village self.cetrifiedDevice = device } func createPrivateKeyController(for name: String, manualCreate: Bool) async throws -> UIViewController { do { let walletCase = try await self.village.createWalletCase(with: name) let walletService = KeysWalletService(village: self.village, device: self.cetrifiedDevice.device, walletCase: walletCase) let storyboard = await UIStoryboard(name: "AccountOnboarding", bundle: nil) guard let viewController = await storyboard.instantiateViewController(withIdentifier: "SetPrivateKeyViewController") as? SetPrivateKeyViewController else { throw ServiceError.controller } // TODO: - THIS BEFORE WE REWRITE TO Layouts await MainActor.run { viewController.showCreateManual = manualCreate viewController.walletService = walletService } return viewController } catch { throw ServiceError.exists } } }