@hiero-ledger/sdk 2.73.1 → 2.73.2
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 +79 -31
- package/dist/umd.min.js +2 -2
- package/lib/account/AccountId.cjs +4 -4
- package/lib/account/AccountId.js +1 -1
- package/lib/account/AccountId.js.map +1 -1
- package/lib/client/Client.cjs +48 -0
- package/lib/client/Client.d.ts +14 -0
- package/lib/client/Client.js +1 -1
- package/lib/client/Client.js.map +1 -1
- package/lib/query/MirrorNodeContractQuery.cjs +15 -9
- package/lib/query/MirrorNodeContractQuery.js +1 -1
- package/lib/query/MirrorNodeContractQuery.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/account/AccountId.js +6 -10
- package/src/client/Client.js +55 -0
- package/src/query/MirrorNodeContractQuery.js +16 -19
package/dist/umd.js
CHANGED
|
@@ -37038,17 +37038,15 @@
|
|
|
37038
37038
|
if (this.evmAddress === null) {
|
|
37039
37039
|
throw new Error("field `evmAddress` should not be null");
|
|
37040
37040
|
}
|
|
37041
|
-
const
|
|
37042
|
-
|
|
37043
|
-
|
|
37044
|
-
);
|
|
37041
|
+
const mirrorRestApiBaseUrl = client.mirrorRestApiBaseUrl;
|
|
37042
|
+
|
|
37043
|
+
const url = `${mirrorRestApiBaseUrl}/accounts/${this.evmAddress.toString()}`;
|
|
37045
37044
|
|
|
37046
37045
|
await new Promise((resolve) => {
|
|
37047
37046
|
setTimeout(resolve, 3000);
|
|
37048
37047
|
});
|
|
37049
37048
|
|
|
37050
37049
|
/* eslint-disable */
|
|
37051
|
-
const url = `https://${mirrorUrl}/api/v1/accounts/${this.evmAddress.toString()}`;
|
|
37052
37050
|
const response = await fetch(url);
|
|
37053
37051
|
const data = await response.json();
|
|
37054
37052
|
const mirrorAccountId = data.account;
|
|
@@ -37070,17 +37068,15 @@
|
|
|
37070
37068
|
if (this.num === null) {
|
|
37071
37069
|
throw new Error("field `num` should not be null");
|
|
37072
37070
|
}
|
|
37073
|
-
const
|
|
37074
|
-
|
|
37075
|
-
|
|
37076
|
-
);
|
|
37071
|
+
const mirrorRestApiBaseUrl = client.mirrorRestApiBaseUrl;
|
|
37072
|
+
|
|
37073
|
+
const url = `${mirrorRestApiBaseUrl}/accounts/${this.num.toString()}`;
|
|
37077
37074
|
|
|
37078
37075
|
await new Promise((resolve) => {
|
|
37079
37076
|
setTimeout(resolve, 3000);
|
|
37080
37077
|
});
|
|
37081
37078
|
|
|
37082
37079
|
/* eslint-disable */
|
|
37083
|
-
const url = `https://${mirrorUrl}/api/v1/accounts/${this.num.toString()}`;
|
|
37084
37080
|
const response = await fetch(url);
|
|
37085
37081
|
const data = await response.json();
|
|
37086
37082
|
const mirrorAccountId = data.evm_address;
|
|
@@ -79568,29 +79564,26 @@
|
|
|
79568
79564
|
throw new Error("Contract ID is not set");
|
|
79569
79565
|
}
|
|
79570
79566
|
this._fillEvmAddress();
|
|
79571
|
-
let
|
|
79572
|
-
const
|
|
79573
|
-
|
|
79574
|
-
if (
|
|
79575
|
-
|
|
79576
|
-
|
|
79577
|
-
|
|
79578
|
-
|
|
79579
|
-
|
|
79580
|
-
|
|
79581
|
-
|
|
79582
|
-
|
|
79583
|
-
|
|
79584
|
-
|
|
79585
|
-
} else {
|
|
79586
|
-
let trimmed = client.mirrorNetwork[0].split(":");
|
|
79587
|
-
mirrorNetworkAddress = "https://"
|
|
79588
|
-
.concat(trimmed[0])
|
|
79589
|
-
.concat(contractCallEndpoint);
|
|
79567
|
+
let mirrorRestApiBaseUrl = client.mirrorRestApiBaseUrl;
|
|
79568
|
+
const contractCallEndpointPath = "/contracts/call";
|
|
79569
|
+
|
|
79570
|
+
// Check if this is a local environment (localhost or 127.0.0.1)
|
|
79571
|
+
const mirrorNode = client._mirrorNetwork.getNextMirrorNode();
|
|
79572
|
+
const host = mirrorNode.address.address;
|
|
79573
|
+
const isLocalEnvironment = host === "localhost" || host === "127.0.0.1";
|
|
79574
|
+
|
|
79575
|
+
if (isLocalEnvironment) {
|
|
79576
|
+
// For local environments, use HTTP scheme and port 8545
|
|
79577
|
+
const url = new URL(mirrorRestApiBaseUrl);
|
|
79578
|
+
url.protocol = "http:";
|
|
79579
|
+
url.port = "8545";
|
|
79580
|
+
mirrorRestApiBaseUrl = url.toString();
|
|
79590
79581
|
}
|
|
79591
79582
|
|
|
79583
|
+
const contractCallEndpointUrl = `${mirrorRestApiBaseUrl}${contractCallEndpointPath}`;
|
|
79584
|
+
|
|
79592
79585
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
79593
|
-
const response = await fetch(
|
|
79586
|
+
const response = await fetch(contractCallEndpointUrl, {
|
|
79594
79587
|
method: "POST",
|
|
79595
79588
|
headers: {
|
|
79596
79589
|
"Content-Type": "application/json",
|
|
@@ -97467,6 +97460,33 @@
|
|
|
97467
97460
|
return this._mirrorNetwork.network;
|
|
97468
97461
|
}
|
|
97469
97462
|
|
|
97463
|
+
/**
|
|
97464
|
+
* @returns {string}
|
|
97465
|
+
* @throws {Error} When no mirror network is configured or available
|
|
97466
|
+
*/
|
|
97467
|
+
get mirrorRestApiBaseUrl() {
|
|
97468
|
+
try {
|
|
97469
|
+
const mirrorNode = this._mirrorNetwork.getNextMirrorNode();
|
|
97470
|
+
const host = mirrorNode.address.address;
|
|
97471
|
+
const port = mirrorNode.address.port;
|
|
97472
|
+
|
|
97473
|
+
if (!host || !port) {
|
|
97474
|
+
throw new Error(
|
|
97475
|
+
"Mirror node has invalid address configuration",
|
|
97476
|
+
);
|
|
97477
|
+
}
|
|
97478
|
+
|
|
97479
|
+
const scheme = this._getSchemeFromHostAndPort(host, port);
|
|
97480
|
+
|
|
97481
|
+
return `${scheme}://${host}:${port}/api/v1`;
|
|
97482
|
+
} catch (error) {
|
|
97483
|
+
// Re-throw with a more descriptive error message
|
|
97484
|
+
throw new Error(
|
|
97485
|
+
"Client has no mirror network configured or no healthy mirror nodes are available",
|
|
97486
|
+
);
|
|
97487
|
+
}
|
|
97488
|
+
}
|
|
97489
|
+
|
|
97470
97490
|
/**
|
|
97471
97491
|
* @returns {boolean}
|
|
97472
97492
|
*/
|
|
@@ -98005,6 +98025,34 @@
|
|
|
98005
98025
|
}, this._networkUpdatePeriod);
|
|
98006
98026
|
}
|
|
98007
98027
|
|
|
98028
|
+
/**
|
|
98029
|
+
* Determines the appropriate scheme (http/https) based on the host and port.
|
|
98030
|
+
*
|
|
98031
|
+
* @private
|
|
98032
|
+
* @param {string} host - The host address
|
|
98033
|
+
* @param {number} port - The port number
|
|
98034
|
+
* @returns {string} - The scheme ('http' or 'https')
|
|
98035
|
+
*/
|
|
98036
|
+
_getSchemeFromHostAndPort(host, port) {
|
|
98037
|
+
// For localhost and 127.0.0.1, use HTTP scheme
|
|
98038
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
98039
|
+
return "http";
|
|
98040
|
+
}
|
|
98041
|
+
|
|
98042
|
+
// Standard HTTPS ports
|
|
98043
|
+
if (port === 443) {
|
|
98044
|
+
return "https";
|
|
98045
|
+
}
|
|
98046
|
+
|
|
98047
|
+
// Standard HTTP ports
|
|
98048
|
+
if (port === 80) {
|
|
98049
|
+
return "http";
|
|
98050
|
+
}
|
|
98051
|
+
|
|
98052
|
+
// For other ports, assume HTTPS for security
|
|
98053
|
+
return "https";
|
|
98054
|
+
}
|
|
98055
|
+
|
|
98008
98056
|
/**
|
|
98009
98057
|
* @returns {boolean}
|
|
98010
98058
|
*/
|
|
@@ -98074,7 +98122,7 @@
|
|
|
98074
98122
|
|
|
98075
98123
|
const SDK_NAME = "hiero-sdk-js";
|
|
98076
98124
|
const SDK_VERSION =
|
|
98077
|
-
"2.73.
|
|
98125
|
+
"2.73.2" ;
|
|
98078
98126
|
|
|
98079
98127
|
// SPDX-License-Identifier: Apache-2.0
|
|
98080
98128
|
|