@apibara/starknet 2.1.0-beta.38 → 2.1.0-beta.39

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.cjs CHANGED
@@ -8543,7 +8543,7 @@ function compileTypeParser(abi, type) {
8543
8543
  return compileStructParser(abi, typeAbi.members);
8544
8544
  }
8545
8545
  case "enum": {
8546
- throw new DecodeEventError(`Enum types are not supported: ${type}`);
8546
+ return compileEnumParser(abi, typeAbi);
8547
8547
  }
8548
8548
  default:
8549
8549
  throw new DecodeEventError(`Invalid type ${typeAbi.type}`);
@@ -8559,6 +8559,16 @@ function compileStructParser(abi, members) {
8559
8559
  }
8560
8560
  return parser.parseStruct(parsers);
8561
8561
  }
8562
+ function compileEnumParser(abi, enumAbi) {
8563
+ const parsers = {};
8564
+ for (const [index, variant] of enumAbi.variants.entries()) {
8565
+ parsers[variant.name] = {
8566
+ index,
8567
+ parser: compileTypeParser(abi, variant.type)
8568
+ };
8569
+ }
8570
+ return parser.parseEnum(parsers);
8571
+ }
8562
8572
 
8563
8573
  const StarknetStream = new protocol.StreamConfig(
8564
8574
  FilterFromBytes,