@hiero-ledger/sdk 2.71.0-beta.0 → 2.71.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 (62) hide show
  1. package/dist/umd.js +142 -40
  2. package/dist/umd.min.js +2 -2
  3. package/lib/LedgerId.cjs +4 -4
  4. package/lib/LedgerId.js +1 -1
  5. package/lib/LedgerId.js.map +1 -1
  6. package/lib/channel/NativeChannel.cjs +3 -2
  7. package/lib/channel/NativeChannel.js +1 -1
  8. package/lib/channel/NativeChannel.js.map +1 -1
  9. package/lib/channel/NodeMirrorChannel.cjs +0 -2
  10. package/lib/channel/NodeMirrorChannel.js +1 -1
  11. package/lib/channel/NodeMirrorChannel.js.map +1 -1
  12. package/lib/client/Client.cjs +3 -2
  13. package/lib/client/Client.d.ts +2 -2
  14. package/lib/client/Client.js +1 -1
  15. package/lib/client/Client.js.map +1 -1
  16. package/lib/client/NativeClient.cjs +141 -44
  17. package/lib/client/NativeClient.d.ts +48 -16
  18. package/lib/client/NativeClient.js +1 -1
  19. package/lib/client/NativeClient.js.map +1 -1
  20. package/lib/client/NodeClient.cjs +63 -2
  21. package/lib/client/NodeClient.d.ts +42 -0
  22. package/lib/client/NodeClient.js +1 -1
  23. package/lib/client/NodeClient.js.map +1 -1
  24. package/lib/client/WebClient.cjs +64 -34
  25. package/lib/client/WebClient.d.ts +35 -15
  26. package/lib/client/WebClient.js +1 -1
  27. package/lib/client/WebClient.js.map +1 -1
  28. package/lib/constants/ClientConstants.cjs +22 -7
  29. package/lib/constants/ClientConstants.d.ts +12 -6
  30. package/lib/constants/ClientConstants.js +1 -1
  31. package/lib/constants/ClientConstants.js.map +1 -1
  32. package/lib/contract/ContractCreateTransaction.cjs +5 -0
  33. package/lib/contract/ContractCreateTransaction.js +1 -1
  34. package/lib/contract/ContractCreateTransaction.js.map +1 -1
  35. package/lib/contract/ContractDeleteTransaction.cjs +35 -2
  36. package/lib/contract/ContractDeleteTransaction.d.ts +18 -0
  37. package/lib/contract/ContractDeleteTransaction.js +1 -1
  38. package/lib/contract/ContractDeleteTransaction.js.map +1 -1
  39. package/lib/contract/ContractUpdateTransaction.cjs +2 -1
  40. package/lib/contract/ContractUpdateTransaction.js +1 -1
  41. package/lib/contract/ContractUpdateTransaction.js.map +1 -1
  42. package/lib/encoding/hex.cjs +11 -0
  43. package/lib/encoding/hex.js +1 -1
  44. package/lib/encoding/hex.js.map +1 -1
  45. package/lib/native.cjs +2 -2
  46. package/lib/native.d.ts +1 -1
  47. package/lib/native.js +1 -1
  48. package/lib/version.js +1 -1
  49. package/package.json +2 -2
  50. package/src/LedgerId.js +4 -4
  51. package/src/channel/NativeChannel.js +9 -1
  52. package/src/channel/NodeMirrorChannel.js +0 -2
  53. package/src/client/Client.js +4 -2
  54. package/src/client/NativeClient.js +151 -47
  55. package/src/client/NodeClient.js +56 -3
  56. package/src/client/WebClient.js +63 -44
  57. package/src/constants/ClientConstants.js +26 -8
  58. package/src/contract/ContractCreateTransaction.js +5 -3
  59. package/src/contract/ContractDeleteTransaction.js +34 -0
  60. package/src/contract/ContractUpdateTransaction.js +4 -1
  61. package/src/encoding/hex.js +20 -0
  62. package/src/native.js +1 -1
