diff --git a/packages/graz/src/actions/account.ts b/packages/graz/src/actions/account.ts index 1cbd08ac..30ab8710 100644 --- a/packages/graz/src/actions/account.ts +++ b/packages/graz/src/actions/account.ts @@ -3,6 +3,7 @@ import { GasPrice } from "@cosmjs/stargate"; import type { Key } from "@keplr-wallet/types"; import type { GrazChain } from "../chains"; +import { RECONNECT_SESSION_KEY } from "../constant"; import { defaultValues, useGrazStore } from "../store"; import type { Maybe } from "../types/core"; import type { WalletType } from "../types/wallet"; @@ -69,7 +70,7 @@ export const connect = async (args?: ConnectArgs): Promise => { _reconnect: Boolean(args?.autoReconnect), _reconnectConnector: currentWalletType, }); - typeof window !== "undefined" && window.sessionStorage.setItem("graz-reconnect-session", "Active"); + typeof window !== "undefined" && window.sessionStorage.setItem(RECONNECT_SESSION_KEY, "Active"); return account; } catch (error) { @@ -81,7 +82,7 @@ export const connect = async (args?: ConnectArgs): Promise => { }; export const disconnect = async (clearRecentChain = false): Promise => { - typeof window !== "undefined" && window.sessionStorage.removeItem("graz-reconnect-session"); + typeof window !== "undefined" && window.sessionStorage.removeItem(RECONNECT_SESSION_KEY); useGrazStore.setState((x) => ({ ...defaultValues, diff --git a/packages/graz/src/constant.ts b/packages/graz/src/constant.ts new file mode 100644 index 00000000..817380db --- /dev/null +++ b/packages/graz/src/constant.ts @@ -0,0 +1 @@ +export const RECONNECT_SESSION_KEY = "graz-reconnect-session"; diff --git a/packages/graz/src/provider/events.tsx b/packages/graz/src/provider/events.tsx index a67a2254..462bcb3e 100644 --- a/packages/graz/src/provider/events.tsx +++ b/packages/graz/src/provider/events.tsx @@ -2,6 +2,7 @@ import type { FC } from "react"; import { useEffect } from "react"; import { reconnect } from "../actions/account"; +import { RECONNECT_SESSION_KEY } from "../constant"; import { useGrazStore } from "../store"; /** @@ -11,7 +12,7 @@ import { useGrazStore } from "../store"; */ export const useGrazEvents = () => { const isSessionActive = - typeof window !== "undefined" && window.sessionStorage.getItem("graz-reconnect-session") === "Active"; + typeof window !== "undefined" && window.sessionStorage.getItem(RECONNECT_SESSION_KEY) === "Active"; const { activeChain, _reconnect, _onReconnectFailed } = useGrazStore.getState(); useEffect(() => {