diff --git a/src/constants/url.js b/src/constants/url.js index a872d3b..996b933 100644 --- a/src/constants/url.js +++ b/src/constants/url.js @@ -13,7 +13,7 @@ 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 INACTIVE_VALIDATORS_URL = `${REST_URL}/cosmos/staking/v1beta1/validators?pagination.limit=1000&status=BOND_STATUS_UNBONDED`; export const INACTIVE_VALIDATORS_UNBONDING_URL = `${REST_URL}/cosmos/staking/v1beta1/validators?pagination.limit=1000&status=BOND_STATUS_UNBONDING`; export const getDelegatedValidatorsURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/delegators/${address}/validators`; diff --git a/src/containers/NavBar/index.js b/src/containers/NavBar/index.js index 2096167..4776359 100644 --- a/src/containers/NavBar/index.js +++ b/src/containers/NavBar/index.js @@ -81,7 +81,7 @@ class NavBar extends Component { array.push(val.proposal_id); } if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') { - this.props.fetchProposalTally(val.proposal_id); + this.props.fetchProposalTally(val.id); } return null; @@ -104,7 +104,7 @@ class NavBar extends Component { array.push(val.proposal_id); } if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') { - this.props.fetchProposalTally(val.proposal_id); + this.props.fetchProposalTally(val.id); } return null; @@ -174,7 +174,7 @@ class NavBar extends Component { if ((val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') && !votedOption && this.props.address) { - this.props.fetchVoteDetails(val.proposal_id, this.props.address); + this.props.fetchVoteDetails(val.id, this.props.address); } return null; @@ -197,8 +197,8 @@ class NavBar extends Component { array.push(val.proposal_id); } if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') { - this.props.fetchProposalTally(val.proposal_id); - this.props.fetchVoteDetails(val.proposal_id, this.props.address); + this.props.fetchProposalTally(val.id); + this.props.fetchVoteDetails(val.id, this.props.address); } return null; diff --git a/src/containers/Proposals/Cards.js b/src/containers/Proposals/Cards.js index 9a2f2c5..6ac9aeb 100644 --- a/src/containers/Proposals/Cards.js +++ b/src/containers/Proposals/Cards.js @@ -31,7 +31,7 @@ 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 value = props.tallyDetails && props.tallyDetails[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)); let val1 = null; @@ -45,33 +45,24 @@ const Cards = (props) => { val1 = 'abstain'; } - return (props.tallyDetails && props.tallyDetails[proposal.proposal_id] && props.tallyDetails[proposal.proposal_id][val1] - ? tally(props.tallyDetails[proposal.proposal_id][val1], sum) : '0%'); + console.log('55555', sum, val, val1, value, props.tallyDetails, proposal.id); + return (props.tallyDetails && props.tallyDetails[proposal.id] && props.tallyDetails[proposal.id][val1] + ? tally(props.tallyDetails[proposal.id][val1], 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)); - let val1 = null; - if (val === 'yes_count') { - val1 = 'yes'; - } else if (val === 'no_count') { - val1 = 'no'; - } else if (val === 'no_with_veto_count') { - val1 = 'no_with_veto'; - } else if (val === 'abstain_count') { - val1 = '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[val1] - ? tally(proposal.final_tally_result[val1], sum) : '0%'); + proposal.final_tally_result[val] + ? tally(proposal.final_tally_result[val], sum) : '0%'); } }; const handleProposal = (proposal) => { - props.router.navigate(`/proposals/${proposal.proposal_id}`); + props.router.navigate(`/proposals/${proposal.id}`); props.handleShow(proposal); }; @@ -82,22 +73,23 @@ const Cards = (props) => { reversedItems.map((proposal, index) => { if (index < (page * rowsPerPage) && index >= (page - 1) * rowsPerPage) { let votedOption = props.voteDetails && props.voteDetails.length && - proposal && proposal.proposal_id && - props.voteDetails.filter((vote) => vote && (vote.proposal_id === proposal.proposal_id))[0]; + proposal && proposal.id && + props.voteDetails.filter((vote) => vote && vote.proposal_id === proposal.id)[0]; if (votedOption && votedOption.options && votedOption.options.length && votedOption.options[0]) { votedOption = votedOption.options[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 && - props.proposalDetails[key][0].body.messages && - props.proposalDetails[key][0].body.messages.length && - props.proposalDetails[key][0].body.messages[0].proposer) { - proposer = props.proposalDetails[key][0].body.messages[0].proposer; + props.proposalDetails[key][0].tx && + props.proposalDetails[key][0].tx.value && + props.proposalDetails[key][0].tx.value.msg[0] && + props.proposalDetails[key][0].tx.value.msg[0].value && + props.proposalDetails[key][0].tx.value.msg[0].value.proposer) { + proposer = props.proposalDetails[key][0].tx.value.msg[0].value.proposer; } } @@ -107,17 +99,19 @@ const Cards = (props) => { Object.keys(props.proposalDetails).find((key) => key === proposal.proposal_id); inProgress = !inProgress && props.proposalDetailsInProgress; + const content = proposal && proposal.messages && proposal.messages[0] && proposal.messages[0].content; + return (
{proposal.summary || (proposal.content && proposal.content.description)}
+{proposal.summary || (content && content.description)}
Proposal Status: { @@ -190,7 +186,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 || diff --git a/src/containers/Proposals/ProposalDialog/index.js b/src/containers/Proposals/ProposalDialog/index.js index 68d27f9..6b769a6 100644 --- a/src/containers/Proposals/ProposalDialog/index.js +++ b/src/containers/Proposals/ProposalDialog/index.js @@ -37,21 +37,23 @@ 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 && vote.proposal_id === this.props.proposal.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); + let votedOption = this.props.voteDetails && this.props.voteDetails.length && this.props.proposal && this.props.proposal.id && + this.props.voteDetails.filter((vote) => vote.proposal_id === this.props.proposal.id)[0]; + if (votedOption && votedOption.options && votedOption.options.length && votedOption.options[0]) { + votedOption = votedOption.options[0]; + } + 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.router && this.props.router.params && this.props.router.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.router.params.proposalID); + const proposal = result.find((val) => val.id === this.props.router.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,7 +75,7 @@ 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 value = this.props.tallyDetails && this.props.tallyDetails[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)); let val1 = null; @@ -87,28 +89,18 @@ class ProposalDialog extends Component { val1 = 'abstain'; } - return (this.props.tallyDetails && this.props.tallyDetails[proposal.proposal_id] && this.props.tallyDetails[proposal.proposal_id][val1] - ? tally(this.props.tallyDetails[proposal.proposal_id][val1], sum) : '0%'); + return (this.props.tallyDetails && this.props.tallyDetails[proposal.id] && this.props.tallyDetails[proposal.id][val1] + ? tally(this.props.tallyDetails[proposal.id][val1], 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)); - let val1 = null; - if (val === 'yes_count') { - val1 = 'yes'; - } else if (val === 'no_count') { - val1 = 'no'; - } else if (val === 'no_with_veto_count') { - val1 = 'no_with_veto'; - } else if (val === 'abstain_count') { - val1 = '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[val1] - ? tally(proposal.final_tally_result[val1], sum) : '0%'); + proposal.final_tally_result[val] + ? tally(proposal.final_tally_result[val], sum) : '0%'); } } @@ -119,8 +111,8 @@ 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 && (vote.proposal_id === this.props.proposal.proposal_id))[0]; + this.props.proposal && this.props.proposal.id && + this.props.voteDetails.filter((vote) => vote && vote.proposal_id === this.props.proposal.id)[0]; if (votedOption && votedOption.options && votedOption.options.length && votedOption.options[0]) { votedOption = votedOption.options[0]; } @@ -128,7 +120,7 @@ class ProposalDialog extends Component { 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 && @@ -143,6 +135,8 @@ class ProposalDialog extends Component { return null; }); + const content = this.props.proposal && this.props.proposal.messages && this.props.proposal.messages[0] && this.props.proposal.messages[0].content; + return (
- {this.props.proposal && this.props.proposal.content && this.props.proposal.content.description} + {this.props.proposal && this.props.proposal.summary}
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}
Voting Period: 8 Days
Unbonding Period: 21 Days