36 lines
901 B
Swift
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)
|
|
}
|
|
}
|