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

fix: disconnect rejection #657

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
} else {
this.updateActiveAccount(event.params.namespaces)
this.notifyListenersWithPermissionResponse(this.session!, {
type: this.wcOptions.network,
type: this.wcOptions.network
})
}
})
Expand Down Expand Up @@ -673,24 +673,28 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
await this.closeSessions()
const signClient = await this.getSignClient()
const pairings = signClient.pairing.getAll() ?? []
for (let pairing of pairings) {
await signClient.core.pairing.disconnect({ topic: pairing.topic })
}
pairings.length &&
(await Promise.allSettled(
pairings.map((pairing) => signClient.core.pairing.disconnect({ topic: pairing.topic }))
))
await this.resetWCSnapshot()
}

private async closeSessions() {
const signClient = await this.getSignClient()
const sessions = signClient.session.getAll() ?? []
for (let session of sessions) {
await signClient.disconnect({
topic: session.topic,
reason: {
code: 0, // TODO: Use constants
message: 'Force new connection'
}
})
}
sessions.length &&
(await Promise.allSettled(
sessions.map((session) =>
signClient.disconnect({
topic: (session as any).topic,
reason: {
code: 0, // TODO: Use constants
message: 'Force new connection'
}
})
)
))

this.clearState()
}
Expand Down