← Back
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;
}

📜 Git History

6c47fa4chore: local Polikopi project home + Phase 1 redesign artifacts12 days ago
Show last diff
Loading...