starknet 11.10.6 → 11.10.8

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,15 @@
1
+ ## [11.10.8](https://github.com/starknet-io/starknet.js/compare/v11.10.7...v11.10.8) (2026-12-03)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **num:** return 0n from tryToBigInt for a zero value ([#1778](https://github.com/starknet-io/starknet.js/issues/1778)) ([ec4fc00](https://github.com/starknet-io/starknet.js/commit/ec4fc00d0509e2242f2c2799ec29e15a89d818ae))
6
+
7
+ ## [11.10.7](https://github.com/starknet-io/starknet.js/compare/v11.10.6...v11.10.7) (2026-12-03)
8
+
9
+ ### Bug Fixes
10
+
11
+ - **num:** normalize a hex input in getHexString ([#1776](https://github.com/starknet-io/starknet.js/issues/1776)) ([d643b7a](https://github.com/starknet-io/starknet.js/commit/d643b7a89594e58b81f23f7ce48a283c8512bead))
12
+
1
13
  ## [11.10.6](https://github.com/starknet-io/starknet.js/compare/v11.10.5...v11.10.6) (2026-12-02)
2
14
 
3
15
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -12278,6 +12278,11 @@ declare function toBigInt(value: BigNumberish): bigint;
12278
12278
  /**
12279
12279
  * try to convert BigNumberish to bigint
12280
12280
  * in case of undefined return undefined
12281
+ * @example
12282
+ * ```typescript
12283
+ * tryToBigInt(0); // 0n
12284
+ * tryToBigInt(undefined); // undefined
12285
+ * ```
12281
12286
  */
12282
12287
  declare function tryToBigInt(value: BigNumberish | undefined): bigint | undefined;
12283
12288
  /**
@@ -12427,18 +12432,28 @@ declare function isStringWholeNumber(str: string): boolean;
12427
12432
  */
12428
12433
  declare function getDecimalString(str: string): string;
12429
12434
  /**
12430
- * Convert string to hexadecimal string
12435
+ * Convert a hex-string, or a string of decimal digits, to a hex-string
12431
12436
  *
12432
- * @param {string} str string to convert
12433
- * @returns converted hex-string
12434
- * @throws str needs to be a number string in hex or whole number format
12437
+ * The result has the form that a node expects for a felt: it starts with `0x`,
12438
+ * its letters are lowercase, and it has no leading zero.
12439
+ * For example, `'0X1F'` and `'0x001f'` both give `'0x1f'`.
12440
+ * @param {string} str the string to convert, like `'123'` or `'0X7B'`
12441
+ * @returns {string} the hex-string
12442
+ * @throws {Error} when `str` is `'0x'`, which has no digit
12443
+ * @throws {Error} when `str` is not a hex-string and not a string of decimal digits
12435
12444
  * @example
12436
12445
  * ```typescript
12437
12446
  * const result = getHexString("123");
12438
12447
  * // result = "0x7b"
12439
12448
  *
12440
- * const result2 = getHexString("Hello");
12449
+ * const result2 = getHexString("0X001F");
12450
+ * // result2 = "0x1f"
12451
+ *
12452
+ * const result3 = getHexString("Hello");
12441
12453
  * // throws Error: Hello needs to be a hex-string or whole-number-string
12454
+ *
12455
+ * const result4 = getHexString("0x");
12456
+ * // throws Error: Invalid input: '0x' holds no hexadecimal digit
12442
12457
  * ```
12443
12458
  */
12444
12459
  declare function getHexString(str: string): string;
@@ -3088,7 +3088,7 @@ ${indent}}` : "}";
3088
3088
  return BigInt(value);
3089
3089
  }
3090
3090
  function tryToBigInt(value) {
3091
- return value ? BigInt(value) : void 0;
3091
+ return value === void 0 ? void 0 : BigInt(value);
3092
3092
  }
3093
3093
  function toHex(value) {
3094
3094
  const bn = toBigInt(value);
@@ -3142,7 +3142,7 @@ ${indent}}` : "}";
3142
3142
  }
3143
3143
  function getHexString(str) {
3144
3144
  if (isHex2(str)) {
3145
- return str;
3145
+ return toHex(str);
3146
3146
  }
3147
3147
  if (isStringWholeNumber(str)) {
3148
3148
  return toHexString(str);