From cf1ae915e119653abbe41a6a9236575e3970a421 Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Mon, 25 Jul 2022 15:46:11 +0100
Subject: [PATCH] Add E2EGetContact functor

---
 Sources/ElixxirDAppsSDK/E2E.swift           |  3 +++
 Sources/ElixxirDAppsSDK/E2EGetContact.swift | 27 +++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 Sources/ElixxirDAppsSDK/E2EGetContact.swift

diff --git a/Sources/ElixxirDAppsSDK/E2E.swift b/Sources/ElixxirDAppsSDK/E2E.swift
index d98b72c0..a3ee3414 100644
--- a/Sources/ElixxirDAppsSDK/E2E.swift
+++ b/Sources/ElixxirDAppsSDK/E2E.swift
@@ -3,6 +3,7 @@ import Bindings
 public struct E2E {
   public var getId: E2EGetId
   public var getReceptionId: E2EGetReceptionId
+  public var getContact: E2EGetContact
   public var payloadSize: E2EPayloadSize
   public var partitionSize: E2EPartitionSize
 
@@ -14,6 +15,7 @@ extension E2E {
     E2E(
       getId: .live(bindingsE2E: bindingsE2E),
       getReceptionId: .live(bindingsE2E: bindingsE2E),
+      getContact: .live(bindingsE2E: bindingsE2E),
       payloadSize: .live(bindingsE2E: bindingsE2E),
       partitionSize: .live(bindingsE2E: bindingsE2E)
     )
@@ -24,6 +26,7 @@ extension E2E {
   public static let unimplemented = E2E(
     getId: .unimplemented,
     getReceptionId: .unimplemented,
+    getContact: .unimplemented,
     payloadSize: .unimplemented,
     partitionSize: .unimplemented
   )
diff --git a/Sources/ElixxirDAppsSDK/E2EGetContact.swift b/Sources/ElixxirDAppsSDK/E2EGetContact.swift
new file mode 100644
index 00000000..fc9053bc
--- /dev/null
+++ b/Sources/ElixxirDAppsSDK/E2EGetContact.swift
@@ -0,0 +1,27 @@
+import Bindings
+import XCTestDynamicOverlay
+
+public struct E2EGetContact {
+  public var run: () -> Data
+
+  public func callAsFunction() -> Data {
+    run()
+  }
+}
+
+extension E2EGetContact {
+  public static func live(bindingsE2E: BindingsE2e) -> E2EGetContact {
+    E2EGetContact {
+      guard let data = bindingsE2E.getContact() else {
+        fatalError("BindingsE2e.getContact returned `nil`")
+      }
+      return data
+    }
+  }
+}
+
+extension E2EGetContact {
+  public static let unimplemented = E2EGetContact(
+    run: XCTUnimplemented("\(Self.self)")
+  )
+}
-- 
GitLab