starknet 11.0.2 → 11.0.3

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
+ ## [11.0.3](https://github.com/starknet-io/starknet.js/compare/v11.0.2...v11.0.3) (2026-10-01)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **calldata:** let named arguments carry built Cairo types ([b05b91f](https://github.com/starknet-io/starknet.js/commit/b05b91f59d7795afcee3f52dbcbf98aab9aeb55d))
6
+
1
7
  ## [11.0.2](https://github.com/starknet-io/starknet.js/compare/v11.0.1...v11.0.2) (2026-09-22)
2
8
 
3
9
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -16470,7 +16470,13 @@ declare class CairoTypeOption {
16470
16470
  * Build an option, from a value a caller passed or from the felts of a response.
16471
16471
  *
16472
16472
  * A {@link CairoOption} says its own branch, so `variant` is not given with one — nor with the
16473
- * response iterator, which reads the branch off the wire. Anywhere else it is required.
16473
+ * response iterator, which reads the branch off the wire, nor with a `CairoTypeOption`, which
16474
+ * is copied as it is. Anywhere else it is required.
16475
+ *
16476
+ * For the same reason, a `CairoOption` that holds a `CairoTypeOption` is refused: once it is
16477
+ * unwrapped, the variant comes with the `CairoTypeOption`. Accepted, it would lose one level:
16478
+ * `Some(Some(1))` would be sent as `Some(None)`. Write a nested value with `CairoOption`
16479
+ * only, or build one `CairoTypeOption` for the whole type.
16474
16480
  *
16475
16481
  * `subType` is what makes an option of options work. Handed a `CairoOption`, this constructor
16476
16482
  * unwraps it and calls itself with what was inside, which for a nested option is another
@@ -16481,11 +16487,11 @@ declare class CairoTypeOption {
16481
16487
  * @param {string} optionCairoType the abi type, `core::option::Option::<T>`
16482
16488
  * @param {AllowArray<CairoTypeStrategy>} parsingStrategy how to build the value
16483
16489
  * @param {CairoOptionVariant | number} [variant] which branch, when the content does not say.
16484
- * Must be omitted when `content` is the response iterator.
16490
+ * Must be omitted when `content` is the response iterator or a `CairoTypeOption`.
16485
16491
  * @param {boolean} [subType=false] true when called from the unwrapping of a nested
16486
16492
  * `CairoOption`, which is the only caller that should set it
16487
- * @throws {Error} when the type is not an option, when the variant is missing, absurd, or
16488
- * contradicts the content
16493
+ * @throws {Error} when the type is not an option, or when the variant is missing, absurd,
16494
+ * contradicts the content, or is given with a `CairoTypeOption`
16489
16495
  * @example
16490
16496
  * ```typescript
16491
16497
  * const type = 'core::option::Option::<core::integer::u8>';
@@ -8167,7 +8167,6 @@ ${indent}}` : "}";
8167
8167
  * ```
8168
8168
  */
8169
8169
  low;
8170
- // TODO should be u128
8171
8170
  /**
8172
8171
  * The top 128 bits of the value.
8173
8172
  * @example
@@ -8177,7 +8176,6 @@ ${indent}}` : "}";
8177
8176
  * ```
8178
8177
  */
8179
8178
  high;
8180
- // TODO should be u128
8181
8179
  /**
8182
8180
  * The abi type this class serializes.
8183
8181
  * @example
@@ -8416,7 +8414,6 @@ ${indent}}` : "}";
8416
8414
  * ```
8417
8415
  */
8418
8416
  limb0;
8419
- // TODO should be u128
8420
8417
  /**
8421
8418
  * Bits 128 to 255 of the value.
8422
8419
  * @example
@@ -8426,7 +8423,6 @@ ${indent}}` : "}";
8426
8423
  * ```
8427
8424
  */
8428
8425
  limb1;
8429
- // TODO should be u128
8430
8426
  /**
8431
8427
  * Bits 256 to 383 of the value.
8432
8428
  * @example
@@ -8436,7 +8432,6 @@ ${indent}}` : "}";
8436
8432
  * ```
8437
8433
  */
8438
8434
  limb2;
8439
- // TODO should be u128
8440
8435
  /**
8441
8436
  * Bits 384 to 511 of the value.
8442
8437
  * @example
@@ -8446,7 +8441,6 @@ ${indent}}` : "}";
8446
8441
  * ```
8447
8442
  */
8448
8443
  limb3;
8449
- // TODO should be u128
8450
8444
  /**
8451
8445
  * The abi type this class serializes.
8452
8446
  * @example
@@ -13701,7 +13695,13 @@ ${indent}}` : "}";
13701
13695
  * Build an option, from a value a caller passed or from the felts of a response.
13702
13696
  *
13703
13697
  * A {@link CairoOption} says its own branch, so `variant` is not given with one — nor with the
13704
- * response iterator, which reads the branch off the wire. Anywhere else it is required.
13698
+ * response iterator, which reads the branch off the wire, nor with a `CairoTypeOption`, which
13699
+ * is copied as it is. Anywhere else it is required.
13700
+ *
13701
+ * For the same reason, a `CairoOption` that holds a `CairoTypeOption` is refused: once it is
13702
+ * unwrapped, the variant comes with the `CairoTypeOption`. Accepted, it would lose one level:
13703
+ * `Some(Some(1))` would be sent as `Some(None)`. Write a nested value with `CairoOption`
13704
+ * only, or build one `CairoTypeOption` for the whole type.
13705
13705
  *
13706
13706
  * `subType` is what makes an option of options work. Handed a `CairoOption`, this constructor
13707
13707
  * unwraps it and calls itself with what was inside, which for a nested option is another
@@ -13712,11 +13712,11 @@ ${indent}}` : "}";
13712
13712
  * @param {string} optionCairoType the abi type, `core::option::Option::<T>`
13713
13713
  * @param {AllowArray<CairoTypeStrategy>} parsingStrategy how to build the value
13714
13714
  * @param {CairoOptionVariant | number} [variant] which branch, when the content does not say.
13715
- * Must be omitted when `content` is the response iterator.
13715
+ * Must be omitted when `content` is the response iterator or a `CairoTypeOption`.
13716
13716
  * @param {boolean} [subType=false] true when called from the unwrapping of a nested
13717
13717
  * `CairoOption`, which is the only caller that should set it
13718
- * @throws {Error} when the type is not an option, when the variant is missing, absurd, or
13719
- * contradicts the content
13718
+ * @throws {Error} when the type is not an option, or when the variant is missing, absurd,
13719
+ * contradicts the content, or is given with a `CairoTypeOption`
13720
13720
  * @example
13721
13721
  * ```typescript
13722
13722
  * const type = 'core::option::Option::<core::integer::u8>';
@@ -13761,6 +13761,10 @@ ${indent}}` : "}";
13761
13761
  return;
13762
13762
  }
13763
13763
  if (content instanceof _CairoTypeOption) {
13764
+ assert(
13765
+ isUndefined(variant),
13766
+ 'when "content" parameter is a CairoTypeOption, do not define "variant" parameter.'
13767
+ );
13764
13768
  this.content = content.content;
13765
13769
  this.isVariantSome = content.isVariantSome;
13766
13770
  this.optionCairoType = content.optionCairoType;
@@ -16222,11 +16226,17 @@ ${indent}}` : "}";
16222
16226
  `Your object includes the property : ${key}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`
