import { ZERO_ADDRESS_HEX_32 } from '@hyperlane-xyz/utils'; import { ISigner } from './altvm.js'; import { AnnotatedTx, TxReceipt } from './module.js'; export declare const ArtifactState: { readonly NEW: "new"; readonly DEPLOYED: "deployed"; readonly UNDERIVED: "underived"; }; export type ArtifactState = (typeof ArtifactState)[keyof typeof ArtifactState]; /** * Represents an artifact that has not yet been deployed. * Contains only the desired configuration. */ export type ArtifactNew = { artifactState?: typeof ArtifactState.NEW; config: C; }; /** * Represents an artifact that has been deployed on-chain. * Contains both the configuration and deployment-derived data (addresses, etc.). */ export type ArtifactDeployed = { artifactState: typeof ArtifactState.DEPLOYED; config: C; deployed: D; }; /** * Represents an artifact that has been deployed on chain * but is represented only by its address */ export type ArtifactUnderived = { artifactState: typeof ArtifactState.UNDERIVED; deployed: D; }; /** * Union type representing a deployed artifact. Can be either the full artifact config * or its address on chain. */ export type ArtifactOnChain = ArtifactDeployed | ArtifactUnderived; /** * Union type representing an artifact in any state. * Useful for APIs that can accept either new or deployed artifacts. */ export type Artifact = ArtifactNew | ArtifactDeployed | ArtifactUnderived; /** * Type guard to check if an artifact is in the NEW state. * Returns true when artifactState is undefined (the default) or explicitly NEW. */ export declare function isArtifactNew(artifact: Artifact): artifact is ArtifactNew; /** * Type guard to check if an artifact is in the DEPLOYED state. */ export declare function isArtifactDeployed(artifact: Artifact): artifact is ArtifactDeployed; /** * Type guard to check if an artifact is in the UNDERIVED state. */ export declare function isArtifactUnderived(artifact: Artifact): artifact is ArtifactUnderived; /** * Interface for reading artifact state from the blockchain. */ export interface ArtifactReader { /** * Read the current state of an artifact at the given address. * @param address The on-chain address of the artifact * @returns The artifact configuration and deployment data */ read(address: string): Promise>; } /** * Interface for creating and updating artifacts on the blockchain. */ export interface ArtifactWriter extends ArtifactReader { /** * Deploy a new artifact on-chain. * @param artifact The artifact configuration to deploy * @returns A tuple of [deployed artifact, transaction receipts] */ create(artifact: ArtifactNew): Promise<[ArtifactDeployed, TxReceipt[]]>; /** * Update an existing artifact to match the desired configuration. * @param artifact The desired artifact state (must be deployed) * @returns Array of transactions needed to perform the update */ update(artifact: ArtifactDeployed): Promise; } /** * Utility type that converts Artifact<> references to ArtifactOnChain<> in a config type. * Used to create "raw" config types that protocol implementations work with. * * Transformations (non-recursive, single level only): * - Artifact → ArtifactOnChain * - Record> → Record> * - Array> → Array> * - Other properties remain unchanged * * This enables defining compound configs once and deriving raw configs automatically. * * Example: * ```typescript * interface RoutingIsmConfig { * type: 'routing'; * owner: string; * domains: Record>; * } * * type RawRoutingIsmConfig = RawArtifact; * // Results in: * // { * // type: 'routing'; * // owner: string; * // domains: Record>; * // } * ``` * * @deprecated FIXME: remove usage of this type in a follow up PR for the hook and ISM artifacts */ export type RawArtifact = { [K in keyof C]: C[K] extends Artifact ? ArtifactOnChain : C[K] extends Artifact[] ? ArtifactOnChain[] : C[K] extends { [L: string]: Artifact; } ? { [L in keyof C[K]]: ArtifactOnChain; } : C[K]; }; /** * Helper type to transform nested objects containing Artifacts. * Handles objects where all properties are Artifacts (required or optional). */ type NestedOnChain = T extends Record ? { [L in keyof T]: T[L] extends Artifact ? ArtifactOnChain : T[L] extends Artifact | undefined ? ArtifactOnChain | undefined : T[L]; } : T; /** * Utility type to convert a config type to its on-chain representation. * Replaces Artifact<> types one level deep with ArtifactOnChain<> types. * Unlike RawArtifact, preserves the nested deployment types. * Handles optional/undefined fields properly using conditional modifiers. */ export type ConfigOnChain = { [K in keyof C]: C[K] extends Artifact ? ArtifactOnChain : C[K] extends Artifact | undefined ? ArtifactOnChain | undefined : C[K] extends Artifact[] ? ArtifactOnChain[] : NestedOnChain; }; /** * Artifact Manager Interface * * Generic interface for managing artifact operations across different artifact types. * Can be specialized for ISMs, Hooks, Warp Routes, etc. * * Uses mapped types to enable proper type inference - when you call createReader(type), * TypeScript will infer the specific config type based on the type parameter. */ export interface IArtifactManager, D> { createReader(type: T): ArtifactReader; createWriter(type: T, signer: ISigner): ArtifactWriter; } export type UnsetArtifactAddress = typeof ZERO_ADDRESS_HEX_32; /** * Returns the artifact if DEPLOYED, undefined if UNDERIVED with zero address. * Throws if UNDERIVED with non-zero address. */ export declare function toDeployedOrUndefined(artifact: ArtifactOnChain, name: string): ArtifactDeployed | undefined; export declare function addressToUnderivedArtifact(address: string | undefined, formatter?: (value: string) => string): ArtifactUnderived<{ address: string; }> | undefined; export declare function artifactOnChainToAddress(artifact: ArtifactOnChain | undefined, formatter?: (value: string) => string): string | undefined; export {}; //# sourceMappingURL=artifact.d.ts.map