@@ -610,8 +610,13 @@ func (c *RegistrationCertificate) UnmarshalCBOR(
610
610
}
611
611
612
612
func (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
+ }
615
620
}
616
621
617
622
func (c * RegistrationCertificate ) Type () uint {
@@ -642,8 +647,13 @@ func (c *DeregistrationCertificate) UnmarshalCBOR(
642
647
}
643
648
644
649
func (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
+ }
647
657
}
648
658
649
659
func (c * DeregistrationCertificate ) Type () uint {
@@ -674,8 +684,14 @@ func (c *VoteDelegationCertificate) UnmarshalCBOR(
674
684
}
675
685
676
686
func (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
+ }
679
695
}
680
696
681
697
func (c * VoteDelegationCertificate ) Type () uint {
@@ -707,8 +723,35 @@ func (c *StakeVoteDelegationCertificate) UnmarshalCBOR(
707
723
}
708
724
709
725
func (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
+ }
712
755
}
713
756
714
757
func (c * StakeVoteDelegationCertificate ) Type () uint {
@@ -740,8 +783,14 @@ func (c *StakeRegistrationDelegationCertificate) UnmarshalCBOR(
740
783
}
741
784
742
785
func (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
+ }
745
794
}
746
795
747
796
func (c * StakeRegistrationDelegationCertificate ) Type () uint {
@@ -773,8 +822,14 @@ func (c *VoteRegistrationDelegationCertificate) UnmarshalCBOR(
773
822
}
774
823
775
824
func (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
+ }
778
833
}
779
834
780
835
func (c * VoteRegistrationDelegationCertificate ) Type () uint {
@@ -807,8 +862,27 @@ func (c *StakeVoteRegistrationDelegationCertificate) UnmarshalCBOR(
807
862
}
808
863
809
864
func (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
+ }
812
886
}
813
887
814
888
func (c * StakeVoteRegistrationDelegationCertificate ) Type () uint {
@@ -839,8 +913,14 @@ func (c *AuthCommitteeHotCertificate) UnmarshalCBOR(
839
913
}
840
914
841
915
func (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
+ }
844
924
}
845
925
846
926
func (c * AuthCommitteeHotCertificate ) Type () uint {
@@ -871,8 +951,21 @@ func (c *ResignCommitteeColdCertificate) UnmarshalCBOR(
871
951
}
872
952
873
953
func (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
+ }
876
969
}
877
970
878
971
func (c * ResignCommitteeColdCertificate ) Type () uint {
@@ -904,8 +997,22 @@ func (c *RegistrationDrepCertificate) UnmarshalCBOR(
904
997
}
905
998
906
999
func (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
+ }
909
1016
}
910
1017
911
1018
func (c * RegistrationDrepCertificate ) Type () uint {
@@ -936,8 +1043,13 @@ func (c *DeregistrationDrepCertificate) UnmarshalCBOR(
936
1043
}
937
1044
938
1045
func (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
+ }
941
1053
}
942
1054
943
1055
func (c * DeregistrationDrepCertificate ) Type () uint {
@@ -968,10 +1080,47 @@ func (c *UpdateDrepCertificate) UnmarshalCBOR(
968
1080
}
969
1081
970
1082
func (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
+ }
973
1098
}
974
1099
975
1100
func (c * UpdateDrepCertificate ) Type () uint {
976
1101
return c .CertType
977
1102
}
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