chore(trading): scoped to teams games (#5920)

Co-authored-by: bwallacee <ben@vega.xyz>
This commit is contained in:
Art 2024-03-06 12:44:33 +01:00 committed by GitHub
parent 0d39c2354c
commit 2a0727ec4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 16 deletions

View File

@ -299,10 +299,10 @@ def test_leaderboard(competitions_page: Page, setup_teams_and_games):
def test_game_card(competitions_page: Page): def test_game_card(competitions_page: Page):
expect(competitions_page.get_by_test_id("active-rewards-card")).to_have_count(2) expect(competitions_page.get_by_test_id("active-rewards-card")).to_have_count(1)
game_1 = competitions_page.get_by_test_id("active-rewards-card").first game_1 = competitions_page.get_by_test_id("active-rewards-card").first
expect(game_1).to_be_visible() expect(game_1).to_be_visible()
expect(game_1.get_by_test_id("entity-scope")).to_have_text("Individual") expect(game_1.get_by_test_id("entity-scope")).to_have_text("Team")
expect(game_1.get_by_test_id("locked-for")).to_have_text("1 epoch") expect(game_1.get_by_test_id("locked-for")).to_have_text("1 epoch")
expect(game_1.get_by_test_id("reward-value")).to_have_text("100.00") expect(game_1.get_by_test_id("reward-value")).to_have_text("100.00")
expect(game_1.get_by_test_id("reward-asset")).to_have_text("VEGA") expect(game_1.get_by_test_id("reward-asset")).to_have_text("VEGA")
@ -311,7 +311,7 @@ def test_game_card(competitions_page: Page):
"Price maker fees paid • tDAI" "Price maker fees paid • tDAI"
) )
expect(game_1.get_by_test_id("assessed-over")).to_have_text("15 epochs") expect(game_1.get_by_test_id("assessed-over")).to_have_text("15 epochs")
expect(game_1.get_by_test_id("scope")).to_have_text("In team") expect(game_1.get_by_test_id("scope")).to_have_text("All teams")
expect(game_1.get_by_test_id("staking-requirement")).to_have_text("0.00") expect(game_1.get_by_test_id("staking-requirement")).to_have_text("0.00")
expect(game_1.get_by_test_id("average-position")).to_have_text("0.00") expect(game_1.get_by_test_id("average-position")).to_have_text("0.00")

View File

@ -194,11 +194,11 @@ describe('isScopedToTeams', () => {
undefined, undefined,
makeDispatchStrategy( makeDispatchStrategy(
EntityScope.ENTITY_SCOPE_INDIVIDUALS, EntityScope.ENTITY_SCOPE_INDIVIDUALS,
IndividualScope.INDIVIDUAL_SCOPE_IN_TEAM // individual in teams IndividualScope.INDIVIDUAL_SCOPE_IN_TEAM // individual in teams but not a team game
), ),
'RecurringTransfer' 'RecurringTransfer'
), ),
true, false,
], ],
[ [
makeReward( makeReward(

View File

@ -14,7 +14,6 @@ import {
TransferStatus, TransferStatus,
type DispatchStrategy, type DispatchStrategy,
EntityScope, EntityScope,
IndividualScope,
MarketState, MarketState,
AccountType, AccountType,
} from '@vegaprotocol/types'; } from '@vegaprotocol/types';
@ -75,20 +74,11 @@ export const isActiveReward = (node: RewardTransfer, currentEpoch: number) => {
/** /**
* Checks if given reward (transfer) is scoped to teams. * Checks if given reward (transfer) is scoped to teams.
*
* A reward is scoped to teams if it's entity scope is set to teams or
* if the scope is set to individuals but the individuals are in a team.
*/ */
export const isScopedToTeams = (node: EnrichedRewardTransfer) => export const isScopedToTeams = (node: EnrichedRewardTransfer) =>
// scoped to teams // scoped to teams
node.transfer.kind.dispatchStrategy?.entityScope === node.transfer.kind.dispatchStrategy?.entityScope ===
EntityScope.ENTITY_SCOPE_TEAMS || EntityScope.ENTITY_SCOPE_TEAMS;
// or to individuals
(node.transfer.kind.dispatchStrategy?.entityScope ===
EntityScope.ENTITY_SCOPE_INDIVIDUALS &&
// but they have to be in a team
node.transfer.kind.dispatchStrategy?.individualScope ===
IndividualScope.INDIVIDUAL_SCOPE_IN_TEAM);
/** Retrieves rewards (transfers) */ /** Retrieves rewards (transfers) */
export const useRewards = ({ export const useRewards = ({