From 61d90fea72250909cacc75d7e5e47268e8614cb5 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:32:02 +0200
Subject: [PATCH 1/8] Remove redundant Package.resolved file

---
 .../xcshareddata/swiftpm/Package.resolved     | 95 -------------------
 1 file changed, 95 deletions(-)
 delete mode 100644 Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

diff --git a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
deleted file mode 100644
index 5b49d015..00000000
--- a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ /dev/null
@@ -1,95 +0,0 @@
-{
-  "pins" : [
-    {
-      "identity" : "combine-schedulers",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/pointfreeco/combine-schedulers",
-      "state" : {
-        "revision" : "4cf088c29a20f52be0f2ca54992b492c54e0076b",
-        "version" : "0.5.3"
-      }
-    },
-    {
-      "identity" : "keychainaccess",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/kishikawakatsumi/KeychainAccess.git",
-      "state" : {
-        "revision" : "84e546727d66f1adc5439debad16270d0fdd04e7",
-        "version" : "4.2.2"
-      }
-    },
-    {
-      "identity" : "swift-case-paths",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/pointfreeco/swift-case-paths",
-      "state" : {
-        "revision" : "ce9c0d897db8a840c39de64caaa9b60119cf4be8",
-        "version" : "0.8.1"
-      }
-    },
-    {
-      "identity" : "swift-collections",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/apple/swift-collections",
-      "state" : {
-        "revision" : "48254824bb4248676bf7ce56014ff57b142b77eb",
-        "version" : "1.0.2"
-      }
-    },
-    {
-      "identity" : "swift-composable-architecture",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/pointfreeco/swift-composable-architecture.git",
-      "state" : {
-        "revision" : "c307541328a636b9e8e25ac868d89be54a8f8dbf",
-        "version" : "0.35.0"
-      }
-    },
-    {
-      "identity" : "swift-composable-presentation",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/darrarski/swift-composable-presentation.git",
-      "state" : {
-        "revision" : "1f4d17fae1f7ed41cbed17929083190fd9a78ee6",
-        "version" : "0.5.2"
-      }
-    },
-    {
-      "identity" : "swift-custom-dump",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/pointfreeco/swift-custom-dump",
-      "state" : {
-        "revision" : "c4f78db9b90ca57b7b6abc2223e235242739ea3c",
-        "version" : "0.4.0"
-      }
-    },
-    {
-      "identity" : "swift-identified-collections",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/pointfreeco/swift-identified-collections",
-      "state" : {
-        "revision" : "2d6b7ffcc67afd9077fac5e5a29bcd6d39b71076",
-        "version" : "0.4.0"
-      }
-    },
-    {
-      "identity" : "swiftui-app-icon-creator",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/darrarski/swiftui-app-icon-creator.git",
-      "state" : {
-        "revision" : "f0c7ba4e66d3dc8135ccf9146afc05f9dff3c4ff",
-        "version" : "1.2.0"
-      }
-    },
-    {
-      "identity" : "xctest-dynamic-overlay",
-      "kind" : "remoteSourceControl",
-      "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
-      "state" : {
-        "revision" : "50a70a9d3583fe228ce672e8923010c8df2deddd",
-        "version" : "0.2.1"
-      }
-    }
-  ],
-  "version" : 2
-}
-- 
GitLab


From f9c29dc3a21405758b16b8cb80b610204025501a Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:32:36 +0200
Subject: [PATCH 2/8] Refactor ConnectionMaker

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

