@arthur2079/internal-profile 0.1.2-next.3 → 0.1.2-next.4

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 (157) hide show
  1. package/package.json +3 -3
  2. package/dist/api/errors.d.ts +0 -3
  3. package/dist/api/errors.js +0 -9
  4. package/dist/api/mod.d.ts +0 -4
  5. package/dist/api/mod.js +0 -2
  6. package/dist/api/request.d.ts +0 -19
  7. package/dist/api/request.js +0 -96
  8. package/dist/api/types.d.ts +0 -193
  9. package/dist/api/types.js +0 -1
  10. package/dist/components/ConnectWalletModal/ConnectWalletFooter.d.ts +0 -5
  11. package/dist/components/ConnectWalletModal/ConnectWalletFooter.js +0 -9
  12. package/dist/components/ConnectWalletModal/ConnectWalletModal.constants.d.ts +0 -5
  13. package/dist/components/ConnectWalletModal/ConnectWalletModal.constants.js +0 -8
  14. package/dist/components/ConnectWalletModal/ConnectWalletModal.d.ts +0 -3
  15. package/dist/components/ConnectWalletModal/ConnectWalletModal.helpers.d.ts +0 -2
  16. package/dist/components/ConnectWalletModal/ConnectWalletModal.helpers.js +0 -9
  17. package/dist/components/ConnectWalletModal/ConnectWalletModal.js +0 -194
  18. package/dist/components/ConnectWalletModal/ConnectWalletModal.styles.d.ts +0 -19
  19. package/dist/components/ConnectWalletModal/ConnectWalletModal.styles.js +0 -101
  20. package/dist/components/ConnectWalletModal/ConnectWalletModal.types.d.ts +0 -44
  21. package/dist/components/ConnectWalletModal/ConnectWalletModal.types.js +0 -1
  22. package/dist/components/ConnectWalletModal/EmptyWalletList.d.ts +0 -2
  23. package/dist/components/ConnectWalletModal/EmptyWalletList.js +0 -9
  24. package/dist/components/ConnectWalletModal/StatefulConnectContainer.d.ts +0 -3
  25. package/dist/components/ConnectWalletModal/StatefulConnectContainer.js +0 -37
  26. package/dist/components/ConnectWalletModal/StatefulConnectContainer.styles.d.ts +0 -1
  27. package/dist/components/ConnectWalletModal/StatefulConnectContainer.styles.js +0 -51
  28. package/dist/components/ConnectWalletModal/StatefulConnectContainer.types.d.ts +0 -12
  29. package/dist/components/ConnectWalletModal/StatefulConnectContainer.types.js +0 -1
  30. package/dist/components/ConnectWalletModal/WalletsChainSelect.d.ts +0 -3
  31. package/dist/components/ConnectWalletModal/WalletsChainSelect.js +0 -87
  32. package/dist/components/ConnectWalletModal/WalletsChainSelect.styles.d.ts +0 -21
  33. package/dist/components/ConnectWalletModal/WalletsChainSelect.styles.js +0 -83
  34. package/dist/components/ConnectWalletModal/WalletsChainSelect.types.d.ts +0 -12
  35. package/dist/components/ConnectWalletModal/WalletsChainSelect.types.js +0 -1
  36. package/dist/components/ConnectWalletModal/index.d.ts +0 -3
  37. package/dist/components/ConnectWalletModal/index.js +0 -2
  38. package/dist/components/ProfileWallet/ProfileWallet.d.ts +0 -3
  39. package/dist/components/ProfileWallet/ProfileWallet.js +0 -54
  40. package/dist/components/ProfileWallet/ProfileWallet.styles.d.ts +0 -6
  41. package/dist/components/ProfileWallet/ProfileWallet.styles.js +0 -54
  42. package/dist/components/ProfileWallet/ProfileWallet.types.d.ts +0 -11
  43. package/dist/components/ProfileWallet/ProfileWallet.types.js +0 -1
  44. package/dist/components/ProfileWallet/index.d.ts +0 -1
  45. package/dist/components/ProfileWallet/index.js +0 -1
  46. package/dist/components/ProfileWallets/ConnectedWallets.d.ts +0 -2
  47. package/dist/components/ProfileWallets/ConnectedWallets.js +0 -25
  48. package/dist/components/ProfileWallets/ConnectedWallets.styles.d.ts +0 -4
  49. package/dist/components/ProfileWallets/ConnectedWallets.styles.js +0 -30
  50. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.d.ts +0 -5
  51. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.js +0 -9
  52. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.styles.d.ts +0 -1
  53. package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.styles.js +0 -8
  54. package/dist/components/ProfileWallets/ProfileWallets.d.ts +0 -4
  55. package/dist/components/ProfileWallets/ProfileWallets.js +0 -37
  56. package/dist/components/ProfileWallets/ProfileWallets.styles.d.ts +0 -5
  57. package/dist/components/ProfileWallets/ProfileWallets.styles.js +0 -17
  58. package/dist/components/ProfileWallets/ProfileWallets.types.d.ts +0 -14
  59. package/dist/components/ProfileWallets/ProfileWallets.types.js +0 -1
  60. package/dist/components/ProfileWallets/index.d.ts +0 -1
  61. package/dist/components/ProfileWallets/index.js +0 -1
  62. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.constants.d.ts +0 -3
  63. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.constants.js +0 -2
  64. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.d.ts +0 -3
  65. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.js +0 -23
  66. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.styles.d.ts +0 -4
  67. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.styles.js +0 -23
  68. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.types.d.ts +0 -23
  69. package/dist/components/ProfileWalletsModal/ProfileWalletsModal.types.js +0 -1
  70. package/dist/components/ProfileWalletsModal/index.d.ts +0 -2
  71. package/dist/components/ProfileWalletsModal/index.js +0 -1
  72. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.d.ts +0 -2
  73. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.js +0 -21
  74. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.styles.d.ts +0 -4
  75. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.styles.js +0 -49
  76. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.types.d.ts +0 -7
  77. package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.types.js +0 -1
  78. package/dist/components/SocialWalletIntroModal/index.d.ts +0 -1
  79. package/dist/components/SocialWalletIntroModal/index.js +0 -1
  80. package/dist/components/StackModal/ModalContainer.d.ts +0 -4
  81. package/dist/components/StackModal/ModalContainer.js +0 -33
  82. package/dist/components/StackModal/ModalContainer.types.d.ts +0 -6
  83. package/dist/components/StackModal/ModalContainer.types.js +0 -1
  84. package/dist/components/StackModal/StackModal.d.ts +0 -3
  85. package/dist/components/StackModal/StackModal.js +0 -90
  86. package/dist/components/StackModal/StackModal.styles.d.ts +0 -2
  87. package/dist/components/StackModal/StackModal.styles.js +0 -77
  88. package/dist/components/StackModal/StackModal.types.d.ts +0 -3
  89. package/dist/components/StackModal/StackModal.types.js +0 -1
  90. package/dist/components/StackModal/index.d.ts +0 -1
  91. package/dist/components/StackModal/index.js +0 -1
  92. package/dist/components/WalletItem/WalletItem.d.ts +0 -3
  93. package/dist/components/WalletItem/WalletItem.js +0 -60
  94. package/dist/components/WalletItem/WalletItem.styles.d.ts +0 -9
  95. package/dist/components/WalletItem/WalletItem.styles.js +0 -71
  96. package/dist/components/WalletItem/WalletItem.types.d.ts +0 -8
  97. package/dist/components/WalletItem/WalletItem.types.js +0 -1
  98. package/dist/components/WalletItem/index.d.ts +0 -1
  99. package/dist/components/WalletItem/index.js +0 -1
  100. package/dist/components/mod.d.ts +0 -5
  101. package/dist/components/mod.js +0 -3
  102. package/dist/constants/errors.d.ts +0 -1
  103. package/dist/constants/errors.js +0 -1
  104. package/dist/constants/events.d.ts +0 -3
  105. package/dist/constants/events.js +0 -3
  106. package/dist/constants/links.d.ts +0 -2
  107. package/dist/constants/links.js +0 -2
  108. package/dist/constants/mod.d.ts +0 -3
  109. package/dist/constants/mod.js +0 -3
  110. package/dist/constants/modals.d.ts +0 -3
  111. package/dist/constants/modals.js +0 -3
  112. package/dist/fetcher.d.ts +0 -3
  113. package/dist/fetcher.js +0 -10
  114. package/dist/hooks/mod.d.ts +0 -4
  115. package/dist/hooks/mod.js +0 -3
  116. package/dist/hooks/useLocalStorage/index.d.ts +0 -1
  117. package/dist/hooks/useLocalStorage/index.js +0 -1
  118. package/dist/hooks/useLocalStorage/useLocalStorage.d.ts +0 -1
  119. package/dist/hooks/useLocalStorage/useLocalStorage.js +0 -24
  120. package/dist/hooks/useProfile/index.d.ts +0 -1
  121. package/dist/hooks/useProfile/index.js +0 -1
  122. package/dist/hooks/useProfile/useProfile.constants.d.ts +0 -2
  123. package/dist/hooks/useProfile/useProfile.constants.js +0 -8
  124. package/dist/hooks/useProfile/useProfile.d.ts +0 -2
  125. package/dist/hooks/useProfile/useProfile.helpers.d.ts +0 -4
  126. package/dist/hooks/useProfile/useProfile.helpers.js +0 -3
  127. package/dist/hooks/useProfile/useProfile.js +0 -20
  128. package/dist/hooks/useProfile/useProfile.types.d.ts +0 -11
  129. package/dist/hooks/useProfile/useProfile.types.js +0 -1
  130. package/dist/hooks/useStackModal.d.ts +0 -38
  131. package/dist/hooks/useStackModal.js +0 -61
  132. package/dist/hooks/useStatefulConnect.d.ts +0 -7
  133. package/dist/hooks/useStatefulConnect.js +0 -15
  134. package/dist/mod.d.ts +0 -1
  135. package/dist/mod.js +0 -1
  136. package/dist/store/helpers.d.ts +0 -9
  137. package/dist/store/helpers.js +0 -69
  138. package/dist/store/middlewares.d.ts +0 -6
  139. package/dist/store/middlewares.js +0 -40
  140. package/dist/store/mod.d.ts +0 -4
  141. package/dist/store/mod.js +0 -3
  142. package/dist/store/selectors.d.ts +0 -47
  143. package/dist/store/selectors.js +0 -21
  144. package/dist/store/slice.d.ts +0 -134
  145. package/dist/store/slice.js +0 -230
  146. package/dist/store/thunks.d.ts +0 -153
  147. package/dist/store/thunks.js +0 -223
  148. package/dist/store/types.d.ts +0 -67
  149. package/dist/store/types.js +0 -1
  150. package/dist/store/utils.d.ts +0 -1
  151. package/dist/store/utils.js +0 -11
  152. package/dist/types.d.ts +0 -3
  153. package/dist/types.js +0 -1
  154. package/dist/utils/mod.d.ts +0 -1
  155. package/dist/utils/mod.js +0 -1
  156. package/dist/utils/wallets.d.ts +0 -16
  157. package/dist/utils/wallets.js +0 -34
