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

refactor: share hex-related validators #2203

Merged
merged 5 commits into from
Aug 5, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Aug 2, 2024

What I did

noticed bugs and also lack of decent use of annotated-validators for hex-to-int situations, so made HexInt for that - likely will end up in eth-pydantic-types after @bitwise-constructs work is complete there.
also had to delete some unnecessary validators for hex-str and hexbytes as it happens automatically when using those types.

note, did this originally because there was a regression i think with a recent merge validating BlobReceipts, somehow it occasionally go a hex-str for an int there and I was going to add the validator but I am getting tired of repeating this validator everywhere, hence HexInt's birthday

How to verify it

things still work (only better in the case of Blob receipts)!

Checklist

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

gas_limit: Optional[int] = Field(default=None, alias="gas")
nonce: Optional[int] = None # NOTE: `Optional` only to denote using default behavior
value: int = 0
gas_limit: Optional[HexInt] = Field(default=None, alias="gas")
Copy link
Member Author

Choose a reason for hiding this comment

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

note, these are not breaking changes (I added a test to make sure).
HexInt is only an annotated int for Pydantic, doesn't change any serialization types or even anything the API is going to compare about.

I added a test just in case in test_transaction to prove this!

fubuloubu
fubuloubu previously approved these changes Aug 2, 2024
fubuloubu
fubuloubu previously approved these changes Aug 5, 2024
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

@antazoey antazoey merged commit 011f776 into ApeWorX:main Aug 5, 2024
15 checks passed
@antazoey antazoey deleted the refactor/hex-int-validation branch August 5, 2024 17:35
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