@gnolang/tm2-js-client 1.3.3 → 2.0.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/README.md +1 -1
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.cjs +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.mjs +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.mjs +11 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/index.cjs +92 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -0
- package/dist/proto/google/protobuf/any.cjs +84 -0
- package/dist/proto/google/protobuf/any.cjs.map +1 -0
- package/dist/proto/google/protobuf/any.d.cts +141 -0
- package/dist/proto/google/protobuf/any.d.cts.map +1 -0
- package/dist/proto/google/protobuf/any.d.mts +141 -0
- package/dist/proto/google/protobuf/any.d.mts.map +1 -0
- package/dist/proto/google/protobuf/any.mjs +83 -0
- package/dist/proto/google/protobuf/any.mjs.map +1 -0
- package/dist/proto/index.cjs +2 -0
- package/dist/proto/index.d.cts +2 -0
- package/dist/proto/index.d.mts +2 -0
- package/dist/proto/index.mjs +3 -0
- package/dist/proto/tm2/abci.cjs +182 -0
- package/dist/proto/tm2/abci.cjs.map +1 -0
- package/dist/proto/tm2/abci.d.cts +33 -0
- package/dist/proto/tm2/abci.d.cts.map +1 -0
- package/dist/proto/tm2/abci.d.mts +33 -0
- package/dist/proto/tm2/abci.d.mts.map +1 -0
- package/dist/proto/tm2/abci.mjs +181 -0
- package/dist/proto/tm2/abci.mjs.map +1 -0
- package/dist/proto/tm2/tx.cjs +263 -0
- package/dist/proto/tm2/tx.cjs.map +1 -0
- package/dist/proto/tm2/tx.d.cts +49 -0
- package/dist/proto/tm2/tx.d.cts.map +1 -0
- package/dist/proto/tm2/tx.d.mts +49 -0
- package/dist/proto/tm2/tx.d.mts.map +1 -0
- package/dist/proto/tm2/tx.mjs +258 -0
- package/dist/proto/tm2/tx.mjs.map +1 -0
- package/dist/provider/endpoints.cjs +43 -0
- package/dist/provider/endpoints.cjs.map +1 -0
- package/dist/provider/endpoints.d.cts +33 -0
- package/dist/provider/endpoints.d.cts.map +1 -0
- package/dist/provider/endpoints.d.mts +33 -0
- package/dist/provider/endpoints.d.mts.map +1 -0
- package/dist/provider/endpoints.mjs +39 -0
- package/dist/provider/endpoints.mjs.map +1 -0
- package/dist/provider/errors/errors.cjs +122 -0
- package/dist/provider/errors/errors.cjs.map +1 -0
- package/dist/provider/errors/errors.d.cts +62 -0
- package/dist/provider/errors/errors.d.cts.map +1 -0
- package/dist/provider/errors/errors.d.mts +62 -0
- package/dist/provider/errors/errors.d.mts.map +1 -0
- package/dist/provider/errors/errors.mjs +104 -0
- package/dist/provider/errors/errors.mjs.map +1 -0
- package/dist/provider/errors/messages.cjs +40 -0
- package/dist/provider/errors/messages.cjs.map +1 -0
- package/dist/provider/errors/messages.mjs +23 -0
- package/dist/provider/errors/messages.mjs.map +1 -0
- package/dist/provider/index.cjs +12 -0
- package/dist/provider/index.d.cts +11 -0
- package/dist/provider/index.d.mts +11 -0
- package/dist/provider/index.mjs +13 -0
- package/dist/provider/jsonrpc/index.cjs +1 -0
- package/dist/provider/jsonrpc/index.d.cts +1 -0
- package/dist/provider/jsonrpc/index.d.mts +1 -0
- package/dist/provider/jsonrpc/index.mjs +2 -0
- package/dist/provider/jsonrpc/jsonrpc.cjs +20 -0
- package/dist/provider/jsonrpc/jsonrpc.cjs.map +1 -0
- package/dist/provider/jsonrpc/jsonrpc.d.cts +16 -0
- package/dist/provider/jsonrpc/jsonrpc.d.cts.map +1 -0
- package/dist/provider/jsonrpc/jsonrpc.d.mts +16 -0
- package/dist/provider/jsonrpc/jsonrpc.d.mts.map +1 -0
- package/dist/provider/jsonrpc/jsonrpc.mjs +19 -0
- package/dist/provider/jsonrpc/jsonrpc.mjs.map +1 -0
- package/dist/provider/provider.cjs +130 -0
- package/dist/provider/provider.cjs.map +1 -0
- package/dist/provider/provider.d.cts +130 -0
- package/dist/provider/provider.d.cts.map +1 -0
- package/dist/provider/provider.d.mts +130 -0
- package/dist/provider/provider.d.mts.map +1 -0
- package/dist/provider/provider.mjs +130 -0
- package/dist/provider/provider.mjs.map +1 -0
- package/dist/provider/types/abci.cjs +6 -0
- package/dist/provider/types/abci.cjs.map +1 -0
- package/dist/provider/types/abci.d.cts +42 -0
- package/dist/provider/types/abci.d.cts.map +1 -0
- package/dist/provider/types/abci.d.mts +42 -0
- package/dist/provider/types/abci.d.mts.map +1 -0
- package/dist/provider/types/abci.mjs +6 -0
- package/dist/provider/types/abci.mjs.map +1 -0
- package/dist/provider/types/common.d.cts +186 -0
- package/dist/provider/types/common.d.cts.map +1 -0
- package/dist/provider/types/common.d.mts +186 -0
- package/dist/provider/types/common.d.mts.map +1 -0
- package/dist/provider/types/jsonrpc.d.cts +30 -0
- package/dist/provider/types/jsonrpc.d.cts.map +1 -0
- package/dist/provider/types/jsonrpc.d.mts +30 -0
- package/dist/provider/types/jsonrpc.d.mts.map +1 -0
- package/dist/provider/utility/adapters.cjs +241 -0
- package/dist/provider/utility/adapters.cjs.map +1 -0
- package/dist/provider/utility/adapters.d.cts +19 -0
- package/dist/provider/utility/adapters.d.cts.map +1 -0
- package/dist/provider/utility/adapters.d.mts +19 -0
- package/dist/provider/utility/adapters.d.mts.map +1 -0
- package/dist/provider/utility/adapters.mjs +231 -0
- package/dist/provider/utility/adapters.mjs.map +1 -0
- package/dist/provider/utility/errors.utility.cjs +38 -0
- package/dist/provider/utility/errors.utility.cjs.map +1 -0
- package/dist/provider/utility/errors.utility.mjs +38 -0
- package/dist/provider/utility/errors.utility.mjs.map +1 -0
- package/dist/provider/utility/index.cjs +3 -0
- package/dist/provider/utility/index.d.cts +3 -0
- package/dist/provider/utility/index.d.mts +3 -0
- package/dist/provider/utility/index.mjs +4 -0
- package/dist/provider/utility/provider.utility.cjs +122 -0
- package/dist/provider/utility/provider.utility.cjs.map +1 -0
- package/{bin/provider/utility/provider.utility.d.ts → dist/provider/utility/provider.utility.d.cts} +15 -10
- package/dist/provider/utility/provider.utility.d.cts.map +1 -0
- package/dist/provider/utility/provider.utility.d.mts +45 -0
- package/dist/provider/utility/provider.utility.d.mts.map +1 -0
- package/dist/provider/utility/provider.utility.mjs +116 -0
- package/dist/provider/utility/provider.utility.mjs.map +1 -0
- package/dist/provider/utility/requests.utility.cjs +75 -0
- package/dist/provider/utility/requests.utility.cjs.map +1 -0
- package/dist/provider/utility/requests.utility.d.cts +40 -0
- package/dist/provider/utility/requests.utility.d.cts.map +1 -0
- package/dist/provider/utility/requests.utility.d.mts +40 -0
- package/dist/provider/utility/requests.utility.d.mts.map +1 -0
- package/dist/provider/utility/requests.utility.mjs +68 -0
- package/dist/provider/utility/requests.utility.mjs.map +1 -0
- package/dist/provider/websocket/index.cjs +1 -0
- package/dist/provider/websocket/index.d.cts +1 -0
- package/dist/provider/websocket/index.d.mts +1 -0
- package/dist/provider/websocket/index.mjs +2 -0
- package/dist/provider/websocket/ws.cjs +27 -0
- package/dist/provider/websocket/ws.cjs.map +1 -0
- package/dist/provider/websocket/ws.d.cts +21 -0
- package/dist/provider/websocket/ws.d.cts.map +1 -0
- package/dist/provider/websocket/ws.d.mts +21 -0
- package/dist/provider/websocket/ws.d.mts.map +1 -0
- package/dist/provider/websocket/ws.mjs +26 -0
- package/dist/provider/websocket/ws.mjs.map +1 -0
- package/dist/services/index.cjs +1 -0
- package/dist/services/index.d.cts +2 -0
- package/dist/services/index.d.mts +2 -0
- package/dist/services/index.mjs +2 -0
- package/dist/services/rest/restService.cjs +16 -0
- package/dist/services/rest/restService.cjs.map +1 -0
- package/dist/services/rest/restService.d.cts +9 -0
- package/dist/services/rest/restService.d.cts.map +1 -0
- package/dist/services/rest/restService.d.mts +9 -0
- package/dist/services/rest/restService.d.mts.map +1 -0
- package/dist/services/rest/restService.mjs +14 -0
- package/dist/services/rest/restService.mjs.map +1 -0
- package/dist/services/rest/restService.types.d.cts +11 -0
- package/dist/services/rest/restService.types.d.cts.map +1 -0
- package/dist/services/rest/restService.types.d.mts +11 -0
- package/dist/services/rest/restService.types.d.mts.map +1 -0
- package/dist/wallet/index.cjs +8 -0
- package/dist/wallet/index.d.cts +7 -0
- package/dist/wallet/index.d.mts +7 -0
- package/dist/wallet/index.mjs +9 -0
- package/dist/wallet/key/index.cjs +1 -0
- package/dist/wallet/key/index.mjs +2 -0
- package/dist/wallet/key/key.cjs +46 -0
- package/dist/wallet/key/key.cjs.map +1 -0
- package/dist/wallet/key/key.d.cts +26 -0
- package/dist/wallet/key/key.d.cts.map +1 -0
- package/dist/wallet/key/key.d.mts +26 -0
- package/dist/wallet/key/key.d.mts.map +1 -0
- package/dist/wallet/key/key.mjs +45 -0
- package/dist/wallet/key/key.mjs.map +1 -0
- package/dist/wallet/ledger/index.cjs +1 -0
- package/dist/wallet/ledger/index.d.cts +1 -0
- package/dist/wallet/ledger/index.d.mts +1 -0
- package/dist/wallet/ledger/index.mjs +2 -0
- package/dist/wallet/ledger/ledger.cjs +49 -0
- package/dist/wallet/ledger/ledger.cjs.map +1 -0
- package/dist/wallet/ledger/ledger.d.cts +27 -0
- package/dist/wallet/ledger/ledger.d.cts.map +1 -0
- package/dist/wallet/ledger/ledger.d.mts +27 -0
- package/dist/wallet/ledger/ledger.d.mts.map +1 -0
- package/dist/wallet/ledger/ledger.mjs +48 -0
- package/dist/wallet/ledger/ledger.mjs.map +1 -0
- package/dist/wallet/signer.d.cts +33 -0
- package/dist/wallet/signer.d.cts.map +1 -0
- package/dist/wallet/signer.d.mts +33 -0
- package/dist/wallet/signer.d.mts.map +1 -0
- package/dist/wallet/types/sign.cjs +6 -0
- package/dist/wallet/types/sign.cjs.map +1 -0
- package/dist/wallet/types/sign.d.cts +20 -0
- package/dist/wallet/types/sign.d.cts.map +1 -0
- package/dist/wallet/types/sign.d.mts +20 -0
- package/dist/wallet/types/sign.d.mts.map +1 -0
- package/dist/wallet/types/sign.mjs +6 -0
- package/dist/wallet/types/sign.mjs.map +1 -0
- package/dist/wallet/types/wallet.d.cts +9 -0
- package/dist/wallet/types/wallet.d.cts.map +1 -0
- package/dist/wallet/types/wallet.d.mts +9 -0
- package/dist/wallet/types/wallet.d.mts.map +1 -0
- package/dist/wallet/utility/index.cjs +1 -0
- package/dist/wallet/utility/index.d.cts +1 -0
- package/dist/wallet/utility/index.d.mts +1 -0
- package/dist/wallet/utility/index.mjs +2 -0
- package/dist/wallet/utility/utility.cjs +83 -0
- package/dist/wallet/utility/utility.cjs.map +1 -0
- package/dist/wallet/utility/utility.d.cts +42 -0
- package/dist/wallet/utility/utility.d.cts.map +1 -0
- package/dist/wallet/utility/utility.d.mts +42 -0
- package/dist/wallet/utility/utility.d.mts.map +1 -0
- package/dist/wallet/utility/utility.mjs +75 -0
- package/dist/wallet/utility/utility.mjs.map +1 -0
- package/dist/wallet/wallet.cjs +223 -0
- package/dist/wallet/wallet.cjs.map +1 -0
- package/dist/wallet/wallet.d.cts +113 -0
- package/dist/wallet/wallet.d.cts.map +1 -0
- package/dist/wallet/wallet.d.mts +113 -0
- package/dist/wallet/wallet.d.mts.map +1 -0
- package/dist/wallet/wallet.mjs +222 -0
- package/dist/wallet/wallet.mjs.map +1 -0
- package/package.json +57 -38
- package/bin/index.d.ts +0 -4
- package/bin/index.js +0 -20
- package/bin/proto/google/protobuf/any.d.ts +0 -145
- package/bin/proto/google/protobuf/any.js +0 -113
- package/bin/proto/index.d.ts +0 -2
- package/bin/proto/index.js +0 -20
- package/bin/proto/tm2/abci.d.ts +0 -37
- package/bin/proto/tm2/abci.js +0 -277
- package/bin/proto/tm2/multisig.d.ts +0 -43
- package/bin/proto/tm2/multisig.js +0 -322
- package/bin/proto/tm2/multisig.test.d.ts +0 -1
- package/bin/proto/tm2/multisig.test.js +0 -63
- package/bin/proto/tm2/tx.d.ts +0 -52
- package/bin/proto/tm2/tx.js +0 -360
- package/bin/provider/endpoints.d.ts +0 -29
- package/bin/provider/endpoints.js +0 -37
- package/bin/provider/errors/errors.d.ts +0 -59
- package/bin/provider/errors/errors.js +0 -173
- package/bin/provider/errors/index.d.ts +0 -1
- package/bin/provider/errors/index.js +0 -17
- package/bin/provider/errors/messages.d.ts +0 -19
- package/bin/provider/errors/messages.js +0 -41
- package/bin/provider/index.d.ts +0 -7
- package/bin/provider/index.js +0 -23
- package/bin/provider/jsonrpc/index.d.ts +0 -1
- package/bin/provider/jsonrpc/index.js +0 -17
- package/bin/provider/jsonrpc/jsonrpc.d.ts +0 -31
- package/bin/provider/jsonrpc/jsonrpc.js +0 -327
- package/bin/provider/jsonrpc/jsonrpc.test.d.ts +0 -1
- package/bin/provider/jsonrpc/jsonrpc.test.js +0 -488
- package/bin/provider/provider.d.ts +0 -98
- package/bin/provider/provider.js +0 -2
- package/bin/provider/types/abci.d.ts +0 -39
- package/bin/provider/types/abci.js +0 -4
- package/bin/provider/types/common.d.ts +0 -184
- package/bin/provider/types/common.js +0 -3
- package/bin/provider/types/index.d.ts +0 -3
- package/bin/provider/types/index.js +0 -19
- package/bin/provider/types/jsonrpc.d.ts +0 -26
- package/bin/provider/types/jsonrpc.js +0 -2
- package/bin/provider/utility/errors.utility.d.ts +0 -11
- package/bin/provider/utility/errors.utility.js +0 -56
- package/bin/provider/utility/index.d.ts +0 -2
- package/bin/provider/utility/index.js +0 -18
- package/bin/provider/utility/provider.utility.js +0 -244
- package/bin/provider/utility/requests.utility.d.ts +0 -35
- package/bin/provider/utility/requests.utility.js +0 -80
- package/bin/provider/websocket/index.d.ts +0 -1
- package/bin/provider/websocket/index.js +0 -17
- package/bin/provider/websocket/ws.d.ts +0 -58
- package/bin/provider/websocket/ws.js +0 -415
- package/bin/provider/websocket/ws.test.d.ts +0 -1
- package/bin/provider/websocket/ws.test.js +0 -648
- package/bin/services/index.d.ts +0 -2
- package/bin/services/index.js +0 -18
- package/bin/services/rest/restService.d.ts +0 -4
- package/bin/services/rest/restService.js +0 -72
- package/bin/services/rest/restService.types.d.ts +0 -6
- package/bin/services/rest/restService.types.js +0 -2
- package/bin/wallet/index.d.ts +0 -6
- package/bin/wallet/index.js +0 -22
- package/bin/wallet/key/index.d.ts +0 -1
- package/bin/wallet/key/index.js +0 -17
- package/bin/wallet/key/key.d.ts +0 -21
- package/bin/wallet/key/key.js +0 -102
- package/bin/wallet/key/key.test.d.ts +0 -1
- package/bin/wallet/key/key.test.js +0 -121
- package/bin/wallet/ledger/index.d.ts +0 -1
- package/bin/wallet/ledger/index.js +0 -17
- package/bin/wallet/ledger/ledger.d.ts +0 -22
- package/bin/wallet/ledger/ledger.js +0 -109
- package/bin/wallet/signer.d.ts +0 -29
- package/bin/wallet/signer.js +0 -2
- package/bin/wallet/types/index.d.ts +0 -2
- package/bin/wallet/types/index.js +0 -18
- package/bin/wallet/types/sign.d.ts +0 -16
- package/bin/wallet/types/sign.js +0 -4
- package/bin/wallet/types/wallet.d.ts +0 -5
- package/bin/wallet/types/wallet.js +0 -2
- package/bin/wallet/utility/index.d.ts +0 -1
- package/bin/wallet/utility/index.js +0 -17
- package/bin/wallet/utility/utility.d.ts +0 -36
- package/bin/wallet/utility/utility.js +0 -117
- package/bin/wallet/wallet.d.ts +0 -106
- package/bin/wallet/wallet.js +0 -361
- package/bin/wallet/wallet.test.d.ts +0 -1
- package/bin/wallet/wallet.test.js +0 -423
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uint8ArrayToBase64 = exports.base64ToUint8Array = exports.stringToBase64 = exports.parseProto = exports.parseABCI = exports.newResponse = exports.newRequest = void 0;
|
|
4
|
-
var uuid_1 = require("uuid");
|
|
5
|
-
// The version of the supported JSON-RPC protocol
|
|
6
|
-
var standardVersion = '2.0';
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new JSON-RPC 2.0 request
|
|
9
|
-
* @param {string} method the requested method
|
|
10
|
-
* @param {string[]} [params] the requested params, if any
|
|
11
|
-
*/
|
|
12
|
-
var newRequest = function (method, params) {
|
|
13
|
-
return {
|
|
14
|
-
// the ID of the request is not that relevant for this helper method;
|
|
15
|
-
// for finer ID control, instantiate the request object directly
|
|
16
|
-
id: (0, uuid_1.v4)(),
|
|
17
|
-
jsonrpc: standardVersion,
|
|
18
|
-
method: method,
|
|
19
|
-
params: params,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.newRequest = newRequest;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new JSON-RPC 2.0 response
|
|
25
|
-
* @param {Result} result the response result, if any
|
|
26
|
-
* @param {RPCError} error the response error, if any
|
|
27
|
-
*/
|
|
28
|
-
var newResponse = function (result, error) {
|
|
29
|
-
return {
|
|
30
|
-
id: (0, uuid_1.v4)(),
|
|
31
|
-
jsonrpc: standardVersion,
|
|
32
|
-
result: result,
|
|
33
|
-
error: error,
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
exports.newResponse = newResponse;
|
|
37
|
-
/**
|
|
38
|
-
* Parses the base64 encoded ABCI JSON into a concrete type
|
|
39
|
-
* @param {string} data the base64-encoded JSON
|
|
40
|
-
*/
|
|
41
|
-
var parseABCI = function (data) {
|
|
42
|
-
var jsonData = Buffer.from(data, 'base64').toString();
|
|
43
|
-
var parsedData = JSON.parse(jsonData);
|
|
44
|
-
if (!parsedData) {
|
|
45
|
-
throw new Error('unable to parse JSON response');
|
|
46
|
-
}
|
|
47
|
-
return parsedData;
|
|
48
|
-
};
|
|
49
|
-
exports.parseABCI = parseABCI;
|
|
50
|
-
var parseProto = function (data, decodeFn) {
|
|
51
|
-
var protoData = decodeFn(Buffer.from(data, 'base64'));
|
|
52
|
-
return protoData;
|
|
53
|
-
};
|
|
54
|
-
exports.parseProto = parseProto;
|
|
55
|
-
/**
|
|
56
|
-
* Converts a string into base64 representation
|
|
57
|
-
* @param {string} str the raw string
|
|
58
|
-
*/
|
|
59
|
-
var stringToBase64 = function (str) {
|
|
60
|
-
var buffer = Buffer.from(str, 'utf-8');
|
|
61
|
-
return buffer.toString('base64');
|
|
62
|
-
};
|
|
63
|
-
exports.stringToBase64 = stringToBase64;
|
|
64
|
-
/**
|
|
65
|
-
* Converts a base64 string into a Uint8Array representation
|
|
66
|
-
* @param {string} str the base64-encoded string
|
|
67
|
-
*/
|
|
68
|
-
var base64ToUint8Array = function (str) {
|
|
69
|
-
var buffer = Buffer.from(str, 'base64');
|
|
70
|
-
return new Uint8Array(buffer);
|
|
71
|
-
};
|
|
72
|
-
exports.base64ToUint8Array = base64ToUint8Array;
|
|
73
|
-
/**
|
|
74
|
-
* Converts a Uint8Array into base64 representation
|
|
75
|
-
* @param {Uint8Array} data the Uint8Array to be encoded
|
|
76
|
-
*/
|
|
77
|
-
var uint8ArrayToBase64 = function (data) {
|
|
78
|
-
return Buffer.from(data).toString('base64');
|
|
79
|
-
};
|
|
80
|
-
exports.uint8ArrayToBase64 = uint8ArrayToBase64;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ws';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./ws"), exports);
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Tx } from '../../proto';
|
|
2
|
-
import { Provider } from '../provider';
|
|
3
|
-
import { ABCIAccount, BlockInfo, BlockResult, BroadcastTransactionMap, ConsensusParams, NetworkInfo, RPCRequest, RPCResponse, Status, TxResult } from '../types';
|
|
4
|
-
/**
|
|
5
|
-
* Provider based on WS JSON-RPC HTTP requests
|
|
6
|
-
*/
|
|
7
|
-
export declare class WSProvider implements Provider {
|
|
8
|
-
protected ws: WebSocket;
|
|
9
|
-
protected readonly requestMap: Map<number | string, {
|
|
10
|
-
resolve: (response: RPCResponse<any>) => void;
|
|
11
|
-
reject: (reason: Error) => void;
|
|
12
|
-
timeout: NodeJS.Timeout;
|
|
13
|
-
}>;
|
|
14
|
-
protected requestTimeout: number;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new instance of the {@link WSProvider}
|
|
17
|
-
* @param {string} baseURL the WS URL of the node
|
|
18
|
-
* @param {number} requestTimeout the timeout for the WS request (in MS)
|
|
19
|
-
*/
|
|
20
|
-
constructor(baseURL: string, requestTimeout?: number);
|
|
21
|
-
/**
|
|
22
|
-
* Closes the WS connection. Required when done working
|
|
23
|
-
* with the WS provider
|
|
24
|
-
*/
|
|
25
|
-
closeConnection(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Sends a request to the WS connection, and resolves
|
|
28
|
-
* upon receiving the response
|
|
29
|
-
* @param {RPCRequest} request the RPC request
|
|
30
|
-
*/
|
|
31
|
-
sendRequest<Result>(request: RPCRequest): Promise<RPCResponse<Result>>;
|
|
32
|
-
/**
|
|
33
|
-
* Parses the result from the response
|
|
34
|
-
* @param {RPCResponse<Result>} response the response to be parsed
|
|
35
|
-
*/
|
|
36
|
-
parseResponse<Result>(response: RPCResponse<Result>): Result;
|
|
37
|
-
/**
|
|
38
|
-
* Waits for the WS connection to be established
|
|
39
|
-
*/
|
|
40
|
-
waitForOpenConnection: () => Promise<null>;
|
|
41
|
-
estimateGas(tx: Tx): Promise<number>;
|
|
42
|
-
getBalance(address: string, denomination?: string, height?: number): Promise<number>;
|
|
43
|
-
getBlock(height: number): Promise<BlockInfo>;
|
|
44
|
-
getBlockResult(height: number): Promise<BlockResult>;
|
|
45
|
-
getBlockNumber(): Promise<number>;
|
|
46
|
-
getConsensusParams(height: number): Promise<ConsensusParams>;
|
|
47
|
-
getGasPrice(): Promise<number>;
|
|
48
|
-
getNetwork(): Promise<NetworkInfo>;
|
|
49
|
-
getAccountSequence(address: string, height?: number): Promise<number>;
|
|
50
|
-
getAccountNumber(address: string, height?: number): Promise<number>;
|
|
51
|
-
getAccount(address: string, height?: number): Promise<ABCIAccount>;
|
|
52
|
-
getStatus(): Promise<Status>;
|
|
53
|
-
getTransaction(hash: string): Promise<TxResult>;
|
|
54
|
-
sendTransaction<K extends keyof BroadcastTransactionMap>(tx: string, endpoint: K): Promise<BroadcastTransactionMap[K]['result']>;
|
|
55
|
-
private broadcastTxSync;
|
|
56
|
-
private broadcastTxCommit;
|
|
57
|
-
waitForTransaction(hash: string, fromHeight?: number, timeout?: number): Promise<Tx>;
|
|
58
|
-
}
|
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.WSProvider = void 0;
|
|
40
|
-
var proto_1 = require("../../proto");
|
|
41
|
-
var endpoints_1 = require("../endpoints");
|
|
42
|
-
var types_1 = require("../types");
|
|
43
|
-
var utility_1 = require("../utility");
|
|
44
|
-
var errors_utility_1 = require("../utility/errors.utility");
|
|
45
|
-
/**
|
|
46
|
-
* Provider based on WS JSON-RPC HTTP requests
|
|
47
|
-
*/
|
|
48
|
-
var WSProvider = /** @class */ (function () {
|
|
49
|
-
/**
|
|
50
|
-
* Creates a new instance of the {@link WSProvider}
|
|
51
|
-
* @param {string} baseURL the WS URL of the node
|
|
52
|
-
* @param {number} requestTimeout the timeout for the WS request (in MS)
|
|
53
|
-
*/
|
|
54
|
-
function WSProvider(baseURL, requestTimeout) {
|
|
55
|
-
var _this = this;
|
|
56
|
-
this.requestMap = new Map(); // callback method map for the individual endpoints
|
|
57
|
-
this.requestTimeout = 15000; // 15s
|
|
58
|
-
/**
|
|
59
|
-
* Waits for the WS connection to be established
|
|
60
|
-
*/
|
|
61
|
-
this.waitForOpenConnection = function () {
|
|
62
|
-
return new Promise(function (resolve, reject) {
|
|
63
|
-
var maxNumberOfAttempts = 20;
|
|
64
|
-
var intervalTime = 500; // ms
|
|
65
|
-
var currentAttempt = 0;
|
|
66
|
-
var interval = setInterval(function () {
|
|
67
|
-
if (_this.ws.readyState === WebSocket.OPEN) {
|
|
68
|
-
clearInterval(interval);
|
|
69
|
-
resolve(null);
|
|
70
|
-
}
|
|
71
|
-
currentAttempt++;
|
|
72
|
-
if (currentAttempt >= maxNumberOfAttempts) {
|
|
73
|
-
clearInterval(interval);
|
|
74
|
-
reject(new Error('Unable to establish WS connection'));
|
|
75
|
-
}
|
|
76
|
-
}, intervalTime);
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
this.ws = new WebSocket(baseURL);
|
|
80
|
-
this.ws.addEventListener('message', function (event) {
|
|
81
|
-
var response = JSON.parse(event.data);
|
|
82
|
-
var request = _this.requestMap.get(response.id);
|
|
83
|
-
if (request) {
|
|
84
|
-
_this.requestMap.delete(response.id);
|
|
85
|
-
clearTimeout(request.timeout);
|
|
86
|
-
request.resolve(response);
|
|
87
|
-
}
|
|
88
|
-
// Set the default timeout
|
|
89
|
-
_this.requestTimeout = requestTimeout ? requestTimeout : 15000;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Closes the WS connection. Required when done working
|
|
94
|
-
* with the WS provider
|
|
95
|
-
*/
|
|
96
|
-
WSProvider.prototype.closeConnection = function () {
|
|
97
|
-
this.ws.close();
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Sends a request to the WS connection, and resolves
|
|
101
|
-
* upon receiving the response
|
|
102
|
-
* @param {RPCRequest} request the RPC request
|
|
103
|
-
*/
|
|
104
|
-
WSProvider.prototype.sendRequest = function (request) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
var promise;
|
|
107
|
-
var _this = this;
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
if (!(this.ws.readyState != WebSocket.OPEN)) return [3 /*break*/, 2];
|
|
112
|
-
return [4 /*yield*/, this.waitForOpenConnection()];
|
|
113
|
-
case 1:
|
|
114
|
-
_a.sent();
|
|
115
|
-
_a.label = 2;
|
|
116
|
-
case 2:
|
|
117
|
-
promise = new Promise(function (resolve, reject) {
|
|
118
|
-
var timeout = setTimeout(function () {
|
|
119
|
-
_this.requestMap.delete(request.id);
|
|
120
|
-
reject(new Error('Request timed out'));
|
|
121
|
-
}, _this.requestTimeout);
|
|
122
|
-
_this.requestMap.set(request.id, { resolve: resolve, reject: reject, timeout: timeout });
|
|
123
|
-
});
|
|
124
|
-
this.ws.send(JSON.stringify(request));
|
|
125
|
-
return [2 /*return*/, promise];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Parses the result from the response
|
|
132
|
-
* @param {RPCResponse<Result>} response the response to be parsed
|
|
133
|
-
*/
|
|
134
|
-
WSProvider.prototype.parseResponse = function (response) {
|
|
135
|
-
var _a;
|
|
136
|
-
if (!response) {
|
|
137
|
-
throw new Error('invalid response');
|
|
138
|
-
}
|
|
139
|
-
if (response.error) {
|
|
140
|
-
throw new Error((_a = response.error) === null || _a === void 0 ? void 0 : _a.message);
|
|
141
|
-
}
|
|
142
|
-
if (!response.result) {
|
|
143
|
-
throw new Error('invalid response returned');
|
|
144
|
-
}
|
|
145
|
-
return response.result;
|
|
146
|
-
};
|
|
147
|
-
WSProvider.prototype.estimateGas = function (tx) {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
-
var encodedTx, response, abciResponse, simulateResult, resultErrorKey;
|
|
150
|
-
var _a, _b;
|
|
151
|
-
return __generator(this, function (_c) {
|
|
152
|
-
switch (_c.label) {
|
|
153
|
-
case 0:
|
|
154
|
-
encodedTx = (0, utility_1.uint8ArrayToBase64)(proto_1.Tx.encode(tx).finish());
|
|
155
|
-
return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ABCIEndpoint.ABCI_QUERY, [
|
|
156
|
-
".app/simulate",
|
|
157
|
-
"".concat(encodedTx),
|
|
158
|
-
'0', // Height; not supported > 0 for now
|
|
159
|
-
false,
|
|
160
|
-
]))];
|
|
161
|
-
case 1:
|
|
162
|
-
response = _c.sent();
|
|
163
|
-
abciResponse = this.parseResponse(response);
|
|
164
|
-
simulateResult = (0, utility_1.extractSimulateFromResponse)(abciResponse);
|
|
165
|
-
resultErrorKey = (_b = (_a = simulateResult.response_base) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.type_url;
|
|
166
|
-
if (resultErrorKey) {
|
|
167
|
-
throw (0, errors_utility_1.constructRequestError)(resultErrorKey);
|
|
168
|
-
}
|
|
169
|
-
return [2 /*return*/, simulateResult.gas_used.toInt()];
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
WSProvider.prototype.getBalance = function (address, denomination, height) {
|
|
175
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
-
var response, abciResponse;
|
|
177
|
-
return __generator(this, function (_a) {
|
|
178
|
-
switch (_a.label) {
|
|
179
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ABCIEndpoint.ABCI_QUERY, [
|
|
180
|
-
"bank/balances/".concat(address),
|
|
181
|
-
'',
|
|
182
|
-
'0', // Height; not supported > 0 for now
|
|
183
|
-
false,
|
|
184
|
-
]))];
|
|
185
|
-
case 1:
|
|
186
|
-
response = _a.sent();
|
|
187
|
-
abciResponse = this.parseResponse(response);
|
|
188
|
-
return [2 /*return*/, (0, utility_1.extractBalanceFromResponse)(abciResponse.response.ResponseBase.Data, denomination ? denomination : 'ugnot')];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
WSProvider.prototype.getBlock = function (height) {
|
|
194
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
-
var response;
|
|
196
|
-
return __generator(this, function (_a) {
|
|
197
|
-
switch (_a.label) {
|
|
198
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.BlockEndpoint.BLOCK, [height.toString()]))];
|
|
199
|
-
case 1:
|
|
200
|
-
response = _a.sent();
|
|
201
|
-
return [2 /*return*/, this.parseResponse(response)];
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
WSProvider.prototype.getBlockResult = function (height) {
|
|
207
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
-
var response;
|
|
209
|
-
return __generator(this, function (_a) {
|
|
210
|
-
switch (_a.label) {
|
|
211
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.BlockEndpoint.BLOCK_RESULTS, [height.toString()]))];
|
|
212
|
-
case 1:
|
|
213
|
-
response = _a.sent();
|
|
214
|
-
return [2 /*return*/, this.parseResponse(response)];
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
WSProvider.prototype.getBlockNumber = function () {
|
|
220
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
-
var status;
|
|
222
|
-
return __generator(this, function (_a) {
|
|
223
|
-
switch (_a.label) {
|
|
224
|
-
case 0: return [4 /*yield*/, this.getStatus()];
|
|
225
|
-
case 1:
|
|
226
|
-
status = _a.sent();
|
|
227
|
-
return [2 /*return*/, parseInt(status.sync_info.latest_block_height)];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
WSProvider.prototype.getConsensusParams = function (height) {
|
|
233
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
-
var response;
|
|
235
|
-
return __generator(this, function (_a) {
|
|
236
|
-
switch (_a.label) {
|
|
237
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ConsensusEndpoint.CONSENSUS_PARAMS, [height.toString()]))];
|
|
238
|
-
case 1:
|
|
239
|
-
response = _a.sent();
|
|
240
|
-
return [2 /*return*/, this.parseResponse(response)];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
};
|
|
245
|
-
WSProvider.prototype.getGasPrice = function () {
|
|
246
|
-
return Promise.reject('implement me');
|
|
247
|
-
};
|
|
248
|
-
WSProvider.prototype.getNetwork = function () {
|
|
249
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
-
var response;
|
|
251
|
-
return __generator(this, function (_a) {
|
|
252
|
-
switch (_a.label) {
|
|
253
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ConsensusEndpoint.NET_INFO))];
|
|
254
|
-
case 1:
|
|
255
|
-
response = _a.sent();
|
|
256
|
-
return [2 /*return*/, this.parseResponse(response)];
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
|
-
WSProvider.prototype.getAccountSequence = function (address, height) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
-
var response, abciResponse;
|
|
264
|
-
return __generator(this, function (_a) {
|
|
265
|
-
switch (_a.label) {
|
|
266
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ABCIEndpoint.ABCI_QUERY, [
|
|
267
|
-
"auth/accounts/".concat(address),
|
|
268
|
-
'',
|
|
269
|
-
'0', // Height; not supported > 0 for now
|
|
270
|
-
false,
|
|
271
|
-
]))];
|
|
272
|
-
case 1:
|
|
273
|
-
response = _a.sent();
|
|
274
|
-
abciResponse = this.parseResponse(response);
|
|
275
|
-
return [2 /*return*/, (0, utility_1.extractSequenceFromResponse)(abciResponse.response.ResponseBase.Data)];
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
};
|
|
280
|
-
WSProvider.prototype.getAccountNumber = function (address, height) {
|
|
281
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
282
|
-
var response, abciResponse;
|
|
283
|
-
return __generator(this, function (_a) {
|
|
284
|
-
switch (_a.label) {
|
|
285
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ABCIEndpoint.ABCI_QUERY, [
|
|
286
|
-
"auth/accounts/".concat(address),
|
|
287
|
-
'',
|
|
288
|
-
'0', // Height; not supported > 0 for now
|
|
289
|
-
false,
|
|
290
|
-
]))];
|
|
291
|
-
case 1:
|
|
292
|
-
response = _a.sent();
|
|
293
|
-
abciResponse = this.parseResponse(response);
|
|
294
|
-
return [2 /*return*/, (0, utility_1.extractAccountNumberFromResponse)(abciResponse.response.ResponseBase.Data)];
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
WSProvider.prototype.getAccount = function (address, height) {
|
|
300
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
-
var response, abciResponse;
|
|
302
|
-
return __generator(this, function (_a) {
|
|
303
|
-
switch (_a.label) {
|
|
304
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ABCIEndpoint.ABCI_QUERY, [
|
|
305
|
-
"auth/accounts/".concat(address),
|
|
306
|
-
'',
|
|
307
|
-
'0', // Height; not supported > 0 for now
|
|
308
|
-
false,
|
|
309
|
-
]))];
|
|
310
|
-
case 1:
|
|
311
|
-
response = _a.sent();
|
|
312
|
-
abciResponse = this.parseResponse(response);
|
|
313
|
-
return [2 /*return*/, (0, utility_1.extractAccountFromResponse)(abciResponse.response.ResponseBase.Data)];
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
};
|
|
318
|
-
WSProvider.prototype.getStatus = function () {
|
|
319
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
320
|
-
var response;
|
|
321
|
-
return __generator(this, function (_a) {
|
|
322
|
-
switch (_a.label) {
|
|
323
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.CommonEndpoint.STATUS, [null]))];
|
|
324
|
-
case 1:
|
|
325
|
-
response = _a.sent();
|
|
326
|
-
return [2 /*return*/, this.parseResponse(response)];
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
};
|
|
331
|
-
WSProvider.prototype.getTransaction = function (hash) {
|
|
332
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
333
|
-
var response;
|
|
334
|
-
return __generator(this, function (_a) {
|
|
335
|
-
switch (_a.label) {
|
|
336
|
-
case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.TransactionEndpoint.TX, [hash]))];
|
|
337
|
-
case 1:
|
|
338
|
-
response = _a.sent();
|
|
339
|
-
return [2 /*return*/, this.parseResponse(response)];
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
WSProvider.prototype.sendTransaction = function (tx, endpoint) {
|
|
345
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
346
|
-
var request;
|
|
347
|
-
return __generator(this, function (_a) {
|
|
348
|
-
request = (0, utility_1.newRequest)(endpoint, [tx]);
|
|
349
|
-
switch (endpoint) {
|
|
350
|
-
case endpoints_1.TransactionEndpoint.BROADCAST_TX_COMMIT:
|
|
351
|
-
// The endpoint is a commit broadcast
|
|
352
|
-
// (it waits for the transaction to be committed) to the chain before returning
|
|
353
|
-
return [2 /*return*/, this.broadcastTxCommit(request)];
|
|
354
|
-
case endpoints_1.TransactionEndpoint.BROADCAST_TX_SYNC:
|
|
355
|
-
default:
|
|
356
|
-
return [2 /*return*/, this.broadcastTxSync(request)];
|
|
357
|
-
}
|
|
358
|
-
return [2 /*return*/];
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
};
|
|
362
|
-
WSProvider.prototype.broadcastTxSync = function (request) {
|
|
363
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
364
|
-
var response, broadcastResponse, errType, log;
|
|
365
|
-
return __generator(this, function (_a) {
|
|
366
|
-
switch (_a.label) {
|
|
367
|
-
case 0: return [4 /*yield*/, this.sendRequest(request)];
|
|
368
|
-
case 1:
|
|
369
|
-
response = _a.sent();
|
|
370
|
-
broadcastResponse = this.parseResponse(response);
|
|
371
|
-
// Check if there is an immediate tx-broadcast error
|
|
372
|
-
// (originating from basic transaction checks like CheckTx)
|
|
373
|
-
if (broadcastResponse.error) {
|
|
374
|
-
errType = broadcastResponse.error[types_1.ABCIErrorKey];
|
|
375
|
-
log = broadcastResponse.Log;
|
|
376
|
-
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
377
|
-
}
|
|
378
|
-
return [2 /*return*/, broadcastResponse];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
};
|
|
383
|
-
WSProvider.prototype.broadcastTxCommit = function (request) {
|
|
384
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
385
|
-
var response, broadcastResponse, check_tx, deliver_tx, errType, log, errType, log;
|
|
386
|
-
return __generator(this, function (_a) {
|
|
387
|
-
switch (_a.label) {
|
|
388
|
-
case 0: return [4 /*yield*/, this.sendRequest(request)];
|
|
389
|
-
case 1:
|
|
390
|
-
response = _a.sent();
|
|
391
|
-
broadcastResponse = this.parseResponse(response);
|
|
392
|
-
check_tx = broadcastResponse.check_tx, deliver_tx = broadcastResponse.deliver_tx;
|
|
393
|
-
// Check if there is an immediate tx-broadcast error (in CheckTx)
|
|
394
|
-
if (check_tx.ResponseBase.Error) {
|
|
395
|
-
errType = check_tx.ResponseBase.Error[types_1.ABCIErrorKey];
|
|
396
|
-
log = check_tx.ResponseBase.Log;
|
|
397
|
-
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
398
|
-
}
|
|
399
|
-
// Check if there is a parsing error with the transaction (in DeliverTx)
|
|
400
|
-
if (deliver_tx.ResponseBase.Error) {
|
|
401
|
-
errType = deliver_tx.ResponseBase.Error[types_1.ABCIErrorKey];
|
|
402
|
-
log = deliver_tx.ResponseBase.Log;
|
|
403
|
-
throw (0, errors_utility_1.constructRequestError)(errType, log);
|
|
404
|
-
}
|
|
405
|
-
return [2 /*return*/, broadcastResponse];
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
};
|
|
410
|
-
WSProvider.prototype.waitForTransaction = function (hash, fromHeight, timeout) {
|
|
411
|
-
return (0, utility_1.waitForTransaction)(this, hash, fromHeight, timeout);
|
|
412
|
-
};
|
|
413
|
-
return WSProvider;
|
|
414
|
-
}());
|
|
415
|
-
exports.WSProvider = WSProvider;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|