import { type Logger } from '@hyperlane-xyz/utils'; import { Artifact, ArtifactDeployed, ArtifactNew, ConfigOnChain, IArtifactManager } from './artifact.js'; import { ChainLookup } from './chain.js'; import { type DeployedFeeAddress, type DerivedFeeConfig, type FeeArtifactConfig, type FeeConfig, type FeeReadContext } from './fee.js'; import { type DeployedHookAddress, type DerivedHookConfig, type HookArtifactConfig, type HookConfig } from './hook.js'; import { type DeployedIsmAddress, type DerivedIsmConfig, type IsmArtifactConfig, type IsmConfig } from './ism.js'; export type TokenRouterModuleType = { config: WarpConfig; derived: DerivedWarpConfig; addresses: WarpRouteAddresses; }; export declare const TokenType: { readonly synthetic: "synthetic"; readonly collateral: "collateral"; readonly native: "native"; readonly crossCollateral: "crossCollateral"; }; export type TokenType = (typeof TokenType)[keyof typeof TokenType]; export type RemoteRouters = Record; export type DestinationGas = Record; export interface BaseWarpConfig { owner: string; mailbox: string; interchainSecurityModule?: IsmConfig | string; hook?: HookConfig | string; fee?: FeeConfig | string; remoteRouters?: RemoteRouters; destinationGas?: DestinationGas; scale?: number; } export interface CollateralWarpConfig extends BaseWarpConfig { type: 'collateral'; token: string; } export interface SyntheticWarpConfig extends BaseWarpConfig { type: 'synthetic'; name?: string; symbol?: string; decimals?: number; metadataUri?: string; } export interface NativeWarpConfig extends BaseWarpConfig { type: 'native'; } export interface CrossCollateralWarpConfig extends BaseWarpConfig { type: 'crossCollateral'; token: string; crossCollateralRouters?: Record; } export type WarpConfig = CollateralWarpConfig | SyntheticWarpConfig | NativeWarpConfig | CrossCollateralWarpConfig; export interface BaseDerivedWarpConfig { owner: string; mailbox: string; interchainSecurityModule: DerivedIsmConfig | string; hook: DerivedHookConfig | string; fee?: DerivedFeeConfig | string; remoteRouters: RemoteRouters; destinationGas: DestinationGas; scale?: number; } export interface DerivedCollateralWarpConfig extends BaseDerivedWarpConfig { type: 'collateral'; token: string; name?: string; symbol?: string; decimals?: number; } export interface DerivedSyntheticWarpConfig extends BaseDerivedWarpConfig { type: 'synthetic'; name?: string; symbol?: string; decimals?: number; metadataUri?: string; } export interface DerivedNativeWarpConfig extends BaseDerivedWarpConfig { type: 'native'; } export interface DerivedCrossCollateralWarpConfig extends BaseDerivedWarpConfig { type: 'crossCollateral'; token: string; name?: string; symbol?: string; decimals?: number; crossCollateralRouters: Record; } export type DerivedWarpConfig = DerivedCollateralWarpConfig | DerivedSyntheticWarpConfig | DerivedNativeWarpConfig | DerivedCrossCollateralWarpConfig; export type WarpRouteAddresses = { deployedTokenRoute: string; }; export interface DeployedWarpAddress { address: string; } /** * Base warp config for Artifact API. * Uses domain IDs (numbers) instead of chain names (strings) for remoteRouters and destinationGas keys. * ISM can be a nested artifact or just an address. */ interface BaseWarpArtifactConfig { owner: string; mailbox: string; interchainSecurityModule?: Artifact; hook?: Artifact; fee?: Artifact; remoteRouters: Record; destinationGas: Record; name?: string; symbol?: string; decimals?: number; scale?: number; } export interface CollateralWarpArtifactConfig extends BaseWarpArtifactConfig { type: typeof TokenType.collateral; token: string; } export interface SyntheticWarpArtifactConfig extends BaseWarpArtifactConfig { type: typeof TokenType.synthetic; name: string; symbol: string; decimals: number; metadataUri?: string; } export interface NativeWarpArtifactConfig extends BaseWarpArtifactConfig { type: typeof TokenType.native; } export interface CrossCollateralWarpArtifactConfig extends BaseWarpArtifactConfig { type: typeof TokenType.crossCollateral; token: string; crossCollateralRouters: Record>; } export interface WarpArtifactConfigs { collateral: CollateralWarpArtifactConfig; synthetic: SyntheticWarpArtifactConfig; native: NativeWarpArtifactConfig; crossCollateral: CrossCollateralWarpArtifactConfig; } export type WarpType = keyof WarpArtifactConfigs; /** * Should be used for the specific artifact code that * deploys or reads any kind of warp token */ export type WarpArtifactConfig = WarpArtifactConfigs[WarpType]; /** * Describes the configuration of deployed warp token */ export type DeployedWarpArtifact = ArtifactDeployed; /** * Should be used to implement an object/closure or class that is in charge of coordinating * deployment of a warp token config */ export type IWarpArtifactManager = IArtifactManager; export type RawCollateralWarpArtifactConfig = ConfigOnChain; export type RawSyntheticWarpArtifactConfig = ConfigOnChain; export type RawNativeWarpArtifactConfig = ConfigOnChain; export type RawCrossCollateralWarpArtifactConfig = ConfigOnChain; export interface RawWarpArtifactConfigs { collateral: RawCollateralWarpArtifactConfig; synthetic: RawSyntheticWarpArtifactConfig; native: RawNativeWarpArtifactConfig; crossCollateral: RawCrossCollateralWarpArtifactConfig; } /** * Should be used for the specific artifact code that * deploys or reads a single warp token artifact on chain */ export type RawWarpArtifactConfig = RawWarpArtifactConfigs[WarpType]; /** * Describes the configuration of deployed Warp artifact without nested config expansion */ export type DeployedRawWarpArtifact = ArtifactDeployed; /** * Should be used to implement an object/closure or class that individually deploys * warp tokens on chain */ export interface IRawWarpArtifactManager extends IArtifactManager { /** * Read any warp token by detecting its type and delegating to the appropriate reader. * This is the generic entry point for reading warp tokens of unknown types. * @param address The on-chain address of the warp token * @returns The artifact configuration and deployment data */ readWarpToken(address: string): Promise; /** * Whether this protocol supports attaching hook configs to warp tokens. * Protocols that don't implement setTokenHook should return false. */ supportsHookUpdates(): boolean; } /** * Converts WarpConfig (Config API) to WarpArtifactConfig (Artifact API). * * Key transformations: * - String chain names → numeric domain IDs for remoteRouters/destinationGas keys * - ISM config → ISM artifact (handled by caller, passed through here) * * @param config The warp configuration using Config API format * @param chainLookup Chain lookup interface for resolving chain names to domain IDs * @param logger Logger for warnings * @returns Artifact wrapper around WarpArtifactConfig suitable for artifact writers */ export declare function warpConfigToArtifact(config: WarpConfig, chainLookup: ChainLookup, logger?: Logger): ArtifactNew; /** * Converts a DeployedWarpArtifact to DerivedWarpConfig format. * This handles the conversion between the new Artifact API and the old Config API. * * @param artifact The deployed warp artifact from the Artifact API * @param chainLookup Chain lookup interface for resolving domain IDs to chain names * @param derivedIsm Optional derived ISM config if ISM is configured * @returns Warp configuration in Config API format with address */ export declare function warpArtifactToDerivedConfig(artifact: DeployedWarpArtifact, chainLookup: ChainLookup): DerivedWarpConfig; /** * Builds a FeeReadContext by unioning domains/routers from the provided * WarpArtifactConfigs. Pass both expected and current configs so the fee * reader can discover routes from current state (for cleanup) and expected * state (for setup). */ export declare function buildFeeReadContextFromWarpArtifactConfig(...configs: WarpArtifactConfig[]): FeeReadContext; export interface WarpRouterDiff { /** Routers that need to be enrolled or updated */ toEnroll: Array<{ domainId: number; routerAddress: string; gas: string; }>; /** Domain IDs where router needs to be unenrolled */ toUnenroll: number[]; } type RemoteRoutersConfig = Pick; /** * Computes which routers need enrollment/unenrollment by diffing current and expected configs. * Pure function - compares router addresses and destination gas to determine required updates. * * @param currentRoutersConfig Current on-chain router state * @param expectedRoutersConfig Desired router state * @param compareAddresses VM-specific address comparison (handles case/format differences) * @returns Lists of domains to enroll/unenroll */ export declare function computeRemoteRoutersUpdates(currentRoutersConfig: Readonly, expectedRoutersConfig: Readonly, compareAddresses: (a: string, b: string) => boolean): WarpRouterDiff; export interface CrossCollateralRouterDiff { /** Per-domain routers to enroll */ toEnroll: Record>; /** Per-domain routers to unenroll (null = bulk-remove entire domain) */ toUnenroll: Record | null>; } /** * Computes which cross-collateral routers need enrollment/unenrollment by * diffing current and expected CC router maps. * Pure function — protocol-agnostic. Addresses are canonicalized to lowercase * hex32 before comparison so callers don't need to normalize beforehand. */ export declare function computeCrossCollateralRouterUpdates(current: Readonly>>, expected: Readonly>>): CrossCollateralRouterDiff; export interface CCGasConfigDiff { toEnroll: Array<{ domain: number; gas: string; }>; toUnenroll: number[]; } /** * Computes destination gas updates for CC-only domains — domains present in * crossCollateralRouters but NOT in remoteRouters. * Pure function — protocol-agnostic. */ export declare function computeCCRouterGasConfigUpdates(currentDestinationGas: Readonly>, expectedDestinationGas: Readonly>, expectedRemoteRouterDomains: ReadonlySet, currentCCRouters: Readonly>>, expectedCCRouters: Readonly>>): CCGasConfigDiff; export {}; //# sourceMappingURL=warp.d.ts.map