@hiero-ledger/sdk 2.73.1 → 2.74.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.
Files changed (125) hide show
  1. package/dist/umd.js +279 -96
  2. package/dist/umd.min.js +3 -3
  3. package/lib/MirrorNode.cjs +46 -0
  4. package/lib/MirrorNode.d.ts +16 -0
  5. package/lib/MirrorNode.js +1 -1
  6. package/lib/MirrorNode.js.map +1 -1
  7. package/lib/account/AccountAllowanceApproveTransaction.cjs +11 -5
  8. package/lib/account/AccountAllowanceApproveTransaction.d.ts +4 -5
  9. package/lib/account/AccountAllowanceApproveTransaction.js +1 -1
  10. package/lib/account/AccountAllowanceApproveTransaction.js.map +1 -1
  11. package/lib/account/AccountId.cjs +4 -4
  12. package/lib/account/AccountId.js +1 -1
  13. package/lib/account/AccountId.js.map +1 -1
  14. package/lib/account/TokenAllowance.cjs +4 -2
  15. package/lib/account/TokenAllowance.d.ts +4 -2
  16. package/lib/account/TokenAllowance.js +1 -1
  17. package/lib/account/TokenAllowance.js.map +1 -1
  18. package/lib/account/TokenTransferMap.cjs +7 -2
  19. package/lib/account/TokenTransferMap.d.ts +6 -2
  20. package/lib/account/TokenTransferMap.js +1 -1
  21. package/lib/account/TokenTransferMap.js.map +1 -1
  22. package/lib/client/Client.cjs +20 -3
  23. package/lib/client/Client.d.ts +17 -3
  24. package/lib/client/Client.js +1 -1
  25. package/lib/client/Client.js.map +1 -1
  26. package/lib/client/MirrorNetwork.cjs +16 -0
  27. package/lib/client/MirrorNetwork.d.ts +7 -0
  28. package/lib/client/MirrorNetwork.js +1 -1
  29. package/lib/client/MirrorNetwork.js.map +1 -1
  30. package/lib/client/addressbooks/mainnet.cjs +1 -1
  31. package/lib/client/addressbooks/mainnet.d.ts +1 -1
  32. package/lib/client/addressbooks/mainnet.js +1 -1
  33. package/lib/client/addressbooks/mainnet.js.map +1 -1
  34. package/lib/client/addressbooks/previewnet.cjs +1 -1
  35. package/lib/client/addressbooks/previewnet.d.ts +1 -1
  36. package/lib/client/addressbooks/previewnet.js +1 -1
  37. package/lib/client/addressbooks/previewnet.js.map +1 -1
  38. package/lib/client/addressbooks/testnet.cjs +1 -1
  39. package/lib/client/addressbooks/testnet.d.ts +1 -1
  40. package/lib/client/addressbooks/testnet.js +1 -1
  41. package/lib/client/addressbooks/testnet.js.map +1 -1
  42. package/lib/constants/ClientConstants.cjs +4 -1
  43. package/lib/constants/ClientConstants.d.ts +2 -0
  44. package/lib/constants/ClientConstants.js +1 -1
  45. package/lib/constants/ClientConstants.js.map +1 -1
  46. package/lib/contract/ContractId.cjs +2 -5
  47. package/lib/contract/ContractId.js +1 -1
  48. package/lib/contract/ContractId.js.map +1 -1
  49. package/lib/query/MirrorNodeContractQuery.cjs +16 -9
  50. package/lib/query/MirrorNodeContractQuery.js +1 -1
  51. package/lib/query/MirrorNodeContractQuery.js.map +1 -1
  52. package/lib/token/AbstractTokenTransferTransaction.cjs +12 -8
  53. package/lib/token/AbstractTokenTransferTransaction.d.ts +14 -11
  54. package/lib/token/AbstractTokenTransferTransaction.js +1 -1
  55. package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
  56. package/lib/token/AssessedCustomFee.cjs +8 -4
  57. package/lib/token/AssessedCustomFee.d.ts +8 -5
  58. package/lib/token/AssessedCustomFee.js +1 -1
  59. package/lib/token/AssessedCustomFee.js.map +1 -1
  60. package/lib/token/CustomFixedFee.cjs +8 -4
  61. package/lib/token/CustomFixedFee.d.ts +8 -5
  62. package/lib/token/CustomFixedFee.js +1 -1
  63. package/lib/token/CustomFixedFee.js.map +1 -1
  64. package/lib/token/PendingAirdropRecord.cjs +7 -2
  65. package/lib/token/PendingAirdropRecord.d.ts +6 -2
  66. package/lib/token/PendingAirdropRecord.js +1 -1
  67. package/lib/token/PendingAirdropRecord.js.map +1 -1
  68. package/lib/token/TokenAirdropTransaction.cjs +2 -1
  69. package/lib/token/TokenAirdropTransaction.d.ts +4 -2
  70. package/lib/token/TokenAirdropTransaction.js.map +1 -1
  71. package/lib/token/TokenBurnTransaction.cjs +5 -3
  72. package/lib/token/TokenBurnTransaction.d.ts +6 -4
  73. package/lib/token/TokenBurnTransaction.js +1 -1
  74. package/lib/token/TokenBurnTransaction.js.map +1 -1
  75. package/lib/token/TokenCreateTransaction.cjs +7 -6
  76. package/lib/token/TokenCreateTransaction.d.ts +8 -8
  77. package/lib/token/TokenCreateTransaction.js +1 -1
  78. package/lib/token/TokenCreateTransaction.js.map +1 -1
  79. package/lib/token/TokenMintTransaction.cjs +5 -4
  80. package/lib/token/TokenMintTransaction.d.ts +6 -5
  81. package/lib/token/TokenMintTransaction.js +1 -1
  82. package/lib/token/TokenMintTransaction.js.map +1 -1
  83. package/lib/token/TokenTransfer.cjs +3 -2
  84. package/lib/token/TokenTransfer.d.ts +2 -2
  85. package/lib/token/TokenTransfer.js +1 -1
  86. package/lib/token/TokenTransfer.js.map +1 -1
  87. package/lib/token/TokenWipeTransaction.cjs +5 -3
  88. package/lib/token/TokenWipeTransaction.d.ts +6 -4
  89. package/lib/token/TokenWipeTransaction.js +1 -1
  90. package/lib/token/TokenWipeTransaction.js.map +1 -1
  91. package/lib/transaction/Transaction.cjs +54 -0
  92. package/lib/transaction/Transaction.d.ts +10 -0
  93. package/lib/transaction/Transaction.js +1 -1
  94. package/lib/transaction/Transaction.js.map +1 -1
  95. package/lib/util.cjs +25 -0
  96. package/lib/util.d.ts +8 -0
  97. package/lib/util.js +1 -1
  98. package/lib/util.js.map +1 -1
  99. package/lib/version.js +1 -1
  100. package/package.json +12 -8
  101. package/src/MirrorNode.js +49 -0
  102. package/src/account/AccountAllowanceApproveTransaction.js +11 -11
  103. package/src/account/AccountId.js +6 -10
  104. package/src/account/TokenAllowance.js +5 -2
  105. package/src/account/TokenTransferMap.js +7 -2
  106. package/src/client/Client.js +20 -3
  107. package/src/client/MirrorNetwork.js +18 -0
  108. package/src/client/addressbooks/mainnet.js +1 -1
  109. package/src/client/addressbooks/previewnet.js +1 -1
  110. package/src/client/addressbooks/testnet.js +1 -1
  111. package/src/constants/ClientConstants.js +3 -0
  112. package/src/contract/ContractId.js +2 -10
  113. package/src/query/MirrorNodeContractQuery.js +17 -19
  114. package/src/token/AbstractTokenTransferTransaction.js +12 -8
  115. package/src/token/AssessedCustomFee.js +8 -5
  116. package/src/token/CustomFixedFee.js +8 -5
  117. package/src/token/PendingAirdropRecord.js +7 -2
  118. package/src/token/TokenAirdropTransaction.js +2 -1
  119. package/src/token/TokenBurnTransaction.js +5 -3
  120. package/src/token/TokenCreateTransaction.js +7 -9
  121. package/src/token/TokenMintTransaction.js +5 -4
  122. package/src/token/TokenTransfer.js +3 -2
  123. package/src/token/TokenWipeTransaction.js +5 -3
  124. package/src/transaction/Transaction.js +63 -0
  125. package/src/util.js +26 -0