@@ -1 +0,0 @@
1
- export { StackModal } from './StackModal';
@@ -1,3 +0,0 @@
1
- import type { WalletItemProps } from './WalletItem.types';
2
- import type { FunctionComponent } from 'react';
3
- export declare const WalletItem: FunctionComponent<WalletItemProps>;
@@ -1,60 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { SOCIAL_WALLET_TYPE } from '@arthur2079/internal-social-wallet';
3
- import { Image, Typography, WalletState } from '@rango-dev/ui';
4
- import { detectInstallLink } from '@rango-dev/wallets-shared';
5
- import { useWallets } from '@rango-dev/widget-embedded';
6
- import { useTranslation } from 'react-i18next';
7
- import { ImageContainer, LogoContainer, logoContainerStyles, Spinner, WalletItemContainer, } from './WalletItem.styles';
8
- export const WalletItem = ({ wallet, handleClick, disabled, disablePartialState, }) => {
9
- const { title, image, link } = wallet;
10
- const { t } = useTranslation();
11
- const { state } = useWallets();
12
- const connecting = wallet.state === WalletState.CONNECTING;
13
- const notInstalled = wallet.state === WalletState.NOT_INSTALLED;
14
- const ParentComp = (props) => {
15
- const containerStyles = {
16
- display: 'flex',
17
- justifyContent: 'flex-start',
18
- textAlign: 'center',
19
- position: 'relative',
20
- // TODO: As this component always receives disabled prop as false, we can remove this
21
- ...(disabled && {
22
- filter: 'grayscale(1)',
23
- pointerEvents: 'none',
24
- }),
25
- };
26
- return notInstalled ? (_jsx("a", { href: detectInstallLink(link), target: "_blank", rel: "noreferrer", style: containerStyles, children: props.children })) : (_jsx("div", { onClick: () => handleClick(wallet), style: containerStyles, children: props.children }));
27
- };
28
- function renderConnectingState() {
29
- return (_jsx(Typography, { variant: "body", size: "xsmall", color: "info500", children: _jsx("b", { children: t('Connecting...') }) }));
30
- }
31
- function renderConnectedState() {
32
- return (_jsx(Typography, { variant: "body", size: "xsmall", color: "success500", children: _jsx("b", { children: t('Connected') }) }));
33
- }
34
- function renderPartiallyConnectedState() {
35
- if (!disablePartialState) {
36
- return (_jsx(Typography, { variant: "body", size: "xsmall", color: "warning500", children: _jsx("b", { children: t('Connected Partially') }) }));
37
- }
38
- const namespacesState = state(wallet.type)?.namespaces;
39
- if (!namespacesState ||
40
- !Array.from(namespacesState.values()).some((namespace) => namespace.connecting)) {
41
- return renderConnectedState();
42
- }
43
- return renderConnectingState();
44
- }
45
- const renderWalletState = () => {
46
- switch (wallet.state) {
47
- case WalletState.NOT_INSTALLED:
48
- return (_jsx(Typography, { variant: "body", size: "xsmall", color: "info500", children: _jsx("b", { children: t('Install') }) }));
49
- case WalletState.DISCONNECTED:
50
- return (_jsx(Typography, { variant: "body", size: "xsmall", color: "neutral600", children: t('Disconnected') }));
51
- case WalletState.CONNECTING:
52
- return renderConnectingState();
53
- case WalletState.PARTIALLY_CONNECTED:
54
- return renderPartiallyConnectedState();
55
- case WalletState.CONNECTED:
56
- return renderConnectedState();
57
- }
58
- };
59
- return (_jsx(ParentComp, { children: _jsxs(WalletItemContainer, { bordered: connecting, children: [_jsxs(LogoContainer, { style: logoContainerStyles, children: [_jsx(ImageContainer, { rounded: wallet.type !== SOCIAL_WALLET_TYPE, children: _jsx(Image, { alt: title, src: image, size: 35 }) }), connecting && _jsx(Spinner, {})] }), _jsx(Typography, { variant: "label", size: "medium", children: title }), renderWalletState()] }) }));
60
- };
@@ -1,9 +0,0 @@
1
- export declare const WalletItemContainer: any;
2
- export declare const LogoContainer: any;
3
- export declare const ImageContainer: any;
4
- export declare const Spinner: any;
5
- export declare const logoContainerStyles: {
6
- margin: string;
7
- marginBottom: string;
8
- borderRadius: string;
9
- };
@@ -1,71 +0,0 @@
1
- import { darkTheme, keyframes, styled } from '@rango-dev/ui';
2
- export const WalletItemContainer = styled('div', {
3
- width: '100%',
4
- position: 'relative',
5
- borderRadius: '$sm',
6
- cursor: 'pointer',
7
- backgroundColor: '$neutral100',
8
- padding: '$10',
9
- display: 'flex',
10
- flexDirection: 'column',
11
- borderWidth: '1px',
12
- borderColor: 'transparent',
13
- [`.${darkTheme} &`]: {
14
- backgroundColor: '$neutral300',
15
- },
16
- variants: {
17
- bordered: {
18
- true: {
19
- borderColor: '$info500',
20
- },
21
- },
22
- },
23
- '&:hover': {
24
- backgroundColor: '$info100',
25
- [`.${darkTheme} &`]: {
26
- backgroundColor: '$neutral100',
27
- },
28
- },
29
- });
30
- export const LogoContainer = styled('div', {
31
- position: 'relative',
32
- });
33
- export const ImageContainer = styled('div', {
34
- borderRadius: '100%',
35
- border: '1.5px transparent solid',
36
- variants: {
37
- rounded: {
38
- true: {
39
- img: {
40
- borderRadius: '100%',
41
- },
42
- },
43
- },
44
- },
45
- });
46
- const spin = keyframes({
47
- '0%': {
48
- transform: 'rotate(0deg)',
49
- },
50
- '100%': {
51
- transform: 'rotate(360deg)',
52
- },
53
- });
54
- export const Spinner = styled('div', {
55
- position: 'absolute',
56
- border: '2px solid rgba(0, 0, 0, 0.1)',
57
- borderTop: '2px solid $info500',
58
- borderRadius: '$lg',
59
- width: '$35',
60
- height: '$35',
61
- animation: `${spin} 1s linear infinite`,
62
- top: 0,
63
- bottom: 0,
64
- right: 0,
65
- left: 0,
66
- });
67
- export const logoContainerStyles = {
68
- margin: '0 auto',
69
- marginBottom: '8px',
70
- borderRadius: '50%',
71
- };
@@ -1,8 +0,0 @@
1
- import type { ExtendedModalWalletInfo } from '../../utils/wallets';
2
- export interface WalletItemProps {
3
- wallet: ExtendedModalWalletInfo;
4
- handleClick: (wallet: ExtendedModalWalletInfo) => void;
5
- disabled: boolean;
6
- /** Reserved for the forcedNamespaces flow; avoid enabling partial state elsewhere. */
7
- disablePartialState?: boolean;
8
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export { WalletItem } from './WalletItem';
@@ -1 +0,0 @@
1
- export { WalletItem } from './WalletItem';
@@ -1,5 +0,0 @@
1
- export { ConnectWalletModal } from './ConnectWalletModal';
2
- export type { ConnectWalletModalProps } from './ConnectWalletModal';
3
- export { ProfileWalletsModal } from './ProfileWalletsModal';
4
- export type { ProfileWalletsModalProps } from './ProfileWalletsModal';
5
- export { StackModal } from './StackModal';
@@ -1,3 +0,0 @@
1
- export { ConnectWalletModal } from './ConnectWalletModal';
2
- export { ProfileWalletsModal } from './ProfileWalletsModal';
3
- export { StackModal } from './StackModal';
@@ -1 +0,0 @@
1
- export declare const DEFAULT_WALLET_INJECTION_ERROR = "Failed to connect to wallet";
@@ -1 +0,0 @@
1
- export const DEFAULT_WALLET_INJECTION_ERROR = 'Failed to connect to wallet';
@@ -1,3 +0,0 @@
1
- export declare const GTMEvents: {
2
- WALLET_FAILED: string;
3
- };
@@ -1,3 +0,0 @@
1
- export const GTMEvents = {
2
- WALLET_FAILED: 'event_wallet_failed',
3
- };
@@ -1,2 +0,0 @@
1
- export declare const TERMS_OF_SERVICE = "https://docs.rango.exchange/terms-of-use";
2
- export declare const PRIVACY_POLICY = "https://docs.rango.exchange/privacy-policy";
@@ -1,2 +0,0 @@
1
- export const TERMS_OF_SERVICE = 'https://docs.rango.exchange/terms-of-use';
2
- export const PRIVACY_POLICY = 'https://docs.rango.exchange/privacy-policy';
@@ -1,3 +0,0 @@
1
- export { STATEFUL_CONNECT_MODAL_ID, CONNECT_WALLETS_MODAL_ID, PROFILE_WALLETS_MODAL_ID, } from './modals';
2
- export { DEFAULT_WALLET_INJECTION_ERROR } from './errors';
3
- export { BLOCKCHAINS_THAT_SUPPORT_PROFILE, WALLETS_WITHOUT_SIGN_MESSAGE_METHOD, } from '../hooks/useProfile/useProfile.constants';
@@ -1,3 +0,0 @@
1
- export { STATEFUL_CONNECT_MODAL_ID, CONNECT_WALLETS_MODAL_ID, PROFILE_WALLETS_MODAL_ID, } from './modals';
2
- export { DEFAULT_WALLET_INJECTION_ERROR } from './errors';
3
- export { BLOCKCHAINS_THAT_SUPPORT_PROFILE, WALLETS_WITHOUT_SIGN_MESSAGE_METHOD, } from '../hooks/useProfile/useProfile.constants';
@@ -1,3 +0,0 @@
1
- export declare const STATEFUL_CONNECT_MODAL_ID = "stateful-connect-modal";
2
- export declare const PROFILE_WALLETS_MODAL_ID = "profile-wallets-modal";
3
- export declare const CONNECT_WALLETS_MODAL_ID = "connect-wallets-modal";
@@ -1,3 +0,0 @@
1
- export const STATEFUL_CONNECT_MODAL_ID = 'stateful-connect-modal';
2
- export const PROFILE_WALLETS_MODAL_ID = 'profile-wallets-modal';
3
- export const CONNECT_WALLETS_MODAL_ID = 'connect-wallets-modal';
package/dist/fetcher.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { AxiosInstance } from 'axios';
2
- export declare function initializeFetcher(instance: AxiosInstance): void;
3
- export declare function fetcher(): AxiosInstance;
package/dist/fetcher.js DELETED
@@ -1,10 +0,0 @@
1
- let fetcherInstance = null;
2
- export function initializeFetcher(instance) {
3
- fetcherInstance = instance;
4
- }
5
- export function fetcher() {
6
- if (!fetcherInstance) {
7
- throw new Error('You are trying to fetch profile data before the fetch instance has been intialized.');
8
- }
9
- return fetcherInstance;
10
- }
@@ -1,4 +0,0 @@
1
- export { useStackModal, MAX_STACK_SIZE, StackModalContextProvider, StackModalContext, } from './useStackModal';
2
- export type { StackItem } from './useStackModal';
3
- export { useStatefulConnect, StatefulConnectContextProvider, StatefulConnectContext, } from './useStatefulConnect';
4
- export { useProfile } from './useProfile';
package/dist/hooks/mod.js DELETED
@@ -1,3 +0,0 @@
1
- export { useStackModal, MAX_STACK_SIZE, StackModalContextProvider, StackModalContext, } from './useStackModal';
2
- export { useStatefulConnect, StatefulConnectContextProvider, StatefulConnectContext, } from './useStatefulConnect';
3
- export { useProfile } from './useProfile';
@@ -1 +0,0 @@
1
- export { useLocalStorage } from './useLocalStorage';
@@ -1 +0,0 @@
1
- export { useLocalStorage } from './useLocalStorage';
@@ -1 +0,0 @@
1
- export declare function useLocalStorage<T>(key: string, initialValue: T): readonly [T, (value: T | ((val: T) => T)) => void];
@@ -1,24 +0,0 @@
1
- import { useState } from 'react';
2
- export function useLocalStorage(key, initialValue) {
3
- const [storedValue, setStoredValue] = useState(() => {
4
- try {
5
- const item = window.localStorage.getItem(key);
6
- return item ? JSON.parse(item) : initialValue;
7
- }
8
- catch (error) {
9
- console.warn(`Error reading localStorage key "${key}":`, error);
10
- return initialValue;
11
- }
12
- });
13
- const setValue = (value) => {
14
- try {
15
- const valueToStore = value instanceof Function ? value(storedValue) : value;
16
- setStoredValue(valueToStore);
17
- window.localStorage.setItem(key, JSON.stringify(valueToStore));
18
- }
19
- catch (error) {
20
- console.warn(`Error setting localStorage key "${key}":`, error);
21
- }
22
- };
23
- return [storedValue, setValue];
24
- }
@@ -1 +0,0 @@
1
- export { useProfile } from './useProfile';
@@ -1 +0,0 @@
1
- export { useProfile } from './useProfile';
@@ -1,2 +0,0 @@
1
- export declare const BLOCKCHAINS_THAT_SUPPORT_PROFILE: string[];
2
- export declare const WALLETS_WITHOUT_SIGN_MESSAGE_METHOD: string[];
@@ -1,8 +0,0 @@
1
- import { Networks } from '@rango-dev/widget-embedded';
2
- export const BLOCKCHAINS_THAT_SUPPORT_PROFILE = [
3
- Networks.ETHEREUM,
4
- Networks.SOLANA,
5
- Networks.COSMOS,
6
- Networks.TERRA,
7
- ];
8
- export const WALLETS_WITHOUT_SIGN_MESSAGE_METHOD = [];
@@ -1,2 +0,0 @@
1
- import type { Params, UseProfile } from './useProfile.types';
2
- export declare function useProfile(params?: Params): UseProfile;
@@ -1,4 +0,0 @@
1
- export declare function hashAccount(account: {
2
- blockchain: string;
3
- address: string;
4
- }): string;
@@ -1,3 +0,0 @@
1
- export function hashAccount(account) {
2
- return `${account.blockchain}-${account.address}`;
3
- }
@@ -1,20 +0,0 @@
1
- import { useWidget } from '@rango-dev/widget-embedded';
2
- import { BLOCKCHAINS_THAT_SUPPORT_PROFILE, WALLETS_WITHOUT_SIGN_MESSAGE_METHOD, } from './useProfile.constants';
3
- import { hashAccount } from './useProfile.helpers';
4
- export function useProfile(params) {
5
- const { wallets: { details: walletsDetails }, } = useWidget();
6
- const hashedAddedAccounts = new Set(params?.addedAccounts?.map(hashAccount));
7
- const compatibleAccounts = walletsDetails
8
- .filter((walletDetail) => BLOCKCHAINS_THAT_SUPPORT_PROFILE.includes(walletDetail.chain) &&
9
- !WALLETS_WITHOUT_SIGN_MESSAGE_METHOD.includes(walletDetail.walletType) &&
10
- !hashedAddedAccounts.has(hashAccount({ blockchain: walletDetail.chain, address: walletDetail.address })))
11
- .map((walletDetail) => ({
12
- address: walletDetail.address,
13
- blockchain: walletDetail.chain,
14
- walletType: walletDetail.walletType,
15
- }));
16
- return {
17
- compatibleAccounts: compatibleAccounts ?? [],
18
- readyToSign: !!compatibleAccounts?.length,
19
- };
20
- }
@@ -1,11 +0,0 @@
1
- import type { ProfileAccount } from '../../api/mod';
2
- export type Params = {
3
- addedAccounts?: {
4
- blockchain: string;
5
- address: string;
6
- }[];
7
- };
8
- export type UseProfile = {
9
- compatibleAccounts: ProfileAccount[];
10
- readyToSign: boolean;
11
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,38 +0,0 @@
1
- import React from 'react';
2
- export type StackItem = {
3
- id: string;
4
- renderContent: (index: number) => React.ReactNode;
5
- onExit?: () => void;
6
- };
7
- type StackModalContextType = {
8
- stack: StackItem[];
9
- setStack: (items: StackItem[] | ((prev: StackItem[]) => StackItem[])) => void;
10
- };
11
- export declare const MAX_STACK_SIZE = 10;
12
- export declare const StackModalContext: React.Context<StackModalContextType>;
13
- export declare const StackModalContextProvider: ({ children }: {
14
- children: React.ReactNode;
15
- }) => import("react/jsx-runtime").JSX.Element;
16
- /**
17
- * Hook for managing a stack of modals
18
- *
19
- * @example
20
- * ```tsx
21
- * const { push, pop, stack } = useStackModal();
22
- *
23
- * const openModal = () => {
24
- * push({
25
- * id: 'my-modal',
26
- * renderContent: (index) => <MyModal index={index} />,
27
- * onExit: () => console.log('Modal closed')
28
- * });
29
- * };
30
- * ```
31
- */
32
- export declare function useStackModal(): {
33
- stack: StackItem[];
34
- push: (item: StackItem) => void;
35
- pop: (count?: number) => void;
36
- clear: () => void;
37
- };
38
- export {};
@@ -1,61 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useCallback, useContext, useMemo, useState } from 'react';
3
- export const MAX_STACK_SIZE = 10;
4
- export const StackModalContext = createContext({
5
- stack: [],
6
- setStack: () => { },
7
- });
8
- export const StackModalContextProvider = ({ children }) => {
9
- const [stack, setStack] = useState([]);
10
- const contextValue = useMemo(() => ({
11
- stack,
12
- setStack,
13
- }), [stack]);
14
- return _jsx(StackModalContext.Provider, { value: contextValue, children: children });
15
- };
16
- /**
17
- * Hook for managing a stack of modals
18
- *
19
- * @example
20
- * ```tsx
21
- * const { push, pop, stack } = useStackModal();
22
- *
23
- * const openModal = () => {
24
- * push({
25
- * id: 'my-modal',
26
- * renderContent: (index) => <MyModal index={index} />,
27
- * onExit: () => console.log('Modal closed')
28
- * });
29
- * };
30
- * ```
31
- */
32
- export function useStackModal() {
33
- const context = useContext(StackModalContext);
34
- if (!context) {
35
- throw new Error('useStackModal must be used within a StackModalContextProvider');
36
- }
37
- const { stack, setStack } = context;
38
- const push = useCallback((item) => {
39
- if (stack.length >= MAX_STACK_SIZE) {
40
- throw new Error('Stack size exceeded');
41
- }
42
- setStack((prevStack) => prevStack.concat(item));
43
- }, [setStack]);
44
- const pop = useCallback((count = 1) => {
45
- setStack((prevStack) => {
46
- if (prevStack.length === 0) {
47
- return prevStack;
48
- }
49
- return prevStack.slice(0, Math.max(prevStack.length - count));
50
- });
51
- }, [setStack]);
52
- const clear = useCallback(() => {
53
- setStack([]);
54
- }, [setStack]);
55
- return {
56
- stack,
57
- push,
58
- pop,
59
- clear,
60
- };
61
- }
@@ -1,7 +0,0 @@
1
- import type { UseStatefulConnect } from '@rango-dev/widget-embedded';
2
- import React from 'react';
3
- export declare const StatefulConnectContext: React.Context<UseStatefulConnect | null>;
4
- export declare const StatefulConnectContextProvider: ({ children }: {
5
- children: React.ReactNode;
6
- }) => import("react/jsx-runtime").JSX.Element;
7
- export declare const useStatefulConnect: () => UseStatefulConnect;
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useStatefulConnect as widgetUseStatefulConnect } from '@rango-dev/widget-embedded';
3
- import { createContext, useContext } from 'react';
4
- export const StatefulConnectContext = createContext(null);
5
- export const StatefulConnectContextProvider = ({ children }) => {
6
- const statefulConnect = widgetUseStatefulConnect();
7
- return (_jsx(StatefulConnectContext.Provider, { value: statefulConnect, children: children }));
8
- };
9
- export const useStatefulConnect = () => {
10
- const context = useContext(StatefulConnectContext);
11
- if (!context) {
12
- throw new Error('useStatefulConnect must be used within a StatefulConnectContextProvider');
13
- }
14
- return context;
15
- };
package/dist/mod.d.ts DELETED
@@ -1 +0,0 @@
1
- export { initializeFetcher } from './fetcher';
package/dist/mod.js DELETED
@@ -1 +0,0 @@
1
- export { initializeFetcher } from './fetcher';
@@ -1,9 +0,0 @@
1
- import { type BlockchainMeta } from 'rango-types';
2
- export declare function getProfileType(isPublic: boolean): 'public' | 'private';
3
- export declare function throwIfAborted(signal: AbortSignal): void;
4
- export declare function getErrorMessage(error: unknown): string;
5
- export declare function loadState<T>(key: string): T | undefined;
6
- export declare function saveState(key: string, state: unknown): void;
7
- export declare function extractPublickKeyFromCosmosInstance(walletType: string, options: {
8
- blockchainMeta: BlockchainMeta;
9
- }): Promise<string | undefined>;
@@ -1,69 +0,0 @@
1
- import { TransactionType } from 'rango-types';
2
- export function getProfileType(isPublic) {
3
- return isPublic ? 'public' : 'private';
4
- }
5
- // These functions have been copy/pasted from `apps/rango/utils/Errors.ts` to avoid creating a third package to share these logic.
6
- export function throwIfAborted(signal) {
7
- if (signal.aborted) {
8
- throw new Error('Operation canceled');
9
- }
10
- }
11
- export function getErrorMessage(error) {
12
- return error instanceof Error ? error.message : 'Something went wrong. Please try again.';
13
- }
14
- export function loadState(key) {
15
- // For avoiding run in SSR
16
- if (typeof window === 'undefined') {
17
- return;
18
- }
19
- try {
20
- const serializedState = localStorage.getItem(key);
21
- if (serializedState === null) {
22
- return undefined;
23
- }
24
- return JSON.parse(serializedState);
25
- }
26
- catch (err) {
27
- console.error('Could not load state', err);
28
- return undefined;
29
- }
30
- }
31
- export function saveState(key, state) {
32
- // For avoiding run in SSR
33
- if (typeof window === 'undefined') {
34
- return;
35
- }
36
- try {
37
- const serializedState = JSON.stringify(state);
38
- localStorage.setItem(key, serializedState);
39
- }
40
- catch (err) {
41
- console.error('Could not save state', err);
42
- }
43
- }
44
- function getKnownCosmosInstancesFromWindow() {
45
- // @ts-expect-error-next-line
46
- const { xfi, keplr } = window;
47
- if (xfi?.keplr) {
48
- return xfi.keplr;
49
- }
50
- else if (keplr) {
51
- return keplr;
52
- }
53
- return undefined;
54
- }
55
- // We have a few wallets that supports for Cosmos, this is a workaround to use them directly, instead of using it through our wallet management.
56
- export async function extractPublickKeyFromCosmosInstance(walletType, options) {
57
- const bytesToB64 = (u8) => btoa(String.fromCharCode(...(u8 instanceof Uint8Array ? u8 : new Uint8Array(u8))));
58
- if (options.blockchainMeta.type === TransactionType.COSMOS) {
59
- const instance = getKnownCosmosInstancesFromWindow();
60
- if (!instance) {
61
- throw new Error(`Your wallet (${walletType}) doesn't support expected interface. Please use Keplr instead.`);
62
- }
63
- const key = await instance.getKey(options.blockchainMeta.chainId);
64
- const pubKeyCompressed = key.pubKey;
65
- const pubKeyBase64 = bytesToB64(pubKeyCompressed);
66
- return pubKeyBase64;
67
- }
68
- return undefined;
69
- }
@@ -1,6 +0,0 @@
1
- import type { RootStateLike } from './slice';
2
- import type { Middleware } from '@reduxjs/toolkit';
3
- export declare const AUTH_PERSIST_KEY = "isLoggedIn";
4
- export declare const PROFILE_PERSIST_KEY = "profile";
5
- export declare const loadPersistedState: () => Partial<RootStateLike>;
6
- export declare const persistProfileState: Middleware<object, RootStateLike>;
@@ -1,40 +0,0 @@
1
- import { loadState, saveState } from './helpers';
2
- import { profileSliceInitialState } from './slice';
3
- import { createFetchProfileSummary, createRequestLogOutUser, createSignMessage } from './thunks';
4
- const signMessage = createSignMessage();
5
- const fetchProfileSummary = createFetchProfileSummary();
6
- const requestLogOutUser = createRequestLogOutUser();
7
- export const AUTH_PERSIST_KEY = 'isLoggedIn';
8
- export const PROFILE_PERSIST_KEY = 'profile';
9
- export const loadPersistedState = () => {
10
- const initialState = { ...profileSliceInitialState };
11
- const authState = loadState(AUTH_PERSIST_KEY);
12
- const profileDataState = loadState(PROFILE_PERSIST_KEY);
13
- if (authState) {
14
- initialState.isLoggedIn = authState;
15
- }
16
- if (profileDataState?.username) {
17
- initialState.username = profileDataState.username;
18
- }
19
- return { profile: initialState };
20
- };
21
- export const persistProfileState = (store) => (next) => (action) => {
22
- const prevState = store.getState();
23
- const returnValue = next(action);
24
- const nextState = store.getState();
25
- const shouldPersistAuthState = prevState.profile.isLoggedIn !== nextState.profile.isLoggedIn;
26
- const shouldPersistProfileData =
27
- // @ts-expect-error to have correct type for action.meta, instead of `action: ProfileSliceActions` we need to have access full store's actions. specificly meta slice.
28
- (fetchProfileSummary.fulfilled.match(action) && !action.meta.arg.public) ||
29
- signMessage.fulfilled.match(action) ||
30
- requestLogOutUser.fulfilled.match(action);
31
- if (shouldPersistAuthState) {
32
- const state = store.getState().profile.isLoggedIn;
33
- saveState(AUTH_PERSIST_KEY, state);
34
- }
35
- if (shouldPersistProfileData) {
36
- const username = store.getState().profile.profileSummary.private.data?.username;
37
- saveState(PROFILE_PERSIST_KEY, { username });
38
- }
39
- return returnValue;
40
- };
@@ -1,4 +0,0 @@
1
- export { profileSliceInitialState, createProfileState } from './slice';
2
- export { showPrivateProfileSelector, profileSummarySelector, authenticatedProfileSelector, privateProfileSummarySelector, isLoggedInProfileSelector, usernameProfileSelector, } from './selectors';
3
- export type { SignMessageParams, ProfileState } from './types';
4
- export { persistProfileState, loadPersistedState, AUTH_PERSIST_KEY, PROFILE_PERSIST_KEY, } from './middlewares';
package/dist/store/mod.js DELETED
@@ -1,3 +0,0 @@
1
- export { profileSliceInitialState, createProfileState } from './slice';
2
- export { showPrivateProfileSelector, profileSummarySelector, authenticatedProfileSelector, privateProfileSummarySelector, isLoggedInProfileSelector, usernameProfileSelector, } from './selectors';
3
- export { persistProfileState, loadPersistedState, AUTH_PERSIST_KEY, PROFILE_PERSIST_KEY, } from './middlewares';