Skip to content

Commit

Permalink
Fix Mana
Browse files Browse the repository at this point in the history
  • Loading branch information
stoodkev committed Sep 26, 2018
1 parent c0ed3c2 commit e7ea55a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "SteemPlus",
"description": "Lightweight toolbox for Steemit",
"version": "3.0.1.0",
"version": "3.0.1.1",
"content_security_policy": "script-src 'self' 'unsafe-eval' https://widget.blocktrades.us/ ; object-src 'self'; child-src 'unsafe-eval' 'self' https://widget.blocktrades.us/",
"browser_action": {
"default_icon": "src/img/logo.png",
Expand Down
2 changes: 1 addition & 1 deletion src/js/user_info_popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function displayPopoverUserInfo(userName){
steem.api.getAccounts([userName], function(err, result){
if(!$('.UserProfile__banner').hasClass('smi-profile-banner-1'))
$('.UserProfile__banner').addClass('smi-profile-banner-1');
Promise.all([window.SteemPlus.Utils.getVotingPowerPerAccount(result[0]), window.SteemPlus.Utils.getVotingDollarsPerAccount(100, result[0], rewardBalanceUIP, recentClaimsUIP, steemPriceUIP, votePowerReserveRateUIP), window.SteemPlus.Utils.getRC(account.name)])
Promise.all([window.SteemPlus.Utils.getVotingPowerPerAccount(result[0]), window.SteemPlus.Utils.getVotingDollarsPerAccount(100, result[0], rewardBalanceUIP, recentClaimsUIP, steemPriceUIP, votePowerReserveRateUIP), window.SteemPlus.Utils.getRC(userName)])
.then(function(values) {
$("#popover").remove();
var pop=document.createElement('a');
Expand Down
7 changes: 6 additions & 1 deletion vendor/smi/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,17 @@

var getMana = function(account) {
const STEEM_VOTING_MANA_REGENERATION_SECONDS =432000;
const estimated_max = parseFloat(account.vesting_shares.replace(" VESTS", ""))*1000000;
const estimated_max = getEffectiveVestingSharesPerAccount(account)*1000000;
console.log(estimated_max);
const current_mana = parseFloat(account.voting_manabar.current_mana);
const last_update_time = account.voting_manabar.last_update_time;
const diff_in_seconds = Math.round(Date.now()/1000-last_update_time);
let estimated_mana = (current_mana + diff_in_seconds * estimated_max / STEEM_VOTING_MANA_REGENERATION_SECONDS);
if (estimated_mana > estimated_max)
estimated_mana = estimated_max;
const estimated_pct = estimated_mana / estimated_max * 100;
console.log({"current_mana": current_mana, "last_update_time": last_update_time,
"estimated_mana": estimated_mana, "estimated_max": estimated_max, "estimated_pct": estimated_pct});
return {"current_mana": current_mana, "last_update_time": last_update_time,
"estimated_mana": estimated_mana, "estimated_max": estimated_max, "estimated_pct": estimated_pct};
}
Expand Down Expand Up @@ -247,6 +250,7 @@
}

var getRC=function(name,cb){
console.log(name);
let data={"jsonrpc":"2.0","id":1,"method":"rc_api.find_rc_accounts","params":{"accounts":[name]}};

return new Promise(function(fulfill,reject){
Expand All @@ -267,6 +271,7 @@
const estimated_pct = estimated_mana / estimated_max * 100;
const res= {"current_mana": current_mana, "last_update_time": last_update_time,
"estimated_mana": estimated_mana, "estimated_max": estimated_max, "estimated_pct": estimated_pct.toFixed(2),"fullin":getTimeBeforeFull(estimated_pct*100)};
console.log(res);
fulfill(res);
},
error:function(e){
Expand Down

0 comments on commit e7ea55a

Please sign in to comment.