From f71be52fc688e343a092a11d084a8d925f42b782 Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 11 Apr 2024 17:53:38 +0700 Subject: [PATCH] MOB-1891 - Updated SDKs to cover PrivacyInfo requirement (#491) * Updated WC SDK * Updated Stripe SDK * Updated XMTP SDK --- ...XMTPPushNotificationsExtensionHelper.swift | 12 ++-- .../project.pbxproj | 52 +++++++++------- .../xcshareddata/swiftpm/Package.resolved | 53 +++++++++------- .../QRScanner/QRScannerViewPresenter.swift | 12 +--- .../MessagingAPIServiceHelper.swift | 4 +- .../XMTPMessagingAPIService.swift | 20 +++---- .../XMTPMessagingWebSocketsService.swift | 2 +- .../XMTP/KeychainXMTPKeysStorage.swift | 2 +- .../XMTP/XMTPEntitiesTransformer.swift | 60 ++++++++++--------- .../XMTP/XMTPEnvironmentNamespace.swift | 2 +- .../XMTP/XMTPPushNotificationsHelper.swift | 2 +- .../XMTP/XMTPServiceHelper.swift | 12 ++-- .../NotificationsService.swift | 2 +- ....swift => WCV2DefaultCryptoProvider.swift} | 4 +- .../Services/Stripe/StripeService.swift | 1 + .../WalletConnectExternalWalletHandler.swift | 2 +- .../WalletConnectServiceV2.swift | 19 +++--- 17 files changed, 139 insertions(+), 122 deletions(-) rename unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/{WCV2NotifyDefaultCryptoProvider.swift => WCV2DefaultCryptoProvider.swift} (88%) diff --git a/unstoppable-ios-app/NotificationServiceExtension/XMTPPushNotificationsExtensionHelper.swift b/unstoppable-ios-app/NotificationServiceExtension/XMTPPushNotificationsExtensionHelper.swift index e6c338b0f..e3f4d80ea 100644 --- a/unstoppable-ios-app/NotificationServiceExtension/XMTPPushNotificationsExtensionHelper.swift +++ b/unstoppable-ios-app/NotificationServiceExtension/XMTPPushNotificationsExtensionHelper.swift @@ -6,7 +6,7 @@ // import Foundation -import XMTP +import XMTPiOS struct XMTPPushNotificationsExtensionHelper { struct NotificationDisplayInfo { @@ -32,13 +32,13 @@ struct XMTPPushNotificationsExtensionHelper { let conversationData = AppGroupsBridgeService.shared.getXMTPConversationDataFor(topic: topic, userWallet: wallet) - let conversationContainer: XMTP.ConversationContainer = try decodeConversationData(from: conversationData) + let conversationContainer: XMTPiOS.ConversationContainer = try decodeConversationData(from: conversationData) let conversation = conversationContainer.decode(with: client) address = conversation.peerAddress guard AppGroupsBridgeService.shared.getXMTPBlockedUsersList().first(where: { $0.userId == data.toAddress && $0.blockedAddress == conversation.peerAddress }) == nil else { return nil } // Ignore notification from blocked user - let envelope = XMTP.Envelope.with { envelope in + let envelope = XMTPiOS.Envelope.with { envelope in envelope.message = encryptedMessageData envelope.contentTopic = topic } @@ -82,7 +82,7 @@ private extension XMTPPushNotificationsExtensionHelper { } static func getClientFor(wallet: String, - env: XMTPEnvironment) async throws -> XMTP.Client { + env: XMTPEnvironment) async throws -> XMTPiOS.Client { if let keysData = KeychainXMTPKeysStorage.instance.getKeysDataFor(identifier: wallet, env: env) { return try await createClientUsing(keysData: keysData, env: env) } @@ -90,9 +90,9 @@ private extension XMTPPushNotificationsExtensionHelper { } static func createClientUsing(keysData: Data, - env: XMTPEnvironment) async throws -> XMTP.Client { + env: XMTPEnvironment) async throws -> XMTPiOS.Client { let keys = try PrivateKeyBundle(serializedData: keysData) - let client = try await XMTP.Client.from(bundle: keys, + let client = try await XMTPiOS.Client.from(bundle: keys, options: .init(api: .init(env: env, appVersion: XMTPServiceSharedHelper.getXMTPVersion()))) return client diff --git a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj index ce9575a08..4db35d084 100644 --- a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj +++ b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj @@ -187,6 +187,8 @@ C609831A282B707B00546392 /* UINavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6098319282B707B00546392 /* UINavigationController.swift */; }; C6098322282B8BA300546392 /* WalletViewTransactionsAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6098321282B8BA300546392 /* WalletViewTransactionsAction.swift */; }; C60A31642B464F6000C806A5 /* PreviewMessagingNewsChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60A31632B464F6000C806A5 /* PreviewMessagingNewsChannel.swift */; }; + C60BC04B2BC7806F00A79CDB /* XMTPiOS in Frameworks */ = {isa = PBXBuildFile; productRef = C60BC04A2BC7806F00A79CDB /* XMTPiOS */; }; + C60BC04D2BC7808400A79CDB /* XMTPiOS in Frameworks */ = {isa = PBXBuildFile; productRef = C60BC04C2BC7808400A79CDB /* XMTPiOS */; }; C60C298C2834E30000626851 /* GroupedCoinRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60C298B2834E30000626851 /* GroupedCoinRecord.swift */; }; C60C29912834E9C200626851 /* ResizableRoundedWalletBadgeImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60C29902834E9C200626851 /* ResizableRoundedWalletBadgeImageView.swift */; }; C60C59B22B47F97900A2522C /* PreviewLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60C59B12B47F97900A2522C /* PreviewLoginViewController.swift */; }; @@ -834,7 +836,7 @@ C651DC51286C115400808D4C /* WatchFaceDomainImagePreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C651DC50286C115400808D4C /* WatchFaceDomainImagePreviewView.swift */; }; C651DC56286C115900808D4C /* WatchFaceDomainImagePreviewView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C651DC55286C115900808D4C /* WatchFaceDomainImagePreviewView.xib */; }; C652446A2AF8A7A400673CC0 /* WalletConnectNotify in Frameworks */ = {isa = PBXBuildFile; productRef = C65244692AF8A7A400673CC0 /* WalletConnectNotify */; }; - C652446C2AF8AA2600673CC0 /* WCV2NotifyDefaultCryptoProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C652446B2AF8AA2600673CC0 /* WCV2NotifyDefaultCryptoProvider.swift */; }; + C652446C2AF8AA2600673CC0 /* WCV2DefaultCryptoProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C652446B2AF8AA2600673CC0 /* WCV2DefaultCryptoProvider.swift */; }; C652629828110B8500F1D699 /* SecurityWallViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C652629628110B8500F1D699 /* SecurityWallViewController.swift */; }; C652629C28110B8500F1D699 /* SecurityWallViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C652629728110B8500F1D699 /* SecurityWallViewController.xib */; }; C6526DB929D2BACB00D6F2EB /* UserProfileService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6526DB829D2BACB00D6F2EB /* UserProfileService.swift */; }; @@ -970,8 +972,6 @@ C66804D5280D9EC8007E6390 /* EnterPasscodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C66804BE280D9EC7007E6390 /* EnterPasscodeViewController.swift */; }; C66804D9280D9EC8007E6390 /* SetupPasscodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C66804BF280D9EC7007E6390 /* SetupPasscodeViewController.swift */; }; C66804DD280D9EC8007E6390 /* VerifyPasscodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C66804C0280D9EC7007E6390 /* VerifyPasscodeViewController.swift */; }; - C66811F52B47B1C600BDABB0 /* XMTP in Frameworks */ = {isa = PBXBuildFile; productRef = C66811F42B47B1C600BDABB0 /* XMTP */; }; - C66811F72B47B1F000BDABB0 /* XMTP in Frameworks */ = {isa = PBXBuildFile; productRef = C66811F62B47B1F000BDABB0 /* XMTP */; }; C669B44F2B747539001D4788 /* SettingsNavigationDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = C669B44E2B747539001D4788 /* SettingsNavigationDestination.swift */; }; C669B4502B747539001D4788 /* SettingsNavigationDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = C669B44E2B747539001D4788 /* SettingsNavigationDestination.swift */; }; C669B4522B747607001D4788 /* SettingsLinkNavigationDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = C669B4512B747607001D4788 /* SettingsLinkNavigationDestination.swift */; }; @@ -1011,6 +1011,7 @@ C670695628981C84001FD241 /* TextWarningButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C670695528981C84001FD241 /* TextWarningButton.swift */; }; C67097AC2BABD47E00BB8AB1 /* DebounceObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C67097AB2BABD47E00BB8AB1 /* DebounceObject.swift */; }; C67097AD2BABD47E00BB8AB1 /* DebounceObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C67097AB2BABD47E00BB8AB1 /* DebounceObject.swift */; }; + C671CD2D2BC7758B005DA2FB /* StripePaymentSheet in Frameworks */ = {isa = PBXBuildFile; productRef = C671CD2C2BC7758B005DA2FB /* StripePaymentSheet */; }; C671E38728FE85C800A2B3A0 /* CarouselView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C671E38628FE85C800A2B3A0 /* CarouselView.swift */; }; C671E38E28FE86EB00A2B3A0 /* CarouselCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C671E38C28FE86EB00A2B3A0 /* CarouselCollectionViewCell.swift */; }; C671E39228FE86EB00A2B3A0 /* CarouselCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C671E38D28FE86EB00A2B3A0 /* CarouselCollectionViewCell.xib */; }; @@ -3182,7 +3183,7 @@ C650E2952B9E9878002C120A /* UDButtonStyle+ViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UDButtonStyle+ViewModifier.swift"; sourceTree = ""; }; C651DC50286C115400808D4C /* WatchFaceDomainImagePreviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchFaceDomainImagePreviewView.swift; sourceTree = ""; }; C651DC55286C115900808D4C /* WatchFaceDomainImagePreviewView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WatchFaceDomainImagePreviewView.xib; sourceTree = ""; }; - C652446B2AF8AA2600673CC0 /* WCV2NotifyDefaultCryptoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCV2NotifyDefaultCryptoProvider.swift; sourceTree = ""; }; + C652446B2AF8AA2600673CC0 /* WCV2DefaultCryptoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCV2DefaultCryptoProvider.swift; sourceTree = ""; }; C652629628110B8500F1D699 /* SecurityWallViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityWallViewController.swift; sourceTree = ""; }; C652629728110B8500F1D699 /* SecurityWallViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SecurityWallViewController.xib; sourceTree = ""; }; C6526DB829D2BACB00D6F2EB /* UserProfileService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProfileService.swift; sourceTree = ""; }; @@ -3982,8 +3983,9 @@ C61ECD862A25AB4200E97D70 /* SocketIO in Frameworks */, 290A604C2950AA1600882109 /* WalletConnectNetworking in Frameworks */, 307B1D5A2603C8E0007B14C3 /* BigInt in Frameworks */, + C60BC04B2BC7806F00A79CDB /* XMTPiOS in Frameworks */, 290A60502950AA1600882109 /* WalletConnectPush in Frameworks */, - C66811F52B47B1C600BDABB0 /* XMTP in Frameworks */, + C671CD2D2BC7758B005DA2FB /* StripePaymentSheet in Frameworks */, 2917EDDD2A6F25AB004EAB31 /* Web3ContractABI in Frameworks */, C689C1732ADE484300AA0186 /* LaunchDarkly in Frameworks */, 290A604E2950AA1600882109 /* WalletConnectPairing in Frameworks */, @@ -4029,11 +4031,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C66811F72B47B1F000BDABB0 /* XMTP in Frameworks */, C60CB2E02A7CB62E00663989 /* web3swift in Frameworks */, C65DD4C62A7CABC700CAB10C /* Valet in Frameworks */, C6E69FA3288AB821000A8346 /* SVGKit in Frameworks */, C6E69F99288AB6DC000A8346 /* Bugsnag in Frameworks */, + C60BC04D2BC7808400A79CDB /* XMTPiOS in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -6138,7 +6140,7 @@ isa = PBXGroup; children = ( C6E69FF0288AD9DB000A8346 /* NotificationsService.swift */, - C652446B2AF8AA2600673CC0 /* WCV2NotifyDefaultCryptoProvider.swift */, + C652446B2AF8AA2600673CC0 /* WCV2DefaultCryptoProvider.swift */, C665FC1E29B06896009699D2 /* NotificationsServiceProtocol.swift */, C665FC2329B068A3009699D2 /* MockNotificationsService.swift */, ); @@ -8279,8 +8281,9 @@ C689C1722ADE484300AA0186 /* LaunchDarkly */, C65244692AF8A7A400673CC0 /* WalletConnectNotify */, C607A5CC2B3288900088ECF3 /* Amplitude */, - C66811F42B47B1C600BDABB0 /* XMTP */, C61B6C732BA0052C007408FD /* Push */, + C671CD2C2BC7758B005DA2FB /* StripePaymentSheet */, + C60BC04A2BC7806F00A79CDB /* XMTPiOS */, ); productName = "domains-manager-ios"; productReference = 3064867D2527253700388026 /* domains-manager-ios.app */; @@ -8357,7 +8360,7 @@ C6E69FA2288AB821000A8346 /* SVGKit */, C65DD4C52A7CABC700CAB10C /* Valet */, C60CB2DF2A7CB62E00663989 /* web3swift */, - C66811F62B47B1F000BDABB0 /* XMTP */, + C60BC04C2BC7808400A79CDB /* XMTPiOS */, ); productName = NotificationServiceExtension; productReference = C6E69F8A288A93D2000A8346 /* NotificationServiceExtension.appex */; @@ -9254,7 +9257,7 @@ C6010D15287EE5C700FBD401 /* BuyDomainsWebViewController.swift in Sources */, C60610D429A4FF84005DC0D5 /* WCRequestsHandlingService.swift in Sources */, C655CA972B16E51B00FDA063 /* View+Skeleton.swift in Sources */, - C652446C2AF8AA2600673CC0 /* WCV2NotifyDefaultCryptoProvider.swift in Sources */, + C652446C2AF8AA2600673CC0 /* WCV2DefaultCryptoProvider.swift in Sources */, 291A9C6A29E444CF00527FF1 /* WC_v1+v2.swift in Sources */, C655CA962B16E51B00FDA063 /* Color+Skeleton.swift in Sources */, C6D6457A2B1D7C2F00D724AC /* PullUpError.swift in Sources */, @@ -11775,7 +11778,7 @@ repositoryURL = "https://github.com/WalletConnect/WalletConnectSwiftV2"; requirement = { kind = exactVersion; - version = 1.11.0; + version = 1.18.4; }; }; 29BF9FDF2A6ED48A00EDA0DF /* XCRemoteSwiftPackageReference "Boilertalk-Web3.swift" */ = { @@ -11799,7 +11802,7 @@ repositoryURL = "https://github.com/stripe/stripe-ios"; requirement = { kind = exactVersion; - version = 22.8.4; + version = 23.27.0; }; }; 30CE604A26A9DED000E0D29B /* XCRemoteSwiftPackageReference "web3swift" */ = { @@ -11862,8 +11865,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/xmtp/xmtp-ios"; requirement = { - kind = revision; - revision = af277a00fb254a1916da8db12caf480655d4894d; + branch = 0a625c91e56538280363c43900b91266554fa515; + kind = branch; }; }; C689C1712ADE47AF00AA0186 /* XCRemoteSwiftPackageReference "ios-client-sdk" */ = { @@ -11960,6 +11963,16 @@ package = C607A5CB2B3288800088ECF3 /* XCRemoteSwiftPackageReference "Amplitude-iOS" */; productName = Amplitude; }; + C60BC04A2BC7806F00A79CDB /* XMTPiOS */ = { + isa = XCSwiftPackageProductDependency; + package = C66811F02B47B0F500BDABB0 /* XCRemoteSwiftPackageReference "xmtp-ios" */; + productName = XMTPiOS; + }; + C60BC04C2BC7808400A79CDB /* XMTPiOS */ = { + isa = XCSwiftPackageProductDependency; + package = C66811F02B47B0F500BDABB0 /* XCRemoteSwiftPackageReference "xmtp-ios" */; + productName = XMTPiOS; + }; C60CB2DF2A7CB62E00663989 /* web3swift */ = { isa = XCSwiftPackageProductDependency; package = 30CE604A26A9DED000E0D29B /* XCRemoteSwiftPackageReference "web3swift" */; @@ -11995,15 +12008,10 @@ package = C63812222993E009002590E7 /* XCRemoteSwiftPackageReference "Valet-ios" */; productName = Valet; }; - C66811F42B47B1C600BDABB0 /* XMTP */ = { - isa = XCSwiftPackageProductDependency; - package = C66811F02B47B0F500BDABB0 /* XCRemoteSwiftPackageReference "xmtp-ios" */; - productName = XMTP; - }; - C66811F62B47B1F000BDABB0 /* XMTP */ = { + C671CD2C2BC7758B005DA2FB /* StripePaymentSheet */ = { isa = XCSwiftPackageProductDependency; - package = C66811F02B47B0F500BDABB0 /* XCRemoteSwiftPackageReference "xmtp-ios" */; - productName = XMTP; + package = 30B6583726A9E75E004F707F /* XCRemoteSwiftPackageReference "stripe-ios" */; + productName = StripePaymentSheet; }; C689C1722ADE484300AA0186 /* LaunchDarkly */ = { isa = XCSwiftPackageProductDependency; diff --git a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d2ec665a7..12e2348b8 100644 --- a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -51,8 +51,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/bufbuild/connect-swift", "state" : { - "revision" : "6f5afc57f44a3ed15b9a01381ce73f84d15e43db", - "version" : "0.3.0" + "revision" : "1701d3d1b2c4c63fcccfd7094f86a88672fa5acb", + "version" : "0.12.0" } }, { @@ -91,6 +91,15 @@ "version" : "9.5.0" } }, + { + "identity" : "libxmtp-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/xmtp/libxmtp-swift", + "state" : { + "revision" : "fa57437cc1a84df566c91bbd5df1d0619d404e09", + "version" : "0.4.3-beta4" + } + }, { "identity" : "objectivepgp", "kind" : "remoteSourceControl", @@ -158,8 +167,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/stripe/stripe-ios", "state" : { - "revision" : "e242f59ce90914e93c8308e0c3ceba7368575b77", - "version" : "22.8.4" + "revision" : "febc79a4c5e02afce39d68211268cbad7c304a8f", + "version" : "23.27.0" } }, { @@ -221,8 +230,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c", - "version" : "2.62.0" + "revision" : "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982", + "version" : "2.64.0" } }, { @@ -239,8 +248,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-http2.git", "state" : { - "revision" : "3bd9004b9d685ed6b629760fc84903e48efec806", - "version" : "1.29.0" + "revision" : "0904bf0feb5122b7e5c3f15db7df0eabe623dd87", + "version" : "1.30.0" } }, { @@ -248,8 +257,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-ssl.git", "state" : { - "revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9", - "version" : "2.25.0" + "revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5", + "version" : "2.26.0" } }, { @@ -279,6 +288,15 @@ "version" : "1.0.3" } }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system.git", + "state" : { + "revision" : "025bcb1165deab2e20d4eaba79967ce73013f496", + "version" : "1.2.1" + } + }, { "identity" : "swiftimagereadwrite", "kind" : "remoteSourceControl", @@ -302,8 +320,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/WalletConnect/WalletConnectSwiftV2", "state" : { - "revision" : "232090b71756417c2ba44cda78ff57bc5ef54ca2", - "version" : "1.11.0" + "revision" : "c9ea7a1836e5a58636c3df528a21997187bd54ac", + "version" : "1.18.4" } }, { @@ -338,16 +356,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/xmtp-ios", "state" : { - "revision" : "af277a00fb254a1916da8db12caf480655d4894d" - } - }, - { - "identity" : "xmtp-rust-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/xmtp/xmtp-rust-swift", - "state" : { - "branch" : "main", - "revision" : "e08af6942841054ae02a6fe01d90d18e76d5f248" + "revision" : "0a625c91e56538280363c43900b91266554fa515" } } ], diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/QRScanner/QRScannerViewPresenter.swift b/unstoppable-ios-app/domains-manager-ios/Modules/QRScanner/QRScannerViewPresenter.swift index 6b6e70c81..028b4ca34 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/QRScanner/QRScannerViewPresenter.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/QRScanner/QRScannerViewPresenter.swift @@ -194,7 +194,7 @@ private extension QRScannerViewPresenter { if let view = self.view { await appContext.pullUpViewService.showWCInvalidQRCodePullUp(in: view) } - throw ScanningError.notSupportedQRCode + throw error } } @@ -217,13 +217,3 @@ private extension QRScannerViewPresenter { await Task.sleep(seconds: interval) } } - -extension QRScannerViewPresenter { - enum ScanningError: String, LocalizedError { - case notSupportedQRCode - case notSupportedQRCodeV2 - - public var errorDescription: String? { rawValue } - - } -} diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/MessagingAPIServiceHelper.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/MessagingAPIServiceHelper.swift index 376abfaed..d51f91f6d 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/MessagingAPIServiceHelper.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/MessagingAPIServiceHelper.swift @@ -6,11 +6,11 @@ // import Foundation -import XMTP +import XMTPiOS struct MessagingAPIServiceHelper { static func getXMTPConversationFromChat(_ chat: MessagingChat, - client: XMTP.Client) throws -> XMTP.Conversation { + client: XMTPiOS.Client) throws -> XMTPiOS.Conversation { let metadata: XMTPEnvironmentNamespace.ChatServiceMetadata = try decodeServiceMetadata(from: chat.serviceMetadata) return metadata.encodedContainer.decode(with: client) } diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/XMTPMessagingAPIService.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/XMTPMessagingAPIService.swift index 9a46a8d19..6c1c2a04e 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/XMTPMessagingAPIService.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/MessagingAPI/XMTPMessagingAPIService.swift @@ -6,7 +6,7 @@ // import Foundation -import XMTP +import XMTPiOS protocol XMTPMessagingAPIServiceDataProvider { func getPreviousMessagesForChat(_ chat: MessagingChat, @@ -52,7 +52,7 @@ extension XMTPMessagingAPIService: MessagingAPIServiceProtocol { func createUser(for wallet: WalletEntity) async throws -> MessagingChatUserProfile { let env = getCurrentXMTPEnvironment() let account = WalletXMTPSigningKey(walletEntity: wallet) - let client = try await XMTP.Client.create(account: account, + let client = try await XMTPiOS.Client.create(account: account, options: .init(api: .init(env: env, isSecure: true, appVersion: XMTPServiceSharedHelper.getXMTPVersion()))) @@ -92,7 +92,7 @@ extension XMTPMessagingAPIService: MessagingAPIServiceProtocol { } func migrateXMTPConsentsFromUDIfNeeded(for user: MessagingChatUserProfile, - client: XMTP.Client, + client: XMTPiOS.Client, using conversations: [Conversation]) async throws { if !UserDefaults.didMigrateXMTPConsentsListFromUD, @@ -309,8 +309,8 @@ extension XMTPMessagingAPIService: MessagingAPIServiceProtocol { // MARK: - Private methods private extension XMTPMessagingAPIService { func sendMessage(_ messageType: MessagingChatMessageDisplayType, - in conversation: XMTP.Conversation, - client: XMTP.Client, + in conversation: XMTPiOS.Conversation, + client: XMTPiOS.Client, chat: MessagingChat, filesService: MessagingFilesServiceProtocol) async throws -> MessagingChatMessage { let senderWallet = chat.displayInfo.thisUserDetails.wallet @@ -484,7 +484,7 @@ private extension XMTPMessagingAPIService { // MARK: - Private methods private extension XMTPMessagingAPIService { - func storeKeysDataFromClientIfNeeded(_ client: XMTP.Client, + func storeKeysDataFromClientIfNeeded(_ client: XMTPiOS.Client, wallet: WalletEntity, env: XMTPEnvironment) throws { let wallet = wallet.ethFullAddress @@ -506,7 +506,7 @@ private extension XMTPMessagingAPIService { func sendImageAttachment(data: Data, in conversation: Conversation, - client: XMTP.Client, + client: XMTPiOS.Client, by wallet: HexAddress) async throws -> String { try await sendAttachment(data: data, filename: "\(UUID().uuidString).png", @@ -520,7 +520,7 @@ private extension XMTPMessagingAPIService { filename: String, mimeType: String, in conversation: Conversation, - client: XMTP.Client, + client: XMTPiOS.Client, by wallet: HexAddress) async throws -> String { let attachment = Attachment(filename: filename, mimeType: mimeType, @@ -568,11 +568,11 @@ private struct WalletXMTPSigningKey { } extension WalletXMTPSigningKey: SigningKey { - func sign(_ data: Data) async throws -> XMTP.Signature { + func sign(_ data: Data) async throws -> XMTPiOS.Signature { try await sign(message: HexAddress.hexPrefix + data.dataToHexString()) } - func sign(message: String) async throws -> XMTP.Signature { + func sign(message: String) async throws -> XMTPiOS.Signature { let newMess = "0x" + Data(message.utf8).toHexString() let sign = try await udWallet.getPersonalSignature(messageString: newMess, shouldTryToConverToReadable: false) var bytes = sign.hexToBytes() diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/WebSockets/XMTPMessagingWebSocketsService.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/WebSockets/XMTPMessagingWebSocketsService.swift index cd8c4b6f8..545dd0970 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/WebSockets/XMTPMessagingWebSocketsService.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/SubServices/WebSockets/XMTPMessagingWebSocketsService.swift @@ -6,7 +6,7 @@ // import Foundation -import XMTP +import XMTPiOS final class XMTPMessagingWebSocketsService { typealias ConversationStream = AsyncThrowingStream diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/KeychainXMTPKeysStorage.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/KeychainXMTPKeysStorage.swift index 6493397f3..8073d653b 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/KeychainXMTPKeysStorage.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/KeychainXMTPKeysStorage.swift @@ -7,7 +7,7 @@ import Foundation import Valet -import XMTP +import XMTPiOS protocol KeychainXMTPKeysStorageProtocol { func saveKeysData(_ keysData: Data, diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEntitiesTransformer.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEntitiesTransformer.swift index b2cf942aa..e6e144c9d 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEntitiesTransformer.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEntitiesTransformer.swift @@ -6,11 +6,11 @@ // import UIKit -import XMTP +import XMTPiOS struct XMTPEntitiesTransformer { - static func convertXMTPClientToChatUser(_ client: XMTP.Client) -> MessagingChatUserProfile { + static func convertXMTPClientToChatUser(_ client: XMTPiOS.Client) -> MessagingChatUserProfile { let wallet = client.address let userId = client.address let displayInfo = MessagingChatUserProfileDisplayInfo(id: userId, @@ -28,7 +28,7 @@ struct XMTPEntitiesTransformer { } - static func convertXMTPChatToChat(_ xmtpChat: XMTP.Conversation, + static func convertXMTPChatToChat(_ xmtpChat: XMTPiOS.Conversation, userId: String, userWallet: String, isApproved: Bool) -> MessagingChat? { @@ -63,23 +63,27 @@ struct XMTPEntitiesTransformer { isApproved: isApproved, lastMessageTime: lastMessageTime, lastMessage: nil) - - let metadataModel = XMTPEnvironmentNamespace.ChatServiceMetadata(encodedContainer: xmtpChat.encodedContainer) - - // Bridging for PNs - AppGroupsBridgeService.shared.saveXMTPConversationData(conversationData: xmtpChat.encodedContainer.jsonData(), - topic: xmtpChat.topic, - userWallet: userWallet) - // - - let serviceMetadata = metadataModel.jsonData() - let chat = MessagingChat(userId: userId, - displayInfo: displayInfo, - serviceMetadata: serviceMetadata) - return chat + do { + let container = try xmtpChat.encodedContainer() + let metadataModel = XMTPEnvironmentNamespace.ChatServiceMetadata(encodedContainer: container) + + // Bridging for PNs + AppGroupsBridgeService.shared.saveXMTPConversationData(conversationData: container.jsonData(), + topic: xmtpChat.topic, + userWallet: userWallet) + // + + let serviceMetadata = metadataModel.jsonData() + let chat = MessagingChat(userId: userId, + displayInfo: displayInfo, + serviceMetadata: serviceMetadata) + return chat + } catch { + return nil + } } - static func convertXMTPMessageToChatMessage(_ xmtpMessage: XMTP.DecodedMessage, + static func convertXMTPMessageToChatMessage(_ xmtpMessage: XMTPiOS.DecodedMessage, cachedMessage: MessagingChatMessage?, in chat: MessagingChat, isRead: Bool, @@ -131,7 +135,7 @@ struct XMTPEntitiesTransformer { } - private static func extractMessageType(from xmtpMessage: XMTP.DecodedMessage, + private static func extractMessageType(from xmtpMessage: XMTPiOS.DecodedMessage, messageId: String, userId: String, filesService: MessagingFilesServiceProtocol) async -> MessagingChatMessageDisplayType { @@ -143,13 +147,13 @@ struct XMTPEntitiesTransformer { let textDisplayInfo = MessagingChatMessageTextTypeDisplayInfo(text: decryptedContent) return .text(textDisplayInfo) case .attachment: - let attachment: XMTP.Attachment = try xmtpMessage.content() + let attachment: XMTPiOS.Attachment = try xmtpMessage.content() return try await getMessageTypeFor(attachment: attachment, messageId: messageId, userId: userId, filesService: filesService) case .remoteStaticAttachment: - let remoteAttachment: XMTP.RemoteAttachment = try xmtpMessage.content() + let remoteAttachment: XMTPiOS.RemoteAttachment = try xmtpMessage.content() let attachmentProperties = RemoteAttachmentProperties(remoteAttachment: remoteAttachment) let serviceData = try attachmentProperties.jsonDataThrowing() let displayInfo = MessagingChatMessageRemoteContentTypeDisplayInfo(serviceData: serviceData) @@ -171,11 +175,11 @@ struct XMTPEntitiesTransformer { } } - static func XMTPMessageTypeIDFrom(_ xmtpMessage: XMTP.DecodedMessage) -> String { + static func XMTPMessageTypeIDFrom(_ xmtpMessage: XMTPiOS.DecodedMessage) -> String { xmtpMessage.encodedContent.type.typeID } - static func XMTPMessageKnownTypeFrom(_ xmtpMessage: XMTP.DecodedMessage) -> XMTPEnvironmentNamespace.KnownType? { + static func XMTPMessageKnownTypeFrom(_ xmtpMessage: XMTPiOS.DecodedMessage) -> XMTPEnvironmentNamespace.KnownType? { XMTPEnvironmentNamespace.KnownType(rawValue: XMTPMessageTypeIDFrom(xmtpMessage)) } @@ -201,7 +205,7 @@ struct XMTPEntitiesTransformer { } } - static func convertXMTPMessageToWebSocketMessageEntity(_ xmtpMessage: XMTP.DecodedMessage, + static func convertXMTPMessageToWebSocketMessageEntity(_ xmtpMessage: XMTPiOS.DecodedMessage, peerAddress: String, userAddress: String) -> MessagingWebSocketMessageEntity { let id = xmtpMessage.id @@ -253,7 +257,7 @@ struct XMTPEntitiesTransformer { static func loadRemoteContentFrom(data: Data, messageId: String, userId: String, - client: XMTP.Client, + client: XMTPiOS.Client, filesService: MessagingFilesServiceProtocol) async throws -> MessagingChatMessageDisplayType { let remoteAttachmentProperties = try RemoteAttachmentProperties.objectFromDataThrowing(data) let remoteAttachment = try remoteAttachmentProperties.createRemoteAttachment() @@ -273,7 +277,7 @@ struct XMTPEntitiesTransformer { let nonce: Data let scheme: String - init(remoteAttachment: XMTP.RemoteAttachment) { + init(remoteAttachment: XMTPiOS.RemoteAttachment) { self.url = remoteAttachment.url self.contentDigest = remoteAttachment.contentDigest self.secret = remoteAttachment.secret @@ -282,8 +286,8 @@ struct XMTPEntitiesTransformer { self.scheme = remoteAttachment.scheme.rawValue } - func createRemoteAttachment() throws -> XMTP.RemoteAttachment { - try XMTP.RemoteAttachment(url: url, + func createRemoteAttachment() throws -> XMTPiOS.RemoteAttachment { + try XMTPiOS.RemoteAttachment(url: url, contentDigest: contentDigest, secret: secret, salt: salt, diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEnvironmentNamespace.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEnvironmentNamespace.swift index a4f719062..22b3e3ffc 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEnvironmentNamespace.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPEnvironmentNamespace.swift @@ -6,7 +6,7 @@ // import Foundation -import XMTP +import XMTPiOS enum XMTPEnvironmentNamespace { diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPPushNotificationsHelper.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPPushNotificationsHelper.swift index d7010f50f..61de1a58f 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPPushNotificationsHelper.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPPushNotificationsHelper.swift @@ -6,7 +6,7 @@ // import Foundation -import XMTP +import XMTPiOS import web3 struct XMTPPushNotificationsHelper { diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPServiceHelper.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPServiceHelper.swift index 39e813902..ddb7a46f3 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPServiceHelper.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/XMTP/XMTPServiceHelper.swift @@ -6,7 +6,7 @@ // import Foundation -import XMTP +import XMTPiOS struct XMTPServiceHelper { static func getCurrentXMTPEnvironment() -> XMTPEnvironment { @@ -15,19 +15,19 @@ struct XMTPServiceHelper { } static func getClientFor(user: MessagingChatUserProfile, - env: XMTPEnvironment) async throws -> XMTP.Client { + env: XMTPEnvironment) async throws -> XMTPiOS.Client { let wallet = user.wallet return try await getClientFor(wallet: wallet, env: env) } static func getClientFor(domain: DomainItem, - env: XMTPEnvironment) async throws -> XMTP.Client { + env: XMTPEnvironment) async throws -> XMTPiOS.Client { let wallet = try domain.getETHAddressThrowing() return try await getClientFor(wallet: wallet, env: env) } static func getClientFor(wallet: String, - env: XMTPEnvironment) async throws -> XMTP.Client { + env: XMTPEnvironment) async throws -> XMTPiOS.Client { if let keysData = KeychainXMTPKeysStorage.instance.getKeysDataFor(identifier: wallet, env: env) { return try await createClientUsing(keysData: keysData, env: env) } @@ -35,9 +35,9 @@ struct XMTPServiceHelper { } static func createClientUsing(keysData: Data, - env: XMTPEnvironment) async throws -> XMTP.Client { + env: XMTPEnvironment) async throws -> XMTPiOS.Client { let keys = try PrivateKeyBundle(serializedData: keysData) - let client = try await XMTP.Client.from(bundle: keys, + let client = try await XMTPiOS.Client.from(bundle: keys, options: .init(api: .init(env: env, appVersion: XMTPServiceSharedHelper.getXMTPVersion()))) client.register(codec: AttachmentCodec()) diff --git a/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/NotificationsService.swift b/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/NotificationsService.swift index 580ea0ebb..e338098ee 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/NotificationsService.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/NotificationsService.swift @@ -167,7 +167,7 @@ fileprivate extension NotificationsService { environment = .production #endif Notify.configure(environment: environment, - crypto: WCV2NotifyDefaultCryptoProvider()) + crypto: WCV2DefaultCryptoProvider()) #if DEBUG Notify.instance.setLogging(level: .debug) #endif diff --git a/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/WCV2NotifyDefaultCryptoProvider.swift b/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/WCV2DefaultCryptoProvider.swift similarity index 88% rename from unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/WCV2NotifyDefaultCryptoProvider.swift rename to unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/WCV2DefaultCryptoProvider.swift index 7c955ab7d..e2b0718cf 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/WCV2NotifyDefaultCryptoProvider.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/NotificationsService/WCV2DefaultCryptoProvider.swift @@ -1,5 +1,5 @@ // -// WCV2NotifyDefaultCryptoProvider.swift +// WCV2DefaultCryptoProvider.swift // domains-manager-ios // // Created by Oleg Kuplin on 06.11.2023. @@ -10,7 +10,7 @@ import CryptoSwift import Boilertalk_Web3 import WalletConnectNotify -struct WCV2NotifyDefaultCryptoProvider: CryptoProvider { +struct WCV2DefaultCryptoProvider: CryptoProvider { public func recoverPubKey(signature: EthereumSignature, message: Data) throws -> Data { let publicKey = try EthereumPublicKey( diff --git a/unstoppable-ios-app/domains-manager-ios/Services/Stripe/StripeService.swift b/unstoppable-ios-app/domains-manager-ios/Services/Stripe/StripeService.swift index 517faf729..3362ba929 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/Stripe/StripeService.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/Stripe/StripeService.swift @@ -7,6 +7,7 @@ import Foundation import Stripe +import StripePaymentSheet import PassKit final class StripeService: NSObject { diff --git a/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectExternalWalletHandler/WalletConnectExternalWalletHandler.swift b/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectExternalWalletHandler/WalletConnectExternalWalletHandler.swift index 82103adf0..3152fa55f 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectExternalWalletHandler/WalletConnectExternalWalletHandler.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectExternalWalletHandler/WalletConnectExternalWalletHandler.swift @@ -60,7 +60,7 @@ extension WalletConnectExternalWalletHandler { guard let chain = Blockchain(chainId: chainId) else { throw WalletConnectRequestError.failedToDetermineChainId } - let request = WalletConnectSign.Request(topic: session.topic, method: method.string, params: requestParams, chainId: chain) + let request = try WalletConnectSign.Request(topic: session.topic, method: method.string, params: requestParams, chainId: chain) try await Sign.instance.request(params: request) try await launchExternalWalletAndNotifyListeners(wallet) return try await withCheckedThrowingContinuation({ (continuation: CheckedContinuation) in diff --git a/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectService_V2/WalletConnectServiceV2.swift b/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectService_V2/WalletConnectServiceV2.swift index c99c12a0e..2bc389d64 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectService_V2/WalletConnectServiceV2.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/WalletConnect/WalletConnectService_V2/WalletConnectServiceV2.swift @@ -167,7 +167,6 @@ class WalletConnectServiceV2: WalletConnectServiceV2Protocol, WalletConnectV2Pub // try? Sign.instance.cleanup() // try? Pair.instance.cleanup() // clientConnectionsV2.removeAll() - let settledSessions = Sign.instance.getSessions() #if DEBUG Debugger.printInfo(topic: .WalletConnectV2, "Connected sessions:\n\(settledSessions)") @@ -260,6 +259,7 @@ class WalletConnectServiceV2: WalletConnectServiceV2Protocol, WalletConnectV2Pub } private func configure() { + Sign.configure(crypto: WCV2DefaultCryptoProvider()) Networking.configure(groupIdentifier: Constants.UnstoppableGroupIdentifier, projectId: AppIdentificators.wc2ProjectId, socketFactory: SocketFactory()) @@ -527,7 +527,7 @@ class WalletConnectServiceV2: WalletConnectServiceV2Protocol, WalletConnectV2Pub } func getWCV2Request(for code: QRCode) throws -> WalletConnectURI { - guard let uri = WalletConnectURI(string: code) else { throw QRScannerViewPresenter.ScanningError.notSupportedQRCodeV2 } + let uri = try WalletConnectURI(uriString: code) return uri } @@ -536,7 +536,7 @@ class WalletConnectServiceV2: WalletConnectServiceV2Protocol, WalletConnectV2Pub Debugger.printInfo(topic: .WalletConnectV2, "[WALLET] Reject Session: \(proposalId)") Task { do { - try await Sign.instance.reject(proposalId: proposalId, reason: reason) + try await Sign.instance.rejectSession(proposalId: proposalId, reason: reason) } catch { Debugger.printFailure("[DAPP] Reject Session error: \(error)") } @@ -546,16 +546,21 @@ class WalletConnectServiceV2: WalletConnectServiceV2Protocol, WalletConnectV2Pub // when user approves proposal func didApproveSession(_ proposal: SessionV2.Proposal, accountAddress: HexAddress) { var sessionNamespaces = [String: SessionNamespace]() - let spaces = proposal.requiredNamespaces.merging(proposal.optionalNamespaces ?? [:]) { (current, new) in ProposalNamespace(chains: (current.chains ?? Set() ).union(new.chains ?? Set()), - methods: current.methods.union(new.methods), - events: current.events.union(new.events)) } + let spaces = proposal.requiredNamespaces.merging(proposal.optionalNamespaces ?? [:]) { (current, new) in + let currentChains = Set(current.chains ?? []) + let newChains = Set(new.chains ?? []) + let mergedChains = currentChains.union(newChains) + return ProposalNamespace(chains: Array(mergedChains), + methods: current.methods.union(new.methods), + events: current.events.union(new.events)) + } spaces.forEach { let caip2Namespace = $0.key let proposalNamespace = $0.value guard let chains = proposalNamespace.chains else { return } let methods = proposalNamespace.methods - let accounts = Set(chains.compactMap { Account($0.absoluteString + ":\(accountAddress)") }) + let accounts = chains.compactMap { Account($0.absoluteString + ":\(accountAddress)") } let sessionNamespace = SessionNamespace(chains: chains, accounts: accounts,