starknet 11.10.1 → 11.10.2

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
@@ -7158,39 +7158,25 @@ function extractCairo0Tuple(type) {
7158
7158
  }
7159
7159
  return recomposed;
7160
7160
  }
7161
- function getClosureOffset(input, open, close) {
7162
- for (let i = 0, counter = 0; i < input.length; i++) {
7163
- if (input[i] === open) {
7164
- counter++;
7165
- } else if (input[i] === close && --counter === 0) {
7166
- return i;
7167
- }
7168
- }
7169
- return Number.POSITIVE_INFINITY;
7170
- }
7171
7161
  function extractCairo1Tuple(type) {
7172
7162
  const input = type.slice(1, -1);
7173
7163
  const result = [];
7164
+ let depth = 0;
7174
7165
  let currentIndex = 0;
7175
- let limitIndex;
7176
- while (currentIndex < input.length) {
7177
- switch (true) {
7178
- // Tuple
7179
- case input[currentIndex] === "(": {
7180
- limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "(", ")") + 1;
7181
- break;
7182
- }
7183
- case (input.startsWith("core::result::Result::<", currentIndex) || input.startsWith("core::array::Array::<", currentIndex) || input.startsWith("core::option::Option::<", currentIndex)): {
7184
- limitIndex = currentIndex + getClosureOffset(input.slice(currentIndex), "<", ">") + 1;
7185
- break;
7186
- }
7187
- default: {
7188
- const commaIndex = input.indexOf(",", currentIndex);
7189
- limitIndex = commaIndex !== -1 ? commaIndex : Number.POSITIVE_INFINITY;
7190
- }
7166
+ for (let i = 0; i < input.length; i++) {
7167
+ const char = input[i];
7168
+ if (char === "(" || char === "<" || char === "[") {
7169
+ depth++;
7170
+ } else if (char === ")" || char === ">" || char === "]") {
7171
+ depth--;
7172
+ } else if (char === "," && depth === 0) {
7173
+ result.push(input.slice(currentIndex, i));
7174
+ currentIndex = i + 2;
7175
+ i++;
7191
7176
  }
7192
- result.push(input.slice(currentIndex, limitIndex));
7193
- currentIndex = limitIndex + 2;
7177
+ }
7178
+ if (currentIndex < input.length) {
7179
+ result.push(input.slice(currentIndex));
7194
7180
  }
7195
7181
  return result;
7196
7182
  }