@@ -626,6 +626,35 @@ func (d *MetadataStoreSqlite) SetTransaction(
626626 if err := saveCertRecord (& tmpReg , txn ); err != nil {
627627 return fmt .Errorf ("process certificate: %w" , err )
628628 }
629+ case * lcommon.DeregistrationDrepCertificate :
630+ drepCredential := c .DrepCredential .Credential [:]
631+
632+ tmpDereg := models.DeregistrationDrep {
633+ DrepCredential : drepCredential ,
634+ AddedSlot : point .Slot ,
635+ DepositAmount : types .Uint64 (deposit ),
636+ CertificateID : uint (i ), //nolint:gosec
637+ }
638+
639+ if err := saveCertRecord (& tmpDereg , txn ); err != nil {
640+ return fmt .Errorf ("process certificate: %w" , err )
641+ }
642+ case * lcommon.UpdateDrepCertificate :
643+ drepCredential := c .DrepCredential .Credential [:]
644+
645+ tmpUpdate := models.UpdateDrep {
646+ Credential : drepCredential ,
647+ AddedSlot : point .Slot ,
648+ CertificateID : uint (i ), //nolint:gosec
649+ }
650+ if c .Anchor != nil {
651+ tmpUpdate .AnchorUrl = c .Anchor .Url
652+ tmpUpdate .AnchorHash = c .Anchor .DataHash [:]
653+ }
654+
655+ if err := saveCertRecord (& tmpUpdate , txn ); err != nil {
656+ return fmt .Errorf ("process certificate: %w" , err )
657+ }
629658 case * lcommon.StakeVoteRegistrationDelegationCertificate :
630659 stakeKey := c .StakeCredential .Credential [:]
631660 tmpAccount , err := d .getOrCreateAccount (stakeKey , txn )
@@ -676,6 +705,70 @@ func (d *MetadataStoreSqlite) SetTransaction(
676705 if err := saveCertRecord (& tmpReg , txn ); err != nil {
677706 return fmt .Errorf ("process certificate: %w" , err )
678707 }
708+ case * lcommon.VoteDelegationCertificate :
709+ stakeKey := c .StakeCredential .Credential [:]
710+ tmpAccount , err := d .GetAccount (stakeKey , txn )
711+ if err != nil {
712+ return fmt .Errorf ("process certificate: %w" , err )
713+ }
714+ if tmpAccount == nil {
715+ d .logger .Warn ("delegating vote for non-existent account" , "hash" , stakeKey )
716+ tmpAccount = & models.Account {
717+ StakingKey : stakeKey ,
718+ }
719+ result := txn .Clauses (clause.OnConflict {
720+ Columns : []clause.Column {{Name : "staking_key" }},
721+ UpdateAll : true ,
722+ }).Create (& tmpAccount )
723+ if result .Error != nil {
724+ return fmt .Errorf ("process certificate: %w" , result .Error )
725+ }
726+ }
727+
728+ tmpAccount .Drep = c .Drep .Credential [:]
729+
730+ tmpItem := models.VoteDelegation {
731+ StakingKey : stakeKey ,
732+ Drep : c .Drep .Credential [:],
733+ AddedSlot : point .Slot ,
734+ CertificateID : uint (i ), //nolint:gosec
735+ }
736+
737+ if err := saveAccountIfNew (tmpAccount , txn ); err != nil {
738+ return fmt .Errorf ("process certificate: %w" , err )
739+ }
740+
741+ if err := saveCertRecord (& tmpItem , txn ); err != nil {
742+ return fmt .Errorf ("process certificate: %w" , err )
743+ }
744+ case * lcommon.AuthCommitteeHotCertificate :
745+ coldCredential := c .ColdCredential .Credential [:]
746+ hotCredential := c .HotCredential .Credential [:]
747+
748+ tmpAuth := models.AuthCommitteeHot {
749+ ColdCredential : coldCredential ,
750+ HostCredential : hotCredential ,
751+ AddedSlot : point .Slot ,
752+ }
753+
754+ if err := saveCertRecord (& tmpAuth , txn ); err != nil {
755+ return fmt .Errorf ("process certificate: %w" , err )
756+ }
757+ case * lcommon.ResignCommitteeColdCertificate :
758+ coldCredential := c .ColdCredential .Credential [:]
759+
760+ tmpResign := models.ResignCommitteeCold {
761+ ColdCredential : coldCredential ,
762+ AddedSlot : point .Slot ,
763+ }
764+ if c .Anchor != nil {
765+ tmpResign .AnchorUrl = c .Anchor .Url
766+ tmpResign .AnchorHash = c .Anchor .DataHash [:]
767+ }
768+
769+ if err := saveCertRecord (& tmpResign , txn ); err != nil {
770+ return fmt .Errorf ("process certificate: %w" , err )
771+ }
679772 default :
680773 return fmt .Errorf ("unsupported certificate type %T" , cert )
681774 }
0 commit comments