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

DX: Keyreg bytes #522

Merged
merged 27 commits into from
Dec 11, 2023
Merged

DX: Keyreg bytes #522

merged 27 commits into from
Dec 11, 2023

Conversation

jannotti
Copy link
Contributor

Allow the various key-ish fields of a keyreg txn to be bytes

Previously, these fields were required to be base64 encoded, which
seems like a strange requirement.

Added a few doc string cleanups.

@jannotti jannotti self-assigned this Dec 11, 2023
@jannotti jannotti changed the title Keyreg bytes DX: Keyreg bytes Dec 11, 2023
Copy link
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

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

Looks good and nice code cleanup. Consider my suggestion optional but encouraged

algosdk/transaction.py Outdated Show resolved Hide resolved
return None
if isinstance(key, (bytes, bytearray)) and len(key) == size:
return base64.b64encode(key)
if len(base64.b64decode(key)) == size:
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe also add isinstance(key, str) otherwise b64decode will probably throw an exception (did not check tho)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose it will, but that's life in a dynamic language, I think. Before you could have stuffed something crazy in that field, and you'd get an exception somewhere when we tried to serialize. Now it happens earlier, which I think is better.

But I don't want to try to turn Python into Go and insert type checks all over the place.

@jannotti jannotti merged commit 3e64019 into algorand:develop Dec 11, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants