starknet 8.5.4 → 8.5.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [8.5.5](https://github.com/starknet-io/starknet.js/compare/v8.5.4...v8.5.5) (2025-10-03)
2
+
3
+ ### Bug Fixes
4
+
5
+ - ensure cleanHex has valid output ([f5123b6](https://github.com/starknet-io/starknet.js/commit/f5123b6f9c7fa49ad104a48fd4a1f62e2520488e))
6
+
1
7
  ## [8.5.4](https://github.com/starknet-io/starknet.js/compare/v8.5.3...v8.5.4) (2025-09-17)
2
8
 
3
9
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -6078,6 +6078,7 @@ declare function tryToBigInt(value: BigNumberish | undefined): bigint | undefine
6078
6078
  * ```typescript
6079
6079
  * toHex(100); // '0x64'
6080
6080
  * toHex('200'); // '0xc8'
6081
+ * toHex('0x00023AB'); // '0x23ab'
6081
6082
  * ```
6082
6083
  */
6083
6084
  declare function toHex(value: BigNumberish): string;
@@ -6085,6 +6086,15 @@ declare function toHex(value: BigNumberish): string;
6085
6086
  * Alias of ToHex
6086
6087
  */
6087
6088
  declare const toHexString: typeof toHex;
6089
+ /**
6090
+ * Remove hex-string leading zeroes and lowercase it
6091
+ *
6092
+ * @example
6093
+ * ```typescript
6094
+ * cleanHex('0x00023AB'); // '0x23ab'
6095
+ * ```
6096
+ */
6097
+ declare function cleanHex(hex: string): string;
6088
6098
  /**
6089
6099
  * Convert BigNumberish to storage-key-string
6090
6100
  *
@@ -6127,17 +6137,6 @@ declare function toHex64(number: BigNumberish): string;
6127
6137
  * ```
6128
6138
  */
6129
6139
  declare function hexToDecimalString(hex: string): string;
6130
- /**
6131
- * Remove hex-string leading zeroes and lowercase it
6132
- *
6133
- * @param {string} hex hex-string
6134
- * @returns {string} updated string in hex-string format
6135
- * @example
6136
- * ```typescript
6137
- * cleanHex('0x00023AB'); // '0x23ab'
6138
- * ```
6139
- */
6140
- declare function cleanHex(hex: string): string;
6141
6140
  /**
6142
6141
  * Asserts input is equal to or greater then lowerBound and lower then upperBound.
6143
6142
  *
@@ -989,7 +989,7 @@ var starknet = (() => {
989
989
  return buffer.reduce((r, x) => r + x.toString(16).padStart(2, "0"), "");
990
990
  }
991
991
  function removeHexPrefix(hex) {
992
- return hex.replace(/^0x/i, "");
992
+ return hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
993
993
  }
994
994
  function addHexPrefix(hex) {
995
995
  return `0x${removeHexPrefix(hex)}`;
@@ -1031,11 +1031,10 @@ var starknet = (() => {
1031
1031
  return result;
1032
1032
  }
1033
1033
  function hexStringToUint8Array(hex) {
1034
- const cleanHex2 = hex.startsWith("0x") ? hex.slice(2) : hex;
1035
- if (cleanHex2.length > 0 && !/^[0-9a-fA-F]+$/.test(cleanHex2)) {
1036
- throw new Error(`Invalid hex string: "${hex}" contains non-hexadecimal characters`);
1034
+ if (!isHexString(addHexPrefix(hex))) {
1035
+ throw new Error(`Invalid hex string: "${hex}"`);
1037
1036
  }
1038
- const paddedHex = cleanHex2.length % 2 !== 0 ? `0${cleanHex2}` : cleanHex2;
1037
+ const paddedHex = removeHexPrefix(sanitizeHex(hex));
1039
1038
  const bytes = new Uint8Array(paddedHex.length / 2);
1040
1039
  for (let i = 0; i < paddedHex.length; i += 2) {
1041
1040
  bytes[i / 2] = parseInt(paddedHex.substring(i, i + 2), 16);
@@ -2845,6 +2844,9 @@ ${indent}}` : "}";
2845
2844
  return addHexPrefix(toBigInt(value).toString(16));
2846
2845
  }
2847
2846
  var toHexString = toHex;
2847
+ function cleanHex(hex) {
2848
+ return toHex(hex);
2849
+ }
2848
2850
  function toStorageKey(number) {
2849
2851
  return addHexPrefix(toBigInt(number).toString(16).padStart(64, "0"));
2850
2852
  }
@@ -2856,9 +2858,6 @@ ${indent}}` : "}";
2856
2858
  function hexToDecimalString(hex) {
2857
2859
  return BigInt(addHexPrefix(hex)).toString(10);
2858
2860
  }
2859
- function cleanHex(hex) {
2860
- return hex.toLowerCase().replace(/^(0x)0+/, "$1");
2861
- }
2862
2861
  function assertInRange(input, lowerBound, upperBound, inputName = "") {
2863
2862
  const messageSuffix = inputName === "" ? "invalid length" : `invalid ${inputName} length`;
2864
2863
  const inputBigInt = BigInt(input);
@@ -19828,7 +19827,7 @@ ${indent}}` : "}";
19828
19827
  throw new Error("Deployer emitted event is empty");
19829
19828
  }
19830
19829
  const event = txReceipt.events.find(
19831
- (it) => cleanHex(it.from_address) === cleanHex(toHex(this.address))
19830
+ (it) => toHex(it.from_address) === toHex(this.address)
19832
19831
  ) || {
19833
19832
  data: []
19834
19833
  };
@@ -21175,7 +21174,7 @@ ${indent}}` : "}";
21175
21174
  transaction_hash: txR.transaction_hash,
21176
21175
  ...event
21177
21176
  };
21178
- }).filter((event) => cleanHex(event.from_address) === cleanHex(this.address), []) || [];
21177
+ }).filter((event) => toHex(event.from_address) === toHex(this.address), []) || [];
21179
21178
  parsed = parseEvents(
21180
21179
  emittedEvents,
21181
21180
  this.events,