///
import { EventEmitter } from "events";
import { type TablelandTables } from "@tableland/evm";
import { type TableIdentifier } from "../registry/contract.js";
import { type Config } from "../helpers/index.js";
type ContractMap = Record;
interface ContractEventListener {
eventName: string;
eventListener: (...args: any[]) => void;
}
type ListenerMap = Record;
/**
* Possible events that can be emitted by the Registry as defined in the
* ITablelandTables interface.
*/
export type ContractEventNames = "CreateTable" | "RunSQL" | "TransferTable" | "SetController";
/**
* A mapping of the contract events to the event names that will be emitted and
* where the corresponding `tableId` can be found in the event arguments.
* Optionally, the `emit` key/value can for subscribing to events.
* @template T The event names that will be emitted.
* @typedef {Object} EventTableIdMap
* @property {number} tableIdIndex Index of the tableId in the event arguments.
* @property {string} [emit] Event name that will be emitted.
*/
type EventTableIdMap = Record;
/**
* Mapping of all contract events to the event names and the location of
* `tableId` in the event arguments.
*/
type ContractEventTableIdMap = EventTableIdMap;
/**
* Mapping of all ITablelandTables contract events and `tableId` event index.
*/
export declare const contractEventsTableIdx: ContractEventTableIdMap;
/**
* TableEventBus provides a way to listen for:
* mutations, transfers, and changes to controller
*/
export declare class TableEventBus {
readonly config: Config;
readonly contracts: ContractMap;
readonly listeners: ListenerMap;
/**
* Create a TableEventBus instance with the specified connection configuration.
* @param config The connection configuration. This must include an ethersjs
* Signer. If passing the config from a pre-existing Database instance, it
* must have a non-null signer key defined.
*/
constructor(config?: Partial);
/**
* Start listening to the Registry Contract for events that are associated
* with a given table.
* There's only ever one "listener" for a table, but the emitter that
* Contract listener has can have as many event listeners as the environment
* supports.
* @param tableName The full name of table that you want to listen for
* changes to.
*/
addListener(tableName: string): Promise;
/**
* A simple wrapper around `addListener` that returns an async iterable
* which can be used with the for await ... of pattern.
* @param tableName The full name of table that you want to listen for
* changes to.
*/
addTableIterator(tableName: string): Promise>;
/**
* Remove a listener (or iterator) based on chain and tableId
* @param params A TableIdentifier Object. Must have `chainId` and `tableId` keys.
*/
removeListener(params: TableIdentifier): void;
removeAllListeners(): void;
_getContract(chainId: number): Promise;
_ensureListening(listenerId: string, emitter: EventEmitter): Promise;
_attachEmitter(contract: TablelandTables, emitter: EventEmitter, tableIdentifier: TableIdentifier): ContractEventListener[];
}
export {};
//# sourceMappingURL=subscribe.d.ts.map