ccxt 4.3.70 → 4.3.72
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/dist/ccxt.browser.min.js +13 -10
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/paradex.js +9 -0
- package/dist/cjs/src/base/Exchange.js +49 -0
- package/dist/cjs/src/paradex.js +2075 -0
- package/dist/cjs/src/pro/bequant.js +4 -0
- package/dist/cjs/src/pro/paradex.js +365 -0
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/poseidon.js +100 -0
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -0
- package/dist/cjs/src/static_dependencies/scure-starknet/index.js +284 -0
- package/dist/cjs/src/static_dependencies/starknet/constants.js +60 -0
- package/dist/cjs/src/static_dependencies/starknet/types/calldata.js +26 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/abi.js +8 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/index.js +13 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/index.js +56 -0
- package/dist/cjs/src/static_dependencies/starknet/types/typedData.js +19 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/assert.js +15 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +44 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +122 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +137 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/byteArray.js +61 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/cairo.js +218 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/formatter.js +66 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/index.js +281 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/index.js +33 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +37 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +156 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/requestParser.js +250 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/responseParser.js +215 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/tuple.js +112 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/validate.js +206 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/encode.js +58 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +57 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/merkle.js +76 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/num.js +92 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/selector.js +48 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/shortString.js +101 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/typedData.js +334 -0
- package/dist/cjs/src/woo.js +4 -2
- package/examples/js/cli.js +8 -4
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/paradex.d.ts +43 -0
- package/js/src/abstract/paradex.js +11 -0
- package/js/src/base/Exchange.d.ts +7 -0
- package/js/src/base/Exchange.js +45 -0
- package/js/src/base/types.d.ts +10 -10
- package/js/src/paradex.d.ts +76 -0
- package/js/src/paradex.js +2075 -0
- package/js/src/pro/bequant.js +4 -0
- package/js/src/pro/paradex.d.ts +15 -0
- package/js/src/pro/paradex.js +366 -0
- package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +24 -0
- package/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -1
- package/js/src/static_dependencies/scure-starknet/index.d.ts +79 -0
- package/js/src/static_dependencies/scure-starknet/index.js +323 -0
- package/js/src/static_dependencies/starknet/constants.d.ts +61 -0
- package/js/src/static_dependencies/starknet/constants.js +67 -0
- package/js/src/static_dependencies/starknet/index.d.ts +7 -0
- package/js/src/static_dependencies/starknet/index.js +50 -0
- package/js/src/static_dependencies/starknet/types/cairoEnum.d.ts +2 -0
- package/js/src/static_dependencies/starknet/types/cairoEnum.js +7 -0
- package/js/src/static_dependencies/starknet/types/calldata.d.ts +19 -0
- package/js/src/static_dependencies/starknet/types/calldata.js +28 -0
- package/js/src/static_dependencies/starknet/types/index.d.ts +13 -0
- package/js/src/static_dependencies/starknet/types/index.js +16 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/abi.d.ts +71 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/abi.js +13 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/index.d.ts +24 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/index.js +16 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/legacy.d.ts +33 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/legacy.js +7 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/sierra.d.ts +52 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/sierra.js +7 -0
- package/js/src/static_dependencies/starknet/types/lib/index.d.ts +248 -0
- package/js/src/static_dependencies/starknet/types/lib/index.js +52 -0
- package/js/src/static_dependencies/starknet/types/typedData.d.ts +44 -0
- package/js/src/static_dependencies/starknet/types/typedData.js +19 -0
- package/js/src/static_dependencies/starknet/utils/address.d.ts +53 -0
- package/js/src/static_dependencies/starknet/utils/address.js +89 -0
- package/js/src/static_dependencies/starknet/utils/assert.d.ts +7 -0
- package/js/src/static_dependencies/starknet/utils/assert.js +17 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +43 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.d.ts +72 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +117 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.d.ts +76 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +136 -0
- package/js/src/static_dependencies/starknet/utils/calldata/byteArray.d.ts +32 -0
- package/js/src/static_dependencies/starknet/utils/calldata/byteArray.js +59 -0
- package/js/src/static_dependencies/starknet/utils/calldata/cairo.d.ts +183 -0
- package/js/src/static_dependencies/starknet/utils/calldata/cairo.js +229 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.d.ts +35 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.d.ts +34 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/index.d.ts +3 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/index.js +9 -0
- package/js/src/static_dependencies/starknet/utils/calldata/formatter.d.ts +9 -0
- package/js/src/static_dependencies/starknet/utils/calldata/formatter.js +67 -0
- package/js/src/static_dependencies/starknet/utils/calldata/index.d.ts +89 -0
- package/js/src/static_dependencies/starknet/utils/calldata/index.js +280 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.js +30 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.d.ts +20 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.js +8 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +36 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
- package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.d.ts +2 -0
- package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +155 -0
- package/js/src/static_dependencies/starknet/utils/calldata/requestParser.d.ts +11 -0
- package/js/src/static_dependencies/starknet/utils/calldata/requestParser.js +248 -0
- package/js/src/static_dependencies/starknet/utils/calldata/responseParser.d.ts +11 -0
- package/js/src/static_dependencies/starknet/utils/calldata/responseParser.js +214 -0
- package/js/src/static_dependencies/starknet/utils/calldata/tuple.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/tuple.js +113 -0
- package/js/src/static_dependencies/starknet/utils/calldata/validate.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/validate.js +208 -0
- package/js/src/static_dependencies/starknet/utils/encode.d.ts +207 -0
- package/js/src/static_dependencies/starknet/utils/encode.js +282 -0
- package/js/src/static_dependencies/starknet/utils/hash/classHash.d.ts +57 -0
- package/js/src/static_dependencies/starknet/utils/hash/classHash.js +224 -0
- package/js/src/static_dependencies/starknet/utils/hash/index.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/hash/index.js +13 -0
- package/js/src/static_dependencies/starknet/utils/json.d.ts +24 -0
- package/js/src/static_dependencies/starknet/utils/json.js +43 -0
- package/js/src/static_dependencies/starknet/utils/merkle.d.ts +35 -0
- package/js/src/static_dependencies/starknet/utils/merkle.js +84 -0
- package/js/src/static_dependencies/starknet/utils/num.d.ts +182 -0
- package/js/src/static_dependencies/starknet/utils/num.js +244 -0
- package/js/src/static_dependencies/starknet/utils/selector.d.ts +48 -0
- package/js/src/static_dependencies/starknet/utils/selector.js +85 -0
- package/js/src/static_dependencies/starknet/utils/shortString.d.ts +57 -0
- package/js/src/static_dependencies/starknet/utils/shortString.js +96 -0
- package/js/src/static_dependencies/starknet/utils/starknetId.d.ts +113 -0
- package/js/src/static_dependencies/starknet/utils/starknetId.js +265 -0
- package/js/src/static_dependencies/starknet/utils/typedData.d.ts +54 -0
- package/js/src/static_dependencies/starknet/utils/typedData.js +321 -0
- package/js/src/static_dependencies/starknet/utils/uint256.d.ts +21 -0
- package/js/src/static_dependencies/starknet/utils/uint256.js +32 -0
- package/js/src/static_dependencies/starknet/utils/url.d.ts +29 -0
- package/js/src/static_dependencies/starknet/utils/url.js +70 -0
- package/js/src/woo.js +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var constants = require('../constants.js');
|
|
6
|
+
require('../types/calldata.js');
|
|
7
|
+
require('../types/lib/index.js');
|
|
8
|
+
var typedData = require('../types/typedData.js');
|
|
9
|
+
var assert = require('./assert.js');
|
|
10
|
+
var byteArray = require('./calldata/byteArray.js');
|
|
11
|
+
require('../../noble-curves/abstract/modular.js');
|
|
12
|
+
var selector = require('./selector.js');
|
|
13
|
+
var classHash = require('./hash/classHash.js');
|
|
14
|
+
var merkle = require('./merkle.js');
|
|
15
|
+
var num = require('./num.js');
|
|
16
|
+
var shortString = require('./shortString.js');
|
|
17
|
+
|
|
18
|
+
/* eslint-disable no-param-reassign */
|
|
19
|
+
const presetTypes = {
|
|
20
|
+
u256: JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),
|
|
21
|
+
TokenAmount: JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),
|
|
22
|
+
NftId: JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]'),
|
|
23
|
+
};
|
|
24
|
+
const revisionConfiguration = {
|
|
25
|
+
[typedData.TypedDataRevision.Active]: {
|
|
26
|
+
domain: 'StarknetDomain',
|
|
27
|
+
hashMethod: classHash.computePoseidonHashOnElements,
|
|
28
|
+
hashMerkleMethod: classHash.computePoseidonHash,
|
|
29
|
+
escapeTypeString: (s) => `"${s}"`,
|
|
30
|
+
presetTypes,
|
|
31
|
+
},
|
|
32
|
+
[typedData.TypedDataRevision.Legacy]: {
|
|
33
|
+
domain: 'StarkNetDomain',
|
|
34
|
+
hashMethod: classHash.computePedersenHashOnElements,
|
|
35
|
+
hashMerkleMethod: classHash.computePedersenHash,
|
|
36
|
+
escapeTypeString: (s) => s,
|
|
37
|
+
presetTypes: {},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
function assertRange(data, type, { min, max }) {
|
|
41
|
+
const value = BigInt(data);
|
|
42
|
+
assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
43
|
+
}
|
|
44
|
+
function identifyRevision({ types, domain }) {
|
|
45
|
+
if (revisionConfiguration[typedData.TypedDataRevision.Active].domain in types && domain.revision === typedData.TypedDataRevision.Active)
|
|
46
|
+
return typedData.TypedDataRevision.Active;
|
|
47
|
+
if (revisionConfiguration[typedData.TypedDataRevision.Legacy].domain in types &&
|
|
48
|
+
(domain.revision ?? typedData.TypedDataRevision.Legacy) === typedData.TypedDataRevision.Legacy)
|
|
49
|
+
return typedData.TypedDataRevision.Legacy;
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
function getHex(value) {
|
|
53
|
+
try {
|
|
54
|
+
return num.toHex(value);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
if (shortString.isString(value)) {
|
|
58
|
+
return num.toHex(shortString.encodeShortString(value));
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`Invalid BigNumberish: ${value}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Validates that `data` matches the EIP-712 JSON schema.
|
|
65
|
+
*/
|
|
66
|
+
function validateTypedData(data) {
|
|
67
|
+
const typedData = data;
|
|
68
|
+
return Boolean(typedData.message && typedData.primaryType && typedData.types && identifyRevision(typedData));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Prepares the selector for use.
|
|
72
|
+
*
|
|
73
|
+
* @param {string} selector - The selector to be prepared.
|
|
74
|
+
* @returns {string} The prepared selector.
|
|
75
|
+
*/
|
|
76
|
+
function prepareSelector(selector$1) {
|
|
77
|
+
return num.isHex(selector$1) ? selector$1 : selector.getSelectorFromName(selector$1);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Checks if the given Starknet type is a Merkle tree type.
|
|
81
|
+
*
|
|
82
|
+
* @param {StarknetType} type - The StarkNet type to check.
|
|
83
|
+
*
|
|
84
|
+
* @returns {boolean} - True if the type is a Merkle tree type, false otherwise.
|
|
85
|
+
*/
|
|
86
|
+
function isMerkleTreeType(type) {
|
|
87
|
+
return type.type === 'merkletree';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the dependencies of a struct type. If a struct has the same dependency multiple times, it's only included once
|
|
91
|
+
* in the resulting array.
|
|
92
|
+
*/
|
|
93
|
+
function getDependencies(types, type, dependencies = [], contains = '', revision = typedData.TypedDataRevision.Legacy) {
|
|
94
|
+
// Include pointers (struct arrays)
|
|
95
|
+
if (type[type.length - 1] === '*') {
|
|
96
|
+
type = type.slice(0, -1);
|
|
97
|
+
}
|
|
98
|
+
else if (revision === typedData.TypedDataRevision.Active) {
|
|
99
|
+
// enum base
|
|
100
|
+
if (type === 'enum') {
|
|
101
|
+
type = contains;
|
|
102
|
+
}
|
|
103
|
+
// enum element types
|
|
104
|
+
else if (type.match(/^\(.*\)$/)) {
|
|
105
|
+
type = type.slice(1, -1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (dependencies.includes(type) || !types[type]) {
|
|
109
|
+
return dependencies;
|
|
110
|
+
}
|
|
111
|
+
return [
|
|
112
|
+
type,
|
|
113
|
+
...types[type].reduce((previous, t) => [
|
|
114
|
+
...previous,
|
|
115
|
+
...getDependencies(types, t.type, previous, t.contains, revision).filter((dependency) => !previous.includes(dependency)),
|
|
116
|
+
], []),
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
function getMerkleTreeType(types, ctx) {
|
|
120
|
+
if (ctx.parent && ctx.key) {
|
|
121
|
+
const parentType = types[ctx.parent];
|
|
122
|
+
const merkleType = parentType.find((t) => t.name === ctx.key);
|
|
123
|
+
const isMerkleTree = isMerkleTreeType(merkleType);
|
|
124
|
+
if (!isMerkleTree) {
|
|
125
|
+
throw new Error(`${ctx.key} is not a merkle tree`);
|
|
126
|
+
}
|
|
127
|
+
if (merkleType.contains.endsWith('*')) {
|
|
128
|
+
throw new Error(`Merkle tree contain property must not be an array but was given ${ctx.key}`);
|
|
129
|
+
}
|
|
130
|
+
return merkleType.contains;
|
|
131
|
+
}
|
|
132
|
+
return 'raw';
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Encode a type to a string. All dependent types are alphabetically sorted.
|
|
136
|
+
*/
|
|
137
|
+
function encodeType(types, type, revision = typedData.TypedDataRevision.Legacy) {
|
|
138
|
+
const allTypes = revision === typedData.TypedDataRevision.Active
|
|
139
|
+
? { ...types, ...revisionConfiguration[revision].presetTypes }
|
|
140
|
+
: types;
|
|
141
|
+
const [primary, ...dependencies] = getDependencies(allTypes, type, undefined, undefined, revision);
|
|
142
|
+
const newTypes = !primary ? [] : [primary, ...dependencies.sort()];
|
|
143
|
+
const esc = revisionConfiguration[revision].escapeTypeString;
|
|
144
|
+
return newTypes
|
|
145
|
+
.map((dependency) => {
|
|
146
|
+
const dependencyElements = allTypes[dependency].map((t) => {
|
|
147
|
+
const targetType = t.type === 'enum' && revision === typedData.TypedDataRevision.Active
|
|
148
|
+
? t.contains
|
|
149
|
+
: t.type;
|
|
150
|
+
// parentheses handling for enum variant types
|
|
151
|
+
const typeString = targetType.match(/^\(.*\)$/)
|
|
152
|
+
? `(${targetType
|
|
153
|
+
.slice(1, -1)
|
|
154
|
+
.split(',')
|
|
155
|
+
.map((e) => (e ? esc(e) : e))
|
|
156
|
+
.join(',')})`
|
|
157
|
+
: esc(targetType);
|
|
158
|
+
return `${esc(t.name)}:${typeString}`;
|
|
159
|
+
});
|
|
160
|
+
return `${esc(dependency)}(${dependencyElements})`;
|
|
161
|
+
})
|
|
162
|
+
.join('');
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get a type string as hash.
|
|
166
|
+
*/
|
|
167
|
+
function getTypeHash(types, type, revision = typedData.TypedDataRevision.Legacy) {
|
|
168
|
+
return selector.getSelectorFromName(encodeType(types, type, revision));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Encodes a single value to an ABI serialisable string, number or Buffer. Returns the data as tuple, which consists of
|
|
172
|
+
* an array of ABI compatible types, and an array of corresponding values.
|
|
173
|
+
*/
|
|
174
|
+
function encodeValue(types, type, data, ctx = {}, revision = typedData.TypedDataRevision.Legacy) {
|
|
175
|
+
if (types[type]) {
|
|
176
|
+
return [type, getStructHash(types, type, data, revision)];
|
|
177
|
+
}
|
|
178
|
+
if (revisionConfiguration[revision].presetTypes[type]) {
|
|
179
|
+
return [
|
|
180
|
+
type,
|
|
181
|
+
getStructHash(revisionConfiguration[revision].presetTypes, type, data, revision),
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
if (type.endsWith('*')) {
|
|
185
|
+
const hashes = data.map((entry) => encodeValue(types, type.slice(0, -1), entry, undefined, revision)[1]);
|
|
186
|
+
return [type, revisionConfiguration[revision].hashMethod(hashes)];
|
|
187
|
+
}
|
|
188
|
+
switch (type) {
|
|
189
|
+
case 'enum': {
|
|
190
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
191
|
+
const [variantKey, variantData] = Object.entries(data)[0];
|
|
192
|
+
const parentType = types[ctx.parent][0];
|
|
193
|
+
const enumType = types[parentType.contains];
|
|
194
|
+
const variantType = enumType.find((t) => t.name === variantKey);
|
|
195
|
+
const variantIndex = enumType.indexOf(variantType);
|
|
196
|
+
const encodedSubtypes = variantType.type
|
|
197
|
+
.slice(1, -1)
|
|
198
|
+
.split(',')
|
|
199
|
+
.map((subtype, index) => {
|
|
200
|
+
if (!subtype)
|
|
201
|
+
return subtype;
|
|
202
|
+
const subtypeData = variantData[index];
|
|
203
|
+
return encodeValue(types, subtype, subtypeData, undefined, revision)[1];
|
|
204
|
+
});
|
|
205
|
+
return [
|
|
206
|
+
type,
|
|
207
|
+
revisionConfiguration[revision].hashMethod([variantIndex, ...encodedSubtypes]),
|
|
208
|
+
];
|
|
209
|
+
} // else fall through to default
|
|
210
|
+
return [type, getHex(data)];
|
|
211
|
+
}
|
|
212
|
+
case 'merkletree': {
|
|
213
|
+
const merkleTreeType = getMerkleTreeType(types, ctx);
|
|
214
|
+
const structHashes = data.map((struct) => {
|
|
215
|
+
return encodeValue(types, merkleTreeType, struct, undefined, revision)[1];
|
|
216
|
+
});
|
|
217
|
+
const { root } = new merkle.MerkleTree(structHashes, revisionConfiguration[revision].hashMerkleMethod);
|
|
218
|
+
return ['felt', root];
|
|
219
|
+
}
|
|
220
|
+
case 'selector': {
|
|
221
|
+
return ['felt', prepareSelector(data)];
|
|
222
|
+
}
|
|
223
|
+
case 'string': {
|
|
224
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
225
|
+
const byteArray$1 = byteArray.byteArrayFromString(data);
|
|
226
|
+
const elements = [
|
|
227
|
+
byteArray$1.data.length,
|
|
228
|
+
...byteArray$1.data,
|
|
229
|
+
byteArray$1.pending_word,
|
|
230
|
+
byteArray$1.pending_word_len,
|
|
231
|
+
];
|
|
232
|
+
return [type, revisionConfiguration[revision].hashMethod(elements)];
|
|
233
|
+
} // else fall through to default
|
|
234
|
+
return [type, getHex(data)];
|
|
235
|
+
}
|
|
236
|
+
case 'i128': {
|
|
237
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
238
|
+
const value = BigInt(data);
|
|
239
|
+
assertRange(value, type, constants.RANGE_I128);
|
|
240
|
+
return [type, getHex(value < 0n ? constants.PRIME + value : value)];
|
|
241
|
+
} // else fall through to default
|
|
242
|
+
return [type, getHex(data)];
|
|
243
|
+
}
|
|
244
|
+
case 'timestamp':
|
|
245
|
+
case 'u128': {
|
|
246
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
247
|
+
assertRange(data, type, constants.RANGE_U128);
|
|
248
|
+
} // else fall through to default
|
|
249
|
+
return [type, getHex(data)];
|
|
250
|
+
}
|
|
251
|
+
case 'felt':
|
|
252
|
+
case 'shortstring': {
|
|
253
|
+
// TODO: should 'shortstring' diverge into directly using encodeShortString()?
|
|
254
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
255
|
+
assertRange(getHex(data), type, constants.RANGE_FELT);
|
|
256
|
+
} // else fall through to default
|
|
257
|
+
return [type, getHex(data)];
|
|
258
|
+
}
|
|
259
|
+
case 'ClassHash':
|
|
260
|
+
case 'ContractAddress': {
|
|
261
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
262
|
+
assertRange(data, type, constants.RANGE_FELT);
|
|
263
|
+
} // else fall through to default
|
|
264
|
+
return [type, getHex(data)];
|
|
265
|
+
}
|
|
266
|
+
case 'bool': {
|
|
267
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
268
|
+
assert(typeof data === 'boolean', `Type mismatch for ${type} ${data}`);
|
|
269
|
+
} // else fall through to default
|
|
270
|
+
return [type, getHex(data)];
|
|
271
|
+
}
|
|
272
|
+
default: {
|
|
273
|
+
if (revision === typedData.TypedDataRevision.Active) {
|
|
274
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
275
|
+
}
|
|
276
|
+
return [type, getHex(data)];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Encode the data to an ABI encoded Buffer. The data should be a key -> value object with all the required values.
|
|
282
|
+
* All dependent types are automatically encoded.
|
|
283
|
+
*/
|
|
284
|
+
function encodeData(types, type, data, revision = typedData.TypedDataRevision.Legacy) {
|
|
285
|
+
const targetType = types[type] ?? revisionConfiguration[revision].presetTypes[type];
|
|
286
|
+
const [returnTypes, values] = targetType.reduce(([ts, vs], field) => {
|
|
287
|
+
if (data[field.name] === undefined ||
|
|
288
|
+
(data[field.name] === null && field.type !== 'enum')) {
|
|
289
|
+
throw new Error(`Cannot encode data: missing data for '${field.name}'`);
|
|
290
|
+
}
|
|
291
|
+
const value = data[field.name];
|
|
292
|
+
const ctx = { parent: type, key: field.name };
|
|
293
|
+
const [t, encodedValue] = encodeValue(types, field.type, value, ctx, revision);
|
|
294
|
+
return [
|
|
295
|
+
[...ts, t],
|
|
296
|
+
[...vs, encodedValue],
|
|
297
|
+
];
|
|
298
|
+
}, [['felt'], [getTypeHash(types, type, revision)]]);
|
|
299
|
+
return [returnTypes, values];
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get encoded data as a hash. The data should be a key -> value object with all the required values.
|
|
303
|
+
* All dependent types are automatically encoded.
|
|
304
|
+
*/
|
|
305
|
+
function getStructHash(types, type, data, revision = typedData.TypedDataRevision.Legacy) {
|
|
306
|
+
return revisionConfiguration[revision].hashMethod(encodeData(types, type, data, revision)[1]);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Get the SNIP-12 encoded message to sign, from the typedData object.
|
|
310
|
+
*/
|
|
311
|
+
function getMessageHash(typedData, account) {
|
|
312
|
+
if (!validateTypedData(typedData)) {
|
|
313
|
+
throw new Error('Typed data does not match JSON schema');
|
|
314
|
+
}
|
|
315
|
+
const revision = identifyRevision(typedData);
|
|
316
|
+
const { domain, hashMethod } = revisionConfiguration[revision];
|
|
317
|
+
const message = [
|
|
318
|
+
shortString.encodeShortString('StarkNet Message'),
|
|
319
|
+
getStructHash(typedData.types, domain, typedData.domain, revision),
|
|
320
|
+
account,
|
|
321
|
+
getStructHash(typedData.types, typedData.primaryType, typedData.message, revision),
|
|
322
|
+
];
|
|
323
|
+
return hashMethod(message);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
exports.encodeData = encodeData;
|
|
327
|
+
exports.encodeType = encodeType;
|
|
328
|
+
exports.encodeValue = encodeValue;
|
|
329
|
+
exports.getDependencies = getDependencies;
|
|
330
|
+
exports.getMessageHash = getMessageHash;
|
|
331
|
+
exports.getStructHash = getStructHash;
|
|
332
|
+
exports.getTypeHash = getTypeHash;
|
|
333
|
+
exports.isMerkleTreeType = isMerkleTreeType;
|
|
334
|
+
exports.prepareSelector = prepareSelector;
|
package/dist/cjs/src/woo.js
CHANGED
|
@@ -2654,11 +2654,13 @@ class woo extends woo$1 {
|
|
|
2654
2654
|
//
|
|
2655
2655
|
const marketId = this.safeString(income, 'symbol');
|
|
2656
2656
|
const symbol = this.safeSymbol(marketId, market);
|
|
2657
|
-
|
|
2657
|
+
let amount = this.safeString(income, 'funding_fee');
|
|
2658
2658
|
const code = this.safeCurrencyCode('USD');
|
|
2659
2659
|
const id = this.safeString(income, 'id');
|
|
2660
2660
|
const timestamp = this.safeTimestamp(income, 'updated_time');
|
|
2661
2661
|
const rate = this.safeNumber(income, 'funding_rate');
|
|
2662
|
+
const paymentType = this.safeString(income, 'payment_type');
|
|
2663
|
+
amount = (paymentType === 'Pay') ? Precise["default"].stringNeg(amount) : amount;
|
|
2662
2664
|
return {
|
|
2663
2665
|
'info': income,
|
|
2664
2666
|
'symbol': symbol,
|
|
@@ -2666,7 +2668,7 @@ class woo extends woo$1 {
|
|
|
2666
2668
|
'timestamp': timestamp,
|
|
2667
2669
|
'datetime': this.iso8601(timestamp),
|
|
2668
2670
|
'id': id,
|
|
2669
|
-
'amount': amount,
|
|
2671
|
+
'amount': this.parseNumber(amount),
|
|
2670
2672
|
'rate': rate,
|
|
2671
2673
|
};
|
|
2672
2674
|
}
|
package/examples/js/cli.js
CHANGED
|
@@ -374,10 +374,14 @@ async function run () {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
if (debug) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
377
|
+
if (httpsAgent.freeSockets) {
|
|
378
|
+
const keys = Object.keys (httpsAgent.freeSockets)
|
|
379
|
+
if (keys.length) {
|
|
380
|
+
const firstKey = keys[0]
|
|
381
|
+
let httpAgent = httpsAgent.freeSockets[firstKey];
|
|
382
|
+
log (firstKey, httpAgent.length)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
381
385
|
}
|
|
382
386
|
|
|
383
387
|
if (!poll && !isWsMethod){
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.3.
|
|
7
|
+
declare const version = "4.3.71";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
|
@@ -94,6 +94,7 @@ import okx from './src/okx.js';
|
|
|
94
94
|
import onetrading from './src/onetrading.js';
|
|
95
95
|
import oxfun from './src/oxfun.js';
|
|
96
96
|
import p2b from './src/p2b.js';
|
|
97
|
+
import paradex from './src/paradex.js';
|
|
97
98
|
import paymium from './src/paymium.js';
|
|
98
99
|
import phemex from './src/phemex.js';
|
|
99
100
|
import poloniex from './src/poloniex.js';
|
|
@@ -171,6 +172,7 @@ import okxPro from './src/pro/okx.js';
|
|
|
171
172
|
import onetradingPro from './src/pro/onetrading.js';
|
|
172
173
|
import oxfunPro from './src/pro/oxfun.js';
|
|
173
174
|
import p2bPro from './src/pro/p2b.js';
|
|
175
|
+
import paradexPro from './src/pro/paradex.js';
|
|
174
176
|
import phemexPro from './src/pro/phemex.js';
|
|
175
177
|
import poloniexPro from './src/pro/poloniex.js';
|
|
176
178
|
import poloniexfuturesPro from './src/pro/poloniexfutures.js';
|
|
@@ -272,6 +274,7 @@ declare const exchanges: {
|
|
|
272
274
|
onetrading: typeof onetrading;
|
|
273
275
|
oxfun: typeof oxfun;
|
|
274
276
|
p2b: typeof p2b;
|
|
277
|
+
paradex: typeof paradex;
|
|
275
278
|
paymium: typeof paymium;
|
|
276
279
|
phemex: typeof phemex;
|
|
277
280
|
poloniex: typeof poloniex;
|
|
@@ -351,6 +354,7 @@ declare const pro: {
|
|
|
351
354
|
onetrading: typeof onetradingPro;
|
|
352
355
|
oxfun: typeof oxfunPro;
|
|
353
356
|
p2b: typeof p2bPro;
|
|
357
|
+
paradex: typeof paradexPro;
|
|
354
358
|
phemex: typeof phemexPro;
|
|
355
359
|
poloniex: typeof poloniexPro;
|
|
356
360
|
poloniexfutures: typeof poloniexfuturesPro;
|
|
@@ -427,6 +431,7 @@ declare const ccxt: {
|
|
|
427
431
|
onetrading: typeof onetradingPro;
|
|
428
432
|
oxfun: typeof oxfunPro;
|
|
429
433
|
p2b: typeof p2bPro;
|
|
434
|
+
paradex: typeof paradexPro;
|
|
430
435
|
phemex: typeof phemexPro;
|
|
431
436
|
poloniex: typeof poloniexPro;
|
|
432
437
|
poloniexfutures: typeof poloniexfuturesPro;
|
|
@@ -529,6 +534,7 @@ declare const ccxt: {
|
|
|
529
534
|
onetrading: typeof onetrading;
|
|
530
535
|
oxfun: typeof oxfun;
|
|
531
536
|
p2b: typeof p2b;
|
|
537
|
+
paradex: typeof paradex;
|
|
532
538
|
paymium: typeof paymium;
|
|
533
539
|
phemex: typeof phemex;
|
|
534
540
|
poloniex: typeof poloniex;
|
|
@@ -549,5 +555,5 @@ declare const ccxt: {
|
|
|
549
555
|
zaif: typeof zaif;
|
|
550
556
|
zonda: typeof zonda;
|
|
551
557
|
} & typeof functions & typeof errors;
|
|
552
|
-
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
|
|
558
|
+
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
|
|
553
559
|
export default ccxt;
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.3.
|
|
41
|
+
const version = '4.3.72';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -130,6 +130,7 @@ import okx from './src/okx.js';
|
|
|
130
130
|
import onetrading from './src/onetrading.js';
|
|
131
131
|
import oxfun from './src/oxfun.js';
|
|
132
132
|
import p2b from './src/p2b.js';
|
|
133
|
+
import paradex from './src/paradex.js';
|
|
133
134
|
import paymium from './src/paymium.js';
|
|
134
135
|
import phemex from './src/phemex.js';
|
|
135
136
|
import poloniex from './src/poloniex.js';
|
|
@@ -208,6 +209,7 @@ import okxPro from './src/pro/okx.js';
|
|
|
208
209
|
import onetradingPro from './src/pro/onetrading.js';
|
|
209
210
|
import oxfunPro from './src/pro/oxfun.js';
|
|
210
211
|
import p2bPro from './src/pro/p2b.js';
|
|
212
|
+
import paradexPro from './src/pro/paradex.js';
|
|
211
213
|
import phemexPro from './src/pro/phemex.js';
|
|
212
214
|
import poloniexPro from './src/pro/poloniex.js';
|
|
213
215
|
import poloniexfuturesPro from './src/pro/poloniexfutures.js';
|
|
@@ -309,6 +311,7 @@ const exchanges = {
|
|
|
309
311
|
'onetrading': onetrading,
|
|
310
312
|
'oxfun': oxfun,
|
|
311
313
|
'p2b': p2b,
|
|
314
|
+
'paradex': paradex,
|
|
312
315
|
'paymium': paymium,
|
|
313
316
|
'phemex': phemex,
|
|
314
317
|
'poloniex': poloniex,
|
|
@@ -388,6 +391,7 @@ const pro = {
|
|
|
388
391
|
'onetrading': onetradingPro,
|
|
389
392
|
'oxfun': oxfunPro,
|
|
390
393
|
'p2b': p2bPro,
|
|
394
|
+
'paradex': paradexPro,
|
|
391
395
|
'phemex': phemexPro,
|
|
392
396
|
'poloniex': poloniexPro,
|
|
393
397
|
'poloniexfutures': poloniexfuturesPro,
|
|
@@ -412,6 +416,6 @@ pro.exchanges = Object.keys(pro);
|
|
|
412
416
|
pro['Exchange'] = Exchange; // now the same for rest and ts
|
|
413
417
|
//-----------------------------------------------------------------------------
|
|
414
418
|
const ccxt = Object.assign({ version, Exchange, Precise, 'exchanges': Object.keys(exchanges), 'pro': pro }, exchanges, functions, errors);
|
|
415
|
-
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
|
|
419
|
+
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
|
|
416
420
|
export default ccxt;
|
|
417
421
|
//-----------------------------------------------------------------------------
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { implicitReturnType } from '../base/types.js';
|
|
2
|
+
import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
3
|
+
interface Exchange {
|
|
4
|
+
publicGetBboMarket(params?: {}): Promise<implicitReturnType>;
|
|
5
|
+
publicGetFundingData(params?: {}): Promise<implicitReturnType>;
|
|
6
|
+
publicGetMarkets(params?: {}): Promise<implicitReturnType>;
|
|
7
|
+
publicGetMarketsKlines(params?: {}): Promise<implicitReturnType>;
|
|
8
|
+
publicGetMarketsSummary(params?: {}): Promise<implicitReturnType>;
|
|
9
|
+
publicGetOrderbookMarket(params?: {}): Promise<implicitReturnType>;
|
|
10
|
+
publicGetInsurance(params?: {}): Promise<implicitReturnType>;
|
|
11
|
+
publicGetReferralsConfig(params?: {}): Promise<implicitReturnType>;
|
|
12
|
+
publicGetSystemConfig(params?: {}): Promise<implicitReturnType>;
|
|
13
|
+
publicGetSystemState(params?: {}): Promise<implicitReturnType>;
|
|
14
|
+
publicGetSystemTime(params?: {}): Promise<implicitReturnType>;
|
|
15
|
+
publicGetTrades(params?: {}): Promise<implicitReturnType>;
|
|
16
|
+
privateGetAccount(params?: {}): Promise<implicitReturnType>;
|
|
17
|
+
privateGetAccountProfile(params?: {}): Promise<implicitReturnType>;
|
|
18
|
+
privateGetBalance(params?: {}): Promise<implicitReturnType>;
|
|
19
|
+
privateGetFills(params?: {}): Promise<implicitReturnType>;
|
|
20
|
+
privateGetFundingPayments(params?: {}): Promise<implicitReturnType>;
|
|
21
|
+
privateGetPositions(params?: {}): Promise<implicitReturnType>;
|
|
22
|
+
privateGetTradebusts(params?: {}): Promise<implicitReturnType>;
|
|
23
|
+
privateGetTransactions(params?: {}): Promise<implicitReturnType>;
|
|
24
|
+
privateGetLiquidations(params?: {}): Promise<implicitReturnType>;
|
|
25
|
+
privateGetOrders(params?: {}): Promise<implicitReturnType>;
|
|
26
|
+
privateGetOrdersHistory(params?: {}): Promise<implicitReturnType>;
|
|
27
|
+
privateGetOrdersByClientIdClientId(params?: {}): Promise<implicitReturnType>;
|
|
28
|
+
privateGetOrdersOrderId(params?: {}): Promise<implicitReturnType>;
|
|
29
|
+
privateGetPointsDataMarketProgram(params?: {}): Promise<implicitReturnType>;
|
|
30
|
+
privateGetReferralsSummary(params?: {}): Promise<implicitReturnType>;
|
|
31
|
+
privateGetTransfers(params?: {}): Promise<implicitReturnType>;
|
|
32
|
+
privatePostAccountProfileReferralCode(params?: {}): Promise<implicitReturnType>;
|
|
33
|
+
privatePostAccountProfileUsername(params?: {}): Promise<implicitReturnType>;
|
|
34
|
+
privatePostAuth(params?: {}): Promise<implicitReturnType>;
|
|
35
|
+
privatePostOnboarding(params?: {}): Promise<implicitReturnType>;
|
|
36
|
+
privatePostOrders(params?: {}): Promise<implicitReturnType>;
|
|
37
|
+
privateDeleteOrders(params?: {}): Promise<implicitReturnType>;
|
|
38
|
+
privateDeleteOrdersByClientIdClientId(params?: {}): Promise<implicitReturnType>;
|
|
39
|
+
privateDeleteOrdersOrderId(params?: {}): Promise<implicitReturnType>;
|
|
40
|
+
}
|
|
41
|
+
declare abstract class Exchange extends _Exchange {
|
|
42
|
+
}
|
|
43
|
+
export default Exchange;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
// -------------------------------------------------------------------------------
|
|
8
|
+
import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
9
|
+
class Exchange extends _Exchange {
|
|
10
|
+
}
|
|
11
|
+
export default Exchange;
|
|
@@ -369,6 +369,13 @@ export default class Exchange {
|
|
|
369
369
|
fixStringifiedJsonMembers(content: string): any;
|
|
370
370
|
ethAbiEncode(types: any, args: any): Uint8Array;
|
|
371
371
|
ethEncodeStructuredData(domain: any, messageTypes: any, messageData: any): Uint8Array;
|
|
372
|
+
retrieveStarkAccount(signature: any, accountClassHash: any, accountProxyClassHash: any): {
|
|
373
|
+
privateKey: string;
|
|
374
|
+
publicKey: string;
|
|
375
|
+
address: string;
|
|
376
|
+
};
|
|
377
|
+
starknetEncodeStructuredData(domain: any, messageTypes: any, messageData: any, address: any): string;
|
|
378
|
+
starknetSign(hash: any, pri: any): string;
|
|
372
379
|
intToBase16(elem: any): string;
|
|
373
380
|
extendExchangeOptions(newOptions: Dict): void;
|
|
374
381
|
createSafeDictionary(): {};
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -24,6 +24,8 @@ import totp from './functions/totp.js';
|
|
|
24
24
|
import ethers from '../static_dependencies/ethers/index.js';
|
|
25
25
|
import { TypedDataEncoder } from '../static_dependencies/ethers/hash/index.js';
|
|
26
26
|
import { SecureRandom } from "../static_dependencies/jsencrypt/lib/jsbn/rng.js";
|
|
27
|
+
import { getStarkKey, ethSigToPrivate, sign as starknetCurveSign } from '../static_dependencies/scure-starknet/index.js';
|
|
28
|
+
import * as Starknet from '../static_dependencies/starknet/index.js';
|
|
27
29
|
// ----------------------------------------------------------------------------
|
|
28
30
|
/**
|
|
29
31
|
* @class Exchange
|
|
@@ -1169,6 +1171,49 @@ export default class Exchange {
|
|
|
1169
1171
|
ethEncodeStructuredData(domain, messageTypes, messageData) {
|
|
1170
1172
|
return this.base16ToBinary(TypedDataEncoder.encode(domain, messageTypes, messageData).slice(-132));
|
|
1171
1173
|
}
|
|
1174
|
+
retrieveStarkAccount(signature, accountClassHash, accountProxyClassHash) {
|
|
1175
|
+
const privateKey = ethSigToPrivate(signature);
|
|
1176
|
+
const publicKey = getStarkKey(privateKey);
|
|
1177
|
+
const callData = Starknet.CallData.compile({
|
|
1178
|
+
implementation: accountClassHash,
|
|
1179
|
+
selector: Starknet.hash.getSelectorFromName('initialize'),
|
|
1180
|
+
calldata: Starknet.CallData.compile({
|
|
1181
|
+
signer: publicKey,
|
|
1182
|
+
guardian: '0',
|
|
1183
|
+
}),
|
|
1184
|
+
});
|
|
1185
|
+
const address = Starknet.hash.calculateContractAddressFromHash(publicKey, accountProxyClassHash, callData, 0);
|
|
1186
|
+
return {
|
|
1187
|
+
privateKey,
|
|
1188
|
+
publicKey,
|
|
1189
|
+
address
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
starknetEncodeStructuredData(domain, messageTypes, messageData, address) {
|
|
1193
|
+
const types = Object.keys(messageTypes);
|
|
1194
|
+
if (types.length > 1) {
|
|
1195
|
+
throw new NotSupported(this.id + 'starknetEncodeStructuredData only support single type');
|
|
1196
|
+
}
|
|
1197
|
+
const request = {
|
|
1198
|
+
'domain': domain,
|
|
1199
|
+
'primaryType': types[0],
|
|
1200
|
+
'types': this.extend({
|
|
1201
|
+
'StarkNetDomain': [
|
|
1202
|
+
{ 'name': "name", 'type': "felt" },
|
|
1203
|
+
{ 'name': "chainId", 'type': "felt" },
|
|
1204
|
+
{ 'name': "version", 'type': "felt" },
|
|
1205
|
+
],
|
|
1206
|
+
}, messageTypes),
|
|
1207
|
+
'message': messageData,
|
|
1208
|
+
};
|
|
1209
|
+
const msgHash = Starknet.typedData.getMessageHash(request, address);
|
|
1210
|
+
return msgHash;
|
|
1211
|
+
}
|
|
1212
|
+
starknetSign(hash, pri) {
|
|
1213
|
+
// TODO: unify to ecdsa
|
|
1214
|
+
const signature = starknetCurveSign(hash.replace('0x', ''), pri.slice(-64));
|
|
1215
|
+
return this.json([signature.r.toString(), signature.s.toString()]);
|
|
1216
|
+
}
|
|
1172
1217
|
intToBase16(elem) {
|
|
1173
1218
|
return elem.toString(16);
|
|
1174
1219
|
}
|