postchain-client 2.1.2 → 2.1.4
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 +8 -0
- package/built/cjs/index.js +3464 -2559
- package/built/cjs/index.js.map +1 -1
- package/built/esm/index.js +4647 -3293
- package/built/esm/index.js.map +1 -1
- package/built/index.js +108 -30
- package/built/index.js.map +1 -1
- package/built/mocks/handlers.js +70 -67
- package/built/mocks/handlers.js.map +1 -1
- package/built/mocks/servers.d.ts +1 -1
- package/built/mocks/servers.js +6 -3
- package/built/mocks/servers.js.map +1 -1
- package/built/resources/testData.js +14 -11
- package/built/resources/testData.js.map +1 -1
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js +39 -29
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js.map +1 -1
- package/built/src/ICCF/error.js +21 -11
- package/built/src/ICCF/error.js.map +1 -1
- package/built/src/ICCF/interfaces.js +2 -1
- package/built/src/ICCF/types.js +2 -1
- package/built/src/ICCF/utils.js +50 -40
- package/built/src/ICCF/utils.js.map +1 -1
- package/built/src/blockchainClient/blockchainClient.js +180 -141
- package/built/src/blockchainClient/blockchainClient.js.map +1 -1
- package/built/src/blockchainClient/clientStub.js +19 -16
- package/built/src/blockchainClient/clientStub.js.map +1 -1
- package/built/src/blockchainClient/enums.js +15 -12
- package/built/src/blockchainClient/enums.js.map +1 -1
- package/built/src/blockchainClient/errors.d.ts +3 -0
- package/built/src/blockchainClient/errors.js +36 -15
- package/built/src/blockchainClient/errors.js.map +1 -1
- package/built/src/blockchainClient/failoverStrategies.js +75 -30
- package/built/src/blockchainClient/failoverStrategies.js.map +1 -1
- package/built/src/blockchainClient/httpUtil.js +45 -9
- package/built/src/blockchainClient/httpUtil.js.map +1 -1
- package/built/src/blockchainClient/interface.js +2 -1
- package/built/src/blockchainClient/nodeManager.js +41 -3
- package/built/src/blockchainClient/nodeManager.js.map +1 -1
- package/built/src/blockchainClient/requestWithFailoverStrategy.js +15 -12
- package/built/src/blockchainClient/requestWithFailoverStrategy.js.map +1 -1
- package/built/src/blockchainClient/types.d.ts +4 -0
- package/built/src/blockchainClient/types.js +2 -1
- package/built/src/blockchainClient/utils.d.ts +3 -1
- package/built/src/blockchainClient/utils.js +242 -153
- package/built/src/blockchainClient/utils.js.map +1 -1
- package/built/src/blockchainClient/validation/anchoringTransaction.js +11 -8
- package/built/src/blockchainClient/validation/anchoringTransaction.js.map +1 -1
- package/built/src/blockchainClient/validation/blockIdentifier.js +10 -6
- package/built/src/blockchainClient/validation/blockIdentifier.js.map +1 -1
- package/built/src/blockchainClient/validation/bufferSchema.js +6 -3
- package/built/src/blockchainClient/validation/bufferSchema.js.map +1 -1
- package/built/src/blockchainClient/validation/merkleHash.js +10 -6
- package/built/src/blockchainClient/validation/merkleHash.js.map +1 -1
- package/built/src/blockchainClient/validation/networkSettings.js +35 -30
- package/built/src/blockchainClient/validation/networkSettings.js.map +1 -1
- package/built/src/blockchainClient/validation/rawGtx.js +18 -15
- package/built/src/blockchainClient/validation/rawGtx.js.map +1 -1
- package/built/src/blockchainClient/validation/requests.js +108 -87
- package/built/src/blockchainClient/validation/requests.js.map +1 -1
- package/built/src/blockchainClient/validation/signMethod.d.ts +8 -8
- package/built/src/blockchainClient/validation/signMethod.js +15 -11
- package/built/src/blockchainClient/validation/signMethod.js.map +1 -1
- package/built/src/blockchainClient/validation/transactionStatusReponse.js +11 -8
- package/built/src/blockchainClient/validation/transactionStatusReponse.js.map +1 -1
- package/built/src/blockchainClient/validation/txRid.d.ts +1 -1
- package/built/src/blockchainClient/validation/txRid.js +10 -6
- package/built/src/blockchainClient/validation/txRid.js.map +1 -1
- package/built/src/blockchainClient/validation/validation.types.js +2 -1
- package/built/src/customError/index.js +5 -1
- package/built/src/customError/index.js.map +1 -1
- package/built/src/encryption/encryption.js +74 -27
- package/built/src/encryption/encryption.js.map +1 -1
- package/built/src/encryption/errors.js +7 -2
- package/built/src/encryption/errors.js.map +1 -1
- package/built/src/encryption/types.js +2 -1
- package/built/src/formatter.js +38 -22
- package/built/src/formatter.js.map +1 -1
- package/built/src/gtv/definition.js +9 -6
- package/built/src/gtv/definition.js.map +1 -1
- package/built/src/gtv/index.js +44 -6
- package/built/src/gtv/index.js.map +1 -1
- package/built/src/gtv/types.js +2 -1
- package/built/src/gtx/errors.js +14 -6
- package/built/src/gtx/errors.js.map +1 -1
- package/built/src/gtx/gtx.js +92 -41
- package/built/src/gtx/gtx.js.map +1 -1
- package/built/src/gtx/index.js +39 -2
- package/built/src/gtx/index.js.map +1 -1
- package/built/src/gtx/serialization.js +26 -18
- package/built/src/gtx/serialization.js.map +1 -1
- package/built/src/gtx/types.js +2 -1
- package/built/src/logger.js +19 -9
- package/built/src/logger.js.map +1 -1
- package/built/src/promiEvent/promiEventEmitter.js +7 -3
- package/built/src/promiEvent/promiEventEmitter.js.map +1 -1
- package/built/src/promiEvent/promiEvents.js +6 -2
- package/built/src/promiEvent/promiEvents.js.map +1 -1
- package/built/src/utils/bufferUtils.js +6 -3
- package/built/src/utils/bufferUtils.js.map +1 -1
- package/built/src/utils/calculateTransactionRid.js +8 -5
- package/built/src/utils/calculateTransactionRid.js.map +1 -1
- package/built/src/utils/constants.js +4 -1
- package/built/src/utils/constants.js.map +1 -1
- package/built/src/utils/decodeTransactionToGtx.js +41 -5
- package/built/src/utils/decodeTransactionToGtx.js.map +1 -1
- package/built/src/utils/dump.js +13 -9
- package/built/src/utils/dump.js.map +1 -1
- package/built/src/utils/encodeTransaction.js +6 -3
- package/built/src/utils/encodeTransaction.js.map +1 -1
- package/built/src/utils/http-utils.js +17 -7
- package/built/src/utils/http-utils.js.map +1 -1
- package/built/test/common/mocks.js +147 -111
- package/built/test/common/mocks.js.map +1 -1
- package/built/test/common/serializationtestobjects.js +13 -7
- package/built/test/common/serializationtestobjects.js.map +1 -1
- package/built/test/common/setups.d.ts +1 -1
- package/built/test/common/setups.js +95 -46
- package/built/test/common/setups.js.map +1 -1
- package/built/test/common/signatures.js +47 -7
- package/built/test/common/signatures.js.map +1 -1
- package/built/test/common/testData.js +4 -1
- package/built/test/common/testData.js.map +1 -1
- package/built/test/common/validationMocks.js +52 -49
- package/built/test/common/validationMocks.js.map +1 -1
- package/built/test/integration/clientGetBlockInfo.test.js +4 -2
- package/built/test/integration/clientGetBlockInfo.test.js.map +1 -1
- package/built/test/integration/clientGetRejectedTransactions.test.js +9 -7
- package/built/test/integration/clientGetRejectedTransactions.test.js.map +1 -1
- package/built/test/integration/clientGetTransaction.test.js +8 -6
- package/built/test/integration/clientGetTransaction.test.js.map +1 -1
- package/built/test/integration/clientGetTransactionStatus.test.js +51 -16
- package/built/test/integration/clientGetTransactionStatus.test.js.map +1 -1
- package/built/test/integration/clientGetWaitingTransaction.test.js +13 -11
- package/built/test/integration/clientGetWaitingTransaction.test.js.map +1 -1
- package/built/test/integration/clientGetWaitingTransactions.test.js +9 -7
- package/built/test/integration/clientGetWaitingTransactions.test.js.map +1 -1
- package/built/test/integration/clientIntegration.test.js +12 -10
- package/built/test/integration/clientIntegration.test.js.map +1 -1
- package/built/test/integration/clientQuery.test.js +61 -26
- package/built/test/integration/clientQuery.test.js.map +1 -1
- package/built/test/integration/clientSendTransaction.test.js +23 -21
- package/built/test/integration/clientSendTransaction.test.js.map +1 -1
- package/built/test/integration/clientSignAndSendUniqueTransaction.test.js +23 -21
- package/built/test/integration/clientSignAndSendUniqueTransaction.test.js.map +1 -1
- package/built/test/integration/clientSignTransaction.test.js +24 -22
- package/built/test/integration/clientSignTransaction.test.js.map +1 -1
- package/built/test/integration/clientUtils.test.js +12 -10
- package/built/test/integration/clientUtils.test.js.map +1 -1
- package/built/test/integration/createClientIntegration.test.js +28 -26
- package/built/test/integration/createClientIntegration.test.js.map +1 -1
- package/built/test/integration/encodeTransaction.test.js +10 -8
- package/built/test/integration/encodeTransaction.test.js.map +1 -1
- package/built/test/integration/failoverStrategiesWithSmartTimeouts.test.js +45 -10
- package/built/test/integration/failoverStrategiesWithSmartTimeouts.test.js.map +1 -1
- package/built/test/integration/getTransactionsInfo.test.js +15 -13
- package/built/test/integration/getTransactionsInfo.test.js.map +1 -1
- package/built/test/integration/signAndSendUniqueTransaction.test.js +16 -14
- package/built/test/integration/signAndSendUniqueTransaction.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/createIccfProofTx.test.js +24 -22
- package/built/test/integrationChromiaNetwork/createIccfProofTx.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/getAnchoringStatusForBlockRid.test.js +15 -13
- package/built/test/integrationChromiaNetwork/getAnchoringStatusForBlockRid.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/getTransactionConfirmationLevel.test.js +10 -8
- package/built/test/integrationChromiaNetwork/getTransactionConfirmationLevel.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/getTransactionStatus.test.js +16 -14
- package/built/test/integrationChromiaNetwork/getTransactionStatus.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/isBlockAnchored.test.js +16 -14
- package/built/test/integrationChromiaNetwork/isBlockAnchored.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/merkleHashIntegration.test.js +21 -19
- package/built/test/integrationChromiaNetwork/merkleHashIntegration.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/nodeDiscovery.test.js +15 -10
- package/built/test/integrationChromiaNetwork/nodeDiscovery.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js +74 -36
- package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.js +17 -15
- package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.js.map +1 -1
- package/built/test/manual/iccfManually.test.js +59 -24
- package/built/test/manual/iccfManually.test.js.map +1 -1
- package/built/test/pcctf/getSuites.test.js +27 -25
- package/built/test/pcctf/getSuites.test.js.map +1 -1
- package/built/test/pcctf/helpers.js +38 -23
- package/built/test/pcctf/helpers.js.map +1 -1
- package/built/test/unit/ICCF/iccf.test.js +77 -75
- package/built/test/unit/ICCF/iccf.test.js.map +1 -1
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.js +112 -58
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.js.map +1 -1
- package/built/test/unit/blockchainClient/client.getRejectedTransactions.test.js +12 -10
- package/built/test/unit/blockchainClient/client.getRejectedTransactions.test.js.map +1 -1
- package/built/test/unit/blockchainClient/client.getWaitingTransaction.test.js +14 -12
- package/built/test/unit/blockchainClient/client.getWaitingTransaction.test.js.map +1 -1
- package/built/test/unit/blockchainClient/client.getWaitingTransactions.test.js +10 -8
- package/built/test/unit/blockchainClient/client.getWaitingTransactions.test.js.map +1 -1
- package/built/test/unit/blockchainClient/client.test.js +89 -54
- package/built/test/unit/blockchainClient/client.test.js.map +1 -1
- package/built/test/unit/blockchainClient/clientCustomStatusCodes.test.js +26 -24
- package/built/test/unit/blockchainClient/clientCustomStatusCodes.test.js.map +1 -1
- package/built/test/unit/blockchainClient/getAnchoringStatusForBlockRid.test.js +52 -17
- package/built/test/unit/blockchainClient/getAnchoringStatusForBlockRid.test.js.map +1 -1
- package/built/test/unit/blockchainClient/getSystemAnchoringTransactionConfirmation.test.js +46 -11
- package/built/test/unit/blockchainClient/getSystemAnchoringTransactionConfirmation.test.js.map +1 -1
- package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js +64 -29
- package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js.map +1 -1
- package/built/test/unit/blockchainClient/sendTransaction.test.js +191 -156
- package/built/test/unit/blockchainClient/sendTransaction.test.js.map +1 -1
- package/built/test/unit/blockchainClient/setMerkleVersion.test.js +15 -13
- package/built/test/unit/blockchainClient/setMerkleVersion.test.js.map +1 -1
- package/built/test/unit/blockchainClient/signAndSendUniqueTransactionPromiEvents.test.js +21 -19
- package/built/test/unit/blockchainClient/signAndSendUniqueTransactionPromiEvents.test.js.map +1 -1
- package/built/test/unit/blockchainClient/statusPollIntervals.test.js +45 -10
- package/built/test/unit/blockchainClient/statusPollIntervals.test.js.map +1 -1
- package/built/test/unit/blockchainClient/util.test.js +119 -31
- package/built/test/unit/blockchainClient/util.test.js.map +1 -1
- package/built/test/unit/decodeTransactionToGtx.test.js +6 -4
- package/built/test/unit/decodeTransactionToGtx.test.js.map +1 -1
- package/built/test/unit/dump.test.js +6 -4
- package/built/test/unit/dump.test.js.map +1 -1
- package/built/test/unit/encryption/encryption.test.js +26 -24
- package/built/test/unit/encryption/encryption.test.js.map +1 -1
- package/built/test/unit/failoverStrategies.test.js +114 -79
- package/built/test/unit/failoverStrategies.test.js.map +1 -1
- package/built/test/unit/failoverStrategies.timeout.test.js +90 -55
- package/built/test/unit/failoverStrategies.timeout.test.js.map +1 -1
- package/built/test/unit/formatter.test.js +23 -21
- package/built/test/unit/formatter.test.js.map +1 -1
- package/built/test/unit/gtv/gtvHash.test.js +13 -11
- package/built/test/unit/gtv/gtvHash.test.js.map +1 -1
- package/built/test/unit/gtx/checkGTXSignature.test.js +18 -16
- package/built/test/unit/gtx/checkGTXSignature.test.js.map +1 -1
- package/built/test/unit/gtx/newSignatureProvider.test.js +14 -12
- package/built/test/unit/gtx/newSignatureProvider.test.js.map +1 -1
- package/built/test/unit/gtx/serialization.test.js +47 -42
- package/built/test/unit/gtx/serialization.test.js.map +1 -1
- package/built/test/unit/httpUtil.test.js +13 -11
- package/built/test/unit/httpUtil.test.js.map +1 -1
- package/built/test/unit/httpUtil.timeout.test.js +12 -10
- package/built/test/unit/httpUtil.timeout.test.js.map +1 -1
- package/built/test/unit/logger.test.js +42 -40
- package/built/test/unit/logger.test.js.map +1 -1
- package/built/test/unit/networkErrorDetection.test.js +39 -37
- package/built/test/unit/networkErrorDetection.test.js.map +1 -1
- package/built/test/unit/nodeMananger.test.js +19 -17
- package/built/test/unit/nodeMananger.test.js.map +1 -1
- package/built/test/unit/setOrdering.test.js +7 -5
- package/built/test/unit/setOrdering.test.js.map +1 -1
- package/built/test/unit/smartTimeouts.test.js +20 -18
- package/built/test/unit/smartTimeouts.test.js.map +1 -1
- package/built/test/unit/stickyNode.test.js +19 -17
- package/built/test/unit/stickyNode.test.js.map +1 -1
- package/built/test/unit/universalNodeRecovery.test.js +54 -19
- package/built/test/unit/universalNodeRecovery.test.js.map +1 -1
- package/built/test/unit/validation/anchoringTransaction.test.js +12 -10
- package/built/test/unit/validation/anchoringTransaction.test.js.map +1 -1
- package/built/test/unit/validation/blockIdentifier.test.js +10 -8
- package/built/test/unit/validation/blockIdentifier.test.js.map +1 -1
- package/built/test/unit/validation/bufferSchema.test.js +8 -6
- package/built/test/unit/validation/bufferSchema.test.js.map +1 -1
- package/built/test/unit/validation/networkSettings.test.js +14 -12
- package/built/test/unit/validation/networkSettings.test.js.map +1 -1
- package/built/test/unit/validation/rawGtx.test.js +24 -22
- package/built/test/unit/validation/rawGtx.test.js.map +1 -1
- package/built/test/unit/validation/requests.test.js +56 -54
- package/built/test/unit/validation/requests.test.js.map +1 -1
- package/built/test/unit/validation/signMethod.test.js +11 -9
- package/built/test/unit/validation/signMethod.test.js.map +1 -1
- package/built/test/unit/validation/statusObject.test.js +21 -19
- package/built/test/unit/validation/statusObject.test.js.map +1 -1
- package/built/test/unit/validation/txRid.test.js +10 -8
- package/built/test/unit/validation/txRid.test.js.map +1 -1
- package/built/umd/index.js +4656 -3372
- package/built/umd/index.js.map +1 -1
- package/changelog.md +8 -4
- package/package.json +2 -2
|
@@ -1,3 +1,37 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
1
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,35 +41,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
42
|
});
|
|
9
43
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.sleep = exports.getUrlsFromEndpoints = exports.createEndpointObjects = exports.defaultFailoverConfig = exports.isKeyPair = exports.formatBlockInfoResponse = exports.formatTransactionInfoResponse = exports.handlePostResponsePromisified = exports.callbackPromiseBuilder = void 0;
|
|
46
|
+
exports.getClientConfigFromSettings = getClientConfigFromSettings;
|
|
47
|
+
exports.getMerkleHashVersionFromDapp = getMerkleHashVersionFromDapp;
|
|
48
|
+
exports.validTxRid = validTxRid;
|
|
49
|
+
exports.nodeDiscovery = nodeDiscovery;
|
|
50
|
+
exports.getBlockchainApiUrls = getBlockchainApiUrls;
|
|
51
|
+
exports.convertToRellOperation = convertToRellOperation;
|
|
52
|
+
exports.getSerializedGTX = getSerializedGTX;
|
|
53
|
+
exports.getGTXFromBufferOrTransactionOrOperation = getGTXFromBufferOrTransactionOrOperation;
|
|
54
|
+
exports.formatRejectedTransactionFromResponse = formatRejectedTransactionFromResponse;
|
|
55
|
+
exports.getSystemClient = getSystemClient;
|
|
56
|
+
exports.getSystemAnchoringChain = getSystemAnchoringChain;
|
|
57
|
+
exports.awaitDappConfirmation = awaitDappConfirmation;
|
|
58
|
+
exports.awaitClusterAnchoringChainConfirmation = awaitClusterAnchoringChainConfirmation;
|
|
59
|
+
exports.handleDappConfirmations = handleDappConfirmations;
|
|
60
|
+
exports.handleSystemConfirmations = handleSystemConfirmations;
|
|
61
|
+
exports.getAnchoringClientAndSystemChainRid = getAnchoringClientAndSystemChainRid;
|
|
62
|
+
exports.getSystemAnchoringTransaction = getSystemAnchoringTransaction;
|
|
63
|
+
exports.setStatusPolling = setStatusPolling;
|
|
64
|
+
exports.setRetryTransactionPolling = setRetryTransactionPolling;
|
|
65
|
+
exports.linkPromiEvents = linkPromiEvents;
|
|
66
|
+
exports.handleGetResponse = handleGetResponse;
|
|
67
|
+
exports.handlePostResponse = handlePostResponse;
|
|
68
|
+
exports.getBlockchainRidFromIid = getBlockchainRidFromIid;
|
|
69
|
+
exports.convertToPrintable = convertToPrintable;
|
|
70
|
+
const buffer_1 = require("buffer");
|
|
71
|
+
const logger = __importStar(require("../logger"));
|
|
72
|
+
const errors_1 = require("./errors");
|
|
73
|
+
const gtxTool = __importStar(require("../gtx/gtx"));
|
|
74
|
+
const errors_2 = require("./errors");
|
|
75
|
+
const formatter_1 = require("../formatter");
|
|
76
|
+
const blockchainClient_1 = require("./blockchainClient");
|
|
77
|
+
const enums_1 = require("./enums");
|
|
78
|
+
const nodeManager_1 = require("./nodeManager");
|
|
79
|
+
const anchoringTransaction_1 = require("./validation/anchoringTransaction");
|
|
80
|
+
const error_1 = require("../ICCF/error");
|
|
81
|
+
const IccfProofTxMaterialBuilder_1 = require("../ICCF/IccfProofTxMaterialBuilder");
|
|
82
|
+
const utils_1 = require("../ICCF/utils");
|
|
83
|
+
const requests_1 = require("./validation/requests");
|
|
84
|
+
const encodeTransaction_1 = require("../utils/encodeTransaction");
|
|
85
|
+
const merkleHash_1 = require("./validation/merkleHash");
|
|
86
|
+
const requestWithFailoverStrategy_1 = require("./requestWithFailoverStrategy");
|
|
87
|
+
const constants_1 = require("../utils/constants");
|
|
88
|
+
const http_utils_1 = require("../utils/http-utils");
|
|
89
|
+
function getClientConfigFromSettings(settings) {
|
|
30
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
91
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
32
92
|
const nodeUrlPoolToUse = yield getNodeUrlsFromSettings(settings);
|
|
33
93
|
if (nodeUrlPoolToUse === null || nodeUrlPoolToUse.length === 0) {
|
|
34
94
|
const id = (_b = (_a = settings.blockchainRid) !== null && _a !== void 0 ? _a : settings.blockchainIid) !== null && _b !== void 0 ? _b : "Unknown";
|
|
35
|
-
throw new BlockchainUrlUndefinedException(id);
|
|
95
|
+
throw new errors_2.BlockchainUrlUndefinedException(id);
|
|
36
96
|
}
|
|
37
|
-
const endpointPool = createEndpointObjects(nodeUrlPoolToUse);
|
|
38
|
-
const nodeManager = createNodeManager({
|
|
97
|
+
const endpointPool = (0, exports.createEndpointObjects)(nodeUrlPoolToUse);
|
|
98
|
+
const nodeManager = (0, nodeManager_1.createNodeManager)({
|
|
39
99
|
nodeUrls: nodeUrlPoolToUse,
|
|
40
100
|
useStickyNode: (_c = settings.useStickyNode) !== null && _c !== void 0 ? _c : false,
|
|
41
101
|
unavailableDuration: (_d = settings.failOverConfig) === null || _d === void 0 ? void 0 : _d.unreachableDuration,
|
|
@@ -50,12 +110,12 @@ export function getClientConfigFromSettings(settings) {
|
|
|
50
110
|
nodeManager,
|
|
51
111
|
endpointPool,
|
|
52
112
|
chainId: settings.blockchainIid,
|
|
53
|
-
merkleHashVersion: (_a = settings.merkleHashVersion) !== null && _a !== void 0 ? _a : MERKLE_HASH_VERSIONS.UNSET,
|
|
113
|
+
merkleHashVersion: (_a = settings.merkleHashVersion) !== null && _a !== void 0 ? _a : constants_1.MERKLE_HASH_VERSIONS.UNSET,
|
|
54
114
|
connectTimeout: settings.connectTimeout,
|
|
55
115
|
responseTimeout: settings.responseTimeout,
|
|
56
116
|
});
|
|
57
117
|
}
|
|
58
|
-
throw new MissingBlockchainIdentifierError();
|
|
118
|
+
throw new errors_2.MissingBlockchainIdentifierError();
|
|
59
119
|
}))();
|
|
60
120
|
const directoryChainRid = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
61
121
|
var _a;
|
|
@@ -67,59 +127,45 @@ export function getClientConfigFromSettings(settings) {
|
|
|
67
127
|
nodeManager,
|
|
68
128
|
endpointPool,
|
|
69
129
|
chainId: directoryChainIid,
|
|
70
|
-
merkleHashVersion: (_a = settings.merkleHashVersion) !== null && _a !== void 0 ? _a : MERKLE_HASH_VERSIONS.UNSET,
|
|
130
|
+
merkleHashVersion: (_a = settings.merkleHashVersion) !== null && _a !== void 0 ? _a : constants_1.MERKLE_HASH_VERSIONS.UNSET,
|
|
71
131
|
connectTimeout: settings.connectTimeout,
|
|
72
132
|
responseTimeout: settings.responseTimeout,
|
|
73
133
|
});
|
|
74
134
|
}))();
|
|
75
|
-
return {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
blockchainRid: blockchainRidToUse,
|
|
79
|
-
merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e : MERKLE_HASH_VERSIONS.UNSET,
|
|
80
|
-
dappStatusPolling: setStatusPolling(settings.dappStatusPolling),
|
|
81
|
-
clusterAnchoringStatusPolling: setStatusPolling(settings.clusterAnchoringStatusPolling),
|
|
82
|
-
systemAnchoringStatusPolling: setStatusPolling(settings.systemAnchoringStatusPolling),
|
|
83
|
-
retryTransactionPolling: setRetryTransactionPolling(settings.retryTransactionPolling),
|
|
84
|
-
failoverStrategy: ((_f = settings.failOverConfig) === null || _f === void 0 ? void 0 : _f.strategy) || defaultFailoverConfig.strategy,
|
|
85
|
-
attemptsPerEndpoint: ((_g = settings.failOverConfig) === null || _g === void 0 ? void 0 : _g.attemptsPerEndpoint) || defaultFailoverConfig.attemptsPerEndpoint,
|
|
86
|
-
attemptInterval: ((_h = settings.failOverConfig) === null || _h === void 0 ? void 0 : _h.attemptInterval) || defaultFailoverConfig.attemptInterval,
|
|
87
|
-
unreachableDuration: ((_j = settings.failOverConfig) === null || _j === void 0 ? void 0 : _j.unreachableDuration) || defaultFailoverConfig.unreachableDuration,
|
|
88
|
-
directoryChainRid: settings.directoryChainRid || directoryChainRid,
|
|
89
|
-
connectTimeout: settings.connectTimeout,
|
|
90
|
-
responseTimeout: settings.responseTimeout,
|
|
91
|
-
};
|
|
135
|
+
return Object.assign(Object.assign(Object.assign({ endpointPool, nodeManager: nodeManager }, (settings.blockedNodeUrlSubstrings !== undefined
|
|
136
|
+
? { blockedNodeUrlSubstrings: settings.blockedNodeUrlSubstrings }
|
|
137
|
+
: {})), (settings.nodeUrlFilter !== undefined ? { nodeUrlFilter: settings.nodeUrlFilter } : {})), { blockchainRid: blockchainRidToUse, merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e : constants_1.MERKLE_HASH_VERSIONS.UNSET, dappStatusPolling: setStatusPolling(settings.dappStatusPolling), clusterAnchoringStatusPolling: setStatusPolling(settings.clusterAnchoringStatusPolling), systemAnchoringStatusPolling: setStatusPolling(settings.systemAnchoringStatusPolling), retryTransactionPolling: setRetryTransactionPolling(settings.retryTransactionPolling), failoverStrategy: ((_f = settings.failOverConfig) === null || _f === void 0 ? void 0 : _f.strategy) || exports.defaultFailoverConfig.strategy, attemptsPerEndpoint: ((_g = settings.failOverConfig) === null || _g === void 0 ? void 0 : _g.attemptsPerEndpoint) || exports.defaultFailoverConfig.attemptsPerEndpoint, attemptInterval: ((_h = settings.failOverConfig) === null || _h === void 0 ? void 0 : _h.attemptInterval) || exports.defaultFailoverConfig.attemptInterval, unreachableDuration: ((_j = settings.failOverConfig) === null || _j === void 0 ? void 0 : _j.unreachableDuration) || exports.defaultFailoverConfig.unreachableDuration, directoryChainRid: settings.directoryChainRid || directoryChainRid, connectTimeout: settings.connectTimeout, responseTimeout: settings.responseTimeout });
|
|
92
138
|
});
|
|
93
139
|
}
|
|
94
|
-
|
|
140
|
+
function getMerkleHashVersionFromDapp(config) {
|
|
95
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
142
|
var _a;
|
|
97
143
|
try {
|
|
98
|
-
const response = yield requestWithFailoverStrategy(Method.GET, `/config/${config.blockchainRid}/features`, config, undefined, false, (_a = config.connectTimeout) !== null && _a !== void 0 ? _a : config.responseTimeout);
|
|
99
|
-
const validatedResponse = validateMerkleHash(response.rspBody);
|
|
144
|
+
const response = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_1.Method.GET, `/config/${config.blockchainRid}/features`, config, undefined, false, (_a = config.connectTimeout) !== null && _a !== void 0 ? _a : config.responseTimeout);
|
|
145
|
+
const validatedResponse = (0, merkleHash_1.validateMerkleHash)(response.rspBody);
|
|
100
146
|
return validatedResponse.merkle_hash_version;
|
|
101
147
|
}
|
|
102
148
|
catch (error) {
|
|
103
149
|
console.warn("MERKLE_HASH_WARNING: version not found or endpoint unreachable", error);
|
|
104
|
-
return MERKLE_HASH_VERSIONS.ONE;
|
|
150
|
+
return constants_1.MERKLE_HASH_VERSIONS.ONE;
|
|
105
151
|
}
|
|
106
152
|
});
|
|
107
153
|
}
|
|
108
|
-
|
|
154
|
+
function validTxRid(txRID) {
|
|
109
155
|
if (txRID.length != 32) {
|
|
110
|
-
const error = new InvalidTxRidException(txRID);
|
|
156
|
+
const error = new errors_1.InvalidTxRidException(txRID);
|
|
111
157
|
logger.error(error.toString());
|
|
112
158
|
return false;
|
|
113
159
|
}
|
|
114
160
|
return true;
|
|
115
161
|
}
|
|
116
|
-
|
|
117
|
-
return __awaiter(this, arguments, void 0, function* ({ nodeManager, directoryEndpointPool, failOverConfig, blockchainRid, blockchainIid, connectTimeout, responseTimeout, }) {
|
|
162
|
+
function nodeDiscovery(_a) {
|
|
163
|
+
return __awaiter(this, arguments, void 0, function* ({ nodeManager, directoryEndpointPool, blockedNodeUrlSubstrings, nodeUrlFilter, failOverConfig, blockchainRid, blockchainIid, connectTimeout, responseTimeout, }) {
|
|
118
164
|
if (directoryEndpointPool.length === 0) {
|
|
119
|
-
throw new DirectoryNodeUrlPoolException();
|
|
165
|
+
throw new errors_2.DirectoryNodeUrlPoolException();
|
|
120
166
|
}
|
|
121
167
|
if (!blockchainRid && blockchainIid === undefined) {
|
|
122
|
-
throw new MissingBlockchainIdentifierError();
|
|
168
|
+
throw new errors_2.MissingBlockchainIdentifierError();
|
|
123
169
|
}
|
|
124
170
|
const directoryIid = 0;
|
|
125
171
|
const directoryBRID = yield getBlockchainRidFromIid({
|
|
@@ -144,16 +190,20 @@ export function nodeDiscovery(_a) {
|
|
|
144
190
|
responseTimeout,
|
|
145
191
|
});
|
|
146
192
|
}
|
|
147
|
-
throw new MissingBlockchainIdentifierError();
|
|
193
|
+
throw new errors_2.MissingBlockchainIdentifierError();
|
|
148
194
|
}))();
|
|
149
|
-
const D1Client = yield createClient({
|
|
150
|
-
nodeUrlPool: getUrlsFromEndpoints(directoryEndpointPool),
|
|
195
|
+
const D1Client = yield (0, blockchainClient_1.createClient)({
|
|
196
|
+
nodeUrlPool: (0, exports.getUrlsFromEndpoints)(directoryEndpointPool),
|
|
151
197
|
blockchainRid: directoryBRID,
|
|
152
198
|
});
|
|
153
|
-
|
|
199
|
+
const discoveredNodes = yield getBlockchainApiUrls(D1Client, (0, formatter_1.ensureBuffer)(blockchainRidToUse));
|
|
200
|
+
return applyNodeUrlFilters(discoveredNodes, {
|
|
201
|
+
blockedNodeUrlSubstrings,
|
|
202
|
+
nodeUrlFilter,
|
|
203
|
+
}, "discoveredNodeUrlPool");
|
|
154
204
|
});
|
|
155
205
|
}
|
|
156
|
-
|
|
206
|
+
function getBlockchainApiUrls(directoryClient, blockchainRid) {
|
|
157
207
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
208
|
const queryObject = {
|
|
159
209
|
name: "cm_get_blockchain_api_urls",
|
|
@@ -162,7 +212,7 @@ export function getBlockchainApiUrls(directoryClient, blockchainRid) {
|
|
|
162
212
|
return yield directoryClient.query(queryObject);
|
|
163
213
|
});
|
|
164
214
|
}
|
|
165
|
-
|
|
215
|
+
function convertToRellOperation(operations) {
|
|
166
216
|
return operations.map(operation => {
|
|
167
217
|
var _a;
|
|
168
218
|
return {
|
|
@@ -171,20 +221,20 @@ export function convertToRellOperation(operations) {
|
|
|
171
221
|
};
|
|
172
222
|
});
|
|
173
223
|
}
|
|
174
|
-
|
|
175
|
-
const gtxBytes = encodeTransaction(gtx);
|
|
176
|
-
if (!Buffer.isBuffer(gtxBytes)) {
|
|
177
|
-
throw new SerializedTransactionFormatException();
|
|
224
|
+
function getSerializedGTX(gtx) {
|
|
225
|
+
const gtxBytes = (0, encodeTransaction_1.encodeTransaction)(gtx);
|
|
226
|
+
if (!buffer_1.Buffer.isBuffer(gtxBytes)) {
|
|
227
|
+
throw new errors_1.SerializedTransactionFormatException();
|
|
178
228
|
}
|
|
179
229
|
return gtxBytes;
|
|
180
230
|
}
|
|
181
|
-
|
|
182
|
-
if (Buffer.isBuffer(transaction)) {
|
|
231
|
+
function getGTXFromBufferOrTransactionOrOperation(transaction, blockchainRid) {
|
|
232
|
+
if (buffer_1.Buffer.isBuffer(transaction)) {
|
|
183
233
|
return gtxTool.deserialize(transaction);
|
|
184
234
|
}
|
|
185
235
|
else if ("operations" in transaction) {
|
|
186
236
|
return {
|
|
187
|
-
blockchainRid: ensureBuffer(blockchainRid),
|
|
237
|
+
blockchainRid: (0, formatter_1.ensureBuffer)(blockchainRid),
|
|
188
238
|
operations: convertToRellOperation(transaction.operations),
|
|
189
239
|
signers: transaction.signers,
|
|
190
240
|
signatures: [],
|
|
@@ -192,17 +242,17 @@ export function getGTXFromBufferOrTransactionOrOperation(transaction, blockchain
|
|
|
192
242
|
}
|
|
193
243
|
else if ("name" in transaction) {
|
|
194
244
|
return {
|
|
195
|
-
blockchainRid: ensureBuffer(blockchainRid),
|
|
245
|
+
blockchainRid: (0, formatter_1.ensureBuffer)(blockchainRid),
|
|
196
246
|
operations: convertToRellOperation([transaction]),
|
|
197
247
|
signers: [],
|
|
198
248
|
signatures: [],
|
|
199
249
|
};
|
|
200
250
|
}
|
|
201
251
|
else {
|
|
202
|
-
throw new InvalidTransactionFormatException();
|
|
252
|
+
throw new errors_2.InvalidTransactionFormatException();
|
|
203
253
|
}
|
|
204
254
|
}
|
|
205
|
-
|
|
255
|
+
const callbackPromiseBuilder = (reject, resolve, callback) => {
|
|
206
256
|
return (error, result) => {
|
|
207
257
|
var _a;
|
|
208
258
|
if (error) {
|
|
@@ -215,7 +265,8 @@ export const callbackPromiseBuilder = (reject, resolve, callback) => {
|
|
|
215
265
|
}
|
|
216
266
|
};
|
|
217
267
|
};
|
|
218
|
-
|
|
268
|
+
exports.callbackPromiseBuilder = callbackPromiseBuilder;
|
|
269
|
+
const handlePostResponsePromisified = (error, statusCode, rspBody) => {
|
|
219
270
|
return new Promise((resolve, reject) => {
|
|
220
271
|
handlePostResponse(error, statusCode, rspBody, _error => {
|
|
221
272
|
if (_error) {
|
|
@@ -227,75 +278,86 @@ export const handlePostResponsePromisified = (error, statusCode, rspBody) => {
|
|
|
227
278
|
});
|
|
228
279
|
});
|
|
229
280
|
};
|
|
281
|
+
exports.handlePostResponsePromisified = handlePostResponsePromisified;
|
|
230
282
|
function ensureArray(input) {
|
|
231
283
|
if (typeof input === "string") {
|
|
232
284
|
return [input];
|
|
233
285
|
}
|
|
234
286
|
return input;
|
|
235
287
|
}
|
|
236
|
-
|
|
288
|
+
const formatTransactionInfoResponse = (transactionInfoResponse) => {
|
|
237
289
|
return {
|
|
238
|
-
blockRid: toBuffer(transactionInfoResponse.blockRID),
|
|
290
|
+
blockRid: (0, formatter_1.toBuffer)(transactionInfoResponse.blockRID),
|
|
239
291
|
blockHeight: transactionInfoResponse.blockHeight,
|
|
240
|
-
blockHeader: toBuffer(transactionInfoResponse.blockHeader),
|
|
241
|
-
witness: toBuffer(transactionInfoResponse.witness),
|
|
292
|
+
blockHeader: (0, formatter_1.toBuffer)(transactionInfoResponse.blockHeader),
|
|
293
|
+
witness: (0, formatter_1.toBuffer)(transactionInfoResponse.witness),
|
|
242
294
|
timestamp: transactionInfoResponse.timestamp,
|
|
243
|
-
txRid: toBuffer(transactionInfoResponse.txRID),
|
|
244
|
-
txHash: toBuffer(transactionInfoResponse.txHash),
|
|
245
|
-
txData: toBuffer(transactionInfoResponse.txData),
|
|
295
|
+
txRid: (0, formatter_1.toBuffer)(transactionInfoResponse.txRID),
|
|
296
|
+
txHash: (0, formatter_1.toBuffer)(transactionInfoResponse.txHash),
|
|
297
|
+
txData: (0, formatter_1.toBuffer)(transactionInfoResponse.txData),
|
|
246
298
|
};
|
|
247
299
|
};
|
|
248
|
-
|
|
300
|
+
exports.formatTransactionInfoResponse = formatTransactionInfoResponse;
|
|
301
|
+
const formatBlockInfoResponse = (blockInfoResponse) => {
|
|
249
302
|
return {
|
|
250
|
-
rid: toBuffer(blockInfoResponse.rid),
|
|
251
|
-
prevBlockRid: toBuffer(blockInfoResponse.prevBlockRID),
|
|
252
|
-
header: toBuffer(blockInfoResponse.header),
|
|
303
|
+
rid: (0, formatter_1.toBuffer)(blockInfoResponse.rid),
|
|
304
|
+
prevBlockRid: (0, formatter_1.toBuffer)(blockInfoResponse.prevBlockRID),
|
|
305
|
+
header: (0, formatter_1.toBuffer)(blockInfoResponse.header),
|
|
253
306
|
transactions: blockInfoResponse.transactions.map(formatTransaction),
|
|
254
307
|
height: blockInfoResponse.height,
|
|
255
|
-
witness: toBuffer(blockInfoResponse.witness),
|
|
308
|
+
witness: (0, formatter_1.toBuffer)(blockInfoResponse.witness),
|
|
256
309
|
witnesses: blockInfoResponse.witnesses.map(witness => {
|
|
257
|
-
return toBuffer(witness);
|
|
310
|
+
return (0, formatter_1.toBuffer)(witness);
|
|
258
311
|
}),
|
|
259
312
|
timestamp: blockInfoResponse.timestamp,
|
|
260
313
|
};
|
|
261
314
|
};
|
|
315
|
+
exports.formatBlockInfoResponse = formatBlockInfoResponse;
|
|
262
316
|
const formatTransaction = (transaction) => {
|
|
263
317
|
const formattedTransaction = {
|
|
264
|
-
rid: toBuffer(transaction.rid),
|
|
265
|
-
hash: toBuffer(transaction.hash),
|
|
318
|
+
rid: (0, formatter_1.toBuffer)(transaction.rid),
|
|
319
|
+
hash: (0, formatter_1.toBuffer)(transaction.hash),
|
|
266
320
|
};
|
|
267
321
|
if (transaction.data !== undefined) {
|
|
268
|
-
formattedTransaction.data = toBuffer(transaction.data);
|
|
322
|
+
formattedTransaction.data = (0, formatter_1.toBuffer)(transaction.data);
|
|
269
323
|
}
|
|
270
324
|
return formattedTransaction;
|
|
271
325
|
};
|
|
272
|
-
|
|
326
|
+
function formatRejectedTransactionFromResponse(rejectedTransactionResponse) {
|
|
273
327
|
return {
|
|
274
|
-
txRid: toBuffer(rejectedTransactionResponse.txRID),
|
|
328
|
+
txRid: (0, formatter_1.toBuffer)(rejectedTransactionResponse.txRID),
|
|
275
329
|
rejectReason: rejectedTransactionResponse.rejectReason,
|
|
276
330
|
rejectTimestamp: rejectedTransactionResponse.rejectTimestamp,
|
|
277
331
|
};
|
|
278
332
|
}
|
|
279
|
-
|
|
333
|
+
const isKeyPair = (keypair) => {
|
|
280
334
|
return (typeof keypair === "object" &&
|
|
281
335
|
keypair !== null &&
|
|
282
336
|
"privKey" in keypair &&
|
|
283
337
|
"pubKey" in keypair &&
|
|
284
|
-
keypair.privKey instanceof Buffer &&
|
|
285
|
-
keypair.pubKey instanceof Buffer);
|
|
338
|
+
keypair.privKey instanceof buffer_1.Buffer &&
|
|
339
|
+
keypair.pubKey instanceof buffer_1.Buffer);
|
|
286
340
|
};
|
|
341
|
+
exports.isKeyPair = isKeyPair;
|
|
287
342
|
function getNodeUrlsFromSettings(settings) {
|
|
288
343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
289
344
|
var _a;
|
|
290
345
|
if (settings.directoryNodeUrlPool) {
|
|
346
|
+
const directoryNodeUrlsOrNull = applyNodeUrlFilters(ensureArray(settings.directoryNodeUrlPool), settings, "directoryNodeUrlPool");
|
|
347
|
+
if (directoryNodeUrlsOrNull === null) {
|
|
348
|
+
throw new errors_2.DirectoryNodeUrlPoolException();
|
|
349
|
+
}
|
|
350
|
+
const directoryNodeUrls = directoryNodeUrlsOrNull;
|
|
291
351
|
// If directoryNodeUrlPool is provided, use nodeDiscovery
|
|
292
|
-
const nodeManager = createNodeManager({
|
|
293
|
-
nodeUrls:
|
|
352
|
+
const nodeManager = (0, nodeManager_1.createNodeManager)({
|
|
353
|
+
nodeUrls: directoryNodeUrls,
|
|
294
354
|
unavailableDuration: (_a = settings.failOverConfig) === null || _a === void 0 ? void 0 : _a.unreachableDuration,
|
|
295
355
|
});
|
|
296
356
|
const discoveredNodes = yield nodeDiscovery({
|
|
297
357
|
nodeManager,
|
|
298
|
-
directoryEndpointPool:
|
|
358
|
+
directoryEndpointPool: (0, exports.createEndpointObjects)(directoryNodeUrls),
|
|
359
|
+
blockedNodeUrlSubstrings: settings.blockedNodeUrlSubstrings,
|
|
360
|
+
nodeUrlFilter: settings.nodeUrlFilter,
|
|
299
361
|
failOverConfig: settings.failOverConfig,
|
|
300
362
|
blockchainRid: settings.blockchainRid,
|
|
301
363
|
blockchainIid: settings.blockchainIid,
|
|
@@ -306,11 +368,11 @@ function getNodeUrlsFromSettings(settings) {
|
|
|
306
368
|
}
|
|
307
369
|
else if (typeof settings.nodeUrlPool === "string") {
|
|
308
370
|
// If nodeUrlPool is a string, convert it to an array
|
|
309
|
-
return [settings.nodeUrlPool];
|
|
371
|
+
return applyNodeUrlFilters([settings.nodeUrlPool], settings, "nodeUrlPool");
|
|
310
372
|
}
|
|
311
373
|
else if (Array.isArray(settings.nodeUrlPool)) {
|
|
312
374
|
// If nodeUrlPool is already an array, use it as-is
|
|
313
|
-
return settings.nodeUrlPool;
|
|
375
|
+
return applyNodeUrlFilters(settings.nodeUrlPool, settings, "nodeUrlPool");
|
|
314
376
|
}
|
|
315
377
|
else {
|
|
316
378
|
// Default to an empty array if no valid configuration is provided
|
|
@@ -318,15 +380,39 @@ function getNodeUrlsFromSettings(settings) {
|
|
|
318
380
|
}
|
|
319
381
|
});
|
|
320
382
|
}
|
|
321
|
-
|
|
383
|
+
function applyNodeUrlFilters(nodeUrls, settings, poolName) {
|
|
384
|
+
var _a;
|
|
385
|
+
if (nodeUrls === null) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
const hasBlockedSubstringsFilter = Array.isArray(settings.blockedNodeUrlSubstrings) &&
|
|
389
|
+
settings.blockedNodeUrlSubstrings.length > 0;
|
|
390
|
+
const hasNodeUrlFilter = typeof settings.nodeUrlFilter === "function";
|
|
391
|
+
if (!hasBlockedSubstringsFilter && !hasNodeUrlFilter) {
|
|
392
|
+
return nodeUrls;
|
|
393
|
+
}
|
|
394
|
+
const blockedSubstrings = ((_a = settings.blockedNodeUrlSubstrings) !== null && _a !== void 0 ? _a : [])
|
|
395
|
+
.map(substring => substring.toLowerCase())
|
|
396
|
+
.filter(substring => substring.length > 0);
|
|
397
|
+
const filteredNodeUrls = nodeUrls.filter(url => {
|
|
398
|
+
const isBlockedBySubstring = blockedSubstrings.some(substring => url.toLowerCase().includes(substring));
|
|
399
|
+
const passesCustomFilter = settings.nodeUrlFilter ? settings.nodeUrlFilter(url) : true;
|
|
400
|
+
return !isBlockedBySubstring && passesCustomFilter;
|
|
401
|
+
});
|
|
402
|
+
if (filteredNodeUrls.length === 0) {
|
|
403
|
+
throw new errors_2.FilteredNodeUrlPoolEmptyError(poolName);
|
|
404
|
+
}
|
|
405
|
+
return filteredNodeUrls;
|
|
406
|
+
}
|
|
407
|
+
function getSystemClient(directoryNodeUrlPool, directoryChainRid) {
|
|
322
408
|
return __awaiter(this, void 0, void 0, function* () {
|
|
323
|
-
return yield createClient({
|
|
409
|
+
return yield (0, blockchainClient_1.createClient)({
|
|
324
410
|
directoryNodeUrlPool,
|
|
325
411
|
blockchainRid: directoryChainRid,
|
|
326
412
|
});
|
|
327
413
|
});
|
|
328
414
|
}
|
|
329
|
-
|
|
415
|
+
function getSystemAnchoringChain(directoryClient) {
|
|
330
416
|
return __awaiter(this, void 0, void 0, function* () {
|
|
331
417
|
try {
|
|
332
418
|
const queryObject = {
|
|
@@ -334,64 +420,66 @@ export function getSystemAnchoringChain(directoryClient) {
|
|
|
334
420
|
};
|
|
335
421
|
const systemAnchoringChain = yield directoryClient.query(queryObject);
|
|
336
422
|
if (!systemAnchoringChain) {
|
|
337
|
-
throw new SystemChainException("Directory chain client must be provided.");
|
|
423
|
+
throw new error_1.SystemChainException("Directory chain client must be provided.");
|
|
338
424
|
}
|
|
339
425
|
return systemAnchoringChain;
|
|
340
426
|
}
|
|
341
427
|
catch (error) {
|
|
342
|
-
throw new SystemChainException(error.message);
|
|
428
|
+
throw new error_1.SystemChainException(error.message);
|
|
343
429
|
}
|
|
344
430
|
});
|
|
345
431
|
}
|
|
346
|
-
|
|
347
|
-
strategy: FailoverStrategy.AbortOnError,
|
|
432
|
+
exports.defaultFailoverConfig = {
|
|
433
|
+
strategy: enums_1.FailoverStrategy.AbortOnError,
|
|
348
434
|
attemptsPerEndpoint: 3,
|
|
349
435
|
attemptInterval: 500,
|
|
350
436
|
unreachableDuration: 30000,
|
|
351
437
|
};
|
|
352
|
-
|
|
438
|
+
const createEndpointObjects = (endpointPoolUrls) => {
|
|
353
439
|
const endpoints = endpointPoolUrls.map(endpointUrl => {
|
|
354
440
|
return { url: endpointUrl, whenAvailable: 0 };
|
|
355
441
|
});
|
|
356
442
|
return endpoints;
|
|
357
443
|
};
|
|
358
|
-
|
|
444
|
+
exports.createEndpointObjects = createEndpointObjects;
|
|
445
|
+
const getUrlsFromEndpoints = (endpointPool) => {
|
|
359
446
|
return endpointPool.map(endpoint => endpoint.url);
|
|
360
447
|
};
|
|
361
|
-
|
|
448
|
+
exports.getUrlsFromEndpoints = getUrlsFromEndpoints;
|
|
449
|
+
function awaitDappConfirmation(txRID, dappStatusPolling, getTransactionStatus) {
|
|
362
450
|
return __awaiter(this, void 0, void 0, function* () {
|
|
363
451
|
var _a;
|
|
364
452
|
let lastKnownResult = null;
|
|
365
453
|
for (let i = 0; i < dappStatusPolling.count; i++) {
|
|
366
454
|
lastKnownResult = yield getTransactionStatus(txRID);
|
|
367
|
-
if (lastKnownResult.status === ResponseStatus.Confirmed) {
|
|
455
|
+
if (lastKnownResult.status === enums_1.ResponseStatus.Confirmed) {
|
|
368
456
|
return lastKnownResult;
|
|
369
457
|
}
|
|
370
|
-
else if (lastKnownResult.status === ResponseStatus.Rejected) {
|
|
371
|
-
throw new TxRejectedError((_a = lastKnownResult.rejectReason) !== null && _a !== void 0 ? _a : "");
|
|
458
|
+
else if (lastKnownResult.status === enums_1.ResponseStatus.Rejected) {
|
|
459
|
+
throw new errors_1.TxRejectedError((_a = lastKnownResult.rejectReason) !== null && _a !== void 0 ? _a : "");
|
|
372
460
|
}
|
|
373
|
-
yield sleep(dappStatusPolling.interval);
|
|
461
|
+
yield (0, exports.sleep)(dappStatusPolling.interval);
|
|
374
462
|
}
|
|
375
463
|
throw new Error(`Retry count exceeded. Confirmation not received. Last transaction status: ${lastKnownResult === null || lastKnownResult === void 0 ? void 0 : lastKnownResult.status}`);
|
|
376
464
|
});
|
|
377
465
|
}
|
|
378
|
-
|
|
466
|
+
function awaitClusterAnchoringChainConfirmation(txRID, clusterAnchoringStatusPolling, getClusterAnchoringTransactionConfirmation) {
|
|
379
467
|
return __awaiter(this, void 0, void 0, function* () {
|
|
380
468
|
var _a;
|
|
381
469
|
let clusterAnchoringConfirmation;
|
|
382
470
|
for (let i = 0; i < clusterAnchoringStatusPolling.count; i++) {
|
|
383
471
|
clusterAnchoringConfirmation = yield getClusterAnchoringTransactionConfirmation(txRID);
|
|
384
|
-
const anchoringTransactionValidaiton = AnchoringTransactionSchema.safeParse(clusterAnchoringConfirmation);
|
|
472
|
+
const anchoringTransactionValidaiton = anchoringTransaction_1.AnchoringTransactionSchema.safeParse(clusterAnchoringConfirmation);
|
|
385
473
|
if (anchoringTransactionValidaiton.success) {
|
|
386
474
|
return {
|
|
387
|
-
status: AnchoringStatus.ClusterAnchored,
|
|
475
|
+
status: enums_1.AnchoringStatus.ClusterAnchored,
|
|
388
476
|
clusterAnchoredTx: anchoringTransactionValidaiton.data,
|
|
389
477
|
};
|
|
390
478
|
}
|
|
391
479
|
else if (!anchoringTransactionValidaiton.success) {
|
|
392
|
-
throw new TxRejectedError((_a = AnchoringStatus.FailedAnchoring) !== null && _a !== void 0 ? _a : "");
|
|
480
|
+
throw new errors_1.TxRejectedError((_a = enums_1.AnchoringStatus.FailedAnchoring) !== null && _a !== void 0 ? _a : "");
|
|
393
481
|
}
|
|
394
|
-
yield sleep(clusterAnchoringStatusPolling.interval);
|
|
482
|
+
yield (0, exports.sleep)(clusterAnchoringStatusPolling.interval);
|
|
395
483
|
}
|
|
396
484
|
// TS issue. This could be fixed by implementing new retry strategy
|
|
397
485
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -399,70 +487,70 @@ export function awaitClusterAnchoringChainConfirmation(txRID, clusterAnchoringSt
|
|
|
399
487
|
return clusterAnchoringConfirmation;
|
|
400
488
|
});
|
|
401
489
|
}
|
|
402
|
-
|
|
490
|
+
function handleDappConfirmations(transactionRid, doStatusPolling, confirmationLevel, promiEvent, dappStatusPolling, getTransactionStatus, client) {
|
|
403
491
|
return __awaiter(this, void 0, void 0, function* () {
|
|
404
492
|
var _a, _b;
|
|
405
493
|
const transactionReceipt = {
|
|
406
|
-
status: ResponseStatus.Pending,
|
|
494
|
+
status: enums_1.ResponseStatus.Pending,
|
|
407
495
|
statusCode: null,
|
|
408
496
|
transactionRid: transactionRid,
|
|
409
497
|
node: (_a = client.config.nodeManager.lastUsedNode) === null || _a === void 0 ? void 0 : _a.url,
|
|
410
498
|
};
|
|
411
|
-
promiEvent.emit(TransactionEvent.DappReceived, transactionReceipt);
|
|
412
|
-
if (doStatusPolling === false || confirmationLevel === ChainConfirmationLevel.None) {
|
|
499
|
+
promiEvent.emit(enums_1.TransactionEvent.DappReceived, transactionReceipt);
|
|
500
|
+
if (doStatusPolling === false || confirmationLevel === enums_1.ChainConfirmationLevel.None) {
|
|
413
501
|
return transactionReceipt;
|
|
414
502
|
}
|
|
415
503
|
const dappConfirmationStatus = yield awaitDappConfirmation(transactionRid, dappStatusPolling, getTransactionStatus);
|
|
416
504
|
transactionReceipt.statusCode = dappConfirmationStatus.statusCode;
|
|
417
505
|
transactionReceipt.status = dappConfirmationStatus.status;
|
|
418
506
|
transactionReceipt.node = (_b = client.config.nodeManager.lastUsedNode) === null || _b === void 0 ? void 0 : _b.url;
|
|
419
|
-
promiEvent.emit(TransactionEvent.DappConfirmed, transactionReceipt);
|
|
420
|
-
if (confirmationLevel === ChainConfirmationLevel.Dapp) {
|
|
507
|
+
promiEvent.emit(enums_1.TransactionEvent.DappConfirmed, transactionReceipt);
|
|
508
|
+
if (confirmationLevel === enums_1.ChainConfirmationLevel.Dapp) {
|
|
421
509
|
return transactionReceipt;
|
|
422
510
|
}
|
|
423
511
|
return transactionReceipt;
|
|
424
512
|
});
|
|
425
513
|
}
|
|
426
|
-
|
|
514
|
+
function handleSystemConfirmations(transactionReceipt, confirmationLevel, promiEvent, statusPollingConfig, anchoringClient, systemAnchoringChainBrid, getClusterAnchoringTransactionConfirmation, getSystemAnchoringTransactionConfirmation) {
|
|
427
515
|
return __awaiter(this, void 0, void 0, function* () {
|
|
428
516
|
const clusterAnchoringChainConfirmation = yield awaitClusterAnchoringChainConfirmation(transactionReceipt.transactionRid, statusPollingConfig.clusterAnchoringStatusPolling, getClusterAnchoringTransactionConfirmation);
|
|
429
517
|
transactionReceipt.status = clusterAnchoringChainConfirmation.status;
|
|
430
518
|
transactionReceipt.clusterAnchoredTx = clusterAnchoringChainConfirmation.clusterAnchoredTx;
|
|
431
519
|
transactionReceipt.clusterAnchoringClientBrid = anchoringClient.config.blockchainRid;
|
|
432
|
-
promiEvent.emit(TransactionEvent.ClusterAnchoringConfirmation, transactionReceipt);
|
|
433
|
-
if (confirmationLevel === ChainConfirmationLevel.ClusterAnchoring) {
|
|
520
|
+
promiEvent.emit(enums_1.TransactionEvent.ClusterAnchoringConfirmation, transactionReceipt);
|
|
521
|
+
if (confirmationLevel === enums_1.ChainConfirmationLevel.ClusterAnchoring) {
|
|
434
522
|
return transactionReceipt;
|
|
435
523
|
}
|
|
436
524
|
const systemAnchoringConfirmation = yield getSystemAnchoringTransactionConfirmation(clusterAnchoringChainConfirmation.clusterAnchoredTx.txRid, anchoringClient, systemAnchoringChainBrid);
|
|
437
525
|
if (!systemAnchoringConfirmation) {
|
|
438
526
|
return transactionReceipt;
|
|
439
527
|
}
|
|
440
|
-
transactionReceipt.status = AnchoringStatus.SystemAnchored;
|
|
528
|
+
transactionReceipt.status = enums_1.AnchoringStatus.SystemAnchored;
|
|
441
529
|
transactionReceipt.systemAnchoredTx = systemAnchoringConfirmation;
|
|
442
530
|
transactionReceipt.systemAnchoringClientBrid = systemAnchoringChainBrid;
|
|
443
|
-
promiEvent.emit(TransactionEvent.SystemAnchoringConfirmation, transactionReceipt);
|
|
444
|
-
if (confirmationLevel === ChainConfirmationLevel.SystemAnchoring) {
|
|
531
|
+
promiEvent.emit(enums_1.TransactionEvent.SystemAnchoringConfirmation, transactionReceipt);
|
|
532
|
+
if (confirmationLevel === enums_1.ChainConfirmationLevel.SystemAnchoring) {
|
|
445
533
|
return transactionReceipt;
|
|
446
534
|
}
|
|
447
535
|
return transactionReceipt;
|
|
448
536
|
});
|
|
449
537
|
}
|
|
450
|
-
|
|
538
|
+
function getAnchoringClientAndSystemChainRid(client) {
|
|
451
539
|
return __awaiter(this, void 0, void 0, function* () {
|
|
452
|
-
const directoryClient = yield getSystemClient(getUrlsFromEndpoints(client.config.endpointPool), client.config.directoryChainRid);
|
|
453
|
-
const anchoringClient = yield getAnchoringClient(directoryClient, client.config.blockchainRid);
|
|
540
|
+
const directoryClient = yield getSystemClient((0, exports.getUrlsFromEndpoints)(client.config.endpointPool), client.config.directoryChainRid);
|
|
541
|
+
const anchoringClient = yield (0, IccfProofTxMaterialBuilder_1.getAnchoringClient)(directoryClient, client.config.blockchainRid);
|
|
454
542
|
const systemAnchoringChainRidBuffer = yield getSystemAnchoringChain(directoryClient);
|
|
455
543
|
const systemAnchoringChainBridString = systemAnchoringChainRidBuffer.toString("hex");
|
|
456
544
|
return { anchoringClient, systemAnchoringChainBridString };
|
|
457
545
|
});
|
|
458
546
|
}
|
|
459
|
-
|
|
547
|
+
function getSystemAnchoringTransaction(dappClientEndpointPool, anchoredTxRid, anchoringClient, systemAnchoringChainRid, systemAnchoringStatusPolling, merkleHashVersion) {
|
|
460
548
|
return __awaiter(this, void 0, void 0, function* () {
|
|
461
|
-
const systemAnchoringChainClient = yield getSystemClient(getUrlsFromEndpoints(dappClientEndpointPool), systemAnchoringChainRid);
|
|
549
|
+
const systemAnchoringChainClient = yield getSystemClient((0, exports.getUrlsFromEndpoints)(dappClientEndpointPool), systemAnchoringChainRid);
|
|
462
550
|
const clusterAnchoringProof = yield anchoringClient.getConfirmationProof(anchoredTxRid);
|
|
463
|
-
const clusterBlockRid = calculateBlockRID(clusterAnchoringProof, merkleHashVersion);
|
|
464
|
-
const systemAnchoringTransactionConfirmation = yield awaitGetAnchoringTransactionForBlockRid(systemAnchoringChainClient, toBuffer(anchoringClient.config.blockchainRid), clusterBlockRid, systemAnchoringStatusPolling);
|
|
465
|
-
const systemAnchoringTransactionValidation = AnchoringTransactionSchema.safeParse(systemAnchoringTransactionConfirmation);
|
|
551
|
+
const clusterBlockRid = (0, utils_1.calculateBlockRID)(clusterAnchoringProof, merkleHashVersion);
|
|
552
|
+
const systemAnchoringTransactionConfirmation = yield (0, utils_1.awaitGetAnchoringTransactionForBlockRid)(systemAnchoringChainClient, (0, formatter_1.toBuffer)(anchoringClient.config.blockchainRid), clusterBlockRid, systemAnchoringStatusPolling);
|
|
553
|
+
const systemAnchoringTransactionValidation = anchoringTransaction_1.AnchoringTransactionSchema.safeParse(systemAnchoringTransactionConfirmation);
|
|
466
554
|
if (!systemAnchoringTransactionValidation.success) {
|
|
467
555
|
return null;
|
|
468
556
|
}
|
|
@@ -479,22 +567,22 @@ export function getSystemAnchoringTransaction(dappClientEndpointPool, anchoredTx
|
|
|
479
567
|
* @returns - Returns a complete `StatusPolling` configuration object, with default values for any missing properties
|
|
480
568
|
* of the provided partial configuration
|
|
481
569
|
*/
|
|
482
|
-
|
|
570
|
+
function setStatusPolling(statusPolling) {
|
|
483
571
|
var _a, _b;
|
|
484
572
|
return {
|
|
485
573
|
interval: (_a = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.interval) !== null && _a !== void 0 ? _a : 500,
|
|
486
574
|
count: (_b = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.count) !== null && _b !== void 0 ? _b : 20,
|
|
487
575
|
};
|
|
488
576
|
}
|
|
489
|
-
|
|
577
|
+
function setRetryTransactionPolling(statusPolling) {
|
|
490
578
|
var _a, _b;
|
|
491
579
|
return {
|
|
492
580
|
interval: (_a = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.interval) !== null && _a !== void 0 ? _a : 500,
|
|
493
581
|
count: (_b = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.count) !== null && _b !== void 0 ? _b : 3,
|
|
494
582
|
};
|
|
495
583
|
}
|
|
496
|
-
|
|
497
|
-
const transactionEvents = Object.values(TransactionEvent).filter((event) => typeof event === "string");
|
|
584
|
+
function linkPromiEvents(event1, event2) {
|
|
585
|
+
const transactionEvents = Object.values(enums_1.TransactionEvent).filter((event) => typeof event === "string");
|
|
498
586
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
499
587
|
const forwardEvent = (eventName) => (receipt) => event2.emit(eventName, receipt);
|
|
500
588
|
for (const eventName of transactionEvents) {
|
|
@@ -507,7 +595,7 @@ export function linkPromiEvents(event1, event2) {
|
|
|
507
595
|
* @param responseObject the responsebody from the server
|
|
508
596
|
* @param callback the callback function to propagate the error and response back to the caller
|
|
509
597
|
*/
|
|
510
|
-
|
|
598
|
+
function handleGetResponse(error, statusCode, responseObject, callback) {
|
|
511
599
|
try {
|
|
512
600
|
const responseObjectPrintable = convertToPrintable(responseObject);
|
|
513
601
|
logger.debug(`error: ${error}, status code: ${statusCode}, response body: ${responseObjectPrintable}`);
|
|
@@ -515,7 +603,7 @@ export function handleGetResponse(error, statusCode, responseObject, callback) {
|
|
|
515
603
|
return callback(error, null);
|
|
516
604
|
}
|
|
517
605
|
if (statusCode !== 200) {
|
|
518
|
-
return callback(new UnexpectedStatusError(statusCode !== null && statusCode !== void 0 ? statusCode : 400, responseObjectPrintable), null);
|
|
606
|
+
return callback(new errors_1.UnexpectedStatusError(statusCode !== null && statusCode !== void 0 ? statusCode : 400, responseObjectPrintable), null);
|
|
519
607
|
}
|
|
520
608
|
return callback(null, responseObject);
|
|
521
609
|
}
|
|
@@ -530,7 +618,7 @@ export function handleGetResponse(error, statusCode, responseObject, callback) {
|
|
|
530
618
|
* @param responseObject the responsebody from the server
|
|
531
619
|
* @param callback the callback function to propagate the error and response back to the caller
|
|
532
620
|
*/
|
|
533
|
-
|
|
621
|
+
function handlePostResponse(error, statusCode, responseObject, callback) {
|
|
534
622
|
var _a;
|
|
535
623
|
const responseObjectPrintable = convertToPrintable(responseObject);
|
|
536
624
|
logger.debug(`error: ${error}, status code: ${statusCode}, response body: ${responseObjectPrintable}`);
|
|
@@ -539,7 +627,7 @@ export function handlePostResponse(error, statusCode, responseObject, callback)
|
|
|
539
627
|
logger.error(`In client post(). ${error}`);
|
|
540
628
|
callback(error, null);
|
|
541
629
|
}
|
|
542
|
-
else if (!statusCode || !isSuccessfulStatusCode(statusCode)) {
|
|
630
|
+
else if (!statusCode || !(0, http_utils_1.isSuccessfulStatusCode)(statusCode)) {
|
|
543
631
|
let errorMessage = `Unexpected status code from server. Code: ${statusCode}.`;
|
|
544
632
|
const errorMessageInResponseBody = !!responseObject && typeof responseObject === "object" && "error" in responseObject
|
|
545
633
|
? (_a = responseObject.error) === null || _a === void 0 ? void 0 : _a.toString()
|
|
@@ -548,7 +636,7 @@ export function handlePostResponse(error, statusCode, responseObject, callback)
|
|
|
548
636
|
errorMessage += ` Message: ${responseObjectPrintable}.`;
|
|
549
637
|
}
|
|
550
638
|
logger.error(errorMessage);
|
|
551
|
-
callback(new UnexpectedStatusError(statusCode !== null && statusCode !== void 0 ? statusCode : 400, errorMessageInResponseBody || responseObjectPrintable), responseObject);
|
|
639
|
+
callback(new errors_1.UnexpectedStatusError(statusCode !== null && statusCode !== void 0 ? statusCode : 400, errorMessageInResponseBody || responseObjectPrintable), responseObject);
|
|
552
640
|
}
|
|
553
641
|
else {
|
|
554
642
|
logger.info(`Calling responseCallback with responseObject: ${responseObjectPrintable}`);
|
|
@@ -559,10 +647,10 @@ export function handlePostResponse(error, statusCode, responseObject, callback)
|
|
|
559
647
|
logger.error(`client.handlePostResponse(): Failed to call callback function ${error}`);
|
|
560
648
|
}
|
|
561
649
|
}
|
|
562
|
-
|
|
650
|
+
function getBlockchainRidFromIid(_a) {
|
|
563
651
|
return __awaiter(this, arguments, void 0, function* ({ endpointPool, chainId, failOverConfig = {}, nodeManager, connectTimeout, responseTimeout, }) {
|
|
564
652
|
var _b;
|
|
565
|
-
const mergedFailOverConfig = Object.assign(Object.assign({}, defaultFailoverConfig), failOverConfig);
|
|
653
|
+
const mergedFailOverConfig = Object.assign(Object.assign({}, exports.defaultFailoverConfig), failOverConfig);
|
|
566
654
|
const config = {
|
|
567
655
|
endpointPool,
|
|
568
656
|
nodeManager,
|
|
@@ -574,26 +662,27 @@ export function getBlockchainRidFromIid(_a) {
|
|
|
574
662
|
attemptsPerEndpoint: mergedFailOverConfig.attemptsPerEndpoint,
|
|
575
663
|
attemptInterval: mergedFailOverConfig.attemptInterval,
|
|
576
664
|
unreachableDuration: mergedFailOverConfig.unreachableDuration,
|
|
577
|
-
merkleHashVersion: MERKLE_HASH_VERSIONS.UNSET,
|
|
665
|
+
merkleHashVersion: constants_1.MERKLE_HASH_VERSIONS.UNSET,
|
|
578
666
|
connectTimeout,
|
|
579
667
|
responseTimeout,
|
|
580
668
|
};
|
|
581
|
-
const { error, statusCode, rspBody } = yield requestWithFailoverStrategy(Method.GET, `/brid/iid_${chainId}`, config, undefined, false, (_b = config.connectTimeout) !== null && _b !== void 0 ? _b : config.responseTimeout);
|
|
582
|
-
const blockchainRid = isString(rspBody);
|
|
669
|
+
const { error, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_1.Method.GET, `/brid/iid_${chainId}`, config, undefined, false, (_b = config.connectTimeout) !== null && _b !== void 0 ? _b : config.responseTimeout);
|
|
670
|
+
const blockchainRid = (0, requests_1.isString)(rspBody);
|
|
583
671
|
if (!blockchainRid) {
|
|
584
672
|
throw error;
|
|
585
673
|
}
|
|
586
674
|
if (error) {
|
|
587
|
-
throw new GetBridFromChainException(chainId, error.message);
|
|
675
|
+
throw new errors_1.GetBridFromChainException(chainId, error.message);
|
|
588
676
|
}
|
|
589
677
|
else if (statusCode !== 200) {
|
|
590
|
-
throw new GetBridFromChainException(chainId, blockchainRid);
|
|
678
|
+
throw new errors_1.GetBridFromChainException(chainId, blockchainRid);
|
|
591
679
|
}
|
|
592
680
|
return blockchainRid;
|
|
593
681
|
});
|
|
594
682
|
}
|
|
595
|
-
|
|
596
|
-
|
|
683
|
+
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
684
|
+
exports.sleep = sleep;
|
|
685
|
+
function convertToPrintable(responseObject) {
|
|
597
686
|
if (typeof responseObject === "bigint") {
|
|
598
687
|
return `${responseObject}n`;
|
|
599
688
|
}
|