Skip to content

Commit

Permalink
Merge pull request #583 from ZIMkaRU/bugfix/fix-ws-transport-to-suppo…
Browse files Browse the repository at this point in the history
…rt-new-rest-api-signature

Fix ws transport to support new rest api signature
  • Loading branch information
vigan-abd committed Jun 2, 2023
2 parents 08a085a + df7889b commit 45e8a0d
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 128 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
6.0.0
- removed unused deps: chai, request-promise, request, crc-32
- removed bluebird Promise
- bumped bfx-api-node-rest version up to 5.1.0, breaks previous versions compatibility
- update params of submitOrder and cancelOrders methods of WS transport to support new rest api signature
- bumped bfx-api-node-rest version up to 5.1.1, breaks previous versions compatibility
- bumped mocha, jsdoc-to-markdown, docdash, blessed-contrib, ws versions to fix vulnerabilities
- moved dev deps readline-promise, blessed, blessed-contrib, cli-table3, p-iteration into corresponding section

Expand Down
2 changes: 1 addition & 1 deletion docs/WS2Manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -5111,7 +5111,7 @@ <h5 class="h5-returns">Returns:</h5>
<br class="clear">

<footer>
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.
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.
</footer>

<script>prettyPrint();</script>
Expand Down
442 changes: 333 additions & 109 deletions docs/WSv2.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ <h5 class="h5-types">Type:</h5>
<br class="clear">

<footer>
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.
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.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ <h3>Contributing</h3>
<br class="clear">

<footer>
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.
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.
</footer>

<script>prettyPrint();</script>
Expand Down
15 changes: 10 additions & 5 deletions docs/transports_ws2.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,8 @@ <h1 class="page-title">transports/ws2.js</h1>
* @see WSv2#cancelOrder
* @see WSv2#updateOrder
*
* @param {object|Array} order - order object model or array
* @param {object|Array} params - parameters or order object model or array
* @param {object|Array} params.order - order object model or array
* @returns {Promise} p - resolves on submit notification
* @example
* const o = new Order({
Expand All @@ -1944,11 +1945,12 @@ <h1 class="page-title">transports/ws2.js</h1>
*
* console.log('order confirmed! status: %s', o.status)
*/
async submitOrder (order) {
async submitOrder (params) {
if (!this._isAuthenticated) {
throw new Error('not authenticated')
}

const order = params?.order ?? params
const packet = Array.isArray(order)
? order
: order instanceof Order
Expand Down Expand Up @@ -2025,15 +2027,18 @@ <h1 class="page-title">transports/ws2.js</h1>
*
* @see WSv2#submitOrder
*
* @param {object[]|Array[]|number[]} orders - array of order models, arrays
* @param {object|object[]|Array[]|number[]} params - parameters or array of order models, arrays
* @param {object[]|Array[]|number[]} params.ids - array of order models, arrays
* or IDs to be cancelled
* @returns {Promise} p
*/
async cancelOrders (orders) {
async cancelOrders (params) {
if (!this._isAuthenticated) {
throw new Error('not authenticated')
}

const orders = params?.ids ?? params

return Promise.all(orders.map(o => {
return this.cancelOrder(o)
}))
Expand Down Expand Up @@ -2855,7 +2860,7 @@ <h1 class="page-title">transports/ws2.js</h1>
<br class="clear">

<footer>
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.
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.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/util_precision.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1 class="page-title">util/precision.js</h1>
<br class="clear">

<footer>
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.
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.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/util_ws2.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h1 class="page-title">util/ws2.js</h1>
<br class="clear">

<footer>
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.
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.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/ws2_manager.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ <h1 class="page-title">ws2_manager.js</h1>
<br class="clear">

<footer>
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.
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.
</footer>

<script>prettyPrint();</script>
Expand Down
13 changes: 9 additions & 4 deletions lib/transports/ws2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1882,7 +1882,8 @@ class WSv2 extends EventEmitter {
* @see WSv2#cancelOrder
* @see WSv2#updateOrder
*
* @param {object|Array} order - order object model or array
* @param {object|Array} params - parameters or order object model or array
* @param {object|Array} params.order - order object model or array
* @returns {Promise} p - resolves on submit notification
* @example
* const o = new Order({
Expand All @@ -1897,11 +1898,12 @@ class WSv2 extends EventEmitter {
*
* console.log('order confirmed! status: %s', o.status)
*/
async submitOrder (order) {
async submitOrder (params) {
if (!this._isAuthenticated) {
throw new Error('not authenticated')
}

const order = params?.order ?? params
const packet = Array.isArray(order)
? order
: order instanceof Order
Expand Down Expand Up @@ -1978,15 +1980,18 @@ class WSv2 extends EventEmitter {
*
* @see WSv2#submitOrder
*
* @param {object[]|Array[]|number[]} orders - array of order models, arrays
* @param {object|object[]|Array[]|number[]} params - parameters or array of order models, arrays
* @param {object[]|Array[]|number[]} params.ids - array of order models, arrays
* or IDs to be cancelled
* @returns {Promise} p
*/
async cancelOrders (orders) {
async cancelOrders (params) {
if (!this._isAuthenticated) {
throw new Error('not authenticated')
}

const orders = params?.ids ?? params

return Promise.all(orders.map(o => {
return this.cancelOrder(o)
}))
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "6.0.0",
"description": "Node reference library for Bitfinex API",
"engines": {
"node": ">=8.3.0"
"node": ">=16.20.0"
},
"main": "index.js",
"husky": {
Expand Down Expand Up @@ -56,8 +56,8 @@
"standard": "^16.0.3"
},
"dependencies": {
"bfx-api-node-models": "^1.4.0",
"bfx-api-node-rest": "^5.1.0",
"bfx-api-node-models": "^1.7.1",
"bfx-api-node-rest": "^5.1.1",
"bfx-api-node-util": "^1.0.10",
"bfx-api-node-ws1": "^1.0.0",
"bignumber.js": "9.0.0",
Expand Down

0 comments on commit 45e8a0d

Please sign in to comment.