diff --git a/multiversx_sdk/core/constants.py b/multiversx_sdk/core/constants.py index 175dc3e6..c3f47ef3 100644 --- a/multiversx_sdk/core/constants.py +++ b/multiversx_sdk/core/constants.py @@ -19,3 +19,5 @@ DIGEST_SIZE = 32 TOKEN_RANDOM_SEQUENCE_LENGTH = 6 + +DEFAULT_MESSAGE_VERSION = 1 diff --git a/multiversx_sdk/core/message.py b/multiversx_sdk/core/message.py index b7bf3ceb..c8e3af31 100644 --- a/multiversx_sdk/core/message.py +++ b/multiversx_sdk/core/message.py @@ -3,11 +3,15 @@ from Cryptodome.Hash import keccak from multiversx_sdk.core.address import Address +from multiversx_sdk.core.constants import DEFAULT_MESSAGE_VERSION from multiversx_sdk.core.interfaces import IAddress, IMessage class Message: - def __init__(self, data: bytes, signature: bytes = b"", address: Optional[IAddress] = None, version: int = 1) -> None: + def __init__(self, data: bytes, + signature: bytes = b"", + address: Optional[IAddress] = None, + version: int = DEFAULT_MESSAGE_VERSION) -> None: self.data = data self.signature = signature self.address = address @@ -53,7 +57,7 @@ def unpack_message(self, packed_message: Dict[str, Any]) -> Message: address = packed_message.get("address", "") address = Address.from_bech32(address) if address else None - version = packed_message.get("version", 1) + version = packed_message.get("version", DEFAULT_MESSAGE_VERSION) return Message( data=bytes.fromhex(data),