diff --git a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift
index aa492cc6..4baa7618 100644
--- a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift
+++ b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift
@@ -15,17 +15,17 @@ public struct ConnectionMaker {
 extension ConnectionMaker {
   public static func live(bindingsClient: BindingsClient) -> ConnectionMaker {
     ConnectionMaker { withAuthentication, recipientContact, myIdentity in
-      if !withAuthentication {
+      if withAuthentication {
         return Connection.live(
-          bindingsConnection: try bindingsClient.connect(
-            recipientContact,
+          bindingsAuthenticatedConnection: try bindingsClient.connect(
+            withAuthentication: recipientContact,
             myIdentity: myIdentity
           )
         )
       } else {
         return Connection.live(
-          bindingsAuthenticatedConnection: try bindingsClient.connect(
-            withAuthentication: recipientContact,
+          bindingsConnection: try bindingsClient.connect(
+            recipientContact,
             myIdentity: myIdentity
           )
         )
-- 
GitLab


From 6d175767be254bd955e4f789705594b196b2d3e3 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:41:40 +0200
Subject: [PATCH 3/8] Unify code formatting

---
 .../ElixxirDAppsSDK/MessageSendReport.swift   | 64 +++++++--------
 Sources/ElixxirDAppsSDK/RestlikeMessage.swift | 80 +++++++++----------
 2 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/Sources/ElixxirDAppsSDK/MessageSendReport.swift b/Sources/ElixxirDAppsSDK/MessageSendReport.swift
index d5b48cdd..bdd22220 100644
--- a/Sources/ElixxirDAppsSDK/MessageSendReport.swift
+++ b/Sources/ElixxirDAppsSDK/MessageSendReport.swift
@@ -1,39 +1,39 @@
 import Foundation
 
 public struct MessageSendReport: Equatable {
-    public init(
-        roundList: [Int],
-        messageId: Data,
-        timestamp: Int
-    ) {
-        self.roundList = roundList
-        self.messageId = messageId
-        self.timestamp = timestamp
-    }
-    
-    public var roundList: [Int]?
-    public var messageId: Data?
-    public var timestamp: Int?
+  public init(
+    roundList: [Int],
+    messageId: Data,
+    timestamp: Int
+  ) {
+    self.roundList = roundList
+    self.messageId = messageId
+    self.timestamp = timestamp
+  }
+
+  public var roundList: [Int]?
+  public var messageId: Data?
+  public var timestamp: Int?
 }
 
 extension MessageSendReport: Codable {
-    enum CodingKeys: String, CodingKey {
-        case roundList = "Rounds"
-        case messageId = "MessageID"
-        case timestamp = "Timestamp"
-    }
-    
-    public init(from decoder: Decoder) throws {
-        let container = try decoder.container(keyedBy: CodingKeys.self)
-        messageId = try container.decodeIfPresent(Data.self, forKey: .messageId)
-        timestamp = try container.decodeIfPresent(Int.self, forKey: .timestamp)
-        roundList = try container.decodeIfPresent([Int].self, forKey: .roundList)
-    }
-    
-    public func encode(to encoder: Encoder) throws {
-        var container = encoder.container(keyedBy: CodingKeys.self)
-        try container.encode(messageId, forKey: .messageId)
-        try container.encode(timestamp, forKey: .timestamp)
-        try container.encode(roundList, forKey: .roundList)
-    }
+  enum CodingKeys: String, CodingKey {
+    case roundList = "Rounds"
+    case messageId = "MessageID"
+    case timestamp = "Timestamp"
+  }
+
+  public init(from decoder: Decoder) throws {
+    let container = try decoder.container(keyedBy: CodingKeys.self)
+    messageId = try container.decodeIfPresent(Data.self, forKey: .messageId)
+    timestamp = try container.decodeIfPresent(Int.self, forKey: .timestamp)
+    roundList = try container.decodeIfPresent([Int].self, forKey: .roundList)
+  }
+
+  public func encode(to encoder: Encoder) throws {
+    var container = encoder.container(keyedBy: CodingKeys.self)
+    try container.encode(messageId, forKey: .messageId)
+    try container.encode(timestamp, forKey: .timestamp)
+    try container.encode(roundList, forKey: .roundList)
+  }
 }
diff --git a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift
index 75e3d421..a202c7cc 100644
--- a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift
+++ b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift
@@ -1,47 +1,47 @@
 import Foundation
 
 public struct RestlikeMessage: Equatable {
-    public init(
-        version: Int,
-        headers: Data,
-        content: Data,
-        method: Int,
-        uri: String,
-        error: String
-    ) {
-        self.version = version
-        self.headers = headers
-        self.content = content
-        self.method = method
-        self.uri = uri
-        self.error = error
-    }
-    
-    public var version: Int?
-    public var headers: Data?
-    public var content: Data?
-    public var method: Int?
-    public var uri: String?
-    public var error: String?
+  public init(
+    version: Int,
+    headers: Data,
+    content: Data,
+    method: Int,
+    uri: String,
+    error: String
+  ) {
+    self.version = version
+    self.headers = headers
+    self.content = content
+    self.method = method
+    self.uri = uri
+    self.error = error
+  }
+
+  public var version: Int?
+  public var headers: Data?
+  public var content: Data?
+  public var method: Int?
+  public var uri: String?
+  public var error: String?
 }
 
 extension RestlikeMessage: Codable {
-    enum CodingKeys: String, CodingKey {
-        case version = "Version"
-        case headers = "Headers"
-        case content = "Content"
-        case method = "Method"
-        case uri = "URI"
-        case error = "Error"
-    }
-    
-    public init(from decoder: Decoder) throws {
-        let container = try decoder.container(keyedBy: CodingKeys.self)
-        version = try container.decodeIfPresent(Int.self, forKey: .version)
-        headers = try container.decodeIfPresent(Data.self, forKey: .headers)
-        content = try container.decodeIfPresent(Data.self, forKey: .content)
-        method = try container.decodeIfPresent(Int.self, forKey: .method)
-        uri = try container.decodeIfPresent(String.self, forKey: .uri)
-        error = try container.decodeIfPresent(String.self, forKey: .error)
-    }
+  enum CodingKeys: String, CodingKey {
+    case version = "Version"
+    case headers = "Headers"
+    case content = "Content"
+    case method = "Method"
+    case uri = "URI"
+    case error = "Error"
+  }
+
+  public init(from decoder: Decoder) throws {
+    let container = try decoder.container(keyedBy: CodingKeys.self)
+    version = try container.decodeIfPresent(Int.self, forKey: .version)
+    headers = try container.decodeIfPresent(Data.self, forKey: .headers)
+    content = try container.decodeIfPresent(Data.self, forKey: .content)
+    method = try container.decodeIfPresent(Int.self, forKey: .method)
+    uri = try container.decodeIfPresent(String.self, forKey: .uri)
+    error = try container.decodeIfPresent(String.self, forKey: .error)
+  }
 }
-- 
GitLab


From 44671488613509ab129b5dc8003c5b1d5a252ea9 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:42:50 +0200
Subject: [PATCH 4/8] Remove unneeded codable initializer

---
 Sources/ElixxirDAppsSDK/RestlikeMessage.swift | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift
index a202c7cc..884afde1 100644
--- a/Sources/ElixxirDAppsSDK/RestlikeMessage.swift
+++ b/Sources/ElixxirDAppsSDK/RestlikeMessage.swift
@@ -34,14 +34,4 @@ extension RestlikeMessage: Codable {
     case uri = "URI"
     case error = "Error"
   }
-
-  public init(from decoder: Decoder) throws {
-    let container = try decoder.container(keyedBy: CodingKeys.self)
-    version = try container.decodeIfPresent(Int.self, forKey: .version)
-    headers = try container.decodeIfPresent(Data.self, forKey: .headers)
-    content = try container.decodeIfPresent(Data.self, forKey: .content)
-    method = try container.decodeIfPresent(Int.self, forKey: .method)
-    uri = try container.decodeIfPresent(String.self, forKey: .uri)
-    error = try container.decodeIfPresent(String.self, forKey: .error)
-  }
 }
-- 
GitLab


From ee82e70b01458889389c5e07b3b5a55c9c13e214 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:48:42 +0200
Subject: [PATCH 5/8] Fix tests

---
 Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift b/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift
index d78a7eea..6418a532 100644
--- a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift
+++ b/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift
@@ -6,9 +6,7 @@ final class MessageSendReportTests: XCTestCase {
   func testCoding() throws {
     let jsonString = """
     {
-      "RoundList": {
-        "Rounds": [1,5,9]
-      },
+      "Rounds": [1,5,9],
       "MessageID": "51Yy47uZbP0o2Y9B/kkreDLTB6opUol3M3mYiY2dcdQ=",
       "Timestamp": 1653582683183384000
     }
-- 
GitLab


From adca4bfa56e616e1e8f89370dd9d1a1e34b62212 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:49:03 +0200
Subject: [PATCH 6/8] Fix MessageSendReport initializer

---
 Sources/ElixxirDAppsSDK/MessageSendReport.swift | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Sources/ElixxirDAppsSDK/MessageSendReport.swift b/Sources/ElixxirDAppsSDK/MessageSendReport.swift
index bdd22220..e12f20f5 100644
--- a/Sources/ElixxirDAppsSDK/MessageSendReport.swift
+++ b/Sources/ElixxirDAppsSDK/MessageSendReport.swift
@@ -2,9 +2,9 @@ import Foundation
 
 public struct MessageSendReport: Equatable {
   public init(
-    roundList: [Int],
-    messageId: Data,
-    timestamp: Int
+    roundList: [Int]?,
+    messageId: Data?,
+    timestamp: Int?
   ) {
     self.roundList = roundList
     self.messageId = messageId
-- 
GitLab


From a5f3236462bf965ca1b0cbd8e2286f86074e61fc Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:49:31 +0200
Subject: [PATCH 7/8] Add missing test for decoding empty MessageSendReport

---
 .../MessageSendReportTests.swift                   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift b/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift
index 6418a532..52f33640 100644
--- a/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift
+++ b/Tests/ElixxirDAppsSDKTests/MessageSendReportTests.swift
@@ -29,4 +29,18 @@ final class MessageSendReportTests: XCTestCase {
 
     XCTAssertNoDifference(decodedReport, report)
   }
+
+  func testDecodeEmpty() throws {
+    let jsonString = "{}"
+    let jsonData = jsonString.data(using: .utf8)!
+    let decoder = JSONDecoder()
+    decoder.dataDecodingStrategy = .base64
+    let report = try decoder.decode(MessageSendReport.self, from: jsonData)
+
+    XCTAssertNoDifference(report, MessageSendReport(
+      roundList: nil,
+      messageId: nil,
+      timestamp: nil
+    ))
+  }
 }
-- 
GitLab


From 8a1d2d970ca815bd3e95f15de47b0d2776528380 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 6 Jun 2022 09:50:08 +0200
Subject: [PATCH 8/8] Remove unneeded codable methods

---
 Sources/ElixxirDAppsSDK/MessageSendReport.swift | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/Sources/ElixxirDAppsSDK/MessageSendReport.swift b/Sources/ElixxirDAppsSDK/MessageSendReport.swift
index e12f20f5..60af863f 100644
--- a/Sources/ElixxirDAppsSDK/MessageSendReport.swift
+++ b/Sources/ElixxirDAppsSDK/MessageSendReport.swift
@@ -22,18 +22,4 @@ extension MessageSendReport: Codable {
     case messageId = "MessageID"
     case timestamp = "Timestamp"
   }
-
-  public init(from decoder: Decoder) throws {
-    let container = try decoder.container(keyedBy: CodingKeys.self)
-    messageId = try container.decodeIfPresent(Data.self, forKey: .messageId)
-    timestamp = try container.decodeIfPresent(Int.self, forKey: .timestamp)
-    roundList = try container.decodeIfPresent([Int].self, forKey: .roundList)
-  }
-
-  public func encode(to encoder: Encoder) throws {
-    var container = encoder.container(keyedBy: CodingKeys.self)
-    try container.encode(messageId, forKey: .messageId)
-    try container.encode(timestamp, forKey: .timestamp)
-    try container.encode(roundList, forKey: .roundList)
-  }
 }
-- 
GitLab