@tchain/tcabci-read-js-client 1.1.0 → 1.2.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/client.js CHANGED
@@ -52,7 +52,7 @@ class TCAbciClient {
52
52
  if (!this.getConnected()) {
53
53
  throw NOT_CONNECTED
54
54
  }
55
- this.ws.close()
55
+ this.Disconnect(1000)
56
56
  this.setConnected(false)
57
57
  this.setSubscribed(false)
58
58
  }
@@ -137,7 +137,7 @@ class TCAbciClient {
137
137
  }
138
138
 
139
139
  return this.httpClient.post(
140
- "/v1/broadcast",
140
+ "/v1/tx",
141
141
  {
142
142
  id,
143
143
  version,
@@ -152,6 +152,10 @@ class TCAbciClient {
152
152
  .catch(e => { throw TRANSACTION_NOT_BROADCAST })
153
153
  }
154
154
 
155
+ Bulk(addresses = []) {
156
+ return this.httpClient.post('/v1/bulk_tx', { addresses: addresses })
157
+ }
158
+
155
159
  Disconnect(code = 1000) {
156
160
  if (this.getConnected()) {
157
161
  this.ws.close(code)
package/client_test.js CHANGED
@@ -167,4 +167,33 @@ describe("TCAbciClient TESTS", () => {
167
167
  })
168
168
  })
169
169
 
170
+ it('should error in bulk tx if addresses count is zero',(done) => {
171
+ const client = new tcAbciClient()
172
+ client.Bulk([])
173
+ .then(() => {
174
+ done(new Error('invalid return'))
175
+ })
176
+ .catch((err) => {
177
+ unitJS.assert.equal(400, err.response.status)
178
+ done()
179
+ })
180
+ })
181
+
182
+ it('should error in bulk tx if addresses count is greater than 251',(done) => {
183
+ const addresses = []
184
+
185
+ for (var i = 0; i < 252; i++) {
186
+ addresses.push("2mSCzresfg8Gwu7LZ9k9BTWkQAcQEkvYHFUSCZE2ubM4QV89PTeSYwQDqBas3ykq2emHEK6VRvxdgoe1vrhBbQGN")
187
+ }
188
+
189
+ const client = new tcAbciClient()
190
+ client.Bulk(addresses)
191
+ .then(() => {
192
+ done(new Error('invalid return'))
193
+ })
194
+ .catch((err) => {
195
+ unitJS.assert.equal(400, err.response.status)
196
+ done()
197
+ })
198
+ })
170
199
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tchain/tcabci-read-js-client",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "TransferChain Fastest Read Network WebSocket Client",
5
5
  "main": "client.js",
6
6
  "type": "commonjs",