o
    ¢ØÆh&  ã                   @   st   d dl mZmZmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZmZmZ G dd„ deƒZG dd	„ d	eƒZd
S )é    )ÚAnyÚDictÚType)Ú	BaseModelÚ
ConfigDict)ÚCoreSchemaField)Úto_camel)ÚDEFAULT_REF_TEMPLATEÚGenerateJsonSchemaÚJsonSchemaModec                       s*   e Zd ZdZdedef‡ fdd„Z‡  ZS )ÚOmitJsonSchemazò
    Custom JSON schema generator that omits the schema generation for fields that are
    invalid. Excluded fields (``Field(exclude=True)``) are generally useful as
    properties of the model but are not meant to be serialized to JSON.
    ÚfieldÚreturnc                    s   |  dd¡rdS tƒ  |¡S )NÚserialization_excludeF)ÚgetÚsuperÚfield_is_present)Úselfr   ©Ú	__class__© ú_/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/eth_utils/pydantic.pyr      s   zOmitJsonSchema.field_is_present)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úboolr   Ú__classcell__r   r   r   r   r      s    r   c                       s`   e Zd ZdZeddedd�Zedee	dfde
dedee ded	eeef f
‡ fd
d„ƒZ‡  ZS )Ú
CamelModelav  
    Camel-case pydantic model. This model is used to ensure serialization in a
    consistent manner, aliasing as camelCase serialization. This is useful for models
    that are used in JSON-RPC requests and responses, marking useful fields for the
    model, but that are not part of the JSON-RPC object, with ``Field(exclude=True)``.
    To serialize a model to the expected JSON-RPC format, or camelCase, use
    ``model_dump(by_alias=True)``.

    .. code-block:: python

        >>> from eth_utils.pydantic import CamelModel
        >>> from pydantic import Field

        >>> class SignedSetCodeAuthorization(CamelModel):
        ...     chain_id: int
        ...     address: bytes
        ...     nonce: int
        ...
        ...     # useful fields for the object but excluded from serialization
        ...     # (not part of the JSON-RPC object)
        ...     authorization_hash: bytes = Field(exclude=True)
        ...     signature: bytes = Field(exclude=True)

        >>> auth = SignedSetCodeAuthorization(
        ...     chain_id=1,
        ...     address=b"0x0000000000000000000000000000000000000000",
        ...     nonce=0,
        ...     authorization_hash=generated_hash,
        ...     signature=generated_signature,
        ... )
        >>> auth.model_dump(by_alias=True)
        {'chainId': 1, 'address': '0x000000000000000000000000000000000000', 'nonce': 0}
    T)Úarbitrary_types_allowedÚpopulate_by_nameÚalias_generatorÚvalidate_defaultÚ
validationÚby_aliasÚref_templateÚschema_generatorÚmoder   c                    s   t ƒ j||||d�S )z—
        Omits excluded fields from the JSON schema, preventing errors that would
        otherwise be raised by the default schema generator.
        )r$   r%   r&   r'   )r   Úmodel_json_schema)Úclsr$   r%   r&   r'   r   r   r   r(   S   s   üzCamelModel.model_json_schema)r   r   r   r   r   r   Úmodel_configÚclassmethodr	   r   r   Ústrr   r
   r   r   r   r(   r   r   r   r   r   r   &   s0    "ù
úþýûú
ùr   N)Útypingr   r   r   Úpydanticr   r   Úpydantic._internal._core_utilsr   Úpydantic.alias_generatorsr   Úpydantic.json_schemar	   r
   r   r   r   r   r   r   r   Ú<module>   s    