ApeWorX / ethpm-types

Implementation of EIP-2678
Apache License 2.0
14 stars 8 forks source link

Hexbytes to validate with Pydantic BaseModel and serialize as hex #20

Closed NotPeopling2day closed 2 years ago

NotPeopling2day commented 2 years ago

Create a data type that is a byte32 in structure but serializes as hex. Updated original ticket, HexBytes to validate with Pydantic BaseModel and serialize as hex in dict and json structures.

Replace Hexbytes with new structure. Requires using the BaseModel from ethpm-types or adding _get_value() method to a Pydantic BaseModel, along with customized ethpm-types.HexBytes containing Pydantic validation methods.

https://github.com/ethereum/hexbytes/blob/master/hexbytes/main.py https://pydantic-docs.helpmanual.io/usage/types/#custom-data-types https://pydantic-docs.helpmanual.io/usage/schema/#modifying-schema-in-custom-fields

Size: 2

fubuloubu commented 2 years ago

Chat earlier: create bytes type that is serialized as hex, and has optional validation on the number of bytes it takes up