Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: adds signed and unsigned ints to list of types #11

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

bitwise-constructs
Copy link
Contributor

@bitwise-constructs bitwise-constructs commented Jun 12, 2024

What I did

Created pydantic types for sized signed and unsigned int types

fixes: #

How I did it

How to verify it

Checklist

  • All changes are completed
  • New test cases have been added
  • Documentation has been updated

@bitwise-constructs bitwise-constructs changed the title Feat: adds signed and unsigned ints to list of types feat: adds signed and unsigned ints to list of types Jun 12, 2024
@antazoey antazoey self-requested a review June 12, 2024 12:55
eth_pydantic_types/hash.py Outdated Show resolved Hide resolved
eth_pydantic_types/hash.py Outdated Show resolved Hide resolved
eth_pydantic_types/hash.py Outdated Show resolved Hide resolved
tests/test_int.py Outdated Show resolved Hide resolved
eth_pydantic_types/validators.py Show resolved Hide resolved
@antazoey
Copy link
Member

  • Include new types / usage in README.md

disentangled previous byte and string types from hash logic, but changed naming convention in the process.
added abi child type for abi specific data, like the name of the type.
README.md Show resolved Hide resolved
eth_pydantic_types/abi.py Outdated Show resolved Hide resolved
eth_pydantic_types/abi.py Outdated Show resolved Hide resolved
eth_pydantic_types/address.py Show resolved Hide resolved
eth_pydantic_types/bytes.py Outdated Show resolved Hide resolved
eth_pydantic_types/hashing.py Outdated Show resolved Hide resolved
eth_pydantic_types/hashing.py Outdated Show resolved Hide resolved
eth_pydantic_types/string.py Outdated Show resolved Hide resolved
@bitwise-constructs bitwise-constructs changed the title feat: adds signed and unsigned ints to list of types feat!: adds signed and unsigned ints to list of types Jun 17, 2024
eth_pydantic_types/abi.py Outdated Show resolved Hide resolved
eth_pydantic_types/hex.py Outdated Show resolved Hide resolved
eth_pydantic_types/hex.py Outdated Show resolved Hide resolved
@bitwise-constructs
Copy link
Contributor Author

submitting as ready for review while updating docs and tests

@bitwise-constructs bitwise-constructs marked this pull request as ready for review June 26, 2024 15:34
eth_pydantic_types/abi.py Outdated Show resolved Hide resolved
eth_pydantic_types/abi.py Outdated Show resolved Hide resolved
eth_pydantic_types/abi.py Outdated Show resolved Hide resolved
tests/test_hash.py Show resolved Hide resolved
@bitwise-constructs bitwise-constructs marked this pull request as draft June 28, 2024 04:29
…h defaulting size of hexbytes object when building out the bound sizes
Copy link
Member

@antazoey antazoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is looking reallly good!

eth_pydantic_types/abi.py Outdated Show resolved Hide resolved
setup.py Outdated
"eth-hash[pycryptodome]>=0.5.2,<1",
"eth-utils>=2.2.0,<3",
"eth-typing>=3.5.0,<4",
"eth-utils>=2.2.0,<5",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably move up some of the lower pins here - try to get these to just 1 major version


```python
from pydantic import BaseModel

from eth_pydantic_types import HashBytes32, HashStr20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include an example of a non-predefine type that is bound?

Like how do I use BoundHexBytes sizes other than 32 and 20?

@@ -28,6 +36,7 @@


class BaseHex:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I am working on core right, and I recently realized I really need a HexInt class.
Basically it allows any hex-str or or bytes but always validates into an integer.

I am going to make one in core ape for now but eventually we can use this work to double-import.

…t/int-types

# Conflicts:
#	eth_pydantic_types/__init__.py
#	eth_pydantic_types/address.py
#	eth_pydantic_types/hash.py
#	eth_pydantic_types/hex.py
#	setup.py
@bitwise-constructs bitwise-constructs marked this pull request as ready for review December 18, 2024 06:51
.pre-commit-config.yaml Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved

@classmethod
def validate_size(cls, value: str) -> str:
if cls.calculate_schema:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: instead of using calculate_schema, what about overriding validate_size() in Address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed by overriding not the full validate_size() call but extracted the contents of this conditional to its own call and overrode that

eth_pydantic_types/utils.py Outdated Show resolved Hide resolved
@@ -1,77 +1,43 @@
import pytest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id like to see a test_abi just to kinda show-case how to use those features, it doesnt have to be comprehensive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants