Skip to content

Commit

Permalink
proposal listing fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Oct 31, 2023
1 parent 215f2a2 commit efe84bd
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/actions/proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const fetchProposalDetails = (id, cb) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchProposalDetailsSuccess(res.data && res.data.txs, id));
dispatch(fetchProposalDetailsSuccess(res.data && res.data.proposal, id));
if (cb) {
cb(res);
}
Expand Down
4 changes: 2 additions & 2 deletions src/constants/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const urlFetchVoteDetails = (proposalId, address) => `${REST_URL}/cosmos/

export const VALIDATORS_LIST_URL = `${REST_URL}/cosmos/staking/v1beta1/validators?pagination.limit=1000`;
export const getValidatorURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/validators/${address}`;
export const PROPOSALS_LIST_URL = `${REST_URL}/cosmos/gov/v1beta1/proposals?pagination.limit=1000`;
export const PROPOSALS_LIST_URL = `${REST_URL}/cosmos/gov/v1/proposals?pagination.limit=1000`;
export const getDelegatedValidatorsURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/delegators/${address}/validators`;
export const urlFetchProposalVotes = (id) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${id}/votes`;
export const urlFetchTallyDetails = (id) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${id}/tally`;
export const urlFetchProposalDetails = (id) => `${REST_URL}/cosmos/tx/v1beta1/txs?events=submit_proposal.proposal_id=${id}`;
export const urlFetchProposalDetails = (id) => `${REST_URL}/cosmos/gov/v1/proposals/${id}`;

export const validatorImageURL = (id) => `https://keybase.io/_/api/1.0/user/lookup.json?fields=pictures&key_suffix=${id}`;
48 changes: 24 additions & 24 deletions src/containers/Proposals/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ const Cards = (props) => {

const VoteCalculation = (proposal, val) => {
if (proposal.status === 2 || proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD') {
const value = props.tallyDetails && props.tallyDetails[proposal.proposal_id];
const sum = value && value.yes && value.no && value.no_with_veto && value.abstain &&
(parseInt(value.yes) + parseInt(value.no) + parseInt(value.no_with_veto) + parseInt(value.abstain));
const value = props.tallyDetails && props.tallyDetails[proposal.id];
const sum = value && value.yes_count && value.no_count && value.no_with_veto_count && value.abstain_count &&
(parseInt(value.yes_count) + parseInt(value.no_count) + parseInt(value.no_with_veto_count) + parseInt(value.abstain_count));

return (props.tallyDetails && props.tallyDetails[proposal.proposal_id] && props.tallyDetails[proposal.proposal_id][val]
? tally(props.tallyDetails[proposal.proposal_id][val], sum) : '0%');
return (props.tallyDetails && props.tallyDetails[proposal.id] && props.tallyDetails[proposal.id][val]
? tally(props.tallyDetails[proposal.id][val], sum) : '0%');
} else {
const sum = proposal.final_tally_result && proposal.final_tally_result.yes &&
proposal.final_tally_result.no && proposal.final_tally_result.no_with_veto &&
proposal.final_tally_result.abstain &&
(parseInt(proposal.final_tally_result.yes) + parseInt(proposal.final_tally_result.no) +
parseInt(proposal.final_tally_result.no_with_veto) + parseInt(proposal.final_tally_result.abstain));
const sum = proposal.final_tally_result && proposal.final_tally_result.yes_count &&
proposal.final_tally_result.no_count && proposal.final_tally_result.no_with_veto_count &&
proposal.final_tally_result.abstain_count &&
(parseInt(proposal.final_tally_result.yes_count) + parseInt(proposal.final_tally_result.no_count) +
parseInt(proposal.final_tally_result.no_with_veto_count) + parseInt(proposal.final_tally_result.abstain_count));

return (proposal && proposal.final_tally_result &&
proposal.final_tally_result[val]
Expand All @@ -51,7 +51,7 @@ const Cards = (props) => {
};

const handleProposal = (proposal) => {
props.history.push(`/proposals/${proposal.proposal_id}`);
props.history.push(`/proposals/${proposal.id}`);
props.handleShow(proposal);
};

Expand All @@ -62,12 +62,12 @@ const Cards = (props) => {
reversedItems.map((proposal, index) => {
if (index < (page * rowsPerPage) && index >= (page - 1) * rowsPerPage) {
const votedOption = props.voteDetails && props.voteDetails.length &&
proposal && proposal.proposal_id &&
props.voteDetails.filter((vote) => vote.proposal_id === proposal.proposal_id)[0];
proposal && proposal.id &&
props.voteDetails.filter((vote) => vote.id === proposal.id)[0];
let proposer = proposal.proposer;
props.proposalDetails && Object.keys(props.proposalDetails).length &&
Object.keys(props.proposalDetails).filter((key) => {
if (key === proposal.proposal_id) {
if (key === proposal.id) {
if (props.proposalDetails[key] &&
props.proposalDetails[key][0] &&
props.proposalDetails[key][0].body &&
Expand All @@ -81,7 +81,7 @@ const Cards = (props) => {
return null;
});
let inProgress = props.proposalDetails && Object.keys(props.proposalDetails).length &&
Object.keys(props.proposalDetails).find((key) => key === proposal.proposal_id);
Object.keys(props.proposalDetails).find((key) => key === proposal.id);
inProgress = !inProgress && props.proposalDetailsInProgress;

return (
Expand All @@ -90,11 +90,11 @@ const Cards = (props) => {
className="card"
onClick={() => handleProposal(proposal)}>
<span className="number">
{proposal.proposal_id}
{proposal.id}
</span>
<div className="card_heading">
<h2 onClick={() => props.handleShow(proposal)}> {
proposal.content && proposal.content.title
proposal.title
}</h2>
{proposal.status === 3 || proposal.status === 'PROPOSAL_STATUS_PASSED'
? <Icon className="success" icon="success"/>
Expand Down Expand Up @@ -123,7 +123,7 @@ const Cards = (props) => {
</Button>
: null}
</div>
<p className="description">{proposal.content && proposal.content.description}</p>
<p className="description">{proposal.summary}</p>
<div className="row">
<div className="icon_info">
<Icon className="person" icon="person"/>
Expand Down Expand Up @@ -156,7 +156,7 @@ const Cards = (props) => {
proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD')
? 'voting_period'
: (proposal.status === 4 ||
proposal.status === 'PROPOSAL_STATUS_REJECTED')
proposal.status === 'PROPOSAL_STATUS_REJECTED')
? 'rejected'
: null)}>
<p>Proposal Status: {
Expand All @@ -167,7 +167,7 @@ const Cards = (props) => {
: proposal.status === 2 ||
proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD' ? 'VotingPeriod'
: proposal.status === 3 ||
proposal.status === 'PROPOSAL_STATUS_PASSED' ? 'Passed'
proposal.status === 'PROPOSAL_STATUS_PASSED' ? 'Passed'
: proposal.status === 4 ||
proposal.status === 'PROPOSAL_STATUS_REJECTED' ? 'Rejected'
: proposal.status === 5 ||
Expand All @@ -177,19 +177,19 @@ const Cards = (props) => {
<div className="vote_details">
<div className="yes">
<span/>
<p>YES ({VoteCalculation(proposal, 'yes')})</p>
<p>YES ({VoteCalculation(proposal, 'yes_count')})</p>
</div>
<div className="no">
<span/>
<p>NO ({VoteCalculation(proposal, 'no')})</p>
<p>NO ({VoteCalculation(proposal, 'no_count')})</p>
</div>
<div className="option3">
<span/>
<p>NoWithVeto ({VoteCalculation(proposal, 'no_with_veto')})</p>
<p>NoWithVeto ({VoteCalculation(proposal, 'no_with_veto_count')})</p>
</div>
<div className="option4">
<span/>
<p>Abstain ({VoteCalculation(proposal, 'abstain')})</p>
<p>Abstain ({VoteCalculation(proposal, 'abstain_count')})</p>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit efe84bd

Please sign in to comment.