Skip to content

Commit 45e8a0d

Browse files
authored
Merge pull request #583 from ZIMkaRU/bugfix/fix-ws-transport-to-support-new-rest-api-signature
Fix ws transport to support new rest api signature
2 parents 08a085a + df7889b commit 45e8a0d

File tree

11 files changed

+363
-128
lines changed

11 files changed

+363
-128
lines changed

CHANGELOG

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
6.0.0
22
- removed unused deps: chai, request-promise, request, crc-32
33
- removed bluebird Promise
4-
- bumped bfx-api-node-rest version up to 5.1.0, breaks previous versions compatibility
4+
- update params of submitOrder and cancelOrders methods of WS transport to support new rest api signature
5+
- bumped bfx-api-node-rest version up to 5.1.1, breaks previous versions compatibility
56
- bumped mocha, jsdoc-to-markdown, docdash, blessed-contrib, ws versions to fix vulnerabilities
67
- moved dev deps readline-promise, blessed, blessed-contrib, cli-table3, p-iteration into corresponding section
78

docs/WS2Manager.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5111,7 +5111,7 @@ <h5 class="h5-returns">Returns:</h5>
51115111
<br class="clear">
51125112

51135113
<footer>
5114-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 11 2023 15:44:15 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
5114+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue May 30 2023 11:56:58 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
51155115
</footer>
51165116

51175117
<script>prettyPrint();</script>

docs/WSv2.html

Lines changed: 333 additions & 109 deletions
Large diffs are not rendered by default.

docs/global.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ <h5 class="h5-types">Type:</h5>
497497
<br class="clear">
498498

499499
<footer>
500-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 11 2023 15:44:15 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
500+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue May 30 2023 11:56:58 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
501501
</footer>
502502

503503
<script>prettyPrint();</script>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ <h3>Contributing</h3>
239239
<br class="clear">
240240

241241
<footer>
242-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 11 2023 15:44:15 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
242+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue May 30 2023 11:56:58 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
243243
</footer>
244244

245245
<script>prettyPrint();</script>

docs/transports_ws2.js.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,8 @@ <h1 class="page-title">transports/ws2.js</h1>
19291929
* @see WSv2#cancelOrder
19301930
* @see WSv2#updateOrder
19311931
*
1932-
* @param {object|Array} order - order object model or array
1932+
* @param {object|Array} params - parameters or order object model or array
1933+
* @param {object|Array} params.order - order object model or array
19331934
* @returns {Promise} p - resolves on submit notification
19341935
* @example
19351936
* const o = new Order({
@@ -1944,11 +1945,12 @@ <h1 class="page-title">transports/ws2.js</h1>
19441945
*
19451946
* console.log('order confirmed! status: %s', o.status)
19461947
*/
1947-
async submitOrder (order) {
1948+
async submitOrder (params) {
19481949
if (!this._isAuthenticated) {
19491950
throw new Error('not authenticated')
19501951
}
19511952

1953+
const order = params?.order ?? params
19521954
const packet = Array.isArray(order)
19531955
? order
19541956
: order instanceof Order
@@ -2025,15 +2027,18 @@ <h1 class="page-title">transports/ws2.js</h1>
20252027
*
20262028
* @see WSv2#submitOrder
20272029
*
2028-
* @param {object[]|Array[]|number[]} orders - array of order models, arrays
2030+
* @param {object|object[]|Array[]|number[]} params - parameters or array of order models, arrays
2031+
* @param {object[]|Array[]|number[]} params.ids - array of order models, arrays
20292032
* or IDs to be cancelled
20302033
* @returns {Promise} p
20312034
*/
2032-
async cancelOrders (orders) {
2035+
async cancelOrders (params) {
20332036
if (!this._isAuthenticated) {
20342037
throw new Error('not authenticated')
20352038
}
20362039

2040+
const orders = params?.ids ?? params
2041+
20372042
return Promise.all(orders.map(o => {
20382043
return this.cancelOrder(o)
20392044
}))
@@ -2855,7 +2860,7 @@ <h1 class="page-title">transports/ws2.js</h1>
28552860
<br class="clear">
28562861

28572862
<footer>
2858-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 11 2023 15:44:15 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
2863+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue May 30 2023 11:56:58 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
28592864
</footer>
28602865

28612866
<script>prettyPrint();</script>

docs/util_precision.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ <h1 class="page-title">util/precision.js</h1>
106106
<br class="clear">
107107

108108
<footer>
109-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 11 2023 15:44:15 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
109+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue May 30 2023 11:56:58 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
110110
</footer>
111111

112112
<script>prettyPrint();</script>

docs/util_ws2.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h1 class="page-title">util/ws2.js</h1>
7272
<br class="clear">
7373

7474
<footer>
75-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 11 2023 15:44:15 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue May 30 2023 11:56:58 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
7676
</footer>
7777

7878
<script>prettyPrint();</script>

docs/ws2_manager.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ <h1 class="page-title">ws2_manager.js</h1>
619619
<br class="clear">
620620

621621
<footer>
622-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 11 2023 15:44:15 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
622+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue May 30 2023 11:56:58 GMT+0300 (Eastern European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
623623
</footer>
624624

625625
<script>prettyPrint();</script>

lib/transports/ws2.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,8 @@ class WSv2 extends EventEmitter {
18821882
* @see WSv2#cancelOrder
18831883
* @see WSv2#updateOrder
18841884
*
1885-
* @param {object|Array} order - order object model or array
1885+
* @param {object|Array} params - parameters or order object model or array
1886+
* @param {object|Array} params.order - order object model or array
18861887
* @returns {Promise} p - resolves on submit notification
18871888
* @example
18881889
* const o = new Order({
@@ -1897,11 +1898,12 @@ class WSv2 extends EventEmitter {
18971898
*
18981899
* console.log('order confirmed! status: %s', o.status)
18991900
*/
1900-
async submitOrder (order) {
1901+
async submitOrder (params) {
19011902
if (!this._isAuthenticated) {
19021903
throw new Error('not authenticated')
19031904
}
19041905

1906+
const order = params?.order ?? params
19051907
const packet = Array.isArray(order)
19061908
? order
19071909
: order instanceof Order
@@ -1978,15 +1980,18 @@ class WSv2 extends EventEmitter {
19781980
*
19791981
* @see WSv2#submitOrder
19801982
*
1981-
* @param {object[]|Array[]|number[]} orders - array of order models, arrays
1983+
* @param {object|object[]|Array[]|number[]} params - parameters or array of order models, arrays
1984+
* @param {object[]|Array[]|number[]} params.ids - array of order models, arrays
19821985
* or IDs to be cancelled
19831986
* @returns {Promise} p
19841987
*/
1985-
async cancelOrders (orders) {
1988+
async cancelOrders (params) {
19861989
if (!this._isAuthenticated) {
19871990
throw new Error('not authenticated')
19881991
}
19891992

1993+
const orders = params?.ids ?? params
1994+
19901995
return Promise.all(orders.map(o => {
19911996
return this.cancelOrder(o)
19921997
}))

0 commit comments

Comments
 (0)