Skip to content

Commit b0e0de6

Browse files
committed
Fix import error
1 parent aa517e9 commit b0e0de6

File tree

8 files changed

+79
-81
lines changed

8 files changed

+79
-81
lines changed

app/scripts/controllers/rewards/rewards-controller.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import type {
4242
SubscriptionDto,
4343
EstimatePointsDto,
4444
EstimatedPointsDto,
45-
SeasonDtoState,
4645
DiscoverSeasonsDto,
4746
SeasonMetadataDto,
4847
SeasonStateDto,
@@ -64,6 +63,7 @@ import {
6463
RewardsDataServiceMobileOptinAction,
6564
RewardsDataServiceValidateReferralCodeAction,
6665
} from './rewards-data-service-types';
66+
import { SeasonDtoState } from '../../../../shared/types/rewards';
6767

6868
type AllActions = MessengerActions<RewardsControllerMessenger>;
6969

app/scripts/controllers/rewards/rewards-controller.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ import {
1818
type LoginResponseDto,
1919
type EstimatePointsDto,
2020
type EstimatedPointsDto,
21-
type SeasonDtoState,
22-
type SeasonStatusState,
23-
type SeasonTierState,
2421
type SeasonTierDto,
2522
type SeasonStatusDto,
2623
type SubscriptionDto,
@@ -38,6 +35,11 @@ import {
3835
} from './rewards-data-service';
3936
import { signSolanaRewardsMessage } from './utils/solana-snap';
4037
import { sortAccounts } from './utils/sortAccounts';
38+
import {
39+
SeasonDtoState,
40+
SeasonStatusState,
41+
SeasonTierState,
42+
} from '../../../../shared/types/rewards';
4143

4244
export const DEFAULT_BLOCKED_REGIONS = ['UK'];
4345

app/scripts/controllers/rewards/rewards-controller.types.ts

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { CaipAccountId, CaipAssetType } from '@metamask/utils';
22
import { InternalAccount } from '@metamask/keyring-internal-api';
3+
import {
4+
SeasonDtoState,
5+
SeasonRewardType,
6+
SeasonStatusState,
7+
} from '../../../../shared/types/rewards';
38

49
export type LoginResponseDto = {
510
sessionId: string;
@@ -410,13 +415,6 @@ export type SeasonRewardDto = {
410415
rewardType: SeasonRewardType;
411416
};
412417

413-
export enum SeasonRewardType {
414-
Generic = 'Generic',
415-
PerpsDiscount = 'PerpsDiscount',
416-
PointsBoost = 'PointsBoost',
417-
AlphaFoxInvite = 'AlphaFoxInvite',
418-
}
419-
420418
export type SeasonDto = {
421419
id: string;
422420
name: string;
@@ -607,68 +605,6 @@ export type ThemeImage = {
607605
darkModeUrl: string;
608606
};
609607

610-
export type ClaimRewardDto = {
611-
data?: Record<string, string>;
612-
};
613-
614-
// Serializable versions for state storage (Date objects converted to timestamps)
615-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
616-
export type SeasonRewardDtoState = {
617-
id: string;
618-
name: string;
619-
shortDescription: string;
620-
longDescription: string;
621-
shortUnlockedDescription: string;
622-
longUnlockedDescription: string;
623-
claimUrl?: string;
624-
iconName: string;
625-
rewardType: SeasonRewardType;
626-
};
627-
628-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
629-
export type SeasonTierDtoState = {
630-
id: string;
631-
name: string;
632-
pointsNeeded: number;
633-
image: {
634-
lightModeUrl: string;
635-
darkModeUrl: string;
636-
};
637-
levelNumber: string;
638-
rewards: SeasonRewardDtoState[];
639-
};
640-
641-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
642-
export type SeasonDtoState = {
643-
id: string;
644-
name: string;
645-
startDate: number; // timestamp
646-
endDate: number; // timestamp
647-
tiers: SeasonTierDtoState[];
648-
lastFetched?: number;
649-
};
650-
651-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
652-
export type SeasonStatusBalanceDtoState = {
653-
total: number;
654-
updatedAt?: number; // timestamp
655-
};
656-
657-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
658-
export type SeasonTierState = {
659-
currentTier: SeasonTierDtoState;
660-
nextTier: SeasonTierDtoState | null;
661-
nextTierPointsNeeded: number | null;
662-
};
663-
664-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
665-
export type SeasonStatusState = {
666-
season: SeasonDtoState;
667-
balance: SeasonStatusBalanceDtoState;
668-
tier: SeasonTierState;
669-
lastFetched?: number;
670-
};
671-
672608
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
673609
export type RewardsAccountState = {
674610
account: CaipAccountId;

shared/types/rewards.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Shared types for rewards functionality
3+
* These types are used across UI and background to avoid import restrictions
4+
*/
5+
6+
export enum SeasonRewardType {
7+
Generic = 'Generic',
8+
PerpsDiscount = 'PerpsDiscount',
9+
PointsBoost = 'PointsBoost',
10+
AlphaFoxInvite = 'AlphaFoxInvite',
11+
}
12+
13+
export type SeasonRewardDtoState = {
14+
id: string;
15+
name: string;
16+
shortDescription: string;
17+
longDescription: string;
18+
shortUnlockedDescription: string;
19+
longUnlockedDescription: string;
20+
claimUrl?: string;
21+
iconName: string;
22+
rewardType: SeasonRewardType;
23+
};
24+
25+
export type SeasonTierDtoState = {
26+
id: string;
27+
name: string;
28+
pointsNeeded: number;
29+
image: {
30+
lightModeUrl: string;
31+
darkModeUrl: string;
32+
};
33+
levelNumber: string;
34+
rewards: SeasonRewardDtoState[];
35+
};
36+
37+
export type SeasonDtoState = {
38+
id: string;
39+
name: string;
40+
startDate: number; // timestamp
41+
endDate: number; // timestamp
42+
tiers: SeasonTierDtoState[];
43+
lastFetched?: number;
44+
};
45+
46+
export type SeasonStatusBalanceDtoState = {
47+
total: number;
48+
updatedAt?: number; // timestamp
49+
};
50+
51+
export type SeasonTierState = {
52+
currentTier: SeasonTierDtoState;
53+
nextTier: SeasonTierDtoState | null;
54+
nextTierPointsNeeded: number | null;
55+
};
56+
57+
export type SeasonStatusState = {
58+
season: SeasonDtoState;
59+
balance: SeasonStatusBalanceDtoState;
60+
tier: SeasonTierState;
61+
lastFetched?: number;
62+
};

ui/components/app/rewards/RewardsPointsBalance.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useSelector } from 'react-redux';
55
import { useI18nContext } from '../../../hooks/useI18nContext';
66
import { useRewardsContext } from '../../../contexts/rewards';
77
import type { RewardsContextValue } from '../../../contexts/rewards';
8+
import type { SeasonStatusState } from '../../../../shared/types/rewards';
89
import { RewardsPointsBalance } from './RewardsPointsBalance';
910

1011
// Mock dependencies

ui/contexts/rewards/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React, { useContext } from 'react';
2-
import type { SeasonStatusState } from '../../../app/scripts/controllers/rewards/rewards-controller.types';
2+
import type { SeasonStatusState } from '../../../shared/types/rewards';
33
import { useCandidateSubscriptionId } from '../../hooks/rewards/useCandidateSubscriptionId';
44
import { useSeasonStatus } from '../../hooks/rewards/useSeasonStatus';
55
import { useRewardsEnabled } from '../../hooks/rewards/useRewardsEnabled';
66

7-
export interface RewardsContextValue {
7+
export type RewardsContextValue = {
88
rewardsEnabled: boolean;
99
candidateSubscriptionId: string | null;
1010
candidateSubscriptionIdError: boolean;
1111
seasonStatus: SeasonStatusState | null;
1212
seasonStatusError: string | null;
1313
seasonStatusLoading: boolean;
1414
refetchSeasonStatus: () => Promise<void>;
15-
}
15+
};
1616

1717
export const RewardsContext = React.createContext<RewardsContextValue>({
1818
rewardsEnabled: false,

ui/hooks/rewards/useSeasonStatus.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { renderHookWithProvider } from '../../../test/lib/render-helpers';
66
import mockState from '../../../test/data/mock-state.json';
77
import { useSeasonStatus } from './useSeasonStatus';
88
import { useRewardsEnabled } from './useRewardsEnabled';
9-
import type { SeasonStatusState } from '../../../app/scripts/controllers/rewards/rewards-controller.types';
9+
import { SeasonStatusState } from '../../../shared/types/rewards';
1010

1111
// Mock dependencies
1212
jest.mock('../../store/background-connection', () => ({

ui/hooks/rewards/useSeasonStatus.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ import { useState, useCallback, useEffect, useRef } from 'react';
22
import { useSelector } from 'react-redux';
33
import log from 'loglevel';
44
import { submitRequestToBackground } from '../../store/background-connection';
5-
import type {
6-
SeasonStatusState,
7-
SeasonDtoState,
8-
} from '../../../app/scripts/controllers/rewards/rewards-controller.types';
95
import { getIsUnlocked } from '../../ducks/metamask/metamask';
106
import { useRewardsEnabled } from './useRewardsEnabled';
7+
import { SeasonDtoState, SeasonStatusState } from '../../../shared/types/rewards';
118

129
interface UseSeasonStatusOptions {
1310
subscriptionId: string | null;

0 commit comments

Comments
 (0)