Skip to content

Commit

Permalink
✨ feat: add dispose for sdk (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustin01 authored Aug 7, 2024
1 parent 8418f5e commit d8ef218
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/sdk/src/lib/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,25 @@ export class HibitIdWallet {

public disconnect = async () => {
console.debug('[sdk call Disconnect]')
this._controller?.destroy()
this._connected = false
this._iframeReadyPromise = new BridgePromise<boolean>()
sessionStorage.removeItem(LOGIN_SESSION_KEY)

this._disconnectedPromise = new BridgePromise<boolean>()
this._rpc?.call(HibitIdExposeRPCMethod.DISCONNECT, {})
await this._disconnectedPromise.promise
this.dispose()
}

public dispose = async () => {
console.debug('[sdk call Dispose]')
sessionStorage.removeItem(LOGIN_SESSION_KEY)
this._controller?.destroy()
this._controller = null
this._connected = false
this._iframeReadyPromise = new BridgePromise<boolean>()
this._connectPromise = null
this._disconnectedPromise = null
this._rpc?.destroy()
this._rpc = null
this._iframe?.destroy()
this._iframe = null
}

public switchToChain = async (chainId: HibitIdChainId) => {
Expand Down

0 comments on commit d8ef218

Please sign in to comment.