@arthur2079/internal-profile 4.1.2-next.4 → 5.1.2-next.6

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,219 @@
1
+ import { createAsyncThunk } from '@reduxjs/toolkit';
2
+ import axios from 'axios';
3
+ import { getLoginMessage, getMergeAccountMessage, getProfileDetails, getProfileLeaderboard, getProfileSummary, getPublicLeaderboard, getPublicProfileLeaderboard, getPublicProfileSummary, getSetClaimMessage, logIn, logOut, mergeAccount, setClaimWallet, updateProfileData, UserUnauthorizedError, } from '../api/mod';
4
+ import { getErrorMessage, throwIfAborted } from './helpers';
5
+ import { memoizeThunk } from './utils';
6
+ // To learn more about this pattern, check https://github.com/rango-exchange/app-v2/pull/281
7
+ export function createSignMessage() {
8
+ const actionType = 'profile/signMessage';
9
+ const signMessageThunk = memoizeThunk(actionType, () => createAsyncThunk(actionType, async (params, options) => {
10
+ const { rejectWithValue, getState, dispatch, signal } = options;
11
+ const { account, getSigners, callback, errorCallback } = params;
12
+ const { meta: { blockchains }, profile: { profileAuth, isLoggedIn }, } = getState();
13
+ const { numberOfRetries } = profileAuth;
14
+ throwIfAborted(signal);
15
+ const signer = await getSigners(account.walletType);
16
+ const blockchainMeta = blockchains.find((blockchain) => blockchain.name === account.blockchain);
17
+ if (!blockchainMeta) {
18
+ return rejectWithValue('Something went wrong. Please try again.');
19
+ }
20
+ let signAction;
21
+ let saveAction;
22
+ if (isLoggedIn) {
23
+ signAction = getMergeAccountMessage;
24
+ saveAction = mergeAccount;
25
+ }
26
+ else {
27
+ signAction = getLoginMessage;
28
+ saveAction = logIn;
29
+ }
30
+ try {
31
+ throwIfAborted(signal);
32
+ const { message, messageId } = await signAction({
33
+ address: account.address,
34
+ blockchain: account.blockchain,
35
+ }, signal);
36
+ throwIfAborted(signal);
37
+ const signature = await signer
38
+ .getSigner(blockchainMeta.type)
39
+ .signMessage(message, account.address, blockchainMeta.chainId);
40
+ throwIfAborted(signal);
41
+ const { profile } = await saveAction({ messageId, signature }, signal);
42
+ if (profile) {
43
+ callback?.(profile, { actionType: isLoggedIn ? 'merge' : 'login' });
44
+ }
45
+ return profile;
46
+ }
47
+ catch (error) {
48
+ if (signal.aborted || axios.isCancel(error)) {
49
+ return null;
50
+ }
51
+ const shouldLogOutAndRetry = !isLoggedIn && error instanceof UserUnauthorizedError && numberOfRetries === 0;
52
+ if (shouldLogOutAndRetry) {
53
+ await logOut(signal);
54
+ // Use a timeout to dispatch signMessage after incrementing the numberOfRetries.
55
+ setTimeout(async () => dispatch(signMessageThunk()(params)), 0);
56
+ return null;
57
+ }
58
+ errorCallback?.(error);
59
+ return rejectWithValue(getErrorMessage(error));
60
+ }
61
+ }));
62
+ return signMessageThunk();
63
+ }
64
+ export function createFetchProfileSummary() {
65
+ const actionType = 'profile/fetchProfileSummary';
66
+ const fetchProfileSummaryThunk = memoizeThunk(actionType, () => createAsyncThunk(actionType, async (params, options) => {
67
+ const { rejectWithValue, signal, getState, fulfillWithValue, dispatch } = options;
68
+ const state = getState().profile;
69
+ const publicProfile = params.public ||
70
+ !state.isLoggedIn ||
71
+ (state.isLoggedIn && state.username !== params.username);
72
+ const request = publicProfile
73
+ ? getPublicProfileSummary.bind(null, params.username)
74
+ : getProfileSummary;
75
+ try {
76
+ const profileSummary = await request(signal);
77
+ return fulfillWithValue(profileSummary.profile);
78
+ }
79
+ catch (error) {
80
+ if (error instanceof UserUnauthorizedError) {
81
+ void dispatch(fetchProfileSummaryThunk()({ username: params.username, public: true }));
82
+ return rejectWithValue(null);
83
+ }
84
+ return rejectWithValue(getErrorMessage(error));
85
+ }
86
+ }));
87
+ return fetchProfileSummaryThunk();
88
+ }
89
+ export function createSetClaim() {
90
+ const actionType = 'profile/setClaim';
91
+ const setClaimThunk = memoizeThunk(actionType, () => createAsyncThunk(actionType, async (params, options) => {
92
+ const { rejectWithValue, getState, signal } = options;
93
+ const { account, getSigners } = params;
94
+ const { meta: { blockchains }, } = getState();
95
+ throwIfAborted(signal);
96
+ const signer = await getSigners(account.walletType);
97
+ const blockchainMeta = blockchains.find((blockchain) => blockchain.name === account.blockchain);
98
+ if (!blockchainMeta) {
99
+ return rejectWithValue(`We couldn't find ${account.blockchain} in our initial data. Please try again.`);
100
+ }
101
+ try {
102
+ throwIfAborted(signal);
103
+ const { message, messageId } = await getSetClaimMessage({
104
+ address: account.address,
105
+ blockchain: account.blockchain,
106
+ }, signal);
107
+ throwIfAborted(signal);
108
+ const signature = await signer
109
+ .getSigner(blockchainMeta.type)
110
+ .signMessage(message, account.address, blockchainMeta.chainId);
111
+ throwIfAborted(signal);
112
+ const { profile } = await setClaimWallet({ messageId, signature }, signal);
113
+ return profile;
114
+ }
115
+ catch (error) {
116
+ if (signal.aborted || axios.isCancel(error)) {
117
+ return null;
118
+ }
119
+ return rejectWithValue(getErrorMessage(error));
120
+ }
121
+ }));
122
+ return setClaimThunk();
123
+ }
124
+ export function createRequestLogOutUser() {
125
+ const actionType = 'profile/logOut';
126
+ const logOutThunk = memoizeThunk(actionType, () => createAsyncThunk(actionType, async (_, options) => {
127
+ const { rejectWithValue, signal } = options;
128
+ try {
129
+ await logOut(signal);
130
+ }
131
+ catch (error) {
132
+ return rejectWithValue(getErrorMessage(error));
133
+ }
134
+ }));
135
+ return logOutThunk();
136
+ }
137
+ export function createProfileThunks() {
138
+ const fetchProfileDetails = createAsyncThunk('profile/fetchProfileDetails', async (_, options) => {
139
+ const { rejectWithValue, signal } = options;
140
+ try {
141
+ const profileDetails = await getProfileDetails(signal);
142
+ return profileDetails.profile;
143
+ }
144
+ catch (error) {
145
+ if (error instanceof UserUnauthorizedError) {
146
+ return rejectWithValue(null);
147
+ }
148
+ return rejectWithValue(getErrorMessage(error));
149
+ }
150
+ });
151
+ const fetchProfileLeaderboard = createAsyncThunk('profile/fetchProfileLeaderboard', async (params, options) => {
152
+ const { rejectWithValue, signal, getState, dispatch } = options;
153
+ const state = getState().profile;
154
+ const publicProfile = params.public ||
155
+ !state.isLoggedIn ||
156
+ (state.isLoggedIn && state.username !== params.username);
157
+ const request = publicProfile
158
+ ? getPublicProfileLeaderboard.bind(null, params.username)
159
+ : getProfileLeaderboard;
160
+ try {
161
+ const profileLeaderboard = await request(signal);
162
+ return profileLeaderboard.data;
163
+ }
164
+ catch (error) {
165
+ if (error instanceof UserUnauthorizedError) {
166
+ void dispatch(fetchProfileLeaderboard({ username: params.username, public: true }));
167
+ return rejectWithValue(null);
168
+ }
169
+ return rejectWithValue(getErrorMessage(error));
170
+ }
171
+ });
172
+ const fetchPublicLeaderboard = createAsyncThunk('profile/fetchPublicLeaderboard', async (params, options) => {
173
+ const { rejectWithValue, signal } = options;
174
+ try {
175
+ const leaderboard = await getPublicLeaderboard(params, signal);
176
+ return { leaderboard: leaderboard.data, totalPages: leaderboard.totalPages };
177
+ }
178
+ catch (error) {
179
+ return rejectWithValue(getErrorMessage(error));
180
+ }
181
+ });
182
+ const fetchTopPublicLeaderboard = createAsyncThunk('profile/fetchTopPublicLeaderboard', async (params, options) => {
183
+ const { rejectWithValue, signal } = options;
184
+ try {
185
+ const leaderboard = await getPublicLeaderboard({ type: params.type, page: 0, offset: 10 }, signal);
186
+ return leaderboard.data;
187
+ }
188
+ catch (error) {
189
+ return rejectWithValue(getErrorMessage(error));
190
+ }
191
+ });
192
+ const updateUsername = createAsyncThunk('profile/updateUsername', async (params, options) => {
193
+ const { rejectWithValue, signal } = options;
194
+ const { userName, callback } = params;
195
+ const DEFAULT_ERROR_MESSAGE = 'An error occurred while updating the username.';
196
+ try {
197
+ const result = await updateProfileData({ userName }, signal);
198
+ if (result.success) {
199
+ callback();
200
+ return { username: userName };
201
+ }
202
+ return rejectWithValue(DEFAULT_ERROR_MESSAGE);
203
+ }
204
+ catch (error) {
205
+ return rejectWithValue(error instanceof Error ? error.message : DEFAULT_ERROR_MESSAGE);
206
+ }
207
+ });
208
+ return {
209
+ signMessage: createSignMessage(),
210
+ fetchProfileSummary: createFetchProfileSummary(),
211
+ fetchProfileDetails,
212
+ fetchProfileLeaderboard,
213
+ fetchPublicLeaderboard,
214
+ fetchTopPublicLeaderboard,
215
+ updateUsername,
216
+ requestLogOutUser: createRequestLogOutUser(),
217
+ setClaim: createSetClaim(),
218
+ };
219
+ }
@@ -0,0 +1,67 @@
1
+ import type { ProfileAccount, ProfileDetails, ProfileLeaderboard, ProfileSummary } from '../api/mod';
2
+ import type { useWallets } from '@rango-dev/widget-embedded';
3
+ type ProfileAuth = {
4
+ numberOfRetries: number;
5
+ accountMerged: boolean;
6
+ } & ({
7
+ loading: true;
8
+ error: null;
9
+ account: ProfileAccount;
10
+ accountMerged: false;
11
+ } | {
12
+ loading: false;
13
+ error: string | null;
14
+ account: null;
15
+ });
16
+ type ProfileSummaryState = {
17
+ loading: boolean;
18
+ error: string | null;
19
+ data: ProfileSummary | null;
20
+ };
21
+ export type ProfileState = {
22
+ isLoggedIn: boolean;
23
+ username: string | null;
24
+ profileAuth: ProfileAuth;
25
+ profileSummary: {
26
+ private: ProfileSummaryState;
27
+ public: ProfileSummaryState;
28
+ };
29
+ profileDetails: {
30
+ loading: boolean;
31
+ error: string | null;
32
+ data: ProfileDetails | null;
33
+ };
34
+ profileLeaderboard: {
35
+ loading: boolean;
36
+ error: string | null;
37
+ data: ProfileLeaderboard[] | null;
38
+ };
39
+ publicLeaderboard: {
40
+ loading: boolean;
41
+ error: string | null;
42
+ totalPages: number | null;
43
+ data: ProfileLeaderboard[] | null;
44
+ };
45
+ topPublicLeaderboard: {
46
+ loading: boolean;
47
+ error: string | null;
48
+ data: ProfileLeaderboard[] | null;
49
+ };
50
+ updateUsername: {
51
+ loading: boolean;
52
+ error: string | null;
53
+ };
54
+ logOut: {
55
+ loading: boolean;
56
+ error: string | null;
57
+ };
58
+ };
59
+ export type SignMessageParams = {
60
+ account: ProfileAccount;
61
+ getSigners: ReturnType<typeof useWallets>['getSigners'];
62
+ callback?: (profileSummary: ProfileSummary, meta: {
63
+ actionType: 'login' | 'merge';
64
+ }) => void;
65
+ errorCallback?: (error: unknown) => void;
66
+ };
67
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function memoizeThunk<Result>(key: string, callback: () => Result): () => Result;
@@ -0,0 +1,11 @@
1
+ const memoizedThunks = new Map();
2
+ export function memoizeThunk(key, callback) {
3
+ return () => {
4
+ let result = memoizedThunks.get(key);
5
+ if (!result) {
6
+ result = callback();
7
+ memoizedThunks.set(key, result);
8
+ }
9
+ return result;
10
+ };
11
+ }
@@ -0,0 +1,3 @@
1
+ export interface Cancellable {
2
+ abort: () => void;
3
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { walletAndSupportedChainsNames, getAddedAccountsToProfile, getConciseAddress, } from './wallets';
@@ -0,0 +1 @@
1
+ export { walletAndSupportedChainsNames, getAddedAccountsToProfile, getConciseAddress, } from './wallets';
@@ -0,0 +1,16 @@
1
+ import type { ProfileSummary } from '../api/mod';
2
+ import type { Networks, WalletInfoWithExtra } from '@rango-dev/widget-embedded';
3
+ import type { BlockchainMeta } from 'rango-types';
4
+ export type ExtendedModalWalletInfo = WalletInfoWithExtra & {
5
+ isHub?: boolean;
6
+ };
7
+ export declare function walletAndSupportedChainsNames(supportedChains: BlockchainMeta[]): Networks[] | null;
8
+ export declare function checkIsWalletPartiallyConnected(wallet: ExtendedModalWalletInfo, namespacesState?: Map<string, {
9
+ connected: boolean;
10
+ }>): boolean;
11
+ export declare function getAddedAccountsToProfile(profileSummary: ProfileSummary): {
12
+ address: string;
13
+ blockchain: string;
14
+ walletType: null;
15
+ }[];
16
+ export declare const getConciseAddress: (address: string | null, maxChars?: number) => string | null;
@@ -0,0 +1,34 @@
1
+ export function walletAndSupportedChainsNames(supportedChains) {
2
+ if (!supportedChains) {
3
+ return null;
4
+ }
5
+ let walletAndSupportedChainsNames = [];
6
+ walletAndSupportedChainsNames = supportedChains.map((blockchainMeta) => blockchainMeta.name);
7
+ return walletAndSupportedChainsNames;
8
+ }
9
+ export function checkIsWalletPartiallyConnected(wallet, namespacesState) {
10
+ if (!wallet.isHub || !wallet.needsNamespace || wallet.state !== 'connected') {
11
+ return false;
12
+ }
13
+ const namespaces = wallet.needsNamespace.data;
14
+ const supportedNamespaces = namespaces.filter((namespace) => !namespace.unsupported);
15
+ return supportedNamespaces.some((namespace) => !namespacesState?.get(namespace.value)?.connected);
16
+ }
17
+ export function getAddedAccountsToProfile(profileSummary) {
18
+ return profileSummary.wallets.map((account) => ({
19
+ address: account.address,
20
+ blockchain: account.blockchain,
21
+ walletType: null,
22
+ }));
23
+ }
24
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
25
+ export const getConciseAddress = (address, maxChars = 6) => {
26
+ if (address === undefined || address === null) {
27
+ return null;
28
+ }
29
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
30
+ if (address.length < 2 * maxChars + 3) {
31
+ return address;
32
+ }
33
+ return address.substr(0, maxChars) + '...' + address.substr(address.length - maxChars);
34
+ };
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@arthur2079/internal-profile",
3
3
  "type": "module",
4
- "version": "4.1.2-next.4",
4
+ "version": "5.1.2-next.6",
5
5
  "license": "MIT",
6
6
  "private": false,
7
+ "files": [
8
+ "dist"
9
+ ],
7
10
  "exports": {
8
11
  ".": {
9
12
  "types": "./dist/mod.d.ts",
@@ -39,8 +42,8 @@
39
42
  "dev": "tsc -p ./tsconfig.json --watch"
40
43
  },
41
44
  "devDependencies": {
42
- "@arthur2079/internal-social-wallet": "^4.1.1-next.3",
43
- "@rango-dev/widget-embedded": "^0.60.1",
45
+ "@arthur2079/internal-social-wallet": "^5.1.1-next.6",
46
+ "@rango-dev/widget-embedded": "^0.60.2-next.0",
44
47
  "@reduxjs/toolkit": "^1.6.0",
45
48
  "@types/node": "^14.14.31",
46
49
  "@types/react": "^18.0.26",
@@ -50,8 +53,8 @@
50
53
  "rango-types": "^0.5.0"
51
54
  },
52
55
  "peerDependencies": {
53
- "@arthur2079/internal-social-wallet": "^4.1.1-next.3",
54
- "@rango-dev/widget-embedded": "^0.60.1",
56
+ "@arthur2079/internal-social-wallet": "^5.1.1-next.6",
57
+ "@rango-dev/widget-embedded": "^0.60.2-next.0",
55
58
  "@reduxjs/toolkit": "^1.6.0",
56
59
  "axios": "^1.16.0",
57
60
  "immer": "*",
package/CHANGELOG.md DELETED
@@ -1,32 +0,0 @@
1
- ## [0.1.1](https://github.com/rango-exchange/app-v2/compare/internal-profile@0.1.0...internal-profile@0.1.1) (2026-05-18)
2
- # 0.1.0 (2026-05-18)
3
-
4
-
5
- ### Bug Fixes
6
-
7
- * adjust initial and detached modal styles ([c4d57b0](https://github.com/rango-exchange/app-v2/commit/c4d57b0c9be814d88eb31b7ad4da933eaa320141))
8
- * adjust wallet connect modal styles ([c90c2c9](https://github.com/rango-exchange/app-v2/commit/c90c2c97f0238abd1b63478b1426ec0e5158ee8c))
9
- * convert social wallet image URLs from relative to absolute paths ([f84d2d7](https://github.com/rango-exchange/app-v2/commit/f84d2d798c13151c24deae9e0cb231ceaca134dd))
10
- * disable partial state in wallet item on force connect to namespace ([32b4aba](https://github.com/rango-exchange/app-v2/commit/32b4abaf9eb0d93cd069ba04e09a1e1bc82a34a2))
11
- * fix bug in connecting wallet flow in profile wallets ([91ba63c](https://github.com/rango-exchange/app-v2/commit/91ba63c96bd43cf727a6e796e0f40908ad63b775))
12
- * fix widget height in small devices ([3221cf8](https://github.com/rango-exchange/app-v2/commit/3221cf84baad83daab6e74e3c769aa585a944d6a))
13
- * improve profile sign message callback ([77e2686](https://github.com/rango-exchange/app-v2/commit/77e268625d8f7999295b715f74326cd660754c37))
14
- * prevent scroll-to-top on connect wallet and keep modal fixed on scroll ([de6f068](https://github.com/rango-exchange/app-v2/commit/de6f068fdf71a0c0ab8462f1f14239e1e74e8d62))
15
- * remove tailwind classes from profile package components ([9281ab2](https://github.com/rango-exchange/app-v2/commit/9281ab237e219ee4228bbd45e17f6d996dfc9e44))
16
- * resolve connect wallet modal style issues ([746df42](https://github.com/rango-exchange/app-v2/commit/746df4204a898bbe1829903806fc7d3cd50a51c5))
17
- * resolve dependency cycle in http service ([7bfa0ef](https://github.com/rango-exchange/app-v2/commit/7bfa0ef35e71815922d463d6d7c8eb097736ad2a))
18
- * show social wallet intro modal only once ([23c728d](https://github.com/rango-exchange/app-v2/commit/23c728d1d7a116227221f84bf94d10c68d1060bf))
19
-
20
-
21
- ### Features
22
-
23
- * add cosmos to profile as signer ([f26c504](https://github.com/rango-exchange/app-v2/commit/f26c5042c17457a120e6a81e7e2411f819b458f9))
24
- * add error handler to profile sign message ([5d9e13f](https://github.com/rango-exchange/app-v2/commit/5d9e13fd0318853a4c556f136130c7bdae1941ed))
25
- * add intro modal for social wallet ([4665fc6](https://github.com/rango-exchange/app-v2/commit/4665fc6d05a79db7a961ce99c2e5298403eaa347))
26
- * add providers config to Connect Wallets modal props to hide social wallet banners ([482bd82](https://github.com/rango-exchange/app-v2/commit/482bd82e88ccbaf86a14665d8d0f3fee32dfec79))
27
- * add zeta campaign banner and tag ([2189bb1](https://github.com/rango-exchange/app-v2/commit/2189bb130d0fd8f5259c2c8eac30d141153ac7bb))
28
- * enable force connect to namespaces and improve connect wallet modal ([58a76b5](https://github.com/rango-exchange/app-v2/commit/58a76b5e9648b51cdaf09589314c936bb348895f))
29
- * enable force connect to namespaces for social wallet ([2485855](https://github.com/rango-exchange/app-v2/commit/2485855b8650917e0b019d8b4439e688bff9b368))
30
- * enable terra to sign and be merged in profile ([900a898](https://github.com/rango-exchange/app-v2/commit/900a898d99989767f37e26cb056279c9b6b1159a))
31
- * improve social wallet user experience and design ([27e7287](https://github.com/rango-exchange/app-v2/commit/27e7287e768e2248b41ca34106e5ceafd5bb5290))
32
- * upgrade rango dependencies ([1e098cf](https://github.com/rango-exchange/app-v2/commit/1e098cf0abfcb4ab5ce00a3000c72e60a1298a70))
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "include": ["src"],
3
- "exclude": ["node_modules"],
4
-
5
- "compilerOptions": {
6
- "module": "esnext",
7
- "moduleResolution": "bundler",
8
- "target": "ESNext",
9
- "lib": ["dom", "dom.iterable", "esnext", "es6"],
10
- "outDir": "dist",
11
- "rootDir": "./src/",
12
-
13
- "esModuleInterop": true,
14
- "allowSyntheticDefaultImports": true,
15
- "strictNullChecks": true,
16
- "skipLibCheck": true,
17
- "declaration": true,
18
- "strict": true,
19
- "jsx": "react-jsx"
20
- }
21
- }