Unverified Commit c2139c81 authored by Jonathan Porta's avatar Jonathan Porta Committed by GitHub
Browse files

Merge pull request #89 from steemit/sps-implementation-show-sp

A simple implementation for showing sp amount instead of votes/vests
parents 59e0ac3a fdaf16bb
......@@ -202,7 +202,7 @@ class App extends React.Component {
);
}
const themeClass = nightmodeEnabled ? ' theme-light' : ' theme-dark';
const themeClass = nightmodeEnabled ? ' theme-dark' : ' theme-light';
return (
<div
......
......@@ -20,8 +20,9 @@ Proposal.propTypes = {
onVote: PropTypes.func.isRequired,
isVoting: PropTypes.bool.isRequired,
isUpVoted: PropTypes.bool.isRequired,
total_vesting_shares: PropTypes.number.isRequired,
total_vesting_fund_steem: PropTypes.number.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) {
......@@ -81,8 +82,12 @@ export default function Proposal(props) {
/>
</span>
</a>
<span>{abbreviateNumber(total_votes_in_sp)}</span>
<span>{abbreviateNumber(
simpleVotesToSp(
total_votes,
props.total_vesting_shares,
props.total_vesting_fund_steem))}
</span>
</div>
<div className="proposals__description">
<span>
......@@ -275,3 +280,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;
}
......@@ -85,4 +88,9 @@ ProposalContainer.propTypes = {
total_vesting_fund_steem: PropTypes.number.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);
......@@ -59,7 +59,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