package/dist/umd.js CHANGED
@@ -4758,6 +4758,32 @@
4758
4758
  throw new Error(FUNCTION_CONVERT_TO_BIGNUMBER_ERROR);
4759
4759
  }
4760
4760
 
4761
+ /**
4762
+ * Converts amount (number, Long, BigNumber, or bigint) to Long.
4763
+ * This utility ensures consistent amount handling across the SDK.
4764
+ *
4765
+ * @param {number | Long | BigNumber | bigint} amount
4766
+ * @returns {Long}
4767
+ */
4768
+ function convertAmountToLong(amount) {
4769
+ requireNonNull(amount);
4770
+
4771
+ // Preserve exact original behavior for existing types
4772
+ if (Long.isLong(amount)) {
4773
+ return amount;
4774
+ } else if (typeof amount === "number") {
4775
+ return Long.fromNumber(amount);
4776
+ } else if (BigNumber$1.isBigNumber(amount)) {
4777
+ return Long.fromValue(
4778
+ amount.integerValue(BigNumber$1.ROUND_DOWN).toString(),
4779
+ );
4780
+ } else if (typeof amount === "bigint") {
4781
+ return Long.fromValue(amount.toString());
4782
+ } else {
4783
+ // Handle other types that can be converted to string
4784
+ return Long.fromValue(String(amount));
4785
+ }
4786
+ }
4761
4787
  /**
4762
4788
  * Converts Array of Numbers or Strings to Array of BigNumbers.
4763
4789
  *
@@ -37038,17 +37064,15 @@
37038
37064
  if (this.evmAddress === null) {
37039
37065
  throw new Error("field `evmAddress` should not be null");
37040
37066
  }
37041
- const mirrorUrl = client.mirrorNetwork[0].slice(
37042
- 0,
37043
- client.mirrorNetwork[0].indexOf(":"),
37044
- );
37067
+ const mirrorRestApiBaseUrl = client.mirrorRestApiBaseUrl;
37068
+
37069
+ const url = `${mirrorRestApiBaseUrl}/accounts/${this.evmAddress.toString()}`;
37045
37070
 
37046
37071
  await new Promise((resolve) => {
37047
37072
  setTimeout(resolve, 3000);
37048
37073
  });
37049
37074
 
37050
37075
  /* eslint-disable */
37051
- const url = `https://${mirrorUrl}/api/v1/accounts/${this.evmAddress.toString()}`;
37052
37076
  const response = await fetch(url);
37053
37077
  const data = await response.json();
37054
37078
  const mirrorAccountId = data.account;
@@ -37070,17 +37094,15 @@
37070
37094
  if (this.num === null) {
37071
37095
  throw new Error("field `num` should not be null");
37072
37096
  }
37073
- const mirrorUrl = client.mirrorNetwork[0].slice(
37074
- 0,
37075
- client.mirrorNetwork[0].indexOf(":"),
37076
- );
37097
+ const mirrorRestApiBaseUrl = client.mirrorRestApiBaseUrl;
37098
+
37099
+ const url = `${mirrorRestApiBaseUrl}/accounts/${this.num.toString()}`;
37077
37100
 
