Skip to content

Commit dd14bfe

Browse files
committed
removed unnecessary methods
1 parent a6277fe commit dd14bfe

File tree

4 files changed

+80
-53
lines changed

4 files changed

+80
-53
lines changed

js/src/base/Exchange.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -550,31 +550,6 @@ export default class Exchange {
550550
throttle(cost = undefined) {
551551
return this.throttler.throttle(cost);
552552
}
553-
setSandboxMode(enabled) {
554-
if (!!enabled) { // eslint-disable-line no-extra-boolean-cast
555-
if ('test' in this.urls) {
556-
if (typeof this.urls['api'] === 'string') {
557-
this.urls['apiBackup'] = this.urls['api'];
558-
this.urls['api'] = this.urls['test'];
559-
}
560-
else {
561-
this.urls['apiBackup'] = clone(this.urls['api']);
562-
this.urls['api'] = clone(this.urls['test']);
563-
}
564-
}
565-
else {
566-
throw new NotSupported(this.id + ' does not have a sandbox URL');
567-
}
568-
}
569-
else if ('apiBackup' in this.urls) {
570-
if (typeof this.urls['api'] === 'string') {
571-
this.urls['api'] = this.urls['apiBackup'];
572-
}
573-
else {
574-
this.urls['api'] = clone(this.urls['apiBackup']);
575-
}
576-
}
577-
}
578553
defineRestApiEndpoint(methodName, uppercaseMethod, lowercaseMethod, camelcaseMethod, path, paths, config = {}) {
579554
const splitPath = path.split(/[^a-zA-Z0-9]/);
580555
const camelcaseSuffix = splitPath.map(this.capitalize).join('');
@@ -1263,6 +1238,33 @@ export default class Exchange {
12631238
}
12641239
return this.filterByLimit(result, limit, key);
12651240
}
1241+
setSandboxMode(enabled) {
1242+
if (enabled) {
1243+
if ('test' in this.urls) {
1244+
if (typeof this.urls['api'] === 'string') {
1245+
this.urls['apiBackup'] = this.urls['api'];
1246+
this.urls['api'] = this.urls['test'];
1247+
}
1248+
else {
1249+
this.urls['apiBackup'] = this.clone(this.urls['api']);
1250+
this.urls['api'] = this.clone(this.urls['test']);
1251+
}
1252+
}
1253+
else {
1254+
throw new NotSupported(this.id + ' does not have a sandbox URL');
1255+
}
1256+
}
1257+
else if ('apiBackup' in this.urls) {
1258+
if (typeof this.urls['api'] === 'string') {
1259+
this.urls['api'] = this.urls['apiBackup'];
1260+
}
1261+
else {
1262+
this.urls['api'] = this.clone(this.urls['apiBackup']);
1263+
}
1264+
const newUrls = this.omit(this.urls, 'apiBackup');
1265+
this.urls = newUrls;
1266+
}
1267+
}
12661268
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
12671269
return {};
12681270
}

php/Exchange.php

Lines changed: 24 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/ccxt/base/exchange.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,13 +1624,13 @@ def find_timeframe(self, timeframe, timeframes=None):
16241624
def clone(self, obj):
16251625
return obj if isinstance(obj, list) else self.extend(obj)
16261626

1627-
def deleteKeyFromDictionary (self, dictionary, key):
1628-
newDictionary = self.clone(dictionary)
1629-
del newDictionary[key]
1630-
return newDictionary
1627+
# def delete_key_from_dictionary(self, dictionary, key):
1628+
# newDictionary = self.clone(dictionary)
1629+
# del newDictionary[key]
1630+
# return newDictionary
16311631

1632-
def setObjectProperty (obj, prop, value):
1633-
obj[prop] = value
1632+
# def set_object_property(obj, prop, value):
1633+
# obj[prop] = value
16341634

16351635
def convert_to_big_int(self, value):
16361636
return int(value) if isinstance(value, str) else value
@@ -1788,6 +1788,25 @@ def filter_by_value_since_limit(self, array: List[object], field: IndexType, val
17881788
return result[-limit:]
17891789
return self.filter_by_limit(result, limit, key)
17901790

1791+
def set_sandbox_mode(self, enabled):
1792+
if enabled:
1793+
if 'test' in self.urls:
1794+
if isinstance(self.urls['api'], str):
1795+
self.urls['apiBackup'] = self.urls['api']
1796+
self.urls['api'] = self.urls['test']
1797+
else:
1798+
self.urls['apiBackup'] = self.clone(self.urls['api'])
1799+
self.urls['api'] = self.clone(self.urls['test'])
1800+
else:
1801+
raise NotSupported(self.id + ' does not have a sandbox URL')
1802+
elif 'apiBackup' in self.urls:
1803+
if isinstance(self.urls['api'], str):
1804+
self.urls['api'] = self.urls['apiBackup']
1805+
else:
1806+
self.urls['api'] = self.clone(self.urls['apiBackup'])
1807+
newUrls = self.omit(self.urls, 'apiBackup')
1808+
self.urls = newUrls
1809+
17911810
def sign(self, path, api: Any = 'public', method='GET', params={}, headers: Optional[Any] = None, body: Optional[Any] = None):
17921811
return {}
17931812

ts/src/base/Exchange.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const {
124124
, NetworkError
125125
, ExchangeNotAvailable
126126
, ArgumentsRequired
127-
, RateLimitExceeded,
127+
, RateLimitExceeded,
128128
BadRequest} from "./errors.js"
129129

130130
import { Precise } from './Precise.js'
@@ -875,7 +875,7 @@ export default class Exchange {
875875
// @ts-ignore
876876
module = await import (/* webpackIgnore: true */ 'socks-proxy-agent');
877877
} catch (e) {
878-
throw new NotSupported (this.id + ' - to use SOCKS proxy with ccxt, at first you need install module "npm i socks-proxy-agent" ');
878+
throw new NotSupported (this.id + ' - to use SOCKS proxy with ccxt, at first you need install module "npm i socks-proxy-agent" ');
879879
}
880880
this.agent = new module.SocksProxyAgent(socksProxy);
881881
}
@@ -1315,16 +1315,6 @@ export default class Exchange {
13151315
return -1;
13161316
}
13171317

1318-
deleteKeyFromDictionary (dictionary, key) {
1319-
const newDictionary = this.clone (dictionary);
1320-
delete newDictionary[key];
1321-
return newDictionary;
1322-
}
1323-
1324-
setObjectProperty (obj, prop, value) {
1325-
obj[prop] = value;
1326-
}
1327-
13281318
convertToBigInt(value: string) {
13291319
return BigInt(value); // used on XT
13301320
}
@@ -1543,8 +1533,8 @@ export default class Exchange {
15431533
} else {
15441534
this.urls['api'] = this.clone (this.urls['apiBackup']);
15451535
}
1546-
const newUrls = this.deleteKeyFromDictionary (this.urls, 'apiBackup');
1547-
this.setObjectProperty (this, 'urls', newUrls);
1536+
const newUrls = this.omit (this.urls, 'apiBackup');
1537+
this.urls = newUrls;
15481538
}
15491539
}
15501540

0 commit comments

Comments
 (0)