File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -74,9 +74,6 @@ async def sign_message(self, message: Dict) -> Dict:
7474 signature = await self .sign_raw (get_verification_buffer (message ))
7575 message ["signature" ] = signature .hex ()
7676
77- if not str (message ["signature" ]).startswith ("0x" ):
78- message ["signature" ] = "0x" + message ["signature" ]
79-
8077 return message
8178
8279 @abstractmethod
Original file line number Diff line number Diff line change 22import base64
33from decimal import Decimal
44from pathlib import Path
5- from typing import Awaitable , Optional , Union
5+ from typing import Awaitable , Dict , Optional , Union
66
77from aleph_message .models import Chain
88from eth_account import Account # type: ignore
@@ -80,6 +80,22 @@ async def sign_raw(self, buffer: bytes) -> bytes:
8080 sig = self ._account .sign_message (msghash )
8181 return sig ["signature" ]
8282
83+ async def sign_message (self , message : Dict ) -> Dict :
84+ """
85+ Returns a signed message from an aleph.im message.
86+ Args:
87+ message: Message to sign
88+ Returns:
89+ Dict: Signed message
90+ """
91+ signed_message = await super ().sign_message (message )
92+
93+ # Apply that fix as seems that sometimes the .hex() method doesn't add the 0x str at the beginning
94+ if not str (signed_message ["signature" ]).startswith ("0x" ):
95+ signed_message ["signature" ] = "0x" + signed_message ["signature" ]
96+
97+ return signed_message
98+
8399 def connect_chain (self , chain : Optional [Chain ] = None ):
84100 self .chain = chain
85101 if self .chain :
You can’t perform that action at this time.
0 commit comments