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:
74
74
signature = await self .sign_raw (get_verification_buffer (message ))
75
75
message ["signature" ] = signature .hex ()
76
76
77
- if not str (message ["signature" ]).startswith ("0x" ):
78
- message ["signature" ] = "0x" + message ["signature" ]
79
-
80
77
return message
81
78
82
79
@abstractmethod
Original file line number Diff line number Diff line change 2
2
import base64
3
3
from decimal import Decimal
4
4
from pathlib import Path
5
- from typing import Awaitable , Optional , Union
5
+ from typing import Awaitable , Dict , Optional , Union
6
6
7
7
from aleph_message .models import Chain
8
8
from eth_account import Account # type: ignore
@@ -80,6 +80,22 @@ async def sign_raw(self, buffer: bytes) -> bytes:
80
80
sig = self ._account .sign_message (msghash )
81
81
return sig ["signature" ]
82
82
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
+
83
99
def connect_chain (self , chain : Optional [Chain ] = None ):
84
100
self .chain = chain
85
101
if self .chain :
You can’t perform that action at this time.
0 commit comments