25
25
"StakeRegistrationAndDelegationAndVoteDelegation" ,
26
26
"DRep" ,
27
27
"DRepKind" ,
28
+ "AuthCommitteeHotCertificate" ,
29
+ "ResignCommitteeColdCertificate" ,
30
+ "Anchor" ,
31
+ "DrepCredential" ,
32
+ "UnregDrepCertificate" ,
33
+ "UpdateDrepCertificate" ,
28
34
]
29
35
30
36
from pycardano .pool_params import PoolParams
31
37
32
38
unit_interval = Tuple [int , int ]
33
39
34
40
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
+
35
52
@dataclass (repr = False )
36
53
class StakeCredential (ArrayCBORSerializable ):
37
54
_CODE : Optional [int ] = field (init = False , default = None )
@@ -403,6 +420,142 @@ def to_primitive(self):
403
420
return [self .kind .value ]
404
421
405
422
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 (ArrayCBORSerializable ):
479
+ """DRep credential is identical to StakeCredential in structure."""
480
+
481
+ _CODE : int = field (init = False , default = 16 )
482
+
483
+ drep_credential : StakeCredential
484
+ coin : int
485
+ anchor : Optional [Anchor ] = field (default = None )
486
+
487
+ def __post_init__ (self ):
488
+ self ._CODE = 16
489
+
490
+ @classmethod
491
+ @limit_primitive_type (list )
492
+ def from_primitive (
493
+ cls : Type [DrepCredential ], values : Union [list , tuple ]
494
+ ) -> DrepCredential :
495
+ if values [0 ] == 16 :
496
+ return cls (
497
+ drep_credential = StakeCredential .from_primitive (values [1 ]),
498
+ coin = values [2 ],
499
+ anchor = (
500
+ Anchor .from_primitive (values [3 ]) if values [3 ] is not None else None
501
+ ),
502
+ )
503
+ else :
504
+ raise DeserializeException (f"Invalid DrepCredential type { values [0 ]} " )
505
+
506
+
507
+ @dataclass (repr = False )
508
+ class UnregDrepCertificate (ArrayCBORSerializable ):
509
+ _CODE : int = field (init = False , default = 17 )
510
+
511
+ drep_credential : DrepCredential
512
+ coin : int
513
+
514
+ def __post_init__ (self ):
515
+ self ._CODE = 17
516
+
517
+ @classmethod
518
+ @limit_primitive_type (list )
519
+ def from_primitive (
520
+ cls : Type [UnregDrepCertificate ], values : Union [list , tuple ]
521
+ ) -> UnregDrepCertificate :
522
+ if values [0 ] == 17 :
523
+ return cls (
524
+ drep_credential = DrepCredential .from_primitive (values [1 ]),
525
+ coin = values [2 ],
526
+ )
527
+ else :
528
+ raise DeserializeException (f"Invalid UnregDrepCertificate type { values [0 ]} " )
529
+
530
+
531
+ @dataclass (repr = False )
532
+ class UpdateDrepCertificate (ArrayCBORSerializable ):
533
+ _CODE : int = field (init = False , default = 18 )
534
+
535
+ drep_credential : DrepCredential
536
+ anchor : Optional [Anchor ]
537
+
538
+ def __post_init__ (self ):
539
+ self ._CODE = 18
540
+
541
+ @classmethod
542
+ @limit_primitive_type (list )
543
+ def from_primitive (
544
+ cls : Type [UpdateDrepCertificate ], values : Union [list , tuple ]
545
+ ) -> UpdateDrepCertificate :
546
+ if values [0 ] == 18 :
547
+ return cls (
548
+ drep_credential = DrepCredential .from_primitive (values [1 ]),
549
+ anchor = (
550
+ Anchor .from_primitive (values [2 ]) if values [2 ] is not None else None
551
+ ),
552
+ )
553
+ else :
554
+ raise DeserializeException (
555
+ f"Invalid UpdateDrepCertificate type { values [0 ]} "
556
+ )
557
+
558
+
406
559
Certificate = Union [
407
560
StakeRegistration ,
408
561
StakeDeregistration ,
@@ -416,4 +569,8 @@ def to_primitive(self):
416
569
StakeRegistrationAndDelegation ,
417
570
StakeRegistrationAndVoteDelegation ,
418
571
StakeRegistrationAndDelegationAndVoteDelegation ,
572
+ AuthCommitteeHotCertificate ,
573
+ ResignCommitteeColdCertificate ,
574
+ UnregDrepCertificate ,
575
+ UpdateDrepCertificate ,
419
576
]
0 commit comments