import { createContext, useContext } from 'react';
export interface SiweValue {
user: string | null; // lowercase address when logged in
isConnected: boolean;
address?: `0x${string}`;
loading: boolean;
error: string | null;
login: () => Promise<void>;
logout: () => Promise<void>;
}
export const SiweContext = createContext<SiweValue | null>(null);
// Kept in a non-component module so the provider file only exports a component
// (satisfies react-refresh/only-export-components → preserves fast refresh).
export function useSiweAuth(): SiweValue {
const ctx = useContext(SiweContext);
if (!ctx) throw new Error('useSiweAuth must be used within SiweAuthProvider');
return ctx;
}