diff --git a/Sources/ElixxirDAppsSDK/Connection.swift b/Sources/ElixxirDAppsSDK/Connection.swift index c2e269ee52f05f789cbc172175bde7f0ff760752..1d857798b9c82e91f283b67a126e334d2e73baae 100644 --- a/Sources/ElixxirDAppsSDK/Connection.swift +++ b/Sources/ElixxirDAppsSDK/Connection.swift @@ -2,24 +2,28 @@ import Bindings public struct Connection { public var getId: ConnectionGetId + public var getPartner: ConnectionGetPartner } extension Connection { public static func live(_ bindingsConnection: BindingsConnection) -> Connection { Connection( - getId: .live(bindingsConnection) + getId: .live(bindingsConnection), + getPartner: .live(bindingsConnection) ) } public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> Connection { Connection( - getId: .live(bindingsConnection) + getId: .live(bindingsConnection), + getPartner: .live(bindingsConnection) ) } } extension Connection { public static let unimplemented = Connection( - getId: .unimplemented + getId: .unimplemented, + getPartner: .unimplemented ) } diff --git a/Sources/ElixxirDAppsSDK/ConnectionGetPartner.swift b/Sources/ElixxirDAppsSDK/ConnectionGetPartner.swift new file mode 100644 index 0000000000000000000000000000000000000000..50f784211a1445f61d6fb00b0b80dab21031fc9b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/ConnectionGetPartner.swift @@ -0,0 +1,36 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionGetPartner { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension ConnectionGetPartner { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionGetPartner { + ConnectionGetPartner { + guard let data = bindingsConnection.getPartner() else { + fatalError("BindingsConnection.getPartner returned `nil`") + } + return data + } + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionGetPartner { + ConnectionGetPartner { + guard let data = bindingsConnection.getPartner() else { + fatalError("BindingsAuthenticatedConnection.getPartner returned `nil`") + } + return data + } + } +} + +extension ConnectionGetPartner { + public static let unimplemented = ConnectionGetPartner( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Legacy/ConnectionPartnerProvider.swift b/Sources/ElixxirDAppsSDK/Legacy/ConnectionPartnerProvider.swift deleted file mode 100644 index 8d2bcbce76c9693f3b4a615d43a5f41193551c99..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/Legacy/ConnectionPartnerProvider.swift +++ /dev/null @@ -1,41 +0,0 @@ -import Bindings - -public struct ConnectionPartnerProvider { - public var get: () -> Data - - public func callAsFunction() -> Data { - get() - } -} - -extension ConnectionPartnerProvider { - public static func live( - bindingsConnection: BindingsConnection - ) -> ConnectionPartnerProvider { - ConnectionPartnerProvider { - guard let data = bindingsConnection.getPartner() else { - fatalError("BindingsConnection.getPartner returned `nil`") - } - return data - } - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> ConnectionPartnerProvider { - ConnectionPartnerProvider { - guard let data = bindingsAuthenticatedConnection.getPartner() else { - fatalError("BindingsAuthenticatedConnection.getPartner returned `nil`") - } - return data - } - } -} - -#if DEBUG -extension ConnectionPartnerProvider { - public static let failing = ConnectionPartnerProvider { - fatalError("Not implemented") - } -} -#endif