Skip to content

Commit

Permalink
Separate debug cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
flypaper0 committed Dec 16, 2022
1 parent bc5c5b3 commit 52a8793
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Example/ExampleApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) async {

let metadata = AppMetadata(
name: "Example Wallet",
Expand All @@ -22,7 +22,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
Pair.configure(metadata: metadata)
#if DEBUG
if CommandLine.arguments.contains("-cleanInstall") {
try? Sign.instance.cleanup()
try? await Sign.instance.cleanup()
}
#endif

Expand Down
15 changes: 11 additions & 4 deletions Sources/WalletConnectSign/Services/SignCleanupService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ final class SignCleanupService {

func cleanup() async throws {
try await unsubscribe()
try cleanupStorages()
}

pairingStore.deleteAll()
sessionStore.deleteAll()
sessionToPairingTopic.deleteAll()
try kms.deleteAll()
func cleanup() throws {
try cleanupStorages()
}
}

Expand All @@ -34,4 +34,11 @@ private extension SignCleanupService {

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

func cleanupStorages() throws {
pairingStore.deleteAll()
sessionStore.deleteAll()
sessionToPairingTopic.deleteAll()
try kms.deleteAll()
}
}
11 changes: 11 additions & 0 deletions Sources/WalletConnectSign/Sign/SignClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,21 @@ public final class SignClient {
}

/// Delete all stored data such as: pairings, sessions, keys
///
/// - Note: Will unsubscribe from all topics
public func cleanup() async throws {
try await cleanupService.cleanup()
}

#if DEBUG
/// Delete all stored data such as: pairings, sessions, keys
///
/// - Note: Doesn't unsubscribe from topics
public func cleanup() throws {
try cleanupService.cleanup()
}
#endif

// MARK: - Private

private func setUpEnginesCallbacks() {
Expand Down

0 comments on commit 52a8793

Please sign in to comment.