From 7c279cf11ed8408d3e67f1ecac43b52e2515c03c Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Thu, 2 Jun 2022 13:57:09 +0200 Subject: [PATCH] Add Connection.getPartner method --- Sources/ElixxirDAppsSDK/Connection.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sources/ElixxirDAppsSDK/Connection.swift b/Sources/ElixxirDAppsSDK/Connection.swift index 5b7cb920..9f269119 100644 --- a/Sources/ElixxirDAppsSDK/Connection.swift +++ b/Sources/ElixxirDAppsSDK/Connection.swift @@ -2,6 +2,7 @@ import Bindings public struct Connection { public var isAuthenticated: () -> Bool + public var getPartner: () -> Data public var send: MessageSender public var listen: MessageListener } @@ -12,6 +13,12 @@ extension Connection { ) -> Connection { Connection( isAuthenticated: { false }, + getPartner: { + guard let data = bindingsConnection.getPartner() else { + fatalError("BindingsConnection.getPartner returned `nil`") + } + return data + }, send: .live(bindingsConnection: bindingsConnection), listen: .live(bindingsConnection: bindingsConnection) ) @@ -22,6 +29,12 @@ extension Connection { ) -> Connection { Connection( isAuthenticated: bindingsAuthenticatedConnection.isAuthenticated, + getPartner: { + guard let data = bindingsAuthenticatedConnection.getPartner() else { + fatalError("BindingsAuthenticatedConnection.getPartner returned `nil`") + } + return data + }, send: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), listen: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection) ) @@ -32,6 +45,7 @@ extension Connection { extension Connection { public static let failing = Connection( isAuthenticated: { fatalError("Not implemented") }, + getPartner: { fatalError("Not implemented") }, send: .failing, listen: .failing ) -- GitLab