/** * @module utils/network-normalizer * @description Network identifier normalization for x402 payment headers. * * Solves the canonical-string mismatch between SAP clients and servers: * some providers accept `solana:mainnet-beta` while others require * the genesis-hash form `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`. * * This module provides a single source of truth for normalizing * network identifiers so that both clients and agents canonicalize * before comparing. Catches the Kamiyo "sap network mismatch" error * at the SDK level. * * @category Utils * @since v0.6.0 */ import { type SapNetworkId } from "../constants/network"; /** * @name normalizeNetworkId * @description Normalize a raw network identifier string to its canonical * {@link SapNetworkId} form. * * Handles: * - Case-insensitive matching * - Stripping whitespace * - Resolving genesis-hash vs. cluster-name aliases * - Unknown strings are returned as-is (passthrough) * * @param raw - Raw network identifier string from headers, env vars, or config. * @returns The canonical {@link SapNetworkId}, or the trimmed input if unknown. * * @category Utils * @since v0.6.0 * * @example * ```ts * import { normalizeNetworkId } from "@synapse-sap/sdk"; * * normalizeNetworkId("solana:mainnet-beta"); * // → "solana:mainnet-beta" * * normalizeNetworkId("5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"); * // → "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" * * normalizeNetworkId(" MAINNET "); * // → "solana:mainnet-beta" * ``` */ export declare function normalizeNetworkId(raw: string): SapNetworkId | string; /** * @name isNetworkEquivalent * @description Check if two network identifier strings refer to the same network, * even if they use different formats (cluster-name vs. genesis-hash). * * This is the key function that prevents the Kamiyo "sap network mismatch" * error — instead of comparing strings literally, we compare their * canonical equivalence class. * * @param a - First network identifier. * @param b - Second network identifier. * @returns `true` if both identifiers refer to the same Solana network. * * @category Utils * @since v0.6.0 * * @example * ```ts * import { isNetworkEquivalent } from "@synapse-sap/sdk"; * * isNetworkEquivalent("solana:mainnet-beta", "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"); * // → true * * isNetworkEquivalent("solana:devnet", "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"); * // → true * * isNetworkEquivalent("solana:mainnet-beta", "solana:devnet"); * // → false * ``` */ export declare function isNetworkEquivalent(a: string, b: string): boolean; /** * @name getNetworkGenesisHash * @description Get the genesis-hash form of a network identifier. * Returns the genesis-hash variant for known networks, or the input as-is. * * Useful for agents that require the genesis-hash form (Kamiyo, Helius x402). * * @param networkId - Any network identifier. * @returns The genesis-hash form, or the input if unknown. * * @category Utils * @since v0.6.0 */ export declare function getNetworkGenesisHash(networkId: string): string; /** * @name getNetworkClusterName * @description Get the cluster-name form of a network identifier. * Returns the human-readable cluster name for known networks. * * Useful for providers that accept cluster names (Coinbase, Phantom). * * @param networkId - Any network identifier. * @returns The cluster-name form, or the input if unknown. * * @category Utils * @since v0.6.0 */ export declare function getNetworkClusterName(networkId: string): string; /** * @name isKnownNetwork * @description Check if a network identifier is recognized by the SDK. * * @param networkId - The network identifier to check. * @returns `true` if the identifier maps to a known Solana network. * * @category Utils * @since v0.6.0 */ export declare function isKnownNetwork(networkId: string): boolean; //# sourceMappingURL=network-normalizer.d.ts.map