-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow bech32 address value payload #174
Allow bech32 address value payload #174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
# Simple (from bech32) | ||
address = Address.new_from_bech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th") | ||
value = AddressValue() | ||
value.set_payload(address.bech32()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use to_bech32()
instead.
multiversx_sdk/abi/address_value.py
Outdated
@@ -45,6 +45,9 @@ def set_payload(self, value: Any): | |||
if isinstance(value, dict): | |||
value = cast(Dict[str, str], value) | |||
pubkey = self._extract_pubkey_from_dict(value) | |||
elif isinstance(value, str): | |||
address = Address.new_from_bech32(value) | |||
pubkey = address.pubkey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say use get_public_key()
to stay consistent throughout the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Nice!
(the comments from Alex)
requested changes applied! |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
Context
Currently, bech32 string cannot be directly passed as tranaction argument to the smart-contract factories. Indeed, this leads to an error when setting the payload of an AddressValue
Proposed Change
If the
set_payload
method receives a string, it should try to parse it as bech32 to extract the pubkeyThis would allow to pass effectively bech32 strings as transaction arguments to the smart-contract factories.