(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None)
| 3344 | } |
| 3345 | |
| 3346 | def sign(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None): |
| 3347 | type = self.safe_string(api, 0) |
| 3348 | access = self.safe_string(api, 1) |
| 3349 | url = self.urls['api'][type] + '/' + path |
| 3350 | query = self.omit(params, self.extract_params(path)) |
| 3351 | if access == 'public': |
| 3352 | if query: |
| 3353 | url += '?' + self.urlencode(query) |
| 3354 | else: |
| 3355 | self.check_required_credentials() |
| 3356 | nonce = str(self.nonce()) |
| 3357 | requestParams = self.extend({}, params) |
| 3358 | paramsKeys = list(requestParams.keys()) |
| 3359 | strSortKey = self.params_to_string(requestParams, 0) |
| 3360 | payload = path + nonce + self.apiKey + strSortKey + nonce |
| 3361 | signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256) |
| 3362 | paramsKeysLength = len(paramsKeys) |
| 3363 | body = self.json({ |
| 3364 | 'id': nonce, |
| 3365 | 'method': path, |
| 3366 | 'params': params, |
| 3367 | 'api_key': self.apiKey, |
| 3368 | 'sig': signature, |
| 3369 | 'nonce': nonce, |
| 3370 | }) |
| 3371 | # fix issue https://github.com/ccxt/ccxt/issues/11179 |
| 3372 | # php always encodes dictionaries |
| 3373 | # if an array is empty, php will put it in square brackets |
| 3374 | # python and js will put it in curly brackets |
| 3375 | # the code below checks and replaces those brackets in empty requests |
| 3376 | if paramsKeysLength == 0: |
| 3377 | paramsString = '{}' |
| 3378 | arrayString = '[]' |
| 3379 | body = body.replace(arrayString, paramsString) |
| 3380 | headers = { |
| 3381 | 'Content-Type': 'application/json', |
| 3382 | } |
| 3383 | return {'url': url, 'method': method, 'body': body, 'headers': headers} |
| 3384 | |
| 3385 | def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody): |
| 3386 | errorCode = self.safe_string(response, 'code') |
nothing calls this directly
no test coverage detected