navskit
Version:
Deploy TypeScript logic on Ethereum. Includes core library, CLI tools, and utilities.
129 lines (128 loc) • 5.19 kB
TypeScript
/**
* NAVS - Unified package for core functionality and deployment contracts
* Deploy TypeScript logic on Ethereum. Powered by EigenLayer.
*/
export * from './consensus';
export * from './tools';
export * from './types';
export * from './utils';
export * from './deploy';
/**
* Main entry point for NAVS (Node-Assisted Verification Service)
*/
import { Account } from 'viem';
import 'reflect-metadata';
import { TNavsConfig, NavsFunction, ExecuteOptions, TaskId, TFun, TOnResponses, TStrictNavsConfig, NavsConfig } from './types';
declare const __navsRegistry: Record<string, NavsFunction<any>>;
export declare const getConfig: () => TStrictNavsConfig;
/**
* Initialize NAVS with the provided configuration
*
* @param config Configuration options for NAVS
* @returns The NAVS client interface
*/
declare const navs: (_config: TNavsConfig) => {
config: TStrictNavsConfig;
setupService: (account: Account) => Promise<void>;
/**
* If running as a node, `main()` is the primary entrypoint for the node.
* This will listen for task events and execute the corresponding functions.
* Always outputs JSON results to stdout for processing by central operator.
*/
main(account?: Account): Promise<void>;
/**
* Challenge a task result by initiating a re-execution through the reexecution endpoint
*
* @param taskId The ID of the task to challenge
* @param account The account to use for the transaction
* @returns Transaction information for the challenge
*/
challenge(task: TaskId<any>, account: Account): Promise<{
transactionHash: `0x${string}`;
blockNumber: bigint;
taskId: string;
}>;
/**
* Get a list of all registered navs functions
*
* @returns Array of registered function information
*/
getRegisteredFunctions(): {
name: string;
serviceName: string;
paramTypes: string[];
returnType: string;
}[];
/**
* Execute a function through the TaskDispatch contract with full type safety
*
* @param fn The function reference to execute (must be decorated with @navs)
* @param args The arguments matching the function's parameter types
* @param options Execution options including account and stake threshold
* @returns A typed TaskId that can be awaited for the result
*/
execute<T extends (...args: any[]) => any>(fn: T, args: Parameters<T>, options: ExecuteOptions): Promise<TaskId<ReturnType<T>>>;
/**
* Execute a function through the TaskDispatch contract (string-based version)
*
* @deprecated Use the type-safe execute method with function references instead
* @param functionName The function name to call
* @param args The arguments to pass
* @param stakeThreshold The minimum stake threshold for agreement
* @param account The account to use for the transaction
* @returns The task ID (raw bigint)
*/
executeByName(functionName: string, args: any[], stakeThreshold: bigint | undefined, account: Account): Promise<bigint>;
/**
* Execute a function by name and return a typed TaskId that can be awaited
*
* @param functionName The name of the function to execute
* @param args The arguments to pass to the function
* @param options Options for execution including account and stake threshold
* @returns A typed TaskId that can be awaited for the result
*/
executeByNameTyped<T>(functionName: string, args: any[], options: ExecuteOptions): Promise<TaskId<T>>;
/**
* Get the status of a task
*
* @param taskId The ID of the task to check
* @returns Task status information
*/
getTaskStatus(taskId: bigint): Promise<{
exists: boolean;
completed: boolean;
failed: boolean;
finalResponse: `0x${string}`;
}>;
/**
* Creates a typed TaskId wrapper for an existing task
*
* @param taskId The task ID (bigint or string)
* @param expectedReturnType The expected return type for proper decoding
* @returns A typed TaskId that can be awaited for the result
*/
getTask<T>(taskId: bigint | string, expectedReturnType: string): Promise<TaskId<T>>;
/**
* Get the details of a task
*
* @param taskId The ID of the task to check
* @returns Task details
*/
getTaskDetails(taskId: bigint): Promise<{
serviceName: string;
serviceVersion: string;
functionName: string;
args: `0x${string}`;
stakeThreshold: bigint;
remainingStake: bigint;
}>;
/**
* Decorator function for registering functions with NAVS
*
* @param onResponse Optional consensus function for handling multiple operator responses
* @param config Optional configuration object with deterministic flag (deprecated - not fully implemented)
* @returns A decorator function
*/
navs<T extends TFun<any>>(onResponse?: TOnResponses<T>, navsConfig?: NavsConfig): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => TypedPropertyDescriptor<T>;
};
export { navs, __navsRegistry as navsRegistry };