From 150cfe25ec3b19991329aaf71cd83c94c5f8d5f2 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Tue, 5 Dec 2023 12:43:10 +0100 Subject: [PATCH 1/8] add PairingDeleteRequestSubscriber --- .../xcshareddata/swiftpm/Package.resolved | 4 +- .../Notifications/NotificationsView.swift | 2 +- .../WalletConnectPairing/PairingClient.swift | 11 +++-- .../PairingClientFactory.swift | 4 +- .../RPCParams/PairingDeleteParams.swift | 7 +++ .../PairingDeleteRequestSubscriber.swift | 43 +++++++++++++++++++ .../PairingDeleteRequester.swift} | 2 +- 7 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 Sources/WalletConnectPairing/RPCParams/PairingDeleteParams.swift create mode 100644 Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequestSubscriber.swift rename Sources/WalletConnectPairing/Services/Common/{DeletePairingService.swift => Delete/PairingDeleteRequester.swift} (97%) diff --git a/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 465b92c16..229e0f8ef 100644 --- a/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -168,8 +168,8 @@ "repositoryURL": "https://github.com/WalletConnect/web3modal-swift", "state": { "branch": null, - "revision": "3295d69d1b12df29a5040578d107f56986b1b399", - "version": "1.0.13" + "revision": "e68c1b1560264965ca13608db44294d301c6404f", + "version": "1.0.9" } } ] diff --git a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift index a3146cbd8..3ced27e6b 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift @@ -191,7 +191,7 @@ struct NotificationsView: View { AsyncButton("Subscribed") { try await presenter.unsubscribe(subscription: subscription) } - .buttonStyle(W3MButtonStyle(size: .m, variant: .accent, rightIcon: Image.Medium.checkmark)) + .buttonStyle(W3MButtonStyle(size: .m, variant: .accent, rightIcon: Image.Checkmark)) .disabled(true) } else { AsyncButton("Subscribe") { diff --git a/Sources/WalletConnectPairing/PairingClient.swift b/Sources/WalletConnectPairing/PairingClient.swift index c9ca77413..43164c16f 100644 --- a/Sources/WalletConnectPairing/PairingClient.swift +++ b/Sources/WalletConnectPairing/PairingClient.swift @@ -17,9 +17,10 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient private let networkingInteractor: NetworkInteracting private let pairingRequestsSubscriber: PairingRequestsSubscriber private let pairingsProvider: PairingsProvider - private let deletePairingService: DeletePairingService + private let pairingDeleteRequester: PairingDeleteRequester private let resubscribeService: PairingResubscribeService private let expirationService: ExpirationService + private let pairingDeleteRequestSubscriber: PairingDeleteRequestSubscriber private let cleanupService: PairingCleanupService @@ -33,7 +34,8 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient networkingInteractor: NetworkInteracting, logger: ConsoleLogging, walletPairService: WalletPairService, - deletePairingService: DeletePairingService, + pairingDeleteRequester: PairingDeleteRequester, + pairingDeleteRequestSubscriber: PairingDeleteRequestSubscriber, resubscribeService: PairingResubscribeService, expirationService: ExpirationService, pairingRequestsSubscriber: PairingRequestsSubscriber, @@ -49,7 +51,8 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient self.networkingInteractor = networkingInteractor self.socketConnectionStatusPublisher = socketConnectionStatusPublisher self.logger = logger - self.deletePairingService = deletePairingService + self.pairingDeleteRequester = pairingDeleteRequester + self.pairingDeleteRequestSubscriber = pairingDeleteRequestSubscriber self.appPairActivateService = appPairActivateService self.resubscribeService = resubscribeService self.expirationService = expirationService @@ -112,7 +115,7 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient } public func disconnect(topic: String) async throws { - try await deletePairingService.delete(topic: topic) + try await pairingDeleteRequester.delete(topic: topic) } public func validatePairingExistance(_ topic: String) throws { diff --git a/Sources/WalletConnectPairing/PairingClientFactory.swift b/Sources/WalletConnectPairing/PairingClientFactory.swift index d24b76adb..e57c53114 100644 --- a/Sources/WalletConnectPairing/PairingClientFactory.swift +++ b/Sources/WalletConnectPairing/PairingClientFactory.swift @@ -30,7 +30,7 @@ public struct PairingClientFactory { let pairingRequestsSubscriber = PairingRequestsSubscriber(networkingInteractor: networkingClient, pairingStorage: pairingStore, logger: logger) let pairingsProvider = PairingsProvider(pairingStorage: pairingStore) let cleanupService = PairingCleanupService(pairingStore: pairingStore, kms: kms) - let deletePairingService = DeletePairingService(networkingInteractor: networkingClient, kms: kms, pairingStorage: pairingStore, logger: logger) + let pairingDeleteRequester = PairingDeleteRequester(networkingInteractor: networkingClient, kms: kms, pairingStorage: pairingStore, logger: logger) let pingService = PairingPingService(pairingStorage: pairingStore, networkingInteractor: networkingClient, logger: logger) let appPairActivateService = AppPairActivationService(pairingStorage: pairingStore, logger: logger) let expirationService = ExpirationService(pairingStorage: pairingStore, networkInteractor: networkingClient, kms: kms) @@ -42,7 +42,7 @@ public struct PairingClientFactory { networkingInteractor: networkingClient, logger: logger, walletPairService: walletPairService, - deletePairingService: deletePairingService, + pairingDeleteRequester: pairingDeleteRequester, resubscribeService: resubscribeService, expirationService: expirationService, pairingRequestsSubscriber: pairingRequestsSubscriber, diff --git a/Sources/WalletConnectPairing/RPCParams/PairingDeleteParams.swift b/Sources/WalletConnectPairing/RPCParams/PairingDeleteParams.swift new file mode 100644 index 000000000..6f3495514 --- /dev/null +++ b/Sources/WalletConnectPairing/RPCParams/PairingDeleteParams.swift @@ -0,0 +1,7 @@ + +import Foundation + +struct PairingDeleteParams: Codable { + let code: Int + let message: String +} diff --git a/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequestSubscriber.swift b/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequestSubscriber.swift new file mode 100644 index 000000000..ab81a5266 --- /dev/null +++ b/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequestSubscriber.swift @@ -0,0 +1,43 @@ +import Combine + +public final class PairingDeleteRequestSubscriber { + private let networkingInteractor: NetworkInteracting + private let logger: ConsoleLogging + private let pairingStorage: WCPairingStorage + private let kms: KeyManagementServiceProtocol + let deletePublisherSubject = PassthroughSubject<(code: Int, message: String), Never>() + + private var publishers = [AnyCancellable]() + + public init( + networkingInteractor: NetworkInteracting, + kms: KeyManagementServiceProtocol, + pairingStorage: WCPairingStorage, + logger: ConsoleLogging + ) { + self.networkingInteractor = networkingInteractor + self.kms = kms + self.pairingStorage = pairingStorage + self.logger = logger + subscribeDeleteRequest() + } + + private func subscribeDeleteRequest() { + let method = PairingProtocolMethod.delete + networkingInteractor.requestSubscription(on: method) + .sink { [unowned self] (payload: RequestSubscriptionPayload) in + + let topic = payload.topic + logger.debug("Received pairing delete request") + pairingStorage.delete(topic: topic) + kms.deleteSymmetricKey(for: topic) + networkingInteractor.unsubscribe(topic: topic) + + deletePublisherSubject.send((code: payload.request.code, message: payload.request.message)) + Task(priority: .high) { + try? await networkingInteractor.respondSuccess(topic: payload.topic, requestId: payload.id, protocolMethod: method) + } + } + .store(in: &publishers) + } +} diff --git a/Sources/WalletConnectPairing/Services/Common/DeletePairingService.swift b/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequester.swift similarity index 97% rename from Sources/WalletConnectPairing/Services/Common/DeletePairingService.swift rename to Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequester.swift index afa43e517..7f5d10cbd 100644 --- a/Sources/WalletConnectPairing/Services/Common/DeletePairingService.swift +++ b/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequester.swift @@ -1,6 +1,6 @@ import Foundation -class DeletePairingService { +class PairingDeleteRequester { private let networkingInteractor: NetworkInteracting private let kms: KeyManagementServiceProtocol private let pairingStorage: WCPairingStorage From ccab7b7932270b49af02aa94627c6946674a912e Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Tue, 5 Dec 2023 12:46:53 +0100 Subject: [PATCH 2/8] add pairingDeletePublisher --- Sources/WalletConnectPairing/PairingClient.swift | 4 ++++ Sources/WalletConnectPairing/PairingClientFactory.swift | 2 ++ Sources/WalletConnectPairing/PairingClientProtocol.swift | 1 + Sources/Web3Wallet/Web3WalletClient.swift | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/Sources/WalletConnectPairing/PairingClient.swift b/Sources/WalletConnectPairing/PairingClient.swift index 43164c16f..16d8f0076 100644 --- a/Sources/WalletConnectPairing/PairingClient.swift +++ b/Sources/WalletConnectPairing/PairingClient.swift @@ -5,6 +5,10 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient public var pingResponsePublisher: AnyPublisher<(String), Never> { pingResponsePublisherSubject.eraseToAnyPublisher() } + public var pairingDeletePublisher: AnyPublisher<(code: Int, message: String), Never> { + pairingDeleteRequestSubscriber.deletePublisherSubject.eraseToAnyPublisher() + } + public let socketConnectionStatusPublisher: AnyPublisher private let pairingStorage: WCPairingStorage diff --git a/Sources/WalletConnectPairing/PairingClientFactory.swift b/Sources/WalletConnectPairing/PairingClientFactory.swift index e57c53114..902ba7d28 100644 --- a/Sources/WalletConnectPairing/PairingClientFactory.swift +++ b/Sources/WalletConnectPairing/PairingClientFactory.swift @@ -35,6 +35,7 @@ public struct PairingClientFactory { let appPairActivateService = AppPairActivationService(pairingStorage: pairingStore, logger: logger) let expirationService = ExpirationService(pairingStorage: pairingStore, networkInteractor: networkingClient, kms: kms) let resubscribeService = PairingResubscribeService(networkInteractor: networkingClient, pairingStorage: pairingStore) + let pairingDeleteRequestSubscriber = PairingDeleteRequestSubscriber(networkingInteractor: networkingClient, kms: kms, pairingStorage: pairingStore, logger: logger) return PairingClient( pairingStorage: pairingStore, @@ -43,6 +44,7 @@ public struct PairingClientFactory { logger: logger, walletPairService: walletPairService, pairingDeleteRequester: pairingDeleteRequester, + pairingDeleteRequestSubscriber: pairingDeleteRequestSubscriber, resubscribeService: resubscribeService, expirationService: expirationService, pairingRequestsSubscriber: pairingRequestsSubscriber, diff --git a/Sources/WalletConnectPairing/PairingClientProtocol.swift b/Sources/WalletConnectPairing/PairingClientProtocol.swift index e025f7fd6..7edd05b30 100644 --- a/Sources/WalletConnectPairing/PairingClientProtocol.swift +++ b/Sources/WalletConnectPairing/PairingClientProtocol.swift @@ -2,6 +2,7 @@ import Combine public protocol PairingClientProtocol { var logsPublisher: AnyPublisher {get} + var pairingDeletePublisher: AnyPublisher<(code: Int, message: String), Never> {get} func pair(uri: WalletConnectURI) async throws func disconnect(topic: String) async throws func getPairings() -> [Pairing] diff --git a/Sources/Web3Wallet/Web3WalletClient.swift b/Sources/Web3Wallet/Web3WalletClient.swift index 38fc6d213..75e4a7dff 100644 --- a/Sources/Web3Wallet/Web3WalletClient.swift +++ b/Sources/Web3Wallet/Web3WalletClient.swift @@ -63,6 +63,10 @@ public class Web3WalletClient { signClient.sessionResponsePublisher.eraseToAnyPublisher() } + public var pairingDeletePublisher: AnyPublisher<(code: Int, message: String), Never> { + pairingClient.pairingDeletePublisher + } + public var logsPublisher: AnyPublisher { return signClient.logsPublisher .merge(with: pairingClient.logsPublisher) From be6cd029afa5d96937668eea89c930e26b9ef303 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Tue, 5 Dec 2023 14:16:05 +0100 Subject: [PATCH 3/8] refactor pairing tests --- .../Pairing/PairingTests.swift | 85 ++++++------------- 1 file changed, 28 insertions(+), 57 deletions(-) diff --git a/Example/IntegrationTests/Pairing/PairingTests.swift b/Example/IntegrationTests/Pairing/PairingTests.swift index bbea6aa46..26f0554de 100644 --- a/Example/IntegrationTests/Pairing/PairingTests.swift +++ b/Example/IntegrationTests/Pairing/PairingTests.swift @@ -23,13 +23,11 @@ final class PairingTests: XCTestCase { private var publishers = [AnyCancellable]() - func makeClientDependencies(prefix: String) -> (PairingClient, NetworkingInteractor, KeychainStorageProtocol, KeyValueStorage) { + func makeClients(prefix: String) -> (PairingClient, AuthClient) { let keychain = KeychainStorageMock() let keyValueStorage = RuntimeKeyValueStorage() - let relayLogger = ConsoleLogger(prefix: prefix + " [Relay]", loggingLevel: .debug) - let pairingLogger = ConsoleLogger(prefix: prefix + " [Pairing]", loggingLevel: .debug) - let networkingLogger = ConsoleLogger(prefix: prefix + " [Networking]", loggingLevel: .debug) + let logger = ConsoleLogger(prefix: name, loggingLevel: .debug) let relayClient = RelayClientFactory.create( relayHost: InputConfig.relayHost, @@ -37,81 +35,45 @@ final class PairingTests: XCTestCase { keyValueStorage: RuntimeKeyValueStorage(), keychainStorage: keychain, socketFactory: DefaultSocketFactory(), - logger: relayLogger) + logger: logger) let networkingClient = NetworkingClientFactory.create( relayClient: relayClient, - logger: networkingLogger, + logger: logger, keychainStorage: keychain, keyValueStorage: keyValueStorage) let pairingClient = PairingClientFactory.create( - logger: pairingLogger, + logger: logger, keyValueStorage: keyValueStorage, keychainStorage: keychain, networkingClient: networkingClient) - let clientId = try! networkingClient.getClientId() - networkingLogger.debug("My client id is: \(clientId)") - - return (pairingClient, networkingClient, keychain, keyValueStorage) - } - func makeDappClients() { - let prefix = "🤖 Dapp: " - let (pairingClient, networkingInteractor, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix) - let notifyLogger = ConsoleLogger(prefix: prefix + " [Notify]", loggingLevel: .debug) - appPairingClient = pairingClient - - appAuthClient = AuthClientFactory.create( - metadata: AppMetadata(name: name, description: "", url: "", icons: [""], redirect: AppMetadata.Redirect(native: "wcdapp://", universal: nil)), - projectId: InputConfig.projectId, - crypto: DefaultCryptoProvider(), - logger: notifyLogger, - keyValueStorage: keyValueStorage, - keychainStorage: keychain, - networkingClient: networkingInteractor, - pairingRegisterer: pairingClient, - iatProvider: IATProviderMock()) - } - func makeWalletClients() { - let prefix = "🐶 Wallet: " - let (pairingClient, networkingInteractor, keychain, keyValueStorage) = makeClientDependencies(prefix: prefix) - let notifyLogger = ConsoleLogger(prefix: prefix + " [Notify]", loggingLevel: .debug) - let defaults = RuntimeKeyValueStorage() - walletPairingClient = pairingClient - let historyClient = HistoryClientFactory.create( - historyUrl: "https://history.walletconnect.com", - relayUrl: "wss://relay.walletconnect.com", - keyValueStorage: defaults, - keychain: keychain, - logger: notifyLogger - ) - appAuthClient = AuthClientFactory.create( + let clientId = try! networkingClient.getClientId() + logger.debug("My client id is: \(clientId)") + + let authClient = AuthClientFactory.create( metadata: AppMetadata(name: name, description: "", url: "", icons: [""], redirect: AppMetadata.Redirect(native: "", universal: nil)), projectId: InputConfig.projectId, crypto: DefaultCryptoProvider(), - logger: notifyLogger, + logger: logger, keyValueStorage: keyValueStorage, keychainStorage: keychain, - networkingClient: networkingInteractor, + networkingClient: networkingClient, pairingRegisterer: pairingClient, iatProvider: IATProviderMock()) - } - func makeWalletPairingClient() { - let prefix = "🐶 Wallet: " - let (pairingClient, _, _, _) = makeClientDependencies(prefix: prefix) - walletPairingClient = pairingClient + return (pairingClient, authClient) } override func setUp() { - makeDappClients() + (appPairingClient, appAuthClient) = makeClients(prefix: "🤖 Dapp: ") + (walletPairingClient, walletAuthClient) = makeClients(prefix: "🐶 Wallet: ") } func testPing() async { let expectation = expectation(description: "expects ping response") - makeWalletClients() let uri = try! await appPairingClient.create() try? await walletPairingClient.pair(uri: uri) try! await walletPairingClient.ping(topic: uri.topic) @@ -124,7 +86,6 @@ final class PairingTests: XCTestCase { } func testResponseErrorForMethodUnregistered() async { - makeWalletPairingClient() let expectation = expectation(description: "wallet responds unsupported method for unregistered method") appAuthClient.authResponsePublisher.sink { (_, response) in @@ -140,8 +101,18 @@ final class PairingTests: XCTestCase { wait(for: [expectation], timeout: InputConfig.defaultTimeout) } - - func testDisconnect() { - // TODO - } +// +// func testDisconnect() { +// +// let expectation = expectation(description: "wallet responds unsupported method for unregistered method") +// +// appAuthClient.authResponsePublisher.sink { (_, response) in +// XCTAssertEqual(response, .failure(AuthError(code: 10001)!)) +// expectation.fulfill() +// }.store(in: &publishers) +// +// let uri = try! await appPairingClient.create() +// +// try? await walletPairingClient.pair(uri: uri) +// } } From 019c5910848b9f3e510ff6dbaa625025a5b0db95 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Wed, 6 Dec 2023 10:23:56 +0100 Subject: [PATCH 4/8] fix tests --- .../Pairing/PairingTests.swift | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Example/IntegrationTests/Pairing/PairingTests.swift b/Example/IntegrationTests/Pairing/PairingTests.swift index 26f0554de..1a064f154 100644 --- a/Example/IntegrationTests/Pairing/PairingTests.swift +++ b/Example/IntegrationTests/Pairing/PairingTests.swift @@ -23,11 +23,11 @@ final class PairingTests: XCTestCase { private var publishers = [AnyCancellable]() - func makeClients(prefix: String) -> (PairingClient, AuthClient) { + func makeClients(prefix: String, includeAuth: Bool = true) -> (PairingClient, AuthClient?) { let keychain = KeychainStorageMock() let keyValueStorage = RuntimeKeyValueStorage() - let logger = ConsoleLogger(prefix: name, loggingLevel: .debug) + let logger = ConsoleLogger(prefix: prefix, loggingLevel: .debug) let relayClient = RelayClientFactory.create( relayHost: InputConfig.relayHost, @@ -53,23 +53,27 @@ final class PairingTests: XCTestCase { let clientId = try! networkingClient.getClientId() logger.debug("My client id is: \(clientId)") - let authClient = AuthClientFactory.create( - metadata: AppMetadata(name: name, description: "", url: "", icons: [""], redirect: AppMetadata.Redirect(native: "", universal: nil)), - projectId: InputConfig.projectId, - crypto: DefaultCryptoProvider(), - logger: logger, - keyValueStorage: keyValueStorage, - keychainStorage: keychain, - networkingClient: networkingClient, - pairingRegisterer: pairingClient, - iatProvider: IATProviderMock()) - - return (pairingClient, authClient) + if includeAuth { + let authClient = AuthClientFactory.create( + metadata: AppMetadata(name: name, description: "", url: "", icons: [""], redirect: AppMetadata.Redirect(native: "", universal: nil)), + projectId: InputConfig.projectId, + crypto: DefaultCryptoProvider(), + logger: logger, + keyValueStorage: keyValueStorage, + keychainStorage: keychain, + networkingClient: networkingClient, + pairingRegisterer: pairingClient, + iatProvider: IATProviderMock()) + + return (pairingClient, authClient) + } else { + return (pairingClient, nil) + } } override func setUp() { (appPairingClient, appAuthClient) = makeClients(prefix: "🤖 Dapp: ") - (walletPairingClient, walletAuthClient) = makeClients(prefix: "🐶 Wallet: ") + (walletPairingClient, _) = makeClients(prefix: "🐶 Wallet: ", includeAuth: false) } func testPing() async { @@ -95,7 +99,7 @@ final class PairingTests: XCTestCase { let uri = try! await appPairingClient.create() - try? await walletPairingClient.pair(uri: uri) + try! await walletPairingClient.pair(uri: uri) try! await appAuthClient.request(RequestParams.stub(), topic: uri.topic) From ee625130cae7b135d467c1b5bde377a0a008e2f2 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Wed, 6 Dec 2023 10:40:04 +0100 Subject: [PATCH 5/8] add testDisconnect --- .../Pairing/PairingTests.swift | 31 ++++++++++--------- .../Delete/PairingDeleteRequester.swift | 3 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Example/IntegrationTests/Pairing/PairingTests.swift b/Example/IntegrationTests/Pairing/PairingTests.swift index 1a064f154..657530902 100644 --- a/Example/IntegrationTests/Pairing/PairingTests.swift +++ b/Example/IntegrationTests/Pairing/PairingTests.swift @@ -105,18 +105,21 @@ final class PairingTests: XCTestCase { wait(for: [expectation], timeout: InputConfig.defaultTimeout) } -// -// func testDisconnect() { -// -// let expectation = expectation(description: "wallet responds unsupported method for unregistered method") -// -// appAuthClient.authResponsePublisher.sink { (_, response) in -// XCTAssertEqual(response, .failure(AuthError(code: 10001)!)) -// expectation.fulfill() -// }.store(in: &publishers) -// -// let uri = try! await appPairingClient.create() -// -// try? await walletPairingClient.pair(uri: uri) -// } + + func testDisconnect() async { + + let expectation = expectation(description: "wallet disconnected pairing") + + + walletPairingClient.pairingDeletePublisher.sink { _ in + expectation.fulfill() + }.store(in: &publishers) + + let uri = try! await appPairingClient.create() + + try? await walletPairingClient.pair(uri: uri) + + try! await appPairingClient.disconnect(topic: uri.topic) + wait(for: [expectation], timeout: InputConfig.defaultTimeout) + } } diff --git a/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequester.swift b/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequester.swift index 7f5d10cbd..f976a3cd0 100644 --- a/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequester.swift +++ b/Sources/WalletConnectPairing/Services/Common/Delete/PairingDeleteRequester.swift @@ -19,8 +19,9 @@ class PairingDeleteRequester { func delete(topic: String) async throws { let reason = PairingReasonCode.userDisconnected let protocolMethod = PairingProtocolMethod.delete + let pairingDeleteParams = PairingDeleteParams(code: reason.code, message: reason.message) logger.debug("Will delete pairing for reason: message: \(reason.message) code: \(reason.code)") - let request = RPCRequest(method: protocolMethod.method, params: reason) + let request = RPCRequest(method: protocolMethod.method, params: pairingDeleteParams) try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod) pairingStorage.delete(topic: topic) kms.deleteSymmetricKey(for: topic) From 99cc66dcb6e2b59e7d9654bb1403a665d4c0c140 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Wed, 6 Dec 2023 10:54:32 +0100 Subject: [PATCH 6/8] fix tests --- Tests/Web3WalletTests/Mocks/PairingClientMock.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/Web3WalletTests/Mocks/PairingClientMock.swift b/Tests/Web3WalletTests/Mocks/PairingClientMock.swift index edf3f1390..0f0012d59 100644 --- a/Tests/Web3WalletTests/Mocks/PairingClientMock.swift +++ b/Tests/Web3WalletTests/Mocks/PairingClientMock.swift @@ -4,7 +4,14 @@ import Combine @testable import WalletConnectPairing final class PairingClientMock: PairingClientProtocol { - private var logsSubject = PassthroughSubject() + var pairingDeletePublisher: AnyPublisher<(code: Int, message: String), Never> { + pairingDeletePublisherSubject.eraseToAnyPublisher() + } + + var pairingDeletePublisherSubject = PassthroughSubject<(code: Int, message: String), Never>() + + + var logsSubject = PassthroughSubject() var logsPublisher: AnyPublisher { return logsSubject.eraseToAnyPublisher() From 40e721392bea122cfa0e792349c0be8332e1b150 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Wed, 6 Dec 2023 10:58:11 +0100 Subject: [PATCH 7/8] fix build --- Example/DApp/SceneDelegate.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Example/DApp/SceneDelegate.swift b/Example/DApp/SceneDelegate.swift index b9b49d56c..528c5ffc6 100644 --- a/Example/DApp/SceneDelegate.swift +++ b/Example/DApp/SceneDelegate.swift @@ -28,6 +28,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { Web3Modal.configure( projectId: InputConfig.projectId, + chainId: Blockchain("eip155:1"), metadata: metadata ) From 0ed11f41c389f56cf1a2450bbab38292722636c3 Mon Sep 17 00:00:00 2001 From: Bartosz Rozwarski Date: Wed, 6 Dec 2023 11:00:53 +0100 Subject: [PATCH 8/8] fix build --- Example/DApp/SceneDelegate.swift | 1 - .../xcshareddata/swiftpm/Package.resolved | 10 +++++----- .../Wallet/Notifications/NotificationsView.swift | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Example/DApp/SceneDelegate.swift b/Example/DApp/SceneDelegate.swift index 528c5ffc6..b9b49d56c 100644 --- a/Example/DApp/SceneDelegate.swift +++ b/Example/DApp/SceneDelegate.swift @@ -28,7 +28,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { Web3Modal.configure( projectId: InputConfig.projectId, - chainId: Blockchain("eip155:1"), metadata: metadata ) diff --git a/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 229e0f8ef..f11eb5be8 100644 --- a/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/ExampleApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -33,7 +33,7 @@ "repositoryURL": "https://github.com/mixpanel/mixpanel-swift", "state": { "branch": "master", - "revision": "1ce27d937009d5ecce74dad97d69898ffea49c75", + "revision": "c6336881a077d283db6f6d6e2f242977250230bd", "version": null } }, @@ -69,8 +69,8 @@ "repositoryURL": "https://github.com/getsentry/sentry-cocoa.git", "state": { "branch": null, - "revision": "14aa6e47b03b820fd2b338728637570b9e969994", - "version": "8.12.0" + "revision": "74cf23b2946c92550fb1185612077151497e648e", + "version": "8.17.1" } }, { @@ -168,8 +168,8 @@ "repositoryURL": "https://github.com/WalletConnect/web3modal-swift", "state": { "branch": null, - "revision": "e68c1b1560264965ca13608db44294d301c6404f", - "version": "1.0.9" + "revision": "3295d69d1b12df29a5040578d107f56986b1b399", + "version": "1.0.13" } } ] diff --git a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift index 3ced27e6b..a3146cbd8 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsView.swift @@ -191,7 +191,7 @@ struct NotificationsView: View { AsyncButton("Subscribed") { try await presenter.unsubscribe(subscription: subscription) } - .buttonStyle(W3MButtonStyle(size: .m, variant: .accent, rightIcon: Image.Checkmark)) + .buttonStyle(W3MButtonStyle(size: .m, variant: .accent, rightIcon: Image.Medium.checkmark)) .disabled(true) } else { AsyncButton("Subscribe") {