|
@@ -27,6 +27,7 @@ interface IProps {
|
|
starred: string | undefined;
|
|
starred: string | undefined;
|
|
stakes?: { [key: string]: Stakes };
|
|
stakes?: { [key: string]: Stakes };
|
|
rewardPoints?: RewardPoints;
|
|
rewardPoints?: RewardPoints;
|
|
|
|
+ reward?: number;
|
|
}
|
|
}
|
|
|
|
|
|
interface IState {
|
|
interface IState {
|
|
@@ -63,6 +64,7 @@ class Validator extends Component<IProps, IState> {
|
|
starred,
|
|
starred,
|
|
stakes,
|
|
stakes,
|
|
rewardPoints,
|
|
rewardPoints,
|
|
|
|
+ reward = 0,
|
|
} = this.props;
|
|
} = this.props;
|
|
const { expandNominators, hidden } = this.state;
|
|
const { expandNominators, hidden } = this.state;
|
|
if (hidden) return <div />;
|
|
if (hidden) return <div />;
|
|
@@ -70,9 +72,23 @@ class Validator extends Component<IProps, IState> {
|
|
const handle = handles[validator] || validator;
|
|
const handle = handles[validator] || validator;
|
|
const points = rewardPoints ? rewardPoints.individual[validator] : "";
|
|
const points = rewardPoints ? rewardPoints.individual[validator] : "";
|
|
const myStakes = stakes ? stakes[validator] : undefined;
|
|
const myStakes = stakes ? stakes[validator] : undefined;
|
|
- const totalStake = myStakes ? myStakes.total : "";
|
|
|
|
- const ownStake = myStakes ? myStakes.own : "";
|
|
|
|
- const commission = myStakes ? `${myStakes.commission}%` : "";
|
|
|
|
|
|
+ let totalStake = 0;
|
|
|
|
+ let ownStake = 0;
|
|
|
|
+ let commission = "";
|
|
|
|
+ let ownReward = 0;
|
|
|
|
+ let othersReward = 0;
|
|
|
|
+
|
|
|
|
+ if (myStakes) {
|
|
|
|
+ totalStake = myStakes.total;
|
|
|
|
+ ownStake = myStakes.own;
|
|
|
|
+ commission = `${myStakes.commission}%`;
|
|
|
|
+
|
|
|
|
+ const own = ownStake / totalStake;
|
|
|
|
+ const others = 1 - own;
|
|
|
|
+ const commissionShare = myStakes.commission / 100;
|
|
|
|
+ othersReward = reward * others * (1 - commissionShare);
|
|
|
|
+ ownReward = reward * (own + others * commissionShare);
|
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className="mx-3 d-flex flex-row">
|
|
<div className="mx-3 d-flex flex-row">
|
|
@@ -111,13 +127,19 @@ class Validator extends Component<IProps, IState> {
|
|
{commission}
|
|
{commission}
|
|
</div>
|
|
</div>
|
|
<div className="col-1 text-right" onClick={() => sortBy("totalStake")}>
|
|
<div className="col-1 text-right" onClick={() => sortBy("totalStake")}>
|
|
- {totalStake}
|
|
|
|
|
|
+ {totalStake > 0 && totalStake}
|
|
</div>
|
|
</div>
|
|
<div className="col-1 text-right" onClick={() => sortBy("ownStake")}>
|
|
<div className="col-1 text-right" onClick={() => sortBy("ownStake")}>
|
|
- {ownStake}
|
|
|
|
|
|
+ {ownStake > 0 && ownStake}
|
|
</div>
|
|
</div>
|
|
|
|
+ {ownReward ? (
|
|
|
|
+ <div className="text-warning">+{Math.round(ownReward)}</div>
|
|
|
|
+ ) : (
|
|
|
|
+ <div />
|
|
|
|
+ )}
|
|
<div className="col-3 mb-1 text-left">
|
|
<div className="col-3 mb-1 text-left">
|
|
<Nominators
|
|
<Nominators
|
|
|
|
+ reward={othersReward}
|
|
toggleExpand={this.toggleExpandNominators}
|
|
toggleExpand={this.toggleExpandNominators}
|
|
sortBy={sortBy}
|
|
sortBy={sortBy}
|
|
expand={expandNominators}
|
|
expand={expandNominators}
|