@hiero-ledger/sdk 2.74.0 → 2.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd.js +152 -96
- package/dist/umd.min.js +1 -1
- package/lib/channel/WebChannel.cjs +11 -2
- package/lib/channel/WebChannel.js +1 -1
- package/lib/channel/WebChannel.js.map +1 -1
- package/lib/client/WebClient.cjs +6 -0
- package/lib/client/WebClient.js +1 -1
- package/lib/client/WebClient.js.map +1 -1
- package/lib/client/addressbooks/mainnet.cjs +1 -1
- package/lib/client/addressbooks/mainnet.d.ts +1 -1
- package/lib/client/addressbooks/mainnet.js +1 -1
- package/lib/client/addressbooks/mainnet.js.map +1 -1
- package/lib/client/addressbooks/previewnet.cjs +1 -1
- package/lib/client/addressbooks/previewnet.d.ts +1 -1
- package/lib/client/addressbooks/previewnet.js +1 -1
- package/lib/client/addressbooks/previewnet.js.map +1 -1
- package/lib/client/addressbooks/testnet.cjs +1 -1
- package/lib/client/addressbooks/testnet.d.ts +1 -1
- package/lib/client/addressbooks/testnet.js +1 -1
- package/lib/client/addressbooks/testnet.js.map +1 -1
- package/lib/constants/ClientConstants.cjs +1 -1
- package/lib/constants/ClientConstants.d.ts +1 -0
- package/lib/constants/ClientConstants.js +1 -1
- package/lib/constants/ClientConstants.js.map +1 -1
- package/lib/network/AddressBookQueryWeb.cjs +88 -60
- package/lib/network/AddressBookQueryWeb.d.ts +7 -37
- package/lib/network/AddressBookQueryWeb.js +1 -1
- package/lib/network/AddressBookQueryWeb.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -8
- package/src/channel/WebChannel.js +19 -7
- package/src/client/WebClient.js +13 -0
- package/src/client/addressbooks/mainnet.js +1 -1
- package/src/client/addressbooks/previewnet.js +1 -1
- package/src/client/addressbooks/testnet.js +1 -1
- package/src/constants/ClientConstants.js +1 -1
- package/src/network/AddressBookQueryWeb.js +122 -91
package/dist/umd.js
CHANGED
|
@@ -96899,7 +96899,7 @@
|
|
|
96899
96899
|
"node29.swirldslabs.com:443": new AccountId(32),
|
|
96900
96900
|
"node30.swirldslabs.com:443": new AccountId(33),
|
|
96901
96901
|
"node31.swirldslabs.com:443": new AccountId(34),
|
|
96902
|
-
|
|
96902
|
+
"node32.swirldslabs.com:443": new AccountId(35),
|
|
96903
96903
|
"node33.swirldslabs.com:443": new AccountId(36),
|
|
96904
96904
|
"node34.swirldslabs.com:443": new AccountId(37),
|
|
96905
96905
|
};
|
|
@@ -97032,8 +97032,15 @@
|
|
|
97032
97032
|
* description: string,
|
|
97033
97033
|
* stake: number
|
|
97034
97034
|
* }>} nodes
|
|
97035
|
+
* @property {?{next: ?string}} links - Links object containing pagination information
|
|
97035
97036
|
*/
|
|
97036
97037
|
|
|
97038
|
+
/**
|
|
97039
|
+
* Default page size limit for optimal pagination performance
|
|
97040
|
+
* @constant {number}
|
|
97041
|
+
*/
|
|
97042
|
+
const DEFAULT_PAGE_SIZE = 25;
|
|
97043
|
+
|
|
97037
97044
|
/**
|
|
97038
97045
|
* Web-compatible query to get a list of Hedera network node addresses from a mirror node.
|
|
97039
97046
|
* Uses fetch API instead of gRPC for web environments.
|
|
@@ -97048,7 +97055,7 @@
|
|
|
97048
97055
|
/**
|
|
97049
97056
|
* @param {object} props
|
|
97050
97057
|
* @param {FileId | string} [props.fileId]
|
|
97051
|
-
* @param {number} [props.limit]
|
|
97058
|
+
* @param {number} [props.limit] - Page size limit (defaults to 25 for optimal performance)
|
|
97052
97059
|
*/
|
|
97053
97060
|
constructor(props = {}) {
|
|
97054
97061
|
super();
|
|
@@ -97215,111 +97222,135 @@
|
|
|
97215
97222
|
baseUrl = `${baseUrl}:${port}`;
|
|
97216
97223
|
}
|
|
97217
97224
|
|
|
97218
|
-
|
|
97225
|
+
// Initialize aggregated results
|
|
97226
|
+
this._addresses = [];
|
|
97227
|
+
let nextUrl = null;
|
|
97228
|
+
let isLastPage = false;
|
|
97219
97229
|
|
|
97230
|
+
// Build initial URL
|
|
97231
|
+
const initialUrl = new URL(`${baseUrl}/api/v1/network/nodes`);
|
|
97220
97232
|
if (this._fileId != null) {
|
|
97221
|
-
|
|
97222
|
-
}
|
|
97223
|
-
if (this._limit != null) {
|
|
97224
|
-
url.searchParams.append("limit", this._limit.toString());
|
|
97233
|
+
initialUrl.searchParams.append("file.id", this._fileId.toString());
|
|
97225
97234
|
}
|
|
97226
97235
|
|
|
97227
|
-
|
|
97228
|
-
|
|
97229
|
-
|
|
97230
|
-
|
|
97231
|
-
method: "GET",
|
|
97232
|
-
headers: {
|
|
97233
|
-
Accept: "application/json",
|
|
97234
|
-
},
|
|
97235
|
-
signal: requestTimeout
|
|
97236
|
-
? AbortSignal.timeout(requestTimeout)
|
|
97237
|
-
: undefined,
|
|
97238
|
-
});
|
|
97236
|
+
// Use the specified limit, or default to DEFAULT_PAGE_SIZE for optimal pagination performance
|
|
97237
|
+
const effectiveLimit =
|
|
97238
|
+
this._limit != null ? this._limit : DEFAULT_PAGE_SIZE;
|
|
97239
|
+
initialUrl.searchParams.append("limit", effectiveLimit.toString());
|
|
97239
97240
|
|
|
97240
|
-
|
|
97241
|
-
|
|
97242
|
-
|
|
97241
|
+
// Fetch all pages
|
|
97242
|
+
while (!isLastPage) {
|
|
97243
|
+
const currentUrl = nextUrl ? new URL(nextUrl, baseUrl) : initialUrl;
|
|
97243
97244
|
|
|
97244
|
-
|
|
97245
|
-
|
|
97246
|
-
|
|
97247
|
-
|
|
97245
|
+
for (let attempt = 0; attempt <= this._maxAttempts; attempt++) {
|
|
97246
|
+
try {
|
|
97247
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
97248
|
+
const response = await fetch(currentUrl.toString(), {
|
|
97249
|
+
method: "GET",
|
|
97250
|
+
headers: {
|
|
97251
|
+
Accept: "application/json",
|
|
97252
|
+
},
|
|
97253
|
+
signal: requestTimeout
|
|
97254
|
+
? AbortSignal.timeout(requestTimeout)
|
|
97255
|
+
: undefined,
|
|
97256
|
+
});
|
|
97248
97257
|
|
|
97249
|
-
|
|
97258
|
+
if (!response.ok) {
|
|
97259
|
+
throw new Error(
|
|
97260
|
+
`HTTP error! status: ${response.status}`,
|
|
97261
|
+
);
|
|
97262
|
+
}
|
|
97250
97263
|
|
|
97251
|
-
|
|
97252
|
-
|
|
97253
|
-
|
|
97254
|
-
|
|
97255
|
-
accountId: node.node_account_id,
|
|
97256
|
-
addresses: this._handleAddressesFromGrpcProxyEndpoint(
|
|
97257
|
-
node,
|
|
97258
|
-
client,
|
|
97259
|
-
),
|
|
97260
|
-
certHash: node.node_cert_hash,
|
|
97261
|
-
publicKey: node.public_key,
|
|
97262
|
-
description: node.description,
|
|
97263
|
-
stake: node.stake.toString(),
|
|
97264
|
-
}),
|
|
97265
|
-
);
|
|
97264
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
97265
|
+
const data = /** @type {AddressBookQueryWebResponse} */ (
|
|
97266
|
+
await response.json()
|
|
97267
|
+
);
|
|
97266
97268
|
|
|
97267
|
-
|
|
97268
|
-
|
|
97269
|
-
|
|
97269
|
+
const nodes = data.nodes || [];
|
|
97270
|
+
|
|
97271
|
+
// Aggregate nodes from this page
|
|
97272
|
+
const pageNodes = nodes.map((node) =>
|
|
97273
|
+
NodeAddress.fromJSON({
|
|
97274
|
+
nodeId: node.node_id.toString(),
|
|
97275
|
+
accountId: node.node_account_id,
|
|
97276
|
+
addresses:
|
|
97277
|
+
this._handleAddressesFromGrpcProxyEndpoint(
|
|
97278
|
+
node,
|
|
97279
|
+
client,
|
|
97280
|
+
),
|
|
97281
|
+
certHash: node.node_cert_hash,
|
|
97282
|
+
publicKey: node.public_key,
|
|
97283
|
+
description: node.description,
|
|
97284
|
+
stake: node.stake.toString(),
|
|
97285
|
+
}),
|
|
97286
|
+
);
|
|
97270
97287
|
|
|
97271
|
-
|
|
97272
|
-
|
|
97273
|
-
} catch (error) {
|
|
97274
|
-
console.error("Error in _makeFetchRequest:", error);
|
|
97275
|
-
const message =
|
|
97276
|
-
error instanceof Error ? error.message : String(error);
|
|
97288
|
+
this._addresses.push(...pageNodes);
|
|
97289
|
+
nextUrl = data.links?.next || null;
|
|
97277
97290
|
|
|
97278
|
-
|
|
97279
|
-
|
|
97280
|
-
|
|
97281
|
-
|
|
97282
|
-
this._retryHandler(
|
|
97283
|
-
/** @type {MirrorError | Error | null} */ (error),
|
|
97284
|
-
)
|
|
97285
|
-
) {
|
|
97286
|
-
const delay = Math.min(
|
|
97287
|
-
250 * 2 ** attempt,
|
|
97288
|
-
this._maxBackoff,
|
|
97289
|
-
);
|
|
97291
|
+
// If no more pages, set flag to exit loop
|
|
97292
|
+
if (!nextUrl) {
|
|
97293
|
+
isLastPage = true;
|
|
97294
|
+
}
|
|
97290
97295
|
|
|
97291
|
-
|
|
97292
|
-
|
|
97293
|
-
|
|
97294
|
-
|
|
97295
|
-
|
|
97296
|
-
|
|
97297
|
-
|
|
97298
|
-
|
|
97299
|
-
|
|
97296
|
+
// Move to next page
|
|
97297
|
+
break;
|
|
97298
|
+
} catch (error) {
|
|
97299
|
+
console.error("Error in _makeFetchRequest:", error);
|
|
97300
|
+
const message =
|
|
97301
|
+
error instanceof Error ? error.message : String(error);
|
|
97302
|
+
|
|
97303
|
+
// Check if we should retry
|
|
97304
|
+
if (
|
|
97305
|
+
attempt < this._maxAttempts &&
|
|
97306
|
+
!client.isClientShutDown &&
|
|
97307
|
+
this._retryHandler(
|
|
97308
|
+
/** @type {MirrorError | Error | null} */ (error),
|
|
97309
|
+
)
|
|
97310
|
+
) {
|
|
97311
|
+
const delay = Math.min(
|
|
97312
|
+
250 * 2 ** attempt,
|
|
97313
|
+
this._maxBackoff,
|
|
97314
|
+
);
|
|
97315
|
+
|
|
97316
|
+
if (this._logger) {
|
|
97317
|
+
this._logger.debug(
|
|
97318
|
+
`Error getting nodes from mirror for file ${
|
|
97319
|
+
this._fileId != null
|
|
97320
|
+
? this._fileId.toString()
|
|
97321
|
+
: "UNKNOWN"
|
|
97322
|
+
} during attempt ${
|
|
97323
|
+
attempt + 1
|
|
97324
|
+
}. Waiting ${delay} ms before next attempt: ${message}`,
|
|
97325
|
+
);
|
|
97326
|
+
}
|
|
97327
|
+
|
|
97328
|
+
// Wait before next attempt
|
|
97329
|
+
// eslint-disable-next-line ie11/no-loop-func
|
|
97330
|
+
await new Promise((resolve) =>
|
|
97331
|
+
setTimeout(resolve, delay),
|
|
97300
97332
|
);
|
|
97333
|
+
continue;
|
|
97301
97334
|
}
|
|
97302
97335
|
|
|
97303
|
-
//
|
|
97304
|
-
|
|
97305
|
-
|
|
97306
|
-
|
|
97336
|
+
// If we shouldn't retry or have exhausted attempts, reject
|
|
97337
|
+
const maxAttemptsReached = attempt >= this._maxAttempts;
|
|
97338
|
+
const errorMessage = maxAttemptsReached
|
|
97339
|
+
? `Failed to query address book after ${
|
|
97340
|
+
this._maxAttempts + 1
|
|
97341
|
+
} attempts. Last error: ${message}`
|
|
97342
|
+
: `Failed to query address book: ${message}`;
|
|
97343
|
+
reject(new Error(errorMessage));
|
|
97344
|
+
return;
|
|
97307
97345
|
}
|
|
97308
|
-
|
|
97309
|
-
// If we shouldn't retry or have exhausted attempts, reject
|
|
97310
|
-
const maxAttemptsReached = attempt >= this._maxAttempts;
|
|
97311
|
-
const errorMessage = maxAttemptsReached
|
|
97312
|
-
? `Failed to query address book after ${
|
|
97313
|
-
this._maxAttempts + 1
|
|
97314
|
-
} attempts. Last error: ${message}`
|
|
97315
|
-
: `Failed to query address book: ${message}`;
|
|
97316
|
-
reject(new Error(errorMessage));
|
|
97317
|
-
return;
|
|
97318
97346
|
}
|
|
97319
97347
|
}
|
|
97320
97348
|
|
|
97321
|
-
//
|
|
97322
|
-
|
|
97349
|
+
// Return the aggregated results
|
|
97350
|
+
const addressBook = new NodeAddressBook({
|
|
97351
|
+
nodeAddresses: this._addresses,
|
|
97352
|
+
});
|
|
97353
|
+
resolve(addressBook);
|
|
97323
97354
|
}
|
|
97324
97355
|
|
|
97325
97356
|
/**
|
|
@@ -98257,7 +98288,7 @@
|
|
|
98257
98288
|
|
|
98258
98289
|
const SDK_NAME = "hiero-sdk-js";
|
|
98259
98290
|
const SDK_VERSION =
|
|
98260
|
-
"2.
|
|
98291
|
+
"2.76.0" ;
|
|
98261
98292
|
|
|
98262
98293
|
// SPDX-License-Identifier: Apache-2.0
|
|
98263
98294
|
|
|
@@ -98632,14 +98663,26 @@
|
|
|
98632
98663
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
98633
98664
|
return async (method, requestData, callback) => {
|
|
98634
98665
|
try {
|
|
98635
|
-
|
|
98636
|
-
|
|
98637
|
-
this._address.
|
|
98638
|
-
|
|
98666
|
+
// Check if address already contains a scheme
|
|
98667
|
+
const hasScheme =
|
|
98668
|
+
this._address.startsWith("http://") ||
|
|
98669
|
+
this._address.startsWith("https://");
|
|
98670
|
+
|
|
98671
|
+
let address;
|
|
98672
|
+
if (hasScheme) {
|
|
98673
|
+
// Use the address as-is if it already has a scheme
|
|
98674
|
+
address = this._address;
|
|
98675
|
+
} else {
|
|
98676
|
+
// Only prepend scheme if none exists
|
|
98677
|
+
const shouldUseHttps = !(
|
|
98678
|
+
this._address.includes("localhost") ||
|
|
98679
|
+
this._address.includes("127.0.0.1")
|
|
98680
|
+
);
|
|
98639
98681
|
|
|
98640
|
-
|
|
98641
|
-
|
|
98642
|
-
|
|
98682
|
+
address = shouldUseHttps
|
|
98683
|
+
? `https://${this._address}`
|
|
98684
|
+
: `http://${this._address}`;
|
|
98685
|
+
}
|
|
98643
98686
|
// this will be executed in a browser environment so eslint is
|
|
98644
98687
|
// disabled for the fetch call
|
|
98645
98688
|
//eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
@@ -98936,6 +98979,19 @@
|
|
|
98936
98979
|
break;
|
|
98937
98980
|
}
|
|
98938
98981
|
} else {
|
|
98982
|
+
// Check for deprecation warnings for network endpoints with schemes
|
|
98983
|
+
for (const [key] of Object.entries(network)) {
|
|
98984
|
+
if (key.startsWith("https://") || key.startsWith("http://")) {
|
|
98985
|
+
console.warn(
|
|
98986
|
+
'[Deprecation Notice] Hiero SDK: Network endpoint "' +
|
|
98987
|
+
key +
|
|
98988
|
+
'" includes a URL scheme (e.g. "https://"). ' +
|
|
98989
|
+
"This format was accepted in earlier versions but is now deprecated. " +
|
|
98990
|
+
'Please remove the scheme and use "host:port" instead (e.g. "node00.swirldslabs.com:443"). ' +
|
|
98991
|
+
"Support for scheme-prefixed endpoints will be removed in a future major release.",
|
|
98992
|
+
);
|
|
98993
|
+
}
|
|
98994
|
+
}
|
|
98939
98995
|
this._network.setNetwork(network);
|
|
98940
98996
|
}
|
|
98941
98997
|
}
|