@hyperlane-xyz/registry
Version:
A collection of configs, artifacts, and schemas for Hyperlane
93 lines (92 loc) • 4.22 kB
TypeScript
import type { Logger } from 'pino';
import type { ChainMap, ChainMetadata, ChainName, WarpCoreConfig, WarpRouteDeployConfig } from '@hyperlane-xyz/sdk';
import { ChainAddresses, UpdateChainParams, WarpDeployConfigMap, WarpRouteConfigMap, WarpRouteFilterParams } from '../types.js';
import { BaseRegistry } from './BaseRegistry.js';
import { AddWarpRouteConfigOptions, ChainFiles, IRegistry, IRegistryMethods, RegistryContent, RegistryType } from './IRegistry.js';
export interface GithubRegistryOptions {
uri?: string;
proxyUrl?: string;
branch?: string;
authToken?: string;
logger?: Logger;
/**
* Override browser detection. Defaults to true if running in a browser environment.
*/
isBrowser?: boolean;
}
type GithubRateResponse = {
resources: {
core: {
limit: number;
used: number;
remaining: number;
reset: number;
};
};
};
export declare const GITHUB_API_URL = "https://api.github.com";
export declare const GITHUB_API_VERSION = "2022-11-28";
export declare class GithubFetchError extends Error {
readonly status: number;
readonly statusText: string;
constructor(response: Response);
}
/**
* A registry that uses a github repository as its data source.
* Reads are performed via the github API and github's raw content URLs.
* Writes are not yet supported (TODO)
*/
export declare class GithubRegistry extends BaseRegistry implements IRegistry {
readonly type = RegistryType.Github;
readonly url: URL;
readonly branch: string;
readonly repoOwner: string;
readonly repoName: string;
readonly proxyUrl: string | undefined;
private readonly authToken;
/** True when running in a browser environment (overridable via options). */
private readonly isBrowser;
private archiveEntries?;
private archiveEntriesPromise?;
readonly unimplementedMethods: Set<IRegistryMethods>;
private readonly baseApiHeaders;
constructor(options?: GithubRegistryOptions);
getUri(itemPath?: string): string;
listRegistryContent(): Promise<RegistryContent>;
getChains(): Promise<Array<ChainName>>;
getMetadata(): Promise<ChainMap<ChainMetadata>>;
getChainMetadata(chainName: ChainName): Promise<ChainMetadata | null>;
getAddresses(): Promise<ChainMap<ChainAddresses>>;
getChainAddresses(chainName: ChainName): Promise<ChainAddresses | null>;
addChain(_chains: UpdateChainParams): Promise<void>;
updateChain(_chains: UpdateChainParams): Promise<void>;
removeChain(_chains: ChainName): Promise<void>;
getWarpRoute(routeId: string): Promise<WarpCoreConfig | null>;
getWarpDeployConfig(routeId: string): Promise<WarpRouteDeployConfig | null>;
getWarpRoutes(filter?: WarpRouteFilterParams): Promise<WarpRouteConfigMap>;
getWarpDeployConfigs(filter?: WarpRouteFilterParams): Promise<WarpDeployConfigMap>;
protected readConfigs<ConfigMap>(routeIds: string[], routeConfigUrls: string[]): Promise<Record<string, ConfigMap>>;
addWarpRoute(_config: WarpCoreConfig): Promise<void>;
addWarpRouteConfig(_config: WarpRouteDeployConfig, _options: AddWarpRouteConfigOptions): Promise<void>;
getApiUrl(): Promise<string>;
getApiRateLimit(): Promise<GithubRateResponse['resources']['core']>;
protected getRawContentUrl(path: string): string;
protected fetchChainFile<T>(fileName: keyof ChainFiles, chainName: ChainName): Promise<T | null>;
protected fetchYamlFiles<T>(urls: string[]): Promise<T[]>;
/**
* Returns an array of URLs to download the repository zip archive.
* If authToken is set, returns the GitHub API zipball endpoint URL only.
* Otherwise returns public archive URLs for branch, tag, and commit-SHA fallbacks.
*/
protected getArchiveDownloadUrls(): Promise<string[]>;
/**
* Ensure the repository archive is downloaded and entries are cached in memory.
*/
protected ensureArchiveEntries(): Promise<void>;
/**
* Fetch a YAML file, using in-memory archive if available for raw content paths.
*/
protected fetchYamlFile<T>(url: string): Promise<T>;
protected fetch(url: string): Promise<Response>;
}
export {};