import type { IOracleFeed } from '../protos.js'; import { OracleFeed } from '../protos.js'; import { Buffer } from 'buffer'; /** * Normalizes and validates an OracleFeed definition * * @param feed - OracleFeed definition in various formats: * - String: JSON with optional comments * - IOracleFeed: Protocol buffer object * - Record: Plain object with tasks array * @returns A validated OracleFeed instance * @throws {OracleFeedError} If validation fails or feed is invalid * * @remarks * - Handles JSON strings with both inline (//) and block (/* *\/) comments * - Validates task array existence and non-emptiness * - Performs basic OracleJob schema validation * - Uses regex pattern from https://regex101.com/r/B8WkuX/1 for comment stripping */ export declare function normalizeOracleFeed(data: string | IOracleFeed | Record): OracleFeed; /** * Encodes an OracleFeed definition into a binary format * * @param data - OracleFeed definition in various formats: * - String: JSON with optional comments * - IOracleFeed: Protocol buffer object * - Record: Plain object with tasks array * @returns Serialized OracleFeeed as Buffer * @throws {OracleFeedError} If validation or encoding fails * * @example * ```typescript * // From JSON string * const encoded1 = serializeOracleFeed(`{ * "jobs": [ * { * "tasks": [ * {"httpTask": {"url": "https://api.coinbase.com/v2/prices/BTC-USD/spot"}} * ] * } * ] * }`); * * // From plain object * const encoded2 = serializeOracleFeed({ * jobs: [ * { * tasks: [ * {"httpTask": {"url": "https://api.coinbase.com/v2/prices/BTC-USD/spot"}} * ] * } * ] * }); * ``` * * @remarks * - Uses normalizeOracleFeed() for initial validation and normalization * - Encodes using Protocol Buffers delimited format */ export declare function serializeOracleFeed(data: string | IOracleFeed | Record): Buffer; /** * Deserializes an OracleFeed from on-chain buffer data * * @param data - Serialized OracleFeed data as Buffer or Uint8Array * @returns A decoded OracleFeed instance * @throws {Error} If deserialization fails or data is invalid * * @example * ```typescript * // From Buffer * const buffer = Buffer.from('...'); // serialized feed data * const feed1 = deserializeOracleFeed(buffer); * * // From Uint8Array * const uint8Array = new Uint8Array([...]); // serialized feed data * const feed2 = deserializeOracleFeed(uint8Array); * ``` * * @remarks * - Uses Protocol Buffers delimited format decoding * - Accepts both Node.js Buffer and Uint8Array formats */ export declare function deserializeOracleFeed(data: Buffer | Uint8Array): OracleFeed; //# sourceMappingURL=oracle-feed.d.ts.map