From c6042614b2865361ee8a272dd26097528c1691b5 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Tue, 7 Jun 2022 11:27:38 +0200
Subject: [PATCH] Update ConnectionMaker to accept Identity model

---
 Sources/ElixxirDAppsSDK/ConnectionMaker.swift | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift
index 4baa7618..34d7c14b 100644
--- a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift
+++ b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift
@@ -1,12 +1,12 @@
 import Bindings
 
 public struct ConnectionMaker {
-  public var connect: (Bool, Data, Data) throws -> Connection
+  public var connect: (Bool, Data, Identity) throws -> Connection
 
   public func callAsFunction(
     withAuthentication: Bool,
     recipientContact: Data,
-    myIdentity: Data
+    myIdentity: Identity
   ) throws -> Connection {
     try connect(withAuthentication, recipientContact, myIdentity)
   }
@@ -15,18 +15,20 @@ public struct ConnectionMaker {
 extension ConnectionMaker {
   public static func live(bindingsClient: BindingsClient) -> ConnectionMaker {
     ConnectionMaker { withAuthentication, recipientContact, myIdentity in
+      let encoder = JSONEncoder()
+      let myIdentityData = try encoder.encode(myIdentity)
       if withAuthentication {
         return Connection.live(
           bindingsAuthenticatedConnection: try bindingsClient.connect(
             withAuthentication: recipientContact,
-            myIdentity: myIdentity
+            myIdentity: myIdentityData
           )
         )
       } else {
         return Connection.live(
           bindingsConnection: try bindingsClient.connect(
             recipientContact,
-            myIdentity: myIdentity
+            myIdentity: myIdentityData
           )
         )
       }
-- 
GitLab