From d331d62826073682917001898c2a4592c39722af Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Tue, 7 Jun 2022 12:02:15 +0200 Subject: [PATCH] Use [Int] in MessageDeliveryWaiter result --- Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift b/Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift index 38283a47..84c19ce7 100644 --- a/Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift +++ b/Sources/ElixxirDAppsSDK/MessageDeliveryWaiter.swift @@ -2,7 +2,7 @@ import Bindings public struct MessageDeliveryWaiter { public enum Result: Equatable { - case delivered(roundResults: Data) + case delivered(roundResults: [Int]) case notDelivered(timedOut: Bool) } @@ -40,8 +40,14 @@ private final class Callback: NSObject, BindingsMessageDeliveryCallbackProtocol let onCallback: (MessageDeliveryWaiter.Result) -> Void func eventCallback(_ delivered: Bool, timedOut: Bool, roundResults: Data?) { - if delivered, !timedOut, let roundResults = roundResults { - return onCallback(.delivered(roundResults: roundResults)) + if delivered, !timedOut, let roundResultsData = roundResults { + let decoder = JSONDecoder() + do { + let roundResults = try decoder.decode([Int].self, from: roundResultsData) + return onCallback(.delivered(roundResults: roundResults)) + } catch { + fatalError("BindingsMessageDeliveryCallback roundResults decoding error: \(error)") + } } if !delivered, roundResults == nil { return onCallback(.notDelivered(timedOut: timedOut)) -- GitLab