export const erc20Abi = [
  {
    type: "function",
    name: "balanceOf",
    stateMutability: "view",
    inputs: [{ name: "account", type: "address" }],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "allowance",
    stateMutability: "view",
    inputs: [
      { name: "owner", type: "address" },
      { name: "spender", type: "address" }
    ],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "approve",
    stateMutability: "nonpayable",
    inputs: [
      { name: "spender", type: "address" },
      { name: "amount", type: "uint256" }
    ],
    outputs: [{ name: "", type: "bool" }]
  },
  {
    type: "function",
    name: "totalSupply",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "owner",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "address" }]
  }
] as const;

export const bountyManagerAbi = [
  {
    type: "event",
    name: "BountyCreated",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "issuer", type: "address", indexed: true },
      { name: "paymentToken", type: "address", indexed: true },
      { name: "instanceCID", type: "string", indexed: false },
      { name: "instanceDigest", type: "bytes32", indexed: false },
      { name: "metadataURI", type: "string", indexed: false },
      { name: "metadataDigest", type: "bytes32", indexed: false },
      { name: "reward", type: "uint256", indexed: false },
      { name: "verifierRewardPool", type: "uint256", indexed: false },
      { name: "postingFee", type: "uint256", indexed: false }
    ]
  },
  {
    type: "event",
    name: "SolutionCommitted",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "solver", type: "address", indexed: true },
      { name: "commitHash", type: "bytes32", indexed: false }
    ]
  },
  {
    type: "event",
    name: "SolutionRevealed",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "solver", type: "address", indexed: true },
      { name: "solutionRef", type: "string", indexed: false },
      { name: "solutionDigest", type: "bytes32", indexed: false },
      { name: "solutionKind", type: "uint8", indexed: false },
      { name: "proofFormat", type: "uint8", indexed: false }
    ]
  },
  {
    type: "event",
    name: "Attested",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "verifier", type: "address", indexed: true },
      { name: "support", type: "bool", indexed: false },
      { name: "solutionKind", type: "uint8", indexed: false },
      { name: "proofFormat", type: "uint8", indexed: false },
      { name: "forVotes", type: "uint16", indexed: false },
      { name: "againstVotes", type: "uint16", indexed: false }
    ]
  },
  {
    type: "event",
    name: "QuorumReached",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "accepted", type: "bool", indexed: false }
    ]
  },
  {
    type: "event",
    name: "Finalized",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "solverWon", type: "bool", indexed: false }
    ]
  },
  {
    type: "event",
    name: "BountyReopened",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "commitDeadline", type: "uint64", indexed: false },
      { name: "revealDeadline", type: "uint64", indexed: false },
      { name: "verificationDeadline", type: "uint64", indexed: false }
    ]
  },
  {
    type: "event",
    name: "VerifierRewardPaid",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "verifier", type: "address", indexed: true },
      { name: "paymentToken", type: "address", indexed: false },
      { name: "amount", type: "uint256", indexed: false }
    ]
  },
  {
    type: "event",
    name: "VerifierRewardRefunded",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "issuer", type: "address", indexed: true },
      { name: "paymentToken", type: "address", indexed: false },
      { name: "amount", type: "uint256", indexed: false }
    ]
  },
  {
    type: "event",
    name: "BondRefunded",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "solver", type: "address", indexed: true },
      { name: "bondToken", type: "address", indexed: false },
      { name: "amount", type: "uint256", indexed: false }
    ]
  },
  {
    type: "event",
    name: "BondSlashed",
    inputs: [
      { name: "bountyId", type: "uint256", indexed: true },
      { name: "submissionId", type: "uint256", indexed: true },
      { name: "solver", type: "address", indexed: true },
      { name: "bondToken", type: "address", indexed: false },
      { name: "amount", type: "uint256", indexed: false }
    ]
  },
  {
    type: "function",
    name: "nextBountyId",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "solverBond",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "solverBondForToken",
    stateMutability: "view",
    inputs: [{ name: "paymentToken", type: "address" }],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "verifierRewardBps",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint16" }]
  },
  {
    type: "function",
    name: "verifierRewardPoolFor",
    stateMutability: "view",
    inputs: [{ name: "reward", type: "uint256" }],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "finalizedWinningSubmissionId",
    stateMutability: "view",
    inputs: [{ name: "bountyId", type: "uint256" }],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "finalizedWinningSolver",
    stateMutability: "view",
    inputs: [{ name: "bountyId", type: "uint256" }],
    outputs: [{ name: "", type: "address" }]
  },
  {
    type: "function",
    name: "owner",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "address" }]
  },
  {
    type: "function",
    name: "getBounty",
    stateMutability: "view",
    inputs: [{ name: "bountyId", type: "uint256" }],
    outputs: [
      {
        name: "",
        type: "tuple",
        components: [
          { name: "issuer", type: "address" },
          { name: "paymentToken", type: "address" },
          { name: "instanceCID", type: "string" },
          { name: "instanceDigest", type: "bytes32" },
          { name: "metadataURI", type: "string" },
          { name: "metadataDigest", type: "bytes32" },
          { name: "reward", type: "uint256" },
          { name: "verifierRewardPool", type: "uint256" },
          { name: "postingFee", type: "uint256" },
          { name: "commitDeadline", type: "uint64" },
          { name: "revealDeadline", type: "uint64" },
          { name: "verificationDeadline", type: "uint64" },
          { name: "verifierQuorum", type: "uint16" },
          { name: "submissionCount", type: "uint256" },
          { name: "acceptedCandidateCount", type: "uint256" },
          { name: "finalized", type: "bool" },
          { name: "postingFeeRouted", type: "bool" }
        ]
      }
    ]
  },
  {
    type: "function",
    name: "getSubmission",
    stateMutability: "view",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" }
    ],
    outputs: [
      {
        name: "",
        type: "tuple",
        components: [
          { name: "solver", type: "address" },
          { name: "commitHash", type: "bytes32" },
          { name: "solutionRef", type: "string" },
          { name: "solutionDigest", type: "bytes32" },
          { name: "solutionKind", type: "uint8" },
          { name: "proofFormat", type: "uint8" },
          { name: "bondToken", type: "address" },
          { name: "solverBond", type: "uint256" },
          { name: "committedAt", type: "uint64" },
          { name: "revealedAt", type: "uint64" },
          { name: "quorumReachedAt", type: "uint64" },
          { name: "forVotes", type: "uint16" },
          { name: "againstVotes", type: "uint16" },
          { name: "bondSettled", type: "bool" },
          { name: "bondSlashed", type: "bool" },
          { name: "state", type: "uint8" }
        ]
      }
    ]
  },
  {
    type: "function",
    name: "isFinalizable",
    stateMutability: "view",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" }
    ],
    outputs: [{ name: "", type: "bool" }]
  },
  {
    type: "function",
    name: "hasAttested",
    stateMutability: "view",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" },
      { name: "verifier", type: "address" }
    ],
    outputs: [{ name: "", type: "bool" }]
  },
  {
    type: "function",
    name: "createBounty",
    stateMutability: "nonpayable",
    inputs: [
      { name: "paymentToken", type: "address" },
      { name: "instanceCID", type: "string" },
      { name: "instanceDigest", type: "bytes32" },
      { name: "metadataURI", type: "string" },
      { name: "metadataDigest", type: "bytes32" },
      { name: "reward", type: "uint256" },
      { name: "postingFee", type: "uint256" },
      { name: "commitWindow", type: "uint64" },
      { name: "revealWindow", type: "uint64" },
      { name: "verificationWindow", type: "uint64" },
      { name: "verifierQuorum", type: "uint16" }
    ],
    outputs: [{ name: "bountyId", type: "uint256" }]
  },
  {
    type: "function",
    name: "commitSolution",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "commitHash", type: "bytes32" }
    ],
    outputs: [{ name: "submissionId", type: "uint256" }]
  },
  {
    type: "function",
    name: "revealSolution",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" },
      { name: "solutionKind", type: "uint8" },
      { name: "proofFormat", type: "uint8" },
      { name: "solutionRef", type: "string" },
      { name: "solutionDigest", type: "bytes32" },
      { name: "salt", type: "bytes32" }
    ],
    outputs: []
  },
  {
    type: "function",
    name: "attest",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" },
      { name: "support", type: "bool" },
      { name: "solutionKind", type: "uint8" },
      { name: "proofFormat", type: "uint8" },
      { name: "solutionRef", type: "string" },
      { name: "solutionDigest", type: "bytes32" }
    ],
    outputs: []
  },
  {
    type: "function",
    name: "finalize",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" }
    ],
    outputs: []
  },
  {
    type: "function",
    name: "slashExpiredSubmission",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" }
    ],
    outputs: []
  },
  {
    type: "function",
    name: "claimSolverBond",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "submissionId", type: "uint256" }
    ],
    outputs: []
  }
] as const;

