Files
Андрей Геращенко f52cdb51bc MALINKA-1095: Password logic refactoring
2023-03-10 11:40:54 +03:00

36 lines
901 B
Swift

//
// CreateWalletService.swift
// Malinka
//
// Created by Juraldinio on 8/26/22.
// Copyright © 2022 NUT.Tech. All rights reserved.
//
import Foundation
import WalletKit
struct CreateWalletService {
// MARK: - Properties
private let village: Village
private let device: Device
private let walletCase: WalletCase
// MARK: - Init
init(village: Village, device: Device, walletCase: WalletCase) {
self.village = village
self.device = device
self.walletCase = walletCase
}
// MARK: - Methods
func create(for password: String) async throws -> UpdateWalletStateService {
let bank = try self.village.getBank(with: password, on: self.device)
let wallet = try await bank.add(using: self.walletCase, password: password)
return UpdateWalletStateService(bank: bank, wallet: wallet)
}
}