starknet 10.3.0 → 10.3.1

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/dist/index.js CHANGED
@@ -1690,8 +1690,11 @@ var CairoUint512 = class _CairoUint512 {
1690
1690
  var isLen = (name) => /_len$/.test(name);
1691
1691
  var isTypeFelt = (type) => type === "felt" || type === "core::felt252";
1692
1692
  var isTypeArray = (type) => /\*/.test(type) || type.startsWith("core::array::Array::") || type.startsWith("core::array::Span::");
1693
- var isTypeTuple = (type) => /^\(.*\)$/i.test(type);
1694
- var isTypeNamedTuple = (type) => /\(.*\)/i.test(type) && type.includes(":");
1693
+ var isTypeTuple = (type) => type.startsWith("(") && type.endsWith(")");
1694
+ var isTypeNamedTuple = (type) => {
1695
+ const start = type.indexOf("(");
1696
+ return start !== -1 && type.indexOf(")", start + 1) !== -1 && type.includes(":");
1697
+ };
1695
1698
  var isTypeStruct = (type, structs) => type in structs;
1696
1699
  var isTypeEnum = (type, enums) => type in enums;
1697
1700
  var isTypeOption = (type) => type.startsWith("core::option::Option::");
@@ -1707,7 +1710,7 @@ var isTypeU96 = (type) => type === "core::internal::bounded_int::BoundedInt::<0,
1707
1710
  var isTypeSecp256k1Point = (type) => type === Literal.Secp256k1Point;
1708
1711
  var isCairo1Type = (type) => type.includes("::");
1709
1712
  var getArrayType = (type) => {
1710
- return isCairo1Type(type) ? type.substring(type.indexOf("<") + 1, type.lastIndexOf(">")) : type.replace("*", "");
1713
+ return isCairo1Type(type) ? type.substring(type.indexOf("<") + 1, type.lastIndexOf(">")) : type.replaceAll("*", "");
1711
1714
  };
1712
1715
  function isCairo1Abi(abi) {
1713
1716
  const { cairo } = getAbiContractVersion(abi);
@@ -3510,6 +3513,18 @@ var CairoFixedArray = class _CairoFixedArray {
3510
3513
  * Cairo fixed array type.
3511
3514
  */
3512
3515
  arrayType;
3516
+ static parseFixedArrayType(type) {
3517
+ if (!type.startsWith("[") || !type.endsWith("]")) {
3518
+ return void 0;
3519
+ }
3520
+ const separator = type.lastIndexOf("; ");
3521
+ const itemType = type.slice(1, separator);
3522
+ const size = type.slice(separator + 2, -1);
3523
+ if (separator <= 1 || size.length === 0 || ![...size].every((char) => char >= "0" && char <= "9")) {
3524
+ return void 0;
3525
+ }
3526
+ return { itemType, size };
3527
+ }
3513
3528
  /**
3514
3529
  * Create an instance representing a Cairo fixed Array.
3515
3530
  * @param {any[]} content JS array representing a Cairo fixed array.
@@ -3553,10 +3568,10 @@ var CairoFixedArray = class _CairoFixedArray {
3553
3568
  * ```
3554
3569
  */
3555
3570
  static getFixedArraySize(type) {
3556
- const matchArray = type.match(/(?<=; )\d+(?=\])/);
3557
- if (matchArray === null)
3571
+ const fixedArrayType = _CairoFixedArray.parseFixedArrayType(type);
3572
+ if (!fixedArrayType)
3558
3573
  throw new Error(`ABI type ${type} do not includes a valid number after ';' character.`);
3559
- return Number(matchArray[0]);
3574
+ return Number(fixedArrayType.size);
3560
3575
  }
3561
3576
  /**
3562
3577
  * Retrieves the Cairo fixed array size from the CairoFixedArray instance.
@@ -3582,10 +3597,9 @@ var CairoFixedArray = class _CairoFixedArray {
3582
3597
  * ```
3583
3598
  */
3584
3599
  static getFixedArrayType = (type) => {
3585
- const matchArray = type.match(/(?<=\[).+(?=;)/);
3586
- if (matchArray === null)
3587
- throw new Error(`ABI type ${type} do not includes a valid type of data.`);
3588
- return matchArray[0];
3600
+ const fixedArrayType = _CairoFixedArray.parseFixedArrayType(type);
3601
+ if (!fixedArrayType) throw new Error(`ABI type ${type} do not includes a valid type of data.`);
3602
+ return fixedArrayType.itemType;
3589
3603
  };
3590
3604
  /**
3591
3605
  * Retrieve the Cairo content type of the Cairo fixed array.
@@ -3643,7 +3657,7 @@ var CairoFixedArray = class _CairoFixedArray {
3643
3657
  * // result = true
3644
3658
  */
3645
3659
  static isTypeFixedArray(type) {
3646
- return /^\[.*;\s.*\]$/.test(type) && /(?<=\[).+(?=;)/.test(type) && /(?<=; )\d+(?=\])/.test(type);
3660
+ return _CairoFixedArray.parseFixedArrayType(type) !== void 0;
3647
3661
  }
3648
3662
  };
3649
3663
 
@@ -4311,7 +4325,7 @@ function responseParser({
4311
4325
  parsedDataArr.push(
4312
4326
  parseResponseValue(
4313
4327
  responseIterator,
4314
- { name, type: output.type.replace("*", "") },
4328
+ { name, type: output.type.replaceAll("*", "") },
4315
4329
  parser,
4316
4330
  structs,
4317
4331
  enums
@@ -9189,7 +9203,19 @@ function dynamicCallData(hardcoded, reference = void 0, arrayReference = void 0)
9189
9203
  });
9190
9204
  }
9191
9205
  function isStarkDomain(domain) {
9192
- return /^(?:[a-z0-9-]{1,48}(?:[a-z0-9-]{1,48}[a-z0-9-])?\.)*[a-z0-9-]{1,48}\.stark$/.test(domain);
9206
+ const starkSuffix = ".stark";
9207
+ if (!domain.endsWith(starkSuffix)) {
9208
+ return false;
9209
+ }
9210
+ const name = domain.slice(0, -starkSuffix.length);
9211
+ if (name.length === 0) {
9212
+ return false;
9213
+ }
9214
+ return name.split(".").every((label) => {
9215
+ return label.length > 0 && label.length <= 48 && [...label].every((char) => {
9216
+ return char >= "a" && char <= "z" || char >= "0" && char <= "9" || char === "-";
9217
+ });
9218
+ });
9193
9219
  }
9194
9220
 
9195
9221
  // src/plugins/starknet-id/index.ts