37078
37101
  await new Promise((resolve) => {
37079
37102
  setTimeout(resolve, 3000);
37080
37103
  });
37081
37104
 
37082
37105
  /* eslint-disable */
37083
- const url = `https://${mirrorUrl}/api/v1/accounts/${this.num.toString()}`;
37084
37106
  const response = await fetch(url);
37085
37107
  const data = await response.json();
37086
37108
  const mirrorAccountId = data.evm_address;
@@ -45010,18 +45032,10 @@
45010
45032
  * @returns {Promise<ContractId>}
45011
45033
  */
45012
45034
  async populateAccountNum(client) {
45013
- if (this.evmAddress === null) {
45014
- throw new Error("field `evmAddress` should not be null");
45015
- }
45016
- const mirrorUrl = client.mirrorNetwork[0].slice(
45017
- 0,
45018
- client.mirrorNetwork[0].indexOf(":"),
45019
- );
45035
+ const mirrorRestApiBaseUrl = client.mirrorRestApiBaseUrl;
45036
+ const url = `${mirrorRestApiBaseUrl}/contracts/${this.toEvmAddress()}`;
45020
45037
 
45021
45038
  /* eslint-disable */
45022
- const url = `https://${mirrorUrl}/api/v1/contracts/${encode$5(
45023
- this.evmAddress,
45024
- )}`;
45025
45039
  const response = await fetch(url);
45026
45040
  const data = await response.json();
45027
45041
  const mirrorAccountId = data.contract_id;
@@ -54101,6 +54115,10 @@
54101
54115
  * @typedef {import("@hashgraph/proto").proto.IAccountID} HieroProto.proto.IAccountID
54102
54116
  */
54103
54117
 
54118
+ /**
54119
+ * @typedef {import("bignumber.js").default} BigNumber
54120
+ */
54121
+
54104
54122
  /**
54105
54123
  * @augments {ObjectMap<TokenId, TokenTransferAccountMap>}
54106
54124
  */
@@ -54113,7 +54131,7 @@
54113
54131
  * @internal
54114
54132
  * @param {TokenId} tokenId
54115
54133
  * @param {AccountId} accountId
54116
- * @param {Long} amount
54134
+ * @param {Long | number | BigNumber | bigint} amount
54117
54135
  */
54118
54136
  __set(tokenId, accountId, amount) {
54119
54137
  const token = tokenId.toString();
@@ -54125,7 +54143,7 @@
54125
54143
  this.__map.set(tokenId, _map);
54126
54144
  }
54127
54145
 
54128
- _map._set(accountId, amount);
54146
+ _map._set(accountId, convertAmountToLong(amount));
54129
54147
  }
54130
54148
 
54131
54149
  /**
@@ -54320,6 +54338,10 @@
54320
54338
  // SPDX-License-Identifier: Apache-2.0
54321
54339
 
54322
54340
 
54341
+ /**
54342
+ * @typedef {import("bignumber.js").default} BigNumber
54343
+ */
54344
+
54323
54345
  /**
54324
54346
  * @namespace proto
54325
54347
  * @typedef {import("@hashgraph/proto").proto.IAssessedCustomFee} HieroProto.proto.IAssessedCustomFee
@@ -54343,7 +54365,7 @@
54343
54365
  * @param {object} props
54344
54366
  * @param {AccountId | string} [props.feeCollectorAccountId]
54345
54367
  * @param {TokenId | string} [props.tokenId]
54346
- * @param {Long | number} [props.amount]
54368
+ * @param {Long | number | BigNumber | bigint} [props.amount]
54347
54369
  * @param {AccountId[]} [props.payerAccountIds]
54348
54370
  */
54349
54371
  constructor(props = {}) {
@@ -54428,12 +54450,11 @@
54428
54450
  }
54429
54451
 
54430
54452
  /**
54431
- * @param {Long | number} amount
54453
+ * @param {Long | number | BigNumber | bigint} amount
54432
54454
  * @returns {AssessedCustomFee}
54433
54455
  */
54434
54456
  setAmount(amount) {
54435
- this._amount =
54436
- typeof amount === "number" ? Long.fromNumber(amount) : amount;
54457
+ this._amount = convertAmountToLong(amount);
54437
54458
  return this;
54438
54459
  }
54439
54460
 
@@ -54672,7 +54693,7 @@
54672
54693
  * @param {TokenId | string} props.tokenId
54673
54694
  * @param {AccountId | string} props.accountId
54674
54695
  * @param {number | null} props.expectedDecimals
54675
- * @param {Long | number} props.amount
54696
+ * @param {Long | number | BigNumber | bigint} props.amount
54676
54697
  * @param {boolean} props.isApproved
54677
54698
  */
54678
54699
  constructor(props) {
@@ -54697,7 +54718,7 @@
54697
54718
  : AccountId.fromString(props.accountId);
54698
54719
 
54699
54720
  this.expectedDecimals = props.expectedDecimals;
54700
- this.amount = Long.fromValue(props.amount);
54721
+ this.amount = convertAmountToLong(props.amount);
54701
54722
  this.isApproved = props.isApproved;
54702
54723
  }
54703
54724
 
@@ -55033,15 +55054,19 @@
55033
55054
  */
55034
55055
 
55035
55056
 
