Commit c137dda4 authored by justinw's avatar justinw
Browse files

a simple implementation for showing sp amount instead of votes/vests

parent fd470686
......@@ -202,7 +202,7 @@ class App extends React.Component {
);
}
const themeClass = nightmodeEnabled ? ' theme-dark' : ' theme-dark';
const themeClass = nightmodeEnabled ? ' theme-dark' : ' theme-light';
return (
<div
......
......@@ -20,6 +20,9 @@ Proposal.propTypes = {
onVote: PropTypes.func.isRequired,
isVoting: PropTypes.bool.isRequired,
isUpVoted: PropTypes.bool.isRequired,
// passed through connect from global state object to calc vests to sp
total_vesting_shares: PropTypes.string.isRequired,
total_vesting_fund_steem: PropTypes.string.isRequired,
};
export default function Proposal(props) {
......@@ -70,7 +73,12 @@ export default function Proposal(props) {
</span>
</a>
<span>{abbreviateNumber(total_votes)}</span>
<span>{abbreviateNumber(
simpleVotesToSp(
total_votes,
props.total_vesting_shares,
props.total_vesting_fund_steem))}
</span>
</div>
<div className="proposals__description">
<span>
......@@ -263,3 +271,16 @@ function linkifyUsername(linkText, username = '') {
function urlifyPermlink(username, permlink) {
return `https://steemit.com/@${username}/${permlink}`;
}
/**
* Given total votes in vests returns value in SP
* @param {number} total_votes - total votes on a proposal (vests from API)
* @param {string} total_vesting_shares - vesting shares with vests symbol on end
* @param {string} total_vesting_fund_steem - total steem vesting fund with liquid symbol on end
* @returns {number} - return the number converted to SP
*/
function simpleVotesToSp(total_votes, total_vesting_shares, total_vesting_fund_steem) {
const total_vests = parseFloat(total_vesting_shares);
const total_vest_steem = parseFloat(total_vesting_fund_steem);
return ((total_vest_steem * (total_votes / total_vests)) * 0.000001).toFixed(2);
}
\ No newline at end of file
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Proposal from './Proposal';
class ProposalContainer extends React.Component {
......@@ -12,6 +12,9 @@ class ProposalContainer extends React.Component {
voteFailed: false,
voteSucceeded: false,
isUpVoted: props.proposal.upVoted,
// needed from global state object to calculate vests to sp
total_vesting_shares: props.total_vesting_shares,
total_vesting_fund_steem: props.total_vesting_fund_steem,
};
this.id = this.props.proposal.id;
}
......@@ -71,4 +74,9 @@ ProposalContainer.propTypes = {
voteOnProposal: PropTypes.func.isRequired,
};
export default ProposalContainer;
export default connect((state, ownProps) => {
// pulling these out of state object to calculate vests to sp
const total_vesting_shares = state.global.getIn(['props', 'total_vesting_shares']);
const total_vesting_fund_steem = state.global.getIn(['props', 'total_vesting_fund_steem']);
return { total_vesting_shares, total_vesting_fund_steem, ...ownProps };
})(ProposalContainer);
......@@ -51,7 +51,7 @@ export default function ProposalList(props) {
return (
<div className="ProposalsList">
<div className="proposals__header">
<div className="proposals__votes">Votes</div>
<div className="proposals__votes">Vote SP</div>
<div className="proposals__description">Proposal</div>
<div className="proposals__amount">Amount</div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment