import type { VaultfireV3Config, V3BondTerms, V3AccountabilityTerms } from "./types";

/** Bonds module. Never redirects to V2; refuses writes when V3 is paused. */
export class BondsModuleV3 {
  constructor(private readonly cfg: VaultfireV3Config) {}

  async createPartnership(_terms: V3BondTerms, _sigA: `0x${string}`, _sigB: `0x${string}`): Promise<{ txHash: `0x${string}`; }> {
    throw new Error("wire to viem writeContract on PartnershipBondV3Safe.createBond");
  }

  async createAccountability(_terms: V3AccountabilityTerms, _sigCompany: `0x${string}`, _sigCounterparty: `0x${string}`): Promise<{ txHash: `0x${string}`; }> {
    throw new Error("wire to viem writeContract on AccountabilityBondV3Safe.createBond");
  }

  async withdrawCredit(_asset: `0x${string}`): Promise<{ txHash: `0x${string}`; }> {
    throw new Error("wire to viem writeContract on PullPaymentsV3.withdrawCredit");
  }

  async solvency(): Promise<any> {
    const url = `${this.cfg.baseUrl}/api/v3/protocol/solvency`;
    const res = await fetch(url);
    if (res.status === 503) throw new Error("data source unavailable — see dataSourceErrors");
    return res.json();
  }
}
