Ver código fonte

optionally getStake at hash

Joystream Stats 3 anos atrás
pai
commit
288efa96dd
2 arquivos alterados com 7 adições e 3 exclusões
  1. 6 2
      api.ts
  2. 1 1
      rewards.ts

+ 6 - 2
api.ts

@@ -258,8 +258,12 @@ export const getWorkers = async (
 
 export const getStake = async (
   api: ApiPromise,
-  id: StakeId | number
-): Promise<Stake> => (await api.query.stake.stakes(id)) as Stake;
+  id: StakeId | number,
+  hash?: Hash
+): Promise<Stake> =>
+  (await (hash
+    ? api.query.stake.stakes.at(hash, id)
+    : api.query.stake.stakes(id))) as Stake;
 
 export const getWorkerReward = (
   api: ApiPromise,

+ 1 - 1
rewards.ts

@@ -71,7 +71,7 @@ export const getWorkerRewards = async (
 
     if (worker.role_stake_profile.isSome) {
       const roleStakeProfile = worker.role_stake_profile.unwrap();
-      stake = await getStake(api, roleStakeProfile.stake_id);
+      stake = await getStake(api, roleStakeProfile.stake_id, hash);
     }
 
     if (worker.reward_relationship.isSome) {