Skip to content

Commit 999174c

Browse files
authored
refactor: message adjustments (#170)
1 parent c8181ae commit 999174c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crypto/utils/message.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ def __init__(self, public_key: Union[bytes, str], message: Union[bytes, str], si
2828
else:
2929
self.signature = signature
3030

31+
@staticmethod
32+
def new(public_key: Union[bytes, str], message: Union[bytes, str], signature: Union[bytes, str]):
33+
"""Creates a new message object
34+
35+
Returns:
36+
Message: returns a message object
37+
"""
38+
return Message(
39+
public_key=public_key,
40+
message=message,
41+
signature=signature,
42+
)
43+
3144
@classmethod
3245
def sign(cls, message: Union[bytes, str], passphrase: Union[bytes, str]):
3346
"""Signs a message
@@ -105,3 +118,11 @@ def to_json(self):
105118
data = self.to_dict()
106119

107120
return json.dumps(data)
121+
122+
def __str__(self):
123+
"""Returns a string representation of the message
124+
125+
Returns:
126+
str: string representation of the message
127+
"""
128+
return self.to_json()

0 commit comments

Comments
 (0)