|
@@ -20,6 +20,7 @@ import {
|
|
getBlockHash,
|
|
getBlockHash,
|
|
getMint,
|
|
getMint,
|
|
getNextWorker,
|
|
getNextWorker,
|
|
|
|
+ getMember,
|
|
getWorker,
|
|
getWorker,
|
|
getWorkerReward,
|
|
getWorkerReward,
|
|
getStake,
|
|
getStake,
|
|
@@ -45,8 +46,11 @@ export const getWorkerRewards = async (
|
|
for (let id = 0; id < nextWorkerId; ++id) {
|
|
for (let id = 0; id < nextWorkerId; ++id) {
|
|
const worker: WorkerOf = await getWorker(api, group, hash, id);
|
|
const worker: WorkerOf = await getWorker(api, group, hash, id);
|
|
|
|
|
|
- // TODO workers fired before the end will be missed out
|
|
|
|
- if (!worker.is_active) continue;
|
|
|
|
|
|
+ const account = worker.role_account_id;
|
|
|
|
+ const memberId = worker.member_id;
|
|
|
|
+ const member: Membership = await getMember(api, memberId, hash);
|
|
|
|
+ const handle = member ? String(member.handle) : account.toString();
|
|
|
|
+ const status = worker.is_active ? `active` : `inactive`;
|
|
let stake: Stake, reward: RewardRelationship;
|
|
let stake: Stake, reward: RewardRelationship;
|
|
|
|
|
|
if (worker.role_stake_profile.isSome) {
|
|
if (worker.role_stake_profile.isSome) {
|
|
@@ -59,11 +63,29 @@ export const getWorkerRewards = async (
|
|
const rewardId: RewardRelationshipId = worker.reward_relationship.unwrap();
|
|
const rewardId: RewardRelationshipId = worker.reward_relationship.unwrap();
|
|
reward = await getWorkerReward(api, hash, rewardId);
|
|
reward = await getWorkerReward(api, hash, rewardId);
|
|
}
|
|
}
|
|
- workers.push({ id, stake, reward });
|
|
|
|
|
|
+ workers.push({ id, stake, reward, status, handle, account, memberId });
|
|
}
|
|
}
|
|
return workers;
|
|
return workers;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+export const getWorkerRow = (
|
|
|
|
+ worker: WorkerReward,
|
|
|
|
+ earnedStart: number
|
|
|
|
+): string => {
|
|
|
|
+ const mtjoy = (mtjoy: number): string => (mtjoy / 1000000).toFixed(1);
|
|
|
|
+
|
|
|
|
+ const { id, memberId, account, handle, status, reward } = worker;
|
|
|
|
+ const earnedEnd = reward.total_reward_received.toNumber();
|
|
|
|
+ if (!earnedEnd) return ``;
|
|
|
|
+ const totalEarned = mtjoy(earnedEnd);
|
|
|
|
+ const earnedTerm = mtjoy(earnedEnd - earnedStart);
|
|
|
|
+ const amount = reward.amount_per_payout.toNumber();
|
|
|
|
+ const rewardPerBlock = (amount / Number(reward.payout_interval)).toFixed();
|
|
|
|
+ const url = `https://pioneer.joystreamstats.live/#/members/${handle}`; // TODO
|
|
|
|
+ // TODO compare earning to term start and show difference
|
|
|
|
+ return `| ${id} | [@${handle}](${url}) | ${status} | ${rewardPerBlock} | ${earnedTerm} | ${totalEarned} |\n`;
|
|
|
|
+};
|
|
|
|
+
|
|
export const getBurnedTokens = (
|
|
export const getBurnedTokens = (
|
|
burnAddress: string,
|
|
burnAddress: string,
|
|
blocks: [number, CacheEvent[]][]
|
|
blocks: [number, CacheEvent[]][]
|