Skip to content

Commit

Permalink
Merge pull request #1376 from WalletConnect/optimistic-pairing-removal
Browse files Browse the repository at this point in the history
optimistic pairing removal
  • Loading branch information
llbartekll authored Jun 27, 2024
2 parents 8c7e413 + ccf37f8 commit 94ffc4c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Sources/WalletConnectPairing/PairingClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient
try await pingService.ping(topic: topic)
}

public func disconnect(topic: String) async throws {
try await pairingDeleteRequester.delete(topic: topic)
public func disconnect(topic: String) async {
await pairingDeleteRequester.delete(topic: topic)
}

public func validatePairingExistance(_ topic: String) throws {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectPairing/PairingClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public protocol PairingClientProtocol {
var pairingStatePublisher: AnyPublisher<Bool, Never> {get}
var pairingExpirationPublisher: AnyPublisher<Pairing, Never> {get}
func pair(uri: WalletConnectURI) async throws
func disconnect(topic: String) async throws
func disconnect(topic: String) async
func getPairings() -> [Pairing]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class PairingDeleteRequester {
self.logger = logger
}

func delete(topic: String) async throws {
func delete(topic: String) async {
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: pairingDeleteParams)
try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod)
try? await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod)
pairingStorage.delete(topic: topic)
kms.deleteSymmetricKey(for: topic)
networkingInteractor.unsubscribe(topic: topic)
Expand Down
4 changes: 2 additions & 2 deletions Sources/WalletConnectSign/Services/SignCleanupService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ private extension SignCleanupService {
let pairing = pairingStore.getAll().map { $0.topic }
let session = sessionStore.getAll().map { $0.topic }

try await networkInteractor.batchUnsubscribe(topics: pairing + session)
try? await networkInteractor.batchUnsubscribe(topics: pairing + session)
}

func cleanupStorages() throws {
pairingStore.deleteAll()
sessionStore.deleteAll()
sessionTopicToProposal.deleteAll()
rpcHistory.deleteAll()
try kms.deleteAll()
try? kms.deleteAll()
}
}
4 changes: 2 additions & 2 deletions Sources/Web3Wallet/Web3WalletClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public class Web3WalletClient {
try await pairingClient.pair(uri: uri)
}

public func disconnectPairing(topic: String) async throws {
try await pairingClient.disconnect(topic: topic)
public func disconnectPairing(topic: String) async {
await pairingClient.disconnect(topic: topic)
}

/// For a wallet and a dApp to terminate a session
Expand Down

0 comments on commit 94ffc4c

Please sign in to comment.