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/dist/index.mjs CHANGED
@@ -1311,13 +1311,40 @@ function extractCairo0Tuple(type) {
1311
1311
  }
1312
1312
  return recomposed;
1313
1313
  }
1314
+ function getClosureOffset(input, open, close) {
1315
+ for (let i = 0, counter = 0; i < input.length; i++) {
1316
+ if (input[i] === open) {
1317
+ counter++;
1318
+ } else if (input[i] === close && --counter === 0) {
1319
+ return i;
1320
+ }
1321
+ }
1322
+ return Number.POSITIVE_INFINITY;
1323
+ }
1314
1324
  function extractCairo1Tuple(type) {
1315
- const cleanType = type.replace(/\s/g, "").slice(1, -1);
1316
- const { subTuple, result } = parseSubTuple(cleanType);
1317
- const recomposed = result.split(",").map((it) => {
1318
- return subTuple.length ? it.replace(" ", subTuple.shift()) : it;
1319
- });
1320
- return recomposed;
1325
+ const input = type.slice(1, -1);
1326
+ const result = [];
1327
+ let currentIndex = 0;
1328
+ let limitIndex;
1329
+ while (currentIndex < input.length) {
1330
+ switch (true) {
1331
+ case input[currentIndex] === "(": {
1332
+ limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "(", ")") + 1;
1333
+ break;
1334
+ }
1335
+ case (input.startsWith("core::result::Result::<", currentIndex) || input.startsWith("core::array::Array::<", currentIndex) || input.startsWith("core::option::Option::<", currentIndex)): {
1336
+ limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "<", ">") + 1;
1337
+ break;
1338
+ }
1339
+ default: {
1340
+ const commaIndex = input.indexOf(",", currentIndex);
1341
+ limitIndex = commaIndex !== -1 ? commaIndex : Number.POSITIVE_INFINITY;
1342
+ }
1343
+ }
1344
+ result.push(input.slice(currentIndex, limitIndex));
1345
+ currentIndex = limitIndex + 2;
1346
+ }
1347
+ return result;
1321
1348
  }
1322
1349
  function extractTupleMemberTypes(type) {
1323
1350
  if (isCairo1Type(type)) {