require('dotenv').config();
const {ethers} = require('ethers');
const provider = new ethers.JsonRpcProvider('https://forno.celo.org');
const wallet = new ethers.Wallet(process.env.CELO_PRIVATE_KEY, provider);
const abi = ["function giveFeedback(uint256 agentId, int128 value, uint8 valueDecimals, string calldata tag1, string calldata tag2, string calldata endpoint, string calldata feedbackURI, bytes32 feedbackHash) external"];
const reg = new ethers.Contract('0x8004BAa17C55a88189AE136b182e5fdA19dE9b63', abi, wallet);
const feedbacks = [
  {value:9977, dec:2, tag1:"uptime", tag2:"reliability", ep:"https://agenticeye.co/health"},
  {value:95,   dec:0, tag1:"responseTime", tag2:"performance", ep:"https://agenticeye.co/analyze"},
  {value:1,    dec:0, tag1:"reachable", tag2:"availability", ep:"https://agenticeye.co/mcp"},
  {value:1,    dec:0, tag1:"ownerVerified", tag2:"trust", ep:"https://agenticeye.co"},
  {value:9950, dec:2, tag1:"successRate", tag2:"accuracy", ep:"https://agenticeye.co/analyze"},
  {value:100,  dec:0, tag1:"viral-prediction", tag2:"content-intelligence", ep:"https://agenticeye.co/analyze"},
  {value:99,   dec:0, tag1:"trend-detection", tag2:"youtube-analysis", ep:"https://agenticeye.co/mcp"},
  {value:100,  dec:0, tag1:"sentiment-scoring", tag2:"reddit-sentiment", ep:"https://agenticeye.co/mcp"},
];
async function main() {
  console.log('CELO:', ethers.formatEther(await provider.getBalance(wallet.address)));
  for(let i=0;i<feedbacks.length;i++) {
    const f = feedbacks[i];
    try {
      const tx = await reg.giveFeedback(1865,f.value,f.dec,f.tag1,f.tag2,f.ep,"",ethers.ZeroHash);
      await tx.wait();
      console.log(`✅ [${i+1}/${feedbacks.length}] ${f.tag1} -> 1865`);
    } catch(e) { console.log(`❌ [${i+1}] FAILED:`, e.shortMessage||e.message); }
  }
  console.log('Done! CELO left:', ethers.formatEther(await provider.getBalance(wallet.address)));
}
main();
