diff --git a/.gitignore b/.gitignore index 1b05740..9c882b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ - __pycache__/ +*.egg-info/ diff --git a/pbcabi/model.py b/pbcabi/model.py index 9aa21fb..ff3ebf2 100644 --- a/pbcabi/model.py +++ b/pbcabi/model.py @@ -67,7 +67,7 @@ class TypeSpec: discriminant): type_spec = type_spec_read_from(reader) return type_spec - assert False, "Unknown discriminant: 0x{:02x}".format(discriminant) + assert False, "Unknown TypeSpec discriminant: 0x{:02x}".format(discriminant) @enforce_typing.enforce_types @@ -232,6 +232,20 @@ class MapTypeSpec(TypeSpec): type_key: TypeSpec type_value: TypeSpec +@enforce_typing.enforce_types +@dataclasses.dataclass(frozen=True, slots=True) +class AvlTreeTypeSpec(MapTypeSpec): + ''' + Type spec for AVL-tree. Avl trees does not store data inline. + ''' + DISCRIMINANT = 0x19 + +@enforce_typing.enforce_types +@dataclasses.dataclass(frozen=True, slots=True) +class InlineMapTypeSpec(MapTypeSpec): + ''' + Type spec for a dynamically-sized map from some type to another type. + ''' DISCRIMINANT = 0x0f @staticmethod @@ -376,7 +390,7 @@ TYPE_SPEC_SUBTYPE_READ_FROM_BY_DISCRIMINANT = { v.value: simple_type_spec_read_from(v) for v in SimpleType } | { t.DISCRIMINANT: t.read_from for t in - [VecTypeSpec, MapTypeSpec, SetTypeSpec, ArrayTypeSpec, OptionTypeSpec] + [VecTypeSpec, InlineMapTypeSpec, AvlTreeTypeSpec, SetTypeSpec, ArrayTypeSpec, OptionTypeSpec] } @@ -417,6 +431,7 @@ class FnKind(Enum): ZK_USER_VAR_OPENED = 0x15 ZK_ATTESTATION_COMPLETE = 0x16 ZK_SECRET_INPUT_WITH_EXPLICIT_TYPE = 0x17 + ZK_EVM_EXTERNAL_EVENT = 0x18 @staticmethod def read_from(reader: BinaryReader): @@ -427,7 +442,7 @@ class FnKind(Enum): if found := [kind for kind in FnKind if kind.value == discriminant]: assert len(found) == 1 return found[0] - assert False, "Unknown discriminant: 0x{:02x}".format(discriminant) + assert False, "Unknown FnKind discriminant: 0x{:02x}".format(discriminant) @enforce_typing.enforce_types @@ -675,6 +690,7 @@ class FileAbi: version_client = Version.read_from(reader) assert version_client >= Version(5, 0, 0), version_client + assert version_client <= Version(5, 4, 0), version_client contract = ContractAbi.read_from(reader) return FileAbi(version_binder, version_client, contract)