import { createContext, useContext } from 'react';
export interface ClobCredentials {
apiKey: string;
secret: string;
passphrase: string;
}
export interface AuthValue {
isAuthenticated: boolean;
isConnected: boolean;
credentials: ClobCredentials | null;
address: `0x${string}` | undefined;
loading: boolean;
error: string | null;
deriveApiKey: () => Promise<void>;
logout: () => void;
}
export const PolymarketAuthContext = createContext<AuthValue | 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 usePolymarketAuth(): AuthValue {
const ctx = useContext(PolymarketAuthContext);
if (!ctx) {
throw new Error('usePolymarketAuth must be used within PolymarketAuthProvider');
}
return ctx;
}