@gnolang/tm2-js-client 1.1.1 → 1.1.3
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.
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.JSONRPCProvider = void 0;
|
|
40
|
+
var types_1 = require("../types");
|
|
40
41
|
var services_1 = require("../../services");
|
|
41
42
|
var utility_1 = require("../utility");
|
|
42
43
|
var endpoints_1 = require("../endpoints");
|
|
@@ -224,7 +225,7 @@ var JSONRPCProvider = /** @class */ (function () {
|
|
|
224
225
|
// Check if there is an immediate tx-broadcast error
|
|
225
226
|
// (originating from basic transaction checks like CheckTx)
|
|
226
227
|
if (response.error) {
|
|
227
|
-
errType = response.error.ABCIErrorKey;
|
|
228
|
+
errType = response.error[types_1.ABCIErrorKey];
|
|
228
229
|
log = response.Log;
|
|
229
230
|
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
230
231
|
}
|
|
@@ -246,13 +247,13 @@ var JSONRPCProvider = /** @class */ (function () {
|
|
|
246
247
|
check_tx = response.check_tx, deliver_tx = response.deliver_tx;
|
|
247
248
|
// Check if there is an immediate tx-broadcast error (in CheckTx)
|
|
248
249
|
if (check_tx.ResponseBase.Error) {
|
|
249
|
-
errType = check_tx.ResponseBase.Error.ABCIErrorKey;
|
|
250
|
+
errType = check_tx.ResponseBase.Error[types_1.ABCIErrorKey];
|
|
250
251
|
log = check_tx.ResponseBase.Log;
|
|
251
252
|
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
252
253
|
}
|
|
253
254
|
// Check if there is a parsing error with the transaction (in DeliverTx)
|
|
254
255
|
if (deliver_tx.ResponseBase.Error) {
|
|
255
|
-
errType = deliver_tx.ResponseBase.Error.ABCIErrorKey;
|
|
256
|
+
errType = deliver_tx.ResponseBase.Error[types_1.ABCIErrorKey];
|
|
256
257
|
log = deliver_tx.ResponseBase.Log;
|
|
257
258
|
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
258
259
|
}
|
|
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var types_1 = require("../types");
|
|
42
43
|
var axios_1 = __importDefault(require("axios"));
|
|
43
44
|
var jsonrpc_1 = require("./jsonrpc");
|
|
44
45
|
var utility_1 = require("../utility");
|
|
@@ -110,6 +111,7 @@ describe('JSON-RPC Provider', function () {
|
|
|
110
111
|
});
|
|
111
112
|
}); });
|
|
112
113
|
describe('sendTransaction', function () {
|
|
114
|
+
var _a;
|
|
113
115
|
var validResult = {
|
|
114
116
|
error: null,
|
|
115
117
|
data: null,
|
|
@@ -119,9 +121,9 @@ describe('JSON-RPC Provider', function () {
|
|
|
119
121
|
var mockError = '/std.UnauthorizedError';
|
|
120
122
|
var mockLog = 'random error message';
|
|
121
123
|
var invalidResult = {
|
|
122
|
-
error: {
|
|
123
|
-
ABCIErrorKey
|
|
124
|
-
|
|
124
|
+
error: (_a = {},
|
|
125
|
+
_a[types_1.ABCIErrorKey] = mockError,
|
|
126
|
+
_a),
|
|
125
127
|
data: null,
|
|
126
128
|
Log: mockLog,
|
|
127
129
|
hash: '',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uint8ArrayToBase64 = exports.base64ToUint8Array = exports.stringToBase64 = exports.parseABCI = exports.newResponse = exports.newRequest = void 0;
|
|
4
|
+
var uuid_1 = require("uuid");
|
|
4
5
|
// The version of the supported JSON-RPC protocol
|
|
5
6
|
var standardVersion = '2.0';
|
|
6
7
|
/**
|
|
@@ -26,7 +27,7 @@ exports.newRequest = newRequest;
|
|
|
26
27
|
*/
|
|
27
28
|
var newResponse = function (result, error) {
|
|
28
29
|
return {
|
|
29
|
-
id:
|
|
30
|
+
id: (0, uuid_1.v4)(),
|
|
30
31
|
jsonrpc: standardVersion,
|
|
31
32
|
result: result,
|
|
32
33
|
error: error,
|
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.WSProvider = void 0;
|
|
40
|
+
var types_1 = require("../types");
|
|
40
41
|
var utility_1 = require("../utility");
|
|
41
42
|
var endpoints_1 = require("../endpoints");
|
|
42
43
|
var errors_utility_1 = require("../utility/errors.utility");
|
|
@@ -58,8 +59,8 @@ var WSProvider = /** @class */ (function () {
|
|
|
58
59
|
*/
|
|
59
60
|
this.waitForOpenConnection = function () {
|
|
60
61
|
return new Promise(function (resolve, reject) {
|
|
61
|
-
var maxNumberOfAttempts =
|
|
62
|
-
var intervalTime =
|
|
62
|
+
var maxNumberOfAttempts = 20;
|
|
63
|
+
var intervalTime = 500; // ms
|
|
63
64
|
var currentAttempt = 0;
|
|
64
65
|
var interval = setInterval(function () {
|
|
65
66
|
if (_this.ws.readyState === WebSocket.OPEN) {
|
|
@@ -67,9 +68,9 @@ var WSProvider = /** @class */ (function () {
|
|
|
67
68
|
resolve(null);
|
|
68
69
|
}
|
|
69
70
|
currentAttempt++;
|
|
70
|
-
if (currentAttempt
|
|
71
|
+
if (currentAttempt >= maxNumberOfAttempts) {
|
|
71
72
|
clearInterval(interval);
|
|
72
|
-
reject(new Error('
|
|
73
|
+
reject(new Error('Unable to establish WS connection'));
|
|
73
74
|
}
|
|
74
75
|
}, intervalTime);
|
|
75
76
|
});
|
|
@@ -313,7 +314,7 @@ var WSProvider = /** @class */ (function () {
|
|
|
313
314
|
// Check if there is an immediate tx-broadcast error
|
|
314
315
|
// (originating from basic transaction checks like CheckTx)
|
|
315
316
|
if (broadcastResponse.error) {
|
|
316
|
-
errType = broadcastResponse.error.ABCIErrorKey;
|
|
317
|
+
errType = broadcastResponse.error[types_1.ABCIErrorKey];
|
|
317
318
|
log = broadcastResponse.Log;
|
|
318
319
|
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
319
320
|
}
|
|
@@ -334,13 +335,13 @@ var WSProvider = /** @class */ (function () {
|
|
|
334
335
|
check_tx = broadcastResponse.check_tx, deliver_tx = broadcastResponse.deliver_tx;
|
|
335
336
|
// Check if there is an immediate tx-broadcast error (in CheckTx)
|
|
336
337
|
if (check_tx.ResponseBase.Error) {
|
|
337
|
-
errType = check_tx.ResponseBase.Error.ABCIErrorKey;
|
|
338
|
+
errType = check_tx.ResponseBase.Error[types_1.ABCIErrorKey];
|
|
338
339
|
log = check_tx.ResponseBase.Log;
|
|
339
340
|
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
340
341
|
}
|
|
341
342
|
// Check if there is a parsing error with the transaction (in DeliverTx)
|
|
342
343
|
if (deliver_tx.ResponseBase.Error) {
|
|
343
|
-
errType = deliver_tx.ResponseBase.Error.ABCIErrorKey;
|
|
344
|
+
errType = deliver_tx.ResponseBase.Error[types_1.ABCIErrorKey];
|
|
344
345
|
log = deliver_tx.ResponseBase.Log;
|
|
345
346
|
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
346
347
|
}
|
|
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var types_1 = require("../types");
|
|
42
43
|
var utility_1 = require("../utility");
|
|
43
44
|
var ws_1 = require("./ws");
|
|
44
45
|
var jest_websocket_mock_1 = __importDefault(require("jest-websocket-mock"));
|
|
@@ -338,6 +339,7 @@ describe('WS Provider', function () {
|
|
|
338
339
|
});
|
|
339
340
|
}); });
|
|
340
341
|
describe('sendTransaction', function () {
|
|
342
|
+
var _a;
|
|
341
343
|
var validResult = {
|
|
342
344
|
error: null,
|
|
343
345
|
data: null,
|
|
@@ -347,9 +349,9 @@ describe('WS Provider', function () {
|
|
|
347
349
|
var mockError = '/std.UnauthorizedError';
|
|
348
350
|
var mockLog = 'random error message';
|
|
349
351
|
var invalidResult = {
|
|
350
|
-
error: {
|
|
351
|
-
ABCIErrorKey
|
|
352
|
-
|
|
352
|
+
error: (_a = {},
|
|
353
|
+
_a[types_1.ABCIErrorKey] = mockError,
|
|
354
|
+
_a),
|
|
353
355
|
data: null,
|
|
354
356
|
Log: mockLog,
|
|
355
357
|
hash: '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnolang/tm2-js-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Tendermint2 JS / TS Client",
|
|
5
5
|
"main": "./bin/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -47,9 +47,11 @@
|
|
|
47
47
|
"@cosmjs/amino": "^0.31.0",
|
|
48
48
|
"@cosmjs/crypto": "^0.31.0",
|
|
49
49
|
"@cosmjs/ledger-amino": "^0.31.0",
|
|
50
|
+
"@types/uuid": "^9.0.4",
|
|
50
51
|
"axios": "^1.4.0",
|
|
51
52
|
"long": "^5.2.3",
|
|
52
53
|
"protobufjs": "^7.2.3",
|
|
54
|
+
"uuid": "^9.0.1",
|
|
53
55
|
"ws": "^8.13.0"
|
|
54
56
|
},
|
|
55
57
|
"scripts": {
|