55057
+ /**
55058
+ * @typedef {import("bignumber.js").default} BigNumber
55059
+ */
55060
+
55036
55061
  class PendingAirdropRecord {
55037
55062
  /**
55038
55063
  * @param {object} props
55039
55064
  * @param {PendingAirdropId} props.airdropId
55040
- * @param {Long} props.amount
55065
+ * @param {Long | number | BigNumber | bigint} props.amount
55041
55066
  */
55042
55067
  constructor(props) {
55043
55068
  this.airdropId = props.airdropId;
55044
- this.amount = props.amount;
55069
+ this.amount = convertAmountToLong(props.amount);
55045
55070
  }
55046
55071
 
55047
55072
  /**
@@ -56652,6 +56677,10 @@
56652
56677
  // SPDX-License-Identifier: Apache-2.0
56653
56678
 
56654
56679
 
56680
+ /**
56681
+ * @typedef {import("bignumber.js").default} BigNumber
56682
+ */
56683
+
56655
56684
  /**
56656
56685
  * @namespace proto
56657
56686
  * @typedef {import("@hashgraph/proto").proto.ICustomFee} HieroProto.proto.ICustomFee
@@ -56665,7 +56694,7 @@
56665
56694
  * @param {AccountId | string} [props.feeCollectorAccountId]
56666
56695
  * @param {boolean} [props.allCollectorsAreExempt]
56667
56696
  * @param {TokenId | string} [props.denominatingTokenId]
56668
- * @param {Long | number} [props.amount]
56697
+ * @param {Long | number | BigNumber | bigint} [props.amount]
56669
56698
  */
56670
56699
  constructor(props = {}) {
56671
56700
  super(props);
@@ -56743,12 +56772,11 @@
56743
56772
  }
56744
56773
 
56745
56774
  /**
56746
- * @param {Long | number} amount
56775
+ * @param {Long | number | BigNumber | bigint} amount
56747
56776
  * @returns {CustomFixedFee}
56748
56777
  */
56749
56778
  setAmount(amount) {
56750
- this._amount =
56751
- typeof amount === "number" ? Long.fromNumber(amount) : amount;
56779
+ this._amount = convertAmountToLong(amount);
56752
56780
  return this;
56753
56781
  }
56754
56782
 
@@ -58255,6 +58283,65 @@
58255
58283
  );
58256
58284
  }
58257
58285
 
58286
+ /**
58287
+ * Apply maxNodesPerTransaction limit to an already frozen transaction.
58288
+ * This trims the node list to the first N nodes while preserving existing signatures.
58289
+ *
58290
+ * Note: This method assumes the caller has already verified that trimming is needed.
58291
+ *
58292
+ * @private
58293
+ * @param {import("../client/Client.js").default<Channel, *>} client
58294
+ */
58295
+ _applyMaxNodesPerTransactionLimit(client) {
58296
+ const maxNodes = client.maxNodesPerTransaction;
58297
+
58298
+ if (maxNodes <= 0 || this._nodeAccountIds.length <= maxNodes) {
58299
+ return;
58300
+ }
58301
+
58302
+ if (this._logger) {
58303
+ this._logger.debug(
58304
+ `Trimming frozen transaction from ${this._nodeAccountIds.length} nodes to ${maxNodes} nodes based on maxNodesPerTransaction setting`,
58305
+ );
58306
+ }
58307
+
58308
+ // Trim the node account IDs to the first N nodes
58309
+ const trimmedNodeIds = this._nodeAccountIds.list.slice(0, maxNodes);
58310
+
58311
+ // Trim the signed transactions to match the trimmed node list
58312
+ // Each chunk has transactions for all nodes, so we need to trim each chunk
58313
+ const nodeCount = this._nodeAccountIds.length;
58314
+ const chunkCount = this._transactionIds.length;
58315
+ const trimmedSignedTransactions = [];
58316
+
58317
+ for (let chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++) {
58318
+ const chunkStart = chunkIndex * nodeCount;
58319
+
58320
+ // Add the first maxNodes transactions from this chunk
58321
+ for (let nodeIndex = 0; nodeIndex < maxNodes; nodeIndex++) {
58322
+ const transactionIndex = chunkStart + nodeIndex;
58323
+ if (transactionIndex < this._signedTransactions.length) {
58324
+ trimmedSignedTransactions.push(
58325
+ this._signedTransactions.get(transactionIndex),
58326
+ );
58327
+ }
58328
+ }
58329
+ }
58330
+
58331
+ // Clear and rebuild the transactions list since it's derived from signed transactions
58332
+ this._transactions.clear();
58333
+
58334
+ // Update the node account IDs (we need to unlock, update, and relock)
58335
+ this._nodeAccountIds.locked = false;
58336
+
58337
+ this._nodeAccountIds.setList(trimmedNodeIds);
58338
+
58339
+ this._nodeAccountIds.locked = true;
58340
+
58341
+ // Update the signed transactions
58342
+ this._signedTransactions.setList(trimmedSignedTransactions);
58343
+ }
58344
+
58258
58345
  /**
58259
58346
  * @description Set the key that will sign the batch of which this Transaction is a part of.
58260
58347
  * @param {Key} batchKey
@@ -58631,6 +58718,10 @@
58631
58718
  this.freezeWith(client);
58632
58719
  }
58633
58720
 
58721
+ // Apply maxNodesPerTransaction limit to already frozen transaction
58722
+ // This allows changing the node count even after freezing while preserving signatures
58723
+ this._applyMaxNodesPerTransactionLimit(client);
58724
+
58634
58725
  // Valid checksums if the option is enabled
58635
58726
  if (client.isAutoValidateChecksumsEnabled()) {
58636
58727
  this._validateChecksums(client);
@@ -59397,6 +59488,10 @@
59397
59488
 
59398
59489
  // SPDX-License-Identifier: Apache-2.0
59399
59490
 
59491
+ /**
59492
+ * @typedef {import("bignumber.js").default} BigNumber
59493
+ */
59494
+
59400
59495
  /**
59401
59496
  * @namespace proto
59402
59497
  * @typedef {import("@hashgraph/proto").proto.ITokenAirdropTransactionBody} HieroProto.proto.ITokenAirdropTransactionBody
@@ -59406,7 +59501,7 @@
59406
59501
  * @typedef {object} TransferTokensInput
59407
59502
  * @property {TokenId | string} tokenId
59408
59503
  * @property {AccountId | string} accountId
59409
- * @property {Long | number} amount
59504
+ * @property {Long | number | BigNumber | bigint} amount
59410
59505
  */
