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}

props.handleShow(proposal)}> { - proposal.content && proposal.content.title + proposal.title }

{proposal.status === 3 || proposal.status === 'PROPOSAL_STATUS_PASSED' ? @@ -123,7 +123,7 @@ const Cards = (props) => { : null}
-

{proposal.content && proposal.content.description}

+

{proposal.summary}

@@ -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)}>

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')})

diff --git a/src/containers/Proposals/ProposalDialog/index.js b/src/containers/Proposals/ProposalDialog/index.js index bac38e0..095fbd4 100644 --- a/src/containers/Proposals/ProposalDialog/index.js +++ b/src/containers/Proposals/ProposalDialog/index.js @@ -37,21 +37,21 @@ class ProposalDialog extends Component { } componentDidMount () { - const votedOption = this.props.voteDetails && this.props.voteDetails.length && this.props.proposal && this.props.proposal.proposal_id && - this.props.voteDetails.filter((vote) => vote.proposal_id === this.props.proposal.proposal_id)[0]; + const votedOption = this.props.voteDetails && this.props.voteDetails.length && this.props.proposal && this.props.proposal.id && + this.props.voteDetails.filter((vote) => vote.id === this.props.proposal.id)[0]; - if (!votedOption && this.props.proposal && this.props.proposal.proposal_id && this.props.address) { - this.props.fetchVoteDetails(this.props.proposal.proposal_id, this.props.address); + if (!votedOption && this.props.proposal && this.props.proposal.id && this.props.address) { + this.props.fetchVoteDetails(this.props.proposal.id, this.props.address); } if (this.props.match && this.props.match.params && this.props.match.params.proposalID) { - if (this.props.proposal && !this.props.proposal.proposal_id) { + if (this.props.proposal && !this.props.proposal.id) { this.props.getProposals((result) => { if (result && result.length) { - const proposal = result.find((val) => val.proposal_id === this.props.match.params.proposalID); + const proposal = result.find((val) => val.id === this.props.match.params.proposalID); this.props.showProposalDialog(proposal); if (proposal && (proposal.status === 2 || proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD')) { - this.props.fetchProposalTally(proposal.proposal_id); + this.props.fetchProposalTally(proposal.id); } } }); @@ -73,18 +73,18 @@ class ProposalDialog extends Component { const { proposal } = this.props; if (proposal && (proposal.status === 2 || proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD')) { - const value = this.props.tallyDetails && this.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 = this.props.tallyDetails && this.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 (this.props.tallyDetails && this.props.tallyDetails[proposal.proposal_id] && this.props.tallyDetails[proposal.proposal_id][val] - ? tally(this.props.tallyDetails[proposal.proposal_id][val], sum) : '0%'); + return (this.props.tallyDetails && this.props.tallyDetails[proposal.id] && this.props.tallyDetails[proposal.id][val] + ? tally(this.props.tallyDetails[proposal.id][val], sum) : '0%'); } else { - const sum = proposal && 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 && 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] @@ -99,13 +99,13 @@ class ProposalDialog extends Component { render () { let votedOption = this.props.voteDetails && this.props.voteDetails.length && - this.props.proposal && this.props.proposal.proposal_id && - this.props.voteDetails.filter((vote) => vote.proposal_id === this.props.proposal.proposal_id)[0]; + this.props.proposal && this.props.proposal.id && + this.props.voteDetails.filter((vote) => vote.id === this.props.proposal.id)[0]; let proposer = this.props.proposal && this.props.proposal.proposer; this.props.proposalDetails && Object.keys(this.props.proposalDetails).length && Object.keys(this.props.proposalDetails).filter((key) => { - if (this.props.proposal && key === this.props.proposal.proposal_id) { + if (this.props.proposal && key === this.props.proposal.id) { if (this.props.proposalDetails[key] && this.props.proposalDetails[key][0] && this.props.proposalDetails[key][0].body && @@ -124,6 +124,8 @@ class ProposalDialog extends Component { votedOption = votedOption.options[0]; } + const content = this.props.proposal && this.props.proposal.messages && this.props.proposal.messages[0] && this.props.proposal.messages[0].content; + return (
@@ -131,7 +133,7 @@ class ProposalDialog extends Component { ?
Loading...
- : this.props.proposal && this.props.proposal.proposal_id + : this.props.proposal && this.props.proposal.id ?
@@ -139,8 +141,7 @@ class ProposalDialog extends Component {
{this.props.proposal && this.props.proposal.content && - this.props.proposal.content.title}
+ className="proposal_dialog_section1_header">{this.props.proposal && this.props.proposal.title}
-                                        {this.props.proposal && this.props.proposal.content && this.props.proposal.content.description}
+                                        {this.props.proposal && this.props.proposal.summary}
                                     
Voting Status

+ this.props.proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD') ? 'vote_in_progress' : '')}>
-

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}

{this.props.proposal && (this.props.proposal.status === 2 || this.props.proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD') && !this.props.voteDetailsInProgress - ? + ? : null}
{votedOption @@ -293,7 +293,7 @@ ProposalDialog.propTypes = { proposalsInProgress: PropTypes.bool, votes: PropTypes.arrayOf( PropTypes.shape({ - proposal_id: PropTypes.string.isRequired, + id: PropTypes.string.isRequired, voter: PropTypes.string.isRequired, option: PropTypes.number, }),