/**
 * Dynamic contract address registry.
 * Populated from /api/contracts at runtime.
 * Module-level store — safe because addresses are the same across all renders.
 */
const dynamicRegistry = new Map<string, `0x${string}`>()

export function setContractAddress(name: string, chainId: number, address: string) {
  if (address && address.startsWith('0x')) {
    dynamicRegistry.set(`${name}:${chainId}`, address as `0x${string}`)
  }
}

export function getContractAddress(name: string, chainId: number): `0x${string}` | undefined {
  return dynamicRegistry.get(`${name}:${chainId}`)
}
