@@ -610,8 +610,13 @@ func (c *RegistrationCertificate) UnmarshalCBOR(
610610}
611611
612612func (c * RegistrationCertificate ) Utxorpc () * utxorpc.Certificate {
613- // TODO (#850)
614- return nil
613+ return & utxorpc.Certificate {
614+ Certificate : & utxorpc.Certificate_RegCert {
615+ RegCert : & utxorpc.RegCert {
616+ StakeCredential : c .StakeCredential .Utxorpc (),
617+ },
618+ },
619+ }
615620}
616621
617622func (c * RegistrationCertificate ) Type () uint {
@@ -642,8 +647,13 @@ func (c *DeregistrationCertificate) UnmarshalCBOR(
642647}
643648
644649func (c * DeregistrationCertificate ) Utxorpc () * utxorpc.Certificate {
645- // TODO (#850)
646- return nil
650+ return & utxorpc.Certificate {
651+ Certificate : & utxorpc.Certificate_UnregCert {
652+ UnregCert : & utxorpc.UnRegCert {
653+ StakeCredential : c .StakeCredential .Utxorpc (),
654+ },
655+ },
656+ }
647657}
648658
649659func (c * DeregistrationCertificate ) Type () uint {
@@ -674,8 +684,14 @@ func (c *VoteDelegationCertificate) UnmarshalCBOR(
674684}
675685
676686func (c * VoteDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
677- // TODO (#850)
678- return nil
687+ return & utxorpc.Certificate {
688+ Certificate : & utxorpc.Certificate_VoteDelegCert {
689+ VoteDelegCert : & utxorpc.VoteDelegCert {
690+ StakeCredential : c .StakeCredential .Utxorpc (),
691+ Drep : c .Drep .Utxorpc (),
692+ },
693+ },
694+ }
679695}
680696
681697func (c * VoteDelegationCertificate ) Type () uint {
@@ -707,8 +723,35 @@ func (c *StakeVoteDelegationCertificate) UnmarshalCBOR(
707723}
708724
709725func (c * StakeVoteDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
710- // TODO (#850)
711- return nil
726+ drepProto := c .Drep .Utxorpc ()
727+ var drepBytes []byte
728+
729+ // Extract DRep credential if it exists (AddrKeyHash or ScriptHash)
730+ if drepProto != nil {
731+ switch v := drepProto .GetDrep ().(type ) {
732+ case * utxorpc.DRep_AddrKeyHash :
733+ drepBytes = v .AddrKeyHash
734+ case * utxorpc.DRep_ScriptHash :
735+ drepBytes = v .ScriptHash
736+ }
737+ }
738+
739+ // Encode both PoolKeyHash and DRep in PoolKeyhash field
740+ // Format: [1-byte type][poolKeyHash][drepBytes]
741+ encodedKey := make ([]byte , 0 , 1 + len (c .PoolKeyHash )+ len (drepBytes ))
742+ encodedKey = append (encodedKey , byte (0x01 )) // Version byte
743+ encodedKey = append (encodedKey , c .PoolKeyHash ... )
744+ encodedKey = append (encodedKey , drepBytes ... )
745+
746+ return & utxorpc.Certificate {
747+ Certificate : & utxorpc.Certificate_StakeVoteDelegCert {
748+ StakeVoteDelegCert : & utxorpc.StakeVoteDelegCert {
749+ StakeCredential : c .StakeCredential .Utxorpc (),
750+ PoolKeyhash : encodedKey ,
751+ Drep : c .Drep .Utxorpc (),
752+ },
753+ },
754+ }
712755}
713756
714757func (c * StakeVoteDelegationCertificate ) Type () uint {
@@ -740,8 +783,14 @@ func (c *StakeRegistrationDelegationCertificate) UnmarshalCBOR(
740783}
741784
742785func (c * StakeRegistrationDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
743- // TODO (#850)
744- return nil
786+ return & utxorpc.Certificate {
787+ Certificate : & utxorpc.Certificate_StakeVoteDelegCert {
788+ StakeVoteDelegCert : & utxorpc.StakeVoteDelegCert {
789+ StakeCredential : c .StakeCredential .Utxorpc (),
790+ PoolKeyhash : c .PoolKeyHash ,
791+ },
792+ },
793+ }
745794}
746795
747796func (c * StakeRegistrationDelegationCertificate ) Type () uint {
@@ -773,8 +822,14 @@ func (c *VoteRegistrationDelegationCertificate) UnmarshalCBOR(
773822}
774823
775824func (c * VoteRegistrationDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
776- // TODO (#850)
777- return nil
825+ return & utxorpc.Certificate {
826+ Certificate : & utxorpc.Certificate_VoteRegDelegCert {
827+ VoteRegDelegCert : & utxorpc.VoteRegDelegCert {
828+ StakeCredential : c .StakeCredential .Utxorpc (),
829+ Drep : c .Drep .Utxorpc (),
830+ },
831+ },
832+ }
778833}
779834
780835func (c * VoteRegistrationDelegationCertificate ) Type () uint {
@@ -807,8 +862,27 @@ func (c *StakeVoteRegistrationDelegationCertificate) UnmarshalCBOR(
807862}
808863
809864func (c * StakeVoteRegistrationDelegationCertificate ) Utxorpc () * utxorpc.Certificate {
810- // TODO (#850)
811- return nil
865+ drepProto := c .Drep .Utxorpc ()
866+ var drepBytes []byte
867+
868+ if drepProto != nil {
869+ switch v := drepProto .GetDrep ().(type ) {
870+ case * utxorpc.DRep_AddrKeyHash :
871+ drepBytes = v .AddrKeyHash
872+ case * utxorpc.DRep_ScriptHash :
873+ drepBytes = v .ScriptHash
874+ }
875+ }
876+
877+ return & utxorpc.Certificate {
878+ Certificate : & utxorpc.Certificate_StakeVoteRegDelegCert {
879+ StakeVoteRegDelegCert : & utxorpc.StakeVoteRegDelegCert {
880+ StakeCredential : c .StakeCredential .Utxorpc (),
881+ PoolKeyhash : drepBytes ,
882+ Drep : c .Drep .Utxorpc (),
883+ },
884+ },
885+ }
812886}
813887
814888func (c * StakeVoteRegistrationDelegationCertificate ) Type () uint {
@@ -839,8 +913,14 @@ func (c *AuthCommitteeHotCertificate) UnmarshalCBOR(
839913}
840914
841915func (c * AuthCommitteeHotCertificate ) Utxorpc () * utxorpc.Certificate {
842- // TODO (#850)
843- return nil
916+ return & utxorpc.Certificate {
917+ Certificate : & utxorpc.Certificate_AuthCommitteeHotCert {
918+ AuthCommitteeHotCert : & utxorpc.AuthCommitteeHotCert {
919+ CommitteeColdCredential : c .ColdCredential .Utxorpc (),
920+ CommitteeHotCredential : c .HostCredential .Utxorpc (),
921+ },
922+ },
923+ }
844924}
845925
846926func (c * AuthCommitteeHotCertificate ) Type () uint {
@@ -871,8 +951,21 @@ func (c *ResignCommitteeColdCertificate) UnmarshalCBOR(
871951}
872952
873953func (c * ResignCommitteeColdCertificate ) Utxorpc () * utxorpc.Certificate {
874- // TODO (#850)
875- return nil
954+ var anchor * utxorpc.Anchor
955+ if c .Anchor != nil {
956+ anchor = & utxorpc.Anchor {
957+ Url : c .Anchor .Url ,
958+ ContentHash : c .Anchor .DataHash [:],
959+ }
960+ }
961+ return & utxorpc.Certificate {
962+ Certificate : & utxorpc.Certificate_ResignCommitteeColdCert {
963+ ResignCommitteeColdCert : & utxorpc.ResignCommitteeColdCert {
964+ CommitteeColdCredential : c .ColdCredential .Utxorpc (),
965+ Anchor : anchor ,
966+ },
967+ },
968+ }
876969}
877970
878971func (c * ResignCommitteeColdCertificate ) Type () uint {
@@ -904,8 +997,22 @@ func (c *RegistrationDrepCertificate) UnmarshalCBOR(
904997}
905998
906999func (c * RegistrationDrepCertificate ) Utxorpc () * utxorpc.Certificate {
907- // TODO (#850)
908- return nil
1000+ // Handle anchor data if present
1001+ var anchor * utxorpc.Anchor
1002+ if c .Anchor != nil {
1003+ anchor = & utxorpc.Anchor {
1004+ Url : c .Anchor .Url ,
1005+ ContentHash : c .Anchor .DataHash [:],
1006+ }
1007+ }
1008+ return & utxorpc.Certificate {
1009+ Certificate : & utxorpc.Certificate_RegDrepCert {
1010+ RegDrepCert : & utxorpc.RegDRepCert {
1011+ DrepCredential : c .DrepCredential .Utxorpc (),
1012+ Anchor : anchor ,
1013+ },
1014+ },
1015+ }
9091016}
9101017
9111018func (c * RegistrationDrepCertificate ) Type () uint {
@@ -936,8 +1043,13 @@ func (c *DeregistrationDrepCertificate) UnmarshalCBOR(
9361043}
9371044
9381045func (c * DeregistrationDrepCertificate ) Utxorpc () * utxorpc.Certificate {
939- // TODO (#850)
940- return nil
1046+ return & utxorpc.Certificate {
1047+ Certificate : & utxorpc.Certificate_UnregDrepCert {
1048+ UnregDrepCert : & utxorpc.UnRegDRepCert {
1049+ DrepCredential : c .DrepCredential .Utxorpc (),
1050+ },
1051+ },
1052+ }
9411053}
9421054
9431055func (c * DeregistrationDrepCertificate ) Type () uint {
@@ -968,10 +1080,47 @@ func (c *UpdateDrepCertificate) UnmarshalCBOR(
9681080}
9691081
9701082func (c * UpdateDrepCertificate ) Utxorpc () * utxorpc.Certificate {
971- // TODO (#850)
972- return nil
1083+ var anchor * utxorpc.Anchor
1084+ if c .Anchor != nil {
1085+ anchor = & utxorpc.Anchor {
1086+ Url : c .Anchor .Url ,
1087+ ContentHash : c .Anchor .DataHash [:],
1088+ }
1089+ }
1090+ return & utxorpc.Certificate {
1091+ Certificate : & utxorpc.Certificate_UpdateDrepCert {
1092+ UpdateDrepCert : & utxorpc.UpdateDRepCert {
1093+ DrepCredential : c .DrepCredential .Utxorpc (),
1094+ Anchor : anchor ,
1095+ },
1096+ },
1097+ }
9731098}
9741099
9751100func (c * UpdateDrepCertificate ) Type () uint {
9761101 return c .CertType
9771102}
1103+
1104+ // DRep implementation
1105+ func (d * Drep ) Utxorpc () * utxorpc.DRep {
1106+ switch d .Type {
1107+ case DrepTypeAddrKeyHash :
1108+ return & utxorpc.DRep {
1109+ Drep : & utxorpc.DRep_AddrKeyHash {AddrKeyHash : d .Credential },
1110+ }
1111+ case DrepTypeScriptHash :
1112+ return & utxorpc.DRep {
1113+ Drep : & utxorpc.DRep_ScriptHash {ScriptHash : d .Credential },
1114+ }
1115+ case DrepTypeAbstain :
1116+ return & utxorpc.DRep {
1117+ Drep : & utxorpc.DRep_Abstain {Abstain : true },
1118+ }
1119+ case DrepTypeNoConfidence :
1120+ return & utxorpc.DRep {
1121+ Drep : & utxorpc.DRep_NoConfidence {NoConfidence : true },
1122+ }
1123+ default :
1124+ return nil
1125+ }
1126+ }
0 commit comments