From b2860121e53885f97599606eec6dd02d57fcd283 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 12 Feb 2024 13:32:45 -0800 Subject: [PATCH 1/2] fix: dont show unrelated rewards in gov rewards table --- .../generate-epoch-total-rewards-list.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts b/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts index 4c20dab59..440ee97ff 100644 --- a/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts +++ b/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts @@ -83,10 +83,12 @@ export const generateEpochTotalRewardsList = ({ (Number(rewardItem?.amount) || 0) + Number(reward.amount) ).toString(); - rewards?.set(reward.rewardType, { - rewardType: reward.rewardType, - amount, - }); + if (Object.keys(RowAccountTypes).includes(reward.rewardType)) { + rewards?.set(reward.rewardType, { + rewardType: reward.rewardType, + amount, + }); + } epoch.assetRewards.set(reward.assetId, { assetId: reward.assetId, From fc2773d7480831025b524b67a2bca58e5058ff06 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 12 Feb 2024 13:42:49 -0800 Subject: [PATCH 2/2] fix: make sure asset is not added to list if it doesn't container correct reward types --- .../generate-epoch-total-rewards-list.spec.ts | 10 ++++++++++ .../generate-epoch-total-rewards-list.ts | 14 +++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.spec.ts b/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.spec.ts index aeae34acb..b58c1262d 100644 --- a/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.spec.ts +++ b/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.spec.ts @@ -241,6 +241,16 @@ describe('generateEpochAssetRewardsList', () => { amount: '5', }, }, + { + // This should not be included in the result + node: { + epoch: 2, + assetId: '3', + decimals: 18, + rewardType: AccountType.ACCOUNT_TYPE_REWARD_RETURN_VOLATILITY, + amount: '5', + }, + }, ], }, epoch: { diff --git a/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts b/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts index 440ee97ff..10aa9e1cc 100644 --- a/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts +++ b/apps/governance/src/routes/rewards/epoch-total-rewards/generate-epoch-total-rewards-list.ts @@ -83,13 +83,17 @@ export const generateEpochTotalRewardsList = ({ (Number(rewardItem?.amount) || 0) + Number(reward.amount) ).toString(); - if (Object.keys(RowAccountTypes).includes(reward.rewardType)) { - rewards?.set(reward.rewardType, { - rewardType: reward.rewardType, - amount, - }); + // only RowAccountTypes are relevant for this table, others should + // be discarded + if (!Object.keys(RowAccountTypes).includes(reward.rewardType)) { + return acc; } + rewards?.set(reward.rewardType, { + rewardType: reward.rewardType, + amount, + }); + epoch.assetRewards.set(reward.assetId, { assetId: reward.assetId, name: matchingAsset?.name || '',