import { SchemeNetworkServer, MoneyParser, Price, Network, AssetAmount, PaymentRequirements } from '@x402/core/types';
import { x402ResourceServer } from '@x402/core/server';

/**
 * EVM server implementation for the Exact payment scheme.
 */
declare class ExactEvmScheme implements SchemeNetworkServer {
    readonly scheme = "exact";
    private moneyParsers;
    /**
     * Register a custom money parser in the parser chain.
     * Multiple parsers can be registered - they will be tried in registration order.
     * Each parser receives a decimal amount (e.g., 1.50 for $1.50).
     * If a parser returns null, the next parser in the chain will be tried.
     * The default parser is always the final fallback.
     *
     * @param parser - Custom function to convert amount to AssetAmount (or null to skip)
     * @returns The server instance for chaining
     *
     * @example
     * evmServer.registerMoneyParser(async (amount, network) => {
     *   // Custom conversion logic
     *   if (amount > 100) {
     *     // Use different token for large amounts
     *     return { amount: (amount * 1e18).toString(), asset: "0xCustomToken" };
     *   }
     *   return null; // Use next parser
     * });
     */
    registerMoneyParser(parser: MoneyParser): ExactEvmScheme;
    /**
     * Parses a price into an asset amount.
     * If price is already an AssetAmount, returns it directly.
     * If price is Money (string | number), parses to decimal and tries custom parsers.
     * Falls back to default conversion if all custom parsers return null.
     *
     * @param price - The price to parse
     * @param network - The network to use
     * @returns Promise that resolves to the parsed asset amount
     */
    parsePrice(price: Price, network: Network): Promise<AssetAmount>;
    /**
     * Build payment requirements for this scheme/network combination
     *
     * @param paymentRequirements - The base payment requirements
     * @param supportedKind - The supported kind from facilitator (unused)
     * @param supportedKind.x402Version - The x402 version
     * @param supportedKind.scheme - The logical payment scheme
     * @param supportedKind.network - The network identifier in CAIP-2 format
     * @param supportedKind.extra - Optional extra metadata regarding scheme/network implementation details
     * @param extensionKeys - Extension keys supported by the facilitator (unused)
     * @returns Payment requirements ready to be sent to clients
     */
    enhancePaymentRequirements(paymentRequirements: PaymentRequirements, supportedKind: {
        x402Version: number;
        scheme: string;
        network: Network;
        extra?: Record<string, unknown>;
    }, extensionKeys: string[]): Promise<PaymentRequirements>;
    /**
     * Parse Money (string | number) to a decimal number.
     * Handles formats like "$1.50", "1.50", 1.50, etc.
     *
     * @param money - The money value to parse
     * @returns Decimal number
     */
    private parseMoneyToDecimal;
    /**
     * Default money conversion implementation.
     * Converts decimal amount to the default stablecoin on the specified network.
     *
     * @param amount - The decimal amount (e.g., 1.50)
     * @param network - The network to use
     * @returns The parsed asset amount in the default stablecoin
     */
    private defaultMoneyConversion;
    /**
     * Convert decimal amount to token units (e.g., 0.10 -> 100000 for 6-decimal tokens)
     *
     * @param decimalAmount - The decimal amount to convert
     * @param decimals - The number of decimals for the token
     * @returns The token amount as a string
     */
    private convertToTokenAmount;
    /**
     * Get the default asset info for a network (typically USDC)
     *
     * @param network - The network to get asset info for
     * @returns The asset information including address, name, version, and decimals
     */
    private getDefaultAsset;
}

/**
 * Configuration options for registering EVM schemes to an x402ResourceServer
 */
interface EvmResourceServerConfig {
    /**
     * Optional specific networks to register
     * If not provided, registers wildcard support (eip155:*)
     */
    networks?: Network[];
}
/**
 * Registers EVM exact payment schemes to an x402ResourceServer instance.
 *
 * This function registers:
 * - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)
 *
 * @param server - The x402ResourceServer instance to register schemes to
 * @param config - Configuration for EVM resource server registration
 * @returns The server instance for chaining
 *
 * @example
 * ```typescript
 * import { registerExactEvmScheme } from "@x402/evm/exact/server/register";
 * import { x402ResourceServer } from "@x402/core/server";
 *
 * const server = new x402ResourceServer(facilitatorClient);
 * registerExactEvmScheme(server, {});
 * ```
 */
declare function registerExactEvmScheme(server: x402ResourceServer, config?: EvmResourceServerConfig): x402ResourceServer;

export { type EvmResourceServerConfig, ExactEvmScheme, registerExactEvmScheme };
