@@ -23,13 +23,25 @@ import (
2323)
2424
2525const (
26- CertificateTypeStakeRegistration = 0
27- CertificateTypeStakeDeregistration = 1
28- CertificateTypeStakeDelegation = 2
29- CertificateTypePoolRegistration = 3
30- CertificateTypePoolRetirement = 4
31- CertificateTypeGenesisKeyDelegation = 5
32- CertificateTypeMoveInstantaneousRewards = 6
26+ CertificateTypeStakeRegistration = 0
27+ CertificateTypeStakeDeregistration = 1
28+ CertificateTypeStakeDelegation = 2
29+ CertificateTypePoolRegistration = 3
30+ CertificateTypePoolRetirement = 4
31+ CertificateTypeGenesisKeyDelegation = 5
32+ CertificateTypeMoveInstantaneousRewards = 6
33+ CertificateTypeRegistration = 7
34+ CertificateTypeDeregistration = 8
35+ CertificateTypeVoteDelegation = 9
36+ CertificateTypeStakeVoteDelegation = 10
37+ CertificateTypeStakeRegistrationDelegation = 11
38+ CertificateTypeVoteRegistrationDelegation = 12
39+ CertificateTypeStakeVoteRegistrationDelegation = 13
40+ CertificateTypeAuthCommitteeHot = 14
41+ CertificateTypeResignCommitteeCold = 15
42+ CertificateTypeRegistrationDrep = 16
43+ CertificateTypeDeregistrationDrep = 17
44+ CertificateTypeUpdateDrep = 18
3345)
3446
3547type CertificateWrapper struct {
@@ -59,6 +71,30 @@ func (c *CertificateWrapper) UnmarshalCBOR(data []byte) error {
5971 tmpCert = & GenesisKeyDelegationCertificate {}
6072 case CertificateTypeMoveInstantaneousRewards :
6173 tmpCert = & MoveInstantaneousRewardsCertificate {}
74+ case CertificateTypeRegistration :
75+ tmpCert = & RegistrationCertificate {}
76+ case CertificateTypeDeregistration :
77+ tmpCert = & DeregistrationCertificate {}
78+ case CertificateTypeVoteDelegation :
79+ tmpCert = & VoteDelegationCertificate {}
80+ case CertificateTypeStakeVoteDelegation :
81+ tmpCert = & StakeVoteDelegationCertificate {}
82+ case CertificateTypeStakeRegistrationDelegation :
83+ tmpCert = & StakeRegistrationDelegationCertificate {}
84+ case CertificateTypeVoteRegistrationDelegation :
85+ tmpCert = & VoteRegistrationDelegationCertificate {}
86+ case CertificateTypeStakeVoteRegistrationDelegation :
87+ tmpCert = & StakeVoteRegistrationDelegationCertificate {}
88+ case CertificateTypeAuthCommitteeHot :
89+ tmpCert = & AuthCommitteeHotCertificate {}
90+ case CertificateTypeResignCommitteeCold :
91+ tmpCert = & ResignCommitteeColdCertificate {}
92+ case CertificateTypeRegistrationDrep :
93+ tmpCert = & RegistrationDrepCertificate {}
94+ case CertificateTypeDeregistrationDrep :
95+ tmpCert = & DeregistrationDrepCertificate {}
96+ case CertificateTypeUpdateDrep :
97+ tmpCert = & UpdateDrepCertificate {}
6298 default :
6399 return fmt .Errorf ("unknown certificate type: %d" , certType )
64100 }
@@ -89,25 +125,62 @@ const (
89125type StakeCredential struct {
90126 cbor.StructAsArray
91127 cbor.DecodeStoreCbor
92- CredType uint
93- StakeCredential []byte
128+ CredType uint
129+ Credential []byte
94130}
95131
96132func (c * StakeCredential ) Utxorpc () * utxorpc.StakeCredential {
97133 ret := & utxorpc.StakeCredential {}
98134 switch c .CredType {
99135 case StakeCredentialTypeAddrKeyHash :
100136 ret .StakeCredential = & utxorpc.StakeCredential_AddrKeyHash {
101- AddrKeyHash : c .StakeCredential [:],
137+ AddrKeyHash : c .Credential [:],
102138 }
103139 case StakeCredentialTypeScriptHash :
104140 ret .StakeCredential = & utxorpc.StakeCredential_ScriptHash {
105- ScriptHash : c .StakeCredential [:],
141+ ScriptHash : c .Credential [:],
106142 }
107143 }
108144 return ret
109145}
110146
147+ const (
148+ DrepTypeAddrKeyHash = 0
149+ DrepTypeScriptHash = 1
150+ DrepTypeAbstain = 2
151+ DrepTypeNoConfidence = 3
152+ )
153+
154+ type Drep struct {
155+ Type int
156+ Credential []byte
157+ }
158+
159+ func (d * Drep ) UnmarshalCBOR (data []byte ) error {
160+ drepType , err := cbor .DecodeIdFromList (data )
161+ if err != nil {
162+ return err
163+ }
164+ switch drepType {
165+ case DrepTypeAddrKeyHash , DrepTypeScriptHash :
166+ d .Type = drepType
167+ tmpData := struct {
168+ cbor.StructAsArray
169+ Type int
170+ Credential []byte
171+ }{}
172+ if _ , err := cbor .Decode (data , & tmpData ); err != nil {
173+ return err
174+ }
175+ d .Credential = tmpData .Credential [:]
176+ case DrepTypeAbstain , DrepTypeNoConfidence :
177+ d .Type = drepType
178+ default :
179+ return fmt .Errorf ("unknown drep type: %d" , drepType )
180+ }
181+ return nil
182+ }
183+
111184type StakeRegistrationCertificate struct {
112185 cbor.StructAsArray
113186 cbor.DecodeStoreCbor
@@ -453,3 +526,261 @@ func (c *MoveInstantaneousRewardsCertificate) Utxorpc() *utxorpc.Certificate {
453526 },
454527 }
455528}
529+
530+ type RegistrationCertificate struct {
531+ cbor.StructAsArray
532+ cbor.DecodeStoreCbor
533+ CertType uint
534+ StakeCredential StakeCredential
535+ Amount int64
536+ }
537+
538+ func (c RegistrationCertificate ) isCertificate () {}
539+
540+ func (c * RegistrationCertificate ) UnmarshalCBOR (
541+ cborData []byte ,
542+ ) error {
543+ return c .UnmarshalCbor (cborData , c )
544+ }
545+
546+ func (c * RegistrationCertificate ) Utxorpc () * utxorpc.Certificate {
547+ // TODO
548+ return nil
549+ }
550+
551+ type DeregistrationCertificate struct {
552+ cbor.StructAsArray
553+ cbor.DecodeStoreCbor
554+ CertType uint
555+ StakeCredential StakeCredential
556+ Amount int64
557+ }
558+
559+ func (c DeregistrationCertificate ) isCertificate () {}
560+
561+ func (c * DeregistrationCertificate ) UnmarshalCBOR (
562+ cborData []byte ,
563+ ) error {
564+ return c .UnmarshalCbor (cborData , c )
565+ }
566+
567+ func (c * DeregistrationCertificate ) Utxorpc () * utxorpc.Certificate {
568+ // TODO
569+ return nil
570+ }
571+
572+ type VoteDelegationCertificate struct {
573+ cbor.StructAsArray
574+ cbor.DecodeStoreCbor
575+ CertType uint
576+ StakeCredential StakeCredential
577+ Drep Drep
578+ }
579+
580+ func (c VoteDelegationCertificate ) isCertificate () {}
581+
582+ func (c * VoteDelegationCertificate ) UnmarshalCBOR (
583+ cborData []byte ,
584+ ) error {
585+ return c .UnmarshalCbor (cborData , c )
586+ }
587+
588+ func (c * VoteDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
589+ // TODO
590+ return nil
591+ }
592+
593+ type StakeVoteDelegationCertificate struct {
594+ cbor.StructAsArray
595+ cbor.DecodeStoreCbor
596+ CertType uint
597+ StakeCredential StakeCredential
598+ PoolKeyHash []byte
599+ Drep Drep
600+ }
601+
602+ func (c StakeVoteDelegationCertificate ) isCertificate () {}
603+
604+ func (c * StakeVoteDelegationCertificate ) UnmarshalCBOR (
605+ cborData []byte ,
606+ ) error {
607+ return c .UnmarshalCbor (cborData , c )
608+ }
609+
610+ func (c * StakeVoteDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
611+ // TODO
612+ return nil
613+ }
614+
615+ type StakeRegistrationDelegationCertificate struct {
616+ cbor.StructAsArray
617+ cbor.DecodeStoreCbor
618+ CertType uint
619+ StakeCredential StakeCredential
620+ PoolKeyHash []byte
621+ Amount int64
622+ }
623+
624+ func (c StakeRegistrationDelegationCertificate ) isCertificate () {}
625+
626+ func (c * StakeRegistrationDelegationCertificate ) UnmarshalCBOR (
627+ cborData []byte ,
628+ ) error {
629+ return c .UnmarshalCbor (cborData , c )
630+ }
631+
632+ func (c * StakeRegistrationDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
633+ // TODO
634+ return nil
635+ }
636+
637+ type VoteRegistrationDelegationCertificate struct {
638+ cbor.StructAsArray
639+ cbor.DecodeStoreCbor
640+ CertType uint
641+ StakeCredential StakeCredential
642+ Drep Drep
643+ Amount int64
644+ }
645+
646+ func (c VoteRegistrationDelegationCertificate ) isCertificate () {}
647+
648+ func (c * VoteRegistrationDelegationCertificate ) UnmarshalCBOR (
649+ cborData []byte ,
650+ ) error {
651+ return c .UnmarshalCbor (cborData , c )
652+ }
653+
654+ func (c * VoteRegistrationDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
655+ // TODO
656+ return nil
657+ }
658+
659+ type StakeVoteRegistrationDelegationCertificate struct {
660+ cbor.StructAsArray
661+ cbor.DecodeStoreCbor
662+ CertType uint
663+ StakeCredential StakeCredential
664+ PoolKeyHash []byte
665+ Drep Drep
666+ Amount int64
667+ }
668+
669+ func (c StakeVoteRegistrationDelegationCertificate ) isCertificate () {}
670+
671+ func (c * StakeVoteRegistrationDelegationCertificate ) UnmarshalCBOR (
672+ cborData []byte ,
673+ ) error {
674+ return c .UnmarshalCbor (cborData , c )
675+ }
676+
677+ func (c * StakeVoteRegistrationDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
678+ // TODO
679+ return nil
680+ }
681+
682+ type AuthCommitteeHotCertificate struct {
683+ cbor.StructAsArray
684+ cbor.DecodeStoreCbor
685+ CertType uint
686+ ColdCredential StakeCredential
687+ HostCredential StakeCredential
688+ }
689+
690+ func (c AuthCommitteeHotCertificate ) isCertificate () {}
691+
692+ func (c * AuthCommitteeHotCertificate ) UnmarshalCBOR (
693+ cborData []byte ,
694+ ) error {
695+ return c .UnmarshalCbor (cborData , c )
696+ }
697+
698+ func (c * AuthCommitteeHotCertificate ) Utxorpc () * utxorpc.Certificate {
699+ // TODO
700+ return nil
701+ }
702+
703+ type ResignCommitteeColdCertificate struct {
704+ cbor.StructAsArray
705+ cbor.DecodeStoreCbor
706+ CertType uint
707+ ColdCredential StakeCredential
708+ Anchor * GovAnchor
709+ }
710+
711+ func (c ResignCommitteeColdCertificate ) isCertificate () {}
712+
713+ func (c * ResignCommitteeColdCertificate ) UnmarshalCBOR (
714+ cborData []byte ,
715+ ) error {
716+ return c .UnmarshalCbor (cborData , c )
717+ }
718+
719+ func (c * ResignCommitteeColdCertificate ) Utxorpc () * utxorpc.Certificate {
720+ // TODO
721+ return nil
722+ }
723+
724+ type RegistrationDrepCertificate struct {
725+ cbor.StructAsArray
726+ cbor.DecodeStoreCbor
727+ CertType uint
728+ DrepCredential StakeCredential
729+ Amount int64
730+ Anchor * GovAnchor
731+ }
732+
733+ func (c RegistrationDrepCertificate ) isCertificate () {}
734+
735+ func (c * RegistrationDrepCertificate ) UnmarshalCBOR (
736+ cborData []byte ,
737+ ) error {
738+ return c .UnmarshalCbor (cborData , c )
739+ }
740+
741+ func (c * RegistrationDrepCertificate ) Utxorpc () * utxorpc.Certificate {
742+ // TODO
743+ return nil
744+ }
745+
746+ type DeregistrationDrepCertificate struct {
747+ cbor.StructAsArray
748+ cbor.DecodeStoreCbor
749+ CertType uint
750+ DrepCredential StakeCredential
751+ Amount int64
752+ }
753+
754+ func (c DeregistrationDrepCertificate ) isCertificate () {}
755+
756+ func (c * DeregistrationDrepCertificate ) UnmarshalCBOR (
757+ cborData []byte ,
758+ ) error {
759+ return c .UnmarshalCbor (cborData , c )
760+ }
761+
762+ func (c * DeregistrationDrepCertificate ) Utxorpc () * utxorpc.Certificate {
763+ // TODO
764+ return nil
765+ }
766+
767+ type UpdateDrepCertificate struct {
768+ cbor.StructAsArray
769+ cbor.DecodeStoreCbor
770+ CertType uint
771+ DrepCredential StakeCredential
772+ Anchor * GovAnchor
773+ }
774+
775+ func (c UpdateDrepCertificate ) isCertificate () {}
776+
777+ func (c * UpdateDrepCertificate ) UnmarshalCBOR (
778+ cborData []byte ,
779+ ) error {
780+ return c .UnmarshalCbor (cborData , c )
781+ }
782+
783+ func (c * UpdateDrepCertificate ) Utxorpc () * utxorpc.Certificate {
784+ // TODO
785+ return nil
786+ }
0 commit comments