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 +6 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.global.js +24 -26
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +24 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3226,7 +3226,6 @@ var CairoUint256 = class _CairoUint256 {
|
|
|
3226
3226
|
* ```
|
|
3227
3227
|
*/
|
|
3228
3228
|
low;
|
|
3229
|
-
// TODO should be u128
|
|
3230
3229
|
/**
|
|
3231
3230
|
* The top 128 bits of the value.
|
|
3232
3231
|
* @example
|
|
@@ -3236,7 +3235,6 @@ var CairoUint256 = class _CairoUint256 {
|
|
|
3236
3235
|
* ```
|
|
3237
3236
|
*/
|
|
3238
3237
|
high;
|
|
3239
|
-
// TODO should be u128
|
|
3240
3238
|
/**
|
|
3241
3239
|
* The abi type this class serializes.
|
|
3242
3240
|
* @example
|
|
@@ -3475,7 +3473,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3475
3473
|
* ```
|
|
3476
3474
|
*/
|
|
3477
3475
|
limb0;
|
|
3478
|
-
// TODO should be u128
|
|
3479
3476
|
/**
|
|
3480
3477
|
* Bits 128 to 255 of the value.
|
|
3481
3478
|
* @example
|
|
@@ -3485,7 +3482,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3485
3482
|
* ```
|
|
3486
3483
|
*/
|
|
3487
3484
|
limb1;
|
|
3488
|
-
// TODO should be u128
|
|
3489
3485
|
/**
|
|
3490
3486
|
* Bits 256 to 383 of the value.
|
|
3491
3487
|
* @example
|
|
@@ -3495,7 +3491,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3495
3491
|
* ```
|
|
3496
3492
|
*/
|
|
3497
3493
|
limb2;
|
|
3498
|
-
// TODO should be u128
|
|
3499
3494
|
/**
|
|
3500
3495
|
* Bits 384 to 511 of the value.
|
|
3501
3496
|
* @example
|
|
@@ -3505,7 +3500,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3505
3500
|
* ```
|
|
3506
3501
|
*/
|
|
3507
3502
|
limb3;
|
|
3508
|
-
// TODO should be u128
|
|
3509
3503
|
/**
|
|
3510
3504
|
* The abi type this class serializes.
|
|
3511
3505
|
* @example
|
|
@@ -8760,7 +8754,13 @@ var CairoTypeOption = class _CairoTypeOption {
|
|
|
8760
8754
|
* Build an option, from a value a caller passed or from the felts of a response.
|
|
8761
8755
|
*
|
|
8762
8756
|
* A {@link CairoOption} says its own branch, so `variant` is not given with one — nor with the
|
|
8763
|
-
* response iterator, which reads the branch off the wire
|
|
8757
|
+
* response iterator, which reads the branch off the wire, nor with a `CairoTypeOption`, which
|
|
8758
|
+
* is copied as it is. Anywhere else it is required.
|
|
8759
|
+
*
|
|
8760
|
+
* For the same reason, a `CairoOption` that holds a `CairoTypeOption` is refused: once it is
|
|
8761
|
+
* unwrapped, the variant comes with the `CairoTypeOption`. Accepted, it would lose one level:
|
|
8762
|
+
* `Some(Some(1))` would be sent as `Some(None)`. Write a nested value with `CairoOption`
|
|
8763
|
+
* only, or build one `CairoTypeOption` for the whole type.
|
|
8764
8764
|
*
|
|
8765
8765
|
* `subType` is what makes an option of options work. Handed a `CairoOption`, this constructor
|
|
8766
8766
|
* unwraps it and calls itself with what was inside, which for a nested option is another
|
|
@@ -8771,11 +8771,11 @@ var CairoTypeOption = class _CairoTypeOption {
|
|
|
8771
8771
|
* @param {string} optionCairoType the abi type, `core::option::Option::<T>`
|
|
8772
8772
|
* @param {AllowArray<CairoTypeStrategy>} parsingStrategy how to build the value
|
|
8773
8773
|
* @param {CairoOptionVariant | number} [variant] which branch, when the content does not say.
|
|
8774
|
-
* Must be omitted when `content` is the response iterator
|
|
8774
|
+
* Must be omitted when `content` is the response iterator or a `CairoTypeOption`.
|
|
8775
8775
|
* @param {boolean} [subType=false] true when called from the unwrapping of a nested
|
|
8776
8776
|
* `CairoOption`, which is the only caller that should set it
|
|
8777
|
-
* @throws {Error} when the type is not an option, when the variant is missing, absurd,
|
|
8778
|
-
* contradicts the content
|
|
8777
|
+
* @throws {Error} when the type is not an option, or when the variant is missing, absurd,
|
|
8778
|
+
* contradicts the content, or is given with a `CairoTypeOption`
|
|
8779
8779
|
* @example
|
|
8780
8780
|
* ```typescript
|
|
8781
8781
|
* const type = 'core::option::Option::<core::integer::u8>';
|
|
@@ -8820,6 +8820,10 @@ var CairoTypeOption = class _CairoTypeOption {
|
|
|
8820
8820
|
return;
|
|
8821
8821
|
}
|
|
8822
8822
|
if (content instanceof _CairoTypeOption) {
|
|
8823
|
+
assert(
|
|
8824
|
+
isUndefined(variant),
|
|
8825
|
+
'when "content" parameter is a CairoTypeOption, do not define "variant" parameter.'
|
|
8826
|
+
);
|
|
8823
8827
|
this.content = content.content;
|
|
8824
8828
|
this.isVariantSome = content.isVariantSome;
|
|
8825
8829
|
this.optionCairoType = content.optionCairoType;
|
|
@@ -11281,11 +11285,17 @@ function errorU512(key) {
|
|
|
11281
11285
|
`Your object includes the property : ${key}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`
|
|
11282
11286
|
);
|
|
11283
11287
|
}
|
|
11288
|
+
function getVariantType(abiEnum, variantName) {
|
|
11289
|
+
return abiEnum.variants?.find((abiVariant) => abiVariant.name === variantName)?.type ?? "";
|
|
11290
|
+
}
|
|
11284
11291
|
function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
11285
11292
|
const orderInput = (unorderedItem, abiType) => {
|
|
11286
11293
|
if (CairoFixedArray.isTypeFixedArray(abiType)) {
|
|
11287
11294
|
return orderFixedArray(unorderedItem, abiType);
|
|
11288
11295
|
}
|
|
11296
|
+
if (isCairoType(unorderedItem)) {
|
|
11297
|
+
return unorderedItem;
|
|
11298
|
+
}
|
|
11289
11299
|
if (isTypeArray(abiType)) {
|
|
11290
11300
|
return orderArray(unorderedItem, abiType);
|
|
11291
11301
|
}
|
|
@@ -11398,14 +11408,8 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
11398
11408
|
const orderEnum = (unorderedObject2, abiObject) => {
|
|
11399
11409
|
if (isTypeResult(abiObject.name)) {
|
|
11400
11410
|
const unorderedResult = unorderedObject2;
|
|
11401
|
-
const resultOkType = abiObject
|
|
11402
|
-
|
|
11403
|
-
abiObject.name.lastIndexOf(",")
|
|
11404
|
-
);
|
|
11405
|
-
const resultErrType = abiObject.name.substring(
|
|
11406
|
-
abiObject.name.indexOf(",") + 1,
|
|
11407
|
-
abiObject.name.lastIndexOf(">")
|
|
11408
|
-
);
|
|
11411
|
+
const resultOkType = getVariantType(abiObject, "Ok");
|
|
11412
|
+
const resultErrType = getVariantType(abiObject, "Err");
|
|
11409
11413
|
if (unorderedResult.isOk()) {
|
|
11410
11414
|
return new CairoResult(
|
|
11411
11415
|
CairoResultVariant.Ok,
|
|
@@ -11419,10 +11423,7 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
11419
11423
|
}
|
|
11420
11424
|
if (isTypeOption(abiObject.name)) {
|
|
11421
11425
|
const unorderedOption = unorderedObject2;
|
|
11422
|
-
const resultSomeType = abiObject
|
|
11423
|
-
abiObject.name.indexOf("<") + 1,
|
|
11424
|
-
abiObject.name.lastIndexOf(">")
|
|
11425
|
-
);
|
|
11426
|
+
const resultSomeType = getVariantType(abiObject, "Some");
|
|
11426
11427
|
if (unorderedOption.isSome()) {
|
|
11427
11428
|
return new CairoOption(
|
|
11428
11429
|
CairoOptionVariant.Some,
|
|
@@ -11437,10 +11438,7 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
11437
11438
|
if (isUndefined(variant[1])) {
|
|
11438
11439
|
return variant;
|
|
11439
11440
|
}
|
|
11440
|
-
const variantType = abiObject
|
|
11441
|
-
abiObject.type.lastIndexOf("<") + 1,
|
|
11442
|
-
abiObject.type.lastIndexOf(">")
|
|
11443
|
-
);
|
|
11441
|
+
const variantType = getVariantType(abiObject, variant[0]);
|
|
11444
11442
|
if (variantType === "()") {
|
|
11445
11443
|
return variant;
|
|
11446
11444
|
}
|