Skip to content

Commit d2ef523

Browse files
committed
Add Drep cert
1 parent e0851bf commit d2ef523

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pycardano/certificate.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,32 @@ def from_primitive(
478478
class DrepCredential(StakeCredential):
479479
"""DRep credential is identical to StakeCredential in structure."""
480480

481-
pass
481+
_CODE: int = field(init=False, default=16)
482+
483+
drep_credential: StakeCredential
484+
coin: int
485+
anchor: Optional[Anchor]
486+
487+
def __post_init__(self):
488+
self._CODE = 16
489+
490+
491+
@classmethod
492+
@limit_primitive_type(list)
493+
def from_primitive(
494+
cls: Type[DrepCredential], values: Union[list, tuple]
495+
) -> DrepCredential:
496+
if values[0] == 16:
497+
return cls(
498+
drep_credential=StakeCredential.from_primitive(values[1]),
499+
coin=values[2],
500+
anchor=(
501+
Anchor.from_primitive(values[3]) if values[3] is not None else None
502+
),
503+
)
504+
else:
505+
raise DeserializeException(f"Invalid DrepCredential type {values[0]}")
506+
482507

483508

484509
@dataclass(repr=False)

0 commit comments

Comments
 (0)