-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #541 from WalletConnect/wallet-pairing-integration
[Apps] Wallet pairing integration
- Loading branch information
Showing
15 changed files
with
65 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Foundation | ||
import WalletConnectUtils | ||
|
||
public protocol PairingInteracting { | ||
func pair(uri: WalletConnectURI) async throws | ||
|
||
func create() async throws -> WalletConnectURI | ||
|
||
func getPairings() -> [Pairing] | ||
|
||
func getPairing(for topic: String) throws -> Pairing | ||
|
||
func ping(topic: String) async throws | ||
|
||
func disconnect(topic: String) async throws | ||
|
||
func cleanup() throws | ||
} |
1 change: 0 additions & 1 deletion
1
Sources/WalletConnectPairing/Services/Common/CleanupService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 4 additions & 10 deletions
14
Sources/WalletConnectSign/Services/DisconnectService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
import Foundation | ||
import WalletConnectPairing | ||
|
||
class DisconnectService { | ||
enum Errors: Error { | ||
case objectForTopicNotFound | ||
case sessionForTopicNotFound | ||
} | ||
|
||
private let deleteSessionService: DeleteSessionService | ||
private let sessionStorage: WCSessionStorage | ||
private let pairingClient: PairingClient | ||
|
||
init(deleteSessionService: DeleteSessionService, | ||
sessionStorage: WCSessionStorage, | ||
pairingClient: PairingClient) { | ||
sessionStorage: WCSessionStorage) { | ||
self.deleteSessionService = deleteSessionService | ||
self.sessionStorage = sessionStorage | ||
self.pairingClient = pairingClient | ||
} | ||
|
||
func disconnect(topic: String) async throws { | ||
if let _ = try? pairingClient.getPairing(for: topic) { | ||
try await pairingClient.disconnect(topic: topic) | ||
} else if sessionStorage.hasSession(forTopic: topic) { | ||
if sessionStorage.hasSession(forTopic: topic) { | ||
try await deleteSessionService.delete(topic: topic) | ||
} else { | ||
throw Errors.objectForTopicNotFound | ||
throw Errors.sessionForTopicNotFound | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters