import type { APIClient } from "../api/Client.js";
import type { ABIDef } from "../chain/Abi.js";
import { Action } from "../chain/Action.js";
import type { NameType } from "../chain/Name.js";
import { type PermissionLevelType } from "../chain/PermissionLevel.js";
import type { GetTableByScopeParams, GetTableRowsParams, GetTableRowsResponse, TableIndexType } from "../api/v1/Types.js";
/** Contract action names that can be built from a typed action map. */
export type ContractActionKey<TActions extends object> = Extract<keyof TActions, string>;
/** Contract table names that can be read from a typed table map. */
export type ContractTableKey<TTables extends object> = Extract<keyof TTables, string>;
/** Runtime serializer used to turn generated action interfaces into ABI data. */
export type ContractActionSerializer<TData> = (data: TData) => unknown;
/** Permission level input accepted by generic contract action builders. */
export type ContractPermissionLevel = PermissionLevelType | string;
/** Runtime metadata for one contract action. */
export interface ContractActionDescriptor<TData> {
    /** ABI action name. */
    name: NameType;
    /** Optional runtime serializer for generated action data. */
    serialize: ContractActionSerializer<TData> | null;
}
/** Runtime metadata for one contract table. */
export interface ContractTableDescriptor<TRow> {
    /** ABI table name. */
    name: NameType;
    /** Type marker for generated table row data. */
    rowType: TRow | null;
}
/** Runtime metadata for a typed contract client. */
export interface ContractDescriptor<TActions extends object, TTables extends object> {
    /** Default account that hosts the contract. */
    account: NameType;
    /** Action metadata keyed by friendly action name. */
    actions: {
        [K in ContractActionKey<TActions>]: ContractActionDescriptor<TActions[K]>;
    };
    /** Table metadata keyed by friendly table name. */
    tables: {
        [K in ContractTableKey<TTables>]: ContractTableDescriptor<TTables[K]>;
    };
}
/** Options for constructing a typed contract client. */
export interface ContractClientOptions<TActions extends object, TTables extends object> {
    /** Chain API client used for RPC reads. */
    client: APIClient;
    /** Contract descriptor generated from, or aligned with, an ABI. */
    descriptor: ContractDescriptor<TActions, TTables>;
    /** Optional account override for deployments that do not use the descriptor account. */
    contract?: NameType;
}
/** Options for building one typed contract action. */
export interface ContractBuildActionOptions {
    /** Optional account override for this action only. */
    contract?: NameType;
    /** Optional ABI used when action data has no runtime serializer. */
    abi?: ABIDef;
}
/** Arguments accepted by `buildContractAction`. */
export interface BuildContractActionArgs<TData> extends ContractBuildActionOptions {
    /** Contract action metadata. */
    descriptor: ContractActionDescriptor<TData>;
    /** Default contract account. */
    contract: NameType;
    /** Permission levels authorizing the action. */
    authorization: ContractPermissionLevel[];
    /** Strongly typed action data. */
    data: TData;
}
/** Options for querying typed contract table rows. */
export type ContractTableRowsOptions<Index = TableIndexType | string> = Omit<GetTableRowsParams<Index>, "code" | "table">;
/** Options for querying typed contract table scopes. */
export type ContractTableScopesOptions = Omit<GetTableByScopeParams, "code" | "table">;
/** Typed action builder methods derived from a contract action map. */
export type ContractActionMethods<TActions extends object> = {
    [K in ContractActionKey<TActions>]: (data: TActions[K], authorization: ContractPermissionLevel[], options?: ContractBuildActionOptions) => Action;
};
/** Typed table clients derived from a contract table map. */
export type ContractTableClients<TTables extends object> = {
    [K in ContractTableKey<TTables>]: ContractTableClient<TTables[K]>;
};
/** Builds an ABI action from contract metadata and strongly typed data. */
export declare function buildContractAction<TData>(args: BuildContractActionArgs<TData>): Action;
/** Typed table reader for one contract table. */
export declare class ContractTableClient<TRow> {
    /** Table metadata. */
    readonly descriptor: ContractTableDescriptor<TRow>;
    private readonly contractClient;
    /** Creates a typed table client. */
    constructor(contractClient: ContractClient<any, any>, descriptor: ContractTableDescriptor<TRow>);
    /** Reads rows from this table, returning the generated row type. */
    rows<Index = TableIndexType | string>(options?: ContractTableRowsOptions<Index>): Promise<GetTableRowsResponse<Index, TRow>>;
    /** Reads the first row from this table, or null when no row is available. */
    first<Index = TableIndexType | string>(options?: ContractTableRowsOptions<Index>): Promise<TRow | null>;
    /** Lists scopes that currently contain rows for this table. */
    scopes(options?: ContractTableScopesOptions): Promise<string[]>;
}
/** Generic typed contract client backed by generated action and table maps. */
export declare class ContractClient<TActions extends object, TTables extends object> {
    /** Chain API client used for RPC reads. */
    readonly client: APIClient;
    /** Contract account used by this client. */
    readonly contract: NameType;
    /** Contract metadata. */
    readonly descriptor: ContractDescriptor<TActions, TTables>;
    /** Typed action builder methods. */
    readonly actions: ContractActionMethods<TActions>;
    /** Typed table readers. */
    readonly tables: ContractTableClients<TTables>;
    /** Creates a typed contract client. */
    constructor(options: ContractClientOptions<TActions, TTables>);
    /** Builds one action by descriptor key. */
    buildAction<K extends ContractActionKey<TActions>>(action: K, data: TActions[K], authorization: ContractPermissionLevel[], options?: ContractBuildActionOptions): Action;
    /** Returns a typed table reader by descriptor key. */
    table<K extends ContractTableKey<TTables>>(table: K): ContractTableClient<TTables[K]>;
    private createActionMethods;
    private createTableClients;
}
/** Creates a typed contract client from a descriptor. */
export declare function createContractClient<TActions extends object, TTables extends object>(options: ContractClientOptions<TActions, TTables>): ContractClient<TActions, TTables>;
//# sourceMappingURL=Contract.d.ts.map