export const verifierRegistryAbi = [
  {
    type: "function",
    name: "minimumStake",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "unbondingDelay",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint64" }]
  },
  {
    type: "function",
    name: "isEligible",
    stateMutability: "view",
    inputs: [{ name: "verifier", type: "address" }],
    outputs: [{ name: "", type: "bool" }]
  },
  {
    type: "function",
    name: "getVerifier",
    stateMutability: "view",
    inputs: [{ name: "verifier", type: "address" }],
    outputs: [
      {
        name: "",
        type: "tuple",
        components: [
          { name: "activeStake", type: "uint256" },
          { name: "pendingUnstake", type: "uint256" },
          { name: "unstakeReadyAt", type: "uint64" },
          { name: "metadataURI", type: "string" },
          { name: "registered", type: "bool" },
          { name: "enabled", type: "bool" }
        ]
      }
    ]
  },
  {
    type: "function",
    name: "stake",
    stateMutability: "nonpayable",
    inputs: [
      { name: "amount", type: "uint256" },
      { name: "metadataURI", type: "string" }
    ],
    outputs: []
  },
  {
    type: "function",
    name: "requestUnstake",
    stateMutability: "nonpayable",
    inputs: [{ name: "amount", type: "uint256" }],
    outputs: []
  },
  {
    type: "function",
    name: "withdrawUnstaked",
    stateMutability: "nonpayable",
    inputs: [],
    outputs: []
  }
] as const;

