From 5f4dd2307da4a2bf086e3da1df4189094f1342de Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Thu, 2 Jun 2022 11:25:23 +0200
Subject: [PATCH] Refactor

---
 Sources/ElixxirDAppsSDK/MessageSender.swift | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Sources/ElixxirDAppsSDK/MessageSender.swift b/Sources/ElixxirDAppsSDK/MessageSender.swift
index ffacd4e0..888159b4 100644
--- a/Sources/ElixxirDAppsSDK/MessageSender.swift
+++ b/Sources/ElixxirDAppsSDK/MessageSender.swift
@@ -15,16 +15,20 @@ extension MessageSender {
   public static func live(
     bindingsConnection: BindingsConnection
   ) -> MessageSender {
-    MessageSender { messageType, payload in
-      try bindingsConnection.sendE2E(messageType, payload: payload)
-    }
+    MessageSender.live(sendE2E: bindingsConnection.sendE2E(_:payload:))
   }
 
   public static func live(
     bindingsAuthenticatedConnection: BindingsAuthenticatedConnection
+  ) -> MessageSender {
+    MessageSender.live(sendE2E: bindingsAuthenticatedConnection.sendE2E(_:payload:))
+  }
+
+  private static func live(
+    sendE2E: @escaping (Int, Data) throws -> Data
   ) -> MessageSender {
     MessageSender { messageType, payload in
-      try bindingsAuthenticatedConnection.sendE2E(messageType, payload: payload)
+      try sendE2E(messageType, payload)
     }
   }
 }
-- 
GitLab