import { BigNumber, ethers, providers } from 'ethers';
import { Logger } from '../utils/logger';
import { Config } from '../config/config';
import { NetworkConfig } from '../config/types';
import { Prometheus } from '../prometheus';
import { EIP1559TxParams, TxParams } from './types';
import { NetworkIdT3rn } from '../pricer/types';
import { AssetName } from '../pricer/enums';
import { RedisClientType } from 'redis';
export declare class CustomJsonRpcProvider extends ethers.providers.JsonRpcProvider {
    private readonly urls;
    readonly networkConfig: NetworkConfig;
    private readonly prometheus;
    private readonly config;
    private readonly redisClient?;
    preferBlockPi: boolean;
    preferQuickNode: boolean;
    childLogger: Logger;
    gasFeesBump: number;
    lastFeeData: ethers.providers.FeeData | null;
    feeData: ethers.providers.FeeData;
    gasPrice: BigNumber;
    healthy: boolean;
    providers: providers.JsonRpcProvider[];
    private preferredProvider;
    constructor(urls: [string, ...string[]], // ensure that at least one URL is provided
    networkConfig: NetworkConfig, prometheus: Prometheus, config: Config, redisClient?: RedisClientType | undefined, // pass redis to rpc.init() to have it available
    preferBlockPi?: boolean, // if true, prefer BlockPi RPCs over QuickNode
    preferQuickNode?: boolean);
    getEffectiveGasPrice(): BigNumber;
    startFetchingGasPrice(): void;
    fetchAndCacheGasPrice(): Promise<void>;
    bumpGasFee(): void;
    setGasFee(bumpCount?: number): void;
    resetGasFeeBump(): void;
    checkProviderHealth(): Promise<boolean>;
    getFeeData(): Promise<ethers.providers.FeeData>;
    getBlock(...args: Parameters<typeof ethers.providers.FallbackProvider.prototype.getBlock>): Promise<ethers.providers.Block>;
    /**
     * @param feeData The most recently fetched fee data.
     * @param lastFeeData The last fetched fee data.
     */
    getNextGasSettings(feeData: ethers.providers.FeeData, lastFeeData: ethers.providers.FeeData, _retries: number, _gasLimitCap?: BigNumber): EIP1559TxParams;
    estimateGasParams(retries?: number, value?: BigNumber | null, forceTxType?: number, gasLimitCap?: BigNumber): TxParams;
    /**
     * Fetches the current nonce for the given wallet on the given network.
     *
     * @param {string}  walletAddress The wallet to get nonce for.
     * @returns {Promise<number>} The current nonce for the given network and wallet.
     */
    getCurrentNonce(walletAddress: string): Promise<number>;
    /**
     * Determines if an error is transient, meaning it is likely temporary and may be resolved
     * by retrying the operation, e.g. network issues, rate limiting, etc.
     *
     * @param {any} error The error object received from the JSON RPC provider.
     * @return {boolean} Returns true if the error is considered transient, false otherwise.
     */
    private isTransientError;
}
export declare class Rpc {
    private readonly config;
    private readonly prometheus;
    readonly provider: Partial<Record<NetworkIdT3rn, CustomJsonRpcProvider>>;
    private redisClient?;
    constructor(config: Config, prometheus: Prometheus);
    /**
     * Initializes or re-initializes RPC provider from a given list
     *
     * @param {string[]} providersUrls URLs of the JSON RPC providers.
     * @param {NetworkIdT3rn} network The network ID.
     * @param redisClient
     * @return {CustomJsonRpcProvider} The initialized provider.
     */
    init(providersUrls: string[] | undefined, network: NetworkConfig, redisClient?: RedisClientType): CustomJsonRpcProvider;
    /**
     * Fetches the balance of a wallet on a specific network.
     *
     * @param {NetworkIdT3rn} networkId The network ID.
     * @param {string} address The address of the wallet to check the balance of.
     *
     * @returns {Promise<BigNumber | null>} The response object containing the balance and a success flag.
     */
    fetchWalletBalance(networkId: NetworkIdT3rn, address: string, symbol?: AssetName): Promise<BigNumber | undefined>;
    fetchTokenBalance(networkId: NetworkIdT3rn, address: string, tokenAddress: string, symbol?: AssetName): Promise<BigNumber | undefined>;
    /**
     * Returns the current height of the given network by querying the current provider.
     *
     * @param {NetworkIdT3rn} networkId
     * @return {Promise<number>} The current block number.
     */
    getCurrentHeight(networkId: NetworkIdT3rn): Promise<number>;
    /**
     * Maintains the RPC connection by continuously checking the health of the current provider
     * and switching to a new provider if the current one becomes unhealthy.
     *
     * @param {NetworkConfig} network The network configuration.
     */
    private maintainRpcConnection;
}
//# sourceMappingURL=rpc.service.d.ts.map