2525 "StakeRegistrationAndDelegationAndVoteDelegation" ,
2626 "DRep" ,
2727 "DRepKind" ,
28+ "AuthCommitteeHotCertificate" ,
29+ "ResignCommitteeColdCertificate" ,
30+ "Anchor" ,
31+ "DrepCredential" ,
32+ "UnregDrepCertificate" ,
33+ "UpdateDrepCertificate" ,
2834]
2935
3036from pycardano .pool_params import PoolParams
3137
3238unit_interval = Tuple [int , int ]
3339
3440
41+ @dataclass (repr = False )
42+ class Anchor (ArrayCBORSerializable ):
43+ url : str
44+ data_hash : bytes
45+
46+ @classmethod
47+ @limit_primitive_type (list )
48+ def from_primitive (cls : Type [Anchor ], values : Union [list , tuple ]) -> Anchor :
49+ return cls (url = values [0 ], data_hash = values [1 ])
50+
51+
3552@dataclass (repr = False )
3653class StakeCredential (ArrayCBORSerializable ):
3754 _CODE : Optional [int ] = field (init = False , default = None )
@@ -403,6 +420,119 @@ def to_primitive(self):
403420 return [self .kind .value ]
404421
405422
423+ @dataclass (repr = False )
424+ class AuthCommitteeHotCertificate (ArrayCBORSerializable ):
425+ _CODE : int = field (init = False , default = 14 )
426+
427+ committee_cold_credential : StakeCredential
428+ committee_hot_credential : StakeCredential
429+
430+ def __post_init__ (self ):
431+ self ._CODE = 14
432+
433+ @classmethod
434+ @limit_primitive_type (list )
435+ def from_primitive (
436+ cls : Type [AuthCommitteeHotCertificate ], values : Union [list , tuple ]
437+ ) -> AuthCommitteeHotCertificate :
438+ if values [0 ] == 14 :
439+ return cls (
440+ committee_cold_credential = StakeCredential .from_primitive (values [1 ]),
441+ committee_hot_credential = StakeCredential .from_primitive (values [2 ]),
442+ )
443+ else :
444+ raise DeserializeException (
445+ f"Invalid AuthCommitteeHotCertificate type { values [0 ]} "
446+ )
447+
448+
449+ @dataclass (repr = False )
450+ class ResignCommitteeColdCertificate (ArrayCBORSerializable ):
451+ _CODE : int = field (init = False , default = 15 )
452+
453+ committee_cold_credential : StakeCredential
454+ anchor : Optional [Anchor ]
455+
456+ def __post_init__ (self ):
457+ self ._CODE = 15
458+
459+ @classmethod
460+ @limit_primitive_type (list )
461+ def from_primitive (
462+ cls : Type [ResignCommitteeColdCertificate ], values : Union [list , tuple ]
463+ ) -> ResignCommitteeColdCertificate :
464+ if values [0 ] == 15 :
465+ return cls (
466+ committee_cold_credential = StakeCredential .from_primitive (values [1 ]),
467+ anchor = (
468+ Anchor .from_primitive (values [2 ]) if values [2 ] is not None else None
469+ ),
470+ )
471+ else :
472+ raise DeserializeException (
473+ f"Invalid ResignCommitteeColdCertificate type { values [0 ]} "
474+ )
475+
476+
477+ @dataclass (repr = False )
478+ class DrepCredential (StakeCredential ):
479+ """DRep credential is identical to StakeCredential in structure."""
480+
481+ pass
482+
483+
484+ @dataclass (repr = False )
485+ class UnregDrepCertificate (ArrayCBORSerializable ):
486+ _CODE : int = field (init = False , default = 17 )
487+
488+ drep_credential : DrepCredential
489+ coin : int
490+
491+ def __post_init__ (self ):
492+ self ._CODE = 17
493+
494+ @classmethod
495+ @limit_primitive_type (list )
496+ def from_primitive (
497+ cls : Type [UnregDrepCertificate ], values : Union [list , tuple ]
498+ ) -> UnregDrepCertificate :
499+ if values [0 ] == 17 :
500+ return cls (
501+ drep_credential = DrepCredential .from_primitive (values [1 ]),
502+ coin = values [2 ],
503+ )
504+ else :
505+ raise DeserializeException (f"Invalid UnregDrepCertificate type { values [0 ]} " )
506+
507+
508+ @dataclass (repr = False )
509+ class UpdateDrepCertificate (ArrayCBORSerializable ):
510+ _CODE : int = field (init = False , default = 18 )
511+
512+ drep_credential : DrepCredential
513+ anchor : Optional [Anchor ]
514+
515+ def __post_init__ (self ):
516+ self ._CODE = 18
517+
518+ @classmethod
519+ @limit_primitive_type (list )
520+ def from_primitive (
521+ cls : Type [UpdateDrepCertificate ], values : Union [list , tuple ]
522+ ) -> UpdateDrepCertificate :
523+ if values [0 ] == 18 :
524+ return cls (
525+ drep_credential = DrepCredential .from_primitive (values [1 ]),
526+ anchor = (
527+ Anchor .from_primitive (values [2 ]) if values [2 ] is not None else None
528+ ),
529+ )
530+ else :
531+ raise DeserializeException (
532+ f"Invalid UpdateDrepCertificate type { values [0 ]} "
533+ )
534+
535+
406536Certificate = Union [
407537 StakeRegistration ,
408538 StakeDeregistration ,
@@ -416,4 +546,8 @@ def to_primitive(self):
416546 StakeRegistrationAndDelegation ,
417547 StakeRegistrationAndVoteDelegation ,
418548 StakeRegistrationAndDelegationAndVoteDelegation ,
549+ AuthCommitteeHotCertificate ,
550+ ResignCommitteeColdCertificate ,
551+ UnregDrepCertificate ,
552+ UpdateDrepCertificate ,
419553]
0 commit comments