@arthur2079/internal-profile 4.1.2-next.5 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/api/errors.d.ts +3 -0
  2. package/dist/api/errors.js +9 -0
  3. package/dist/api/mod.d.ts +4 -0
  4. package/dist/api/mod.js +2 -0
  5. package/dist/api/request.d.ts +19 -0
  6. package/dist/api/request.js +96 -0
  7. package/dist/api/types.d.ts +190 -0
  8. package/dist/api/types.js +1 -0
  9. package/dist/components/ConnectWalletModal/ConnectWalletFooter.d.ts +5 -0
  10. package/dist/components/ConnectWalletModal/ConnectWalletFooter.js +9 -0
  11. package/dist/components/ConnectWalletModal/ConnectWalletModal.constants.d.ts +5 -0
  12. package/dist/components/ConnectWalletModal/ConnectWalletModal.constants.js +8 -0
  13. package/dist/components/ConnectWalletModal/ConnectWalletModal.d.ts +3 -0
  14. package/dist/components/ConnectWalletModal/ConnectWalletModal.helpers.d.ts +2 -0
  15. package/dist/components/ConnectWalletModal/ConnectWalletModal.helpers.js +9 -0
  16. package/dist/components/ConnectWalletModal/ConnectWalletModal.js +194 -0
  17. package/dist/components/ConnectWalletModal/ConnectWalletModal.styles.d.ts +19 -0
  18. package/dist/components/ConnectWalletModal/ConnectWalletModal.styles.js +101 -0
  19. package/dist/components/ConnectWalletModal/ConnectWalletModal.types.d.ts +44 -0
  20. package/dist/components/ConnectWalletModal/ConnectWalletModal.types.js +1 -0
  21. package/dist/components/ConnectWalletModal/EmptyWalletList.d.ts +2 -0
  22. package/dist/components/ConnectWalletModal/EmptyWalletList.js +9 -0
  23. package/dist/components/ConnectWalletModal/StatefulConnectContainer.d.ts +3 -0
  24. package/dist/components/ConnectWalletModal/StatefulConnectContainer.js +37 -0
  25. package/dist/components/ConnectWalletModal/StatefulConnectContainer.styles.d.ts +1 -0
  26. package/dist/components/ConnectWalletModal/StatefulConnectContainer.styles.js +51 -0
  27. package/dist/components/ConnectWalletModal/StatefulConnectContainer.types.d.ts +12 -0
  28. package/dist/components/ConnectWalletModal/StatefulConnectContainer.types.js +1 -0
  29. package/dist/components/ConnectWalletModal/WalletsChainSelect.d.ts +3 -0
  30. package/dist/components/ConnectWalletModal/WalletsChainSelect.js +86 -0
  31. package/dist/components/ConnectWalletModal/WalletsChainSelect.styles.d.ts +21 -0
  32. package/dist/components/ConnectWalletModal/WalletsChainSelect.styles.js +83 -0
  33. package/dist/components/ConnectWalletModal/WalletsChainSelect.types.d.ts +12 -0
  34. package/dist/components/ConnectWalletModal/WalletsChainSelect.types.js +1 -0
  35. package/dist/components/ConnectWalletModal/index.d.ts +3 -0
  36. package/dist/components/ConnectWalletModal/index.js +2 -0
  37. package/dist/components/ProfileWallet/ProfileWallet.d.ts +3 -0
  38. package/dist/components/ProfileWallet/ProfileWallet.js +54 -0
  39. package/dist/components/ProfileWallet/ProfileWallet.styles.d.ts +6 -0
  40. package/dist/components/ProfileWallet/ProfileWallet.styles.js +54 -0
  41. package/dist/components/ProfileWallet/ProfileWallet.types.d.ts +11 -0
  42. package/dist/components/ProfileWallet/ProfileWallet.types.js +1 -0
  43. package/dist/components/ProfileWallet/index.d.ts +1 -0
  44. package/dist/components/ProfileWallet/index.js +1 -0
  45. package/dist/components/ProfileWallets/ConnectedWallets.d.ts +2 -0
  46. package/dist/components/ProfileWallets/ConnectedWallets.js +25 -0
  47. package/dist/components/ProfileWallets/ConnectedWallets.styles.d.ts +4 -0
  48. package/dist/components/ProfileWallets/ConnectedWallets.styles.js +30 -0
  49. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.d.ts +5 -0
  50. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.js +9 -0
  51. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.styles.d.ts +1 -0
  52. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.styles.js +8 -0
  53. package/dist/components/ProfileWallets/ProfileWallets.d.ts +4 -0
  54. package/dist/components/ProfileWallets/ProfileWallets.js +37 -0
  55. package/dist/components/ProfileWallets/ProfileWallets.styles.d.ts +5 -0
  56. package/dist/components/ProfileWallets/ProfileWallets.styles.js +17 -0
  57. package/dist/components/ProfileWallets/ProfileWallets.types.d.ts +14 -0
  58. package/dist/components/ProfileWallets/ProfileWallets.types.js +1 -0
  59. package/dist/components/ProfileWallets/index.d.ts +1 -0
  60. package/dist/components/ProfileWallets/index.js +1 -0
  61. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.constants.d.ts +3 -0
  62. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.constants.js +2 -0
  63. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.d.ts +3 -0
  64. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.js +23 -0
  65. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.styles.d.ts +4 -0
  66. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.styles.js +23 -0
  67. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.types.d.ts +23 -0
  68. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.types.js +1 -0
  69. package/dist/components/ProfileWalletsModal/index.d.ts +2 -0
  70. package/dist/components/ProfileWalletsModal/index.js +1 -0
  71. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.d.ts +2 -0
  72. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.js +21 -0
  73. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.styles.d.ts +4 -0
  74. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.styles.js +49 -0
  75. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.types.d.ts +7 -0
  76. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.types.js +1 -0
  77. package/dist/components/SocialWalletIntroModal/index.d.ts +1 -0
  78. package/dist/components/SocialWalletIntroModal/index.js +1 -0
  79. package/dist/components/StackModal/ModalContainer.d.ts +4 -0
  80. package/dist/components/StackModal/ModalContainer.js +33 -0
  81. package/dist/components/StackModal/ModalContainer.types.d.ts +6 -0
  82. package/dist/components/StackModal/ModalContainer.types.js +1 -0
  83. package/dist/components/StackModal/StackModal.d.ts +3 -0
  84. package/dist/components/StackModal/StackModal.js +90 -0
  85. package/dist/components/StackModal/StackModal.styles.d.ts +2 -0
  86. package/dist/components/StackModal/StackModal.styles.js +77 -0
  87. package/dist/components/StackModal/StackModal.types.d.ts +3 -0
  88. package/dist/components/StackModal/StackModal.types.js +1 -0
  89. package/dist/components/StackModal/index.d.ts +1 -0
  90. package/dist/components/StackModal/index.js +1 -0
  91. package/dist/components/WalletItem/WalletItem.d.ts +3 -0
  92. package/dist/components/WalletItem/WalletItem.js +60 -0
  93. package/dist/components/WalletItem/WalletItem.styles.d.ts +9 -0
  94. package/dist/components/WalletItem/WalletItem.styles.js +71 -0
  95. package/dist/components/WalletItem/WalletItem.types.d.ts +8 -0
  96. package/dist/components/WalletItem/WalletItem.types.js +1 -0
  97. package/dist/components/WalletItem/index.d.ts +1 -0
  98. package/dist/components/WalletItem/index.js +1 -0
  99. package/dist/components/mod.d.ts +5 -0
  100. package/dist/components/mod.js +3 -0
  101. package/dist/constants/errors.d.ts +1 -0
  102. package/dist/constants/errors.js +1 -0
  103. package/dist/constants/events.d.ts +3 -0
  104. package/dist/constants/events.js +3 -0
  105. package/dist/constants/links.d.ts +2 -0
  106. package/dist/constants/links.js +2 -0
  107. package/dist/constants/mod.d.ts +3 -0
  108. package/dist/constants/mod.js +3 -0
  109. package/dist/constants/modals.d.ts +3 -0
  110. package/dist/constants/modals.js +3 -0
  111. package/dist/fetcher.d.ts +3 -0
  112. package/dist/fetcher.js +10 -0
  113. package/dist/hooks/mod.d.ts +4 -0
  114. package/dist/hooks/mod.js +3 -0
  115. package/dist/hooks/useLocalStorage/index.d.ts +1 -0
  116. package/dist/hooks/useLocalStorage/index.js +1 -0
  117. package/dist/hooks/useLocalStorage/useLocalStorage.d.ts +1 -0
  118. package/dist/hooks/useLocalStorage/useLocalStorage.js +24 -0
  119. package/dist/hooks/useProfile/index.d.ts +1 -0
  120. package/dist/hooks/useProfile/index.js +1 -0
  121. package/dist/hooks/useProfile/useProfile.constants.d.ts +2 -0
  122. package/dist/hooks/useProfile/useProfile.constants.js +3 -0
  123. package/dist/hooks/useProfile/useProfile.d.ts +2 -0
  124. package/dist/hooks/useProfile/useProfile.helpers.d.ts +4 -0
  125. package/dist/hooks/useProfile/useProfile.helpers.js +3 -0
  126. package/dist/hooks/useProfile/useProfile.js +20 -0
  127. package/dist/hooks/useProfile/useProfile.types.d.ts +11 -0
  128. package/dist/hooks/useProfile/useProfile.types.js +1 -0
  129. package/dist/hooks/useStackModal.d.ts +38 -0
  130. package/dist/hooks/useStackModal.js +61 -0
  131. package/dist/hooks/useStatefulConnect.d.ts +7 -0
  132. package/dist/hooks/useStatefulConnect.js +15 -0
  133. package/dist/mod.d.ts +1 -0
  134. package/dist/mod.js +1 -0
  135. package/dist/store/helpers.d.ts +5 -0
  136. package/dist/store/helpers.js +42 -0
  137. package/dist/store/middlewares.d.ts +6 -0
  138. package/dist/store/middlewares.js +40 -0
  139. package/dist/store/mod.d.ts +4 -0
  140. package/dist/store/mod.js +3 -0
  141. package/dist/store/selectors.d.ts +47 -0
  142. package/dist/store/selectors.js +21 -0
  143. package/dist/store/slice.d.ts +134 -0
  144. package/dist/store/slice.js +230 -0
  145. package/dist/store/thunks.d.ts +153 -0
  146. package/dist/store/thunks.js +219 -0
  147. package/dist/store/types.d.ts +67 -0
  148. package/dist/store/types.js +1 -0
  149. package/dist/store/utils.d.ts +1 -0
  150. package/dist/store/utils.js +11 -0
  151. package/dist/types.d.ts +3 -0
  152. package/dist/types.js +1 -0
  153. package/dist/utils/mod.d.ts +1 -0
  154. package/dist/utils/mod.js +1 -0
  155. package/dist/utils/wallets.d.ts +16 -0
  156. package/dist/utils/wallets.js +34 -0
  157. package/package.json +8 -5
  158. package/CHANGELOG.md +0 -32
  159. package/tsconfig.json +0 -21
