import { type PublicClient, type TypedDataDomain } from "viem";
import type { Account, Address, Chain, Hex, Transport, WalletClient } from "viem";
import type { DispatchModel } from "./capabilities.js";
import type { SerializedTypedData } from "./signing.js";
import type { ILocalKeyring } from "./types.js";
/** EIP-712 domain for the SailKernel on a given chain. */
export declare function sailKernelDomain(args: {
    chainId: number;
    kernel: Address;
}): TypedDataDomain;
/**
 * EIP-712 Dispatch struct field lists, keyed by dispatch model.
 *
 * This is the canonical definition used by BOTH `buildDispatchSignature` (the
 * public helper) and `SailorClient.dispatch.single()` (the internal path) — a
 * single source of truth that makes it impossible for the two paths to diverge.
 * Selective kernels include the `permission` field; conjunctive kernels do not.
 */
export declare const DISPATCH_EIP712_FIELDS: {
    readonly selective: readonly [{
        readonly name: "account";
        readonly type: "address";
    }, {
        readonly name: "permission";
        readonly type: "address";
    }, {
        readonly name: "target";
        readonly type: "address";
    }, {
        readonly name: "value";
        readonly type: "uint256";
    }, {
        readonly name: "dataHash";
        readonly type: "bytes32";
    }, {
        readonly name: "nonce";
        readonly type: "uint256";
    }, {
        readonly name: "deadline";
        readonly type: "uint256";
    }];
    readonly conjunctive: readonly [{
        readonly name: "account";
        readonly type: "address";
    }, {
        readonly name: "target";
        readonly type: "address";
    }, {
        readonly name: "value";
        readonly type: "uint256";
    }, {
        readonly name: "dataHash";
        readonly type: "bytes32";
    }, {
        readonly name: "nonce";
        readonly type: "uint256";
    }, {
        readonly name: "deadline";
        readonly type: "uint256";
    }];
};
/**
 * Build a signed EIP-712 Dispatch payload for a SailKernel manager dispatch.
 *
 * ### Why there is no `model` / `dispatchModel` parameter
 *
 * The Phase 1 incident established that the single most dangerous mistake an
 * operator can make is using the wrong dispatch model. The conjunctive struct
 * (6 fields, no `permission`) and the selective struct (7 fields, with
 * `permission`) produce different EIP-712 digests; signing the wrong one
 * recovers a random address and reverts with `InvalidManagerSignature()`.
 *
 * This function reads the on-chain `DISPATCH_TYPEHASH` from the kernel before
 * signing — the correct struct is selected automatically regardless of what the
 * caller believes the model to be. Callers cannot supply a model override; if
 * the on-chain read fails (bad RPC, wrong kernel address), the function throws
 * a clear error rather than signing blindly against an assumed model.
 *
 * @example
 * ```ts
 * const { signature, nonce, deadline } = await buildDispatchSignature({
 *   publicClient,
 *   kernel: "0x6319d3df...",
 *   chainId: 8453,
 *   account: mySafe,
 *   permission: myPermission,
 *   call: { target: router, value: 0n, data: swapCalldata },
 *   manager: myKeyring,
 * });
 * // Then submit: kernel.dispatch(account, permission, target, value, data, signature, deadline)
 * ```
 */
export declare function buildDispatchSignature(params: {
    /** viem public client bound to the kernel's chain. */
    publicClient: PublicClient;
    /** Deployed SailKernel address. */
    kernel: Address;
    /** EVM chain id — required for the EIP-712 domain separator. */
    chainId: number;
    /** The Safe (SMA) account executing the dispatch. */
    account: Address;
    /**
     * The registered permission that authorises this call.
     * Required by selective kernels — the `permission` field is part of the
     * signed struct and the kernel rejects dispatches that name an
     * unregistered permission.
     */
    permission: Address;
    /** The call to execute: target contract, ETH value (wei), and calldata. */
    call: {
        target: Address;
        value: bigint;
        data: Hex;
    };
    /** Manager key (the agent's hot key) that will sign the dispatch. */
    manager: ILocalKeyring;
    /**
     * Signature deadline as a Unix timestamp (seconds).
     * Defaults to now + 600 s (10 minutes).
     */
    deadline?: bigint;
    /**
     * Manager nonce to sign with.
     * Defaults to the current on-chain `managerNonces[account]` value.
     * Pass an explicit value when submitting sequential dispatches whose
     * nonce ordering you control.
     */
    nonce?: bigint;
}): Promise<{
    /** Raw EIP-712 signature bytes — pass directly to `kernel.dispatch`. */
    signature: Hex;
    /** The nonce that was signed (on-chain value or explicit override). */
    nonce: bigint;
    /** The deadline that was signed (unix seconds). */
    deadline: bigint;
    /**
     * The dispatch model detected from the on-chain DISPATCH_TYPEHASH.
     * Informational — the correct struct was already selected for this signature.
     */
    dispatchModel: DispatchModel;
}>;
/**
 * EIP-712 types for RegisterPermission — selective kernel (withDeadline variant).
 * Used when detectKernelCapabilities reports registerPermissionHasDeadline = true.
 */
