Skip to content

Commit

Permalink
use constant for message version
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Feb 12, 2024
1 parent 9170dc0 commit e116bdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions multiversx_sdk/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
DIGEST_SIZE = 32

TOKEN_RANDOM_SEQUENCE_LENGTH = 6

DEFAULT_MESSAGE_VERSION = 1
8 changes: 6 additions & 2 deletions multiversx_sdk/core/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit e116bdd

Please sign in to comment.