package/dist/umd.js CHANGED
@@ -36822,6 +36822,26 @@
36822
36822
  */
36823
36823
  function decode$2(text) {
36824
36824
  const str = text.startsWith("0x") ? text.substring(2) : text;
36825
+
36826
+ if (str.length % 2 !== 0) {
36827
+ throw new Error(
36828
+ "Invalid hex string: Must have an even number of characters.",
36829
+ );
36830
+ }
36831
+
36832
+ if (/[^0-9a-fA-F]/.test(str)) {
36833
+ throw new Error(
36834
+ "Invalid hex string: Contains non-hexadecimal characters.",
36835
+ );
36836
+ }
36837
+
36838
+ const bytes = new Uint8Array(str.length / 2);
36839
+
36840
+ for (let i = 0; i < str.length; i += 2) {
36841
+ const byte = parseInt(str.substring(i, i + 2), 16);
36842
+ bytes[i / 2] = byte;
36843
+ }
36844
+
36825
36845
  return Buffer.from(str, "hex");
36826
36846
  }
36827
36847
 
@@ -64059,11 +64079,11 @@
64059
64079
  case "3":
64060
64080
  return LedgerId.LOCAL_NODE;
64061
64081
  default: {
64062
- let ledgerIdDecoded = decode$8(ledgerId);
64063
- if (ledgerIdDecoded.length == 0 && ledgerId.length != 0) {
64064
- throw new Error("Default reached for fromString");
64065
- } else {
64082
+ try {
64083
+ let ledgerIdDecoded = decode$8(ledgerId);
64066
64084
  return new LedgerId(ledgerIdDecoded);
64085
+ } catch (error) {
64086
+ throw new Error("Default reached for fromString");
64067
64087
  }
64068
64088
  }
64069
64089
  }
@@ -71937,7 +71957,9 @@
71937
71957
  setGas(gas) {
71938
71958
  this._requireNotFrozen();
71939
71959
  this._gas = gas instanceof Long ? gas : Long.fromValue(gas);
71940
-
71960
+ if (this._gas.lessThan(0)) {
71961
+ throw new Error("Gas cannot be negative number");
71962
+ }
71941
71963
  return this;
71942
71964
  }
71943
71965
 
@@ -72085,7 +72107,7 @@
72085
72107
  typeof stakedAccountId === "string"
72086
72108
  ? AccountId.fromString(stakedAccountId)
72087
72109
  : stakedAccountId;
72088
-
72110
+ this._stakedNodeId = null;
72089
72111
  return this;
72090
72112
  }
72091
72113
 
@@ -72103,7 +72125,7 @@
72103
72125
  setStakedNodeId(stakedNodeId) {
72104
72126
  this._requireNotFrozen();
72105
72127
  this._stakedNodeId = Long.fromValue(stakedNodeId);
72106
-
72128
+ this._stakedAccountId = null;
72107
72129
  return this;
72108
72130
  }
72109
72131
 
@@ -72832,6 +72854,7 @@
72832
72854
  * @param {ContractId | string} [props.contractId]
72833
72855
  * @param {ContractId | string} [props.transferContractId]
72834
72856
  * @param {AccountId | string} [props.transferAccountId]
72857
+ * @param {boolean} [props.permanentRemoval]
72835
72858
  */
72836
72859
  constructor(props = {}) {
72837
72860
  super();
@@ -72854,6 +72877,12 @@
72854
72877
  */
72855
72878
  this._transferContractId = null;
72856
72879
 
72880
+ /**
72881
+ * @private
72882
+ * @type {boolean}
72883
+ */
72884
+ this._permanentRemoval = false;
72885
+
72857
72886
  if (props.contractId != null) {
72858
72887
  this.setContractId(props.contractId);
72859
72888
  }
@@ -72865,6 +72894,10 @@
72865
72894
  if (props.transferContractId != null) {
72866
72895
  this.setTransferContractId(props.transferContractId);
72867
72896
  }
72897
+
72898
+ if (props.permanentRemoval != null) {
72899
+ this.setPermanentRemoval(props.permanentRemoval);
72900
+ }
72868
72901
  }
