postchain-client 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/cjs/index.js +99 -25
- package/built/cjs/index.js.map +1 -1
- package/built/esm/index.js +99 -25
- package/built/esm/index.js.map +1 -1
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js +1 -1
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js.map +1 -1
- package/built/src/ICCF/utils.js.map +1 -1
- package/built/src/blockchainClient/blockchainClient.js +61 -3
- package/built/src/blockchainClient/blockchainClient.js.map +1 -1
- package/built/src/blockchainClient/clientStub.js +5 -1
- package/built/src/blockchainClient/clientStub.js.map +1 -1
- package/built/src/blockchainClient/enums.d.ts +2 -1
- package/built/src/blockchainClient/enums.js +1 -0
- package/built/src/blockchainClient/enums.js.map +1 -1
- package/built/src/blockchainClient/failoverStrategies.js +3 -1
- package/built/src/blockchainClient/failoverStrategies.js.map +1 -1
- package/built/src/blockchainClient/interface.d.ts +1 -0
- package/built/src/blockchainClient/types.d.ts +3 -1
- package/built/src/blockchainClient/utils.d.ts +2 -1
- package/built/src/blockchainClient/utils.js +15 -13
- package/built/src/blockchainClient/utils.js.map +1 -1
- package/built/src/gtv/index.js +7 -0
- package/built/src/gtv/index.js.map +1 -1
- package/built/src/gtx/gtx.d.ts +1 -1
- package/built/src/gtx/gtx.js +3 -3
- package/built/src/gtx/gtx.js.map +1 -1
- package/built/src/utils/constants.d.ts +1 -0
- package/built/src/utils/constants.js +1 -0
- package/built/src/utils/constants.js.map +1 -1
- package/built/test/common/mocks.d.ts +17 -0
- package/built/test/common/mocks.js +21 -1
- package/built/test/common/mocks.js.map +1 -1
- package/built/test/integration/clientGetTransactionStatus.test.js +2 -2
- package/built/test/integration/clientGetTransactionStatus.test.js.map +1 -1
- package/built/test/integration/clientQuery.test.js +2 -2
- package/built/test/integration/clientQuery.test.js.map +1 -1
- package/built/test/integration/clientSendTransaction.test.js +1 -1
- package/built/test/integration/clientSendTransaction.test.js.map +1 -1
- package/built/test/integration/clientSignAndSendUniqueTransaction.test.js +1 -1
- package/built/test/integration/clientSignAndSendUniqueTransaction.test.js.map +1 -1
- package/built/test/integration/createClientIntegration.test.js +3 -0
- package/built/test/integration/createClientIntegration.test.js.map +1 -1
- package/built/test/integration/signAndSendUniqueTransaction.test.js +7 -6
- package/built/test/integration/signAndSendUniqueTransaction.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/getTransactionConfirmationLevel.test.js +1 -0
- package/built/test/integrationChromiaNetwork/getTransactionConfirmationLevel.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js +4 -3
- package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.js +10 -7
- package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.js.map +1 -1
- package/built/test/pcctf/getSuites.test.js +1 -1
- package/built/test/pcctf/getSuites.test.js.map +1 -1
- package/built/test/pcctf/helpers.js +1 -1
- package/built/test/pcctf/helpers.js.map +1 -1
- package/built/test/unit/blockchainClient/client.test.js +2 -1
- package/built/test/unit/blockchainClient/client.test.js.map +1 -1
- package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js +2 -2
- package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js.map +1 -1
- package/built/test/unit/blockchainClient/sendTransaction.test.js +14 -8
- package/built/test/unit/blockchainClient/sendTransaction.test.js.map +1 -1
- package/built/test/unit/blockchainClient/statusPollIntervals.test.js +35 -28
- package/built/test/unit/blockchainClient/statusPollIntervals.test.js.map +1 -1
- package/built/test/unit/failoverStrategies.test.js +15 -14
- package/built/test/unit/failoverStrategies.test.js.map +1 -1
- package/built/test/unit/gtv/gtvHash.test.js +44 -0
- package/built/test/unit/gtv/gtvHash.test.js.map +1 -1
- package/built/test/unit/gtx/newSignatureProvider.test.js +4 -4
- package/built/test/unit/gtx/newSignatureProvider.test.js.map +1 -1
- package/built/test/unit/httpUtil.test.js +4 -0
- package/built/test/unit/httpUtil.test.js.map +1 -1
- package/built/umd/index.js +99 -25
- package/built/umd/index.js.map +1 -1
- package/changelog.md +3 -1
- package/package.json +1 -1
package/built/esm/index.js
CHANGED
|
@@ -33200,7 +33200,19 @@ function sortDictPairByKey(dict) {
|
|
|
33200
33200
|
return sortedDict;
|
|
33201
33201
|
}
|
|
33202
33202
|
|
|
33203
|
+
const MERKLE_HASH_VERSIONS = {
|
|
33204
|
+
ONE: 1,
|
|
33205
|
+
TWO: 2,
|
|
33206
|
+
UNSET: NaN,
|
|
33207
|
+
};
|
|
33208
|
+
|
|
33203
33209
|
const gtvHash2 = (obj, merkleHashVersion) => {
|
|
33210
|
+
if (!Object.values(MERKLE_HASH_VERSIONS).includes(merkleHashVersion)) {
|
|
33211
|
+
throw new Error("Merkle hash version is not valid");
|
|
33212
|
+
}
|
|
33213
|
+
if (isNaN(merkleHashVersion)) {
|
|
33214
|
+
throw new Error("Merkle hash version is not set");
|
|
33215
|
+
}
|
|
33204
33216
|
return gtvHash_1(obj, merkleHashVersion);
|
|
33205
33217
|
};
|
|
33206
33218
|
const encode$1 = encodeValue;
|
|
@@ -34173,7 +34185,7 @@ function sign(gtx, privOrSigProv, merkleHashVersion, pubKey) {
|
|
|
34173
34185
|
else {
|
|
34174
34186
|
// Removes signatures and extract the rawgtxBody
|
|
34175
34187
|
const rawGtxBody = gtxToRawGtxBody(gtx);
|
|
34176
|
-
const signature = yield privOrSigProv.sign(rawGtxBody);
|
|
34188
|
+
const signature = yield privOrSigProv.sign(rawGtxBody, merkleHashVersion);
|
|
34177
34189
|
return addSignature(privOrSigProv.pubKey, signature, gtx);
|
|
34178
34190
|
}
|
|
34179
34191
|
});
|
|
@@ -34243,7 +34255,7 @@ function checkExistingGTXSignatures(txHash, gtx) {
|
|
|
34243
34255
|
}
|
|
34244
34256
|
return true;
|
|
34245
34257
|
}
|
|
34246
|
-
function newSignatureProvider(
|
|
34258
|
+
function newSignatureProvider(keyPair) {
|
|
34247
34259
|
let pub, priv;
|
|
34248
34260
|
if (keyPair) {
|
|
34249
34261
|
priv = ensureBuffer(keyPair.privKey);
|
|
@@ -34254,7 +34266,7 @@ function newSignatureProvider(merkleHashVersion, keyPair) {
|
|
|
34254
34266
|
}
|
|
34255
34267
|
return {
|
|
34256
34268
|
pubKey: pub,
|
|
34257
|
-
sign: (gtx) => __awaiter$9(this, void 0, void 0, function* () {
|
|
34269
|
+
sign: (gtx, merkleHashVersion) => __awaiter$9(this, void 0, void 0, function* () {
|
|
34258
34270
|
const signature = getDigestToSignFromRawGtxBody(gtx, merkleHashVersion);
|
|
34259
34271
|
return signDigest(signature, priv);
|
|
34260
34272
|
}),
|
|
@@ -37347,6 +37359,7 @@ var TransactionEvent;
|
|
|
37347
37359
|
TransactionEvent["DappConfirmed"] = "dappConfirmed";
|
|
37348
37360
|
TransactionEvent["DappReceived"] = "dappReceived";
|
|
37349
37361
|
TransactionEvent["Signed"] = "signed";
|
|
37362
|
+
TransactionEvent["Rejected"] = "rejected";
|
|
37350
37363
|
})(TransactionEvent || (TransactionEvent = {}));
|
|
37351
37364
|
var AnchoringStatus;
|
|
37352
37365
|
(function (AnchoringStatus) {
|
|
@@ -37655,11 +37668,6 @@ function encodeTransaction(gtx) {
|
|
|
37655
37668
|
return serialize(gtx);
|
|
37656
37669
|
}
|
|
37657
37670
|
|
|
37658
|
-
const MERKLE_HASH_VERSIONS = {
|
|
37659
|
-
ONE: 1,
|
|
37660
|
-
TWO: 2,
|
|
37661
|
-
};
|
|
37662
|
-
|
|
37663
37671
|
const MerkleHashSchema = z.object({
|
|
37664
37672
|
merkle_hash_version: z.number().int().positive(),
|
|
37665
37673
|
});
|
|
@@ -37942,7 +37950,8 @@ function retryRequest({ method, path, config, postObject, validateStatusCode, })
|
|
|
37942
37950
|
let error = null;
|
|
37943
37951
|
let transactionTimestamp = undefined;
|
|
37944
37952
|
const { nodeManager } = config;
|
|
37945
|
-
|
|
37953
|
+
const availableNodes = nodeManager.getAvailableNodes();
|
|
37954
|
+
for (const endpoint of availableNodes) {
|
|
37946
37955
|
for (let attempt = 0; attempt < config.attemptsPerEndpoint; attempt++) {
|
|
37947
37956
|
const response = yield handleRequest(method, path, endpoint.url, postObject);
|
|
37948
37957
|
error = (_a = response === null || response === void 0 ? void 0 : response.error) !== null && _a !== void 0 ? _a : null;
|
|
@@ -37953,6 +37962,7 @@ function retryRequest({ method, path, config, postObject, validateStatusCode, })
|
|
|
37953
37962
|
const isServerError = statusCode ? hasServerError(statusCode) : false;
|
|
37954
37963
|
if (isStatusCodeValid && !error) {
|
|
37955
37964
|
// Find a way to have this handled more elegantly in the node manager.
|
|
37965
|
+
nodeManager.lastUsedNode = endpoint;
|
|
37956
37966
|
if (nodeManager.stickedNode !== endpoint) {
|
|
37957
37967
|
nodeManager.setStickyNode(endpoint);
|
|
37958
37968
|
}
|
|
@@ -38103,7 +38113,7 @@ function getClientConfigFromSettings(settings) {
|
|
|
38103
38113
|
nodeManager,
|
|
38104
38114
|
endpointPool,
|
|
38105
38115
|
chainId: settings.blockchainIid,
|
|
38106
|
-
merkleHashVersion: (_k = settings.merkleHashVersion) !== null && _k !== void 0 ? _k :
|
|
38116
|
+
merkleHashVersion: (_k = settings.merkleHashVersion) !== null && _k !== void 0 ? _k : MERKLE_HASH_VERSIONS.UNSET,
|
|
38107
38117
|
});
|
|
38108
38118
|
}
|
|
38109
38119
|
throw new MissingBlockchainIdentifierError();
|
|
@@ -38118,17 +38128,18 @@ function getClientConfigFromSettings(settings) {
|
|
|
38118
38128
|
nodeManager,
|
|
38119
38129
|
endpointPool,
|
|
38120
38130
|
chainId: directoryChainIid,
|
|
38121
|
-
merkleHashVersion: (_l = settings.merkleHashVersion) !== null && _l !== void 0 ? _l :
|
|
38131
|
+
merkleHashVersion: (_l = settings.merkleHashVersion) !== null && _l !== void 0 ? _l : MERKLE_HASH_VERSIONS.UNSET,
|
|
38122
38132
|
});
|
|
38123
38133
|
}))();
|
|
38124
38134
|
return {
|
|
38125
38135
|
endpointPool,
|
|
38126
38136
|
nodeManager: nodeManager,
|
|
38127
38137
|
blockchainRid: blockchainRidToUse,
|
|
38128
|
-
merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e :
|
|
38138
|
+
merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e : MERKLE_HASH_VERSIONS.UNSET,
|
|
38129
38139
|
dappStatusPolling: setStatusPolling(settings.dappStatusPolling),
|
|
38130
38140
|
clusterAnchoringStatusPolling: setStatusPolling(settings.clusterAnchoringStatusPolling),
|
|
38131
38141
|
systemAnchoringStatusPolling: setStatusPolling(settings.systemAnchoringStatusPolling),
|
|
38142
|
+
retryTransactionPolling: setRetryTransactionPolling(settings.retryTransactionPolling),
|
|
38132
38143
|
failoverStrategy: ((_f = settings.failOverConfig) === null || _f === void 0 ? void 0 : _f.strategy) || defaultFailoverConfig.strategy,
|
|
38133
38144
|
attemptsPerEndpoint: ((_g = settings.failOverConfig) === null || _g === void 0 ? void 0 : _g.attemptsPerEndpoint) || defaultFailoverConfig.attemptsPerEndpoint,
|
|
38134
38145
|
attemptInterval: ((_h = settings.failOverConfig) === null || _h === void 0 ? void 0 : _h.attemptInterval) || defaultFailoverConfig.attemptInterval,
|
|
@@ -38164,7 +38175,6 @@ function nodeDiscovery({ nodeManager, directoryEndpointPool, failOverConfig, blo
|
|
|
38164
38175
|
endpointPool: directoryEndpointPool,
|
|
38165
38176
|
chainId: directoryIid,
|
|
38166
38177
|
failOverConfig,
|
|
38167
|
-
merkleHashVersion: 0,
|
|
38168
38178
|
});
|
|
38169
38179
|
const blockchainRidToUse = yield (() => __awaiter$5(this, void 0, void 0, function* () {
|
|
38170
38180
|
if (blockchainRid) {
|
|
@@ -38176,7 +38186,6 @@ function nodeDiscovery({ nodeManager, directoryEndpointPool, failOverConfig, blo
|
|
|
38176
38186
|
endpointPool: directoryEndpointPool,
|
|
38177
38187
|
chainId: blockchainIid,
|
|
38178
38188
|
failOverConfig,
|
|
38179
|
-
merkleHashVersion: 0,
|
|
38180
38189
|
});
|
|
38181
38190
|
}
|
|
38182
38191
|
throw new MissingBlockchainIdentifierError();
|
|
@@ -38184,7 +38193,6 @@ function nodeDiscovery({ nodeManager, directoryEndpointPool, failOverConfig, blo
|
|
|
38184
38193
|
const D1Client = yield createClient({
|
|
38185
38194
|
nodeUrlPool: getUrlsFromEndpoints(directoryEndpointPool),
|
|
38186
38195
|
blockchainRid: directoryBRID,
|
|
38187
|
-
merkleHashVersion: 0,
|
|
38188
38196
|
});
|
|
38189
38197
|
return yield getBlockchainApiUrls(D1Client, ensureBuffer(blockchainRidToUse));
|
|
38190
38198
|
});
|
|
@@ -38357,7 +38365,6 @@ function getSystemClient(directoryNodeUrlPool, directoryChainRid) {
|
|
|
38357
38365
|
return yield createClient({
|
|
38358
38366
|
directoryNodeUrlPool,
|
|
38359
38367
|
blockchainRid: directoryChainRid,
|
|
38360
|
-
merkleHashVersion: 0,
|
|
38361
38368
|
});
|
|
38362
38369
|
});
|
|
38363
38370
|
}
|
|
@@ -38396,7 +38403,7 @@ const getUrlsFromEndpoints = (endpointPool) => {
|
|
|
38396
38403
|
function awaitDappConfirmation(txRID, dappStatusPolling, getTransactionStatus) {
|
|
38397
38404
|
var _a;
|
|
38398
38405
|
return __awaiter$5(this, void 0, void 0, function* () {
|
|
38399
|
-
let lastKnownResult;
|
|
38406
|
+
let lastKnownResult = null;
|
|
38400
38407
|
for (let i = 0; i < dappStatusPolling.count; i++) {
|
|
38401
38408
|
lastKnownResult = yield getTransactionStatus(txRID);
|
|
38402
38409
|
if (lastKnownResult.status === ResponseStatus.Confirmed) {
|
|
@@ -38407,10 +38414,7 @@ function awaitDappConfirmation(txRID, dappStatusPolling, getTransactionStatus) {
|
|
|
38407
38414
|
}
|
|
38408
38415
|
yield sleep(dappStatusPolling.interval);
|
|
38409
38416
|
}
|
|
38410
|
-
|
|
38411
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
38412
|
-
//@ts-expect-error
|
|
38413
|
-
return lastKnownResult;
|
|
38417
|
+
throw new Error(`Retry count exceeded. Confirmation not received. Last transaction status: ${lastKnownResult === null || lastKnownResult === void 0 ? void 0 : lastKnownResult.status}`);
|
|
38414
38418
|
});
|
|
38415
38419
|
}
|
|
38416
38420
|
function awaitClusterAnchoringChainConfirmation(txRID, clusterAnchoringStatusPolling, getClusterAnchoringTransactionConfirmation) {
|
|
@@ -38524,6 +38528,13 @@ function setStatusPolling(statusPolling) {
|
|
|
38524
38528
|
count: (_b = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.count) !== null && _b !== void 0 ? _b : 20,
|
|
38525
38529
|
};
|
|
38526
38530
|
}
|
|
38531
|
+
function setRetryTransactionPolling(statusPolling) {
|
|
38532
|
+
var _a, _b;
|
|
38533
|
+
return {
|
|
38534
|
+
interval: (_a = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.interval) !== null && _a !== void 0 ? _a : 500,
|
|
38535
|
+
count: (_b = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.count) !== null && _b !== void 0 ? _b : 3,
|
|
38536
|
+
};
|
|
38537
|
+
}
|
|
38527
38538
|
function linkPromiEvents(event1, event2) {
|
|
38528
38539
|
const transactionEvents = Object.values(TransactionEvent).filter((event) => typeof event === "string");
|
|
38529
38540
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -38595,11 +38606,12 @@ function getBlockchainRidFromIid({ endpointPool, chainId, failOverConfig = {}, n
|
|
|
38595
38606
|
dappStatusPolling: setStatusPolling(),
|
|
38596
38607
|
clusterAnchoringStatusPolling: setStatusPolling(),
|
|
38597
38608
|
systemAnchoringStatusPolling: setStatusPolling(),
|
|
38609
|
+
retryTransactionPolling: setRetryTransactionPolling(),
|
|
38598
38610
|
failoverStrategy: mergedFailOverConfig.strategy,
|
|
38599
38611
|
attemptsPerEndpoint: mergedFailOverConfig.attemptsPerEndpoint,
|
|
38600
38612
|
attemptInterval: mergedFailOverConfig.attemptInterval,
|
|
38601
38613
|
unreachableDuration: mergedFailOverConfig.unreachableDuration,
|
|
38602
|
-
merkleHashVersion:
|
|
38614
|
+
merkleHashVersion: MERKLE_HASH_VERSIONS.UNSET,
|
|
38603
38615
|
};
|
|
38604
38616
|
const { error, statusCode, rspBody } = yield requestWithFailoverStrategy(Method.GET, `/brid/iid_${chainId}`, config);
|
|
38605
38617
|
const blockchainRid = isString(rspBody);
|
|
@@ -38907,7 +38919,7 @@ function getAnchoringClient(client, dappBlockchainRid, cluster) {
|
|
|
38907
38919
|
if (!sourceClusterInfo || !sourceClusterInfo.anchoring_chain) {
|
|
38908
38920
|
throw Error("Cluster info could not be found");
|
|
38909
38921
|
}
|
|
38910
|
-
const networkSettings = Object.assign(Object.assign({}, client.config), { directoryNodeUrlPool: getUrlsFromEndpoints(client.config.endpointPool), blockchainRid: toString(sourceClusterInfo.anchoring_chain)
|
|
38922
|
+
const networkSettings = Object.assign(Object.assign({}, client.config), { directoryNodeUrlPool: getUrlsFromEndpoints(client.config.endpointPool), blockchainRid: toString(sourceClusterInfo.anchoring_chain) });
|
|
38911
38923
|
const clientConfiguredToAnchoringchain = yield createClient(networkSettings);
|
|
38912
38924
|
return clientConfiguredToAnchoringchain;
|
|
38913
38925
|
});
|
|
@@ -39265,6 +39277,48 @@ function createClient(settings) {
|
|
|
39265
39277
|
}
|
|
39266
39278
|
});
|
|
39267
39279
|
},
|
|
39280
|
+
sendTransactionWithRetries(transaction, callback, confirmationLevel = ChainConfirmationLevel.Dapp) {
|
|
39281
|
+
const client = this;
|
|
39282
|
+
function sendOnce() {
|
|
39283
|
+
return client.sendTransaction(transaction, true, callback, confirmationLevel);
|
|
39284
|
+
}
|
|
39285
|
+
const promiEvent = new Web3PromiEvent((resolve, reject) => __awaiter$1(this, void 0, void 0, function* () {
|
|
39286
|
+
let error = null;
|
|
39287
|
+
// await sleep(1000);
|
|
39288
|
+
for (let i = 0; i < config.retryTransactionPolling.count; i++) {
|
|
39289
|
+
info(`sendTransactionWithRetries attempt ${i + 1} of ${config.retryTransactionPolling.count}`);
|
|
39290
|
+
const tmpPromiEvent = sendOnce()
|
|
39291
|
+
.on(TransactionEvent.ClusterAnchoringConfirmation, receipt => {
|
|
39292
|
+
promiEvent.emit(TransactionEvent.ClusterAnchoringConfirmation, receipt);
|
|
39293
|
+
})
|
|
39294
|
+
.on(TransactionEvent.SystemAnchoringConfirmation, receipt => {
|
|
39295
|
+
promiEvent.emit(TransactionEvent.SystemAnchoringConfirmation, receipt);
|
|
39296
|
+
})
|
|
39297
|
+
.on(TransactionEvent.DappReceived, receipt => {
|
|
39298
|
+
promiEvent.emit(TransactionEvent.DappReceived, receipt);
|
|
39299
|
+
})
|
|
39300
|
+
.on(TransactionEvent.Signed, receipt => {
|
|
39301
|
+
promiEvent.emit(TransactionEvent.Signed, receipt);
|
|
39302
|
+
})
|
|
39303
|
+
.on(TransactionEvent.DappConfirmed, receipt => {
|
|
39304
|
+
promiEvent.emit(TransactionEvent.DappConfirmed, receipt);
|
|
39305
|
+
})
|
|
39306
|
+
.catch(tmpError => {
|
|
39307
|
+
warning(`sendTransactionWithRetries error on attempt ${i + 1} of ${config.retryTransactionPolling.count}: ${tmpError}`);
|
|
39308
|
+
promiEvent.emit(TransactionEvent.Rejected, tmpError);
|
|
39309
|
+
error = tmpError;
|
|
39310
|
+
});
|
|
39311
|
+
const tmpReceipt = yield tmpPromiEvent;
|
|
39312
|
+
if (tmpReceipt) {
|
|
39313
|
+
resolve(tmpReceipt);
|
|
39314
|
+
return;
|
|
39315
|
+
}
|
|
39316
|
+
yield sleep(config.retryTransactionPolling.interval);
|
|
39317
|
+
}
|
|
39318
|
+
reject(error);
|
|
39319
|
+
}));
|
|
39320
|
+
return promiEvent;
|
|
39321
|
+
},
|
|
39268
39322
|
sendTransaction(transaction, doStatusPolling = true, callback, confirmationLevel = ChainConfirmationLevel.Dapp) {
|
|
39269
39323
|
const promiEvent = new Web3PromiEvent((resolve, reject) => __awaiter$1(this, void 0, void 0, function* () {
|
|
39270
39324
|
var _a, _b;
|
|
@@ -39299,14 +39353,15 @@ function createClient(settings) {
|
|
|
39299
39353
|
clusterAnchoringStatusPolling: client.config.clusterAnchoringStatusPolling,
|
|
39300
39354
|
systemAnchoringStatusPolling: client.config.systemAnchoringStatusPolling,
|
|
39301
39355
|
};
|
|
39302
|
-
|
|
39356
|
+
const stickyNodeClient = yield createStickyNodeClient(client); //to avoid false rejections by oblivious nodes
|
|
39357
|
+
let transactionReceipt = yield handleDappConfirmations(transactionRid, doStatusPolling, confirmationLevel, promiEvent, statusPollingConfig.dappStatusPolling, () => stickyNodeClient.getTransactionStatus(transactionRid, callback), stickyNodeClient);
|
|
39303
39358
|
if (confirmationLevel === ChainConfirmationLevel.None ||
|
|
39304
39359
|
confirmationLevel === ChainConfirmationLevel.Dapp) {
|
|
39305
39360
|
resolve(transactionReceipt);
|
|
39306
39361
|
return;
|
|
39307
39362
|
}
|
|
39308
39363
|
const { anchoringClient, systemAnchoringChainBridString } = yield getAnchoringClientAndSystemChainRid(client);
|
|
39309
|
-
transactionReceipt = yield handleSystemConfirmations(transactionReceipt, confirmationLevel, promiEvent, statusPollingConfig, anchoringClient, systemAnchoringChainBridString, () =>
|
|
39364
|
+
transactionReceipt = yield handleSystemConfirmations(transactionReceipt, confirmationLevel, promiEvent, statusPollingConfig, anchoringClient, systemAnchoringChainBridString, () => stickyNodeClient.getClusterAnchoringTransactionConfirmation(transactionRid, anchoringClient, callback), anchoredTxRid => stickyNodeClient.getSystemAnchoringTransactionConfirmation(anchoredTxRid, anchoringClient, systemAnchoringChainBridString, callback));
|
|
39310
39365
|
resolve(transactionReceipt);
|
|
39311
39366
|
}
|
|
39312
39367
|
catch (error) {
|
|
@@ -39726,6 +39781,21 @@ function createClient(settings) {
|
|
|
39726
39781
|
return merkleHashVersion;
|
|
39727
39782
|
});
|
|
39728
39783
|
}
|
|
39784
|
+
function createStickyNodeClient(client) {
|
|
39785
|
+
var _a;
|
|
39786
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
39787
|
+
if (!client.config.nodeManager.lastUsedNode) {
|
|
39788
|
+
throw new Error("No last used node found; cannot create sticky node client");
|
|
39789
|
+
}
|
|
39790
|
+
const stickyNodeClient = yield createClient({
|
|
39791
|
+
nodeUrlPool: (_a = client.config.nodeManager.lastUsedNode) === null || _a === void 0 ? void 0 : _a.url,
|
|
39792
|
+
blockchainRid: client.config.blockchainRid,
|
|
39793
|
+
merkleHashVersion: client.config.merkleHashVersion,
|
|
39794
|
+
useStickyNode: true,
|
|
39795
|
+
});
|
|
39796
|
+
return stickyNodeClient;
|
|
39797
|
+
});
|
|
39798
|
+
}
|
|
39729
39799
|
});
|
|
39730
39800
|
}
|
|
39731
39801
|
|
|
@@ -39751,6 +39821,7 @@ function createStubClient() {
|
|
|
39751
39821
|
dappStatusPolling: setStatusPolling({ interval: 5000, count: 5 }),
|
|
39752
39822
|
clusterAnchoringStatusPolling: setStatusPolling(),
|
|
39753
39823
|
systemAnchoringStatusPolling: setStatusPolling(),
|
|
39824
|
+
retryTransactionPolling: setRetryTransactionPolling(),
|
|
39754
39825
|
failoverStrategy: FailoverStrategy.AbortOnError,
|
|
39755
39826
|
attemptsPerEndpoint: 3,
|
|
39756
39827
|
attemptInterval: 5000,
|
|
@@ -39770,6 +39841,9 @@ function createStubClient() {
|
|
|
39770
39841
|
sendTransaction() {
|
|
39771
39842
|
return new Web3PromiEvent((_resolve, reject) => reject("sendTransaction rejected"));
|
|
39772
39843
|
},
|
|
39844
|
+
sendTransactionWithRetries() {
|
|
39845
|
+
return new Web3PromiEvent((_resolve, reject) => reject("sendTransactionWithRetries rejected"));
|
|
39846
|
+
},
|
|
39773
39847
|
signAndSendUniqueTransaction() {
|
|
39774
39848
|
return new Web3PromiEvent((_resolve, reject) => reject("signAndSendUniqueTransaction rejected"));
|
|
39775
39849
|
},
|