UNPKG

@hyperlane-xyz/registry

Version:

A collection of configs, artifacts, and schemas for Hyperlane

64 lines (63 loc) 3.77 kB
import type { Logger } from 'pino'; import { ChainMap, ChainMetadata, ChainName, WarpCoreConfig, WarpRouteDeployConfig } from '@hyperlane-xyz/sdk'; import type { ChainAddresses, MaybePromise, UpdateChainParams, WarpDeployConfigMap, WarpRouteFilterParams, WarpRouteId } from '../types.js'; import { WarpRouteConfigMap } from '../types.js'; import type { AddWarpRouteConfigOptions, IRegistry, RegistryContent, RegistryType } from './IRegistry.js'; export declare abstract class BaseRegistry implements IRegistry { abstract type: RegistryType; readonly uri: string; protected readonly logger: Logger; protected listContentCache?: RegistryContent; protected metadataCache?: ChainMap<ChainMetadata>; protected isMetadataCacheFull: boolean; protected addressCache?: ChainMap<ChainAddresses>; protected isAddressCacheFull: boolean; protected warpRouteCache?: WarpRouteConfigMap; protected isWarpRouteCacheFull: boolean; constructor({ uri, logger }: { uri: string; logger?: Logger; }); getUri(itemPath?: string): string; protected getChainsPath(): string; protected getWarpRoutesPath(): string; /** * Generates a warp route ID from a warp core config. * * The function handles three main cases: * 1. If a warpRouteId is provided in options, it uses that directly * 2. If there is exactly one synthetic token, it uses that token's chain and symbol * 3. Otherwise, it uses all chains and requires a single symbol (either from options or tokens) */ static warpRouteConfigToId(config: WarpCoreConfig, options?: AddWarpRouteConfigOptions): WarpRouteId; protected getWarpRouteCoreConfigPath(config: WarpCoreConfig, options?: AddWarpRouteConfigOptions): string; /** * Generates a warp route ID based on the deploy config and options. * * @param config The warp route deployment config * @param options Additional config options for the warp route * @returns A string ID for the warp route * * If a warpRouteId is provided in options, use it directly. * Otherwise, the method attempts to generate an ID based on 1 synthetic chain, or defaults to all chains. */ static warpDeployConfigToId(config: WarpRouteDeployConfig, options: AddWarpRouteConfigOptions): string; protected getWarpRouteDeployConfigPath(config: WarpRouteDeployConfig, options: AddWarpRouteConfigOptions): string; abstract listRegistryContent(): MaybePromise<RegistryContent>; abstract getChains(): MaybePromise<Array<ChainName>>; abstract getMetadata(): MaybePromise<ChainMap<ChainMetadata>>; abstract getChainMetadata(chainName: ChainName): MaybePromise<ChainMetadata | null>; abstract getAddresses(): MaybePromise<ChainMap<ChainAddresses>>; abstract getChainAddresses(chainName: ChainName): MaybePromise<ChainAddresses | null>; getChainLogoUri(chainName: ChainName): Promise<string | null>; abstract addChain(chain: UpdateChainParams): MaybePromise<void>; abstract updateChain(chain: UpdateChainParams): MaybePromise<void>; abstract removeChain(chain: ChainName): MaybePromise<void>; abstract getWarpRoute(routeId: string): MaybePromise<WarpCoreConfig | null>; abstract getWarpRoutes(filter?: WarpRouteFilterParams): MaybePromise<WarpRouteConfigMap>; abstract addWarpRoute(config: WarpCoreConfig): MaybePromise<void>; abstract addWarpRouteConfig(warpConfig: WarpRouteDeployConfig, options: AddWarpRouteConfigOptions): MaybePromise<void>; abstract getWarpDeployConfig(routeId: string): MaybePromise<WarpRouteDeployConfig | null>; abstract getWarpDeployConfigs(filter?: WarpRouteFilterParams): MaybePromise<WarpDeployConfigMap>; merge(otherRegistry: IRegistry): IRegistry; }