72869
72902
 
72870
72903
  /**
@@ -72915,6 +72948,7 @@
72915
72948
  ),
72916
72949
  )
72917
72950
  : undefined,
72951
+ permanentRemoval: contractDelete.permanentRemoval ?? false,
72918
72952
  }),
72919
72953
  transactions,
72920
72954
  signedTransactions,
@@ -72966,6 +73000,7 @@
72966
73000
  transferContractId instanceof ContractId
72967
73001
  ? transferContractId
72968
73002
  : ContractId.fromString(transferContractId);
73003
+ this._transferAccountId = null;
72969
73004
 
72970
73005
  return this;
72971
73006
  }
@@ -72989,10 +73024,30 @@
72989
73024
  transferAccountId instanceof AccountId
72990
73025
  ? transferAccountId
72991
73026
  : AccountId.fromString(transferAccountId);
73027
+ this._transferContractId = null;
72992
73028
 
72993
73029
  return this;
72994
73030
  }
72995
73031
 
73032
+ /**
73033
+ * @returns {boolean}
73034
+ */
73035
+ get permanentRemoval() {
73036
+ return this._permanentRemoval;
73037
+ }
73038
+
73039
+ /**
73040
+ * Sets the permanent removal flag.
73041
+ *
73042
+ * @param {boolean} permanentRemoval
73043
+ * @returns {ContractDeleteTransaction}
73044
+ */
73045
+ setPermanentRemoval(permanentRemoval) {
73046
+ this._requireNotFrozen();
73047
+ this._permanentRemoval = permanentRemoval;
73048
+ return this;
73049
+ }
73050
+
72996
73051
  /**
72997
73052
  * @param {Client} client
72998
73053
  */
@@ -73048,6 +73103,7 @@
73048
73103
  this._transferContractId != null
73049
73104
  ? this._transferContractId._toProtobuf()
73050
73105
  : null,
73106
+ permanentRemoval: this._permanentRemoval,
73051
73107
  };
73052
73108
  }
73053
73109
 
@@ -74464,7 +74520,9 @@
74464
74520
  : null,
74465
74521
  autoRenewAccountId:
74466
74522
  this._autoRenewAccountId != null
74467
- ? this._autoRenewAccountId._toProtobuf()
74523
+ ? this._autoRenewAccountId.toString() == "0.0.0"
74524
+ ? libExports.proto.AccountID.create()
74525
+ : this._autoRenewAccountId._toProtobuf()
74468
74526
  : null,
74469
74527
  };
74470
74528
  }
@@ -96150,7 +96208,7 @@
96150
96208
  /**
96151
96209
  * @augments {ManagedNetwork<Channel, Node, AccountId>}
96152
96210
  */
96153
- let Network$1 = class Network extends ManagedNetwork {
96211
+ class Network extends ManagedNetwork {
96154
96212
  /**
96155
96213
  * @param {(address: string) => Channel} createNetworkChannel
96156
96214
  */
@@ -96434,7 +96492,7 @@
96434
96492
  this.getNumberOfNodesForTransaction(),
96435
96493
  ).map((node) => node.accountId);
96436
96494
  }
96437
- };
96495
+ }
96438
96496
 
96439
96497
  // SPDX-License-Identifier: Apache-2.0
96440
96498
 
@@ -96617,14 +96675,6 @@
96617
96675
  "previewnet-node06-00-grpc.hedera.com:443": new AccountId(9),
96618
96676
  };
96619
96677
 
96620
- ({
96621
- "testnet-node00-00-grpc.hedera.com:443": new AccountId(3),
96622
- });
96623
-
96624
- ({
96625
- "previewnet-node00-00-grpc.hedera.com:443": new AccountId(3),
96626
- });
96627
-
96628
96678
  /**
96629
96679
  * @type {Record<string, AccountId>}
96630
96680
  */
