Skip to content

Commit

Permalink
fix the problem in sign when the order of the parameters was differen…
Browse files Browse the repository at this point in the history
…t from the ones passed in the query
  • Loading branch information
makarworld committed Jun 20, 2023
1 parent 4a21b60 commit 46235a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pymexc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def sign(self, **kwargs) -> str:
A hexadecimal string representing the signature of the request.
"""
# Generate signature
query_string = "&".join([f"{k}={v}" for k, v in sorted(kwargs.items())])
query_string = "&".join([f"{k}={v}" for k, v in kwargs.items()])
signature = hmac.new(self.api_secret.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256).hexdigest()
return signature

Expand All @@ -82,6 +82,7 @@ def call(self, method: Union[Literal["GET"], Literal["POST"], Literal["PUT"], Li
timestamp = str(int(time.time() * 1000))
kwargs['params']['recvWindow'] = self.recvWindow
kwargs['params']['timestamp'] = timestamp
kwargs['params'] = {k: v for k, v in sorted(kwargs['params'].items())}
kwargs['params']['signature'] = self.sign(**kwargs['params'])

response = self.session.request(method, f"{self.base_url}{router}", *args, **kwargs)
Expand Down

0 comments on commit 46235a0

Please sign in to comment.