Skip to content

Commit

Permalink
Merge branch 'b/testnet' into b/master
Browse files Browse the repository at this point in the history
  • Loading branch information
romever committed Jul 14, 2024
2 parents e5bb938 + aa8507e commit 2f9fe4d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions api/internal/logic/governance/governanceproposalwithvoteslogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (l *GovernanceProposalWithVotesLogic) GovernanceProposalWithVotes(req *type

proposalHeight, err := l.svcCtx.Beacon.GetEpochBlock(l.ctx, beacon.EpochTime(m.ClosedEpoch))
if err != nil {
logc.Errorf(l.ctx, "getEpochBlock error, %v", err)
proposalHeight = currentHeight
//logc.Errorf(l.ctx, "getEpochBlock error, %v", err)
proposalHeight = chainStatus.GenesisHeight
}

totalVotes := quantity.NewQuantity()
Expand Down Expand Up @@ -143,6 +143,12 @@ func (l *GovernanceProposalWithVotesLogic) GovernanceProposalWithVotes(req *type
return nil, errort.NewDefaultError()
}

name, icon := "", ""
if validatorInfo != nil {
name = validatorInfo.Name
icon = validatorInfo.Icon
}

optionVoteFloat := new(big.Float).SetInt(voteMap[vote.Voter].ToBigInt())
p, _ := new(big.Float).Quo(optionVoteFloat, new(big.Float).SetInt(totalVotes.ToBigInt())).Float64()
percent, err := strconv.ParseFloat(fmt.Sprintf("%.4f", p), 64)
Expand All @@ -152,8 +158,8 @@ func (l *GovernanceProposalWithVotesLogic) GovernanceProposalWithVotes(req *type
}

voteList = append(voteList, &types.ProposalVote{
Name: validatorInfo.Name,
Icon: validatorInfo.Icon,
Name: name,
Icon: icon,
Address: vote.Voter.String(),
Vote: vote.Vote.String(),
Amount: fmt.Sprintf("%.9f", common.ValueToFloatByDecimals(voteMap[vote.Voter].ToBigInt(), common.Decimals)),
Expand Down

0 comments on commit 2f9fe4d

Please sign in to comment.