Skip to content

Commit

Permalink
Merge pull request #299 from alephium/fix-no-matching-keychain-error
Browse files Browse the repository at this point in the history
Fix no matching keychain error
  • Loading branch information
Lbqds authored Jan 9, 2024
2 parents 94f0655 + 2f49db2 commit 0dc7563
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit 0dc7563

Please sign in to comment.