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

Implement explicit enums #116

Merged
merged 3 commits into from
Oct 24, 2024
Merged

Implement explicit enums #116

merged 3 commits into from
Oct 24, 2024

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented Oct 23, 2024

Implement explicit enums e.g.:

"OperationCompletionStatus": {
            "type": "explicit-enum",
            "variants": [
                {
                    "docs": [
                        "indicates that operation was completed"
                    ],
                    "name": "completed"
                },
                {
                    "docs": [
                        "indicates that operation was interrupted prematurely, due to low gas"
                    ],
                    "name": "interrupted"
                }
            ]
        },

References:

@andreibancioiu andreibancioiu self-assigned this Oct 23, 2024
@andreibancioiu andreibancioiu changed the title Implement explicit enums. Implement explicit enums Oct 23, 2024
@andreibancioiu andreibancioiu marked this pull request as ready for review October 23, 2024 10:22
Copy link

github-actions bot commented Oct 23, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  multiversx_sdk/abi
  __init__.py
  abi.py
  abi_definition.py 254, 270
  enum_value.py
  explicit_enum_value.py
Project Total  

This report was generated by python-coverage-comment-action



class _EnumPayload(SimpleNamespace):
def __int__(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This way, people can convert an EnumValue to an int (quite useful).

self.value = value

def __eq__(self, other: Any) -> bool:
return isinstance(other, ExplicitEnumValue) and self.value == other.value
Copy link
Contributor Author

@andreibancioiu andreibancioiu Oct 23, 2024

Choose a reason for hiding this comment

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

Currently, we don't differentiate between different types of enums (as seen in ABI) if they have the same value / name. We'll brainstorm this a bit (could be perfectly fine in practice).

popenta
popenta previously approved these changes Oct 23, 2024
@@ -6,8 +6,8 @@
from multiversx_sdk.abi.biguint_value import BigUIntValue
from multiversx_sdk.abi.bool_value import BoolValue
from multiversx_sdk.abi.bytes_value import BytesValue
from multiversx_sdk.abi.code_metadata_value import CodeMetadataValue
Copy link
Collaborator

Choose a reason for hiding this comment

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

why was this deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By mistake 🙈

Fixed.

@andreibancioiu andreibancioiu merged commit bb1b7be into main Oct 24, 2024
7 checks passed
@andreibancioiu andreibancioiu deleted the update-23-2 branch October 24, 2024 06:51
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.

3 participants