import type { OpenChannelParams, Settlement } from "./protocol.js";
import { type ForwardTerms, type SessionOffer } from "./offers.js";
import type { Hash } from "./transcript.js";
/** A pallet event surfaced by a submitted extrinsic. */
export interface ChainEvent {
    section: string;
    method: string;
    /** Decoded fields keyed by the pallet's (camelCased) field names. */
    data: Record<string, unknown>;
}
/** Result of a submitted + included extrinsic. */
export interface SubmitResult {
    txHash: string;
    events: ChainEvent[];
}
/**
 * The minimal chain port the bridge needs: sign + submit one extrinsic by
 * `(pallet, method, args)` under a bound signer, resolving once included with
 * the emitted events. Tests inject a fake; production wraps `@polkadot/api`
 * (see the module doc).
 */
export interface ChainSubmitter {
    submit(pallet: string, method: string, args: unknown[]): Promise<SubmitResult>;
}
export interface OpenChannelResult {
    channelId: Hash;
    measuredRoot: Hash;
    escrow: bigint;
    txHash: string;
}
export type ForceOpenParams = Omit<OpenChannelParams, "enclaveKey" | "settlementClass">;
export interface OfferOpenParams {
    offer: SessionOffer;
    minerSignature: Uint8Array;
    measuredRoot: Hash;
    decodePolicyHash: Hash;
    agentKey: Uint8Array;
    escrow: bigint;
    agentSignature: Uint8Array;
    settlementClass?: OpenChannelParams["settlementClass"];
    /** Delegated-wallet limit checked before a forward pickup is submitted. */
    spendingLimit?: bigint;
}
export interface ForceOpenResult {
    channelId: Hash;
    ackDeadline: bigint;
    escrow: bigint;
    txHash: string;
}
export interface ForwardBidPostParams {
    modelHash: Hash;
    measuredRoot: Hash;
    decodePolicyHash: Hash;
    precision: number;
    agentKey: Uint8Array;
    maxTurns: number;
    maxDuration: bigint;
    reattestEvery: number;
    terms: ForwardTerms;
    nonce: bigint;
    spendingLimit: bigint;
}
export interface ForceOpenExpiredResult {
    channelId: Hash;
    refunded: bigint;
    failedAcks: number;
    txHash: string;
}
export interface TopUpResult {
    added: bigint;
    total: bigint;
    txHash: string;
}
export interface TimedOutResult {
    channelId: Hash;
    refunded: bigint;
    txHash: string;
}
export interface SettlementPostedResult {
    channelId: Hash;
    finalRoot: Hash;
    aggregateGn: bigint;
    challengeEnd: bigint;
    txHash: string;
}
export interface SettledResult {
    channelId: Hash;
    minerPaid: bigint;
    burned: bigint;
    aggregateGn: bigint;
    cooperative: boolean;
    txHash: string;
}
/**
 * Typed wrapper over the four agent-side `pallet_compute_channel` extrinsics:
 * open a session, splice in escrow, force-settle (the no-cooperation escape
 * hatch, R2), and finalize after the challenge window.
 */
