starknet 6.2.0 → 6.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [6.2.1](https://github.com/starknet-io/starknet.js/compare/v6.2.0...v6.2.1) (2024-03-11)
2
+
3
+ ### Bug Fixes
4
+
5
+ - repair Cairo 1 nested and enum tuple handling ([ce2e541](https://github.com/starknet-io/starknet.js/commit/ce2e5417e6c42af17418408dc1ca6aab4c570473))
6
+
1
7
  # [6.2.0](https://github.com/starknet-io/starknet.js/compare/v6.1.5...v6.2.0) (2024-03-07)
2
8
 
3
9
  ### Features
@@ -16773,13 +16773,40 @@ var starknet = (() => {
16773
16773
  }
16774
16774
  return recomposed;
16775
16775
  }
16776
+ function getClosureOffset(input, open, close) {
16777
+ for (let i = 0, counter = 0; i < input.length; i++) {
16778
+ if (input[i] === open) {
16779
+ counter++;
16780
+ } else if (input[i] === close && --counter === 0) {
16781
+ return i;
16782
+ }
16783
+ }
16784
+ return Number.POSITIVE_INFINITY;
16785
+ }
16776
16786
  function extractCairo1Tuple(type) {
16777
- const cleanType = type.replace(/\s/g, "").slice(1, -1);
16778
- const { subTuple, result } = parseSubTuple(cleanType);
16779
- const recomposed = result.split(",").map((it) => {
16780
- return subTuple.length ? it.replace(" ", subTuple.shift()) : it;
16781
- });
16782
- return recomposed;
16787
+ const input = type.slice(1, -1);
16788
+ const result = [];
16789
+ let currentIndex = 0;
16790
+ let limitIndex;
16791
+ while (currentIndex < input.length) {
16792
+ switch (true) {
16793
+ case input[currentIndex] === "(": {
16794
+ limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "(", ")") + 1;
16795
+ break;
16796
+ }
16797
+ case (input.startsWith("core::result::Result::<", currentIndex) || input.startsWith("core::array::Array::<", currentIndex) || input.startsWith("core::option::Option::<", currentIndex)): {
16798
+ limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "<", ">") + 1;
16799
+ break;
16800
+ }
16801
+ default: {
16802
+ const commaIndex = input.indexOf(",", currentIndex);
16803
+ limitIndex = commaIndex !== -1 ? commaIndex : Number.POSITIVE_INFINITY;
16804
+ }
16805
+ }
16806
+ result.push(input.slice(currentIndex, limitIndex));
16807
+ currentIndex = limitIndex + 2;
16808
+ }
16809
+ return result;
16783
16810
  }
16784
16811
  function extractTupleMemberTypes(type) {
16785
16812
  if (isCairo1Type(type)) {