import type { Simplify } from 'type-fest'; import type { Chain } from './chain.ts'; import type { CCIPMessage_V2_0 } from './evm/messages.ts'; import type { CCIPMessage_V1_6_Solana } from './solana/types.ts'; import type { CCIPMessage, MessageInput } from './types.ts'; /** * A subset of {@link MessageInput} for estimating receive execution gas. */ export type EstimateMessageInput = Simplify & Partial> & Partial> & Partial> & { /** * optional tokenAmounts; `amount` with either source `token` (as in MessageInput) or * `{ sourceTokenAddress?, sourcePoolAddress, destTokenAddress }` (as in v1.5..v2.0 tokenAmounts) * can be provided */ tokenAmounts?: readonly ({ amount: bigint; extraData?: string; } & ({ token: string; } | { sourceTokenAddress?: string; sourcePoolAddress: string; destTokenAddress: string; }))[]; }>; /** * Options for {@link estimateReceiveExecution} function. */ export type EstimateReceiveExecutionOpts = { /** Source chain instance (for token data retrieval) */ source: Chain; /** Dest chain instance (for token and execution simulation) */ dest: Chain; /** source router or onRamp, or dest offRamp contract address */ routerOrRamp: string; /** message to be simulated */ message: Omit; }; /** * 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; /** * If given a `{token, amount}` and no `source` (e.g. when called from Chain.estimateReceiveExecution), * assume it's already a dest tokenAmount and return as-is. * Otherwise, if given a source tokenAmount, resolve the corresponding destTokenAddress and adjust * the amount for decimals difference. * @param opts - options to get destination token amount * @returns dest `token` and adjusted `amount` for the given source token amount */ export declare function getDestTokenAmount({ source, onRamp, dest, tokenAmount, }: { source?: Chain; onRamp?: string; dest: Chain; tokenAmount: NonNullable[number]; }): Promise<{ token: string; amount: bigint; }>; /** * Estimate CCIP gasLimit needed to execute a request on a contract receiver. * * @param opts - {@link EstimateReceiveExecutionOpts} for estimation * @returns Estimated execution gas (base transaction cost subtracted) * * @throws {@link CCIPMethodUnsupportedError} if dest chain doesn't support estimation * @throws {@link CCIPContractTypeInvalidError} if routerOrRamp is not a valid contract type * @throws {@link CCIPTokenDecimalsInsufficientError} if dest token has insufficient decimals * @throws {@link CCIPOnRampRequiredError} if no OnRamp found for the given OffRamp and source chain * * @example * ```typescript * import { estimateReceiveExecution, EVMChain } from '@chainlink/ccip-sdk' * * const source = await EVMChain.fromUrl('https://rpc.sepolia.org') * const dest = await EVMChain.fromUrl('https://rpc.fuji.avax.network') * * const gasLimit = await estimateReceiveExecution({ * source, * dest, * routerOrRamp: '0xRouter...', * message: { * sender: '0x...', * receiver: '0x...', * data: '0x...', * tokenAmounts: [], * }, * }) * console.log('Estimated gas:', gasLimit) * ``` */ export declare function estimateReceiveExecution({ source, dest, routerOrRamp, message, }: EstimateReceiveExecutionOpts): Promise; //# sourceMappingURL=gas.d.ts.map