diff --git a/Sources/ElixxirDAppsSDK/NewCmix.swift b/Sources/ElixxirDAppsSDK/NewCmix.swift new file mode 100644 index 0000000000000000000000000000000000000000..193fd57f81a48cf2eadb979d465e3cae2c3e5720 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/NewCmix.swift @@ -0,0 +1,36 @@ +import Bindings +import XCTestDynamicOverlay + +public struct NewCmix { + public init(run: @escaping (String, String, Data, String?) throws -> Bool) { + self.run = run + } + + public var run: (String, String, Data, String?) throws -> Bool + + public func callAsFunction( + ndfJSON: String, + storageDir: String, + password: Data, + registrationCode: String? + ) throws -> Bool { + try run(ndfJSON, storageDir, password, registrationCode) + } +} + +extension NewCmix { + public static let live = NewCmix { ndfJSON, storageDir, password, registrationCode in + var error: NSError? + let result = BindingsNewCmix(ndfJSON, storageDir, password, registrationCode, &error) + if let error = error { + throw error + } + return result + } +} + +extension NewCmix { + public static let unimplemented = NewCmix( + run: XCTUnimplemented("\(Self.self)") + ) +}