import type { Abi } from 'abitype'; import { type Addressable, type BaseContract, type BigNumberish, type BytesLike, type Provider, Result } from 'ethers'; import type { TypedContract } from 'ethers-abitype'; import { type NetworkInfo, CCIPContractType, CCIPVersion, ChainFamily, VersionedContractABI } from './types.ts'; /** * Returns *some* block number with timestamp prior to `timestamp` * * @param provider - provider to search blocks on * @param timestamp - target timestamp * @param precision - returned blockNumber should be within this many blocks from target * @returns blockNumber of a block at provider which is close but before target timestamp **/ export declare function getSomeBlockNumberBefore(provider: Provider, timestamp: number, precision?: number): Promise; /** * Receives a key and a factory: creates, caches and returns the same value for a given key **/ export declare function lazyCached(key: string, lazy: () => T, cache?: Map): T; export type KeysMatching = { [K in keyof T]: T[K] extends V ? K : never; }[keyof T]; export type ContractLike = C extends { [1]: Abi; } ? TypedContract : C; export type AwaitedReturn = T extends (...args: any) => Promise ? R : never; /** * Fetches multiple properties of a contract (async getters with no arguments), caching the results * * @param contract - contract to fetch properties from, as contract instance * or [address, abi, provider] contract constructor arguments (constructed only if not cached) * @param properties - list of property names to fetch * @returns Promise to tuple of property values **/ export declare function getContractProperties | readonly [address: string | Addressable, abi: Abi, provider: Provider], T extends readonly (string & KeysMatching, () => Promise>)[]>(contract: C, ...properties: T): Promise<{ [K in keyof T]: AwaitedReturn[T[K]]>; }>; export declare function getTypeAndVersion(provider: Provider, address: string): Promise<[type_: string, version: string, typeAndVersion: string, suffix?: string]>; export declare function getTypeAndVersion(contract: Pick, 'typeAndVersion' | 'getAddress' | 'runner'>): Promise<[type_: string, version: string, typeAndVersion: string, suffix?: string]>; /** * Fetches and validates typeAndVersion for known/core contract types (OnRamp, OffRamp, etc) * and supported CCIP versions **/ export declare function validateContractType(provider: Provider, address: string, type: CCIPContractType): Promise; export declare function chainNameFromId(id: NetworkInfo['chainId']): string; export declare function chainSelectorFromId(id: NetworkInfo['chainId']): bigint; export declare function chainIdFromSelector(selector: bigint): NetworkInfo['chainId']; export declare const chainNameFromSelector: (selector: bigint) => string; export declare function chainIdFromName(name: string): NetworkInfo['chainId']; /** * Converts a chain selector, chain ID, or chain name to complete network information * * @param selectorOrIdOrName - Can be: * - Chain selector as bigint or numeric string * - Chain ID as number or string (EVM: "1", Aptos: "aptos:1", Solana: base58) * - Chain name as string ("ethereum-mainnet") * @returns Complete NetworkInfo object */ export declare function networkInfo(selectorOrIdOrName: bigint | number | string): NetworkInfo; export declare function getProviderNetwork(provider: Provider): Promise; /** * Generates exclusive block ranges [fromBlock, toBlock] * If startBlock is given, moves forward from there (up to latestBlock), * Otherwise, moves backwards down to genesis (you probably want to break/return before that) **/ export declare function blockRangeGenerator(params: { endBlock: number; startBlock?: number; } | { singleBlock: number; }, stepSize?: number): Generator<{ fromBlock: number; toBlock: number; progress?: undefined; } | { fromBlock: number; toBlock: number; progress: string; }, void, unknown>; export declare function bigIntReplacer(_key: string, value: unknown): unknown; export declare function bigIntReviver(_key: string, value: unknown): unknown; /** * When decoding structs, we often get Results which don't support ` in` operator, so we need to convert them to proper objects first **/ export declare function toObject(obj: T | Result): T; /** * Decode address from a 32-byte hex string **/ export declare function decodeAddress(address: BytesLike, family?: ChainFamily): string; export declare function toLeHex(_value: BigNumberish, width?: number): string; export declare function getDataBytes(data: BytesLike): Uint8Array; export declare function getAddressBytes(address: BytesLike): Uint8Array; /** * Converts snake_case strings to camelCase */ export declare function toCamelCase(str: string): string; /** * Recursively converts all snake_case keys in an object to camelCase * Only converts keys that actually have snake_case format */ export declare function convertKeysToCamelCase(obj: unknown): unknown; //# sourceMappingURL=utils.d.ts.map