export declare class ComputeChannelChainClient {
    private readonly chain;
    constructor(chain: ChainSubmitter);
    /** `open_channel`: escrow reserved capacity, commit the measured root, policy + keys. */
    openChannel(p: OpenChannelParams): Promise<OpenChannelResult>;
    /** `open_channel_with_offer`: direct Open from signed supply without rendezvous. */
    openChannelWithOffer(p: OfferOpenParams): Promise<OpenChannelResult>;
    /** Pre-fund the Policy escrow backing a miner's signed forward offer. */
    fundForwardOffer(offer: SessionOffer, minerSignature: Uint8Array): Promise<{
        txHash: string;
        events: ChainEvent[];
    }>;
    /** Release an unpicked forward offer after its signed expiry. */
    cancelFundedForwardOffer(offerNonce: bigint): Promise<{
        txHash: string;
    }>;
    /** Claim the liveness-backed availability earnout accrued so far. */
    claimForwardAvailability(channelId: Hash): Promise<{
        amount: bigint;
        cumulative: bigint;
        txHash: string;
    }>;
    /** Release the miner bond pro-rata to receipt-backed cumulative delivery. */
    releaseForwardBond(s: Pick<Settlement, "channelId" | "finalRoot" | "aggregateGn" | "agentReceiptSig" | "verifiedTurns">): Promise<{
        amount: bigint;
        cumulative: bigint;
        txHash: string;
    }>;
    /** Assign a forward position to a countersigning buyer. */
    assignForwardChannel(channelId: Hash, newAgent: string, newAgentKey: Uint8Array, newAgentSignature: Uint8Array): Promise<{
        txHash: string;
    }>;
    transferForwardUnits(channelId: Hash, to: string, units: bigint): Promise<{
        txHash: string;
    }>;
    claimForwardDistribution(channelId: Hash): Promise<{
        amount: bigint;
        units: bigint;
        txHash: string;
    }>;
    /** Quote whole holder rights for exact native-FLOP atoms; the channel keeps its receipt authority. */
    listForwardUnits(channelId: Hash, units: bigint, totalPrice: bigint, expiresAt: bigint): Promise<{
        listingId: Hash;
        txHash: string;
    }>;
    /** Fill the identified whole listing within the buyer's signed spending budget. */
    fillForwardListing(channelId: Hash, seller: string, listingId: Hash, maxTotalPrice: bigint): Promise<{
        txHash: string;
    }>;
    cancelForwardListing(channelId: Hash, seller: string, listingId: Hash): Promise<{
        txHash: string;
    }>;
    openForwardDraw(channelId: Hash, units: bigint, nonce: bigint): Promise<{
        drawId: Hash;
        aggregateUnits: bigint;
        txHash: string;
    }>;
    closeForwardDraw(channelId: Hash, drawId: Hash): Promise<{
        txHash: string;
    }>;
    /** Buyer-side posted demand; delegated spend is rejected before payment lock. */
    postForwardBid(p: ForwardBidPostParams): Promise<{
        bidId: Hash;
        txHash: string;
    }>;
    commitForwardBidClaim(bidId: Hash, commitment: Hash): Promise<{
        txHash: string;
    }>;
    /** Seal registration first; call again after delayed BABE entropy is available to start reveal. */
    sealForwardBidClaims(bidId: Hash): Promise<{
        txHash: string;
    }>;
    revealForwardBidClaim(bidId: Hash, enclaveKey: Uint8Array, salt: Hash): Promise<{
        txHash: string;
    }>;
    clearForwardBid(bidId: Hash): Promise<{
        txHash: string;
    }>;
    cancelForwardBid(bidId: Hash): Promise<{
        txHash: string;
    }>;
    /** `force_open`: permissionless request against a named miner. */
    forceOpen(p: ForceOpenParams): Promise<ForceOpenResult>;
    /** `force_ack`: named miner binds its enclave key and opens the channel. */
    forceAck(channelId: Hash, enclaveKey: Uint8Array): Promise<OpenChannelResult>;
    /** `expire_force_open`: permissionless full refund after the ack window. */
    expireForceOpen(channelId: Hash): Promise<ForceOpenExpiredResult>;
    /** `top_up_escrow`: raise a live session's reserved capacity (Lightning splice-in). */
    topUpEscrow(channelId: Hash, additional: bigint): Promise<TopUpResult>;
    /**
     * `settle` (cooperative): the miner posts the final root + aggregate `G_n`
     * together with the agent's co-signed receipt. Both parties agreed ⇒ nothing
     * to dispute ⇒ the escrow (minus the protocol burn) pays out to the miner in
     * the **same block** — no challenge window. Must be submitted by the miner.
     */
    settle(s: Settlement): Promise<SettledResult>;
    /** `force_settle`: post the latest signed receipt unilaterally; opens the window. */
    forceSettle(s: Settlement): Promise<SettlementPostedResult>;
    /** `finalize`: pay out a force-settled channel after its challenge window closes. */
    finalize(channelId: Hash): Promise<SettledResult>;
    /** `timeout`: refund an open channel after its max-duration deadline. */
    timeout(channelId: Hash): Promise<TimedOutResult>;
    /**
     * `submit_toploc_evidence` (D-0431 / #753): the miner records a per-turn TOPLOC
     * activation commitment for an `Open` channel — the mandatory settlement-gate
     * marker. Without at least one evidence submission, `settle` / `force_settle`
     * fail closed with `RequiredToplocEvidenceMissing`. Must be submitted by the
     * miner before settling.
     */
    submitToplocEvidence(channelId: Hash, commitmentRef: Hash): Promise<{
        txHash: string;
        events: ChainEvent[];
    }>;
    /** Allocate immutable session DA; null turnIndex selects the final transcript. */
    registerSessionEvidence(channelId: Hash, turnIndex: number | null, commitment: Hash, sizeBytes: number): Promise<SubmitResult>;
    /**
     * `report_toploc_mismatch`: BFT quorum of validator-signed lane/band mismatch
     * attestations → fraud slash + agent refund (or band escalate event).
     * Attestations should already be extrinsic-shaped (see
     * `toExtrinsicToplocMismatchAttestation` in toploc-checker).
     */
    reportToplocMismatch(channelId: Hash, miner: string, attestations: unknown[]): Promise<{
        txHash: string;
        events: ChainEvent[];
    }>;
    /**
     * `report_toploc_mismatch_claim`: shared attestation-result path. Claim must
     * bind the channel-turn subject and carry Fraud-tier quorum signatures.
     */
    reportToplocMismatchClaim(args: {
        channelId: Hash;
        miner: string;
        turnIndex: number;
        activationHash: Hash;
        recomputedHash: Hash;
        distance: {
            hammingMisses: number;
            l1Distance: number;
        };
        milliExponentError: bigint;
        claim: unknown;
    }): Promise<{
        txHash: string;
        events: ChainEvent[];
    }>;
}
//# sourceMappingURL=chain.d.ts.map