fix: staking rewards filter
This commit is contained in:
parent
966390f19a
commit
831651e7f3
@ -27,6 +27,7 @@ import {
|
||||
AccountType,
|
||||
DistributionStrategy,
|
||||
IndividualScope,
|
||||
type Asset,
|
||||
} from '@vegaprotocol/types';
|
||||
import { Card } from '../card/card';
|
||||
import { type ReactNode, useState } from 'react';
|
||||
@ -182,6 +183,29 @@ export const ActiveRewardCard = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
!transferNode.transfer.kind.dispatchStrategy &&
|
||||
transferNode.transfer.toAccountType ===
|
||||
AccountType.ACCOUNT_TYPE_GLOBAL_REWARD
|
||||
) {
|
||||
return (
|
||||
<StakingRewardCard
|
||||
colour={CardColour.WHITE}
|
||||
rewardAmount={addDecimalsFormatNumber(
|
||||
transferNode.transfer.amount,
|
||||
transferNode.transfer.asset?.decimals || 0,
|
||||
6
|
||||
)}
|
||||
rewardAsset={transferNode.transfer.asset || undefined}
|
||||
endsIn={
|
||||
transferNode.transfer.kind.endEpoch != null
|
||||
? transferNode.transfer.kind.endEpoch - currentEpoch
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
let colour =
|
||||
DispatchMetricColourMap[
|
||||
transferNode.transfer.kind.dispatchStrategy.dispatchMetric
|
||||
@ -201,28 +225,6 @@ export const ActiveRewardCard = ({
|
||||
colour = CardColour.GREY;
|
||||
}
|
||||
|
||||
if (
|
||||
transferNode.transfer.toAccountType ===
|
||||
AccountType.ACCOUNT_TYPE_GLOBAL_REWARD
|
||||
) {
|
||||
return (
|
||||
<StakingRewardCard
|
||||
colour={CardColour.WHITE}
|
||||
rewardAmount={addDecimalsFormatNumber(
|
||||
transferNode.transfer.amount,
|
||||
transferNode.transfer.asset?.decimals || 0,
|
||||
6
|
||||
)}
|
||||
rewardAsset={transferNode.asset}
|
||||
endsIn={
|
||||
transferNode.transfer.kind.endEpoch != null
|
||||
? transferNode.transfer.kind.endEpoch - currentEpoch
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<RewardCard
|
||||
colour={colour}
|
||||
@ -405,7 +407,7 @@ const StakingRewardCard = ({
|
||||
colour: CardColour;
|
||||
rewardAmount: string;
|
||||
/** The asset linked to the dispatch strategy via `dispatchMetricAssetId` property. */
|
||||
rewardAsset?: BasicAssetDetails;
|
||||
rewardAsset?: Asset;
|
||||
/** The number of epochs until the transfer stops. */
|
||||
endsIn?: number;
|
||||
/** The VEGA asset details, required to format the min staking amount. */
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
EntityScope,
|
||||
IndividualScope,
|
||||
MarketState,
|
||||
AccountType,
|
||||
} from '@vegaprotocol/types';
|
||||
import { type ApolloError } from '@apollo/client';
|
||||
import compact from 'lodash/compact';
|
||||
@ -46,8 +47,9 @@ export type EnrichedRewardTransfer = RewardTransfer & {
|
||||
*/
|
||||
export const isReward = (node: TransferNode): node is RewardTransfer => {
|
||||
if (
|
||||
node.transfer.kind.__typename === 'RecurringTransfer' &&
|
||||
node.transfer.kind.dispatchStrategy != null
|
||||
(node.transfer.kind.__typename === 'RecurringTransfer' &&
|
||||
node.transfer.kind.dispatchStrategy != null) ||
|
||||
node.transfer.toAccountType === AccountType.ACCOUNT_TYPE_GLOBAL_REWARD
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@ -142,6 +144,7 @@ export const useRewards = ({
|
||||
.filter((node) => (scopeToTeams ? isScopedToTeams(node) : true))
|
||||
// enrich with dispatch asset and markets in scope details
|
||||
.map((node) => {
|
||||
if (!node.transfer.kind.dispatchStrategy) return node;
|
||||
const asset =
|
||||
assets &&
|
||||
assets[node.transfer.kind.dispatchStrategy.dispatchMetricAssetId];
|
||||
@ -169,7 +172,7 @@ export const useRewards = ({
|
||||
...node,
|
||||
asset: asset ? asset : undefined,
|
||||
isAssetTraded: isAssetTraded != null ? isAssetTraded : undefined,
|
||||
markets: marketsInScope.length > 0 ? marketsInScope : undefined,
|
||||
markets: marketsInScope?.length > 0 ? marketsInScope : undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user