@@ -0,0 +1,47 @@
1
+ import type { RootStateLike } from './slice';
2
+ export declare const showPrivateProfileSelector: ((state: RootStateLike, username?: string | undefined) => boolean) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState, args_1: string | undefined) => boolean, {
3
+ clearCache: () => void;
4
+ }> & {
5
+ clearCache: () => void;
6
+ };
7
+ export declare const profileSummarySelector: ((state: RootStateLike, username?: string | undefined) => {
8
+ loading: boolean;
9
+ error: string | null;
10
+ data: import("../api/types").ProfileSummary | null;
11
+ }) & import("reselect").OutputSelectorFields<(args_0: boolean, args_1: import("./types").ProfileState) => {
12
+ loading: boolean;
13
+ error: string | null;
14
+ data: import("../api/types").ProfileSummary | null;
15
+ }, {
16
+ clearCache: () => void;
17
+ }> & {
18
+ clearCache: () => void;
19
+ };
20
+ export declare const privateProfileSummarySelector: ((state: RootStateLike) => {
21
+ loading: boolean;
22
+ error: string | null;
23
+ data: import("../api/types").ProfileSummary | null;
24
+ }) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => {
25
+ loading: boolean;
26
+ error: string | null;
27
+ data: import("../api/types").ProfileSummary | null;
28
+ }, {
29
+ clearCache: () => void;
30
+ }> & {
31
+ clearCache: () => void;
32
+ };
33
+ export declare const isLoggedInProfileSelector: ((state: RootStateLike) => boolean) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => boolean, {
34
+ clearCache: () => void;
35
+ }> & {
36
+ clearCache: () => void;
37
+ };
38
+ export declare const authenticatedProfileSelector: ((state: RootStateLike) => import("../api/types").ProfileAccount | null) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => import("../api/types").ProfileAccount | null, {
39
+ clearCache: () => void;
40
+ }> & {
41
+ clearCache: () => void;
42
+ };
43
+ export declare const usernameProfileSelector: ((state: RootStateLike) => string | null) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => string | null, {
44
+ clearCache: () => void;
45
+ }> & {
46
+ clearCache: () => void;
47
+ };
@@ -0,0 +1,21 @@
1
+ import { createSelector } from '@reduxjs/toolkit';
2
+ const profileSelector = (state) => state.profile;
3
+ const usernameSelector = (_, username) => username;
4
+ export const showPrivateProfileSelector = createSelector([profileSelector, usernameSelector], (profile, username) => {
5
+ return profile.isLoggedIn && profile.username === username;
6
+ });
7
+ export const profileSummarySelector = createSelector([showPrivateProfileSelector, profileSelector], (showPrivateProfile, profile) => {
8
+ return showPrivateProfile ? profile.profileSummary.private : profile.profileSummary.public;
9
+ });
10
+ export const privateProfileSummarySelector = createSelector([profileSelector], (profile) => {
11
+ return profile.profileSummary.private;
12
+ });
13
+ export const isLoggedInProfileSelector = createSelector([profileSelector], (profile) => {
14
+ return profile.isLoggedIn;
15
+ });
16
+ export const authenticatedProfileSelector = createSelector([profileSelector], (profile) => {
17
+ return profile.profileAuth.account;
18
+ });
19
+ export const usernameProfileSelector = createSelector([profileSelector], (profile) => {
20
+ return profile.username;
21
+ });
@@ -0,0 +1,134 @@
1
+ import type { ProfileState } from './types';
2
+ import type { Slice } from '@reduxjs/toolkit';
3
+ import type { BlockchainMeta, SwapperMeta, Token as TokenMeta } from 'rango-types/mainApi';
4
+ export declare const profileSliceInitialState: ProfileState;
5
+ type ActionsFromSlice<T extends Slice> = ReturnType<T['actions'][keyof T['actions']]>;
6
+ export type ProfileSliceActions = ActionsFromSlice<ReturnType<typeof createProfileState>['slice']>;
7
+ export type MetaStateLike = {
8
+ loadingStatus: 'loading' | 'success' | 'failed';
9
+ tokens: TokenMeta[];
10
+ blockchains: BlockchainMeta[];
11
+ swappers: SwapperMeta[];
12
+ };
13
+ export type RootStateLike = {
14
+ profile: ProfileState;
15
+ meta: MetaStateLike;
16
+ };
17
+ export declare const createProfileState: <T extends RootStateLike>() => {
18
+ slice: Slice<ProfileState, {
19
+ logInUser: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
20
+ logOutUser: () => ProfileState;
21
+ clearAuthError: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
22
+ resetMergeStatus: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
23
+ resetUserData: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
24
+ resetUpdateUsernameError: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
25
+ }, "profile">;
26
+ thunks: {
27
+ signMessage: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileSummary | null, import("./types").SignMessageParams, {
28
+ state: RootStateLike;
29
+ rejectValue: string;
30
+ dispatch?: import("redux").Dispatch | undefined;
31
+ extra?: unknown;
32
+ serializedErrorType?: unknown;
33
+ pendingMeta?: unknown;
34
+ fulfilledMeta?: unknown;
35
+ rejectedMeta?: unknown;
36
+ }>;
37
+ fetchProfileSummary: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileSummary | null, {
38
+ username: string;
39
+ public: boolean;
40
+ }, {
41
+ state: RootStateLike;
42
+ rejectValue: string | null;
43
+ dispatch?: import("redux").Dispatch | undefined;
44
+ extra?: unknown;
45
+ serializedErrorType?: unknown;
46
+ pendingMeta?: unknown;
47
+ fulfilledMeta?: unknown;
48
+ rejectedMeta?: unknown;
49
+ }>;
50
+ fetchProfileDetails: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileDetails | null, undefined, {
51
+ state: T;
52
+ rejectValue: string | null;
53
+ dispatch?: import("redux").Dispatch | undefined;
54
+ extra?: unknown;
55
+ serializedErrorType?: unknown;
56
+ pendingMeta?: unknown;
57
+ fulfilledMeta?: unknown;
58
+ rejectedMeta?: unknown;
59
+ }>;
60
+ fetchProfileLeaderboard: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileLeaderboard[] | null, {
61
+ username: string;
62
+ public?: boolean;
63
+ }, {
64
+ state: T;
65
+ rejectValue: string | null;
66
+ dispatch?: import("redux").Dispatch | undefined;
67
+ extra?: unknown;
68
+ serializedErrorType?: unknown;
69
+ pendingMeta?: unknown;
70
+ fulfilledMeta?: unknown;
71
+ rejectedMeta?: unknown;
72
+ }>;
73
+ fetchPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<{
74
+ leaderboard: import("../api/types").ProfileLeaderboard[] | null;
75
+ totalPages: number | null;
76
+ }, import("../api/types").PublicLeaderboardRequest, {
77
+ state: T;
78
+ rejectValue: string;
79
+ dispatch?: import("redux").Dispatch | undefined;
80
+ extra?: unknown;
81
+ serializedErrorType?: unknown;
82
+ pendingMeta?: unknown;
83
+ fulfilledMeta?: unknown;
84
+ rejectedMeta?: unknown;
85
+ }>;
86
+ fetchTopPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileLeaderboard[] | null, {
87
+ type: import("../api/types").PublicLeaderboardType;
88
+ }, {
89
+ state: T;
90
+ rejectValue: string;
91
+ dispatch?: import("redux").Dispatch | undefined;
92
+ extra?: unknown;
93
+ serializedErrorType?: unknown;
94
+ pendingMeta?: unknown;
95
+ fulfilledMeta?: unknown;
96
+ rejectedMeta?: unknown;
97
+ }>;
98
+ updateUsername: import("@reduxjs/toolkit").AsyncThunk<{
99
+ username: string;
100
+ }, import("../api/request").UpdateProfileData & {
101
+ callback: () => void;
102
+ }, {
103
+ state: T;
104
+ rejectValue: string;
105
+ dispatch?: import("redux").Dispatch | undefined;
106
+ extra?: unknown;
107
+ serializedErrorType?: unknown;
108
+ pendingMeta?: unknown;
109
+ fulfilledMeta?: unknown;
110
+ rejectedMeta?: unknown;
111
+ }>;
112
+ requestLogOutUser: import("@reduxjs/toolkit").AsyncThunk<void, void, {
113
+ state: RootStateLike;
114
+ rejectValue: string;
115
+ dispatch?: import("redux").Dispatch | undefined;
116
+ extra?: unknown;
117
+ serializedErrorType?: unknown;
118
+ pendingMeta?: unknown;
119
+ fulfilledMeta?: unknown;
120
+ rejectedMeta?: unknown;
121
+ }>;
122
+ setClaim: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileSummary | null, import("./types").SignMessageParams, {
123
+ state: RootStateLike;
124
+ rejectValue: string;
125
+ dispatch?: import("redux").Dispatch | undefined;
126
+ extra?: unknown;
127
+ serializedErrorType?: unknown;
128
+ pendingMeta?: unknown;
129
+ fulfilledMeta?: unknown;
130
+ rejectedMeta?: unknown;
131
+ }>;
132
+ };
133
+ };
134
+ export {};
@@ -0,0 +1,230 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+ import { getProfileType } from './helpers';
3
+ import { createProfileThunks } from './thunks';
4
+ export const profileSliceInitialState = {
5
+ isLoggedIn: false,
6
+ username: null,
7
+ profileAuth: {
8
+ loading: false,
9
+ error: null,
10
+ account: null,
11
+ numberOfRetries: 0,
12
+ accountMerged: false,
13
+ },
14
+ profileSummary: {
15
+ private: { loading: true, error: null, data: null },
16
+ public: { loading: true, error: null, data: null },
17
+ },
18
+ profileDetails: { loading: true, error: null, data: null },
19
+ profileLeaderboard: { loading: false, error: null, data: null },
20
+ publicLeaderboard: { loading: false, error: null, data: null, totalPages: null },
21
+ topPublicLeaderboard: { loading: false, error: null, data: null },
22
+ updateUsername: { loading: false, error: null },
23
+ logOut: {
24
+ loading: false,
25
+ error: null,
26
+ },
27
+ };
28
+ export const createProfileState = () => {
29
+ const thunks = createProfileThunks();
30
+ const slice = createSlice({
31
+ name: 'profile',
32
+ initialState: profileSliceInitialState,
33
+ reducers: {
34
+ logInUser: (state) => {
35
+ state.isLoggedIn = true;
36
+ },
37
+ logOutUser: () => {
38
+ return profileSliceInitialState;
39
+ },
40
+ clearAuthError: (state) => {
41
+ state.profileAuth.error = null;
42
+ },
43
+ resetMergeStatus: (state) => {
44
+ state.profileAuth.accountMerged = false;
45
+ },
46
+ resetUserData: (state) => {
47
+ state.profileSummary.public = profileSliceInitialState.profileSummary.public;
48
+ },
49
+ resetUpdateUsernameError: (state) => {
50
+ state.updateUsername.error = null;
51
+ },
52
+ },
53
+ extraReducers: (builder) => {
54
+ builder
55
+ .addCase(thunks.setClaim.fulfilled, (state, action) => {
56
+ state.profileSummary.private.data = action.payload;
57
+ })
58
+ .addCase(thunks.signMessage.pending, (state, action) => {
59
+ state.profileAuth.loading = true;
60
+ state.profileAuth.error = null;
61
+ state.profileAuth.account = action.meta.arg.account;
62
+ state.profileAuth.numberOfRetries = 0;
63
+ })
64
+ .addCase(thunks.signMessage.rejected, (state, action) => {
65
+ state.profileAuth.loading = false;
66
+ state.profileAuth.account = null;
67
+ state.profileAuth.numberOfRetries = 0;
68
+ state.profileAuth.error = action.payload ?? null;
69
+ })
70
+ .addCase(thunks.signMessage.fulfilled, (state, action) => {
71
+ state.profileAuth.loading = false;
72
+ state.profileSummary.private.loading = false;
73
+ state.profileAuth.error = null;
74
+ state.profileAuth.account = null;
75
+ if (action.payload) {
76
+ if (state.isLoggedIn) {
77
+ state.profileAuth.accountMerged = true;
78
+ }
79
+ else {
80
+ state.isLoggedIn = true;
81
+ }
82
+ state.profileSummary.private.data = action.payload;
83
+ if (action.payload?.username) {
84
+ state.username = action.payload?.username;
85
+ }
86
+ state.profileAuth.numberOfRetries = 0;
87
+ }
88
+ else {
89
+ state.profileAuth.numberOfRetries += 1;
90
+ }
91
+ })
92
+ .addCase(thunks.fetchProfileSummary.pending, (state, action) => {
93
+ const { meta: { arg }, } = action;
94
+ const key = getProfileType(arg.public);
95
+ state.profileSummary[key].data = null;
96
+ state.profileSummary[key].loading = true;
97
+ state.profileSummary[key].error = null;
98
+ })
99
+ .addCase(thunks.fetchProfileSummary.fulfilled, (state, action) => {
100
+ const key = getProfileType(action.meta.arg.public);
101
+ state.profileSummary[key].loading = false;
102
+ state.profileSummary[key].error = null;
103
+ state.profileSummary[key].data = action.payload;
104
+ if (action.payload?.username && key === 'private') {
105
+ state.username = action.payload?.username;
106
+ }
107
+ })
108
+ .addCase(thunks.fetchProfileSummary.rejected, (state, action) => {
109
+ /**
110
+ * In DEV mode react strict will call the action twice.
111
+ * We added a check here to make sure if the first request has been cancelled,
112
+ * we don't update the state in between of these two requests.
113
+ */
114
+ if (!action.payload || action.error.name === 'AbortError') {
115
+ return;
116
+ }
117
+ const key = getProfileType(action.meta.arg.public);
118
+ state.profileSummary[key].loading = false;
119
+ state.profileSummary[key].error =
120
+ typeof action.payload === 'string' ? action.payload : null;
121
+ state.profileSummary[key].data = null;
122
+ })
123
+ .addCase(thunks.fetchProfileDetails.pending, (state) => {
124
+ state.profileDetails.data = null;
125
+ state.profileDetails.loading = true;
126
+ state.profileDetails.error = null;
127
+ })
128
+ .addCase(thunks.fetchProfileDetails.fulfilled, (state, action) => {
129
+ state.profileDetails.loading = false;
130
+ state.profileDetails.error = null;
131
+ state.profileDetails.data = action.payload;
132
+ })
133
+ .addCase(thunks.fetchProfileDetails.rejected, (state, action) => {
134
+ /**
135
+ * In DEV mode react strict will call the action twice.
136
+ * We added a check here to make sure if the first request has been cancelled,
137
+ * we don't update the state in between of these two requests.
138
+ */
139
+ if (action.error.name === 'AbortError') {
140
+ return;
141
+ }
142
+ state.profileDetails.loading = false;
143
+ state.profileDetails.error = action.payload ?? null;
144
+ state.profileDetails.data = null;
145
+ })
146
+ .addCase(thunks.fetchProfileLeaderboard.pending, (state) => {
147
+ state.profileLeaderboard.data = null;
148
+ state.profileLeaderboard.loading = true;
149
+ state.profileLeaderboard.error = null;
150
+ })
151
+ .addCase(thunks.fetchProfileLeaderboard.fulfilled, (state, action) => {
152
+ state.profileLeaderboard.loading = false;
153
+ state.profileLeaderboard.error = null;
154
+ state.profileLeaderboard.data = action.payload;
155
+ })
156
+ .addCase(thunks.fetchProfileLeaderboard.rejected, (state, action) => {
157
+ if (!action.payload) {
158
+ return;
159
+ }
160
+ state.profileLeaderboard.loading = false;
161
+ state.profileLeaderboard.error = action.payload ?? null;
162
+ })
163
+ .addCase(thunks.fetchPublicLeaderboard.pending, (state, action) => {
164
+ state.publicLeaderboard.loading = true;
165
+ state.publicLeaderboard.error = null;
166
+ if (action.meta.arg.page === 0) {
167
+ state.topPublicLeaderboard.loading = true;
168
+ state.topPublicLeaderboard.error = null;
169
+ }
170
+ })
171
+ .addCase(thunks.fetchPublicLeaderboard.fulfilled, (state, action) => {
172
+ state.publicLeaderboard.loading = false;
173
+ state.publicLeaderboard.error = null;
174
+ state.publicLeaderboard.data = action.payload.leaderboard;
175
+ state.publicLeaderboard.totalPages = action.payload.totalPages;
176
+ if (action.meta.arg.page === 0) {
177
+ state.topPublicLeaderboard.loading = false;
178
+ state.topPublicLeaderboard.error = null;
179
+ state.topPublicLeaderboard.data = action.payload.leaderboard;
180
+ }
181
+ })
182
+ .addCase(thunks.fetchPublicLeaderboard.rejected, (state, action) => {
183
+ state.publicLeaderboard.loading = false;
184
+ state.publicLeaderboard.error = action.payload ?? null;
185
+ if (action.meta.arg.page === 0) {
186
+ state.topPublicLeaderboard.loading = false;
187
+ state.topPublicLeaderboard.error = action.payload ?? null;
188
+ }
189
+ })
190
+ .addCase(thunks.fetchTopPublicLeaderboard.pending, (state) => {
191
+ state.topPublicLeaderboard.loading = true;
192
+ state.topPublicLeaderboard.error = null;
193
+ })
194
+ .addCase(thunks.fetchTopPublicLeaderboard.fulfilled, (state, action) => {
195
+ state.topPublicLeaderboard.loading = false;
196
+ state.topPublicLeaderboard.error = null;
197
+ state.topPublicLeaderboard.data = action.payload;
198
+ })
199
+ .addCase(thunks.fetchTopPublicLeaderboard.rejected, (state, action) => {
200
+ state.topPublicLeaderboard.loading = false;
201
+ state.topPublicLeaderboard.error = action.payload ?? null;
202
+ })
203
+ .addCase(thunks.updateUsername.pending, (state) => {
204
+ state.updateUsername.loading = true;
205
+ state.updateUsername.error = null;
206
+ })
207
+ .addCase(thunks.updateUsername.fulfilled, (state, action) => {
208
+ state.updateUsername.loading = false;
209
+ state.username = action.payload.username;
210
+ })
211
+ .addCase(thunks.updateUsername.rejected, (state, action) => {
212
+ state.updateUsername.loading = false;
213
+ state.updateUsername.error = action.payload ?? null;
214
+ })
215
+ .addCase(thunks.requestLogOutUser.pending, (state) => {
216
+ state.logOut.loading = true;
217
+ state.logOut.error = null;
218
+ })
219
+ .addCase(thunks.requestLogOutUser.fulfilled, () => profileSliceInitialState)
220
+ .addCase(thunks.requestLogOutUser.rejected, (state, action) => {
221
+ state.logOut.loading = false;
222
+ state.logOut.error = action.payload ?? null;
223
+ });
224
+ },
225
+ });
226
+ return {
227
+ slice,
228
+ thunks,
229
+ };
230
+ };
@@ -0,0 +1,153 @@
1
+ import type { RootStateLike } from './slice';
2
+ import type { SignMessageParams } from './types';
3
+ import type { ProfileDetails, ProfileLeaderboard, ProfileSummary, PublicLeaderboardRequest, PublicLeaderboardType, UpdateProfileData } from '../api/mod';
4
+ export declare function createSignMessage<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
5
+ state: T;
6
+ rejectValue: string;
7
+ dispatch?: import("redux").Dispatch | undefined;
8
+ extra?: unknown;
9
+ serializedErrorType?: unknown;
10
+ pendingMeta?: unknown;
11
+ fulfilledMeta?: unknown;
12
+ rejectedMeta?: unknown;
13
+ }>;
14
+ export declare function createFetchProfileSummary<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, {
15
+ username: string;
16
+ public: boolean;
17
+ }, {
18
+ state: T;
19
+ rejectValue: string | null;
20
+ dispatch?: import("redux").Dispatch | undefined;
21
+ extra?: unknown;
22
+ serializedErrorType?: unknown;
23
+ pendingMeta?: unknown;
24
+ fulfilledMeta?: unknown;
25
+ rejectedMeta?: unknown;
26
+ }>;
27
+ export declare function createSetClaim<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
28
+ state: T;
29
+ rejectValue: string;
30
+ dispatch?: import("redux").Dispatch | undefined;
31
+ extra?: unknown;
32
+ serializedErrorType?: unknown;
33
+ pendingMeta?: unknown;
34
+ fulfilledMeta?: unknown;
35
+ rejectedMeta?: unknown;
36
+ }>;
37
+ export declare function createRequestLogOutUser<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<void, void, {
38
+ state: T;
39
+ rejectValue: string;
40
+ dispatch?: import("redux").Dispatch | undefined;
41
+ extra?: unknown;
42
+ serializedErrorType?: unknown;
43
+ pendingMeta?: unknown;
44
+ fulfilledMeta?: unknown;
45
+ rejectedMeta?: unknown;
46
+ }>;
47
+ export declare function createProfileThunks<T extends RootStateLike>(): {
48
+ signMessage: import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
49
+ state: RootStateLike;
50
+ rejectValue: string;
51
+ dispatch?: import("redux").Dispatch | undefined;
52
+ extra?: unknown;
53
+ serializedErrorType?: unknown;
54
+ pendingMeta?: unknown;
55
+ fulfilledMeta?: unknown;
56
+ rejectedMeta?: unknown;
57
+ }>;
58
+ fetchProfileSummary: import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, {
59
+ username: string;
60
+ public: boolean;
61
+ }, {
62
+ state: RootStateLike;
63
+ rejectValue: string | null;
64
+ dispatch?: import("redux").Dispatch | undefined;
65
+ extra?: unknown;
66
+ serializedErrorType?: unknown;
67
+ pendingMeta?: unknown;
68
+ fulfilledMeta?: unknown;
69
+ rejectedMeta?: unknown;
70
+ }>;
71
+ fetchProfileDetails: import("@reduxjs/toolkit").AsyncThunk<ProfileDetails | null, undefined, {
72
+ state: T;
73
+ rejectValue: string | null;
74
+ dispatch?: import("redux").Dispatch | undefined;
75
+ extra?: unknown;
76
+ serializedErrorType?: unknown;
77
+ pendingMeta?: unknown;
78
+ fulfilledMeta?: unknown;
79
+ rejectedMeta?: unknown;
80
+ }>;
81
+ fetchProfileLeaderboard: import("@reduxjs/toolkit").AsyncThunk<ProfileLeaderboard[] | null, {
82
+ username: string;
83
+ public?: boolean;
84
+ }, {
85
+ state: T;
86
+ rejectValue: string | null;
87
+ dispatch?: import("redux").Dispatch | undefined;
88
+ extra?: unknown;
89
+ serializedErrorType?: unknown;
90
+ pendingMeta?: unknown;
91
+ fulfilledMeta?: unknown;
92
+ rejectedMeta?: unknown;
93
+ }>;
94
+ fetchPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<{
95
+ leaderboard: ProfileLeaderboard[] | null;
96
+ totalPages: number | null;
97
+ }, PublicLeaderboardRequest, {
98
+ state: T;
99
+ rejectValue: string;
100
+ dispatch?: import("redux").Dispatch | undefined;
101
+ extra?: unknown;
102
+ serializedErrorType?: unknown;
103
+ pendingMeta?: unknown;
104
+ fulfilledMeta?: unknown;
105
+ rejectedMeta?: unknown;
106
+ }>;
107
+ fetchTopPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<ProfileLeaderboard[] | null, {
108
+ type: PublicLeaderboardType;
109
+ }, {
110
+ state: T;
111
+ rejectValue: string;
112
+ dispatch?: import("redux").Dispatch | undefined;
113
+ extra?: unknown;
114
+ serializedErrorType?: unknown;
115
+ pendingMeta?: unknown;
116
+ fulfilledMeta?: unknown;
117
+ rejectedMeta?: unknown;
118
+ }>;
119
+ updateUsername: import("@reduxjs/toolkit").AsyncThunk<{
120
+ username: string;
121
+ }, UpdateProfileData & {
122
+ callback: () => void;
123
+ }, {
124
+ state: T;
125
+ rejectValue: string;
126
+ dispatch?: import("redux").Dispatch | undefined;
127
+ extra?: unknown;
128
+ serializedErrorType?: unknown;
129
+ pendingMeta?: unknown;
130
+ fulfilledMeta?: unknown;
131
+ rejectedMeta?: unknown;
132
+ }>;
133
+ requestLogOutUser: import("@reduxjs/toolkit").AsyncThunk<void, void, {
134
+ state: RootStateLike;
135
+ rejectValue: string;
136
+ dispatch?: import("redux").Dispatch | undefined;
137
+ extra?: unknown;
138
+ serializedErrorType?: unknown;
139
+ pendingMeta?: unknown;
140
+ fulfilledMeta?: unknown;
141
+ rejectedMeta?: unknown;
142
+ }>;
143
+ setClaim: import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
144
+ state: RootStateLike;
145
+ rejectValue: string;
146
+ dispatch?: import("redux").Dispatch | undefined;
147
+ extra?: unknown;
148
+ serializedErrorType?: unknown;
149
+ pendingMeta?: unknown;
150
+ fulfilledMeta?: unknown;
151
+ rejectedMeta?: unknown;
152
+ }>;
153
+ };