postchain-client 2.1.3 → 2.1.5
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 +65 -30
- package/built/cjs/index.js.map +1 -1
- package/built/esm/index.js +65 -30
- package/built/esm/index.js.map +1 -1
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js +4 -0
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js.map +1 -1
- package/built/src/blockchainClient/blockchainClient.js +4 -2
- package/built/src/blockchainClient/blockchainClient.js.map +1 -1
- package/built/src/blockchainClient/errors.d.ts +3 -0
- package/built/src/blockchainClient/errors.js +7 -1
- package/built/src/blockchainClient/errors.js.map +1 -1
- package/built/src/blockchainClient/types.d.ts +4 -0
- package/built/src/blockchainClient/utils.d.ts +5 -3
- package/built/src/blockchainClient/utils.js +50 -27
- package/built/src/blockchainClient/utils.js.map +1 -1
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.js +19 -0
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.js.map +1 -1
- package/built/test/unit/blockchainClient/util.test.js +66 -0
- package/built/test/unit/blockchainClient/util.test.js.map +1 -1
- package/built/umd/index.js +65 -30
- package/built/umd/index.js.map +1 -1
- package/changelog.md +7 -1
- package/package.json +1 -1
|
@@ -171,5 +171,71 @@ describe("Blockchain client util tests", () => {
|
|
|
171
171
|
expect(foundBlockchainApiUrls).toEqual(expectedNodesUrls);
|
|
172
172
|
}));
|
|
173
173
|
});
|
|
174
|
+
describe("optional node URL filtering", () => {
|
|
175
|
+
it("keeps previous behavior when filters are not configured", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
|
+
const nodeUrlPool = ["http://node-1", "http://node-2"];
|
|
177
|
+
const config = yield utils.getClientConfigFromSettings({
|
|
178
|
+
blockchainRid: mocks_1.mockStringBlockchainRid,
|
|
179
|
+
directoryChainRid: mocks_1.mockStringDirectoryChainRid,
|
|
180
|
+
nodeUrlPool,
|
|
181
|
+
});
|
|
182
|
+
expect(config.endpointPool.map(endpoint => endpoint.url)).toEqual(nodeUrlPool);
|
|
183
|
+
expect(config.nodeManager.nodes.map(node => node.url)).toEqual(nodeUrlPool);
|
|
184
|
+
}));
|
|
185
|
+
it("filters direct, directory, and discovered pools when configured", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
186
|
+
const directConfig = yield utils.getClientConfigFromSettings({
|
|
187
|
+
blockchainRid: mocks_1.mockStringBlockchainRid,
|
|
188
|
+
directoryChainRid: mocks_1.mockStringDirectoryChainRid,
|
|
189
|
+
nodeUrlPool: ["http://allowed-1", "http://blocked-node", "http://allowed-2"],
|
|
190
|
+
blockedNodeUrlSubstrings: ["BLOCKED"],
|
|
191
|
+
});
|
|
192
|
+
expect(directConfig.endpointPool.map(endpoint => endpoint.url)).toEqual([
|
|
193
|
+
"http://allowed-1",
|
|
194
|
+
"http://allowed-2",
|
|
195
|
+
]);
|
|
196
|
+
expect(directConfig.nodeManager.nodes.map(node => node.url)).toEqual([
|
|
197
|
+
"http://allowed-1",
|
|
198
|
+
"http://allowed-2",
|
|
199
|
+
]);
|
|
200
|
+
const mockDirectoryClient = {
|
|
201
|
+
query: jest
|
|
202
|
+
.fn()
|
|
203
|
+
.mockResolvedValue(["http://allowed-discovered", "http://blocked-discovered"]),
|
|
204
|
+
config: { endpointPool: [{ url: mocks_1.LOCAL_POOL }] },
|
|
205
|
+
};
|
|
206
|
+
jest.spyOn(blockchainClient, "createClient").mockResolvedValue(mockDirectoryClient);
|
|
207
|
+
const discovered = yield utils.nodeDiscovery({
|
|
208
|
+
nodeManager: (0, nodeManager_1.createNodeManager)({
|
|
209
|
+
nodeUrls: [mocks_1.LOCAL_POOL],
|
|
210
|
+
}),
|
|
211
|
+
directoryEndpointPool: [{ url: mocks_1.LOCAL_POOL, whenAvailable: 0 }],
|
|
212
|
+
blockchainRid: mocks_1.mockHexStringOfThirtyTwoBytesBuffer,
|
|
213
|
+
blockedNodeUrlSubstrings: ["BLOCKED"],
|
|
214
|
+
nodeUrlFilter: (url) => url.includes("allowed"),
|
|
215
|
+
});
|
|
216
|
+
expect(discovered).toEqual(["http://allowed-discovered"]);
|
|
217
|
+
}));
|
|
218
|
+
it("throws explicit error when filtering empties a pool", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
219
|
+
yield expect(utils.getClientConfigFromSettings({
|
|
220
|
+
blockchainRid: mocks_1.mockStringBlockchainRid,
|
|
221
|
+
directoryChainRid: mocks_1.mockStringDirectoryChainRid,
|
|
222
|
+
nodeUrlPool: ["http://blocked-1", "http://blocked-2"],
|
|
223
|
+
blockedNodeUrlSubstrings: ["blocked"],
|
|
224
|
+
})).rejects.toThrow(new errors_1.FilteredNodeUrlPoolEmptyError("nodeUrlPool"));
|
|
225
|
+
}));
|
|
226
|
+
it("propagates filters in nested system client creation", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
227
|
+
const createClientSpy = jest
|
|
228
|
+
.spyOn(blockchainClient, "createClient")
|
|
229
|
+
.mockResolvedValue(mocks_1.clientConfiguredToD1);
|
|
230
|
+
const nodeUrlFilter = (url) => url.includes("allowed");
|
|
231
|
+
yield utils.getSystemClient([mocks_1.LOCAL_POOL], mocks_1.mockStringDirectoryChainRid, ["blocked"], nodeUrlFilter);
|
|
232
|
+
expect(createClientSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
233
|
+
directoryNodeUrlPool: [mocks_1.LOCAL_POOL],
|
|
234
|
+
blockchainRid: mocks_1.mockStringDirectoryChainRid,
|
|
235
|
+
blockedNodeUrlSubstrings: ["blocked"],
|
|
236
|
+
nodeUrlFilter,
|
|
237
|
+
}));
|
|
238
|
+
}));
|
|
239
|
+
});
|
|
174
240
|
});
|
|
175
241
|
//# sourceMappingURL=util.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.test.js","sourceRoot":"","sources":["../../../../test/unit/blockchainClient/util.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;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,mCAA2B,EAC3B,CAAC,SAAS,CAAC,EACX,aAAa,CACd,CAAC;YAEF,MAAM,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAC1C,MAAM,CAAC,gBAAgB,CAAC;gBACtB,oBAAoB,EAAE,CAAC,kBAAU,CAAC;gBAClC,aAAa,EAAE,mCAA2B;gBAC1C,wBAAwB,EAAE,CAAC,SAAS,CAAC;gBACrC,aAAa;aACd,CAAC,CACH,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/built/umd/index.js
CHANGED
|
@@ -39186,7 +39186,7 @@
|
|
|
39186
39186
|
var errors = {};
|
|
39187
39187
|
|
|
39188
39188
|
Object.defineProperty(errors, "__esModule", { value: true });
|
|
39189
|
-
errors.GetBridFromChainException = errors.SerializedTransactionFormatException = errors.InvalidTxRidException = errors.UnexpectedStatusError = errors.TxRejectedError = errors.GetTransactionRidException = errors.InvalidTransactionFormatException = errors.DirectoryNodeUrlPoolException = errors.BlockchainUrlUndefinedException = errors.MissingNodeUrlError = errors.MissingBlockchainIdentifierError = errors.MissingPubKeyError = void 0;
|
|
39189
|
+
errors.GetBridFromChainException = errors.SerializedTransactionFormatException = errors.InvalidTxRidException = errors.UnexpectedStatusError = errors.TxRejectedError = errors.GetTransactionRidException = errors.InvalidTransactionFormatException = errors.FilteredNodeUrlPoolEmptyError = errors.DirectoryNodeUrlPoolException = errors.BlockchainUrlUndefinedException = errors.MissingNodeUrlError = errors.MissingBlockchainIdentifierError = errors.MissingPubKeyError = void 0;
|
|
39190
39190
|
const customError_1 = customError;
|
|
39191
39191
|
const formatter_1$1 = formatter;
|
|
39192
39192
|
class MissingPubKeyError extends customError_1.CustomError {
|
|
@@ -39220,6 +39220,12 @@
|
|
|
39220
39220
|
}
|
|
39221
39221
|
}
|
|
39222
39222
|
errors.DirectoryNodeUrlPoolException = DirectoryNodeUrlPoolException;
|
|
39223
|
+
class FilteredNodeUrlPoolEmptyError extends customError_1.CustomError {
|
|
39224
|
+
constructor(poolName) {
|
|
39225
|
+
super(`All node URLs were filtered out for pool "${poolName}". Update node URL filters or pool configuration.`, 400);
|
|
39226
|
+
}
|
|
39227
|
+
}
|
|
39228
|
+
errors.FilteredNodeUrlPoolEmptyError = FilteredNodeUrlPoolEmptyError;
|
|
39223
39229
|
class InvalidTransactionFormatException extends customError_1.CustomError {
|
|
39224
39230
|
constructor() {
|
|
39225
39231
|
super(`The transaction is not in the right format`, 400);
|
|
@@ -40547,23 +40553,9 @@
|
|
|
40547
40553
|
responseTimeout: settings.responseTimeout,
|
|
40548
40554
|
});
|
|
40549
40555
|
}))();
|
|
40550
|
-
return {
|
|
40551
|
-
|
|
40552
|
-
|
|
40553
|
-
blockchainRid: blockchainRidToUse,
|
|
40554
|
-
merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e : constants_1.MERKLE_HASH_VERSIONS.UNSET,
|
|
40555
|
-
dappStatusPolling: setStatusPolling(settings.dappStatusPolling),
|
|
40556
|
-
clusterAnchoringStatusPolling: setStatusPolling(settings.clusterAnchoringStatusPolling),
|
|
40557
|
-
systemAnchoringStatusPolling: setStatusPolling(settings.systemAnchoringStatusPolling),
|
|
40558
|
-
retryTransactionPolling: setRetryTransactionPolling(settings.retryTransactionPolling),
|
|
40559
|
-
failoverStrategy: ((_f = settings.failOverConfig) === null || _f === void 0 ? void 0 : _f.strategy) || exports.defaultFailoverConfig.strategy,
|
|
40560
|
-
attemptsPerEndpoint: ((_g = settings.failOverConfig) === null || _g === void 0 ? void 0 : _g.attemptsPerEndpoint) || exports.defaultFailoverConfig.attemptsPerEndpoint,
|
|
40561
|
-
attemptInterval: ((_h = settings.failOverConfig) === null || _h === void 0 ? void 0 : _h.attemptInterval) || exports.defaultFailoverConfig.attemptInterval,
|
|
40562
|
-
unreachableDuration: ((_j = settings.failOverConfig) === null || _j === void 0 ? void 0 : _j.unreachableDuration) || exports.defaultFailoverConfig.unreachableDuration,
|
|
40563
|
-
directoryChainRid: settings.directoryChainRid || directoryChainRid,
|
|
40564
|
-
connectTimeout: settings.connectTimeout,
|
|
40565
|
-
responseTimeout: settings.responseTimeout,
|
|
40566
|
-
};
|
|
40556
|
+
return Object.assign(Object.assign(Object.assign({ endpointPool, nodeManager: nodeManager }, (settings.blockedNodeUrlSubstrings !== undefined
|
|
40557
|
+
? { blockedNodeUrlSubstrings: settings.blockedNodeUrlSubstrings }
|
|
40558
|
+
: {})), (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 });
|
|
40567
40559
|
});
|
|
40568
40560
|
}
|
|
40569
40561
|
function getMerkleHashVersionFromDapp(config) {
|
|
@@ -40589,7 +40581,7 @@
|
|
|
40589
40581
|
return true;
|
|
40590
40582
|
}
|
|
40591
40583
|
function nodeDiscovery(_a) {
|
|
40592
|
-
return __awaiter(this, arguments, void 0, function* ({ nodeManager, directoryEndpointPool, failOverConfig, blockchainRid, blockchainIid, connectTimeout, responseTimeout, }) {
|
|
40584
|
+
return __awaiter(this, arguments, void 0, function* ({ nodeManager, directoryEndpointPool, blockedNodeUrlSubstrings, nodeUrlFilter, failOverConfig, blockchainRid, blockchainIid, connectTimeout, responseTimeout, }) {
|
|
40593
40585
|
if (directoryEndpointPool.length === 0) {
|
|
40594
40586
|
throw new errors_2.DirectoryNodeUrlPoolException();
|
|
40595
40587
|
}
|
|
@@ -40625,7 +40617,11 @@
|
|
|
40625
40617
|
nodeUrlPool: (0, exports.getUrlsFromEndpoints)(directoryEndpointPool),
|
|
40626
40618
|
blockchainRid: directoryBRID,
|
|
40627
40619
|
});
|
|
40628
|
-
|
|
40620
|
+
const discoveredNodes = yield getBlockchainApiUrls(D1Client, (0, formatter_1.ensureBuffer)(blockchainRidToUse));
|
|
40621
|
+
return applyNodeUrlFilters(discoveredNodes, {
|
|
40622
|
+
blockedNodeUrlSubstrings,
|
|
40623
|
+
nodeUrlFilter,
|
|
40624
|
+
}, "discoveredNodeUrlPool");
|
|
40629
40625
|
});
|
|
40630
40626
|
}
|
|
40631
40627
|
function getBlockchainApiUrls(directoryClient, blockchainRid) {
|
|
@@ -40768,14 +40764,21 @@
|
|
|
40768
40764
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40769
40765
|
var _a;
|
|
40770
40766
|
if (settings.directoryNodeUrlPool) {
|
|
40767
|
+
const directoryNodeUrlsOrNull = applyNodeUrlFilters(ensureArray(settings.directoryNodeUrlPool), settings, "directoryNodeUrlPool");
|
|
40768
|
+
if (directoryNodeUrlsOrNull === null) {
|
|
40769
|
+
throw new errors_2.DirectoryNodeUrlPoolException();
|
|
40770
|
+
}
|
|
40771
|
+
const directoryNodeUrls = directoryNodeUrlsOrNull;
|
|
40771
40772
|
// If directoryNodeUrlPool is provided, use nodeDiscovery
|
|
40772
40773
|
const nodeManager = (0, nodeManager_1.createNodeManager)({
|
|
40773
|
-
nodeUrls:
|
|
40774
|
+
nodeUrls: directoryNodeUrls,
|
|
40774
40775
|
unavailableDuration: (_a = settings.failOverConfig) === null || _a === void 0 ? void 0 : _a.unreachableDuration,
|
|
40775
40776
|
});
|
|
40776
40777
|
const discoveredNodes = yield nodeDiscovery({
|
|
40777
40778
|
nodeManager,
|
|
40778
|
-
directoryEndpointPool: (0, exports.createEndpointObjects)(
|
|
40779
|
+
directoryEndpointPool: (0, exports.createEndpointObjects)(directoryNodeUrls),
|
|
40780
|
+
blockedNodeUrlSubstrings: settings.blockedNodeUrlSubstrings,
|
|
40781
|
+
nodeUrlFilter: settings.nodeUrlFilter,
|
|
40779
40782
|
failOverConfig: settings.failOverConfig,
|
|
40780
40783
|
blockchainRid: settings.blockchainRid,
|
|
40781
40784
|
blockchainIid: settings.blockchainIid,
|
|
@@ -40786,11 +40789,11 @@
|
|
|
40786
40789
|
}
|
|
40787
40790
|
else if (typeof settings.nodeUrlPool === "string") {
|
|
40788
40791
|
// If nodeUrlPool is a string, convert it to an array
|
|
40789
|
-
return [settings.nodeUrlPool];
|
|
40792
|
+
return applyNodeUrlFilters([settings.nodeUrlPool], settings, "nodeUrlPool");
|
|
40790
40793
|
}
|
|
40791
40794
|
else if (Array.isArray(settings.nodeUrlPool)) {
|
|
40792
40795
|
// If nodeUrlPool is already an array, use it as-is
|
|
40793
|
-
return settings.nodeUrlPool;
|
|
40796
|
+
return applyNodeUrlFilters(settings.nodeUrlPool, settings, "nodeUrlPool");
|
|
40794
40797
|
}
|
|
40795
40798
|
else {
|
|
40796
40799
|
// Default to an empty array if no valid configuration is provided
|
|
@@ -40798,11 +40801,37 @@
|
|
|
40798
40801
|
}
|
|
40799
40802
|
});
|
|
40800
40803
|
}
|
|
40801
|
-
function
|
|
40804
|
+
function applyNodeUrlFilters(nodeUrls, settings, poolName) {
|
|
40805
|
+
var _a;
|
|
40806
|
+
if (nodeUrls === null) {
|
|
40807
|
+
return null;
|
|
40808
|
+
}
|
|
40809
|
+
const hasBlockedSubstringsFilter = Array.isArray(settings.blockedNodeUrlSubstrings) &&
|
|
40810
|
+
settings.blockedNodeUrlSubstrings.length > 0;
|
|
40811
|
+
const hasNodeUrlFilter = typeof settings.nodeUrlFilter === "function";
|
|
40812
|
+
if (!hasBlockedSubstringsFilter && !hasNodeUrlFilter) {
|
|
40813
|
+
return nodeUrls;
|
|
40814
|
+
}
|
|
40815
|
+
const blockedSubstrings = ((_a = settings.blockedNodeUrlSubstrings) !== null && _a !== void 0 ? _a : [])
|
|
40816
|
+
.map(substring => substring.toLowerCase())
|
|
40817
|
+
.filter(substring => substring.length > 0);
|
|
40818
|
+
const filteredNodeUrls = nodeUrls.filter(url => {
|
|
40819
|
+
const isBlockedBySubstring = blockedSubstrings.some(substring => url.toLowerCase().includes(substring));
|
|
40820
|
+
const passesCustomFilter = settings.nodeUrlFilter ? settings.nodeUrlFilter(url) : true;
|
|
40821
|
+
return !isBlockedBySubstring && passesCustomFilter;
|
|
40822
|
+
});
|
|
40823
|
+
if (filteredNodeUrls.length === 0) {
|
|
40824
|
+
throw new errors_2.FilteredNodeUrlPoolEmptyError(poolName);
|
|
40825
|
+
}
|
|
40826
|
+
return filteredNodeUrls;
|
|
40827
|
+
}
|
|
40828
|
+
function getSystemClient(directoryNodeUrlPool, directoryChainRid, blockedNodeUrlSubstrings, nodeUrlFilter) {
|
|
40802
40829
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40803
40830
|
return yield (0, blockchainClient_1.createClient)({
|
|
40804
40831
|
directoryNodeUrlPool,
|
|
40805
40832
|
blockchainRid: directoryChainRid,
|
|
40833
|
+
blockedNodeUrlSubstrings,
|
|
40834
|
+
nodeUrlFilter,
|
|
40806
40835
|
});
|
|
40807
40836
|
});
|
|
40808
40837
|
}
|
|
@@ -40931,16 +40960,16 @@
|
|
|
40931
40960
|
}
|
|
40932
40961
|
function getAnchoringClientAndSystemChainRid(client) {
|
|
40933
40962
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40934
|
-
const directoryClient = yield getSystemClient((0, exports.getUrlsFromEndpoints)(client.config.endpointPool), client.config.directoryChainRid);
|
|
40963
|
+
const directoryClient = yield getSystemClient((0, exports.getUrlsFromEndpoints)(client.config.endpointPool), client.config.directoryChainRid, client.config.blockedNodeUrlSubstrings, client.config.nodeUrlFilter);
|
|
40935
40964
|
const anchoringClient = yield (0, IccfProofTxMaterialBuilder_1.getAnchoringClient)(directoryClient, client.config.blockchainRid);
|
|
40936
40965
|
const systemAnchoringChainRidBuffer = yield getSystemAnchoringChain(directoryClient);
|
|
40937
40966
|
const systemAnchoringChainBridString = systemAnchoringChainRidBuffer.toString("hex");
|
|
40938
40967
|
return { anchoringClient, systemAnchoringChainBridString };
|
|
40939
40968
|
});
|
|
40940
40969
|
}
|
|
40941
|
-
function getSystemAnchoringTransaction(dappClientEndpointPool, anchoredTxRid, anchoringClient, systemAnchoringChainRid, systemAnchoringStatusPolling, merkleHashVersion) {
|
|
40970
|
+
function getSystemAnchoringTransaction(dappClientEndpointPool, anchoredTxRid, anchoringClient, systemAnchoringChainRid, systemAnchoringStatusPolling, merkleHashVersion, blockedNodeUrlSubstrings, nodeUrlFilter) {
|
|
40942
40971
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40943
|
-
const systemAnchoringChainClient = yield getSystemClient((0, exports.getUrlsFromEndpoints)(dappClientEndpointPool), systemAnchoringChainRid);
|
|
40972
|
+
const systemAnchoringChainClient = yield getSystemClient((0, exports.getUrlsFromEndpoints)(dappClientEndpointPool), systemAnchoringChainRid, blockedNodeUrlSubstrings, nodeUrlFilter);
|
|
40944
40973
|
const clusterAnchoringProof = yield anchoringClient.getConfirmationProof(anchoredTxRid);
|
|
40945
40974
|
const clusterBlockRid = (0, utils_1.calculateBlockRID)(clusterAnchoringProof, merkleHashVersion);
|
|
40946
40975
|
const systemAnchoringTransactionConfirmation = yield (0, utils_1.awaitGetAnchoringTransactionForBlockRid)(systemAnchoringChainClient, (0, formatter_1.toBuffer)(anchoringClient.config.blockchainRid), clusterBlockRid, systemAnchoringStatusPolling);
|
|
@@ -41316,6 +41345,8 @@
|
|
|
41316
41345
|
blockchainRid: (0, formatter_1.ensureString)(sourceBlockchainRid),
|
|
41317
41346
|
merkleHashVersion: merkleHashVersion,
|
|
41318
41347
|
useStickyNode: true,
|
|
41348
|
+
blockedNodeUrlSubstrings: directoryClient.config.blockedNodeUrlSubstrings,
|
|
41349
|
+
nodeUrlFilter: directoryClient.config.nodeUrlFilter,
|
|
41319
41350
|
});
|
|
41320
41351
|
}
|
|
41321
41352
|
else {
|
|
@@ -41324,6 +41355,8 @@
|
|
|
41324
41355
|
blockchainRid: (0, formatter_1.ensureString)(sourceBlockchainRid),
|
|
41325
41356
|
merkleHashVersion: merkleHashVersion,
|
|
41326
41357
|
useStickyNode: true,
|
|
41358
|
+
blockedNodeUrlSubstrings: directoryClient.config.blockedNodeUrlSubstrings,
|
|
41359
|
+
nodeUrlFilter: directoryClient.config.nodeUrlFilter,
|
|
41327
41360
|
});
|
|
41328
41361
|
}
|
|
41329
41362
|
const txProof = yield clientConfiguredToSource.getConfirmationProof(txToProveRid);
|
|
@@ -42102,7 +42135,7 @@
|
|
|
42102
42135
|
}
|
|
42103
42136
|
result.status = enums_1.AnchoringStatus.ClusterAnchored;
|
|
42104
42137
|
result.clusterAnchoredTx = anchoringTransactionValidation.data;
|
|
42105
|
-
const systemAnchoredTransaction = yield (0, utils_1.getSystemAnchoringTransaction)(config.endpointPool, anchoringTransactionValidation.data.txRid, anchoringClient, systemAnchoringChainRid, config.systemAnchoringStatusPolling, config.merkleHashVersion);
|
|
42138
|
+
const systemAnchoredTransaction = yield (0, utils_1.getSystemAnchoringTransaction)(config.endpointPool, anchoringTransactionValidation.data.txRid, anchoringClient, systemAnchoringChainRid, config.systemAnchoringStatusPolling, config.merkleHashVersion, config.blockedNodeUrlSubstrings, config.nodeUrlFilter);
|
|
42106
42139
|
if (!systemAnchoredTransaction) {
|
|
42107
42140
|
return result;
|
|
42108
42141
|
}
|
|
@@ -42332,7 +42365,7 @@
|
|
|
42332
42365
|
callback === null || callback === void 0 ? void 0 : callback(error, null);
|
|
42333
42366
|
throw error;
|
|
42334
42367
|
}
|
|
42335
|
-
const systemAnchoringTransactionTransaction = yield (0, utils_1.getSystemAnchoringTransaction)(config.endpointPool, anchoredTxRid, anchoringClient, systemAnchoringChainRid, config.systemAnchoringStatusPolling, config.merkleHashVersion);
|
|
42368
|
+
const systemAnchoringTransactionTransaction = yield (0, utils_1.getSystemAnchoringTransaction)(config.endpointPool, anchoredTxRid, anchoringClient, systemAnchoringChainRid, config.systemAnchoringStatusPolling, config.merkleHashVersion, config.blockedNodeUrlSubstrings, config.nodeUrlFilter);
|
|
42336
42369
|
return systemAnchoringTransactionTransaction;
|
|
42337
42370
|
});
|
|
42338
42371
|
},
|
|
@@ -42405,6 +42438,8 @@
|
|
|
42405
42438
|
blockchainRid: client.config.blockchainRid,
|
|
42406
42439
|
merkleHashVersion: client.config.merkleHashVersion,
|
|
42407
42440
|
useStickyNode: true,
|
|
42441
|
+
blockedNodeUrlSubstrings: client.config.blockedNodeUrlSubstrings,
|
|
42442
|
+
nodeUrlFilter: client.config.nodeUrlFilter,
|
|
42408
42443
|
});
|
|
42409
42444
|
return stickyNodeClient;
|
|
42410
42445
|
});
|