/** * Environment management for sui-client-gen generated code. * * This module provides runtime environment switching, allowing generated code * to work with different networks (mainnet, testnet, custom) without regeneration. */ /** * Configuration for a single package (top-level or dependency). */ export interface PackageConfig { /** Original package ID (the package's permanent identifier) */ originalId: string; /** Address to use for function calls (may differ after upgrades) */ publishedAt: string; /** Type origins: maps "module::TypeName" to the defining package address */ typeOrigins: Record; } /** * Complete environment configuration containing all packages and dependencies. */ export interface EnvConfig { /** Top-level package configurations, keyed by kebab-case package name */ packages: Record; /** Dependency package configurations, keyed by kebab-case package name */ dependencies: Record; } /** * Register an environment configuration. * Called during init to register generated env configs. */ export declare function registerEnv(name: string, config: EnvConfig): void; /** * Get a registered environment configuration by name. * Useful when building an ad-hoc config derived from a known env, e.g. via `cloneEnv`. * @throws Error if the environment is not registered. */ export declare function getEnv(name: string): EnvConfig; /** * Produce a new `EnvConfig` by shallow-merging `overrides` onto `base`, per package. * * Only the fields you provide on each package are replaced — other fields (including * the untouched packages) are preserved by reference. Useful for creating a scoped * env for a single call (e.g. to target a historical `publishedAt`) without mutating * any shared state. * * @example * const historical = cloneEnv(getEnv('mainnet'), { * packages: { 'my-app': { publishedAt: '0x...' } }, * }) * transfer(tx, typeArgs, args, { env: historical }) */ export declare function cloneEnv(base: EnvConfig, overrides?: { packages?: Record>; dependencies?: Record>; }): EnvConfig; /** * Set the active environment by name. * @param name - The name of a registered environment * @param overrides - Optional map of package names to publishedAt addresses to override * @throws Error if the environment is not registered */ export declare function setActiveEnv(name: string, overrides?: Record): void; /** * Set the active environment using a custom config object. * Use this to provide a custom environment configuration at runtime. * @param config - A custom EnvConfig object * @param overrides - Optional map of package names to publishedAt addresses to override */ export declare function setActiveEnvWithConfig(config: EnvConfig, overrides?: Record): void; /** * Get the active environment configuration. * @throws Error if no environment is set */ export declare function getActiveEnv(): EnvConfig; /** * Get the active environment name. * Returns null if no environment is set. */ export declare function getActiveEnvName(): string | null; /** * Get the list of registered environment names. */ export declare function getRegisteredEnvs(): string[]; /** * Get configuration for a top-level package. * @throws Error if package not found */ export declare function getPackageConfig(pkgName: string, env?: EnvConfig): PackageConfig; /** * Get configuration for a dependency package. * @throws Error if dependency not found */ export declare function getDependencyConfig(pkgName: string, env?: EnvConfig): PackageConfig; /** * Get the publishedAt address for function calls. * * When an explicit `env` is supplied, it is authoritative and the module-level * `publishedAtOverrides` (set via `setActiveEnv`) are ignored — callers that pass * their own env own their own scope. Otherwise the active env is used with overrides * applied on top. * * @throws Error if package not found */ export declare function getPublishedAt(pkgName: string, env?: EnvConfig): string; /** * Get the type origin address for a specific type. * Used in $typeName construction for structs and enums. * @param pkgName - Kebab-case package name * @param moduleTypePath - "module::TypeName" format (e.g., "balance::Balance") * @throws Error if package or type origin not found */ export declare function getTypeOrigin(pkgName: string, moduleTypePath: string, env?: EnvConfig): string; /** * Get the original package ID. * Works for both packages and dependencies. * @throws Error if package not found */ export declare function getOriginalId(pkgName: string, env?: EnvConfig): string; /** * Get all distinct addresses where types in this package were defined. * Useful for understanding package upgrade history and querying objects. * Works for both packages and dependencies. * @param pkgName - Kebab-case package name * @returns Array of unique addresses, sorted for determinism * @throws Error if package not found */ export declare function getTypeOriginAddresses(pkgName: string, env?: EnvConfig): string[]; /** * Get distinct addresses where specific types are defined. * Useful for querying objects of specific types. * Works for both packages and dependencies. * @param pkgName - Kebab-case package name * @param moduleTypePaths - Array of "module::TypeName" strings (e.g., ["balance::Balance", "coin::Coin"]) * @returns Array of unique addresses, sorted for determinism * @throws Error if package not found or any type origin not found */ export declare function getTypeOriginAddressesFor(pkgName: string, moduleTypePaths: string[], env?: EnvConfig): string[];