Skip to content

Commit

Permalink
Add STEEM to author rewards output, resolves steemit#326 (steemit#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
roadscape authored and Valentine Zavgorodnev committed Sep 23, 2016
1 parent fcc16b5 commit d151977
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
4 changes: 3 additions & 1 deletion app/components/cards/TransferHistoryRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ class TransferHistoryRow extends React.Component {
other_account = data.comment_author;
description_end = `/${data.comment_permlink}`;
} else if (type === 'author_reward') {
description_start += `Author reward of ${renameToSd(data.sbd_payout)} and ${author_reward} STEEM POWER for ${data.author}/${data.permlink}`;
let steem_payout = ""
if(data.steem_payout !== '0.000 STEEM') steem_payout = ", " + data.steem_payout;
description_start += `Author reward of ${renameToSd(data.sbd_payout)}${steem_payout} and ${author_reward} STEEM POWER for ${data.author}/${data.permlink}`;
// other_account = ``;
description_end = '';
} else if (type === 'interest') {
Expand Down
35 changes: 24 additions & 11 deletions app/components/modules/AuthorRewards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AuthorRewards extends React.Component {

/// transfer log
let rewards24Vests = 0, rewardsWeekVests = 0, totalRewardsVests = 0;
let rewards24Steem = 0, rewardsWeekSteem = 0, totalRewardsSteem = 0;
let rewards24SBD = 0, rewardsWeekSBD = 0, totalRewardsSBD = 0;
const today = new Date();
const oneDay = 86400 * 1000;
Expand All @@ -49,20 +50,25 @@ class AuthorRewards extends React.Component {
finalDate = new Date(item[1].timestamp).getTime();
}
firstDate = new Date(item[1].timestamp).getTime();
const vest = assetFloat(item[1].op[1].vesting_payout, 'VESTS');
const sbd = assetFloat(item[1].op[1].sbd_payout, 'SBD');

if (new Date(item[1].timestamp).getTime() > yesterday) {
rewards24Vests += vest;
rewardsWeekVests += vest;
rewards24SBD += sbd;
rewardsWeekSBD += sbd;
} else if (new Date(item[1].timestamp).getTime() > lastWeek) {
const vest = assetFloat(item[1].op[1].vesting_payout, 'VESTS');
const steem = assetFloat(item[1].op[1].steem_payout, 'STEEM');
const sbd = assetFloat(item[1].op[1].sbd_payout, 'SBD');

if (new Date(item[1].timestamp).getTime() > lastWeek) {
if (new Date(item[1].timestamp).getTime() > yesterday) {
rewards24Vests += vest;
rewards24Steem += steem;
rewards24SBD += sbd;
}
rewardsWeekVests += vest;
rewardsWeekSBD += sbd;
rewardsWeekSteem += steem;
rewardsWeekSBD += sbd;
}
totalRewardsVests += vest;
totalRewardsSBD += sbd;
totalRewardsSteem += steem;
totalRewardsSBD += sbd;

return <TransferHistoryRow key={index} op={item} context={account.name} />
}
return null;
Expand All @@ -72,7 +78,8 @@ class AuthorRewards extends React.Component {
const curationLength = author_log.length;
const daysOfCuration = (firstDate - finalDate) / oneDay || 1;
const averageCurationVests = !daysOfCuration ? 0 : totalRewardsVests / daysOfCuration;
const averageCurationSBD = !daysOfCuration ? 0 : totalRewardsSBD / daysOfCuration;
const averageCurationSteem = !daysOfCuration ? 0 : totalRewardsSteem / daysOfCuration;
const averageCurationSBD = !daysOfCuration ? 0 : totalRewardsSBD / daysOfCuration;
const hasFullWeek = daysOfCuration >= 7;
const limitedIndex = Math.min(historyIndex, curationLength - 10);
author_log = author_log.reverse().filter(() => {
Expand Down Expand Up @@ -109,6 +116,8 @@ class AuthorRewards extends React.Component {
<div className="column small-12 medium-3">
{numberWithCommas(vestsToSp(this.props.state, rewards24Vests + " VESTS")) + " STEEM POWER"}
<br />
{rewards24Steem.toFixed(3) + " STEEM"}
<br />
{rewards24SBD.toFixed(3) + " SD"}
</div>
</div>
Expand All @@ -120,6 +129,8 @@ class AuthorRewards extends React.Component {
<div className="column small-12 medium-3">
{numberWithCommas(vestsToSp(this.props.state, averageCurationVests + " VESTS")) + " STEEM POWER"}
<br />
{averageCurationSteem.toFixed(3) + " STEEM"}
<br />
{averageCurationSBD.toFixed(3) + " SD"}
</div>
</div>
Expand All @@ -130,6 +141,8 @@ class AuthorRewards extends React.Component {
<div className="column small-12 medium-3">
{numberWithCommas(vestsToSp(this.props.state, (hasFullWeek ? rewardsWeekVests : averageCurationVests * 7) + " VESTS")) + " STEEM POWER"}
<br />
{(hasFullWeek ? rewardsWeekSteem : averageCurationSteem * 7).toFixed(3) + " STEEM"}
<br />
{(hasFullWeek ? rewardsWeekSBD : averageCurationSBD * 7).toFixed(3) + " SD"}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/modules/CurationRewards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class CurationRewards extends React.Component {
{!hasFullWeek ? "Estimated curation rewards last week" : "Curation rewards last week"}
</div>
<div className="column small-12 medium-3">
{numberWithCommas(vestsToSp(this.props.state, (hasFullWeek ? rewardsWeek : averageCuration * 7) + " VESTS")) + " STEEM POWER"}:
{numberWithCommas(vestsToSp(this.props.state, (hasFullWeek ? rewardsWeek : averageCuration * 7) + " VESTS")) + " STEEM POWER"}
</div>
</div>
<div className="row">
Expand Down

0 comments on commit d151977

Please sign in to comment.