ccxt 4.2.60 → 4.2.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +11280 -3407
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/hyperliquid.js +9 -0
- package/dist/cjs/src/base/Exchange.js +22 -1
- package/dist/cjs/src/base/functions/encode.js +5 -0
- package/dist/cjs/src/base/functions.js +1 -0
- package/dist/cjs/src/bitfinex2.js +1 -1
- package/dist/cjs/src/bitget.js +74 -23
- package/dist/cjs/src/coinbase.js +108 -103
- package/dist/cjs/src/coinex.js +61 -1
- package/dist/cjs/src/hyperliquid.js +2035 -0
- package/dist/cjs/src/kraken.js +8 -2
- package/dist/cjs/src/krakenfutures.js +28 -0
- package/dist/cjs/src/kucoinfutures.js +2 -2
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/phemex.js +2 -2
- package/dist/cjs/src/pro/bingx.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +158 -0
- package/dist/cjs/src/static_dependencies/ethers/address/address.js +144 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +407 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/address.js +45 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +28 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/array.js +176 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +27 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +52 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +45 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/null.js +30 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/number.js +60 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/string.js +27 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +68 -0
- package/dist/cjs/src/static_dependencies/ethers/fragments.js +614 -0
- package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +492 -0
- package/dist/cjs/src/static_dependencies/ethers/index.js +35 -0
- package/dist/cjs/src/static_dependencies/ethers/interface.js +44 -0
- package/dist/cjs/src/static_dependencies/ethers/typed.js +618 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +20 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/data.js +134 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +228 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/events.js +13 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +29 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/index.js +53 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +231 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +47 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +218 -0
- package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +292 -0
- package/dist/cjs/src/tokocrypto.js +22 -2
- package/dist/cjs/src/wazirx.js +308 -3
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/coinbase.d.ts +3 -3
- package/js/src/abstract/hyperliquid.d.ts +9 -0
- package/js/src/abstract/hyperliquid.js +11 -0
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +13 -1
- package/js/src/base/functions/encode.d.ts +2 -1
- package/js/src/base/functions/encode.js +5 -1
- package/js/src/bitfinex2.js +1 -1
- package/js/src/bitget.js +74 -23
- package/js/src/coinbase.js +108 -103
- package/js/src/coinex.d.ts +3 -1
- package/js/src/coinex.js +61 -1
- package/js/src/hyperliquid.d.ts +83 -0
- package/js/src/hyperliquid.js +2036 -0
- package/js/src/kraken.js +8 -2
- package/js/src/krakenfutures.d.ts +2 -1
- package/js/src/krakenfutures.js +28 -0
- package/js/src/kucoinfutures.js +2 -2
- package/js/src/okx.js +1 -1
- package/js/src/phemex.js +2 -2
- package/js/src/pro/bingx.js +1 -0
- package/js/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
- package/js/src/static_dependencies/ethers/abi-coder.js +148 -0
- package/js/src/static_dependencies/ethers/address/address.d.ts +55 -0
- package/js/src/static_dependencies/ethers/address/address.js +162 -0
- package/js/src/static_dependencies/ethers/address/checks.d.ts +80 -0
- package/js/src/static_dependencies/ethers/address/checks.js +119 -0
- package/js/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
- package/js/src/static_dependencies/ethers/address/contract-address.js +73 -0
- package/js/src/static_dependencies/ethers/address/index.d.ts +48 -0
- package/js/src/static_dependencies/ethers/address/index.js +24 -0
- package/js/src/static_dependencies/ethers/bytes32.d.ts +14 -0
- package/js/src/static_dependencies/ethers/bytes32.js +45 -0
- package/js/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
- package/js/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
- package/js/src/static_dependencies/ethers/coders/address.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/address.js +34 -0
- package/js/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
- package/js/src/static_dependencies/ethers/coders/anonymous.js +27 -0
- package/js/src/static_dependencies/ethers/coders/array.d.ts +24 -0
- package/js/src/static_dependencies/ethers/coders/array.js +162 -0
- package/js/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/boolean.js +26 -0
- package/js/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
- package/js/src/static_dependencies/ethers/coders/bytes.js +39 -0
- package/js/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
- package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
- package/js/src/static_dependencies/ethers/coders/null.d.ts +11 -0
- package/js/src/static_dependencies/ethers/coders/null.js +29 -0
- package/js/src/static_dependencies/ethers/coders/number.d.ts +15 -0
- package/js/src/static_dependencies/ethers/coders/number.js +48 -0
- package/js/src/static_dependencies/ethers/coders/string.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/string.js +26 -0
- package/js/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
- package/js/src/static_dependencies/ethers/coders/tuple.js +67 -0
- package/js/src/static_dependencies/ethers/fragments.d.ts +458 -0
- package/js/src/static_dependencies/ethers/fragments.js +1252 -0
- package/js/src/static_dependencies/ethers/hash/index.d.ts +10 -0
- package/js/src/static_dependencies/ethers/hash/index.js +15 -0
- package/js/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
- package/js/src/static_dependencies/ethers/hash/solidity.js +107 -0
- package/js/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
- package/js/src/static_dependencies/ethers/hash/typed-data.js +490 -0
- package/js/src/static_dependencies/ethers/index.d.ts +19 -0
- package/js/src/static_dependencies/ethers/index.js +22 -0
- package/js/src/static_dependencies/ethers/interface.d.ts +380 -0
- package/js/src/static_dependencies/ethers/interface.js +990 -0
- package/js/src/static_dependencies/ethers/typed.d.ts +569 -0
- package/js/src/static_dependencies/ethers/typed.js +608 -0
- package/js/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
- package/js/src/static_dependencies/ethers/utils/base58.js +68 -0
- package/js/src/static_dependencies/ethers/utils/base64-browser.d.ts +3 -0
- package/js/src/static_dependencies/ethers/utils/base64-browser.js +24 -0
- package/js/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
- package/js/src/static_dependencies/ethers/utils/base64.js +58 -0
- package/js/src/static_dependencies/ethers/utils/data.d.ts +92 -0
- package/js/src/static_dependencies/ethers/utils/data.js +175 -0
- package/js/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
- package/js/src/static_dependencies/ethers/utils/errors.js +227 -0
- package/js/src/static_dependencies/ethers/utils/events.d.ts +76 -0
- package/js/src/static_dependencies/ethers/utils/events.js +52 -0
- package/js/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
- package/js/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
- package/js/src/static_dependencies/ethers/utils/index.d.ts +30 -0
- package/js/src/static_dependencies/ethers/utils/index.js +38 -0
- package/js/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
- package/js/src/static_dependencies/ethers/utils/maths.js +220 -0
- package/js/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
- package/js/src/static_dependencies/ethers/utils/properties.js +59 -0
- package/js/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
- package/js/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
- package/js/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
- package/js/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
- package/js/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
- package/js/src/static_dependencies/ethers/utils/rlp.js +14 -0
- package/js/src/static_dependencies/ethers/utils/units.d.ts +23 -0
- package/js/src/static_dependencies/ethers/utils/units.js +88 -0
- package/js/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
- package/js/src/static_dependencies/ethers/utils/utf8.js +225 -0
- package/js/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
- package/js/src/static_dependencies/ethers/utils/uuid.js +35 -0
- package/js/src/static_dependencies/messagepack/msgpack.d.ts +2 -0
- package/js/src/static_dependencies/messagepack/msgpack.js +572 -0
- package/js/src/tokocrypto.js +22 -2
- package/js/src/wazirx.d.ts +12 -1
- package/js/src/wazirx.js +308 -3
- package/package.json +1 -1
- package/skip-tests.json +18 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Property helper functions.
|
|
7
|
+
*
|
|
8
|
+
* @_subsection api/utils:Properties [about-properties]
|
|
9
|
+
*/
|
|
10
|
+
function checkType(value, type, name) {
|
|
11
|
+
const types = type.split("|").map(t => t.trim());
|
|
12
|
+
for (let i = 0; i < types.length; i++) {
|
|
13
|
+
switch (type) {
|
|
14
|
+
case "any":
|
|
15
|
+
return;
|
|
16
|
+
case "bigint":
|
|
17
|
+
case "boolean":
|
|
18
|
+
case "number":
|
|
19
|
+
case "string":
|
|
20
|
+
if (typeof (value) === type) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const error = new Error(`invalid value for type ${type}`);
|
|
26
|
+
error.code = "INVALID_ARGUMENT";
|
|
27
|
+
error.argument = `value.${name}`;
|
|
28
|
+
error.value = value;
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Assigns the %%values%% to %%target%% as read-only values.
|
|
33
|
+
*
|
|
34
|
+
* It %%types%% is specified, the values are checked.
|
|
35
|
+
*/
|
|
36
|
+
function defineProperties(target, values, types) {
|
|
37
|
+
for (let key in values) {
|
|
38
|
+
let value = values[key];
|
|
39
|
+
const type = (types ? types[key] : null);
|
|
40
|
+
if (type) {
|
|
41
|
+
checkType(value, type, key);
|
|
42
|
+
}
|
|
43
|
+
Object.defineProperty(target, key, { enumerable: true, value, writable: false });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.defineProperties = defineProperties;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var data = require('./data.js');
|
|
6
|
+
var errors = require('./errors.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Using strings in Ethereum (or any security-basd system) requires
|
|
10
|
+
* additional care. These utilities attempt to mitigate some of the
|
|
11
|
+
* safety issues as well as provide the ability to recover and analyse
|
|
12
|
+
* strings.
|
|
13
|
+
*
|
|
14
|
+
* @_subsection api/utils:Strings and UTF-8 [about-strings]
|
|
15
|
+
*/
|
|
16
|
+
function errorFunc(reason, offset, bytes, output, badCodepoint) {
|
|
17
|
+
errors.assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes);
|
|
18
|
+
}
|
|
19
|
+
function ignoreFunc(reason, offset, bytes, output, badCodepoint) {
|
|
20
|
+
// If there is an invalid prefix (including stray continuation), skip any additional continuation bytes
|
|
21
|
+
if (reason === "BAD_PREFIX" || reason === "UNEXPECTED_CONTINUE") {
|
|
22
|
+
let i = 0;
|
|
23
|
+
for (let o = offset + 1; o < bytes.length; o++) {
|
|
24
|
+
if (bytes[o] >> 6 !== 0x02) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
i++;
|
|
28
|
+
}
|
|
29
|
+
return i;
|
|
30
|
+
}
|
|
31
|
+
// This byte runs us past the end of the string, so just jump to the end
|
|
32
|
+
// (but the first byte was read already read and therefore skipped)
|
|
33
|
+
if (reason === "OVERRUN") {
|
|
34
|
+
return bytes.length - offset - 1;
|
|
35
|
+
}
|
|
36
|
+
// Nothing to skip
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
function replaceFunc(reason, offset, bytes, output, badCodepoint) {
|
|
40
|
+
// Overlong representations are otherwise "valid" code points; just non-deistingtished
|
|
41
|
+
if (reason === "OVERLONG") {
|
|
42
|
+
errors.assertArgument(typeof (badCodepoint) === "number", "invalid bad code point for replacement", "badCodepoint", badCodepoint);
|
|
43
|
+
output.push(badCodepoint);
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
// Put the replacement character into the output
|
|
47
|
+
output.push(0xfffd);
|
|
48
|
+
// Otherwise, process as if ignoring errors
|
|
49
|
+
return ignoreFunc(reason, offset, bytes);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A handful of popular, built-in UTF-8 error handling strategies.
|
|
53
|
+
*
|
|
54
|
+
* **``"error"``** - throws on ANY illegal UTF-8 sequence or
|
|
55
|
+
* non-canonical (overlong) codepoints (this is the default)
|
|
56
|
+
*
|
|
57
|
+
* **``"ignore"``** - silently drops any illegal UTF-8 sequence
|
|
58
|
+
* and accepts non-canonical (overlong) codepoints
|
|
59
|
+
*
|
|
60
|
+
* **``"replace"``** - replace any illegal UTF-8 sequence with the
|
|
61
|
+
* UTF-8 replacement character (i.e. ``"\\ufffd"``) and accepts
|
|
62
|
+
* non-canonical (overlong) codepoints
|
|
63
|
+
*
|
|
64
|
+
* @returns: Record<"error" | "ignore" | "replace", Utf8ErrorFunc>
|
|
65
|
+
*/
|
|
66
|
+
const Utf8ErrorFuncs = Object.freeze({
|
|
67
|
+
error: errorFunc,
|
|
68
|
+
ignore: ignoreFunc,
|
|
69
|
+
replace: replaceFunc
|
|
70
|
+
});
|
|
71
|
+
// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499
|
|
72
|
+
function getUtf8CodePoints(_bytes, onError) {
|
|
73
|
+
if (onError == null) {
|
|
74
|
+
onError = Utf8ErrorFuncs.error;
|
|
75
|
+
}
|
|
76
|
+
const bytes = data.getBytes(_bytes, "bytes");
|
|
77
|
+
const result = [];
|
|
78
|
+
let i = 0;
|
|
79
|
+
// Invalid bytes are ignored
|
|
80
|
+
while (i < bytes.length) {
|
|
81
|
+
const c = bytes[i++];
|
|
82
|
+
// 0xxx xxxx
|
|
83
|
+
if (c >> 7 === 0) {
|
|
84
|
+
result.push(c);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Multibyte; how many bytes left for this character?
|
|
88
|
+
let extraLength = null;
|
|
89
|
+
let overlongMask = null;
|
|
90
|
+
// 110x xxxx 10xx xxxx
|
|
91
|
+
if ((c & 0xe0) === 0xc0) {
|
|
92
|
+
extraLength = 1;
|
|
93
|
+
overlongMask = 0x7f;
|
|
94
|
+
// 1110 xxxx 10xx xxxx 10xx xxxx
|
|
95
|
+
}
|
|
96
|
+
else if ((c & 0xf0) === 0xe0) {
|
|
97
|
+
extraLength = 2;
|
|
98
|
+
overlongMask = 0x7ff;
|
|
99
|
+
// 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
|
|
100
|
+
}
|
|
101
|
+
else if ((c & 0xf8) === 0xf0) {
|
|
102
|
+
extraLength = 3;
|
|
103
|
+
overlongMask = 0xffff;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
if ((c & 0xc0) === 0x80) {
|
|
107
|
+
i += onError("UNEXPECTED_CONTINUE", i - 1, bytes, result);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
i += onError("BAD_PREFIX", i - 1, bytes, result);
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// Do we have enough bytes in our data?
|
|
115
|
+
if (i - 1 + extraLength >= bytes.length) {
|
|
116
|
+
i += onError("OVERRUN", i - 1, bytes, result);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
// Remove the length prefix from the char
|
|
120
|
+
let res = c & ((1 << (8 - extraLength - 1)) - 1);
|
|
121
|
+
for (let j = 0; j < extraLength; j++) {
|
|
122
|
+
let nextChar = bytes[i];
|
|
123
|
+
// Invalid continuation byte
|
|
124
|
+
if ((nextChar & 0xc0) != 0x80) {
|
|
125
|
+
i += onError("MISSING_CONTINUE", i, bytes, result);
|
|
126
|
+
res = null;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
res = (res << 6) | (nextChar & 0x3f);
|
|
130
|
+
i++;
|
|
131
|
+
}
|
|
132
|
+
// See above loop for invalid continuation byte
|
|
133
|
+
if (res === null) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
// Maximum code point
|
|
137
|
+
if (res > 0x10ffff) {
|
|
138
|
+
i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes, result, res);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
// Reserved for UTF-16 surrogate halves
|
|
142
|
+
if (res >= 0xd800 && res <= 0xdfff) {
|
|
143
|
+
i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes, result, res);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// Check for overlong sequences (more bytes than needed)
|
|
147
|
+
if (res <= overlongMask) {
|
|
148
|
+
i += onError("OVERLONG", i - 1 - extraLength, bytes, result, res);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
result.push(res);
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
|
|
156
|
+
/**
|
|
157
|
+
* Returns the UTF-8 byte representation of %%str%%.
|
|
158
|
+
*
|
|
159
|
+
* If %%form%% is specified, the string is normalized.
|
|
160
|
+
*/
|
|
161
|
+
function toUtf8Bytes(str, form) {
|
|
162
|
+
if (form != null) {
|
|
163
|
+
errors.assertNormalize(form);
|
|
164
|
+
str = str.normalize(form);
|
|
165
|
+
}
|
|
166
|
+
let result = [];
|
|
167
|
+
for (let i = 0; i < str.length; i++) {
|
|
168
|
+
const c = str.charCodeAt(i);
|
|
169
|
+
if (c < 0x80) {
|
|
170
|
+
result.push(c);
|
|
171
|
+
}
|
|
172
|
+
else if (c < 0x800) {
|
|
173
|
+
result.push((c >> 6) | 0xc0);
|
|
174
|
+
result.push((c & 0x3f) | 0x80);
|
|
175
|
+
}
|
|
176
|
+
else if ((c & 0xfc00) == 0xd800) {
|
|
177
|
+
i++;
|
|
178
|
+
const c2 = str.charCodeAt(i);
|
|
179
|
+
errors.assertArgument(i < str.length && ((c2 & 0xfc00) === 0xdc00), "invalid surrogate pair", "str", str);
|
|
180
|
+
// Surrogate Pair
|
|
181
|
+
const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);
|
|
182
|
+
result.push((pair >> 18) | 0xf0);
|
|
183
|
+
result.push(((pair >> 12) & 0x3f) | 0x80);
|
|
184
|
+
result.push(((pair >> 6) & 0x3f) | 0x80);
|
|
185
|
+
result.push((pair & 0x3f) | 0x80);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
result.push((c >> 12) | 0xe0);
|
|
189
|
+
result.push(((c >> 6) & 0x3f) | 0x80);
|
|
190
|
+
result.push((c & 0x3f) | 0x80);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return new Uint8Array(result);
|
|
194
|
+
}
|
|
195
|
+
//export
|
|
196
|
+
function _toUtf8String(codePoints) {
|
|
197
|
+
return codePoints.map((codePoint) => {
|
|
198
|
+
if (codePoint <= 0xffff) {
|
|
199
|
+
return String.fromCharCode(codePoint);
|
|
200
|
+
}
|
|
201
|
+
codePoint -= 0x10000;
|
|
202
|
+
return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00));
|
|
203
|
+
}).join("");
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Returns the string represented by the UTF-8 data %%bytes%%.
|
|
207
|
+
*
|
|
208
|
+
* When %%onError%% function is specified, it is called on UTF-8
|
|
209
|
+
* errors allowing recovery using the [[Utf8ErrorFunc]] API.
|
|
210
|
+
* (default: [error](Utf8ErrorFuncs))
|
|
211
|
+
*/
|
|
212
|
+
function toUtf8String(bytes, onError) {
|
|
213
|
+
return _toUtf8String(getUtf8CodePoints(bytes, onError));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
exports.Utf8ErrorFuncs = Utf8ErrorFuncs;
|
|
217
|
+
exports.toUtf8Bytes = toUtf8Bytes;
|
|
218
|
+
exports.toUtf8String = toUtf8String;
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// (function () {
|
|
6
|
+
// "use strict";
|
|
7
|
+
// Serializes a value to a MessagePack byte array.
|
|
8
|
+
//
|
|
9
|
+
// data: The value to serialize. This can be a scalar, array or object.
|
|
10
|
+
// options: An object that defines additional options.
|
|
11
|
+
// - multiple: (boolean) Indicates whether multiple values in data are concatenated to multiple MessagePack arrays. Default: false.
|
|
12
|
+
// - invalidTypeReplacement:
|
|
13
|
+
// (any) The value that is used to replace values of unsupported types.
|
|
14
|
+
// (function) A function that returns such a value, given the original value as parameter.
|
|
15
|
+
function serialize(data, options) {
|
|
16
|
+
if (options && options.multiple && !Array.isArray(data)) {
|
|
17
|
+
throw new Error("Invalid argument type: Expected an Array to serialize multiple values.");
|
|
18
|
+
}
|
|
19
|
+
const pow32 = 0x100000000; // 2^32
|
|
20
|
+
let floatBuffer, floatView;
|
|
21
|
+
let array = new Uint8Array(128);
|
|
22
|
+
let length = 0;
|
|
23
|
+
if (options && options.multiple) {
|
|
24
|
+
for (let i = 0; i < data.length; i++) {
|
|
25
|
+
append(data[i]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
append(data);
|
|
30
|
+
}
|
|
31
|
+
return array.subarray(0, length);
|
|
32
|
+
function append(data, isReplacement) {
|
|
33
|
+
switch (typeof data) {
|
|
34
|
+
case "undefined":
|
|
35
|
+
appendNull();
|
|
36
|
+
break;
|
|
37
|
+
case "boolean":
|
|
38
|
+
appendBoolean(data);
|
|
39
|
+
break;
|
|
40
|
+
case "number":
|
|
41
|
+
appendNumber(data);
|
|
42
|
+
break;
|
|
43
|
+
case "string":
|
|
44
|
+
appendString(data);
|
|
45
|
+
break;
|
|
46
|
+
case "object":
|
|
47
|
+
if (data === null)
|
|
48
|
+
appendNull();
|
|
49
|
+
else if (data instanceof Date)
|
|
50
|
+
appendDate(data);
|
|
51
|
+
else if (Array.isArray(data))
|
|
52
|
+
appendArray(data);
|
|
53
|
+
else if (data instanceof Uint8Array || data instanceof Uint8ClampedArray)
|
|
54
|
+
appendBinArray(data);
|
|
55
|
+
else if (data instanceof Int8Array || data instanceof Int16Array || data instanceof Uint16Array ||
|
|
56
|
+
data instanceof Int32Array || data instanceof Uint32Array ||
|
|
57
|
+
data instanceof Float32Array || data instanceof Float64Array)
|
|
58
|
+
appendArray(data);
|
|
59
|
+
else
|
|
60
|
+
appendObject(data);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
if (!isReplacement && options && options.invalidTypeReplacement) {
|
|
64
|
+
if (typeof options.invalidTypeReplacement === "function")
|
|
65
|
+
append(options.invalidTypeReplacement(data), true);
|
|
66
|
+
else
|
|
67
|
+
append(options.invalidTypeReplacement, true);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new Error("Invalid argument type: The type '" + (typeof data) + "' cannot be serialized.");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function appendNull(data) {
|
|
75
|
+
appendByte(0xc0);
|
|
76
|
+
}
|
|
77
|
+
function appendBoolean(data) {
|
|
78
|
+
appendByte(data ? 0xc3 : 0xc2);
|
|
79
|
+
}
|
|
80
|
+
function appendNumber(data) {
|
|
81
|
+
if (isFinite(data) && Math.floor(data) === data) {
|
|
82
|
+
// Integer
|
|
83
|
+
if (data >= 0 && data <= 0x7f) {
|
|
84
|
+
appendByte(data);
|
|
85
|
+
}
|
|
86
|
+
else if (data < 0 && data >= -0x20) {
|
|
87
|
+
appendByte(data);
|
|
88
|
+
}
|
|
89
|
+
else if (data > 0 && data <= 0xff) { // uint8
|
|
90
|
+
appendBytes([0xcc, data]);
|
|
91
|
+
}
|
|
92
|
+
else if (data >= -0x80 && data <= 0x7f) { // int8
|
|
93
|
+
appendBytes([0xd0, data]);
|
|
94
|
+
}
|
|
95
|
+
else if (data > 0 && data <= 0xffff) { // uint16
|
|
96
|
+
appendBytes([0xcd, data >>> 8, data]);
|
|
97
|
+
}
|
|
98
|
+
else if (data >= -0x8000 && data <= 0x7fff) { // int16
|
|
99
|
+
appendBytes([0xd1, data >>> 8, data]);
|
|
100
|
+
}
|
|
101
|
+
else if (data > 0 && data <= 0xffffffff) { // uint32
|
|
102
|
+
appendBytes([0xce, data >>> 24, data >>> 16, data >>> 8, data]);
|
|
103
|
+
}
|
|
104
|
+
else if (data >= -0x80000000 && data <= 0x7fffffff) { // int32
|
|
105
|
+
appendBytes([0xd2, data >>> 24, data >>> 16, data >>> 8, data]);
|
|
106
|
+
}
|
|
107
|
+
else if (data > 0 && data <= 0xffffffffffffffff) { // uint64
|
|
108
|
+
// Split 64 bit number into two 32 bit numbers because JavaScript only regards
|
|
109
|
+
// 32 bits for bitwise operations.
|
|
110
|
+
let hi = data / pow32;
|
|
111
|
+
let lo = data % pow32;
|
|
112
|
+
appendBytes([0xcf, hi >>> 24, hi >>> 16, hi >>> 8, hi, lo >>> 24, lo >>> 16, lo >>> 8, lo]);
|
|
113
|
+
}
|
|
114
|
+
else if (data >= -0x8000000000000000 && data <= 0x7fffffffffffffff) { // int64
|
|
115
|
+
appendByte(0xd3);
|
|
116
|
+
appendInt64(data);
|
|
117
|
+
}
|
|
118
|
+
else if (data < 0) { // below int64
|
|
119
|
+
appendBytes([0xd3, 0x80, 0, 0, 0, 0, 0, 0, 0]);
|
|
120
|
+
}
|
|
121
|
+
else { // above uint64
|
|
122
|
+
appendBytes([0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Float
|
|
127
|
+
if (!floatView) {
|
|
128
|
+
floatBuffer = new ArrayBuffer(8);
|
|
129
|
+
floatView = new DataView(floatBuffer);
|
|
130
|
+
}
|
|
131
|
+
floatView.setFloat64(0, data);
|
|
132
|
+
appendByte(0xcb);
|
|
133
|
+
appendBytes(new Uint8Array(floatBuffer));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function appendString(data) {
|
|
137
|
+
let bytes = encodeUtf8(data);
|
|
138
|
+
let length = bytes.length;
|
|
139
|
+
if (length <= 0x1f)
|
|
140
|
+
appendByte(0xa0 + length);
|
|
141
|
+
else if (length <= 0xff)
|
|
142
|
+
appendBytes([0xd9, length]);
|
|
143
|
+
else if (length <= 0xffff)
|
|
144
|
+
appendBytes([0xda, length >>> 8, length]);
|
|
145
|
+
else
|
|
146
|
+
appendBytes([0xdb, length >>> 24, length >>> 16, length >>> 8, length]);
|
|
147
|
+
appendBytes(bytes);
|
|
148
|
+
}
|
|
149
|
+
function appendArray(data) {
|
|
150
|
+
let length = data.length;
|
|
151
|
+
if (length <= 0xf)
|
|
152
|
+
appendByte(0x90 + length);
|
|
153
|
+
else if (length <= 0xffff)
|
|
154
|
+
appendBytes([0xdc, length >>> 8, length]);
|
|
155
|
+
else
|
|
156
|
+
appendBytes([0xdd, length >>> 24, length >>> 16, length >>> 8, length]);
|
|
157
|
+
for (let index = 0; index < length; index++) {
|
|
158
|
+
append(data[index]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function appendBinArray(data) {
|
|
162
|
+
let length = data.length;
|
|
163
|
+
if (length <= 0xf)
|
|
164
|
+
appendBytes([0xc4, length]);
|
|
165
|
+
else if (length <= 0xffff)
|
|
166
|
+
appendBytes([0xc5, length >>> 8, length]);
|
|
167
|
+
else
|
|
168
|
+
appendBytes([0xc6, length >>> 24, length >>> 16, length >>> 8, length]);
|
|
169
|
+
appendBytes(data);
|
|
170
|
+
}
|
|
171
|
+
function appendObject(data) {
|
|
172
|
+
let length = 0;
|
|
173
|
+
for (let key in data) {
|
|
174
|
+
if (data[key] !== undefined) {
|
|
175
|
+
length++;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (length <= 0xf)
|
|
179
|
+
appendByte(0x80 + length);
|
|
180
|
+
else if (length <= 0xffff)
|
|
181
|
+
appendBytes([0xde, length >>> 8, length]);
|
|
182
|
+
else
|
|
183
|
+
appendBytes([0xdf, length >>> 24, length >>> 16, length >>> 8, length]);
|
|
184
|
+
for (let key in data) {
|
|
185
|
+
let value = data[key];
|
|
186
|
+
if (value !== undefined) {
|
|
187
|
+
append(key);
|
|
188
|
+
append(value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function appendDate(data) {
|
|
193
|
+
let sec = data.getTime() / 1000;
|
|
194
|
+
if (data.getMilliseconds() === 0 && sec >= 0 && sec < 0x100000000) { // 32 bit seconds
|
|
195
|
+
appendBytes([0xd6, 0xff, sec >>> 24, sec >>> 16, sec >>> 8, sec]);
|
|
196
|
+
}
|
|
197
|
+
else if (sec >= 0 && sec < 0x400000000) { // 30 bit nanoseconds, 34 bit seconds
|
|
198
|
+
let ns = data.getMilliseconds() * 1000000;
|
|
199
|
+
appendBytes([0xd7, 0xff, ns >>> 22, ns >>> 14, ns >>> 6, ((ns << 2) >>> 0) | (sec / pow32), sec >>> 24, sec >>> 16, sec >>> 8, sec]);
|
|
200
|
+
}
|
|
201
|
+
else { // 32 bit nanoseconds, 64 bit seconds, negative values allowed
|
|
202
|
+
let ns = data.getMilliseconds() * 1000000;
|
|
203
|
+
appendBytes([0xc7, 12, 0xff, ns >>> 24, ns >>> 16, ns >>> 8, ns]);
|
|
204
|
+
appendInt64(sec);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function appendByte(byte) {
|
|
208
|
+
if (array.length < length + 1) {
|
|
209
|
+
let newLength = array.length * 2;
|
|
210
|
+
while (newLength < length + 1)
|
|
211
|
+
newLength *= 2;
|
|
212
|
+
let newArray = new Uint8Array(newLength);
|
|
213
|
+
newArray.set(array);
|
|
214
|
+
array = newArray;
|
|
215
|
+
}
|
|
216
|
+
array[length] = byte;
|
|
217
|
+
length++;
|
|
218
|
+
}
|
|
219
|
+
function appendBytes(bytes) {
|
|
220
|
+
if (array.length < length + bytes.length) {
|
|
221
|
+
let newLength = array.length * 2;
|
|
222
|
+
while (newLength < length + bytes.length)
|
|
223
|
+
newLength *= 2;
|
|
224
|
+
let newArray = new Uint8Array(newLength);
|
|
225
|
+
newArray.set(array);
|
|
226
|
+
array = newArray;
|
|
227
|
+
}
|
|
228
|
+
array.set(bytes, length);
|
|
229
|
+
length += bytes.length;
|
|
230
|
+
}
|
|
231
|
+
function appendInt64(value) {
|
|
232
|
+
// Split 64 bit number into two 32 bit numbers because JavaScript only regards 32 bits for
|
|
233
|
+
// bitwise operations.
|
|
234
|
+
let hi, lo;
|
|
235
|
+
if (value >= 0) {
|
|
236
|
+
// Same as uint64
|
|
237
|
+
hi = value / pow32;
|
|
238
|
+
lo = value % pow32;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// Split absolute value to high and low, then NOT and ADD(1) to restore negativity
|
|
242
|
+
value++;
|
|
243
|
+
hi = Math.abs(value) / pow32;
|
|
244
|
+
lo = Math.abs(value) % pow32;
|
|
245
|
+
hi = ~hi;
|
|
246
|
+
lo = ~lo;
|
|
247
|
+
}
|
|
248
|
+
appendBytes([hi >>> 24, hi >>> 16, hi >>> 8, hi, lo >>> 24, lo >>> 16, lo >>> 8, lo]);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Encodes a string to UTF-8 bytes.
|
|
252
|
+
function encodeUtf8(str) {
|
|
253
|
+
// Prevent excessive array allocation and slicing for all 7-bit characters
|
|
254
|
+
let ascii = true, length = str.length;
|
|
255
|
+
for (let x = 0; x < length; x++) {
|
|
256
|
+
if (str.charCodeAt(x) > 127) {
|
|
257
|
+
ascii = false;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// Based on: https://gist.github.com/pascaldekloe/62546103a1576803dade9269ccf76330
|
|
262
|
+
let i = 0, bytes = new Uint8Array(str.length * (ascii ? 1 : 4));
|
|
263
|
+
for (let ci = 0; ci !== length; ci++) {
|
|
264
|
+
let c = str.charCodeAt(ci);
|
|
265
|
+
if (c < 128) {
|
|
266
|
+
bytes[i++] = c;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (c < 2048) {
|
|
270
|
+
bytes[i++] = c >> 6 | 192;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
if (c > 0xd7ff && c < 0xdc00) {
|
|
274
|
+
if (++ci >= length)
|
|
275
|
+
throw new Error("UTF-8 encode: incomplete surrogate pair");
|
|
276
|
+
let c2 = str.charCodeAt(ci);
|
|
277
|
+
if (c2 < 0xdc00 || c2 > 0xdfff)
|
|
278
|
+
throw new Error("UTF-8 encode: second surrogate character 0x" + c2.toString(16) + " at index " + ci + " out of range");
|
|
279
|
+
c = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);
|
|
280
|
+
bytes[i++] = c >> 18 | 240;
|
|
281
|
+
bytes[i++] = c >> 12 & 63 | 128;
|
|
282
|
+
}
|
|
283
|
+
else
|
|
284
|
+
bytes[i++] = c >> 12 | 224;
|
|
285
|
+
bytes[i++] = c >> 6 & 63 | 128;
|
|
286
|
+
}
|
|
287
|
+
bytes[i++] = c & 63 | 128;
|
|
288
|
+
}
|
|
289
|
+
return ascii ? bytes : bytes.subarray(0, i);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
exports.serialize = serialize;
|
|
@@ -1016,8 +1016,28 @@ class tokocrypto extends tokocrypto$1 {
|
|
|
1016
1016
|
request['limit'] = limit;
|
|
1017
1017
|
}
|
|
1018
1018
|
const responseInner = this.publicGetOpenV1MarketTrades(this.extend(request, params));
|
|
1019
|
-
|
|
1020
|
-
|
|
1019
|
+
//
|
|
1020
|
+
// {
|
|
1021
|
+
// "code": 0,
|
|
1022
|
+
// "msg": "success",
|
|
1023
|
+
// "data": {
|
|
1024
|
+
// "list": [
|
|
1025
|
+
// {
|
|
1026
|
+
// "id": 28457,
|
|
1027
|
+
// "price": "4.00000100",
|
|
1028
|
+
// "qty": "12.00000000",
|
|
1029
|
+
// "time": 1499865549590,
|
|
1030
|
+
// "isBuyerMaker": true,
|
|
1031
|
+
// "isBestMatch": true
|
|
1032
|
+
// }
|
|
1033
|
+
// ]
|
|
1034
|
+
// },
|
|
1035
|
+
// "timestamp": 1571921637091
|
|
1036
|
+
// }
|
|
1037
|
+
//
|
|
1038
|
+
const data = this.safeDict(responseInner, 'data', {});
|
|
1039
|
+
const list = this.safeList(data, 'list', []);
|
|
1040
|
+
return this.parseTrades(list, market, since, limit);
|
|
1021
1041
|
}
|
|
1022
1042
|
if (limit !== undefined) {
|
|
1023
1043
|
request['limit'] = limit; // default = 500, maximum = 1000
|