59411
59506
 
59412
59507
  /**
@@ -59485,7 +59580,7 @@
59485
59580
  /**
59486
59581
  * @param {TokenId | string} tokenId
59487
59582
  * @param {AccountId | string} accountId
59488
- * @param {number | Long} amount
59583
+ * @param {number | Long | BigNumber | bigint} amount
59489
59584
  * @param {boolean} isApproved
59490
59585
  * @param {number | null} expectedDecimals
59491
59586
  * @returns {this}
@@ -59505,7 +59600,7 @@
59505
59600
  accountId instanceof AccountId
59506
59601
  ? accountId
59507
59602
  : AccountId.fromString(accountId);
59508
- const value = amount instanceof Long ? amount : Long.fromNumber(amount);
59603
+ const value = convertAmountToLong(amount);
59509
59604
 
59510
59605
  for (const tokenTransfer of this._tokenTransfers) {
59511
59606
  if (
@@ -59534,7 +59629,7 @@
59534
59629
  /**
59535
59630
  * @param {TokenId | string} tokenId
59536
59631
  * @param {AccountId | string} accountId
59537
- * @param {number | Long} amount
59632
+ * @param {number | Long | BigNumber | bigint} amount
59538
59633
  * @returns {this}
59539
59634
  */
59540
59635
  addTokenTransfer(tokenId, accountId, amount) {
@@ -59676,7 +59771,7 @@
59676
59771
  /**
59677
59772
  * @param {TokenId | string} tokenId
59678
59773
  * @param {AccountId | string} accountId
59679
- * @param {number | Long} amount
59774
+ * @param {number | Long | BigNumber | bigint} amount
59680
59775
  * @returns {this}
59681
59776
  */
59682
59777
  addApprovedTokenTransfer(tokenId, accountId, amount) {
@@ -59686,7 +59781,7 @@
59686
59781
  /**
59687
59782
  * @param {TokenId | string} tokenId
59688
59783
  * @param {AccountId | string} accountId
59689
- * @param {number | Long} amount
59784
+ * @param {number | Long | BigNumber | bigint} amount
59690
59785
  * @param {number} decimals
59691
59786
  * @returns {this}
59692
59787
  */
@@ -59699,7 +59794,7 @@
59699
59794
  accountId instanceof AccountId
59700
59795
  ? accountId
59701
59796
  : AccountId.fromString(accountId);
59702
- const value = amount instanceof Long ? amount : Long.fromNumber(amount);
59797
+ const value = convertAmountToLong(amount);
59703
59798
 
59704
59799
  let found = false;
59705
59800
 
@@ -59994,6 +60089,7 @@
59994
60089
  * @typedef {import("../account/AccountId.js").default} AccountId
59995
60090
  * @typedef {import("./NftId.js").default} NftId
59996
60091
  * @typedef {import("./TokenId.js").default} TokenId
60092
+ * @typedef {import("bignumber.js").default} BigNumber
59997
60093
  */
59998
60094
 
59999
60095
  /**
@@ -60089,7 +60185,7 @@
60089
60185
  *
60090
60186
  * @param {TokenId} tokenId
60091
60187
  * @param {AccountId} accountId
60092
- * @param {Long} amount
60188
+ * @param {Long | number | BigNumber | bigint} amount
60093
60189
  * @param {number} expectedDecimals
60094
60190
  * @returns {this}
60095
60191
  */
@@ -60640,6 +60736,7 @@
60640
60736
 
60641
60737
  /**
60642
60738
  * @typedef {import("../client/Client.js").default<*, *>} Client
60739
+ * @typedef {import("bignumber.js").default} BigNumber
60643
60740
  */
60644
60741
 
60645
60742
  /**
@@ -60656,7 +60753,7 @@
60656
60753
  * @param {TokenId} props.tokenId
60657
60754
  * @param {AccountId | null} props.spenderAccountId
60658
60755
  * @param {AccountId | null} props.ownerAccountId
60659
- * @param {Long | null} props.amount
60756
+ * @param {Long | number | BigNumber | bigint | null} props.amount
60660
60757
  */
60661
60758
  constructor(props) {
60662
60759
  /**
@@ -60687,7 +60784,8 @@
60687
60784
  *
60688
60785
  * @readonly
60689
60786
  */
60690
- this.amount = props.amount;
60787
+ this.amount =
60788
+ props.amount != null ? convertAmountToLong(props.amount) : null;
60691
60789
 
60692
60790
  Object.freeze(this);
60693
60791
  }
@@ -61704,12 +61802,15 @@
61704
61802
  * @param {TokenId | string} tokenId
61705
61803
  * @param {AccountId | string} ownerAccountId
61706
61804
  * @param {AccountId | ContractId | string} spenderAccountId
61707
- * @param {Long | number} amount
61805
+ * @param {Long | number | BigNumber | bigint} amount
61708
61806
  * @returns {AccountAllowanceApproveTransaction}
61709
61807
  */
61710
61808
  approveTokenAllowance(tokenId, ownerAccountId, spenderAccountId, amount) {
61711
61809
  this._requireNotFrozen();
61712
61810
 
61811
+ // Convert amount to Long
61812
+ const amountLong = convertAmountToLong(amount);
61813
+
61713
61814
  this._tokenApprovals.push(
61714
61815
  new TokenAllowance({
61715
61816
  tokenId:
@@ -61736,10 +61837,7 @@
61736
61837
  ownerAccountId.toEvmAddress(),
61737
61838
  )
61738
61839
  : ownerAccountId,
61739
- amount:
61740
- typeof amount === "number"
61741
- ? Long.fromNumber(amount)
61742
- : amount,
61840
+ amount: amountLong,
61743
61841
  }),
61744
61842
  );
61745
61843
 
@@ -61750,12 +61848,15 @@
61750
61848
  * @deprecated - Use `approveTokenAllowance()` instead
61751
61849
  * @param {TokenId | string} tokenId
61752
61850
  * @param {AccountId | string} spenderAccountId
61753
- * @param {Long | number} amount
61851
+ * @param {Long | number | BigNumber | bigint} amount
61754
61852
  * @returns {AccountAllowanceApproveTransaction}
61755
61853
  */
61756
61854
  addTokenAllowance(tokenId, spenderAccountId, amount) {
61757
61855
  this._requireNotFrozen();
61758
61856
 
61857
+ // Convert amount to Long
61858
+ const amountLong = convertAmountToLong(amount);
61859
+
61759
61860
  this._tokenApprovals.push(
61760
61861
  new TokenAllowance({
61761
61862
  tokenId:
@@ -61766,10 +61867,7 @@
61766
61867
  typeof spenderAccountId === "string"
61767
61868
  ? AccountId.fromString(spenderAccountId)
61768
61869
  : spenderAccountId,
61769
- amount:
61770
- typeof amount === "number"
61771
- ? Long.fromNumber(amount)
61772
- : amount,
61870
+ amount: amountLong,
61773
61871
  ownerAccountId: null,
61774
61872
  }),
61775
61873
  );
@@ -79568,29 +79666,27 @@
79568
79666
  throw new Error("Contract ID is not set");
79569
79667
  }
79570
79668
  this._fillEvmAddress();
79571
- let mirrorNetworkAddress = client.mirrorNetwork[0];
79572
- const contractCallEndpoint = "/api/v1/contracts/call";
79573
-
79574
- if (!client.ledgerId || client.ledgerId?.isLocalNode()) {
79575
- const currentMirrorNetworkPort =
79576
- client.mirrorNetwork[0].split(":")[1];
79577
- mirrorNetworkAddress = "http://"
79578
- .concat(
79579
- client.mirrorNetwork[0].replace(
79580
- currentMirrorNetworkPort,
79581
- "8545",
79582
- ),
79583
- )
79584
- .concat(contractCallEndpoint);
79585
- } else {
79586
- let trimmed = client.mirrorNetwork[0].split(":");
79587
- mirrorNetworkAddress = "https://"
79588
- .concat(trimmed[0])
79589
- .concat(contractCallEndpoint);
79669
+ let mirrorRestApiBaseUrl = client.mirrorRestApiBaseUrl;
79670
+ const contractCallEndpointPath = "/contracts/call";
79671
+
79672
+ // Check if this is a local environment (localhost or 127.0.0.1)
79673
+ const mirrorNode = client._mirrorNetwork.getNextMirrorNode();
79674
+ const host = mirrorNode.address.address;
79675
+ const isLocalEnvironment = host === "localhost" || host === "127.0.0.1";
79676
+
79677
+ if (isLocalEnvironment) {
79678
+ // For local environments, use HTTP scheme and port 8545 for contract calls
79679
+ // (different from general mirror node REST API port 5551)
79680
+ const url = new URL(mirrorRestApiBaseUrl);
79681
+ url.protocol = "http:";
79682
+ url.port = "8545";
79683
+ mirrorRestApiBaseUrl = url.toString();
79590
79684
  }
79591
79685
 
79686
+ const contractCallEndpointUrl = `${mirrorRestApiBaseUrl}${contractCallEndpointPath}`;
79687
+
79592
79688
  // eslint-disable-next-line n/no-unsupported-features/node-builtins
79593
- const response = await fetch(mirrorNetworkAddress, {
79689
+ const response = await fetch(contractCallEndpointUrl, {
79594
79690
  method: "POST",
79595
79691
  headers: {
79596
79692
  "Content-Type": "application/json",
@@ -82931,6 +83027,7 @@
82931
83027
  * @typedef {import("../client/Client.js").default<*, *>} Client
82932
83028
  * @typedef {import("../account/AccountId.js").default} AccountId
82933
83029
  * @typedef {import("../transaction/TransactionId.js").default} TransactionId
83030
+ * @typedef {import("bignumber.js").default} BigNumber
82934
83031
  */
82935
83032
 
82936
83033
  /**
@@ -82940,7 +83037,7 @@
82940
83037
  /**
82941
83038
  * @param {object} [props]
82942
83039
  * @param {TokenId | string} [props.tokenId]
82943
- * @param {Long | number} [props.amount]
83040
+ * @param {Long | number | BigNumber | bigint} [props.amount]
82944
83041
  * @param {(Long | number)[]} [props.serials]
82945
83042
  */
82946
83043
  constructor(props = {}) {
@@ -83048,12 +83145,12 @@
83048
83145
  }
83049
83146
 
83050
83147
  /**
83051
- * @param {Long | number} amount
83148
+ * @param {Long | number | BigNumber | bigint} amount
83052
83149
  * @returns {this}
83053
83150
  */
83054
83151
  setAmount(amount) {
83055
83152
  this._requireNotFrozen();
83056
- this._amount = amount instanceof Long ? amount : Long.fromValue(amount);
83153
+ this._amount = convertAmountToLong(amount);
83057
83154
 
83058
83155
  return this;
83059
83156
  }
@@ -84084,7 +84181,7 @@
84084
84181
  * @param {string} [props.tokenName]
84085
84182
  * @param {string} [props.tokenSymbol]
84086
84183
  * @param {Long | number} [props.decimals]
84087
- * @param {Long | number} [props.initialSupply]
84184
+ * @param {Long | number | BigNumber | bigint} [props.initialSupply]
84088
84185
  * @param {AccountId | string} [props.treasuryAccountId]
84089
84186
  * @param {Key} [props.adminKey]
84090
84187
  * @param {Key} [props.kycKey]
@@ -84101,7 +84198,7 @@
84101
84198
  * @param {CustomFee[]} [props.customFees]
84102
84199
  * @param {TokenType} [props.tokenType]
84103
84200
  * @param {TokenSupplyType} [props.supplyType]
84104
- * @param {Long | number} [props.maxSupply]
84201
+ * @param {Long | number | BigNumber | bigint} [props.maxSupply]
84105
84202
  * @param {Key} [props.metadataKey]
84106
84203
  * @param {Uint8Array} [props.metadata]
84107
84204
  */
@@ -84526,12 +84623,12 @@
84526
84623
  }
84527
84624
 
84528
84625
  /**
84529
- * @param {Long | number} initialSupply
84626
+ * @param {Long | number | BigNumber | bigint} initialSupply
84530
84627
  * @returns {this}
84531
84628
  */
84532
84629
  setInitialSupply(initialSupply) {
84533
84630
  this._requireNotFrozen();
84534
- this._initialSupply = Long.fromValue(initialSupply);
84631
+ this._initialSupply = convertAmountToLong(initialSupply);
84535
84632
 
84536
84633
  return this;
84537
84634
  }
@@ -84859,14 +84956,11 @@
84859
84956
  }
84860
84957
 
84861
84958
  /**
84862
- * @param {Long | number} maxSupply
84959
+ * @param {Long | number | BigNumber | bigint} maxSupply
84863
84960
  * @returns {this}
84864
84961
  */
84865
84962
  setMaxSupply(maxSupply) {
84866
- this._maxSupply =
84867
- typeof maxSupply === "number"
84868
- ? Long.fromNumber(maxSupply)
84869
- : maxSupply;
84963
+ this._maxSupply = convertAmountToLong(maxSupply);
84870
84964
  return this;
84871
84965
  }
84872
84966
 
@@ -86407,6 +86501,7 @@
86407
86501
  * @typedef {import("../client/Client.js").default<*, *>} Client
86408
86502
  * @typedef {import("../account/AccountId.js").default} AccountId
86409
86503
  * @typedef {import("../transaction/TransactionId.js").default} TransactionId
86504
+ * @typedef {import("bignumber.js").default} BigNumber
86410
86505
  */
86411
86506
 
86412
86507
  /**
@@ -86416,7 +86511,7 @@
86416
86511
  /**
86417
86512
  * @param {object} [props]
86418
86513
  * @param {TokenId | string} [props.tokenId]
86419
- * @param {Long | number} [props.amount]
86514
+ * @param {Long | number | BigNumber | bigint} [props.amount]
86420
86515
  * @param {Uint8Array[]} [props.metadata]
86421
86516
  */
86422
86517
  constructor(props = {}) {
@@ -86522,12 +86617,12 @@
86522
86617
  }
86523
86618
 
86524
86619
  /**
86525
- * @param {Long | number} amount
86620
+ * @param {Long | number | BigNumber | bigint} amount
86526
86621
  * @returns {this}
86527
86622
  */
86528
86623
  setAmount(amount) {
86529
86624
  this._requireNotFrozen();
86530
- this._amount = amount instanceof Long ? amount : Long.fromValue(amount);
86625
+ this._amount = convertAmountToLong(amount);
86531
86626
 
86532
86627
  return this;
86533
86628
  }
@@ -88756,6 +88851,7 @@
88756
88851
  * @typedef {import("../channel/Channel.js").default} Channel
88757
88852
  * @typedef {import("../client/Client.js").default<*, *>} Client
88758
88853
  * @typedef {import("../transaction/TransactionId.js").default} TransactionId
88854
+ * @typedef {import("bignumber.js").default} BigNumber
88759
88855
  */
88760
88856
 
88761
88857
  /**
@@ -88766,7 +88862,7 @@
88766
88862
  * @param {object} [props]
88767
88863
  * @param {TokenId | string} [props.tokenId]
88768
88864
  * @param {AccountId | string} [props.accountId]
88769
- * @param {Long | number} [props.amount]
88865
+ * @param {Long | number | BigNumber | bigint} [props.amount]
88770
88866
  * @param {(Long | number)[]} [props.serials]
88771
88867
  */
88772
88868
  constructor(props = {}) {
@@ -88909,12 +89005,12 @@
88909
89005
  }
88910
89006
 
88911
89007
  /**
88912
- * @param {Long | number} amount
89008
+ * @param {Long | number | BigNumber | bigint} amount
88913
89009
  * @returns {this}
88914
89010
  */
88915
89011
  setAmount(amount) {
88916
89012
  this._requireNotFrozen();
88917
- this._amount = amount instanceof Long ? amount : Long.fromValue(amount);
89013
+ this._amount = convertAmountToLong(amount);
88918
89014
 
88919
89015
  return this;
88920
89016
  }
@@ -96616,6 +96712,55 @@
96616
96712
  getKey() {
96617
96713
  return this._address.toString();
96618
96714
  }
96715
+
96716
+ /**
96717
+ * Gets the base URL for this mirror node's REST API.
96718
+ *
96719
+ * @returns {string} The base URL for the mirror node REST API
96720
+ * @throws {Error} When the mirror node has invalid address configuration
96721
+ */
96722
+ get mirrorRestApiBaseUrl() {
96723
+ const host = this.address.address;
96724
+ const port = this.address.port;
96725
+
96726
+ if (!host || !port) {
96727
+ throw new Error("Mirror node has invalid address configuration");
96728
+ }
96729
+
96730
+ // For localhost/127.0.0.1, mirror node gRPC and REST API use different ports
96731
+ // gRPC typically uses port 5600, but REST API uses port 5551
96732
+ // Note: Contract calls may use port 8545 (handled separately in MirrorNodeContractQuery)
96733
+ if (host === "localhost" || host === "127.0.0.1") {
96734
+ return `http://${host}:5551/api/v1`;
96735
+ }
96736
+
96737
+ const scheme = this._getSchemeFromHostAndPort(host, port);
96738
+
96739
+ return `${scheme}://${host}:${port}/api/v1`;
96740
+ }
96741
+
96742
+ /**
96743
+ * Determines the appropriate scheme (http/https) based on the host and port.
96744
+ *
96745
+ * @private
96746
+ * @param {string} host - The host address
96747
+ * @param {number} port - The port number
96748
+ * @returns {string} - The scheme ('http' or 'https')
96749
+ */
96750
+ _getSchemeFromHostAndPort(host, port) {
96751
+ // For localhost and 127.0.0.1, use HTTP scheme
96752
+ if (host === "localhost" || host === "127.0.0.1") {
96753
+ return "http";
96754
+ }
96755
+
96756
+ // Standard HTTP ports
96757
+ if (port === 80) {
96758
+ return "http";
96759
+ }
96760
+
96761
+ // For other ports, assume HTTPS for security
96762
+ return "https";
96763
+ }
96619
96764
  }
96620
96765
 
96621
96766
  // SPDX-License-Identifier: Apache-2.0
@@ -96702,6 +96847,24 @@
96702
96847
  getNextMirrorNode() {
96703
96848
  return this._getNumberOfMostHealthyNodes(1)[0];
96704
96849
  }
96850
+
96851
+ /**
96852
+ * Gets the base URL for the mirror node REST API.
96853
+ *
96854
+ * @returns {string} The base URL for the mirror node REST API
96855
+ * @throws {Error} When no mirror network is configured or available
96856
+ */
96857
+ get mirrorRestApiBaseUrl() {
96858
+ try {
96859
+ const mirrorNode = this.getNextMirrorNode();
96860
+ return mirrorNode.mirrorRestApiBaseUrl;
96861
+ } catch (error) {
96862
+ // Re-throw with a more descriptive error message
96863
+ throw new Error(
96864
+ "Client has no mirror network configured or no healthy mirror nodes are available",
96865
+ );
96866
+ }
96867
+ }
96705
96868
  };
96706
96869
 
96707
96870
  /* NOSONAR */
@@ -96736,6 +96899,9 @@
96736
96899
  "node29.swirldslabs.com:443": new AccountId(32),
96737
96900
  "node30.swirldslabs.com:443": new AccountId(33),
96738
96901
  "node31.swirldslabs.com:443": new AccountId(34),
96902
+ // "node32.swirldslabs.com:443": new AccountId(35), - temporarily disabled
96903
+ "node33.swirldslabs.com:443": new AccountId(36),
96904
+ "node34.swirldslabs.com:443": new AccountId(37),
96739
96905
  };
96740
96906
 
96741
96907
  const WEB_TESTNET = {
@@ -97467,6 +97633,14 @@
97467
97633
  return this._mirrorNetwork.network;
97468
97634
  }
97469
97635
 
97636
+ /**
97637
+ * @returns {string}
97638
+ * @throws {Error} When no mirror network is configured or available
97639
+ */
97640
+ get mirrorRestApiBaseUrl() {
97641
+ return this._mirrorNetwork.mirrorRestApiBaseUrl;
97642
+ }
97643
+
97470
97644
  /**
97471
97645
  * @returns {boolean}
97472
97646
  */
@@ -97735,15 +97909,24 @@
97735
97909
  }
97736
97910
 
97737
97911
  /**
97738
- * @returns {number}
97912
+ * Gets the maximum number of nodes that a transaction or query will attempt to execute against.
97913
+ *
97914
+ * @returns {number} The current maximum nodes per transaction setting.
97915
+ * Returns -1 if no limit is set (uses network defaults).
97739
97916
  */
97740
97917
  get maxNodesPerTransaction() {
97741
97918
  return this._network.maxNodesPerTransaction;
97742
97919
  }
97743
97920
 
97744
97921
  /**
97745
- * @param {number} maxNodesPerTransaction
97746
- * @returns {this}
97922
+ * Sets the maximum number of nodes that a transaction or query will execute against.
97923
+ *
97924
+ * - **Before freezing**: Limits automatic node selection when no explicit nodes are set
97925
+ * - **After freezing**: Trims frozen transactions to the first N nodes while preserving signatures
97926
+ * - **Special values**: 0 disables limiting, values > available nodes cause no trimming
97927
+ *
97928
+ * @param {number} maxNodesPerTransaction - Maximum nodes per transaction. Set to 0 to disable.
97929
+ * @returns {this} The client instance for method chaining
97747
97930
  */
97748
97931
  setMaxNodesPerTransaction(maxNodesPerTransaction) {
97749
97932
  this._network.setMaxNodesPerTransaction(maxNodesPerTransaction);
@@ -98074,7 +98257,7 @@
98074
98257
 
98075
98258
  const SDK_NAME = "hiero-sdk-js";
98076
98259
  const SDK_VERSION =
98077
- "2.73.1" ;
98260
+ "2.74.0" ;
98078
98261
 
98079
98262
  // SPDX-License-Identifier: Apache-2.0
98080
98263