Skip to content

Commit 8b7d2d6

Browse files
committed
Revert "Add a flag to enable/disable auto CONSTR_ID"
This reverts commit 787e160.
1 parent 787e160 commit 8b7d2d6

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

pycardano/plutus.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from dataclasses import dataclass, field, fields
88
from enum import Enum
99
from hashlib import sha256
10-
from typing import Any, ClassVar, Optional, Type, Union
10+
from typing import Any, Optional, Type, Union
1111

1212
import cbor2
1313
from cbor2 import CBORTag
@@ -468,9 +468,6 @@ class will reduce the complexity of serialization and deserialization tremendous
468468
>>> assert test == Test.from_cbor("d87a9f187b43333231ff")
469469
"""
470470

471-
AUTO_ID: ClassVar[bool] = False
472-
"""Enables automatic assignment of a deterministic constructor id (CONSTR_ID) for the Plutus data if set to True."""
473-
474471
@classproperty
475472
def CONSTR_ID(cls):
476473
"""
@@ -479,9 +476,6 @@ def CONSTR_ID(cls):
479476
The default implementation is an almost unique, deterministic constructor ID in the range 1 - 2^32 based
480477
on class attributes, types and class name.
481478
"""
482-
if not cls.AUTO_ID:
483-
return 0
484-
485479
k = f"_CONSTR_ID_{cls.__name__}"
486480
if not hasattr(cls, k):
487481
det_string = (

test/pycardano/test_plutus.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_plutus_data_from_json_wrong_data_structure_type():
207207
def test_plutus_data_hash():
208208
assert (
209209
bytes.fromhex(
210-
"923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec"
210+
"19d31e4f3aa9b03ad93b64c8dd2cc822d247c21e2c22762b7b08e6cadfeddb47"
211211
)
212212
== PlutusData().hash().payload
213213
)
@@ -324,12 +324,10 @@ def test_clone_plutus_data():
324324
def test_unique_constr_ids():
325325
@dataclass
326326
class A(PlutusData):
327-
AUTO_ID = True
328327
pass
329328

330329
@dataclass
331330
class B(PlutusData):
332-
AUTO_ID = True
333331
pass
334332

335333
assert (
@@ -339,7 +337,6 @@ class B(PlutusData):
339337

340338
@dataclass
341339
class B(PlutusData):
342-
AUTO_ID = True
343340
a: int
344341
b: bytes
345342

@@ -351,7 +348,6 @@ class B(PlutusData):
351348

352349
@dataclass
353350
class B(PlutusData):
354-
AUTO_ID = True
355351
a: bytes
356352
b: bytes
357353

@@ -363,15 +359,13 @@ class B(PlutusData):
363359
def test_deterministic_constr_ids_local():
364360
@dataclass
365361
class A(PlutusData):
366-
AUTO_ID = True
367362
a: int
368363
b: bytes
369364

370365
A_tmp = A
371366

372367
@dataclass
373368
class A(PlutusData):
374-
AUTO_ID = True
375369
a: int
376370
b: bytes
377371

@@ -387,7 +381,6 @@ def test_deterministic_constr_ids_global():
387381
388382
@dataclass
389383
class A(PlutusData):
390-
AUTO_ID = True
391384
a: int
392385
b: bytes
393386

0 commit comments

Comments
 (0)