diff --git a/package.json b/package.json index 59e2859dd..ce944a794 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "name": "@hyperlane-xyz/registry", "description": "A collection of configs, artifacts, and schemas for Hyperlane", "version": "1.0.2", + "dependencies": { + "yaml": "^2" + }, "devDependencies": { "@changesets/cli": "^2.26.2", "@hyperlane-xyz/sdk": "3.10.0", @@ -14,7 +17,6 @@ "prettier": "^2.8.8", "tsx": "^4.7.1", "typescript": "5.3.3", - "yaml": "^2.3.1", "zod": "^3.21.2", "zod-to-json-schema": "^3.22.5" }, diff --git a/src/registry/BaseRegistry.ts b/src/registry/BaseRegistry.ts index 5816bc229..839bbf667 100644 --- a/src/registry/BaseRegistry.ts +++ b/src/registry/BaseRegistry.ts @@ -1,9 +1,7 @@ import type { Logger } from 'pino'; -import { rootLogger } from '@hyperlane-xyz/utils'; - -import { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk'; -import { ChainAddresses, IRegistry, RegistryContent } from './IRegistry.js'; +import type { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk'; +import type { ChainAddresses, IRegistry, RegistryContent } from './IRegistry.js'; export abstract class BaseRegistry implements IRegistry { protected readonly logger: Logger; @@ -13,8 +11,11 @@ export abstract class BaseRegistry implements IRegistry { protected metadataCache?: ChainMap; protected addressCache?: ChainMap; - constructor({ logger = rootLogger.child({ module: 'Registry' }) }: { logger?: Logger }) { - this.logger = logger; + constructor({ logger }: { logger?: Logger }) { + // @ts-ignore forcing in to avoid a @hyperlane-xyz/utils + // dependency here, which could bloat consumer bundles + // unnecessarily (e.g. they just want metadata) + this.logger = logger || console; } protected getChainsPath(): string { diff --git a/src/registry/GithubRegistry.ts b/src/registry/GithubRegistry.ts index dd9c49e51..8652667e7 100644 --- a/src/registry/GithubRegistry.ts +++ b/src/registry/GithubRegistry.ts @@ -1,12 +1,10 @@ import type { Logger } from 'pino'; import { parse } from 'yaml'; -import { rootLogger } from '@hyperlane-xyz/utils'; - -import { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk'; +import type { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk'; import { BaseRegistry } from './BaseRegistry.js'; -import { ChainAddresses, ChainFiles, IRegistry, RegistryContent } from './IRegistry.js'; +import type { ChainAddresses, ChainFiles, IRegistry, RegistryContent } from './IRegistry.js'; const DEFAULT_REGISTRY = 'https://github.com/hyperlane-xyz/hyperlane-registry'; const CHAIN_FILE_REGEX = /chains\/([a-z]+)\/([a-z]+)\.yaml/; @@ -33,9 +31,7 @@ export class GithubRegistry extends BaseRegistry implements IRegistry { public readonly repoName: string; constructor(options: GithubRegistryOptions = {}) { - super({ - logger: options.logger ?? rootLogger.child({ module: 'GithubRegistry' }), - }); + super({ logger: options.logger }); this.url = new URL(options.url ?? DEFAULT_REGISTRY); this.branch = options.branch ?? 'main'; const pathSegments = this.url.pathname.split('/');