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 no matching keychain error #299

Merged
merged 1 commit into from
Jan 9, 2024
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
14 changes: 9 additions & 5 deletions packages/walletconnect/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,13 @@ export class WalletConnectProvider extends SignerProvider {

await this.providerOpts.onDisconnected()

await this.client.disconnect({
topic: this.session.topic,
reason: getSdkError('USER_DISCONNECTED')
})
const reason = getSdkError('USER_DISCONNECTED')
try {
await this.client.disconnect({ topic: this.session.topic, reason })
} catch (error) {
await this.client.session.delete(this.session.topic, reason)
await this.client.core.crypto.deleteSymKey(this.session.topic)
}
this.session = undefined
this.account = undefined
}
Expand Down Expand Up @@ -331,8 +334,9 @@ export class WalletConnectProvider extends SignerProvider {
const sessionKeys = this.client.session.keys
for (let i = sessionKeys.length - 1; i >= 0; i--) {
const session = this.client.session.get(sessionKeys[`${i}`])
const hasKeyChain = this.client.core.crypto.keychain.has(session.topic)
const chains = getChainsFromNamespaces(session.namespaces, [PROVIDER_NAMESPACE])
if (this.sameChains(chains, [this.permittedChain])) {
if (this.sameChains(chains, [this.permittedChain]) && hasKeyChain) {
this.session = session
return
}
Expand Down
Loading