ccxt 4.2.60 → 4.2.61

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.
Files changed (158) hide show
  1. package/README.md +103 -102
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +107943 -100121
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +4 -1
  6. package/dist/cjs/src/abstract/hyperliquid.js +9 -0
  7. package/dist/cjs/src/base/Exchange.js +22 -1
  8. package/dist/cjs/src/base/functions/encode.js +5 -0
  9. package/dist/cjs/src/base/functions.js +1 -0
  10. package/dist/cjs/src/bitfinex2.js +1 -1
  11. package/dist/cjs/src/coinbase.js +108 -103
  12. package/dist/cjs/src/coinex.js +61 -1
  13. package/dist/cjs/src/hyperliquid.js +2035 -0
  14. package/dist/cjs/src/kraken.js +8 -2
  15. package/dist/cjs/src/krakenfutures.js +28 -0
  16. package/dist/cjs/src/kucoinfutures.js +2 -2
  17. package/dist/cjs/src/okx.js +1 -1
  18. package/dist/cjs/src/phemex.js +2 -2
  19. package/dist/cjs/src/pro/bingx.js +1 -0
  20. package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +158 -0
  21. package/dist/cjs/src/static_dependencies/ethers/address/address.js +144 -0
  22. package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +407 -0
  23. package/dist/cjs/src/static_dependencies/ethers/coders/address.js +45 -0
  24. package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +28 -0
  25. package/dist/cjs/src/static_dependencies/ethers/coders/array.js +176 -0
  26. package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +27 -0
  27. package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +52 -0
  28. package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +45 -0
  29. package/dist/cjs/src/static_dependencies/ethers/coders/null.js +30 -0
  30. package/dist/cjs/src/static_dependencies/ethers/coders/number.js +60 -0
  31. package/dist/cjs/src/static_dependencies/ethers/coders/string.js +27 -0
  32. package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +68 -0
  33. package/dist/cjs/src/static_dependencies/ethers/fragments.js +614 -0
  34. package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +492 -0
  35. package/dist/cjs/src/static_dependencies/ethers/index.js +35 -0
  36. package/dist/cjs/src/static_dependencies/ethers/interface.js +44 -0
  37. package/dist/cjs/src/static_dependencies/ethers/typed.js +618 -0
  38. package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +20 -0
  39. package/dist/cjs/src/static_dependencies/ethers/utils/data.js +134 -0
  40. package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +228 -0
  41. package/dist/cjs/src/static_dependencies/ethers/utils/events.js +13 -0
  42. package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +29 -0
  43. package/dist/cjs/src/static_dependencies/ethers/utils/index.js +53 -0
  44. package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +231 -0
  45. package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +47 -0
  46. package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +218 -0
  47. package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +292 -0
  48. package/dist/cjs/src/tokocrypto.js +22 -2
  49. package/dist/cjs/src/wazirx.js +308 -3
  50. package/js/ccxt.d.ts +5 -2
  51. package/js/ccxt.js +4 -2
  52. package/js/src/abstract/coinbase.d.ts +3 -3
  53. package/js/src/abstract/hyperliquid.d.ts +9 -0
  54. package/js/src/abstract/hyperliquid.js +11 -0
  55. package/js/src/base/Exchange.d.ts +4 -0
  56. package/js/src/base/Exchange.js +13 -1
  57. package/js/src/base/functions/encode.d.ts +2 -1
  58. package/js/src/base/functions/encode.js +5 -1
  59. package/js/src/bitfinex2.js +1 -1
  60. package/js/src/coinbase.js +108 -103
  61. package/js/src/coinex.d.ts +3 -1
  62. package/js/src/coinex.js +61 -1
  63. package/js/src/hyperliquid.d.ts +83 -0
  64. package/js/src/hyperliquid.js +2036 -0
  65. package/js/src/kraken.js +8 -2
  66. package/js/src/krakenfutures.d.ts +2 -1
  67. package/js/src/krakenfutures.js +28 -0
  68. package/js/src/kucoinfutures.js +2 -2
  69. package/js/src/okx.js +1 -1
  70. package/js/src/phemex.js +2 -2
  71. package/js/src/pro/bingx.js +1 -0
  72. package/js/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
  73. package/js/src/static_dependencies/ethers/abi-coder.js +148 -0
  74. package/js/src/static_dependencies/ethers/address/address.d.ts +55 -0
  75. package/js/src/static_dependencies/ethers/address/address.js +162 -0
  76. package/js/src/static_dependencies/ethers/address/checks.d.ts +80 -0
  77. package/js/src/static_dependencies/ethers/address/checks.js +119 -0
  78. package/js/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
  79. package/js/src/static_dependencies/ethers/address/contract-address.js +73 -0
  80. package/js/src/static_dependencies/ethers/address/index.d.ts +48 -0
  81. package/js/src/static_dependencies/ethers/address/index.js +24 -0
  82. package/js/src/static_dependencies/ethers/bytes32.d.ts +14 -0
  83. package/js/src/static_dependencies/ethers/bytes32.js +45 -0
  84. package/js/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
  85. package/js/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
  86. package/js/src/static_dependencies/ethers/coders/address.d.ts +12 -0
  87. package/js/src/static_dependencies/ethers/coders/address.js +34 -0
  88. package/js/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
  89. package/js/src/static_dependencies/ethers/coders/anonymous.js +27 -0
  90. package/js/src/static_dependencies/ethers/coders/array.d.ts +24 -0
  91. package/js/src/static_dependencies/ethers/coders/array.js +162 -0
  92. package/js/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
  93. package/js/src/static_dependencies/ethers/coders/boolean.js +26 -0
  94. package/js/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
  95. package/js/src/static_dependencies/ethers/coders/bytes.js +39 -0
  96. package/js/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
  97. package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
  98. package/js/src/static_dependencies/ethers/coders/null.d.ts +11 -0
  99. package/js/src/static_dependencies/ethers/coders/null.js +29 -0
  100. package/js/src/static_dependencies/ethers/coders/number.d.ts +15 -0
  101. package/js/src/static_dependencies/ethers/coders/number.js +48 -0
  102. package/js/src/static_dependencies/ethers/coders/string.d.ts +12 -0
  103. package/js/src/static_dependencies/ethers/coders/string.js +26 -0
  104. package/js/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
  105. package/js/src/static_dependencies/ethers/coders/tuple.js +67 -0
  106. package/js/src/static_dependencies/ethers/fragments.d.ts +458 -0
  107. package/js/src/static_dependencies/ethers/fragments.js +1252 -0
  108. package/js/src/static_dependencies/ethers/hash/index.d.ts +10 -0
  109. package/js/src/static_dependencies/ethers/hash/index.js +15 -0
  110. package/js/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
  111. package/js/src/static_dependencies/ethers/hash/solidity.js +107 -0
  112. package/js/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
  113. package/js/src/static_dependencies/ethers/hash/typed-data.js +490 -0
  114. package/js/src/static_dependencies/ethers/index.d.ts +19 -0
  115. package/js/src/static_dependencies/ethers/index.js +22 -0
  116. package/js/src/static_dependencies/ethers/interface.d.ts +380 -0
  117. package/js/src/static_dependencies/ethers/interface.js +990 -0
  118. package/js/src/static_dependencies/ethers/typed.d.ts +569 -0
  119. package/js/src/static_dependencies/ethers/typed.js +608 -0
  120. package/js/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
  121. package/js/src/static_dependencies/ethers/utils/base58.js +68 -0
  122. package/js/src/static_dependencies/ethers/utils/base64-browser.d.ts +3 -0
  123. package/js/src/static_dependencies/ethers/utils/base64-browser.js +24 -0
  124. package/js/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
  125. package/js/src/static_dependencies/ethers/utils/base64.js +58 -0
  126. package/js/src/static_dependencies/ethers/utils/data.d.ts +92 -0
  127. package/js/src/static_dependencies/ethers/utils/data.js +175 -0
  128. package/js/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
  129. package/js/src/static_dependencies/ethers/utils/errors.js +227 -0
  130. package/js/src/static_dependencies/ethers/utils/events.d.ts +76 -0
  131. package/js/src/static_dependencies/ethers/utils/events.js +52 -0
  132. package/js/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
  133. package/js/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
  134. package/js/src/static_dependencies/ethers/utils/index.d.ts +30 -0
  135. package/js/src/static_dependencies/ethers/utils/index.js +38 -0
  136. package/js/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
  137. package/js/src/static_dependencies/ethers/utils/maths.js +220 -0
  138. package/js/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
  139. package/js/src/static_dependencies/ethers/utils/properties.js +59 -0
  140. package/js/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
  141. package/js/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
  142. package/js/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
  143. package/js/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
  144. package/js/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
  145. package/js/src/static_dependencies/ethers/utils/rlp.js +14 -0
  146. package/js/src/static_dependencies/ethers/utils/units.d.ts +23 -0
  147. package/js/src/static_dependencies/ethers/utils/units.js +88 -0
  148. package/js/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
  149. package/js/src/static_dependencies/ethers/utils/utf8.js +225 -0
  150. package/js/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
  151. package/js/src/static_dependencies/ethers/utils/uuid.js +35 -0
  152. package/js/src/static_dependencies/messagepack/msgpack.d.ts +2 -0
  153. package/js/src/static_dependencies/messagepack/msgpack.js +572 -0
  154. package/js/src/tokocrypto.js +22 -2
  155. package/js/src/wazirx.d.ts +12 -1
  156. package/js/src/wazirx.js +308 -3
  157. package/package.json +1 -1
  158. package/skip-tests.json +18 -0
