Skip to Content
Packages@tuwaio/orbit-coreVariableslastConnectedConnectorHelpers

lastConnectedConnectorHelpers

const lastConnectedConnectorHelpers: object

Defined in: utils/lastConnectedConnectorHelpers.ts:41 

Helper utilities for managing the last connected wallet state

Type Declaration

getLastConnectedConnector

getLastConnectedConnector: () => LastConnectedConnector | undefined

Retrieves the current last connected wallet data, from sessionStorage first, then from localStorage.

Returns

LastConnectedConnector | undefined

The LastConnectedConnector object or undefined if not set or in SSR context

isLastConnectedConnectorRemembered

isLastConnectedConnectorRemembered: () => boolean | undefined

Whether the last connection is remembered after the tab closes.

Returns

boolean | undefined

true when it is in localStorage, false when it is in sessionStorage, undefined when there is none

lastConnectedConnector

lastConnectedConnector: LastConnectedConnector | undefined

The value of the last connected wallet, initialized when the module loads. Returns undefined if not set, invalid, or in an SSR context.

removeLastConnectedConnector

removeLastConnectedConnector: () => void

Removes the last connected wallet data from localStorage and sessionStorage.

Returns

void

undefined in SSR context, void in browser

setLastConnectedConnector

setLastConnectedConnector: (data, options) => void

Stores the last connected wallet data: in localStorage when it is remembered (the default), otherwise in sessionStorage; the copy in the other storage is removed.

Parameters

data

LastConnectedConnector

Connector type, chain ID and optional address of the connected wallet.

options?

WalletMemoryOptions = {}

Whether the wallet is remembered after the tab closes.

Returns

void

undefined in SSR context, void in browser

STORAGE_KEY

STORAGE_KEY: string = KEY

Remarks

The data is stored under the ‘orbit-core:lastConnectedConnector’ key: in localStorage for a remembered wallet, in sessionStorage for one that is kept only until the tab closes (WalletMemoryOptions). A value in sessionStorage takes precedence when reading. Functions are safe to use in both browser and SSR environments.

Last updated on