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.mjs
CHANGED
|
@@ -3020,7 +3020,6 @@ var CairoUint256 = class _CairoUint256 {
|
|
|
3020
3020
|
* ```
|
|
3021
3021
|
*/
|
|
3022
3022
|
low;
|
|
3023
|
-
// TODO should be u128
|
|
3024
3023
|
/**
|
|
3025
3024
|
* The top 128 bits of the value.
|
|
3026
3025
|
* @example
|
|
@@ -3030,7 +3029,6 @@ var CairoUint256 = class _CairoUint256 {
|
|
|
3030
3029
|
* ```
|
|
3031
3030
|
*/
|
|
3032
3031
|
high;
|
|
3033
|
-
// TODO should be u128
|
|
3034
3032
|
/**
|
|
3035
3033
|
* The abi type this class serializes.
|
|
3036
3034
|
* @example
|
|
@@ -3269,7 +3267,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3269
3267
|
* ```
|
|
3270
3268
|
*/
|
|
3271
3269
|
limb0;
|
|
3272
|
-
// TODO should be u128
|
|
3273
3270
|
/**
|
|
3274
3271
|
* Bits 128 to 255 of the value.
|
|
3275
3272
|
* @example
|
|
@@ -3279,7 +3276,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3279
3276
|
* ```
|
|
3280
3277
|
*/
|
|
3281
3278
|
limb1;
|
|
3282
|
-
// TODO should be u128
|
|
3283
3279
|
/**
|
|
3284
3280
|
* Bits 256 to 383 of the value.
|
|
3285
3281
|
* @example
|
|
@@ -3289,7 +3285,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3289
3285
|
* ```
|
|
3290
3286
|
*/
|
|
3291
3287
|
limb2;
|
|
3292
|
-
// TODO should be u128
|
|
3293
3288
|
/**
|
|
3294
3289
|
* Bits 384 to 511 of the value.
|
|
3295
3290
|
* @example
|
|
@@ -3299,7 +3294,6 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
3299
3294
|
* ```
|
|
3300
3295
|
*/
|
|
3301
3296
|
limb3;
|
|
3302
|
-
// TODO should be u128
|
|
3303
3297
|
/**
|
|
3304
3298
|
* The abi type this class serializes.
|
|
3305
3299
|
* @example
|
|
@@ -8554,7 +8548,13 @@ var CairoTypeOption = class _CairoTypeOption {
|
|
|
8554
8548
|
* Build an option, from a value a caller passed or from the felts of a response.
|
|
8555
8549
|
*
|
|
8556
8550
|
* A {@link CairoOption} says its own branch, so `variant` is not given with one — nor with the
|
|
8557
|
-
* response iterator, which reads the branch off the wire
|
|
8551
|
+
* response iterator, which reads the branch off the wire, nor with a `CairoTypeOption`, which
|
|
8552
|
+
* is copied as it is. Anywhere else it is required.
|
|
8553
|
+
*
|
|
8554
|
+
* For the same reason, a `CairoOption` that holds a `CairoTypeOption` is refused: once it is
|
|
8555
|
+
* unwrapped, the variant comes with the `CairoTypeOption`. Accepted, it would lose one level:
|
|
8556
|
+
* `Some(Some(1))` would be sent as `Some(None)`. Write a nested value with `CairoOption`
|
|
8557
|
+
* only, or build one `CairoTypeOption` for the whole type.
|
|
8558
8558
|
*
|
|
8559
8559
|
* `subType` is what makes an option of options work. Handed a `CairoOption`, this constructor
|
|
8560
8560
|
* unwraps it and calls itself with what was inside, which for a nested option is another
|
|
@@ -8565,11 +8565,11 @@ var CairoTypeOption = class _CairoTypeOption {
|
|
|
8565
8565
|
* @param {string} optionCairoType the abi type, `core::option::Option::<T>`
|
|
8566
8566
|
* @param {AllowArray<CairoTypeStrategy>} parsingStrategy how to build the value
|
|
8567
8567
|
* @param {CairoOptionVariant | number} [variant] which branch, when the content does not say.
|
|
8568
|
-
* Must be omitted when `content` is the response iterator
|
|
8568
|
+
* Must be omitted when `content` is the response iterator or a `CairoTypeOption`.
|
|
8569
8569
|
* @param {boolean} [subType=false] true when called from the unwrapping of a nested
|
|
8570
8570
|
* `CairoOption`, which is the only caller that should set it
|
|
8571
|
-
* @throws {Error} when the type is not an option, when the variant is missing, absurd,
|
|
8572
|
-
* contradicts the content
|
|
8571
|
+
* @throws {Error} when the type is not an option, or when the variant is missing, absurd,
|
|
8572
|
+
* contradicts the content, or is given with a `CairoTypeOption`
|
|
8573
8573
|
* @example
|
|
8574
8574
|
* ```typescript
|
|
8575
8575
|
* const type = 'core::option::Option::<core::integer::u8>';
|
|
@@ -8614,6 +8614,10 @@ var CairoTypeOption = class _CairoTypeOption {
|
|
|
8614
8614
|
return;
|
|
8615
8615
|
}
|
|
8616
8616
|
if (content instanceof _CairoTypeOption) {
|
|
8617
|
+
assert(
|
|
8618
|
+
isUndefined(variant),
|
|
8619
|
+
'when "content" parameter is a CairoTypeOption, do not define "variant" parameter.'
|
|
8620
|
+
);
|
|
8617
8621
|
this.content = content.content;
|
|
8618
8622
|
this.isVariantSome = content.isVariantSome;
|
|
8619
8623
|
this.optionCairoType = content.optionCairoType;
|
|
@@ -11075,11 +11079,17 @@ function errorU512(key) {
|
|
|
11075
11079
|
`Your object includes the property : ${key}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`
|
|
11076
11080
|
);
|
|
11077
11081
|
}
|
|
11082
|
+
function getVariantType(abiEnum, variantName) {
|
|
11083
|
+
return abiEnum.variants?.find((abiVariant) => abiVariant.name === variantName)?.type ?? "";
|
|
11084
|
+
}
|
|
11078
11085
|
function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
11079
11086
|
const orderInput = (unorderedItem, abiType) => {
|
|
11080
11087
|
if (CairoFixedArray.isTypeFixedArray(abiType)) {
|
|
11081
11088
|
return orderFixedArray(unorderedItem, abiType);
|
|
11082
11089
|
}
|
|
11090
|
+
if (isCairoType(unorderedItem)) {
|
|
11091
|
+
return unorderedItem;
|
|
11092
|
+
}
|
|
11083
11093
|
if (isTypeArray(abiType)) {
|
|
11084
11094
|
return orderArray(unorderedItem, abiType);
|
|
11085
11095
|
}
|
|
@@ -11192,14 +11202,8 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
11192
11202
|
const orderEnum = (unorderedObject2, abiObject) => {
|
|
11193
11203
|
if (isTypeResult(abiObject.name)) {
|
|
11194
11204
|
const unorderedResult = unorderedObject2;
|
|
11195
|
-
const resultOkType = abiObject
|
|
11196
|
-
|
|
11197
|
-
abiObject.name.lastIndexOf(",")
|
|
11198
|
-
);
|
|
11199
|
-
const resultErrType = abiObject.name.substring(
|
|
11200
|
-
abiObject.name.indexOf(",") + 1,
|
|
11201
|
-
abiObject.name.lastIndexOf(">")
|
|
11202
|
-
);
|
|
11205
|
+
const resultOkType = getVariantType(abiObject, "Ok");
|
|
11206
|
+
const resultErrType = getVariantType(abiObject, "Err");
|
|
11203
11207
|
if (unorderedResult.isOk()) {
|
|
11204
11208
|
return new CairoResult(
|
|
11205
11209
|
CairoResultVariant.Ok,
|
|
@@ -11213,10 +11217,7 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
11213
11217
|
}
|
|
11214
11218
|
if (isTypeOption(abiObject.name)) {
|
|
11215
11219
|
const unorderedOption = unorderedObject2;
|
|
11216
|
-
const resultSomeType = abiObject
|
|
11217
|
-
abiObject.name.indexOf("<") + 1,
|
|
11218
|
-
abiObject.name.lastIndexOf(">")
|
|
11219
|
-
);
|
|
11220
|
+
const resultSomeType = getVariantType(abiObject, "Some");
|
|
11220
11221
|
if (unorderedOption.isSome()) {
|
|
11221
11222
|
return new CairoOption(
|
|
11222
11223
|
CairoOptionVariant.Some,
|
|
@@ -11231,10 +11232,7 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
|
|
|
11231
11232
|
if (isUndefined(variant[1])) {
|
|
11232
11233
|
return variant;
|
|
11233
11234
|
}
|
|
11234
|
-
const variantType = abiObject
|
|
11235
|
-
abiObject.type.lastIndexOf("<") + 1,
|
|
11236
|
-
abiObject.type.lastIndexOf(">")
|
|
11237
|
-
);
|
|
11235
|
+
const variantType = getVariantType(abiObject, variant[0]);
|
|
11238
11236
|
if (variantType === "()") {
|
|
11239
11237
|
return variant;
|
|
11240
11238
|
}
|