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/cjs/index.js
CHANGED
|
@@ -385,7 +385,19 @@ function sortDictPairByKey(dict) {
|
|
|
385
385
|
return sortedDict;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
const MERKLE_HASH_VERSIONS = {
|
|
389
|
+
ONE: 1,
|
|
390
|
+
TWO: 2,
|
|
391
|
+
UNSET: NaN,
|
|
392
|
+
};
|
|
393
|
+
|
|
388
394
|
const gtvHash2 = (obj, merkleHashVersion) => {
|
|
395
|
+
if (!Object.values(MERKLE_HASH_VERSIONS).includes(merkleHashVersion)) {
|
|
396
|
+
throw new Error("Merkle hash version is not valid");
|
|
397
|
+
}
|
|
398
|
+
if (isNaN(merkleHashVersion)) {
|
|
399
|
+
throw new Error("Merkle hash version is not set");
|
|
400
|
+
}
|
|
389
401
|
return merklehashts.gtvHash(obj, merkleHashVersion);
|
|
390
402
|
};
|
|
391
403
|
const encode$1 = encodeValue;
|
|
@@ -610,7 +622,7 @@ function sign(gtx, privOrSigProv, merkleHashVersion, pubKey) {
|
|
|
610
622
|
else {
|
|
611
623
|
// Removes signatures and extract the rawgtxBody
|
|
612
624
|
const rawGtxBody = gtxToRawGtxBody(gtx);
|
|
613
|
-
const signature = yield privOrSigProv.sign(rawGtxBody);
|
|
625
|
+
const signature = yield privOrSigProv.sign(rawGtxBody, merkleHashVersion);
|
|
614
626
|
return addSignature(privOrSigProv.pubKey, signature, gtx);
|
|
615
627
|
}
|
|
616
628
|
});
|
|
@@ -680,7 +692,7 @@ function checkExistingGTXSignatures(txHash, gtx) {
|
|
|
680
692
|
}
|
|
681
693
|
return true;
|
|
682
694
|
}
|
|
683
|
-
function newSignatureProvider(
|
|
695
|
+
function newSignatureProvider(keyPair) {
|
|
684
696
|
let pub, priv;
|
|
685
697
|
if (keyPair) {
|
|
686
698
|
priv = ensureBuffer(keyPair.privKey);
|
|
@@ -691,7 +703,7 @@ function newSignatureProvider(merkleHashVersion, keyPair) {
|
|
|
691
703
|
}
|
|
692
704
|
return {
|
|
693
705
|
pubKey: pub,
|
|
694
|
-
sign: (gtx) => __awaiter$9(this, void 0, void 0, function* () {
|
|
706
|
+
sign: (gtx, merkleHashVersion) => __awaiter$9(this, void 0, void 0, function* () {
|
|
695
707
|
const signature = getDigestToSignFromRawGtxBody(gtx, merkleHashVersion);
|
|
696
708
|
return signDigest(signature, priv);
|
|
697
709
|
}),
|
|
@@ -988,6 +1000,7 @@ exports.TransactionEvent = void 0;
|
|
|
988
1000
|
TransactionEvent["DappConfirmed"] = "dappConfirmed";
|
|
989
1001
|
TransactionEvent["DappReceived"] = "dappReceived";
|
|
990
1002
|
TransactionEvent["Signed"] = "signed";
|
|
1003
|
+
TransactionEvent["Rejected"] = "rejected";
|
|
991
1004
|
})(exports.TransactionEvent || (exports.TransactionEvent = {}));
|
|
992
1005
|
exports.AnchoringStatus = void 0;
|
|
993
1006
|
(function (AnchoringStatus) {
|
|
@@ -1296,11 +1309,6 @@ function encodeTransaction(gtx) {
|
|
|
1296
1309
|
return serialize(gtx);
|
|
1297
1310
|
}
|
|
1298
1311
|
|
|
1299
|
-
const MERKLE_HASH_VERSIONS = {
|
|
1300
|
-
ONE: 1,
|
|
1301
|
-
TWO: 2,
|
|
1302
|
-
};
|
|
1303
|
-
|
|
1304
1312
|
const MerkleHashSchema = zod.z.object({
|
|
1305
1313
|
merkle_hash_version: zod.z.number().int().positive(),
|
|
1306
1314
|
});
|
|
@@ -1583,7 +1591,8 @@ function retryRequest({ method, path, config, postObject, validateStatusCode, })
|
|
|
1583
1591
|
let error = null;
|
|
1584
1592
|
let transactionTimestamp = undefined;
|
|
1585
1593
|
const { nodeManager } = config;
|
|
1586
|
-
|
|
1594
|
+
const availableNodes = nodeManager.getAvailableNodes();
|
|
1595
|
+
for (const endpoint of availableNodes) {
|
|
1587
1596
|
for (let attempt = 0; attempt < config.attemptsPerEndpoint; attempt++) {
|
|
1588
1597
|
const response = yield handleRequest(method, path, endpoint.url, postObject);
|
|
1589
1598
|
error = (_a = response === null || response === void 0 ? void 0 : response.error) !== null && _a !== void 0 ? _a : null;
|
|
@@ -1594,6 +1603,7 @@ function retryRequest({ method, path, config, postObject, validateStatusCode, })
|
|
|
1594
1603
|
const isServerError = statusCode ? hasServerError(statusCode) : false;
|
|
1595
1604
|
if (isStatusCodeValid && !error) {
|
|
1596
1605
|
// Find a way to have this handled more elegantly in the node manager.
|
|
1606
|
+
nodeManager.lastUsedNode = endpoint;
|
|
1597
1607
|
if (nodeManager.stickedNode !== endpoint) {
|
|
1598
1608
|
nodeManager.setStickyNode(endpoint);
|
|
1599
1609
|
}
|
|
@@ -1744,7 +1754,7 @@ function getClientConfigFromSettings(settings) {
|
|
|
1744
1754
|
nodeManager,
|
|
1745
1755
|
endpointPool,
|
|
1746
1756
|
chainId: settings.blockchainIid,
|
|
1747
|
-
merkleHashVersion: (_k = settings.merkleHashVersion) !== null && _k !== void 0 ? _k :
|
|
1757
|
+
merkleHashVersion: (_k = settings.merkleHashVersion) !== null && _k !== void 0 ? _k : MERKLE_HASH_VERSIONS.UNSET,
|
|
1748
1758
|
});
|
|
1749
1759
|
}
|
|
1750
1760
|
throw new MissingBlockchainIdentifierError();
|
|
@@ -1759,17 +1769,18 @@ function getClientConfigFromSettings(settings) {
|
|
|
1759
1769
|
nodeManager,
|
|
1760
1770
|
endpointPool,
|
|
1761
1771
|
chainId: directoryChainIid,
|
|
1762
|
-
merkleHashVersion: (_l = settings.merkleHashVersion) !== null && _l !== void 0 ? _l :
|
|
1772
|
+
merkleHashVersion: (_l = settings.merkleHashVersion) !== null && _l !== void 0 ? _l : MERKLE_HASH_VERSIONS.UNSET,
|
|
1763
1773
|
});
|
|
1764
1774
|
}))();
|
|
1765
1775
|
return {
|
|
1766
1776
|
endpointPool,
|
|
1767
1777
|
nodeManager: nodeManager,
|
|
1768
1778
|
blockchainRid: blockchainRidToUse,
|
|
1769
|
-
merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e :
|
|
1779
|
+
merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e : MERKLE_HASH_VERSIONS.UNSET,
|
|
1770
1780
|
dappStatusPolling: setStatusPolling(settings.dappStatusPolling),
|
|
1771
1781
|
clusterAnchoringStatusPolling: setStatusPolling(settings.clusterAnchoringStatusPolling),
|
|
1772
1782
|
systemAnchoringStatusPolling: setStatusPolling(settings.systemAnchoringStatusPolling),
|
|
1783
|
+
retryTransactionPolling: setRetryTransactionPolling(settings.retryTransactionPolling),
|
|
1773
1784
|
failoverStrategy: ((_f = settings.failOverConfig) === null || _f === void 0 ? void 0 : _f.strategy) || defaultFailoverConfig.strategy,
|
|
1774
1785
|
attemptsPerEndpoint: ((_g = settings.failOverConfig) === null || _g === void 0 ? void 0 : _g.attemptsPerEndpoint) || defaultFailoverConfig.attemptsPerEndpoint,
|
|
1775
1786
|
attemptInterval: ((_h = settings.failOverConfig) === null || _h === void 0 ? void 0 : _h.attemptInterval) || defaultFailoverConfig.attemptInterval,
|
|
@@ -1805,7 +1816,6 @@ function nodeDiscovery({ nodeManager, directoryEndpointPool, failOverConfig, blo
|
|
|
1805
1816
|
endpointPool: directoryEndpointPool,
|
|
1806
1817
|
chainId: directoryIid,
|
|
1807
1818
|
failOverConfig,
|
|
1808
|
-
merkleHashVersion: 0,
|
|
1809
1819
|
});
|
|
1810
1820
|
const blockchainRidToUse = yield (() => __awaiter$5(this, void 0, void 0, function* () {
|
|
1811
1821
|
if (blockchainRid) {
|
|
@@ -1817,7 +1827,6 @@ function nodeDiscovery({ nodeManager, directoryEndpointPool, failOverConfig, blo
|
|
|
1817
1827
|
endpointPool: directoryEndpointPool,
|
|
1818
1828
|
chainId: blockchainIid,
|
|
1819
1829
|
failOverConfig,
|
|
1820
|
-
merkleHashVersion: 0,
|
|
1821
1830
|
});
|
|
1822
1831
|
}
|
|
1823
1832
|
throw new MissingBlockchainIdentifierError();
|
|
@@ -1825,7 +1834,6 @@ function nodeDiscovery({ nodeManager, directoryEndpointPool, failOverConfig, blo
|
|
|
1825
1834
|
const D1Client = yield createClient({
|
|
1826
1835
|
nodeUrlPool: getUrlsFromEndpoints(directoryEndpointPool),
|
|
1827
1836
|
blockchainRid: directoryBRID,
|
|
1828
|
-
merkleHashVersion: 0,
|
|
1829
1837
|
});
|
|
1830
1838
|
return yield getBlockchainApiUrls(D1Client, ensureBuffer(blockchainRidToUse));
|
|
1831
1839
|
});
|
|
@@ -1998,7 +2006,6 @@ function getSystemClient(directoryNodeUrlPool, directoryChainRid) {
|
|
|
1998
2006
|
return yield createClient({
|
|
1999
2007
|
directoryNodeUrlPool,
|
|
2000
2008
|
blockchainRid: directoryChainRid,
|
|
2001
|
-
merkleHashVersion: 0,
|
|
2002
2009
|
});
|
|
2003
2010
|
});
|
|
2004
2011
|
}
|
|
@@ -2037,7 +2044,7 @@ const getUrlsFromEndpoints = (endpointPool) => {
|
|
|
2037
2044
|
function awaitDappConfirmation(txRID, dappStatusPolling, getTransactionStatus) {
|
|
2038
2045
|
var _a;
|
|
2039
2046
|
return __awaiter$5(this, void 0, void 0, function* () {
|
|
2040
|
-
let lastKnownResult;
|
|
2047
|
+
let lastKnownResult = null;
|
|
2041
2048
|
for (let i = 0; i < dappStatusPolling.count; i++) {
|
|
2042
2049
|
lastKnownResult = yield getTransactionStatus(txRID);
|
|
2043
2050
|
if (lastKnownResult.status === exports.ResponseStatus.Confirmed) {
|
|
@@ -2048,10 +2055,7 @@ function awaitDappConfirmation(txRID, dappStatusPolling, getTransactionStatus) {
|
|
|
2048
2055
|
}
|
|
2049
2056
|
yield sleep(dappStatusPolling.interval);
|
|
2050
2057
|
}
|
|
2051
|
-
|
|
2052
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2053
|
-
//@ts-expect-error
|
|
2054
|
-
return lastKnownResult;
|
|
2058
|
+
throw new Error(`Retry count exceeded. Confirmation not received. Last transaction status: ${lastKnownResult === null || lastKnownResult === void 0 ? void 0 : lastKnownResult.status}`);
|
|
2055
2059
|
});
|
|
2056
2060
|
}
|
|
2057
2061
|
function awaitClusterAnchoringChainConfirmation(txRID, clusterAnchoringStatusPolling, getClusterAnchoringTransactionConfirmation) {
|
|
@@ -2165,6 +2169,13 @@ function setStatusPolling(statusPolling) {
|
|
|
2165
2169
|
count: (_b = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.count) !== null && _b !== void 0 ? _b : 20,
|
|
2166
2170
|
};
|
|
2167
2171
|
}
|
|
2172
|
+
function setRetryTransactionPolling(statusPolling) {
|
|
2173
|
+
var _a, _b;
|
|
2174
|
+
return {
|
|
2175
|
+
interval: (_a = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.interval) !== null && _a !== void 0 ? _a : 500,
|
|
2176
|
+
count: (_b = statusPolling === null || statusPolling === void 0 ? void 0 : statusPolling.count) !== null && _b !== void 0 ? _b : 3,
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2168
2179
|
function linkPromiEvents(event1, event2) {
|
|
2169
2180
|
const transactionEvents = Object.values(exports.TransactionEvent).filter((event) => typeof event === "string");
|
|
2170
2181
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -2236,11 +2247,12 @@ function getBlockchainRidFromIid({ endpointPool, chainId, failOverConfig = {}, n
|
|
|
2236
2247
|
dappStatusPolling: setStatusPolling(),
|
|
2237
2248
|
clusterAnchoringStatusPolling: setStatusPolling(),
|
|
2238
2249
|
systemAnchoringStatusPolling: setStatusPolling(),
|
|
2250
|
+
retryTransactionPolling: setRetryTransactionPolling(),
|
|
2239
2251
|
failoverStrategy: mergedFailOverConfig.strategy,
|
|
2240
2252
|
attemptsPerEndpoint: mergedFailOverConfig.attemptsPerEndpoint,
|
|
2241
2253
|
attemptInterval: mergedFailOverConfig.attemptInterval,
|
|
2242
2254
|
unreachableDuration: mergedFailOverConfig.unreachableDuration,
|
|
2243
|
-
merkleHashVersion:
|
|
2255
|
+
merkleHashVersion: MERKLE_HASH_VERSIONS.UNSET,
|
|
2244
2256
|
};
|
|
2245
2257
|
const { error, statusCode, rspBody } = yield requestWithFailoverStrategy(Method.GET, `/brid/iid_${chainId}`, config);
|
|
2246
2258
|
const blockchainRid = isString(rspBody);
|
|
@@ -2548,7 +2560,7 @@ function getAnchoringClient(client, dappBlockchainRid, cluster) {
|
|
|
2548
2560
|
if (!sourceClusterInfo || !sourceClusterInfo.anchoring_chain) {
|
|
2549
2561
|
throw Error("Cluster info could not be found");
|
|
2550
2562
|
}
|
|
2551
|
-
const networkSettings = Object.assign(Object.assign({}, client.config), { directoryNodeUrlPool: getUrlsFromEndpoints(client.config.endpointPool), blockchainRid: toString(sourceClusterInfo.anchoring_chain)
|
|
2563
|
+
const networkSettings = Object.assign(Object.assign({}, client.config), { directoryNodeUrlPool: getUrlsFromEndpoints(client.config.endpointPool), blockchainRid: toString(sourceClusterInfo.anchoring_chain) });
|
|
2552
2564
|
const clientConfiguredToAnchoringchain = yield createClient(networkSettings);
|
|
2553
2565
|
return clientConfiguredToAnchoringchain;
|
|
2554
2566
|
});
|
|
@@ -2906,6 +2918,48 @@ function createClient(settings) {
|
|
|
2906
2918
|
}
|
|
2907
2919
|
});
|
|
2908
2920
|
},
|
|
2921
|
+
sendTransactionWithRetries(transaction, callback, confirmationLevel = exports.ChainConfirmationLevel.Dapp) {
|
|
2922
|
+
const client = this;
|
|
2923
|
+
function sendOnce() {
|
|
2924
|
+
return client.sendTransaction(transaction, true, callback, confirmationLevel);
|
|
2925
|
+
}
|
|
2926
|
+
const promiEvent = new Web3PromiEvent((resolve, reject) => __awaiter$1(this, void 0, void 0, function* () {
|
|
2927
|
+
let error = null;
|
|
2928
|
+
// await sleep(1000);
|
|
2929
|
+
for (let i = 0; i < config.retryTransactionPolling.count; i++) {
|
|
2930
|
+
info(`sendTransactionWithRetries attempt ${i + 1} of ${config.retryTransactionPolling.count}`);
|
|
2931
|
+
const tmpPromiEvent = sendOnce()
|
|
2932
|
+
.on(exports.TransactionEvent.ClusterAnchoringConfirmation, receipt => {
|
|
2933
|
+
promiEvent.emit(exports.TransactionEvent.ClusterAnchoringConfirmation, receipt);
|
|
2934
|
+
})
|
|
2935
|
+
.on(exports.TransactionEvent.SystemAnchoringConfirmation, receipt => {
|
|
2936
|
+
promiEvent.emit(exports.TransactionEvent.SystemAnchoringConfirmation, receipt);
|
|
2937
|
+
})
|
|
2938
|
+
.on(exports.TransactionEvent.DappReceived, receipt => {
|
|
2939
|
+
promiEvent.emit(exports.TransactionEvent.DappReceived, receipt);
|
|
2940
|
+
})
|
|
2941
|
+
.on(exports.TransactionEvent.Signed, receipt => {
|
|
2942
|
+
promiEvent.emit(exports.TransactionEvent.Signed, receipt);
|
|
2943
|
+
})
|
|
2944
|
+
.on(exports.TransactionEvent.DappConfirmed, receipt => {
|
|
2945
|
+
promiEvent.emit(exports.TransactionEvent.DappConfirmed, receipt);
|
|
2946
|
+
})
|
|
2947
|
+
.catch(tmpError => {
|
|
2948
|
+
warning(`sendTransactionWithRetries error on attempt ${i + 1} of ${config.retryTransactionPolling.count}: ${tmpError}`);
|
|
2949
|
+
promiEvent.emit(exports.TransactionEvent.Rejected, tmpError);
|
|
2950
|
+
error = tmpError;
|
|
2951
|
+
});
|
|
2952
|
+
const tmpReceipt = yield tmpPromiEvent;
|
|
2953
|
+
if (tmpReceipt) {
|
|
2954
|
+
resolve(tmpReceipt);
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2957
|
+
yield sleep(config.retryTransactionPolling.interval);
|
|
2958
|
+
}
|
|
2959
|
+
reject(error);
|
|
2960
|
+
}));
|
|
2961
|
+
return promiEvent;
|
|
2962
|
+
},
|
|
2909
2963
|
sendTransaction(transaction, doStatusPolling = true, callback, confirmationLevel = exports.ChainConfirmationLevel.Dapp) {
|
|
2910
2964
|
const promiEvent = new Web3PromiEvent((resolve, reject) => __awaiter$1(this, void 0, void 0, function* () {
|
|
2911
2965
|
var _a, _b;
|
|
@@ -2940,14 +2994,15 @@ function createClient(settings) {
|
|
|
2940
2994
|
clusterAnchoringStatusPolling: client.config.clusterAnchoringStatusPolling,
|
|
2941
2995
|
systemAnchoringStatusPolling: client.config.systemAnchoringStatusPolling,
|
|
2942
2996
|
};
|
|
2943
|
-
|
|
2997
|
+
const stickyNodeClient = yield createStickyNodeClient(client); //to avoid false rejections by oblivious nodes
|
|
2998
|
+
let transactionReceipt = yield handleDappConfirmations(transactionRid, doStatusPolling, confirmationLevel, promiEvent, statusPollingConfig.dappStatusPolling, () => stickyNodeClient.getTransactionStatus(transactionRid, callback), stickyNodeClient);
|
|
2944
2999
|
if (confirmationLevel === exports.ChainConfirmationLevel.None ||
|
|
2945
3000
|
confirmationLevel === exports.ChainConfirmationLevel.Dapp) {
|
|
2946
3001
|
resolve(transactionReceipt);
|
|
2947
3002
|
return;
|
|
2948
3003
|
}
|
|
2949
3004
|
const { anchoringClient, systemAnchoringChainBridString } = yield getAnchoringClientAndSystemChainRid(client);
|
|
2950
|
-
transactionReceipt = yield handleSystemConfirmations(transactionReceipt, confirmationLevel, promiEvent, statusPollingConfig, anchoringClient, systemAnchoringChainBridString, () =>
|
|
3005
|
+
transactionReceipt = yield handleSystemConfirmations(transactionReceipt, confirmationLevel, promiEvent, statusPollingConfig, anchoringClient, systemAnchoringChainBridString, () => stickyNodeClient.getClusterAnchoringTransactionConfirmation(transactionRid, anchoringClient, callback), anchoredTxRid => stickyNodeClient.getSystemAnchoringTransactionConfirmation(anchoredTxRid, anchoringClient, systemAnchoringChainBridString, callback));
|
|
2951
3006
|
resolve(transactionReceipt);
|
|
2952
3007
|
}
|
|
2953
3008
|
catch (error) {
|
|
@@ -3367,6 +3422,21 @@ function createClient(settings) {
|
|
|
3367
3422
|
return merkleHashVersion;
|
|
3368
3423
|
});
|
|
3369
3424
|
}
|
|
3425
|
+
function createStickyNodeClient(client) {
|
|
3426
|
+
var _a;
|
|
3427
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
3428
|
+
if (!client.config.nodeManager.lastUsedNode) {
|
|
3429
|
+
throw new Error("No last used node found; cannot create sticky node client");
|
|
3430
|
+
}
|
|
3431
|
+
const stickyNodeClient = yield createClient({
|
|
3432
|
+
nodeUrlPool: (_a = client.config.nodeManager.lastUsedNode) === null || _a === void 0 ? void 0 : _a.url,
|
|
3433
|
+
blockchainRid: client.config.blockchainRid,
|
|
3434
|
+
merkleHashVersion: client.config.merkleHashVersion,
|
|
3435
|
+
useStickyNode: true,
|
|
3436
|
+
});
|
|
3437
|
+
return stickyNodeClient;
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3370
3440
|
});
|
|
3371
3441
|
}
|
|
3372
3442
|
|
|
@@ -3392,6 +3462,7 @@ function createStubClient() {
|
|
|
3392
3462
|
dappStatusPolling: setStatusPolling({ interval: 5000, count: 5 }),
|
|
3393
3463
|
clusterAnchoringStatusPolling: setStatusPolling(),
|
|
3394
3464
|
systemAnchoringStatusPolling: setStatusPolling(),
|
|
3465
|
+
retryTransactionPolling: setRetryTransactionPolling(),
|
|
3395
3466
|
failoverStrategy: exports.FailoverStrategy.AbortOnError,
|
|
3396
3467
|
attemptsPerEndpoint: 3,
|
|
3397
3468
|
attemptInterval: 5000,
|
|
@@ -3411,6 +3482,9 @@ function createStubClient() {
|
|
|
3411
3482
|
sendTransaction() {
|
|
3412
3483
|
return new Web3PromiEvent((_resolve, reject) => reject("sendTransaction rejected"));
|
|
3413
3484
|
},
|
|
3485
|
+
sendTransactionWithRetries() {
|
|
3486
|
+
return new Web3PromiEvent((_resolve, reject) => reject("sendTransactionWithRetries rejected"));
|
|
3487
|
+
},
|
|
3414
3488
|
signAndSendUniqueTransaction() {
|
|
3415
3489
|
return new Web3PromiEvent((_resolve, reject) => reject("signAndSendUniqueTransaction rejected"));
|
|
3416
3490
|
},
|