const walletTokenKey = "ark-wallet-token:v1";

export function readWalletToken(): string | null {
  if (typeof window === "undefined") return null;
  try {
    return window.localStorage.getItem(walletTokenKey);
  } catch {
    return null;
  }
}

export function writeWalletToken(token: string): void {
  if (typeof window === "undefined") return;
  try {
    window.localStorage.setItem(walletTokenKey, token);
  } catch {
    return;
  }
}

export function clearWalletToken(): void {
  if (typeof window === "undefined") return;
  try {
    window.localStorage.removeItem(walletTokenKey);
  } catch {
    return;
  }
}