@@ -0,0 +1,162 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { defineProperties, isError, assert, assertArgument, assertArgumentCount } from "../utils/index.js";
8
+ import { Typed } from "../typed.js";
9
+ import { Coder, Result, WordSize, Writer } from "./abstract-coder.js";
10
+ import { AnonymousCoder } from "./anonymous.js";
11
+ /**
12
+ * @_ignore
13
+ */
14
+ export function pack(writer, coders, values) {
15
+ let arrayValues = [];
16
+ if (Array.isArray(values)) {
17
+ arrayValues = values;
18
+ }
19
+ else if (values && typeof (values) === "object") {
20
+ let unique = {};
21
+ arrayValues = coders.map((coder) => {
22
+ const name = coder.localName;
23
+ assert(name, "cannot encode object for signature with missing names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
24
+ assert(!unique[name], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
25
+ unique[name] = true;
26
+ return values[name];
27
+ });
28
+ }
29
+ else {
30
+ assertArgument(false, "invalid tuple value", "tuple", values);
31
+ }
32
+ assertArgument(coders.length === arrayValues.length, "types/value length mismatch", "tuple", values);
33
+ let staticWriter = new Writer();
34
+ let dynamicWriter = new Writer();
35
+ let updateFuncs = [];
36
+ coders.forEach((coder, index) => {
37
+ let value = arrayValues[index];
38
+ if (coder.dynamic) {
39
+ // Get current dynamic offset (for the future pointer)
40
+ let dynamicOffset = dynamicWriter.length;
41
+ // Encode the dynamic value into the dynamicWriter
42
+ coder.encode(dynamicWriter, value);
43
+ // Prepare to populate the correct offset once we are done
44
+ let updateFunc = staticWriter.writeUpdatableValue();
45
+ updateFuncs.push((baseOffset) => {
46
+ updateFunc(baseOffset + dynamicOffset);
47
+ });
48
+ }
49
+ else {
50
+ coder.encode(staticWriter, value);
51
+ }
52
+ });
53
+ // Backfill all the dynamic offsets, now that we know the static length
54
+ updateFuncs.forEach((func) => { func(staticWriter.length); });
55
+ let length = writer.appendWriter(staticWriter);
56
+ length += writer.appendWriter(dynamicWriter);
57
+ return length;
58
+ }
59
+ /**
60
+ * @_ignore
61
+ */
62
+ export function unpack(reader, coders) {
63
+ let values = [];
64
+ let keys = [];
65
+ // A reader anchored to this base
66
+ let baseReader = reader.subReader(0);
67
+ coders.forEach((coder) => {
68
+ let value = null;
69
+ if (coder.dynamic) {
70
+ let offset = reader.readIndex();
71
+ let offsetReader = baseReader.subReader(offset);
72
+ try {
73
+ value = coder.decode(offsetReader);
74
+ }
75
+ catch (error) {
76
+ // Cannot recover from this
77
+ if (isError(error, "BUFFER_OVERRUN")) {
78
+ throw error;
79
+ }
80
+ value = error;
81
+ value.baseType = coder.name;
82
+ value.name = coder.localName;
83
+ value.type = coder.type;
84
+ }
85
+ }
86
+ else {
87
+ try {
88
+ value = coder.decode(reader);
89
+ }
90
+ catch (error) {
91
+ // Cannot recover from this
92
+ if (isError(error, "BUFFER_OVERRUN")) {
93
+ throw error;
94
+ }
95
+ value = error;
96
+ value.baseType = coder.name;
97
+ value.name = coder.localName;
98
+ value.type = coder.type;
99
+ }
100
+ }
101
+ if (value == undefined) {
102
+ throw new Error("investigate");
103
+ }
104
+ values.push(value);
105
+ keys.push(coder.localName || null);
106
+ });
107
+ return Result.fromItems(values, keys);
108
+ }
109
+ /**
110
+ * @_ignore
111
+ */
112
+ export class ArrayCoder extends Coder {
113
+ constructor(coder, length, localName) {
114
+ const type = (coder.type + "[" + (length >= 0 ? length : "") + "]");
115
+ const dynamic = (length === -1 || coder.dynamic);
116
+ super("array", type, localName, dynamic);
117
+ defineProperties(this, { coder, length });
118
+ }
119
+ defaultValue() {
120
+ // Verifies the child coder is valid (even if the array is dynamic or 0-length)
121
+ const defaultChild = this.coder.defaultValue();
122
+ const result = [];
123
+ for (let i = 0; i < this.length; i++) {
124
+ result.push(defaultChild);
125
+ }
126
+ return result;
127
+ }
128
+ encode(writer, _value) {
129
+ const value = Typed.dereference(_value, "array");
130
+ if (!Array.isArray(value)) {
131
+ this._throwError("expected array value", value);
132
+ }
133
+ let count = this.length;
134
+ if (count === -1) {
135
+ count = value.length;
136
+ writer.writeValue(value.length);
137
+ }
138
+ assertArgumentCount(value.length, count, "coder array" + (this.localName ? (" " + this.localName) : ""));
139
+ let coders = [];
140
+ for (let i = 0; i < value.length; i++) {
141
+ coders.push(this.coder);
142
+ }
143
+ return pack(writer, coders, value);
144
+ }
145
+ decode(reader) {
146
+ let count = this.length;
147
+ if (count === -1) {
148
+ count = reader.readIndex();
149
+ // Check that there is *roughly* enough data to ensure
150
+ // stray random data is not being read as a length. Each
151
+ // slot requires at least 32 bytes for their value (or 32
152
+ // bytes as a link to the data). This could use a much
153
+ // tighter bound, but we are erroring on the side of safety.
154
+ assert(count * WordSize <= reader.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * WordSize, length: reader.dataLength });
155
+ }
156
+ let coders = [];
157
+ for (let i = 0; i < count; i++) {
158
+ coders.push(new AnonymousCoder(this.coder));
159
+ }
160
+ return unpack(reader, coders);
161
+ }
162
+ }
@@ -0,0 +1,12 @@
1
+ import { Typed } from "../typed.js";
2
+ import { Coder } from "./abstract-coder.js";
3
+ import type { Reader, Writer } from "./abstract-coder.js";
4
+ /**
5
+ * @_ignore
6
+ */
7
+ export declare class BooleanCoder extends Coder {
8
+ constructor(localName: string);
9
+ defaultValue(): boolean;
10
+ encode(writer: Writer, _value: boolean | Typed): number;
11
+ decode(reader: Reader): any;
12
+ }
@@ -0,0 +1,26 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { Typed } from "../typed.js";
8
+ import { Coder } from "./abstract-coder.js";
9
+ /**
10
+ * @_ignore
11
+ */
12
+ export class BooleanCoder extends Coder {
13
+ constructor(localName) {
14
+ super("bool", "bool", localName, false);
15
+ }
16
+ defaultValue() {
17
+ return false;
18
+ }
19
+ encode(writer, _value) {
20
+ const value = Typed.dereference(_value, "bool");
21
+ return writer.writeValue(value ? 1 : 0);
22
+ }
23
+ decode(reader) {
24
+ return !!reader.readValue();
25
+ }
26
+ }
@@ -0,0 +1,18 @@
1
+ import { Coder } from "./abstract-coder.js";
2
+ import type { Reader, Writer } from "./abstract-coder.js";
3
+ /**
4
+ * @_ignore
5
+ */
6
+ export declare class DynamicBytesCoder extends Coder {
7
+ constructor(type: string, localName: string);
8
+ defaultValue(): string;
9
+ encode(writer: Writer, value: any): number;
10
+ decode(reader: Reader): any;
11
+ }
12
+ /**
13
+ * @_ignore
14
+ */
15
+ export declare class BytesCoder extends DynamicBytesCoder {
16
+ constructor(localName: string);
17
+ decode(reader: Reader): any;
18
+ }
@@ -0,0 +1,39 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { getBytesCopy, hexlify } from "../utils/index.js";
8
+ import { Coder } from "./abstract-coder.js";
9
+ /**
10
+ * @_ignore
11
+ */
12
+ export class DynamicBytesCoder extends Coder {
13
+ constructor(type, localName) {
14
+ super(type, type, localName, true);
15
+ }
16
+ defaultValue() {
17
+ return "0x";
18
+ }
19
+ encode(writer, value) {
20
+ value = getBytesCopy(value);
21
+ let length = writer.writeValue(value.length);
22
+ length += writer.writeBytes(value);
23
+ return length;
24
+ }
25
+ decode(reader) {
26
+ return reader.readBytes(reader.readIndex(), true);
27
+ }
28
+ }
29
+ /**
30
+ * @_ignore
31
+ */
32
+ export class BytesCoder extends DynamicBytesCoder {
33
+ constructor(localName) {
34
+ super("bytes", localName);
35
+ }
36
+ decode(reader) {
37
+ return hexlify(super.decode(reader));
38
+ }
39
+ }
@@ -0,0 +1,14 @@
1
+ import { Typed } from "../typed.js";
2
+ import { Coder } from "./abstract-coder.js";
3
+ import type { BytesLike } from "../utils/index.js";
4
+ import type { Reader, Writer } from "./abstract-coder.js";
5
+ /**
6
+ * @_ignore
7
+ */
8
+ export declare class FixedBytesCoder extends Coder {
9
+ readonly size: number;
10
+ constructor(size: number, localName: string);
11
+ defaultValue(): string;
12
+ encode(writer: Writer, _value: BytesLike | Typed): number;
13
+ decode(reader: Reader): any;
14
+ }
@@ -0,0 +1,32 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { defineProperties, getBytesCopy, hexlify } from "../utils/index.js";
8
+ import { Typed } from "../typed.js";
9
+ import { Coder } from "./abstract-coder.js";
10
+ /**
11
+ * @_ignore
12
+ */
13
+ export class FixedBytesCoder extends Coder {
14
+ constructor(size, localName) {
15
+ let name = "bytes" + String(size);
16
+ super(name, name, localName, false);
17
+ defineProperties(this, { size }, { size: "number" });
18
+ }
19
+ defaultValue() {
20
+ return ("0x0000000000000000000000000000000000000000000000000000000000000000").substring(0, 2 + this.size * 2);
21
+ }
22
+ encode(writer, _value) {
23
+ let data = getBytesCopy(Typed.dereference(_value, this.type));
24
+ if (data.length !== this.size) {
25
+ this._throwError("incorrect data length", _value);
26
+ }
27
+ return writer.writeBytes(data);
28
+ }
29
+ decode(reader) {
30
+ return hexlify(reader.readBytes(this.size));
31
+ }
32
+ }
@@ -0,0 +1,11 @@
1
+ import { Coder } from "./abstract-coder.js";
2
+ import type { Reader, Writer } from "./abstract-coder.js";
3
+ /**
4
+ * @_ignore
5
+ */
6
+ export declare class NullCoder extends Coder {
7
+ constructor(localName: string);
8
+ defaultValue(): null;
9
+ encode(writer: Writer, value: any): number;
10
+ decode(reader: Reader): any;
11
+ }
@@ -0,0 +1,29 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { Coder } from "./abstract-coder.js";
8
+ const Empty = new Uint8Array([]);
9
+ /**
10
+ * @_ignore
11
+ */
12
+ export class NullCoder extends Coder {
13
+ constructor(localName) {
14
+ super("null", "", localName, false);
15
+ }
16
+ defaultValue() {
17
+ return null;
18
+ }
19
+ encode(writer, value) {
20
+ if (value != null) {
21
+ this._throwError("not null", value);
22
+ }
23
+ return writer.writeBytes(Empty);
24
+ }
25
+ decode(reader) {
26
+ reader.readBytes(0);
27
+ return null;
28
+ }
29
+ }
@@ -0,0 +1,15 @@
1
+ import { Typed } from "../typed.js";
2
+ import { Coder } from "./abstract-coder.js";
3
+ import type { BigNumberish } from "../utils/index.js";
4
+ import type { Reader, Writer } from "./abstract-coder.js";
5
+ /**
6
+ * @_ignore
7
+ */
8
+ export declare class NumberCoder extends Coder {
9
+ readonly size: number;
10
+ readonly signed: boolean;
11
+ constructor(size: number, signed: boolean, localName: string);
12
+ defaultValue(): number;
13
+ encode(writer: Writer, _value: BigNumberish | Typed): number;
14
+ decode(reader: Reader): any;
15
+ }
@@ -0,0 +1,48 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { defineProperties, fromTwos, getBigInt, mask, toTwos } from "../utils/index.js";
8
+ import { Typed } from "../typed.js";
9
+ import { Coder, WordSize } from "./abstract-coder.js";
10
+ const BN_0 = BigInt(0);
11
+ const BN_1 = BigInt(1);
12
+ const BN_MAX_UINT256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
13
+ /**
14
+ * @_ignore
15
+ */
16
+ export class NumberCoder extends Coder {
17
+ constructor(size, signed, localName) {
18
+ const name = ((signed ? "int" : "uint") + (size * 8));
19
+ super(name, name, localName, false);
20
+ defineProperties(this, { size, signed }, { size: "number", signed: "boolean" });
21
+ }
22
+ defaultValue() {
23
+ return 0;
24
+ }
25
+ encode(writer, _value) {
26
+ let value = getBigInt(Typed.dereference(_value, this.type));
27
+ // Check bounds are safe for encoding
28
+ let maxUintValue = mask(BN_MAX_UINT256, WordSize * 8);
29
+ if (this.signed) {
30
+ let bounds = mask(maxUintValue, (this.size * 8) - 1);
31
+ if (value > bounds || value < -(bounds + BN_1)) {
32
+ this._throwError("value out-of-bounds", _value);
33
+ }
34
+ value = toTwos(value, 8 * WordSize);
35
+ }
36
+ else if (value < BN_0 || value > mask(maxUintValue, this.size * 8)) {
37
+ this._throwError("value out-of-bounds", _value);
38
+ }
39
+ return writer.writeValue(value);
40
+ }
41
+ decode(reader) {
42
+ let value = mask(reader.readValue(), this.size * 8);
43
+ if (this.signed) {
44
+ value = fromTwos(value, this.size * 8);
45
+ }
46
+ return value;
47
+ }
48
+ }
@@ -0,0 +1,12 @@
1
+ import { Typed } from "../typed.js";
2
+ import { DynamicBytesCoder } from "./bytes.js";
3
+ import type { Reader, Writer } from "./abstract-coder.js";
4
+ /**
5
+ * @_ignore
6
+ */
7
+ export declare class StringCoder extends DynamicBytesCoder {
8
+ constructor(localName: string);
9
+ defaultValue(): string;
10
+ encode(writer: Writer, _value: string | Typed): number;
11
+ decode(reader: Reader): any;
12
+ }
@@ -0,0 +1,26 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { toUtf8Bytes, toUtf8String } from "../utils/utf8.js";
8
+ import { Typed } from "../typed.js";
9
+ import { DynamicBytesCoder } from "./bytes.js";
10
+ /**
11
+ * @_ignore
12
+ */
13
+ export class StringCoder extends DynamicBytesCoder {
14
+ constructor(localName) {
15
+ super("string", localName);
16
+ }
17
+ defaultValue() {
18
+ return "";
19
+ }
20
+ encode(writer, _value) {
21
+ return super.encode(writer, toUtf8Bytes(Typed.dereference(_value, "string")));
22
+ }
23
+ decode(reader) {
24
+ return toUtf8String(super.decode(reader));
25
+ }
26
+ }
@@ -0,0 +1,15 @@
1
+ import { Typed } from "../typed.js";
2
+ import { Coder } from "./abstract-coder.js";
3
+ import type { Reader, Writer } from "./abstract-coder.js";
4
+ /**
5
+ * @_ignore
6
+ */
7
+ export declare class TupleCoder extends Coder {
8
+ readonly coders: ReadonlyArray<Coder>;
9
+ constructor(coders: Array<Coder>, localName: string);
10
+ defaultValue(): any;
11
+ encode(writer: Writer, _value: Array<any> | {
12
+ [name: string]: any;
13
+ } | Typed): number;
14
+ decode(reader: Reader): any;
15
+ }
@@ -0,0 +1,67 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ import { defineProperties } from "../utils/properties.js";
8
+ import { Typed } from "../typed.js";
9
+ import { Coder } from "./abstract-coder.js";
10
+ import { pack, unpack } from "./array.js";
11
+ /**
12
+ * @_ignore
13
+ */
14
+ export class TupleCoder extends Coder {
15
+ constructor(coders, localName) {
16
+ let dynamic = false;
17
+ const types = [];
18
+ coders.forEach((coder) => {
19
+ if (coder.dynamic) {
20
+ dynamic = true;
21
+ }
22
+ types.push(coder.type);
23
+ });
24
+ const type = ("tuple(" + types.join(",") + ")");
25
+ super("tuple", type, localName, dynamic);
26
+ defineProperties(this, { coders: Object.freeze(coders.slice()) });
27
+ }
28
+ defaultValue() {
29
+ const values = [];
30
+ this.coders.forEach((coder) => {
31
+ values.push(coder.defaultValue());
32
+ });
33
+ // We only output named properties for uniquely named coders
34
+ const uniqueNames = this.coders.reduce((accum, coder) => {
35
+ const name = coder.localName;
36
+ if (name) {
37
+ if (!accum[name]) {
38
+ accum[name] = 0;
39
+ }
40
+ accum[name]++;
41
+ }
42
+ return accum;
43
+ }, {});
44
+ // Add named values
45
+ this.coders.forEach((coder, index) => {
46
+ let name = coder.localName;
47
+ if (!name || uniqueNames[name] !== 1) {
48
+ return;
49
+ }
50
+ if (name === "length") {
51
+ name = "_length";
52
+ }
53
+ if (values[name] != null) {
54
+ return;
55
+ }
56
+ values[name] = values[index];
57
+ });
58
+ return Object.freeze(values);
59
+ }
60
+ encode(writer, _value) {
61
+ const value = Typed.dereference(_value, "tuple");
62
+ return pack(writer, this.coders, value);
63
+ }
64
+ decode(reader) {
65
+ return unpack(reader, this.coders);
66
+ }
67
+ }