@getpara/react-sdk 1.1.0 → 1.3.0

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 (146) hide show
  1. package/dist/MoonPayEmbed-GAWXP6V7.js +2 -0
  2. package/dist/MoonPayEmbed-GAWXP6V7.js.br +0 -0
  3. package/dist/MoonPayEmbed-GAWXP6V7.js.gz +0 -0
  4. package/dist/index.js +675 -5
  5. package/dist/index.js.br +0 -0
  6. package/dist/index.js.gz +0 -0
  7. package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
  8. package/dist/provider/stores/useStore.d.ts +7 -2
  9. package/dist/provider/types/provider.d.ts +15 -3
  10. package/package.json +8 -7
  11. package/dist/modal/ParaModal.js +0 -281
  12. package/dist/modal/components/Account/Account.js +0 -60
  13. package/dist/modal/components/AddFunds/AddFunds.js +0 -147
  14. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
  15. package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
  16. package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
  17. package/dist/modal/components/AddFunds/index.js +0 -3
  18. package/dist/modal/components/AuthInput/AuthInput.js +0 -221
  19. package/dist/modal/components/AuthInput/countryCodes.js +0 -40
  20. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
  21. package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
  22. package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
  23. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
  24. package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
  25. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
  26. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
  27. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
  28. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
  29. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
  30. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
  31. package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
  32. package/dist/modal/components/Body/Body.js +0 -232
  33. package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
  34. package/dist/modal/components/ChainSwitch/config.js +0 -11
  35. package/dist/modal/components/Controls/Controls.js +0 -54
  36. package/dist/modal/components/Controls/Selects.js +0 -159
  37. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
  38. package/dist/modal/components/ExternalWalletStep/config.js +0 -11
  39. package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
  40. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
  41. package/dist/modal/components/Footer/Footer.js +0 -71
  42. package/dist/modal/components/Header/Header.js +0 -24
  43. package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
  44. package/dist/modal/components/Hero/Hero.js +0 -119
  45. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
  46. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
  47. package/dist/modal/components/ModalContent/ModalContent.js +0 -280
  48. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -82
  49. package/dist/modal/components/OAuth/OAuth.js +0 -125
  50. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
  51. package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
  52. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
  53. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
  54. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
  55. package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
  56. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
  57. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
  58. package/dist/modal/components/Waiting/Waiting.js +0 -6
  59. package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
  60. package/dist/modal/components/WalletCard/WalletCard.js +0 -93
  61. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
  62. package/dist/modal/components/common.js +0 -67
  63. package/dist/modal/components/index.js +0 -1
  64. package/dist/modal/constants/constants.js +0 -93
  65. package/dist/modal/constants/defaults.js +0 -5
  66. package/dist/modal/constants/oAuthLogos.js +0 -18
  67. package/dist/modal/hooks/useActiveWallet.js +0 -11
  68. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
  69. package/dist/modal/hooks/useGoBack.js +0 -34
  70. package/dist/modal/index.js +0 -9
  71. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
  72. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
  73. package/dist/modal/providers/ExternalWalletContext.js +0 -253
  74. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
  75. package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
  76. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
  77. package/dist/modal/stores/index.js +0 -3
  78. package/dist/modal/stores/modal/actions.js +0 -64
  79. package/dist/modal/stores/modal/useModalStore.js +0 -41
  80. package/dist/modal/stores/para/actions.js +0 -5
  81. package/dist/modal/stores/para/useParaStore.js +0 -3
  82. package/dist/modal/stores/theme/actions.js +0 -24
  83. package/dist/modal/stores/theme/useThemeStore.js +0 -14
  84. package/dist/modal/stores/userInfo/actions.js +0 -34
  85. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
  86. package/dist/modal/types/commonTypes.js +0 -1
  87. package/dist/modal/types/externalWallets.js +0 -21
  88. package/dist/modal/types/modalProps.js +0 -7
  89. package/dist/modal/utils/authLayoutHelpers.js +0 -2
  90. package/dist/modal/utils/getMailtoLink.js +0 -5
  91. package/dist/modal/utils/getTileButtonFlex.js +0 -15
  92. package/dist/modal/utils/isPasskeySupported.js +0 -10
  93. package/dist/modal/utils/openPopup.js +0 -55
  94. package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
  95. package/dist/modal/utils/steps.js +0 -215
  96. package/dist/modal/utils/stringFormatters.js +0 -12
  97. package/dist/modal/utils/validateOnRampConfig.js +0 -26
  98. package/dist/provider/ParaProvider.js +0 -16
  99. package/dist/provider/actions/checkIfUserExists.js +0 -26
  100. package/dist/provider/actions/createUser.js +0 -30
  101. package/dist/provider/actions/getAccount.js +0 -24
  102. package/dist/provider/actions/getWallet.js +0 -16
  103. package/dist/provider/actions/initiateLogin.js +0 -23
  104. package/dist/provider/actions/keepSessionAlive.js +0 -23
  105. package/dist/provider/actions/logout.js +0 -20
  106. package/dist/provider/actions/signMessage.js +0 -23
  107. package/dist/provider/actions/signTransaction.js +0 -23
  108. package/dist/provider/actions/waitForAccountCreation.js +0 -24
  109. package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
  110. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
  111. package/dist/provider/hooks/index.js +0 -3
  112. package/dist/provider/hooks/mutations/index.js +0 -10
  113. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  114. package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
  115. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  116. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
  117. package/dist/provider/hooks/mutations/useLogout.js +0 -33
  118. package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
  119. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
  120. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  121. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  122. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  123. package/dist/provider/hooks/queries/index.js +0 -2
  124. package/dist/provider/hooks/queries/useAccount.js +0 -23
  125. package/dist/provider/hooks/queries/useWallet.js +0 -24
  126. package/dist/provider/hooks/utils/index.js +0 -3
  127. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
  128. package/dist/provider/hooks/utils/useClient.js +0 -8
  129. package/dist/provider/hooks/utils/useEventListeners.js +0 -87
  130. package/dist/provider/hooks/utils/useInternalClient.js +0 -9
  131. package/dist/provider/hooks/utils/useModal.js +0 -15
  132. package/dist/provider/hooks/utils/useWalletState.js +0 -33
  133. package/dist/provider/index.js +0 -3
  134. package/dist/provider/stores/getters.js +0 -5
  135. package/dist/provider/stores/slices/client.js +0 -4
  136. package/dist/provider/stores/slices/index.js +0 -3
  137. package/dist/provider/stores/slices/modal.js +0 -4
  138. package/dist/provider/stores/slices/wallet.js +0 -6
  139. package/dist/provider/stores/types.js +0 -1
  140. package/dist/provider/stores/useStore.js +0 -12
  141. package/dist/provider/types/provider.js +0 -1
  142. package/dist/provider/types/query.js +0 -1
  143. package/dist/provider/types/utils.js +0 -1
  144. package/dist/provider/utils/renameMutations.js +0 -19
  145. /package/dist/{modal/css → css}/modal.css +0 -0
  146. /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
