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

add to_0x_hex method to easily create 0x-prefixed strings #43

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

pacrob
Copy link
Contributor

@pacrob pacrob commented Mar 19, 2024

What was wrong?

In PR #38, I changed the function of the .hex() method to drop the 0x-prefix to match the parent bytes class. But it turns out some other libs depend on there being a quick method to render an 0x-prefixed string.

How was it fixed?

Added the to_0x_hex() method to provide the same functionality .hex() used to have, but more explicitly.

Todo:

  • Clean up commit history

  • Add or update documentation related to these changes

  • Add entry to the release notes

Cute Animal Picture

image

"""
Convert the bytes to a 0x-prefixed hex string
"""
return "0x" + self.hex()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if the hexbbytes object is guarunteed to store without the prefix? Should this ensure the 0x is not already part of the string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it's just a bytes object at the core, there would be no 0x from there. Previously the .hex() method returned an 0x prefix, but does not anymore.

Copy link
Contributor

@reedsa reedsa left a comment

Choose a reason for hiding this comment

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

lgtm!

@pacrob pacrob merged commit 8018c5a into ethereum:main Mar 19, 2024
20 checks passed
@pacrob pacrob deleted the add-to_0x_hex-method branch March 19, 2024 18:00
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.

None yet

2 participants