Skip to content

Commit

Permalink
fix: sessions and pairings check
Browse files Browse the repository at this point in the history
  • Loading branch information
isordo committed Nov 22, 2023
1 parent 6d600d3 commit 13bf76e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/dapp.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
},
featuredWallets: ['kukai', 'metamask', 'airgap'],
network: {
type: beacon.NetworkType.MAINNET
type: beacon.NetworkType.GHOSTNET
}
// matrixNodes: ['test.papers.tech', 'test2.papers.tech', 'matrix.papers.tech']
// matrixNodes: ['beacon-node-0.papers.tech:8448']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,22 @@ export class WalletConnectTransport<
}

public async hasPairings() {
let hasPairings = false

if (await LocalStorage.isSupported()) {
return ((await new LocalStorage().get(StorageKey.WC_2_CORE_PAIRING)) ?? '[]') !== '[]'
} else {
return !!this.client.signClient?.pairing.getAll()?.length
hasPairings = ((await new LocalStorage().get(StorageKey.WC_2_CORE_PAIRING)) ?? '[]') !== '[]'
}

return hasPairings ? hasPairings : !!this.client.signClient?.pairing.getAll()?.length
}

public async hasSessions() {
let hasSessions = false
if (await LocalStorage.isSupported()) {
return ((await new LocalStorage().get(StorageKey.WC_2_CLIENT_SESSION)) ?? '[]') !== '[]'
} else {
return !!this.client.signClient?.session.getAll()?.length
hasSessions =
((await new LocalStorage().get(StorageKey.WC_2_CLIENT_SESSION)) ?? '[]') !== '[]'
}
return hasSessions ? hasSessions : !!this.client.signClient?.session.getAll()?.length
}

public async closeActiveSession(account: AccountInfo) {
Expand Down

0 comments on commit 13bf76e

Please sign in to comment.