@@ -1,77 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from '@getpara/react-components';
12
- import { CenteredText, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
13
- import { useEffect, useMemo } from 'react';
14
- import { useModalStore } from '../../stores/index.js';
15
- import styled from 'styled-components';
16
- import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
17
- import { useCopyToClipboard } from '@getpara/react-common';
18
- import { ModalStep } from '../../utils/steps.js';
19
- import { routeMobileExternalWallet } from '../../utils/routeMobileExternalWallet.js';
20
- import { NETWORK_NOT_SUPPORTED_ERROR } from '../../constants/constants.js';
21
- import { WalletType } from '@getpara/web-sdk';
22
- export const ChainSwitch = () => {
23
- const [isCopied, copy] = useCopyToClipboard();
24
- const externalWalletError = useModalStore(state => state.externalWalletError);
25
- const setStep = useModalStore(state => state.setStep);
26
- const setStepDirection = useModalStore(state => state.setStepDirection);
27
- const { switchChain, wallet, qrUri, chainIdSwitchingTo, walletDisplayHelpers } = useExternalWallets();
28
- useEffect(() => {
29
- if ((wallet === null || wallet === void 0 ? void 0 : wallet.type) === WalletType.COSMOS) {
30
- routeMobileExternalWallet(qrUri);
31
- }
32
- }, [qrUri, wallet]);
33
- useEffect(() => {
34
- if (!wallet) {
35
- setStepDirection(-1);
36
- setStep(ModalStep.ACCOUNT_MAIN);
37
- }
38
- }, [wallet]);
39
- const handleTryAgainClick = () => __awaiter(void 0, void 0, void 0, function* () {
40
- if (chainIdSwitchingTo) {
41
- yield switchChain(chainIdSwitchingTo);
42
- }
43
- });
44
- const handleCopy = () => {
45
- copy(qrUri);
46
- };
47
- const Content = useMemo(() => {
48
- var _a;
49
- if (!wallet) {
50
- return null;
51
- }
52
- const { isCosmosMobileWallet } = walletDisplayHelpers;
53
- if (isCosmosMobileWallet) {
54
- return (_jsx(_Fragment, { children: _jsxs(InnerStepContainer, { children: [_jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device to switch networks" }), _jsx(QRContainer, { children: !qrUri ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }), _jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [_jsx(CpslIcon, { slot: "start", icon: isCopied ? 'check' : 'copy' }), isCopied ? 'Copied' : 'Copy Link'] })] }) }));
55
- }
56
- return (_jsxs(InnerStepContainer, { children: [!(externalWalletError === null || externalWalletError === void 0 ? void 0 : externalWalletError.length) ? (_jsx(CenteredText, { color: "contrast", weight: "semiBold", children: `Confirm the request to change networks in your ${wallet.name} wallet.` })) : (_jsxs(_Fragment, { children: [_jsxs(ErrorContainer, { children: [_jsx(ErrorIcon, { icon: "alertCircle" }), _jsx(CenteredText, { weight: "semiBold", color: "error", children: externalWalletError[0] })] }), externalWalletError[1] && (_jsx(CenteredText, { color: "secondary", weight: "medium", children: externalWalletError[1] }))] })), ((_a = externalWalletError === null || externalWalletError === void 0 ? void 0 : externalWalletError[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== NETWORK_NOT_SUPPORTED_ERROR && (_jsxs(CpslButton, { variant: "secondary", onClick: handleTryAgainClick, children: [_jsx(CpslIcon, { slot: "start", icon: "refresh" }), "Try Again"] }))] }));
57
- }, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
58
- if (!wallet) {
59
- return null;
60
- }
61
- return _jsx(Container, { children: Content });
62
- };
63
- const Container = styled(StepContainer) `
64
- flex: 1;
65
- justify-content: space-between;
66
- `;
67
- const ErrorContainer = styled.div `
68
- display: flex;
69
- align-items: center;
70
- justify-content: center;
71
- gap: 4px;
72
- `;
73
- const ErrorIcon = styled(CpslIcon) `
74
- --height: 16px;
75
- --width: 16px;
76
- --icon-color: var(--cpsl-color-text-error);
77
- `;
@@ -1,11 +0,0 @@
1
- export var TabValue;
2
- (function (TabValue) {
3
- TabValue["extension"] = "extension";
4
- TabValue["mobile"] = "mobile";
5
- TabValue["web"] = "web";
6
- })(TabValue || (TabValue = {}));
7
- export const TABS = {
8
- extension: { label: 'Extension', value: TabValue.extension, icon: 'puzzlePiece' },
9
- mobile: { label: 'Mobile', value: TabValue.mobile, icon: 'phone' },
10
- web: { label: 'Web', value: TabValue.web, icon: 'globe' },
11
- };
@@ -1,54 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CpslIcon } from '@getpara/react-components';
3
- import { styled } from 'styled-components';
4
- import { useModalStore } from '../../stores/index.js';
5
- import { useThemeStore } from '../../stores/theme/useThemeStore.js';
6
- import { useGoBack } from '../../hooks/useGoBack.js';
7
- import { AccountSelect, ChainSelect } from './Selects.js';
8
- import { ModalStep } from '../../utils/steps.js';
9
- import { HeaderButton } from '@getpara/react-common';
10
- export const Controls = ({ onClose }) => {
11
- const bareModal = useThemeStore(state => state.bareModal);
12
- const hasPreviousStep = useModalStore(state => state.hasPreviousStep());
13
- const step = useModalStore(state => state.step);
14
- const isFullyLoggedIn = useModalStore(state => state.isFullyLoggedIn);
15
- const goBack = useGoBack();
16
- const shouldShowSelects = [
17
- ModalStep.ACCOUNT_MAIN,
18
- ModalStep.CHAIN_SWITCH,
19
- ModalStep.ADD_FUNDS_BUY,
20
- ModalStep.ADD_FUNDS_RECEIVE,
21
- ModalStep.ADD_FUNDS_WITHDRAW,
22
- ].includes(step);
23
- const handleBackClick = () => {
24
- goBack();
25
- };
26
- return (_jsxs(Container, { children: [_jsx(BackButton, { variant: "ghost", style: {
27
- visibility: hasPreviousStep ? 'visible' : 'hidden',
28
- }, onClick: handleBackClick, children: _jsx(CpslIcon, { icon: "arrow" }) }), _jsx(MiddleContainer, { children: shouldShowSelects && isFullyLoggedIn && (_jsxs(_Fragment, { children: [_jsx(ChainSelect, {}), _jsx(AccountSelect, {})] })) }), _jsx(CloseButton, { bareModal: bareModal, variant: "ghost", onClick: onClose, children: _jsx(CpslIcon, { icon: "close" }) })] }));
29
- };
30
- const Container = styled.div `
31
- position: absolute;
32
- width: 100%;
33
- top: 16px;
34
-
35
- z-index: 3;
36
- display: flex;
37
- align-items: center;
38
- justify-content: space-between;
39
- gap: 8px;
40
- `;
41
- const MiddleContainer = styled.div `
42
- flex: 1;
43
- display: flex;
44
- align-items: center;
45
- justify-content: center;
46
- gap: 4px;
47
- `;
48
- const CloseButton = styled(HeaderButton) `
49
- transform: rotate(180deg);
50
- visibility: ${({ bareModal }) => (bareModal ? 'hidden' : 'visible')};
51
- `;
52
- const BackButton = styled(HeaderButton) `
53
- transform: rotate(180deg);
54
- `;
@@ -1,159 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { CpslIdenticon, CpslSelect, CpslSelectItem, CpslText } from '@getpara/react-components';
12
- import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
13
- import styled from 'styled-components';
14
- import { useThemeStore } from '../../stores/index.js';
15
- import { truncateAddress, WalletType } from '@getpara/web-sdk';
16
- import { useEffect, useRef } from 'react';
17
- import { useDropdownPosition } from '../AuthInput/hooks/useDropdownPosition.js';
18
- import { MOBILE_SIZE } from '../../constants/constants.js';
19
- import { useActiveWallet } from '../../hooks/useActiveWallet.js';
20
- import { useWalletState } from '../../../provider/index.js';
21
- import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
22
- const getValue = (id, type) => {
23
- return id && type ? `${id}~${type}` : undefined;
24
- };
25
- const WALLET_TYPES = {
26
- [WalletType.EVM]: 'EVM',
27
- [WalletType.SOLANA]: 'Solana',
28
- [WalletType.COSMOS]: 'Cosmos',
29
- };
30
- export const ChainSelect = () => {
31
- var _a, _b;
32
- const containerRef = useRef(null);
33
- const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
34
- const activeWallet = useActiveWallet();
35
- const { switchChain, chainId, chains, chainIdSwitchingTo } = useExternalWallets();
36
- useEffect(() => {
37
- if (dropdownMaxHeight && chainId) {
38
- resize();
39
- }
40
- }, [chainId, chainIdSwitchingTo, dropdownMaxHeight]);
41
- const handleChainChange = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
42
- yield switchChain(chainId);
43
- });
44
- if (!activeWallet || !activeWallet.isExternal || activeWallet.type === WalletType.SOLANA) {
45
- return null;
46
- }
47
- const chainIdToUse = chainIdSwitchingTo !== null && chainIdSwitchingTo !== void 0 ? chainIdSwitchingTo : chainId;
48
- const selectedChainName = (_a = chains.find(c => c.id.toString() === chainIdToUse)) === null || _a === void 0 ? void 0 : _a.name;
49
- return (_jsx(Container, { children: _jsx(SelectContainer, { ref: containerRef, id: "inputContainer", children: _jsxs(StyledSelect, { selectedValue: (_b = chainIdToUse === null || chainIdToUse === void 0 ? void 0 : chainIdToUse.toString()) !== null && _b !== void 0 ? _b : '', onCpslSelectValueChange: e => {
50
- handleChainChange(e.detail);
51
- }, showFormattedSelectedItem: true, placeholder: "Choose chain...", anchorElId: "inputContainer", dropdownMaxHeight: dropdownMaxHeight, "$width": dropdownWidth, "$top": mobileAnchor + 16 + 1, autoWidth: true, selectedItemVariant: "bodyXS", children: [chainIdToUse && (_jsx(ChainName, { variant: "bodyXS", color: "contrast", slot: "selected-item", children: selectedChainName })), chains === null || chains === void 0 ? void 0 : chains.map(chain => (_jsx(StyledSelectItem, { slot: "items", value: chain.id.toString(), children: _jsx(ChainName, { variant: "bodyXS", color: "contrast", children: chain.name }) }, chain.id)))] }) }) }));
52
- };
53
- function getName(para, { type, isExternal, name, isMenu = false, hideWallets = false, }) {
54
- if (para.isMultiWallet) {
55
- return (name !== null && name !== void 0 ? name : `${isExternal ? 'External ' : ''}${WALLET_TYPES[type]}${!hideWallets && (isMenu || isExternal) ? ' Wallet' : ''}`);
56
- }
57
- return hideWallets ? 'My Account' : name || 'My Wallet';
58
- }
59
- export const AccountSelect = () => {
60
- const hideWallets = useThemeStore(state => state.hideWallets);
61
- const para = useInternalClient();
62
- const containerRef = useRef(null);
63
- const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
64
- const { setSelectedWallet } = useWalletState();
65
- const activeWallet = useActiveWallet();
66
- const ActiveWalletNode = activeWallet ? (_jsxs(FlexRow, { slot: "selected-item", children: [_jsx(CpslIdenticon, { variant: "avatar", size: "14px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }), _jsx(WalletName, { variant: "bodyXS", color: "contrast", children: getName(para, Object.assign(Object.assign({}, activeWallet), { hideWallets })) }), !hideWallets && (_jsx(CpslText, { variant: "bodyXS", color: "secondary", children: para.getDisplayAddress(activeWallet.id, { truncate: true, addressType: activeWallet.type }) }))] })) : null;
67
- useEffect(() => {
68
- if (dropdownMaxHeight && (activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.address)) {
69
- resize();
70
- }
71
- }, [activeWallet, para.availableWallets, dropdownMaxHeight]);
72
- return (_jsx(Container, { children: _jsx(SelectContainer, { ref: containerRef, id: "addressInputContainer", children: para.availableWallets.length > 1 ? (_jsxs(StyledSelect, { selectedValue: getValue(activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.id, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type), onCpslSelectValueChange: e => {
73
- const [id, type] = e.detail.split('~');
74
- setSelectedWallet({ id, type: type });
75
- }, showFormattedSelectedItem: true, placeholder: "Choose wallet...", anchorElId: "addressInputContainer", dropdownMaxHeight: dropdownMaxHeight, "$width": dropdownWidth, "$top": mobileAnchor + 16 + 1, autoWidth: true, selectedItemVariant: "bodyXS", children: [activeWallet && ActiveWalletNode, para.availableWallets.map(({ address, name: _name, id, type, isExternal }) => {
76
- const key = getValue(id, type);
77
- const name = _name !== null && _name !== void 0 ? _name : getName(para, { type, isExternal, isMenu: true, hideWallets });
78
- return (_jsx(StyledSelectItem, { slot: "items", value: key, children: _jsxs(FlexRow, { children: [_jsx(CpslIdenticon, { size: "40px", hash: para.getIdenticonHash(id, type) }), _jsxs(FlexCol, { children: [name && (_jsx(CpslText, { variant: "bodyS", color: "contrast", children: name })), !hideWallets && (_jsx(CpslText, { variant: "bodyXS", color: "secondary", children: truncateAddress(address, type, { prefix: para.cosmosPrefix }) }))] })] }) }, key));
79
- })] })) : (ActiveWalletNode) }) }));
80
- };
81
- const Container = styled.div `
82
- flex: 0;
83
- width: 100%;
84
- display: flex;
85
- justify-content: center;
86
- `;
87
- const FlexRow = styled.div `
88
- display: flex;
89
- align-items: center;
90
- gap: 8px;
91
- `;
92
- const FlexCol = styled.div `
93
- display: flex;
94
- flex-direction: column;
95
- align-items: flex-start;
96
- `;
97
- const WalletName = styled(CpslText) `
98
- white-space: nowrap;
99
- `;
100
- const SelectContainer = styled.div `
101
- position: relative;
102
- display: flex;
103
- align-items: center;
104
- gap: 8px;
105
- border-radius: 1000px;
106
- background-color: var(--cpsl-color-background-8);
107
- padding: 8px;
108
- `;
109
- const ChainName = styled(CpslText) `
110
- max-width: 150px;
111
- text-transform: capitalize;
112
-
113
- &::part(text-element) {
114
- white-space: nowrap;
115
- text-overflow: ellipsis;
116
- overflow: hidden;
117
- }
118
- `;
119
- const StyledSelect = styled(CpslSelect) `
120
- --container-height: auto;
121
- --container-border-width: 0px;
122
- --container-padding-end: 0px;
123
- --container-padding-start: 0px;
124
- --container-background-color: transparent;
125
- --container-box-shadow: none;
126
- --container-gap: 2px;
127
- --icon-width: 16px;
128
- --icon-height: 16px;
129
-
130
- &::part(selected-text) {
131
- white-space: nowrap;
132
- }
133
-
134
- &::part(dropdown) {
135
- min-width: ${({ $width }) => `${$width - 2}px`};
136
- }
137
-
138
- &::part(popover) {
139
- /* Have to adjust the top of the popover here since we're using a transform on the modal which causes fixed position items to not be relative to the viewport */
140
- @media (max-width: ${MOBILE_SIZE}px) {
141
- top: ${({ $top }) => ($top ? `${$top}px` : '0px')};
142
- bottom: 16px;
143
- }
144
- cpsl-auth-modal.force-mobile-media & {
145
- top: ${({ $top }) => ($top ? `${$top}px` : '0px')};
146
- bottom: 16px;
147
- }
148
- }
149
-
150
- &::part(icon) {
151
- --icon-color: var(--cpsl-color-contrast);
152
- }
153
- `;
154
- const StyledSelectItem = styled(CpslSelectItem) `
155
- --outer-container-padding-start: 4px;
156
- --outer-container-padding-end: 4px;
157
- --outer-container-padding-top: 4px;
158
- --outer-container-padding-bottom: 4px;
159
- `;
@@ -1,116 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from '@getpara/react-components';
12
- import { CenteredText, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
13
- import { useEffect, useMemo } from 'react';
14
- import { useModalStore } from '../../stores/index.js';
15
- import styled from 'styled-components';
16
- import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
17
- import { useCopyToClipboard } from '@getpara/react-common';
18
- import { ModalStep } from '../../utils/steps.js';
19
- import { isMobile, isTablet, WalletType } from '@getpara/web-sdk';
20
- import { routeMobileExternalWallet } from '../../utils/routeMobileExternalWallet.js';
21
- export const ExternalWalletStep = () => {
22
- const [isCopied, copy] = useCopyToClipboard();
23
- const externalWalletError = useModalStore(state => state.externalWalletError);
24
- const setStep = useModalStore(state => state.setStep);
25
- const { connectExternalWallet, wallet, qrUri, walletDisplayHelpers } = useExternalWallets();
26
- useEffect(() => {
27
- routeMobileExternalWallet(qrUri);
28
- }, [qrUri]);
29
- const handleTryAgainClick = () => __awaiter(void 0, void 0, void 0, function* () {
30
- yield connectExternalWallet(wallet);
31
- });
32
- const handleCopy = () => {
33
- copy(qrUri);
34
- };
35
- const Content = useMemo(() => {
36
- var _a, _b, _c;
37
- if (!wallet) {
38
- return null;
39
- }
40
- const isWalletConnect = wallet.id === 'walletConnect';
41
- const isMobileWalletConnect = isMobile() && isWalletConnect;
42
- if (isMobileWalletConnect) {
43
- _jsx(InnerStepContainer, { children: _jsx(Text, { weight: "semiBold", children: "Continue in the WalletConnect modal." }) });
44
- }
45
- const { showExtension, showMobile, isSolanaMobileIOS } = walletDisplayHelpers;
46
- // Fallback to not supported text
47
- if ((!showMobile && !showExtension) || (isSolanaMobileIOS && !wallet.installed)) {
48
- const text = isSolanaMobileIOS
49
- ? "Solana wallets aren't available on mobile IOS browsers.\n\nPlease continue in the wallet app."
50
- : `${wallet.name} isn't supported on mobile devices.\n\nPlease choose another wallet or continue on desktop.`;
51
- return (_jsx(InnerStepContainer, { children: _jsx(Text, { weight: "semiBold", children: text }) }));
52
- }
53
- if (showExtension) {
54
- const isInstalled = wallet.installed;
55
- return (_jsxs(InnerStepContainer, { children: [isInstalled && !(externalWalletError === null || externalWalletError === void 0 ? void 0 : externalWalletError.length) ? (_jsx(CenteredText, { color: "contrast", weight: "semiBold", children: `Confirm connection request in the ${wallet.name} browser extension.` })) : (_jsxs(ErrorContainer, { children: [_jsx(ErrorIcon, { icon: "alertCircle" }), _jsx(CpslText, { weight: "semiBold", color: "error", children: isInstalled ? externalWalletError === null || externalWalletError === void 0 ? void 0 : externalWalletError[0] : `${wallet.name} not detected` })] })), _jsxs(CpslButton, { as: isInstalled ? 'button' : 'a', href: (_a = wallet.downloadUrl) !== null && _a !== void 0 ? _a : '', target: "_blank", variant: "secondary", onClick: handleTryAgainClick, children: [_jsx(CpslIcon, { slot: "start", icon: isInstalled ? 'refresh' : 'linkExternal' }), isInstalled ? 'Try Again' : `Get ${wallet.name}`] })] }));
56
- }
57
- if (showMobile) {
58
- // If Solana wallet or if on a mobile and NOT on a table, show the connection screen. Else show the QR code.
59
- if (wallet.type === WalletType.SOLANA || (isMobile() && !isTablet())) {
60
- // Checking if the wallet is installed only for Solana wallets since Solana MWA doesn't work on IOS Safari
61
- // https://docs.solanamobile.com/web/developing-for-web#ios-web
62
- const isInstalled = wallet.type !== WalletType.SOLANA || wallet.installed;
63
- return (_jsxs(_Fragment, { children: [_jsx(InnerStepContainer, { children: !isInstalled && (_jsx(CpslText, { weight: "semiBold", color: "error", children: `${wallet.name} not detected` })) }), wallet.id !== 'walletConnect' && (_jsxs(InnerStepContainer, { children: [_jsx(CpslButton, { onClick: () => routeMobileExternalWallet(qrUri), fullWidth: true, children: "Connect Wallet" }), _jsx(Link, { href: (_b = wallet.downloadUrl) !== null && _b !== void 0 ? _b : '', target: "_blank", children: _jsxs(ExternalButton, { variant: "secondary", children: [`Get ${wallet.name}`, _jsx(ExternalIcon, { icon: "linkExternal" })] }) })] }))] }));
64
- }
65
- const openWCModal = () => __awaiter(void 0, void 0, void 0, function* () {
66
- yield connectExternalWallet(wallet, true, true);
67
- });
68
- const GetWalletButton = (_jsxs(ExternalButton, { variant: "secondary", onClick: isWalletConnect ? openWCModal : undefined, children: [`${isWalletConnect ? 'Open' : 'Get'} ${wallet.name}`, _jsx(ExternalIcon, { icon: "linkExternal" })] }));
69
- return (_jsxs(_Fragment, { children: [_jsxs(InnerStepContainer, { children: [_jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device" }), _jsx(QRContainer, { children: !qrUri ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }), _jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [_jsx(CpslIcon, { slot: "start", icon: isCopied ? 'check' : 'copy' }), isCopied ? 'Copied' : 'Copy Link'] })] }), _jsx(InnerStepContainer, { children: isWalletConnect ? (_jsx(_Fragment, { children: GetWalletButton })) : (_jsx(Link, { href: (_c = wallet.downloadUrl) !== null && _c !== void 0 ? _c : '', target: "_blank", children: GetWalletButton })) })] }));
70
- }
71
- }, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
72
- useEffect(() => {
73
- if (!wallet) {
74
- setStep(ModalStep.AUTH_MAIN);
75
- }
76
- }, [wallet]);
77
- if (!wallet) {
78
- return null;
79
- }
80
- return _jsx(Container, { children: Content });
81
- };
82
- const Container = styled(StepContainer) `
83
- flex: 1;
84
- justify-content: space-between;
85
- `;
86
- const ErrorContainer = styled.div `
87
- display: flex;
88
- align-items: center;
89
- justify-content: center;
90
- gap: 4px;
91
- `;
92
- const ErrorIcon = styled(CpslIcon) `
93
- --height: 16px;
94
- --width: 16px;
95
- --icon-color: var(--cpsl-color-text-error);
96
- `;
97
- const Text = styled(CenteredText) `
98
- white-space: pre-line;
99
- `;
100
- const ExternalButton = styled(CpslButton) `
101
- display: flex;
102
- gap: 8px;
103
- align-items: center;
104
- justify-content: center;
105
- width: 100%;
106
- cursor: pointer;
107
- margin-top: 8px;
108
- text-decoration: none;
109
- `;
110
- const ExternalIcon = styled(CpslIcon) `
111
- --height: 20px;
112
- --width: 20px;
113
- `;
114
- const Link = styled.a `
115
- text-decoration: none;
116
- `;
@@ -1,11 +0,0 @@
1
- export var TabValue;
2
- (function (TabValue) {
3
- TabValue["extension"] = "extension";
4
- TabValue["mobile"] = "mobile";
5
- TabValue["web"] = "web";
6
- })(TabValue || (TabValue = {}));
7
- export const TABS = {
8
- extension: { label: 'Extension', value: TabValue.extension, icon: 'puzzlePiece' },
9
- mobile: { label: 'Mobile', value: TabValue.mobile, icon: 'phone' },
10
- web: { label: 'Web', value: TabValue.web, icon: 'globe' },
11
- };
@@ -1,142 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- import styled from 'styled-components';
12
- import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
13
- import { StyledCpslTileButton } from '../common.js';
14
- import { CpslButton, CpslIcon, CpslInput, CpslText } from '@getpara/react-components';
15
- import { useModalStore, useThemeStore } from '../../stores/index.js';
16
- import { ModalStep } from '../../utils/steps.js';
17
- import { useState } from 'react';
18
- import { hasEmbeddedAuth } from '../../utils/authLayoutHelpers.js';
19
- const HAS_MORE_LENGTH = 3;
20
- export const ExternalWallets = () => {
21
- const { wallets, connectExternalWallet } = useExternalWallets();
22
- const setSelectedExternalWalletId = useModalStore(state => state.setSelectedExternalWalletId);
23
- const setStep = useModalStore(state => state.setStep);
24
- const showAll = useModalStore(state => state.step === ModalStep.EX_WALLET_MORE);
25
- const authLayout = useThemeStore(state => state.authLayout);
26
- const [search, setSearch] = useState('');
27
- const hasMore = wallets.length > HAS_MORE_LENGTH;
28
- const walletsToShow = showAll || !hasMore
29
- ? search
30
- ? wallets.filter(w => w.name.toLowerCase().includes(search.toLowerCase()))
31
- : wallets
32
- : wallets.slice(0, HAS_MORE_LENGTH);
33
- const showMoreButton = !showAll && hasMore;
34
- const handleShowAll = () => {
35
- setStep(ModalStep.EX_WALLET_MORE);
36
- };
37
- const handleParaClick = () => {
38
- setStep(ModalStep.AUTH_MORE);
39
- };
40
- const handleWalletClick = (wallet) => () => {
41
- setSelectedExternalWalletId(wallet.id);
42
- setStep(ModalStep.EX_WALLET_SELECTED);
43
- if (wallet.installed) {
44
- connectExternalWallet(wallet);
45
- }
46
- else if (wallet.isMobile) {
47
- connectExternalWallet(wallet, true);
48
- }
49
- };
50
- return (_jsxs(Container, { "$maxHeight": showAll, children: [showAll && (_jsxs(_Fragment, { children: [_jsx(SearchInputWrapper, { children: _jsx(SearchInput, { placeholder: "Search for your wallet", onCpslInput: (e) => __awaiter(void 0, void 0, void 0, function* () {
51
- setSearch(e.target.value);
52
- }), value: search, style: { width: '100%' }, children: _jsx(SearchIcon, { slot: "start", icon: "search" }) }) }), hasEmbeddedAuth(authLayout) && (_jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleParaClick, children: _jsxs(WalletButtonOuterContainer, { children: [_jsxs(WalletButtonInnerContainer, { children: [_jsx(CpslIcon, { slot: "start", icon: "paraIcon" }), _jsx(CpslText, { weight: "medium", children: "Para" })] }), _jsx(Badge, { "$show": true, "$variant": "installed", children: _jsx(CpslText, { variant: "body2XS", weight: "medium", children: "Available" }) })] }) }))] })), walletsToShow.map(wallet => showAll ? (_jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleWalletClick(wallet), children: _jsxs(WalletButtonOuterContainer, { children: [_jsxs(WalletButtonInnerContainer, { children: [_jsx(CpslIcon, { slot: "start", src: wallet.iconUrl }), _jsx(CpslText, { weight: "medium", children: wallet.name })] }), _jsx(Badge, { "$show": wallet.isMobile || wallet.installed, "$variant": wallet.installed ? 'installed' : 'mobile', children: _jsx(CpslText, { variant: "body2XS", weight: "medium", children: wallet.installed ? 'Installed' : 'Mobile' }) })] }) }, wallet.id)) : (_jsx(WalletTileButton, { src: wallet.iconUrl, onClick: handleWalletClick(wallet), children: _jsxs(TileButtonInnerContainer, { children: [wallet.installed && _jsx(InstalledIndicator, {}), _jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: wallet.name })] }) }, wallet.id))), showMoreButton && (_jsxs(CpslButton, { variant: "tertiary", fullWidth: true, onClick: handleShowAll, children: [_jsx(CpslIcon, { slot: "start", icon: "wallet" }), "More Wallets"] })), showAll && _jsx(BlurContainer, {})] }));
53
- };
54
- const Container = styled.div `
55
- position: relative;
56
- display: flex;
57
- justify-content: center;
58
- gap: 8px;
59
- flex-wrap: wrap;
60
-
61
- max-height: ${({ $maxHeight }) => ($maxHeight ? '348px' : 'none')};
62
- overflow-y: auto;
63
-
64
- &::-webkit-scrollbar {
65
- display: none;
66
- }
67
- -ms-overflow-style: none;
68
- scrollbar-width: none;
69
- `;
70
- const WalletTileButton = styled(StyledCpslTileButton) `
71
- flex: 1;
72
- `;
73
- const WalletButtonOuterContainer = styled.div `
74
- width: 100%;
75
- display: flex;
76
- align-items: center;
77
- gap: 8px;
78
- justify-content: space-between;
79
- `;
80
- const WalletButtonInnerContainer = styled.div `
81
- display: flex;
82
- align-items: center;
83
- gap: 8px;
84
-
85
- cpsl-icon {
86
- --icon-color: var(--cpsl-color-contrast);
87
- }
88
- cpsl-text {
89
- &::part(text-element) {
90
- color: var(--cpsl-color-contrast);
91
- }
92
- }
93
- `;
94
- const Badge = styled.div `
95
- visibility: ${({ $show }) => ($show ? 'visible' : 'hidden')};
96
- padding: 2px 4px;
97
- border-radius: 4px;
98
- border: 1px solid;
99
- border-color: ${({ $variant }) => $variant === 'installed' ? 'var(--cpsl-color-utility-green)' : 'var(--cpsl-color-text-primary)'};
100
- cpsl-text {
101
- &::part(text-element) {
102
- color: ${({ $variant }) => $variant === 'installed' ? 'var(--cpsl-color-utility-green)' : 'var(--cpsl-color-text-primary)'};
103
- }
104
- }
105
- `;
106
- const InstalledIndicator = styled.span `
107
- width: 8px;
108
- height: 8px;
109
- border-radius: 100%;
110
- background-color: var(--cpsl-color-utility-green);
111
- `;
112
- const TileButtonInnerContainer = styled.div `
113
- display: flex;
114
- gap: 4px;
115
- align-items: center;
116
- `;
117
- const SearchIcon = styled(CpslIcon) `
118
- --icon-color: var(--cpsl-color-contrast);
119
- `;
120
- const SearchInputWrapper = styled.div `
121
- width: 100%;
122
- background-color: var(--cpsl-color-background-0);
123
-
124
- position: sticky;
125
- top: 0;
126
- padding-bottom: 4px;
127
- margin-bottom: -4px;
128
- `;
129
- const SearchInput = styled(CpslInput) `
130
- width: 100%;
131
- --container-background-color: var(--cpsl-color-background-8);
132
- --input-background-color: var(--cpsl-color-background-8);
133
- `;
134
- const BlurContainer = styled.div `
135
- position: sticky;
136
- height: 56px;
137
- width: 100%;
138
- bottom: 0;
139
-
140
- background: linear-gradient(0deg, var(--cpsl-color-background-0) 0%, rgba(234, 239, 211, 0) 100%);
141
- pointer-events: none;
142
- `;