hollaex-node-lib 2.1.0 → 2.14.0

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/.drone.yml ADDED
@@ -0,0 +1,59 @@
1
+ kind: pipeline
2
+ type: docker
3
+ name: slack_notify
4
+
5
+ steps:
6
+ - name: partymaker_version_tag_testnet
7
+ image: alpine
8
+ commands:
9
+ - export PACKAGE_VERSION="$(grep version package.json | cut -c 14- | rev | cut -c 3- | rev)" && echo "$PACKAGE_VERSION" > .tags
10
+ - echo "Current version tag is :" && cat .tags
11
+ when:
12
+ branch: master
13
+
14
+ - name: partymaker_version_tag
15
+ image: alpine
16
+ commands:
17
+ - export PACKAGE_VERSION="$(grep version package.json | cut -c 14- | rev | cut -c 3- | rev)" && echo "$PACKAGE_VERSION-testnet" > .tags
18
+ - echo "Current version tag is :" && cat .tags
19
+ when:
20
+ branch: testnet
21
+
22
+ - name: create_github_release
23
+ image: bitholla/devops-tools:drone_github_hub-2004241546
24
+ environment:
25
+ GITHUB_TOKEN:
26
+ from_secret: github_oauth2_token_for_releases
27
+ commands:
28
+ - apt-get update && apt-get install -y hub git
29
+ - hub release create -m "HollaEx Kit v$(cat .tags) Release" -t ${DRONE_BRANCH} $(cat .tags)
30
+ when:
31
+ branch: master
32
+
33
+ - name: slack_noti_to_releases
34
+ image: bitholla/devops-tools:drone_partymaker-0.1.4
35
+ environment:
36
+ WEBHOOK_URL:
37
+ from_secret: webhook_url
38
+ when:
39
+ status: [success]
40
+
41
+ - name: notify_to_discord_releases
42
+ image: bitholla/devops-tools:drone_partymaker-0.1.5
43
+ channel: deployment
44
+ settings:
45
+ target: discord
46
+ release_name: hollaex-node-lib
47
+ environment:
48
+ WEBHOOK_URL:
49
+ from_secret: discord_webhook_url
50
+ when:
51
+ status: [ success, failure ]
52
+ branch: master
53
+
54
+ trigger:
55
+ branch:
56
+ - master
57
+ - testnet
58
+ event:
59
+ - push
package/.editorconfig ADDED
@@ -0,0 +1,10 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+
8
+ [*.{js,json}]
9
+ indent_style = tab
10
+ indent_size = 4
package/.eslintrc.json CHANGED
@@ -12,6 +12,9 @@
12
12
  "linebreak-style": ["error", "unix"],
13
13
  "quotes": ["error", "single"],
14
14
  "semi": ["error", "always"],
15
+ "indent": ["error", "tab"],
16
+ "arrow-parens": ["error", "always"],
17
+ "object-curly-spacing": ["error", "always"],
15
18
  "no-console": 0
16
19
  }
17
20
  }
package/README.md CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  Nodejs library for HollaEx Kit enabled exchanges.
4
4
 