export declare const REGISTER_PERMISSION_TYPES: {
    readonly RegisterPermission: readonly [{
        readonly name: "account";
        readonly type: "address";
    }, {
        readonly name: "permission";
        readonly type: "address";
    }, {
        readonly name: "nonce";
        readonly type: "uint256";
    }, {
        readonly name: "deadline";
        readonly type: "uint256";
    }];
};
/**
 * EIP-712 types for RegisterPermission — conjunctive kernel (noDeadline variant).
 * Used when detectKernelCapabilities reports registerPermissionHasDeadline = false.
 */
export declare const REGISTER_PERMISSION_TYPES_NO_DEADLINE: {
    readonly RegisterPermission: readonly [{
        readonly name: "account";
        readonly type: "address";
    }, {
        readonly name: "permission";
        readonly type: "address";
    }, {
        readonly name: "nonce";
        readonly type: "uint256";
    }];
};
/**
 * Build a JSON-serializable RegisterPermission typed-data payload for the
 * browser signing station. Bigints are stringified so it survives transport;
 * the UI re-parses decimal-string fields before signing.
 *
 * Pass `hasDeadline` from KernelCapabilities.registerPermissionHasDeadline.
 * All bundled kernels (Base, Base Sepolia, Arbitrum) are now selective and include
 * the deadline field. This flag exists for older or custom kernels that predate the
 * selective model. detectKernelCapabilities resolves this from the on-chain REGISTER_PERMISSION_TYPEHASH.
 */
export declare function buildRegisterPermissionTypedData(args: {
    chainId: number;
    kernel: Address;
    account: Address;
    permission: Address;
    nonce: bigint;
    /**
     * Whether the kernel's RegisterPermission type includes a deadline field.
     * Read from KernelCapabilities.registerPermissionHasDeadline.
     * Defaults to false (conjunctive, no deadline) — the safer choice when unknown,
     * since including an unexpected field causes an on-chain signature mismatch.
     */
    hasDeadline?: boolean;
    /** Signature deadline (unix seconds). Only used when hasDeadline = true. Defaults to 5 minutes from now. */
    deadline?: bigint;
}): SerializedTypedData;
/**
 * EIP-712 types for RegisterPermissions (batch) — selective kernel. Mirrors the
 * shape SailorClient.mandate.attachBatch signs and the on-chain
 * registerPermissions(account, permissions[], deadline, sig) entry point.
 */
export declare const REGISTER_PERMISSIONS_BATCH_TYPES: {
    readonly RegisterPermissions: readonly [{
        readonly name: "account";
        readonly type: "address";
    }, {
        readonly name: "permissions";
        readonly type: "address[]";
    }, {
        readonly name: "nonce";
        readonly type: "uint256";
    }, {
        readonly name: "deadline";
        readonly type: "uint256";
    }];
};
/**
 * Build a JSON-serializable RegisterPermissions (batch) typed-data payload for
 * the browser signing station — the re-approval step after a manager rotation,
 * which rebinds every previously-attached mandate to the new delegated signer in
 * a single owner signature + tx. Bigints are stringified for transport.
 */
export declare function buildRegisterPermissionsBatchTypedData(args: {
    chainId: number;
    kernel: Address;
    account: Address;
    permissions: Address[];
    nonce: bigint;
    /** Signature deadline (unix seconds). Defaults to 10 minutes from now. */
    deadline?: bigint;
}): SerializedTypedData;
/**
 * Sign a RegisterPermission message directly with a wallet client. Used by
 * headless flows (tests / scripts) where the owner's key is local rather than
 * in a browser. The browser path uses buildRegisterPermissionTypedData instead.
 *
 * Pass `hasDeadline` from KernelCapabilities.registerPermissionHasDeadline.
 */
export declare function signRegisterPermission(args: {
    walletClient: WalletClient<Transport, Chain, Account>;
    chainId: number;
    kernel: Address;
    account: Address;
    permission: Address;
    nonce: bigint;
    /** Whether the kernel's RegisterPermission type includes a deadline field. Defaults to false. */
    hasDeadline?: boolean;
    /** Signature deadline (unix seconds). Only used when hasDeadline = true. Defaults to 5 minutes from now. */
    deadline?: bigint;
}): Promise<Hex>;
//# sourceMappingURL=eip712.d.ts.map