export type ProtocolVersion = "v2" | "v3";
export type ContractStatus  = "active" | "legacy" | "deprecated" | "paused" | "read-only";
export type Finality        = "soft" | "safe" | "finalized";

export interface VaultfireV3Config {
  baseUrl: string;       // e.g. https://theloopbreaker.com
  defaultChainId: number;
  rpcUrls: Record<number, string>;
  x402: {
    payer: string;
    assetPerChain: Record<number, string>;
    /** Exact settlement recipient allowlist, keyed by the EVM payment chain. */
    payeePerChain: Record<number, string>;
  };
}

export interface V3BondTerms {
  bondId: bigint;
  partyA: `0x${string}`;
  partyB: `0x${string}`;
  partyAStake: bigint;
  partyBStake: bigint;
  stakeAsset: `0x${string}`;
  partnershipType: `0x${string}`;
  breachConditionsHash: `0x${string}`;
  flourishRewardConditionsHash: `0x${string}`;
  rewardProgramId: bigint;
  proposalDeadline: bigint;
  activePeriodStart: bigint;
  activePeriodEnd: bigint;
  challengeWindow: bigint;
  nonce: bigint;
  chainId: bigint;
  protocolVersion: string;
}

export interface V3AccountabilityTerms {
  bondId: bigint; aiCompany: `0x${string}`; counterparty: `0x${string}`;
  companyStake: bigint; stakeAsset: `0x${string}`;
  missionHash: `0x${string}`; objectiveBreachRulesHash: `0x${string}`;
  flourishRewardRulesHash: `0x${string}`; rewardProgramId: bigint;
  activePeriodStart: bigint; activePeriodEnd: bigint; challengeWindow: bigint;
  nonce: bigint; chainId: bigint; protocolVersion: string;
}

export interface V3Mandate {
  identityRegistryChainId: bigint; identityRegistry: `0x${string}`;
  principalAgentId: bigint; principal: `0x${string}`;
  operatorAgentId: bigint; operator: `0x${string}`;
  beneficiary: `0x${string}`;
  allowedActions: `0x${string}`[]; prohibitedActions: `0x${string}`[];
  allowedContracts: `0x${string}`[]; allowedSelectors: `0x${string}`[];
  spendAsset: `0x${string}`; spendCap: bigint; rateLimitPerHour: bigint;
  evidencePolicyId: `0x${string}`; disputePolicyId: `0x${string}`;
  notBefore: bigint; notAfter: bigint; nonce: bigint; chainId: bigint; protocolVersion: string;
}

export interface V3EscrowTask {
  taskId: bigint; creator: `0x${string}`; assignee: `0x${string}`;
  asset: `0x${string}`; amount: bigint;
  state: number;
}

export interface V3RewardProgram {
  programId: bigint; sponsor: `0x${string}`; asset: `0x${string}`;
  fundedAmount: bigint; committedAmount: bigint; paidAmount: bigint;
  maxLiability: bigint; startsAt: bigint; endsAt: bigint;
  cancelled: boolean;
}

export interface V3StreetCredScore {
  subject: `0x${string}`;
  schemaVersion: number; scoreBps: number; evidenceCount: number;
  evidenceRoot: `0x${string}`; lastUpdated: bigint; sybilFlagged: boolean;
}

export interface V3RouteRegistryEntry {
  id: string;
  method: "GET" | "POST" | "PUT" | "DELETE";
  path: string;
  free: boolean;
  version: ProtocolVersion;
  contractStatus: ContractStatus;
}
