import { settlementApi } from './dex';

export type OmnlChainSummary = {
  chainId: number;
  name: string;
  status: string;
  tier: string;
  omnlRole: string;
  nativeSymbol: string;
  settlement?: { swapEnabled?: boolean; bridgeEnabled?: boolean; m2LoadEnabled?: boolean };
};

export type ChainRegistryResponse = {
  brand: string;
  maxCapacity: number;
  primaryChainId: number;
  mirrorChainId: number;
  stats?: { total: number; active: number; staged: number; reserved: number };
  chains: OmnlChainSummary[];
};

export async function fetchOmnlChainRegistry(): Promise<ChainRegistryResponse | null> {
  try {
    const res = await fetch(settlementApi('/chains'));
    if (!res.ok) return null;
    return res.json();
  } catch {
    return null;
  }
}
