From b97c5467c982e0175f653c61aa9f23cb1afad489 Mon Sep 17 00:00:00 2001 From: Enzo Cioppettini Date: Mon, 8 Apr 2024 14:20:57 -0300 Subject: [PATCH] fix multiera_drep_delegation not using drep credential --- indexer/tasks/src/multiera/multiera_address.rs | 2 +- indexer/tasks/src/multiera/multiera_drep_delegation.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/indexer/tasks/src/multiera/multiera_address.rs b/indexer/tasks/src/multiera/multiera_address.rs index 42ac6b95..ea0c3b7f 100644 --- a/indexer/tasks/src/multiera/multiera_address.rs +++ b/indexer/tasks/src/multiera/multiera_address.rs @@ -463,7 +463,7 @@ fn queue_address_credential( // AlwaysAbstain and AlwaysNoConfidence are ignored here because we only can add // relations to actual credentials -fn drep_to_credential(d_rep: &cml_chain::certs::DRep) -> Option { +pub fn drep_to_credential(d_rep: &cml_chain::certs::DRep) -> Option { match d_rep { cml_chain::certs::DRep::Key { pool, .. } => Some(StakeCredential::new_pub_key(*pool)), cml_chain::certs::DRep::Script { script_hash, .. } => { diff --git a/indexer/tasks/src/multiera/multiera_drep_delegation.rs b/indexer/tasks/src/multiera/multiera_drep_delegation.rs index 86c9002c..b12fe2d3 100644 --- a/indexer/tasks/src/multiera/multiera_drep_delegation.rs +++ b/indexer/tasks/src/multiera/multiera_drep_delegation.rs @@ -14,6 +14,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::ops::Deref; use super::{ + multiera_address::drep_to_credential, multiera_address_credential_relations::QueuedAddressCredentialRelation, multiera_txs::MultieraTransactionTask, relation_map::RelationMap, }; @@ -61,19 +62,19 @@ async fn handle( let (credential, drep) = match cert { MultiEraCertificate::VoteDelegCert(delegation) => ( delegation.stake_credential.clone(), - Some(delegation.d_rep.to_cbor_bytes()), + drep_to_credential(&delegation.d_rep), ), MultiEraCertificate::StakeVoteDelegCert(delegation) => ( delegation.stake_credential.clone(), - Some(delegation.d_rep.to_cbor_bytes()), + drep_to_credential(&delegation.d_rep), ), MultiEraCertificate::VoteRegDelegCert(delegation) => ( delegation.stake_credential.clone(), - Some(delegation.d_rep.to_cbor_bytes()), + drep_to_credential(&delegation.d_rep), ), MultiEraCertificate::StakeVoteRegDelegCert(delegation) => ( delegation.stake_credential.clone(), - Some(delegation.d_rep.to_cbor_bytes()), + drep_to_credential(&delegation.d_rep), ), MultiEraCertificate::StakeDeregistration(deregistration) => { (deregistration.stake_credential.clone(), None) @@ -83,6 +84,7 @@ async fn handle( }; let credential = credential.to_cbor_bytes(); + let drep = drep.map(|cred| cred.to_cbor_bytes()); let stake_credential_id = multiera_stake_credential .get(&credential.to_vec())