export const artifactAccessControllerAbi = [
  {
    type: "function",
    name: "defaultPaymentToken",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "address" }]
  },
  {
    type: "function",
    name: "ARTIFACT_SOLUTION",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint8" }]
  },
  {
    type: "function",
    name: "accessPrice",
    stateMutability: "view",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" }
    ],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "accessPrice",
    stateMutability: "view",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" },
      { name: "paymentToken", type: "address" }
    ],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "defaultSolverAccessRewardBps",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint16" }]
  },
  {
    type: "function",
    name: "solverRoyaltyBps",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint16" }]
  },
  {
    type: "function",
    name: "accessDistribution",
    stateMutability: "view",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" }
    ],
    outputs: [
      { name: "price", type: "uint256" },
      { name: "solver", type: "address" },
      { name: "solverAmount", type: "uint256" },
      { name: "routedAmount", type: "uint256" }
    ]
  },
  {
    type: "function",
    name: "accessDistribution",
    stateMutability: "view",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" },
      { name: "paymentToken", type: "address" }
    ],
    outputs: [
      { name: "price", type: "uint256" },
      { name: "solver", type: "address" },
      { name: "solverAmount", type: "uint256" },
      { name: "routedAmount", type: "uint256" }
    ]
  },
  {
    type: "function",
    name: "hasAccess",
    stateMutability: "view",
    inputs: [
      { name: "user", type: "address" },
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" }
    ],
    outputs: [{ name: "", type: "bool" }]
  },
  {
    type: "function",
    name: "canAccess",
    stateMutability: "view",
    inputs: [
      { name: "user", type: "address" },
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" }
    ],
    outputs: [{ name: "", type: "bool" }]
  },
  {
    type: "function",
    name: "purchaseAccess",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" }
    ],
    outputs: []
  },
  {
    type: "function",
    name: "purchaseAccess",
    stateMutability: "nonpayable",
    inputs: [
      { name: "bountyId", type: "uint256" },
      { name: "artifactType", type: "uint8" },
      { name: "paymentToken", type: "address" }
    ],
    outputs: []
  }
] as const;

export const tokenVestingAbi = [
  {
    type: "function",
    name: "beneficiary",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "address" }]
  },
  {
    type: "function",
    name: "releasable",
    stateMutability: "view",
    inputs: [],
    outputs: [{ name: "", type: "uint256" }]
  },
  {
    type: "function",
    name: "release",
    stateMutability: "nonpayable",
    inputs: [],
    outputs: [{ name: "amount", type: "uint256" }]
  }
] as const;