@@ -96641,6 +96691,12 @@
96641
96691
  LOCAL_NODE: ["127.0.0.1:5600"],
96642
96692
  };
96643
96693
 
96694
+ const WebNetwork = {
96695
+ MAINNET: MAINNET,
96696
+ TESTNET: WEB_TESTNET,
96697
+ PREVIEWNET: WEB_PREVIEWNET,
96698
+ };
96699
+
96644
96700
  // SPDX-License-Identifier: Apache-2.0
96645
96701
 
96646
96702
 
@@ -97089,7 +97145,7 @@
97089
97145
  * @internal
97090
97146
  * @type {Network}
97091
97147
  */
97092
- this._network = new Network$1(this._createNetworkChannel());
97148
+ this._network = new Network(this._createNetworkChannel());
97093
97149
 
97094
97150
  /**
97095
97151
  * @internal
@@ -97741,11 +97797,11 @@
97741
97797
 
97742
97798
  /**
97743
97799
  * Update the network address book.
97744
- * @returns {Promise<void>}
97800
+ * @returns {Promise<this>}
97745
97801
  */
97746
97802
  async updateNetwork() {
97747
97803
  if (this._isUpdatingNetwork) {
97748
- return;
97804
+ return this;
97749
97805
  }
97750
97806
 
97751
97807
  this._isUpdatingNetwork = true;
@@ -97768,6 +97824,8 @@
97768
97824
  } finally {
97769
97825
  this._isUpdatingNetwork = false;
97770
97826
  }
97827
+
97828
+ return this;
97771
97829
  }
97772
97830
 
97773
97831
  /**
@@ -97882,7 +97940,7 @@
97882
97940
 
97883
97941
  const SDK_NAME = "hiero-sdk-js";
97884
97942
  const SDK_VERSION =
97885
- "2.71.0-beta.0" ;
97943
+ "2.71.0" ;
97886
97944
 
97887
97945
  // SPDX-License-Identifier: Apache-2.0
97888
97946
 
@@ -98325,12 +98383,6 @@
98325
98383
  * @typedef {import("../account/AccountId.js").default} AccountId
98326
98384
  */
98327
98385
 
