Skip to content

Commit

Permalink
chore: stake pool votes in gov state query
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-HuyLe3 committed Jul 8, 2024
1 parent 939715b commit 32c85ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.bloxbean.cardano.yaci.core.model.PoolVotingThresholds;
import com.bloxbean.cardano.yaci.core.model.ProtocolParamUpdate;
import com.bloxbean.cardano.yaci.core.model.certs.StakeCredType;
import com.bloxbean.cardano.yaci.core.model.certs.StakePoolId;
import com.bloxbean.cardano.yaci.core.model.governance.*;
import com.bloxbean.cardano.yaci.core.model.serializers.governance.AnchorSerializer;
import com.bloxbean.cardano.yaci.core.protocol.handshake.messages.AcceptVersion;
Expand Down Expand Up @@ -195,13 +196,24 @@ public GovStateResult deserializeResult(AcceptVersion protocolVersion, DataItem[
dRepVotes.put(credType == 0 ? Drep.addrKeyHash(credHash) : Drep.scriptHash(credHash), vote);
}

// stake pool votes
java.util.Map<StakePoolId, Vote> stakePoolVotes = new HashMap<>();
var stakePoolVotesDI = (Map) proposalDI.getDataItems().get(3);
for (DataItem key : stakePoolVotesDI.getKeys()) {
String poolHash = HexUtil.encodeHexString(((ByteString)key).getBytes());
var voteDI = stakePoolVotesDI.get(key);
Vote vote = Vote.values()[toInt(voteDI)];
stakePoolVotes.put(StakePoolId.builder().poolKeyHash(poolHash).build(), vote);
}

// expiredAfter
Integer expiredAfter = toInt(proposalDI.getDataItems().get(6));
// proposedIn
Integer proposedIn = toInt(proposalDI.getDataItems().get(5));
proposals.add(
Proposal.builder()
.dRepVotes(dRepVotes)
.stakePoolVotes(stakePoolVotes)
.proposalProcedure(proposalProcedure)
.govActionId(govActionId)
.expiredAfter(expiredAfter)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bloxbean.cardano.yaci.core.protocol.localstate.queries.model;

import com.bloxbean.cardano.yaci.core.model.certs.StakePoolId;
import com.bloxbean.cardano.yaci.core.model.governance.Drep;
import com.bloxbean.cardano.yaci.core.model.governance.GovActionId;
import com.bloxbean.cardano.yaci.core.model.governance.ProposalProcedure;
Expand All @@ -16,8 +17,8 @@
public class Proposal {
private GovActionId govActionId;
// TODO: committees votes;
// TODO: stake pools votes
private Map<Drep, Vote> dRepVotes;
private Map<StakePoolId, Vote> stakePoolVotes;
private ProposalProcedure proposalProcedure;
private Integer expiredAfter;
private Integer proposedIn;
Expand Down

0 comments on commit 32c85ab

Please sign in to comment.