Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimistic pairing removal #1376

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}