From 79e8e4acb4a0cd7ec9e0b674d82e7e3b26866371 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Thu, 2 Jun 2022 12:03:14 +0200 Subject: [PATCH] Add regCode parameter to ClientCreator --- Sources/ElixxirDAppsSDK/ClientCreator.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Sources/ElixxirDAppsSDK/ClientCreator.swift b/Sources/ElixxirDAppsSDK/ClientCreator.swift index 9e698645..5049fbce 100644 --- a/Sources/ElixxirDAppsSDK/ClientCreator.swift +++ b/Sources/ElixxirDAppsSDK/ClientCreator.swift @@ -1,18 +1,23 @@ import Bindings public struct ClientCreator { - public var create: (URL, Data, Data) throws -> Void + public var create: (URL, Data, Data, String?) throws -> Void - public func callAsFunction(directoryURL: URL, ndf: Data, password: Data) throws { - try create(directoryURL, ndf, password) + public func callAsFunction( + directoryURL: URL, + ndf: Data, + password: Data, + regCode: String? = nil + ) throws { + try create(directoryURL, ndf, password, regCode) } } extension ClientCreator { - public static let live = ClientCreator { directoryURL, ndf, password in + public static let live = ClientCreator { directoryURL, ndf, password, regCode in var error: NSError? let network = String(data: ndf, encoding: .utf8)! - let created = BindingsNewClient(network, directoryURL.path, password, nil, &error) + let created = BindingsNewClient(network, directoryURL.path, password, regCode, &error) if let error = error { throw error } @@ -24,7 +29,7 @@ extension ClientCreator { #if DEBUG extension ClientCreator { - public static let failing = ClientCreator { _, _, _ in + public static let failing = ClientCreator { _, _, _, _ in struct NotImplemented: Error {} throw NotImplemented() } -- GitLab