diff --git a/src/actions/proposals.js b/src/actions/proposals.js index 947e36a..04e698c 100644 --- a/src/actions/proposals.js +++ b/src/actions/proposals.js @@ -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); } diff --git a/src/constants/url.js b/src/constants/url.js index f7d2b56..8c0dc4f 100644 --- a/src/constants/url.js +++ b/src/constants/url.js @@ -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}`; diff --git a/src/containers/Proposals/Cards.js b/src/containers/Proposals/Cards.js index 8eea686..998e168 100644 --- a/src/containers/Proposals/Cards.js +++ b/src/containers/Proposals/Cards.js @@ -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] @@ -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); }; @@ -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 && @@ -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 ( @@ -90,11 +90,11 @@ const Cards = (props) => { className="card" onClick={() => handleProposal(proposal)}> - {proposal.proposal_id} + {proposal.id}
{proposal.content && proposal.content.description}
+{proposal.summary}
Proposal Status: { @@ -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 || @@ -177,19 +177,19 @@ const Cards = (props) => {
YES ({VoteCalculation(proposal, 'yes')})
+YES ({VoteCalculation(proposal, 'yes_count')})
NO ({VoteCalculation(proposal, 'no')})
+NO ({VoteCalculation(proposal, 'no_count')})
NoWithVeto ({VoteCalculation(proposal, 'no_with_veto')})
+NoWithVeto ({VoteCalculation(proposal, 'no_with_veto_count')})
Abstain ({VoteCalculation(proposal, 'abstain')})
+Abstain ({VoteCalculation(proposal, 'abstain_count')})
- {this.props.proposal && this.props.proposal.content && this.props.proposal.content.description} + {this.props.proposal && this.props.proposal.summary}
YES ({this.VoteCalculation('yes')})
+YES ({this.VoteCalculation('yes_count')})
NO ({this.VoteCalculation('no')})
+NO ({this.VoteCalculation('no_count')})
NoWithVeto ({this.VoteCalculation('no_with_veto')})
+NoWithVeto ({this.VoteCalculation('no_with_veto_count')})
Abstain ({this.VoteCalculation('abstain')})
+Abstain ({this.VoteCalculation('abstain_count')})
Type
-{this.props.proposal && this.props.proposal.content && - this.props.proposal.content.type - ? this.props.proposal.content.type - : this.props.proposal && this.props.proposal.content && this.props.proposal.content['@type'] - ? this.props.proposal.content['@type'] : null}
+{this.props.proposal && content && content.type + ? content.type + : this.props.proposal && content && content['@type'] + ? content['@type'] : null}