5
- **This documentation is specifically for using this library to connect to HollaEx Kit enabled exchanges. If you are an exchange operator and would like to use this library for the HollaEx Network, [click here](NETWORK_README.md)**
5
+ **This library is specifically for end users and traders to connect to HollaEx Kit exchanges. It connects to [HollaEx Pro](https://pro.hollaex.com/trade/xht-usdt) by default.**
6
6
 
7
7
  ## Usage
8
8
 
9
9
  ```javascript
10
- const { Kit } = require('hollaex-node-lib');
10
+ const hollaex = require('hollaex-node-lib');
11
11
 
12
- const client = new Kit();
12
+ const client = new hollaex();
13
13
  ```
14
14
 
15
15
  You can pass the `apiURL` and `baseURL` of the HollaEx-Enabled exchange to connect to. You can also pass your `apiKey` and `apiSecret` generated from the HollaEx-Enabled exchange.
16
16
 
17
17
  ```javascript
18
- const client = new Kit({
18
+ const client = new hollaex({
19
19
  apiURL: '<EXCHANGE_API_URL>',
20
20
  baseURL: '<EXCHANGE_BASE_URL>',
21
21
  apiKey: '<MY_API_KEY>',
@@ -28,7 +28,7 @@ You can also pass the field `apiExpiresAfter` which is the length of time in sec
28
28
  ### Example:
29
29
 
30
30
  ```javascript
31
- const client = new Kit({
31
+ const client = new hollaex({
32
32
  apiURL: '<EXCHANGE_API_URL>',
33
33
  baseURL: '<EXCHANGE_BASE_URL>',
34
34
  apiKey: '<MY_API_KEY>',
@@ -56,28 +56,26 @@ client
56
56
 
57
57
  ### Available functions:
58
58
 
59
- - **Optional parameters are all contained within an object parameter called `opts`**
60
-
61
59
  | Command | Parameters | Description |
62
60
  | - | - | - |
63
61
  | `getKit` | | Get exchange information e.g. name, valid languages, description, etc. |
64
62
  | `getConstants` | | Tick size, min price, max price, min size and max size of each symbol pair and coin |
65
- | `getTicker` | **symbol** | Last, high, low, open and close price and volume within the last 24 hours |
63
+ | `getTicker` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Last, high, low, open and close price and volume within the last 24 hours |
66
64
  | `getTickers` | | Last, high, low, open and close price and volume within the last 24 hours for all symbols |
67
- | `getOrderbook` | **symbol** | Orderbook containing list of bids and asks |
65
+ | `getOrderbook` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Orderbook containing list of bids and asks |
68
66
  | `getOrderbooks` | | Orderbook containing list of bids and asks for all symbols |
69
- | `getTrades` | **symbol** (_optional_) | List of last trades |
67
+ | `getTrades` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li></ul> | List of last trades |
70
68
  | `getUser` | | User's personal information |
71
69
  | `getBalance` | | User's wallet balance |
72
- | `getDeposits` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all deposits |
73
- | `getWithdrawals` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all withdrawals |
74
- | `requestWithdrawal` | **currency**, **amount**, **address**, **network** (_optional_), **otpCode** (_optional_) | Create a new withdrawal request |
75
- | `getUserTrades` | **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all trades |
76
- | `getOrder` | **orderId** | Get specific information about a certain order |
77
- | `getOrders` | **symbol** (_optional_), **side** (_optional_), **status** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, _enum_=`asc`, `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Get the list of all user orders. It can be filter by passing the symbol |
78
- | `createOrder` | **symbol**, **side** (`buy` or `sell`), **size**, **type** (`market` or `limit`), **price**, **stop** (_optional_), **meta** (_optional_, object with optional properties e.g. `post_only`) | Create a new order |
79
- | `cancelOrder` | **orderId** | Cancel a specific order with its ID |
80
- | `cancelAllOrders` | **symbol** (_optional_) | Cancel all open order. It can be filter by passing the symbol |
70
+ | `getDeposits` | <ul><li>**opts**: Object with additional params</li><li>**opts.currency**: (_optional_) Filter data set by asset</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.dismissed**: (_optional_) Filter data set `dismissed`</li><li>**opts.rejected**: (_optional_) Filter data set `rejected`</li><li>**opts.processing**: (_optional_) Filter data set `processing`</li><li>**opts.waiting**: (_optional_) Filter data set `waiting`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li><li>**opts.transactionId**: (_optional_) Filter data set by TXID</li><li>**opts.address**: (_optional_) Filter data set by address</li></ul> | User's list of all deposits |
71
+ | `getWithdrawals` | <ul><li>**opts**: Object with additional params</li><li>**opts.currency**: (_optional_) Filter data set by asset</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.dismissed**: (_optional_) Filter data set `dismissed`</li><li>**opts.rejected**: (_optional_) Filter data set `rejected`</li><li>**opts.processing**: (_optional_) Filter data set `processing`</li><li>**opts.waiting**: (_optional_) Filter data set `waiting`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li><li>**opts.transactionId**: (_optional_) Filter data set by TXID</li><li>**opts.address**: (_optional_) Filter data set by address</li></ul> | User's list of all withdrawals |
72
+ | `makeWithdrawal` | <ul><li>**currency**: Currency code e.g. `xht`</li><li>**amount**: Withdrawal amount</li><li>**address**: Address to withdrawal to</li><li>**opts**: Object with additional params</li><li>**opts.network**: (_required if asset has multiple networks_) Blockchain network to create address for e.g. `trx`</li></ul> | Create a new withdrawal request |
73
+ | `getUserTrades` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li></ul> | User's list of all trades |
74
+ | `getOrder` | <ul><li>**orderId**: HollaEx Network Order ID</li></ul> | Get specific information about a certain order |
75
+ | `getOrders` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li><li>**opts.side**: (_optional_, _enum_=[`buy`, `sell`]) Order side</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`])</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li></ul> | Get the list of all user orders. It can be filter by passing the symbol |
76
+ | `createOrder` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li><li>**side** (_enum_=[`buy`, `sell`]): Order side</li><li>**size**: Size of order to place</li><li>**type**: (_enum_=[`market`, `limit`] Order type</li><li>**price**: (_required if limit order type_) Order price</li><li>**opts**: Object with additional params</li><li>**opts.stop**: (_optional_) Stop price for order</li><li>**opts.meta**: (_optional_) Object with additional meta configurations</li><li>**opts.meta.post_only**: (_optional_, _default_=`false`) Make post only order </li><li>**opts.meta.note**: (_optional_) Custom note for order</li></ul> | Create a new order |
77
+ | `cancelOrder` | <ul><li>**orderId**: HollaEx Network order ID</li></ul> | Cancel a specific order with its ID |
78
+ | `cancelAllOrders` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Cancel all the active orders of a user, filtered by currency pair symbol |
81
79
 
82
80
  ### Websocket
83
81
 
@@ -1,19 +1,21 @@
1
1
  const HollaEx = require('../index');
2
2
  require('dotenv').load();
3
3
 
4
- const API_KEY = process.env.API_KEY || '';
5
- const API_SECRET = process.env.API_SECRET || '';
6
- const client = new HollaEx({ apiKey: API_KEY, apiSecret: API_SECRET });
7
-
8
- client
9
- .getTicker('xht-usdt')
10
- .then((res) => {
11
- let data = JSON.parse(res);
12
- console.log('The volume is', data.volume);
13
- })
14
- .catch((err) => {
15
- console.log(err);
16
- });
4
+ const API_KEY = process.env.API_KEY || 'b28d81e806535350d83b48e952d0e2ed8ffcc6ef';
5
+ const API_SECRET = process.env.API_SECRET || '73879b785c50e235a0e2e972a899eba56968bc42c956f68e87';
6
+ const client = new HollaEx({ apiURL: 'https://api.sandbox.hollaex.com', apiKey: API_KEY, apiSecret: API_SECRET });
7
+
8
+ // client
9
+ // .getBalance()
10
+ // .then(async (data) => {
11
+ // console.log(data);
12
+ // // console.log('The volume is', data.volume);
13
+ // // const withdrawal = await client.makeWithdrawal('xht', 1, '0x97e13fccfe2edab7e8077d0f2ac69fe984cfe7f7', { network: 'eth' });
14
+ // // console.log(withdrawal);
15
+ // })
16
+ // .catch((err) => {
17
+ // console.log(err);
18
+ // });
17
19
 
18
20
  // connect to websocket
19
21
  /*
@@ -22,24 +24,19 @@ client
22
24
  symbols : xht-usdt
23
25
  */
24
26
 
25
- const socket1 = client.connect('trades:xht-usdt');
27
+ client.connect(['orderbook:xht-usdt','wallet']);
26
28
 
27
- socket1.on('trades', (data) => {
29
+ client.ws.on('message', (data) => {
30
+ data = JSON.parse(data);
28
31
  console.log(data);
29
32
  });
30
33
 
31
- const socket2 = client.connect('all');
32
34
 
33
- socket2.on('orderbook', (data) => {
34
- console.log(data);
35
- });
36
-
37
- // You have to use a token to use these otherwise the socket disconnects
38
- socket2.on('userInfo', (data) => {
39
- console.log(data);
35
+ client.ws.on('error', (error) => {
36
+ console.log(error);
40
37
  });
41
38
 
42
39
 
43
- setTimeout(() => {
44
- socket2.disconnect();
45
- }, 5000);
40
+ // setTimeout(() => {
41
+ // client.disconnect();
42
+ // }, 10000);
package/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const Kit = require('./kit');
4
- const Network = require('./network');
5
4
 
6
- module.exports = {
7
- Kit,
8
- Network
9
- };
5
+ // To maintain backwards compatibility for `const { Kit } = require("hollaex-node-lib")`
6
+ class BackwardsCompatibleKit extends Kit {
7
+ static get Kit() {
8
+ return Kit;
9
+ }
10
+ }
11
+
12
+ module.exports = BackwardsCompatibleKit;