@aibtc/types
Version:
TypeScript types for AIBTC
55 lines (54 loc) • 2.49 kB
TypeScript
import { ContractType, ContractSubtype } from "./utilities/contract-types";
export interface EnrichedErrorCodeDetail {
contractType: ContractType;
contractSubtype: ContractSubtype<ContractType>;
contractName: string;
code: number;
name: string;
description: string;
}
/**
* Retrieves all known error details.
* @returns A shallow copy of the list of all enriched error code details.
*/
export declare function getAllErrorDetails(): EnrichedErrorCodeDetail[];
/**
* Retrieves error details for a specific contract type and subtype.
* @param params Parameters to filter errors by.
* @param params.type The contract type.
* @param params.subtype The contract subtype.
* @returns An array of enriched error code details matching the contract type and subtype.
*/
export declare function getErrorsByContractDetails(params: {
type: ContractType;
subtype: ContractSubtype<ContractType>;
}): EnrichedErrorCodeDetail[];
/**
* Finds error details based on various criteria.
* This is a flexible search function.
* @param params Parameters to filter errors by.
* @param params.identifier Optional. Error name (string) or code (number or "u" prefixed string like "u1234").
* @param params.contractType Optional. The contract type to scope the search.
* @param params.contractSubtype Optional. The contract subtype to scope the search.
* @returns An array of enriched error code details matching the criteria.
*/
export declare function findErrorDetails(params: {
identifier?: string | number;
contractType?: ContractType;
contractSubtype?: ContractSubtype<ContractType>;
}): EnrichedErrorCodeDetail[];
/**
* Retrieves the description for a specific error.
* For reliable results when using an error name as an identifier,
* contractType and contractSubtype should be provided to ensure uniqueness.
* @param params Parameters to identify the error.
* @param params.identifier Error name (string) or code (number or "u" prefixed string).
* @param params.contractType Required when identifier is a name to ensure uniqueness. Recommended for code.
* @param params.contractSubtype Required when identifier is a name to ensure uniqueness. Recommended for code.
* @returns The error description if a unique match is found, otherwise undefined.
*/
export declare function getErrorDescription(params: {
identifier: string | number;
contractType: ContractType;
contractSubtype: ContractSubtype<ContractType>;
}): string | undefined;