
    (i?                     x    d dl 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e      Z G d d	e      Zy
)    )Any)	BaseModel
ConfigDict)CoreSchemaField)to_camel)DEFAULT_REF_TEMPLATEGenerateJsonSchemaJsonSchemaModec                   ,     e Zd ZdZdedef fdZ x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                 H    |j                  dd      ryt        | 	  |      S )Nserialization_excludeF)getsuperfield_is_present)selfr   	__class__s     C/var/www/br/venv/lib/python3.12/site-packages/eth_utils/pydantic.pyr   zOmitJsonSchema.field_is_present   s%    99,e4w'..    )__name__
__module____qualname____doc__r   boolr   __classcell__r   s   @r   r   r      s     /o /$ / /r   r   c                   x     e Zd ZdZ edded      Zedee	dfde
dedee   ded	ed
eeef   f fd       Z x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modekwargsr   c                 ,    t        |   d||||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   s         r   r-   zCamelModel.model_json_schemaQ   s2     w( 
%-	

 
 	
r   )r   r   r   r   r   r   model_configclassmethodr   r   r   strtyper	   r
   r   dictr-   r   r   s   @r   r    r    $   s     D  $ L  05C+

 

 12
 
 
 
c3h
 
r   r    N)typingr   pydanticr   r   pydantic._internal._core_utilsr   pydantic.alias_generatorsr   pydantic.json_schemar   r	   r
   r   r    r,   r   r   <module>r9      s>    /' /A
 A
r   