NomicFoundation / edr

An Ethereum development runtime implementation that can be reused to build new developer tools.
MIT License
52 stars 8 forks source link

refactor: Provide helpful error msg when deserializing big timestamp #494

Closed Xanewok closed 3 months ago

Xanewok commented 3 months ago

Fixes #435

In place of the existing U64OrUsize we provide a newtype Timestamp around u64 with a custom Deserialize impl that leniently first deserializes to a number/string and then attempts to parse the value to see if it's within the valid range.

We keep providing From and Into for the new type, so the existing code keeps using the impls whenever possible.

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 913edb7a511e996113c84e84560b13297029346a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------------- | ----- | | @nomicfoundation/edr | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Xanewok commented 3 months ago

Reshuffled the tests to be first (to double-check what we do on main already) and force-pushed with expanded deserialize_timestamp test; hope you don't mind :pray: