From f0d60efae6d4e39dc4b62bd46111b01def8c215f Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Mon, 22 Jan 2024 19:52:33 +0300 Subject: [PATCH 1/2] Nullable icon and url parsing --- .../Types/DataStructures/NotifyMessage.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Sources/WalletConnectNotify/Types/DataStructures/NotifyMessage.swift b/Sources/WalletConnectNotify/Types/DataStructures/NotifyMessage.swift index 6c88dfa7a..f34549757 100644 --- a/Sources/WalletConnectNotify/Types/DataStructures/NotifyMessage.swift +++ b/Sources/WalletConnectNotify/Types/DataStructures/NotifyMessage.swift @@ -13,13 +13,24 @@ public struct NotifyMessage: Codable, Equatable { return Date(milliseconds: sent_at) } - public init(id: String, title: String, body: String, icon: String, url: String, type: String, sentAt: Date) { + public init(id: String, title: String, body: String, icon: String?, url: String?, type: String, sentAt: Date) { self.id = id self.title = title self.body = body - self.icon = icon - self.url = url + self.icon = icon ?? "" + self.url = url ?? "" self.type = type self.sent_at = UInt64(sentAt.millisecondsSince1970) } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.id = try container.decode(String.self, forKey: .id) + self.title = try container.decode(String.self, forKey: .title) + self.body = try container.decode(String.self, forKey: .body) + self.icon = try container.decodeIfPresent(String.self, forKey: .icon) ?? "" + self.url = try container.decodeIfPresent(String.self, forKey: .url) ?? "" + self.type = try container.decode(String.self, forKey: .type) + self.sent_at = try container.decode(UInt64.self, forKey: .sent_at) + } } From 3ac1823941ecb7d2fcac7287db42b969c33d69bf Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Tue, 23 Jan 2024 13:22:31 +0300 Subject: [PATCH 2/2] testFetchHistory stability --- Example/IntegrationTests/Push/NotifyTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/IntegrationTests/Push/NotifyTests.swift b/Example/IntegrationTests/Push/NotifyTests.swift index fe1125fa9..5644fcd89 100644 --- a/Example/IntegrationTests/Push/NotifyTests.swift +++ b/Example/IntegrationTests/Push/NotifyTests.swift @@ -273,7 +273,7 @@ final class NotifyTests: XCTestCase { await fulfillment(of: [subscribeExpectation], timeout: InputConfig.defaultTimeout) try await walletNotifyClientA.fetchHistory(subscription: subscription) - XCTAssertEqual(walletNotifyClientA.getMessageHistory(topic: subscription.topic).count, 41) + XCTAssertTrue(walletNotifyClientA.getMessageHistory(topic: subscription.topic).count > 40) } }