16223
16227
  );
16224
16228
  }
16229
+ function getVariantType(abiEnum, variantName) {
16230
+ return abiEnum.variants?.find((abiVariant) => abiVariant.name === variantName)?.type ?? "";
16231
+ }
16225
16232
  function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
16226
16233
  const orderInput = (unorderedItem, abiType) => {
16227
16234
  if (CairoFixedArray.isTypeFixedArray(abiType)) {
16228
16235
  return orderFixedArray(unorderedItem, abiType);
16229
16236
  }
16237
+ if (isCairoType(unorderedItem)) {
16238
+ return unorderedItem;
16239
+ }
16230
16240
  if (isTypeArray(abiType)) {
16231
16241
  return orderArray(unorderedItem, abiType);
16232
16242
  }
@@ -16339,14 +16349,8 @@ ${indent}}` : "}";
16339
16349
  const orderEnum = (unorderedObject2, abiObject) => {
16340
16350
  if (isTypeResult(abiObject.name)) {
16341
16351
  const unorderedResult = unorderedObject2;
16342
- const resultOkType = abiObject.name.substring(
16343
- abiObject.name.indexOf("<") + 1,
16344
- abiObject.name.lastIndexOf(",")
16345
- );
16346
- const resultErrType = abiObject.name.substring(
16347
- abiObject.name.indexOf(",") + 1,
16348
- abiObject.name.lastIndexOf(">")
16349
- );
16352
+ const resultOkType = getVariantType(abiObject, "Ok");
16353
+ const resultErrType = getVariantType(abiObject, "Err");
16350
16354
  if (unorderedResult.isOk()) {
16351
16355
  return new CairoResult(
16352
16356
  CairoResultVariant.Ok,
@@ -16360,10 +16364,7 @@ ${indent}}` : "}";
16360
16364
  }
16361
16365
  if (isTypeOption(abiObject.name)) {
16362
16366
  const unorderedOption = unorderedObject2;
16363
- const resultSomeType = abiObject.name.substring(
16364
- abiObject.name.indexOf("<") + 1,
16365
- abiObject.name.lastIndexOf(">")
16366
- );
16367
+ const resultSomeType = getVariantType(abiObject, "Some");
16367
16368
  if (unorderedOption.isSome()) {
16368
16369
  return new CairoOption(
16369
16370
  CairoOptionVariant.Some,
@@ -16378,10 +16379,7 @@ ${indent}}` : "}";
16378
16379
  if (isUndefined(variant[1])) {
16379
16380
  return variant;
16380
16381
  }
16381
- const variantType = abiObject.type.substring(
16382
- abiObject.type.lastIndexOf("<") + 1,
16383
- abiObject.type.lastIndexOf(">")
16384
- );
16382
+ const variantType = getVariantType(abiObject, variant[0]);
16385
16383
  if (variantType === "()") {
16386
16384
  return variant;
16387
16385
  }