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 bytes.fromhex #393

Merged
merged 2 commits into from
Jul 23, 2024
Merged

Add bytes.fromhex #393

merged 2 commits into from
Jul 23, 2024

Conversation

nielstron
Copy link
Contributor

This fixes #103 and currently works using the object like this

b"".fromhex("abcd")
bytes([]).fromhex("abcd")

Another implementation (using bytes.fromhex) will not be available without also adding #365 .

Comment on lines +433 to +440
try:
ret = eval_uplc_value(source_code, i.encode("utf8"))
except RuntimeError as e:
ret = None
try:
exp = bytes.fromhex(i)
except ValueError:
exp = None

Choose a reason for hiding this comment

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

The nested try-except blocks for eval_uplc_value and bytes.fromhex can make the code harder to read and maintain. If both operations are expected to fail under similar conditions, consider combining the error handling to simplify the logic.

Recommended Solution:
Combine the try-except blocks to handle both operations together, improving readability and maintainability.

@nielstron nielstron merged commit 6a0918b into dev Jul 23, 2024
4 checks passed
@nielstron
Copy link
Contributor Author

Payment was issued to $nielstron in this transaction:
https://cexplorer.io/tx/6d2ed1dc7850e56a40e7b11ff063545823298f8ae18f337b8c93fd166e97bd02

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.

1 participant