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

Web3Wallet expose disconnect pairing #720

Merged
merged 1 commit into from
Feb 15, 2023
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
1 change: 1 addition & 0 deletions Sources/WalletConnectPairing/PairingClientProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
public protocol PairingClientProtocol {
func pair(uri: WalletConnectURI) async throws
func disconnect(topic: String) async throws
}
4 changes: 4 additions & 0 deletions Sources/Web3Wallet/Web3WalletClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public class Web3WalletClient {
public func pair(uri: WalletConnectURI) async throws {
try await pairingClient.pair(uri: uri)
}

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

/// For a wallet and a dApp to terminate a session
///
Expand Down
5 changes: 5 additions & 0 deletions Tests/Web3WalletTests/Mocks/PairingClientMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import Combine

final class PairingClientMock: PairingClientProtocol {
var pairCalled = false
var disconnectPairingCalled = false

func pair(uri: WalletConnectUtils.WalletConnectURI) async throws {
pairCalled = true
}

func disconnect(topic: String) async throws {
disconnectPairingCalled = true
}
}
5 changes: 5 additions & 0 deletions Tests/Web3WalletTests/Web3WalletTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ final class Web3WalletTests: XCTestCase {
XCTAssertTrue(pairingClient.pairCalled)
}

func testDisconnectPairingCalled() async {
try! await web3WalletClient.disconnectPairing(topic: "topic")
XCTAssertTrue(pairingClient.disconnectPairingCalled)
}

func testDisconnectCalled() async {
try! await web3WalletClient.disconnect(topic: "")
XCTAssertTrue(signClient.disconnectCalled)
Expand Down