fix: make sure asset is not added to list if it doesn't container correct reward types

This commit is contained in:
Matthew Russell 2024-02-12 13:42:49 -08:00
parent b2860121e5
commit fc2773d748
No known key found for this signature in database
2 changed files with 19 additions and 5 deletions

View File

@ -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: {

View File

@ -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 || '',