98328
- const Network = {
98329
- MAINNET: MAINNET,
98330
- TESTNET: WEB_TESTNET,
98331
- PREVIEWNET: WEB_PREVIEWNET,
98332
- };
98333
-
98334
98386
  /**
98335
98387
  * Represents a client for interacting with the Hedera network over the web.
98336
98388
  * The `WebClient` class extends the base `Client` class and provides methods
@@ -98349,19 +98401,19 @@
98349
98401
  if (typeof props.network === "string") {
98350
98402
  switch (props.network) {
98351
98403
  case "mainnet":
98352
- this.setNetwork(Network.MAINNET);
98353
- this.setMirrorNetwork(MirrorNetwork.MAINNET);
98404
+ this.setNetwork(WebNetwork.MAINNET);
98354
98405
  this.setLedgerId(LedgerId.MAINNET);
98406
+ this.setMirrorNetwork(MirrorNetwork.MAINNET);
98355
98407
  break;
98356
98408
 
98357
98409
  case "testnet":
98358
- this.setNetwork(Network.TESTNET);
98410
+ this.setNetwork(WebNetwork.TESTNET);
98359
98411
  this.setLedgerId(LedgerId.TESTNET);
98360
98412
  this.setMirrorNetwork(MirrorNetwork.TESTNET);
98361
98413
  break;
98362
98414
 
98363
98415
  case "previewnet":
98364
- this.setNetwork(Network.PREVIEWNET);
98416
+ this.setNetwork(WebNetwork.PREVIEWNET);
98365
98417
  this.setLedgerId(LedgerId.PREVIEWNET);
98366
98418
  this.setMirrorNetwork(MirrorNetwork.PREVIEWNET);
98367
98419
  break;
@@ -98461,6 +98513,56 @@
98461
98513
  });
98462
98514
  }
98463
98515
 
98516
+ /**
98517
+ * Construct a Hedera client pre-configured for Mainnet access with network update.
98518
+ *
98519
+ * @returns {Promise<WebClient>}
98520
+ */
98521
+ static async forMainnetAsync() {
98522
+ return new WebClient({
98523
+ network: "mainnet",
98524
+ }).updateNetwork();
98525
+ }
98526
+
98527
+ /**
98528
+ * Construct a Hedera client pre-configured for Testnet access with network update.
98529
+ *
98530
+ * @returns {Promise<WebClient>}
98531
+ */
98532
+ static async forTestnetAsync() {
98533
+ return new WebClient({
98534
+ network: "testnet",
98535
+ }).updateNetwork();
98536
+ }
98537
+
98538
+ /**
98539
+ * Construct a Hedera client pre-configured for Previewnet access with network update.
98540
+ *
98541
+ * @returns {Promise<WebClient>}
98542
+ */
98543
+ static async forPreviewnetAsync() {
98544
+ return new WebClient({
98545
+ network: "previewnet",
98546
+ }).updateNetwork();
98547
+ }
98548
+
98549
+ /**
98550
+ * Construct a client for a specific network with optional network update.
98551
+ * Updates network only if the network is not "local-node".
98552
+ *
98553
+ * @param {string} network
98554
+ * @returns {Promise<WebClient>}
98555
+ */
98556
+ static async forNameAsync(network) {
98557
+ const client = new WebClient({ network });
98558
+
98559
+ if (network !== "local-node") {
98560
+ await client.updateNetwork();
98561
+ }
98562
+
98563
+ return client;
98564
+ }
98565
+
98464
98566
  /**
98465
98567
  * Construct a client configured to use mirror nodes.
98466
98568
  * This will query the address book to get the network nodes.
@@ -98469,9 +98571,7 @@
98469
98571
  * @returns {Promise<WebClient>}
98470
98572
  */
98471
98573
  static async forMirrorNetwork(mirrorNetwork) {
98472
- const client = new WebClient();
98473
-
98474
- client.setMirrorNetwork(mirrorNetwork);
98574
+ const client = new WebClient({ mirrorNetwork: mirrorNetwork });
98475
98575
 
98476
98576
  await client.updateNetwork();
98477
98577
 
@@ -98486,13 +98586,13 @@
98486
98586
  if (typeof network === "string") {
98487
98587
  switch (network) {
98488
98588
  case "previewnet":
98489
- this._network.setNetwork(Network.PREVIEWNET);
98589
+ this._network.setNetwork(WebNetwork.PREVIEWNET);
98490
98590
  break;
98491
98591
  case "testnet":
98492
- this._network.setNetwork(Network.TESTNET);
98592
+ this._network.setNetwork(WebNetwork.TESTNET);
98493
98593
  break;
98494
98594
  case "mainnet":
98495
- this._network.setNetwork(Network.MAINNET);
98595
+ this._network.setNetwork(WebNetwork.MAINNET);
98496
98596
  }
98497
98597
  } else {
98498
98598
  this._network.setNetwork(network);
@@ -98530,11 +98630,11 @@
98530
98630
 
98531
98631
  /**
98532
98632
  * @override
98533
- * @returns {Promise<void>}
98633
+ * @returns {Promise<this>}
98534
98634
  */
98535
98635
  async updateNetwork() {
98536
98636
  if (this._isUpdatingNetwork) {
98537
- return;
98637
+ return this;
98538
98638
  }
98539
98639
 
98540
98640
  this._isUpdatingNetwork = true;
@@ -98568,6 +98668,8 @@
98568
98668
  } finally {
98569
98669
  this._isUpdatingNetwork = false;
98570
98670
  }
98671
+
98672
+ return this;
98571
98673
  }
98572
98674
 
98573
98675
  /**