import type { Chain as ViemChain } from "viem"; import type { ThirdwebClient } from "../client/client.js"; import type { Chain, ChainMetadata, ChainOptions, LegacyChain } from "./types.js"; /** * @internal Exported for tests */ export declare const CUSTOM_CHAIN_MAP: Map>; /** * Defines a chain with the given options. * @param options The options for the chain. * @returns The defined chain. * @example * Just pass the chain ID to connect to: * ```ts * const chain = defineChain(1); * ``` * Or pass your own RPC or custom values: * ```ts * const chain = defineChain({ * id: 1, * rpc: "https://my-rpc.com", * nativeCurrency: { * name: "Ether", * symbol: "ETH", * decimals: 18, * }, * }); * ``` * @chain */ export declare function defineChain(options: number | ChainOptions | ViemChain | LegacyChain): Chain; /** * @internal */ export declare function cacheChains(chains: Chain[]): void; /** * @internal */ export declare function getCachedChain(id: number): Readonly | { readonly id: number; readonly rpc: `https://${number}.${string}`; }; /** * @internal */ export declare function getCachedChainIfExists(id: number): Readonly | undefined; /** * @internal */ export declare function convertLegacyChain(legacyChain: LegacyChain): Chain; /** * @internal */ export declare function convertViemChain(viemChain: ViemChain): Chain; type GetRpcUrlForChainOptions = { client: ThirdwebClient; chain: Chain | number; }; /** * Retrieves the RPC URL for the specified chain. * If a custom RPC URL is defined in the options, it will be used. * Otherwise, a thirdweb RPC URL will be constructed using the chain ID and client ID. * @param options - The options object containing the chain and client information. * @returns The RPC URL for the specified chain. * @example * ```ts * import { getRpcUrlForChain } from "thirdweb/chains"; * const rpcUrl = getRpcUrlForChain({ chain: 1, client }); * console.log(rpcUrl); // "https://1.rpc.thirdweb.com/... * ``` * @chain */ export declare function getRpcUrlForChain(options: GetRpcUrlForChainOptions): string; /** * Retrieves the chain symbol from the provided chain. * @param chain - The chain. * @returns The chain symbol. * @internal */ export declare function getChainSymbol(chain: Chain): Promise; /** * Retrieves the number of decimals for the native currency of a given chain. * If the chain is not recognized or the data cannot be fetched, it returns a fallback value of 18. * @param chain - The chain for which to retrieve the decimals. * @returns A promise that resolves to the number of decimals for the native currency of the chain. * @internal */ export declare function getChainDecimals(chain: Chain): Promise; /** * Retrieves the name of the native currency for a given chain. * If the chain object does not have a native currency name, it attempts to fetch the chain data and retrieve the native currency name from there. * If fetching the chain data fails, it falls back to returning "ETH". * @param chain The chain object for which to retrieve the native currency name. * @returns A promise that resolves to the native currency name. * @internal */ export declare function getChainNativeCurrencyName(chain: Chain): Promise; /** * Retrieves chain data for a given chain. * @param chain - The chain object containing the chain ID. * @returns A Promise that resolves to the chain data. * @throws If there is an error fetching the chain data. * @example * ```ts * const chain = defineChain({ id: 1 }); * const chainData = await getChainMetadata(chain); * console.log(chainData); * ``` * @chain */ export declare function getChainMetadata(chain: Chain): Promise; export declare function getInsightEnabledChainIds(): Promise; /** * Convert `ApiChain` to `Chain` object * @internal */ export declare function convertApiChainToChain(apiChain: ChainMetadata): Chain; export {}; //# sourceMappingURL=utils.d.ts.map