/**
 * Sourcify (https://sourcify.dev/) helpers for querying
 * contract metadata when it's available.
 *
 * @example
 * Get the ABI of an arbitrary contract.
 * ```ts
 * const metadata = fetchMetadata('42220', '0xF27c7D717B4b7CaD2833a61cb9CA7B61021f9F73')
 * if (metadata.abi !== null) {
 *  // do something with it.
 * }
 */
import { ABIDefinition, AbiItem, Address, Connection } from '@celo/connect';
import { ContractMapping } from './base';
/**
 * MetadataResponse interface for the `metadata.json` file that the sourcify repo returns.
 * All fields are optional because we don't really _know_ what we get from the API, thus
 * we need to enforce the structure at runtime.
 */
export interface MetadataResponse {
    output?: {
        abi?: AbiItem[];
    };
    settings?: {
        compilationTarget?: Record<string, string>;
    };
}
/**
 * Wrapper class for a metadata.json response from sourcify.
 * Because the response's true structure is unknown this wrapper implements
 * light runtime verification.
 */
export declare class Metadata {
    abi: AbiItem[] | null;
    contractName: string | null;
    fnMapping: Map<string, ABIDefinition>;
    private abiCoder;
    private jsonInterfaceMethodToString;
    private address;
    constructor(connection: Connection, address: Address, response: any);
    set response(value: MetadataResponse);
    /**
     * Turn the ABI into a mapping of function selectors to ABI items.
     */
    toContractMapping(): ContractMapping;
    /**
     * Find the AbiItem for a given function selector
     * @param selector the 4-byte selector of the function call
     * @returns an AbiItem if found or null
     */
    abiForSelector(selector: string): AbiItem | null;
    /**
     * Find the AbiItem for methods that match the provided method name.
     * The function can return more than one AbiItem if the query string
     * provided doesn't contain arguments as there can be multiple
     * definitions with different arguments.
     * @param method name of the method to lookup
     * @returns and array of AbiItems matching the query
     */
    abiForMethod(query: string): AbiItem[];
}
/**
 * Fetch the sourcify response and instantiate a Metadata wrapper class around it.
 * Try a full_match but fallback to partial_match when not strict.
 * @param connection @celo/connect instance
 * @param contract the address of the contract to query
 * @param strict only allow full matches https://docs.sourcify.dev/docs/full-vs-partial-match/
 * @returns Metadata or null
 */
export declare function fetchMetadata(connection: Connection, contract: Address, strict?: boolean): Promise<Metadata | null>;
/**
 * Use heuristics to determine if the contract can be a proxy
 * and extract the implementation.
 * Available scenarios:
 * - _getImplementation() exists
 * - getImplementation() exists
 * - _implementation() exists
 * - implementation() exists
 * @param connection @celo/connect instance
 * @param contract the address of the contract to query
 * @returns the implementation address or null
 */
export declare function tryGetProxyImplementation(connection: Connection, contract: Address): Promise<Address | undefined>;
