diff --git a/Example/DApp/SceneDelegate.swift b/Example/DApp/SceneDelegate.swift index c08b15a8b..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..dceba93f5 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": "e68c1b1560264965ca13608db44294d301c6404f", - "version": "1.0.9" + "revision": "831410cfd6e68afa7212a5547483fb2d180f0fa7", + "version": "1.0.10" } } ] diff --git a/Example/WalletApp/ApplicationLayer/ProfilingService.swift b/Example/WalletApp/ApplicationLayer/ProfilingService.swift index bfffe219a..ed46d3771 100644 --- a/Example/WalletApp/ApplicationLayer/ProfilingService.swift +++ b/Example/WalletApp/ApplicationLayer/ProfilingService.swift @@ -2,6 +2,7 @@ import Foundation import Mixpanel import WalletConnectNetworking import Combine +import Web3Wallet import WalletConnectNotify final class ProfilingService { @@ -34,6 +35,8 @@ final class ProfilingService { handleLogs(from: Networking.instance.logsPublisher) handleLogs(from: Notify.instance.logsPublisher) handleLogs(from: Push.instance.logsPublisher) + handleLogs(from: Web3Wallet.instance.logsPublisher) + } private func handleLogs(from publisher: AnyPublisher) { diff --git a/Sources/WalletConnectPairing/PairingClient.swift b/Sources/WalletConnectPairing/PairingClient.swift index 3eafd2838..c9ca77413 100644 --- a/Sources/WalletConnectPairing/PairingClient.swift +++ b/Sources/WalletConnectPairing/PairingClient.swift @@ -23,6 +23,10 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient private let cleanupService: PairingCleanupService + public var logsPublisher: AnyPublisher { + return logger.logsPublisher + } + init( pairingStorage: WCPairingStorage, appPairService: AppPairService, diff --git a/Sources/WalletConnectPairing/PairingClientProtocol.swift b/Sources/WalletConnectPairing/PairingClientProtocol.swift index 098293c19..e025f7fd6 100644 --- a/Sources/WalletConnectPairing/PairingClientProtocol.swift +++ b/Sources/WalletConnectPairing/PairingClientProtocol.swift @@ -1,4 +1,7 @@ +import Combine + public protocol PairingClientProtocol { + var logsPublisher: AnyPublisher {get} func pair(uri: WalletConnectURI) async throws func disconnect(topic: String) async throws func getPairings() -> [Pairing] diff --git a/Sources/WalletConnectPairing/Services/Wallet/WalletPairService.swift b/Sources/WalletConnectPairing/Services/Wallet/WalletPairService.swift index c962b8a41..7c04a0acc 100644 --- a/Sources/WalletConnectPairing/Services/Wallet/WalletPairService.swift +++ b/Sources/WalletConnectPairing/Services/Wallet/WalletPairService.swift @@ -10,21 +10,26 @@ actor WalletPairService { let kms: KeyManagementServiceProtocol private let pairingStorage: WCPairingStorage private let history: RPCHistory + private let logger: ConsoleLogging init( networkingInteractor: NetworkInteracting, kms: KeyManagementServiceProtocol, pairingStorage: WCPairingStorage, - history: RPCHistory + history: RPCHistory, + logger: ConsoleLogging ) { self.networkingInteractor = networkingInteractor self.kms = kms self.pairingStorage = pairingStorage self.history = history + self.logger = logger } func pair(_ uri: WalletConnectURI) async throws { + logger.debug("Pairing with uri: \(uri)") guard try !pairingHasPendingRequest(for: uri.topic) else { + logger.debug("Pairing with topic (\(uri.topic)) has pending request") return } @@ -35,6 +40,7 @@ actor WalletPairService { let networkConnectionStatus = await resolveNetworkConnectionStatus() guard networkConnectionStatus == .connected else { + logger.debug("Pairing failed - Network is not connected") throw Errors.networkNotConnected } diff --git a/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift b/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift index 7e26a2725..8c994c094 100644 --- a/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift +++ b/Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift @@ -61,6 +61,7 @@ final class ApproveEngine { } func approveProposal(proposerPubKey: String, validating sessionNamespaces: [String: SessionNamespace], sessionProperties: [String: String]? = nil) async throws { + logger.debug("Approving session proposal") guard let payload = try proposalPayloadsStore.get(key: proposerPubKey) else { throw Errors.wrongRequestParams } @@ -112,6 +113,8 @@ final class ApproveEngine { _ = try await [proposeResponse, settleRequest] + logger.debug("Session proposal response and settle request have been sent") + pairingRegisterer.activate( pairingTopic: payload.topic, peerMetadata: payload.request.proposer.metadata diff --git a/Sources/WalletConnectSign/Sign/SignClient.swift b/Sources/WalletConnectSign/Sign/SignClient.swift index 299e6c4b1..b87864de1 100644 --- a/Sources/WalletConnectSign/Sign/SignClient.swift +++ b/Sources/WalletConnectSign/Sign/SignClient.swift @@ -95,6 +95,10 @@ public final class SignClient: SignClientProtocol { sessionsPublisherSubject.eraseToAnyPublisher() } + public var logsPublisher: AnyPublisher { + return logger.logsPublisher + } + /// An object that loggs SDK's errors and info messages public let logger: ConsoleLogging diff --git a/Sources/WalletConnectSign/Sign/SignClientFactory.swift b/Sources/WalletConnectSign/Sign/SignClientFactory.swift index 8844e08d4..1d9adf073 100644 --- a/Sources/WalletConnectSign/Sign/SignClientFactory.swift +++ b/Sources/WalletConnectSign/Sign/SignClientFactory.swift @@ -17,7 +17,7 @@ public struct SignClientFactory { networkingClient: NetworkingInteractor, groupIdentifier: String ) -> SignClient { - let logger = ConsoleLogger(loggingLevel: .debug) + let logger = ConsoleLogger(prefix: "📝", loggingLevel: .debug) guard let keyValueStorage = UserDefaults(suiteName: groupIdentifier) else { fatalError("Could not instantiate UserDefaults for a group identifier \(groupIdentifier)") diff --git a/Sources/WalletConnectSign/Sign/SignClientProtocol.swift b/Sources/WalletConnectSign/Sign/SignClientProtocol.swift index 0d83845b1..2b174ddec 100644 --- a/Sources/WalletConnectSign/Sign/SignClientProtocol.swift +++ b/Sources/WalletConnectSign/Sign/SignClientProtocol.swift @@ -11,7 +11,8 @@ public protocol SignClientProtocol { var sessionResponsePublisher: AnyPublisher { get } var sessionRejectionPublisher: AnyPublisher<(Session.Proposal, Reason), Never> { get } var sessionEventPublisher: AnyPublisher<(event: Session.Event, sessionTopic: String, chainId: Blockchain?), Never> { get } - + var logsPublisher: AnyPublisher {get} + func connect(requiredNamespaces: [String: ProposalNamespace], optionalNamespaces: [String: ProposalNamespace]?, sessionProperties: [String: String]?, topic: String) async throws func request(params: Request) async throws func approve(proposalId: String, namespaces: [String: SessionNamespace], sessionProperties: [String: String]?) async throws diff --git a/Sources/Web3Wallet/Web3WalletClient.swift b/Sources/Web3Wallet/Web3WalletClient.swift index a90093a10..19e27790f 100644 --- a/Sources/Web3Wallet/Web3WalletClient.swift +++ b/Sources/Web3Wallet/Web3WalletClient.swift @@ -63,6 +63,12 @@ public class Web3WalletClient { signClient.sessionResponsePublisher.eraseToAnyPublisher() } + public var logsPublisher: AnyPublisher { + return signClient.logsPublisher + .merge(with: pairingClient.logsPublisher) + .eraseToAnyPublisher() + } + // MARK: - Private Properties private let authClient: AuthClientProtocol private let signClient: SignClientProtocol