import { OpenRPCSchema, OpenRPCSpec } from '../../types'; import { LanguageTypeMapper } from '../interfaces'; /** * Python-specific type mapping implementation with type hints. * This class implements the LanguageTypeMapper interface to provide * conversions from Solidity/OpenRPC types to Python type hints, * and generates Python Pydantic model definitions. */ export declare class PythonTypeMapper implements LanguageTypeMapper { /** * Base Solidity to Python type hint mappings. * This readonly record maps common Solidity types to their direct * Python equivalent type hints. */ private static readonly BASE_TYPE_MAPPINGS; /** * Maps a Solidity type format to the corresponding Python type hint. * This method handles basic types, integer types, fixed-size byte arrays, * and array types by delegating to helper methods for dynamic handling. * * @param solidityType The Solidity type string (e.g., 'uint256', 'address', 'bytes32', 'string[]'). * @returns The corresponding Python type hint string, or `null` if no mapping is found. */ mapSolidityType(solidityType: string): string | null; /** * Determines and collects all necessary Python `typing` module imports * and other standard library imports (like `pydantic`, `collections.OrderedDict`) * based on the given OpenRPC specification. * * @param openrpc The OpenRPC specification object. * @returns An array of import statements as strings, sorted for consistency. */ getRequiredImports(openrpc: OpenRPCSpec): string[]; /** * Generates Python class definitions (Pydantic Models) from the OpenRPC schema components. * These Pydantic models represent custom complex types defined in the OpenRPC specification. * * @param openrpc The OpenRPC specification object. * @returns A string containing the generated Python Pydantic model definitions, * including necessary imports, or an empty string if no structs is found. */ generateTypes(openrpc: OpenRPCSpec): string; /** * Maps an OpenRPC schema object to a Python type hint string. * This method handles various schema types including references, arrays, * format-based types (Solidity), and basic scalar types. * It also correctly applies `Optional` for non-required fields. * * @param schema The OpenRPC schema object to map. * @param isRequired A boolean indicating whether the field represented by this schema is required. * @returns The corresponding Python type hint string. */ openRpcSchemaToPythonType(schema: OpenRPCSchema, isRequired: boolean): string; /** * Provides the Python type mapping for array types, including multi-dimensional arrays, * based on their Solidity representation. * * @param solidityType The Solidity array type string (e.g., 'uint256[]', 'bytes32[10]', 'uint[][2]'). * @returns The corresponding Python `list` type hint string (e.g., `list[list[int]]`), * or `null` if the base type cannot be mapped. */ private getArrayMapping; /** * Extracts and generates Python Pydantic model definitions from the `schemas` object * within OpenRPC components. This method iterates through the schemas and * generates a Python class string for each object schema found. * * @param schemas A record of schema definitions from OpenRPC `components.schemas`. * @param structMap A Map to store the generated Python class strings, keyed by struct name. */ private extractStructsFromOpenRPC; /** * Generates a Python Pydantic model string from an OpenRPC schema definition for an object type. * This includes extending `BaseModel` and defining all properties as fields * with appropriate Python type hints and default values for optional fields. * * @param className The name of the Python class to generate. * @param schema The OpenRPC schema object defining the class structure. * @returns A string representing the complete Python Pydantic model definition. */ private generatePythonClassFromOpenRPC; /** * Sanitizes a given field name to conform to Python's snake_case naming conventions * and ensures it's a valid identifier. * * @param name The original field name string. * @returns The sanitized field name in snake_case. */ private sanitizeFieldName; } //# sourceMappingURL=python-type-mapper.d.ts.map