const {ethers}=require("ethers");
const p=new ethers.JsonRpcProvider("https://forno.celo.org");

// Known 8004 contract prefixes on Celo
const candidates = [
  "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432", // Identity
  "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63", // Reputation
];

// Check for Validation Registry - try common patterns
const validationCandidates = [
  "0x8004C47bE24F8B2a7D7e5F3c1B9a6E2f4D8c0A1b",
  "0x8004000000000000000000000000000000000003",
];

(async()=>{
  // Check what contracts exist at 8004 prefix
  for(const addr of candidates) {
    const code = await p.getCode(addr);
    console.log(addr.slice(0,10)+"...", code.length > 2 ? "CONTRACT" : "EOA");
  }
  
  // Check the identity registry for any validation-related functions
  const iface = new ethers.Interface([
    "function getValidationStatus(uint256) view returns (uint8)",
    "function getSummary(uint256) view returns (tuple(uint256,uint256,uint256))",
  ]);
  
  // Try reading agent 17 summary from reputation
  const rep = new ethers.Contract("0x8004BAa17C55a88189AE136b182e5fdA19dE9b63", [
    "function getSummary(uint256) view returns (uint256,int256,uint256,uint256)"
  ], p);
  try {
    const summary = await rep.getSummary(17);
    console.log("Agent 17 Reputation Summary:", summary.toString());
  } catch(e) {
    console.log("getSummary error:", e.message.substring(0,80));
  }
})();
