import type { PickDeep } from 'type-fest'; import type { Chain, LogFilter } from './chain.ts'; import { type AnyMessage, type CCIPMessage, type CCIPRequest, type ChainTransaction, type MessageInput, ChainFamily } from './types.ts'; /** * Decodes hex strings, bytearrays, JSON strings and raw objects as CCIPMessages. * Does minimal validation, but converts objects in the format expected by ccip-tools-ts. * * @param data - Data to decode (hex string, Uint8Array, JSON string, or object) * @returns Decoded CCIPMessage * @throws {@link CCIPMessageDecodeError} if data cannot be decoded as a valid message * @throws {@link CCIPMessageInvalidError} if message structure is invalid or missing required fields * * @example * ```typescript * import { decodeMessage } from '@chainlink/ccip-sdk' * * // Decode from JSON string * const message = decodeMessage('{"header":{"sourceChainSelector":"123",...}') * * // Decode from hex-encoded bytes * const message = decodeMessage('0x...') * * console.log('Message ID:', message.messageId) * ``` */ export declare function decodeMessage(data: string | Uint8Array | Record): CCIPMessage; /** * Populates missing required fields (e.g. `extraArgs`) from AnyMessage. * @param message - Partial AnyMessage with at least receiver * @param dest - Destination chain family to build message for * @returns Original message or shallow copy with defaults for required fields */ export declare function buildMessageForDest(message: MessageInput, dest: ChainFamily): AnyMessage; /** * Fetch all CCIP messages in a transaction. * @param source - Source chain instance * @param tx - ChainTransaction to search in * @returns CCIP requests (messages) in the transaction (at least one) * @throws {@link CCIPChainFamilyUnsupportedError} if chain family not supported for legacy messages * @throws {@link CCIPMessageNotFoundInTxError} if no CCIP messages found in transaction * * @see {@link getMessageById} - Search by messageId when tx hash unknown */ export declare function getMessagesInTx(source: Chain, tx: ChainTransaction): Promise; /** * Fetch a CCIP message by messageId from RPC logs (slow scan). * * This is the fallback implementation called by {@link Chain.getMessageById} * when the API client is unavailable or fails. * * @param source - Source chain to scan logs from * @param messageId - Message ID to search for * @param opts - Optional hints (onRamp address narrows search, page controls batch size) * @returns CCIPRequest matching the messageId * * @throws {@link CCIPMessageIdNotFoundError} if message not found after scanning all logs * * @example * * ```typescript * import { getMessageById, EVMChain } from '@chainlink/ccip-sdk' * * const source = await EVMChain.fromUrl('https://rpc.sepolia.org') * const request = await getMessageById(source, '0xabc123...', { * onRamp: '0xOnRampAddress...', * startTime: 1710000000, * }) * console.log(`Found: seqNr=${request.message.sequenceNumber}`) * ``` * * @internal */ export declare function getMessageById(source: Chain, messageId: string, opts?: Pick & { onRamp?: string; }): Promise; /** * Fetches all CCIP messages contained in a given commit batch. * @param source - The source chain. * @param request - The CCIP request containing lane and message info. * @param range - Object containing minSeqNr and maxSeqNr for the batch range. * @param opts - Optional log filtering parameters. * @returns Array of messages in the batch. * @throws {@link CCIPMessageBatchIncompleteError} if not all messages in the batch range could be found in source chain logs * @see {@link getVerifications} - Get commit report to determine batch range */ export declare function getMessagesInBatch>(source: C, request: R, { minSeqNr, maxSeqNr }: { minSeqNr: bigint; maxSeqNr: bigint; }, opts?: Parameters[0]): Promise; /** * Map source token to its pool address and destination token address. * * Resolves token routing by querying the TokenAdminRegistry and TokenPool * to find the corresponding destination chain token. * * @param opts - options to convert source to dest token addresses * @returns Extended token amount with `sourcePoolAddress`, `sourceTokenAddress`, and `destTokenAddress` * * @throws {@link CCIPTokenNotInRegistryError} if token is not registered in TokenAdminRegistry * * @example * ```typescript * import { sourceToDestTokenAddresses, EVMChain } from '@chainlink/ccip-sdk' * * const source = await EVMChain.fromUrl('https://rpc.sepolia.org') * const tokenAmount = await sourceToDestTokenAddresses({ * source, * onRamp: '0xOnRamp...', * destChainSelector: 14767482510784806043n, * sourceTokenAmount: { token: '0xLINK...', amount: 1000000000000000000n }, * }) * console.log(`Pool: ${tokenAmount.sourcePoolAddress}`) * console.log(`Dest token: ${tokenAmount.destTokenAddress}`) * ``` */ export declare function sourceToDestTokenAddresses({ source, onRamp, destChainSelector, sourceTokenAmount, }: { /** Source chain instance */ source: Chain; /** OnRamp contract address */ onRamp: string; /** Destination chain selector */ destChainSelector: bigint; /** Token amount object containing `token` and `amount` */ sourceTokenAmount: S; }): Promise; //# sourceMappingURL=requests.d.ts.map