@getpara/react-sdk 1.7.1 → 1.8.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 (158) hide show
  1. package/dist/index.js +6 -6659
  2. package/dist/modal/ParaModal.js +362 -0
  3. package/dist/modal/components/Account/Account.js +77 -0
  4. package/dist/modal/components/AddFunds/AddFunds.js +220 -0
  5. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +72 -0
  6. package/dist/modal/components/AddFunds/AddFundsDone.js +43 -0
  7. package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
  8. package/dist/modal/components/AddFunds/index.js +4 -0
  9. package/dist/modal/components/AuthInput/AuthInput.js +283 -0
  10. package/dist/modal/components/AuthInput/countryCodes.js +42 -0
  11. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
  12. package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
  13. package/dist/modal/components/AuthMainStep/AuthMainStep.js +37 -0
  14. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +113 -0
  15. package/dist/modal/components/AuthOptions/AuthOptions.js +33 -0
  16. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
  17. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
  18. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
  19. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +44 -0
  20. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +55 -0
  21. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +93 -0
  22. package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
  23. package/dist/modal/components/Body/Body.js +308 -0
  24. package/dist/modal/components/ChainSwitch/ChainSwitch.js +94 -0
  25. package/dist/modal/components/ChainSwitch/config.js +17 -0
  26. package/dist/modal/components/Controls/Controls.js +74 -0
  27. package/dist/modal/components/Controls/Selects.js +234 -0
  28. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +140 -0
  29. package/dist/modal/components/ExternalWalletStep/config.js +17 -0
  30. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +96 -0
  31. package/dist/modal/components/ExternalWallets/ExternalWallets.js +172 -0
  32. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +124 -0
  33. package/dist/modal/components/Footer/Footer.js +93 -0
  34. package/dist/modal/components/Header/Header.js +43 -0
  35. package/dist/modal/components/Header/hooks/useStepTitle.js +50 -0
  36. package/dist/modal/components/Hero/Hero.js +116 -0
  37. package/dist/modal/components/IFrameStep/IFrameStep.js +55 -0
  38. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +28 -0
  39. package/dist/modal/components/ModalContent/ModalContent.js +324 -0
  40. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
  41. package/dist/modal/components/OAuth/OAuth.js +153 -0
  42. package/dist/modal/components/OAuth/TelegramOAuthStep.js +139 -0
  43. package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
  44. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
  45. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +101 -0
  46. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +141 -0
  47. package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
  48. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +24 -0
  49. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +159 -0
  50. package/dist/modal/components/Waiting/Waiting.js +17 -0
  51. package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
  52. package/dist/modal/components/WalletCard/WalletCard.js +127 -0
  53. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +52 -0
  54. package/dist/modal/components/common.d.ts +6 -6
  55. package/dist/modal/components/common.js +96 -0
  56. package/dist/modal/components/index.js +2 -0
  57. package/dist/modal/constants/constants.d.ts +1 -1
  58. package/dist/modal/constants/constants.js +111 -0
  59. package/dist/modal/constants/defaults.js +10 -0
  60. package/dist/modal/constants/oAuthLogos.js +24 -0
  61. package/dist/modal/hooks/useActiveWallet.js +15 -0
  62. package/dist/modal/hooks/useCreateAccount.js +72 -0
  63. package/dist/modal/hooks/useEmbeddedExternalConnection.js +54 -0
  64. package/dist/modal/hooks/useGoBack.js +42 -0
  65. package/dist/modal/hooks/useSetLoginURLs.js +49 -0
  66. package/dist/modal/hooks/useWalletBalance.d.ts +4 -0
  67. package/dist/modal/hooks/useWalletBalance.js +47 -0
  68. package/dist/modal/index.js +33 -0
  69. package/dist/modal/providers/CosmosExternalWalletContextStub.js +38 -0
  70. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +2 -0
  71. package/dist/modal/providers/EvmExternalWalletContextStub.js +55 -0
  72. package/dist/modal/providers/ExternalWalletContext.d.ts +3 -0
  73. package/dist/modal/providers/ExternalWalletContext.js +394 -0
  74. package/dist/modal/providers/SolanaExternalWalletContextStub.js +32 -0
  75. package/dist/modal/stores/externalWalletProvider/actions.js +10 -0
  76. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +21 -0
  77. package/dist/modal/stores/index.js +4 -0
  78. package/dist/modal/stores/modal/actions.js +70 -0
  79. package/dist/modal/stores/modal/useModalStore.js +65 -0
  80. package/dist/modal/stores/theme/actions.js +28 -0
  81. package/dist/modal/stores/theme/useThemeStore.js +21 -0
  82. package/dist/modal/stores/userInfo/actions.js +30 -0
  83. package/dist/modal/stores/userInfo/useUserInfoStore.js +17 -0
  84. package/dist/modal/types/commonTypes.js +1 -0
  85. package/dist/modal/types/externalWallets.js +32 -0
  86. package/dist/modal/types/modalProps.d.ts +4 -0
  87. package/dist/modal/types/modalProps.js +12 -0
  88. package/dist/modal/utils/authLayoutHelpers.js +8 -0
  89. package/dist/modal/utils/getMailtoLink.js +10 -0
  90. package/dist/modal/utils/getTileButtonFlex.js +20 -0
  91. package/dist/modal/utils/openPopup.js +60 -0
  92. package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
  93. package/dist/modal/utils/steps.js +232 -0
  94. package/dist/modal/utils/stringFormatters.d.ts +1 -0
  95. package/dist/modal/utils/stringFormatters.js +19 -0
  96. package/dist/modal/utils/validateOnRampConfig.js +32 -0
  97. package/dist/package.json +3 -1
  98. package/dist/provider/ParaProvider.js +22 -0
  99. package/dist/provider/actions/checkIfUserExists.js +21 -0
  100. package/dist/provider/actions/createUser.js +26 -0
  101. package/dist/provider/actions/getAccount.js +22 -0
  102. package/dist/provider/actions/getWallet.js +14 -0
  103. package/dist/provider/actions/getWalletBalance.d.ts +2 -0
  104. package/dist/provider/actions/getWalletBalance.js +14 -0
  105. package/dist/provider/actions/initiateLogin.js +20 -0
  106. package/dist/provider/actions/keepSessionAlive.js +20 -0
  107. package/dist/provider/actions/logout.js +17 -0
  108. package/dist/provider/actions/signMessage.js +20 -0
  109. package/dist/provider/actions/signTransaction.js +20 -0
  110. package/dist/provider/actions/waitForAccountCreation.js +21 -0
  111. package/dist/provider/actions/waitForLoginAndSetup.js +24 -0
  112. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +21 -0
  113. package/dist/provider/hooks/index.js +4 -0
  114. package/dist/provider/hooks/mutations/index.js +24 -0
  115. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
  116. package/dist/provider/hooks/mutations/useCreateUser.js +20 -0
  117. package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
  118. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +20 -0
  119. package/dist/provider/hooks/mutations/useLogout.js +30 -0
  120. package/dist/provider/hooks/mutations/useSignMessage.js +39 -0
  121. package/dist/provider/hooks/mutations/useSignTransaction.js +39 -0
  122. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
  123. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
  124. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
  125. package/dist/provider/hooks/queries/index.d.ts +1 -0
  126. package/dist/provider/hooks/queries/index.js +10 -0
  127. package/dist/provider/hooks/queries/useAccount.js +21 -0
  128. package/dist/provider/hooks/queries/useWallet.js +22 -0
  129. package/dist/provider/hooks/queries/useWalletBalance.d.ts +7 -0
  130. package/dist/provider/hooks/queries/useWalletBalance.js +26 -0
  131. package/dist/provider/hooks/utils/index.js +10 -0
  132. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
  133. package/dist/provider/hooks/utils/useClient.js +10 -0
  134. package/dist/provider/hooks/utils/useEventListeners.js +105 -0
  135. package/dist/provider/hooks/utils/useInternalClient.js +10 -0
  136. package/dist/provider/hooks/utils/useModal.js +17 -0
  137. package/dist/provider/hooks/utils/useWalletState.js +33 -0
  138. package/dist/provider/index.js +8 -0
  139. package/dist/provider/stores/getters.js +13 -0
  140. package/dist/provider/stores/slices/client.js +9 -0
  141. package/dist/provider/stores/slices/index.js +4 -0
  142. package/dist/provider/stores/slices/modal.js +9 -0
  143. package/dist/provider/stores/slices/wallet.js +13 -0
  144. package/dist/provider/stores/types.d.ts +2 -0
  145. package/dist/provider/stores/types.js +1 -0
  146. package/dist/provider/stores/useStore.js +27 -0
  147. package/dist/provider/types/provider.js +1 -0
  148. package/dist/provider/types/query.js +1 -0
  149. package/dist/provider/types/utils.js +1 -0
  150. package/dist/provider/utils/constants.js +11 -0
  151. package/dist/provider/utils/renameMutations.js +16 -0
  152. package/package.json +5 -5
  153. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  154. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  155. package/dist/chunk-MMUBH76A.js.br +0 -0
  156. package/dist/chunk-MMUBH76A.js.gz +0 -0
  157. package/dist/index.js.br +0 -0
  158. package/dist/index.js.gz +0 -0
@@ -0,0 +1,234 @@
1
+ "use client";
2
+ import {
3
+ __async,
4
+ __spreadProps,
5
+ __spreadValues
6
+ } from "../../../chunk-MMUBH76A.js";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { CpslButton, CpslIcon, CpslIdenticon, CpslSelect, CpslSelectItem, CpslText } from "@getpara/react-components";
9
+ import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
10
+ import styled from "styled-components";
11
+ import { useThemeStore } from "../../stores/index.js";
12
+ import { truncateAddress, WalletType } from "@getpara/web-sdk";
13
+ import { useEffect, useRef } from "react";
14
+ import { useDropdownPosition } from "../AuthInput/hooks/useDropdownPosition.js";
15
+ import { MOBILE_SIZE } from "../../constants/constants.js";
16
+ import { useActiveWallet } from "../../hooks/useActiveWallet.js";
17
+ import { useWalletState } from "../../../provider/index.js";
18
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
19
+ import { useCopyToClipboard } from "@getpara/react-common";
20
+ const getValue = (id, type) => {
21
+ return id && type ? `${id}~${type}` : void 0;
22
+ };
23
+ const WALLET_TYPES = {
24
+ [WalletType.EVM]: "EVM",
25
+ [WalletType.SOLANA]: "Solana",
26
+ [WalletType.COSMOS]: "Cosmos"
27
+ };
28
+ const ChainSelect = () => {
29
+ var _a, _b;
30
+ const containerRef = useRef(null);
31
+ const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
32
+ const activeWallet = useActiveWallet();
33
+ const { switchChain, chainId, chains, chainIdSwitchingTo } = useExternalWallets();
34
+ useEffect(() => {
35
+ if (dropdownMaxHeight && chainId) {
36
+ resize();
37
+ }
38
+ }, [chainId, chainIdSwitchingTo, dropdownMaxHeight]);
39
+ const handleChainChange = (chainId2) => __async(void 0, null, function* () {
40
+ yield switchChain(chainId2);
41
+ });
42
+ if (!activeWallet || !activeWallet.isExternal || activeWallet.type === WalletType.SOLANA) {
43
+ return null;
44
+ }
45
+ const chainIdToUse = chainIdSwitchingTo != null ? chainIdSwitchingTo : chainId;
46
+ const selectedChainName = (_a = chains.find((c) => c.id.toString() === chainIdToUse)) == null ? void 0 : _a.name;
47
+ return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(SelectContainer, { ref: containerRef, id: "inputContainer", children: /* @__PURE__ */ jsxs(
48
+ StyledSelect,
49
+ {
50
+ selectedValue: (_b = chainIdToUse == null ? void 0 : chainIdToUse.toString()) != null ? _b : "",
51
+ onCpslSelectValueChange: (e) => {
52
+ handleChainChange(e.detail);
53
+ },
54
+ showFormattedSelectedItem: true,
55
+ placeholder: "Choose chain...",
56
+ anchorElId: "inputContainer",
57
+ dropdownMaxHeight,
58
+ $width: dropdownWidth,
59
+ $top: mobileAnchor + 16 + 1,
60
+ autoWidth: true,
61
+ selectedItemVariant: "bodyXS",
62
+ children: [
63
+ chainIdToUse && /* @__PURE__ */ jsx(ChainName, { variant: "bodyXS", color: "contrast", slot: "selected-item", children: selectedChainName }),
64
+ chains == null ? void 0 : chains.map((chain) => /* @__PURE__ */ jsx(StyledSelectItem, { slot: "items", value: chain.id.toString(), children: /* @__PURE__ */ jsx(ChainName, { variant: "bodyXS", color: "contrast", children: chain.name }) }, chain.id))
65
+ ]
66
+ }
67
+ ) }) });
68
+ };
69
+ function getName(para, {
70
+ type,
71
+ isExternal,
72
+ name,
73
+ isMenu = false,
74
+ hideWallets = false
75
+ }) {
76
+ if (para.isMultiWallet) {
77
+ return name != null ? name : `${isExternal ? "External " : ""}${WALLET_TYPES[type]}${!hideWallets && (isMenu || isExternal) ? " Wallet" : ""}`;
78
+ }
79
+ return hideWallets ? "My Account" : name || "My Wallet";
80
+ }
81
+ const AccountSelect = () => {
82
+ var _a;
83
+ const hideWallets = useThemeStore((state) => state.hideWallets);
84
+ const para = useInternalClient();
85
+ const containerRef = useRef(null);
86
+ const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
87
+ const [isCopied, copy] = useCopyToClipboard();
88
+ const { setSelectedWallet } = useWalletState();
89
+ const activeWallet = useActiveWallet();
90
+ const handleCopy = () => {
91
+ copy(activeWallet.address ? para.getDisplayAddress(activeWallet.id, { addressType: activeWallet.type }) : "");
92
+ };
93
+ const ActiveWalletNode = activeWallet ? /* @__PURE__ */ jsxs(FlexRow, { slot: "selected-item", children: [
94
+ /* @__PURE__ */ jsx(CpslIdenticon, { variant: "avatar", size: "14px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }),
95
+ /* @__PURE__ */ jsx(WalletName, { variant: "bodyXS", color: "contrast", children: getName(para, __spreadProps(__spreadValues({}, activeWallet), { hideWallets })) }),
96
+ !hideWallets && /* @__PURE__ */ jsxs(Fragment, { children: [
97
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", children: (_a = activeWallet.ensName) != null ? _a : para.getDisplayAddress(activeWallet.id, { truncate: true, addressType: activeWallet.type }) }),
98
+ /* @__PURE__ */ jsx(
99
+ CpslButton,
100
+ {
101
+ id: "ignore-click",
102
+ size: "small",
103
+ variant: "ghost",
104
+ onClick: (e) => {
105
+ e.stopPropagation();
106
+ e.preventDefault();
107
+ handleCopy();
108
+ },
109
+ children: /* @__PURE__ */ jsx(CpslIcon, { id: "ignore-click", slot: "start", icon: isCopied ? "check" : "copy" })
110
+ }
111
+ )
112
+ ] })
113
+ ] }) : null;
114
+ useEffect(() => {
115
+ if (dropdownMaxHeight && (activeWallet == null ? void 0 : activeWallet.address)) {
116
+ resize();
117
+ }
118
+ }, [activeWallet, para.availableWallets, dropdownMaxHeight]);
119
+ return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(SelectContainer, { ref: containerRef, id: "addressInputContainer", children: para.availableWallets.length > 1 ? /* @__PURE__ */ jsxs(
120
+ StyledSelect,
121
+ {
122
+ selectedValue: getValue(activeWallet == null ? void 0 : activeWallet.id, activeWallet == null ? void 0 : activeWallet.type),
123
+ onCpslSelectValueChange: (e) => {
124
+ const [id, type] = e.detail.split("~");
125
+ setSelectedWallet({ id, type });
126
+ },
127
+ showFormattedSelectedItem: true,
128
+ placeholder: "Choose wallet...",
129
+ anchorElId: "addressInputContainer",
130
+ dropdownMaxHeight,
131
+ $width: dropdownWidth,
132
+ $top: mobileAnchor + 16 + 1,
133
+ autoWidth: true,
134
+ selectedItemVariant: "bodyXS",
135
+ children: [
136
+ activeWallet && ActiveWalletNode,
137
+ para.availableWallets.map(({ address, name: _name, id, type, isExternal }) => {
138
+ const key = getValue(id, type);
139
+ const name = _name != null ? _name : getName(para, { type, isExternal, isMenu: true, hideWallets });
140
+ return /* @__PURE__ */ jsx(StyledSelectItem, { slot: "items", value: key, children: /* @__PURE__ */ jsxs(FlexRow, { children: [
141
+ /* @__PURE__ */ jsx(CpslIdenticon, { size: "40px", hash: para.getIdenticonHash(id, type) }),
142
+ /* @__PURE__ */ jsxs(FlexCol, { children: [
143
+ name && /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "contrast", children: name }),
144
+ !hideWallets && /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", children: truncateAddress(address, type, { prefix: para.cosmosPrefix }) })
145
+ ] })
146
+ ] }) }, key);
147
+ })
148
+ ]
149
+ }
150
+ ) : ActiveWalletNode }) });
151
+ };
152
+ const Container = styled.div`
153
+ flex: 0;
154
+ width: 100%;
155
+ display: flex;
156
+ justify-content: center;
157
+ `;
158
+ const FlexRow = styled.div`
159
+ display: flex;
160
+ align-items: center;
161
+ gap: 8px;
162
+ `;
163
+ const FlexCol = styled.div`
164
+ display: flex;
165
+ flex-direction: column;
166
+ align-items: flex-start;
167
+ `;
168
+ const WalletName = styled(CpslText)`
169
+ white-space: nowrap;
170
+ `;
171
+ const SelectContainer = styled.div`
172
+ position: relative;
173
+ display: flex;
174
+ align-items: center;
175
+ gap: 8px;
176
+ border-radius: 1000px;
177
+ background-color: var(--cpsl-color-background-8);
178
+ padding: 8px;
179
+ `;
180
+ const ChainName = styled(CpslText)`
181
+ max-width: 150px;
182
+ text-transform: capitalize;
183
+
184
+ &::part(text-element) {
185
+ white-space: nowrap;
186
+ text-overflow: ellipsis;
187
+ overflow: hidden;
188
+ }
189
+ `;
190
+ const StyledSelect = styled(CpslSelect)`
191
+ --container-height: auto;
192
+ --container-border-width: 0px;
193
+ --container-padding-end: 0px;
194
+ --container-padding-start: 0px;
195
+ --container-background-color: transparent;
196
+ --container-box-shadow: none;
197
+ --container-gap: 2px;
198
+ --icon-width: 16px;
199
+ --icon-height: 16px;
200
+
201
+ &::part(selected-text) {
202
+ white-space: nowrap;
203
+ }
204
+
205
+ &::part(dropdown) {
206
+ min-width: ${({ $width }) => `${$width - 2}px`};
207
+ }
208
+
209
+ &::part(popover) {
210
+ /* 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 */
211
+ @media (max-width: ${MOBILE_SIZE}px) {
212
+ top: ${({ $top }) => $top ? `${$top}px` : "0px"};
213
+ bottom: 16px;
214
+ }
215
+ cpsl-auth-modal.force-mobile-media & {
216
+ top: ${({ $top }) => $top ? `${$top}px` : "0px"};
217
+ bottom: 16px;
218
+ }
219
+ }
220
+
221
+ &::part(icon) {
222
+ --icon-color: var(--cpsl-color-contrast);
223
+ }
224
+ `;
225
+ const StyledSelectItem = styled(CpslSelectItem)`
226
+ --outer-container-padding-start: 4px;
227
+ --outer-container-padding-end: 4px;
228
+ --outer-container-padding-top: 4px;
229
+ --outer-container-padding-bottom: 4px;
230
+ `;
231
+ export {
232
+ AccountSelect,
233
+ ChainSelect
234
+ };
@@ -0,0 +1,140 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
7
+ import { CenteredText, ErrorContainer, ErrorIcon, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
8
+ import { useEffect, useMemo } from "react";
9
+ import { useModalStore } from "../../stores/index.js";
10
+ import styled from "styled-components";
11
+ import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
12
+ import { useCopyToClipboard } from "@getpara/react-common";
13
+ import { ModalStep } from "../../utils/steps.js";
14
+ import { isMobile, isTablet, WalletType } from "@getpara/web-sdk";
15
+ import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
16
+ const ExternalWalletStep = () => {
17
+ const [isCopied, copy] = useCopyToClipboard();
18
+ const externalWalletError = useModalStore((state) => state.externalWalletError);
19
+ const setStep = useModalStore((state) => state.setStep);
20
+ const { connectExternalWallet, wallet, qrUri, walletDisplayHelpers } = useExternalWallets();
21
+ useEffect(() => {
22
+ routeMobileExternalWallet(qrUri);
23
+ }, [qrUri]);
24
+ const handleTryAgainClick = () => __async(void 0, null, function* () {
25
+ yield connectExternalWallet(wallet);
26
+ });
27
+ const handleCopy = () => {
28
+ copy(qrUri);
29
+ };
30
+ const Content = useMemo(() => {
31
+ var _a, _b, _c;
32
+ if (!wallet) {
33
+ return null;
34
+ }
35
+ const isWalletConnect = wallet.id === "walletConnect";
36
+ const isMobileWalletConnect = isMobile() && isWalletConnect;
37
+ if (isMobileWalletConnect) {
38
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: "Continue in the WalletConnect modal." }) });
39
+ }
40
+ const { showExtension, showMobile, isSolanaMobileIOS } = walletDisplayHelpers;
41
+ if (!showMobile && !showExtension || isSolanaMobileIOS && !wallet.installed) {
42
+ const text = isSolanaMobileIOS ? "Solana wallets aren't available on mobile IOS browsers.\n\nPlease continue in the wallet app." : `${wallet.name} isn't supported on mobile devices.
43
+
44
+ Please choose another wallet or continue on desktop.`;
45
+ return /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: text }) });
46
+ }
47
+ if (showExtension) {
48
+ const isInstalled = wallet.installed;
49
+ return /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
50
+ isInstalled && !(externalWalletError == null ? void 0 : externalWalletError.length) ? /* @__PURE__ */ jsx(CenteredText, { color: "contrast", weight: "semiBold", children: `Confirm connection request in the ${wallet.name} browser extension.` }) : /* @__PURE__ */ jsxs(ErrorContainer, { children: [
51
+ /* @__PURE__ */ jsx(ErrorIcon, { icon: "alertCircle" }),
52
+ /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: isInstalled ? externalWalletError == null ? void 0 : externalWalletError[0] : `${wallet.name} not detected` })
53
+ ] }),
54
+ /* @__PURE__ */ jsxs(
55
+ CpslButton,
56
+ {
57
+ as: isInstalled ? "button" : "a",
58
+ href: (_a = wallet.downloadUrl) != null ? _a : "",
59
+ target: "_blank",
60
+ variant: "secondary",
61
+ onClick: handleTryAgainClick,
62
+ children: [
63
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isInstalled ? "refresh" : "linkExternal" }),
64
+ isInstalled ? "Try Again" : `Get ${wallet.name}`
65
+ ]
66
+ }
67
+ )
68
+ ] });
69
+ }
70
+ if (showMobile) {
71
+ if (wallet.type === WalletType.SOLANA || isMobile() && !isTablet()) {
72
+ const isInstalled = wallet.type !== WalletType.SOLANA || wallet.installed;
73
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
74
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: !isInstalled && /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: `${wallet.name} not detected` }) }),
75
+ wallet.id !== "walletConnect" && /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
76
+ /* @__PURE__ */ jsx(CpslButton, { onClick: () => routeMobileExternalWallet(qrUri), fullWidth: true, children: "Connect Wallet" }),
77
+ /* @__PURE__ */ jsx(Link, { href: (_b = wallet.downloadUrl) != null ? _b : "", target: "_blank", children: /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", children: [
78
+ `Get ${wallet.name}`,
79
+ /* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
80
+ ] }) })
81
+ ] })
82
+ ] });
83
+ }
84
+ const openWCModal = () => __async(void 0, null, function* () {
85
+ yield connectExternalWallet(wallet, true, true);
86
+ });
87
+ const GetWalletButton = /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", onClick: isWalletConnect ? openWCModal : void 0, children: [
88
+ `${isWalletConnect ? "Open" : "Get"} ${wallet.name}`,
89
+ /* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
90
+ ] });
91
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
92
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
93
+ /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device" }),
94
+ /* @__PURE__ */ jsx(QRContainer, { children: !qrUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }),
95
+ /* @__PURE__ */ jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [
96
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
97
+ isCopied ? "Copied" : "Copy Link"
98
+ ] })
99
+ ] }),
100
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: isWalletConnect ? /* @__PURE__ */ jsx(Fragment, { children: GetWalletButton }) : /* @__PURE__ */ jsx(Link, { href: (_c = wallet.downloadUrl) != null ? _c : "", target: "_blank", children: GetWalletButton }) })
101
+ ] });
102
+ }
103
+ }, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
104
+ useEffect(() => {
105
+ if (!wallet) {
106
+ setStep(ModalStep.AUTH_MAIN);
107
+ }
108
+ }, [wallet]);
109
+ if (!wallet) {
110
+ return null;
111
+ }
112
+ return /* @__PURE__ */ jsx(Container, { children: Content });
113
+ };
114
+ const Container = styled(StepContainer)`
115
+ flex: 1;
116
+ justify-content: space-between;
117
+ `;
118
+ const Text = styled(CenteredText)`
119
+ white-space: pre-line;
120
+ `;
121
+ const ExternalButton = styled(CpslButton)`
122
+ display: flex;
123
+ gap: 8px;
124
+ align-items: center;
125
+ justify-content: center;
126
+ width: 100%;
127
+ cursor: pointer;
128
+ margin-top: 8px;
129
+ text-decoration: none;
130
+ `;
131
+ const ExternalIcon = styled(CpslIcon)`
132
+ --height: 20px;
133
+ --width: 20px;
134
+ `;
135
+ const Link = styled.a`
136
+ text-decoration: none;
137
+ `;
138
+ export {
139
+ ExternalWalletStep
140
+ };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ var TabValue = /* @__PURE__ */ ((TabValue2) => {
4
+ TabValue2["extension"] = "extension";
5
+ TabValue2["mobile"] = "mobile";
6
+ TabValue2["web"] = "web";
7
+ return TabValue2;
8
+ })(TabValue || {});
9
+ const TABS = {
10
+ extension: { label: "Extension", value: "extension" /* extension */, icon: "puzzlePiece" },
11
+ mobile: { label: "Mobile", value: "mobile" /* mobile */, icon: "phone" },
12
+ web: { label: "Web", value: "web" /* web */, icon: "globe" }
13
+ };
14
+ export {
15
+ TABS,
16
+ TabValue
17
+ };
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { CpslButton, CpslSpinner, CpslText } from "@getpara/react-components";
7
+ import { useEffect, useState } from "react";
8
+ import { styled } from "styled-components";
9
+ import { ModalStep } from "../../utils/steps.js";
10
+ import { useModalStore, useThemeStore, useUserInfoStore } from "../../stores/index.js";
11
+ import { ErrorContainer, ErrorIcon, Heading, InnerStepContainer, StepContainer } from "../common.js";
12
+ import { AuthMethod } from "@getpara/core-sdk";
13
+ import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
14
+ import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
15
+ const ExternalWalletVerificationStep = () => {
16
+ const theme = useThemeStore((state) => state.theme);
17
+ const authInfo = useUserInfoStore((state) => state.getAuthInfo());
18
+ const setStep = useModalStore((state) => state.setStep);
19
+ const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
20
+ const isIFrameReady = useModalStore((state) => state.isIFrameReady);
21
+ const setIsIFrameReady = useModalStore((state) => state.setIsIFrameReady);
22
+ const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
23
+ const externalWalletError = useModalStore((state) => state.externalWalletError);
24
+ const setExternalWalletError = useModalStore((state) => state.setExternalWalletError);
25
+ const para = useInternalClient();
26
+ const { verifyWalletSignature } = useExternalWallets();
27
+ const [shouldRouteToStep, setShouldRouteToStep] = useState();
28
+ const [isVerifying, setIsVerifying] = useState(false);
29
+ useEffect(() => {
30
+ handleVerifyWallet();
31
+ }, []);
32
+ useEffect(() => {
33
+ if (!!shouldRouteToStep && isIFrameReady) {
34
+ setTimeout(() => {
35
+ setStep(shouldRouteToStep);
36
+ setIsVerifying(false);
37
+ }, 200);
38
+ }
39
+ }, [shouldRouteToStep, isIFrameReady]);
40
+ const handleVerifyWallet = () => __async(void 0, null, function* () {
41
+ setIsVerifying(true);
42
+ try {
43
+ setIsIFrameReady(false);
44
+ const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
45
+ const walletSignature = yield verifyWalletSignature();
46
+ if (!walletSignature.signature || !walletSignature.address) {
47
+ console.error("No signature or address found on the verifyWalletSignature response.");
48
+ setIsVerifying(false);
49
+ return;
50
+ }
51
+ const url = yield para.verifyExternalWallet({
52
+ address: walletSignature.address,
53
+ signedMessage: walletSignature.signature,
54
+ cosmosPublicKeyHex: walletSignature.cosmosPublicKeyHex,
55
+ cosmosSigner: walletSignature.cosmosSigner
56
+ });
57
+ if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD) && supportedCreateAuthMethods.has(AuthMethod.PASSKEY)) {
58
+ const passwordAuthUrl = yield para.getSetupPasswordURL({ authType: authInfo == null ? void 0 : authInfo.authType, theme });
59
+ setWebAuthURLForCreate(yield para.shortenLoginLink(url));
60
+ setIFrameUrl(yield para.shortenLoginLink(passwordAuthUrl));
61
+ setShouldRouteToStep(ModalStep.BIOMETRIC_CREATION);
62
+ return;
63
+ } else if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD)) {
64
+ const url2 = yield para.getSetupPasswordURL({ authType: authInfo == null ? void 0 : authInfo.authType, theme });
65
+ setIFrameUrl(yield para.shortenLoginLink(url2));
66
+ setShouldRouteToStep(ModalStep.PASSWORD_CREATION);
67
+ return;
68
+ } else {
69
+ setWebAuthURLForCreate(yield para.shortenLoginLink(url));
70
+ setStep(ModalStep.BIOMETRIC_CREATION);
71
+ }
72
+ } catch (e) {
73
+ console.error("Error verifying signature:", e);
74
+ setExternalWalletError(["Signature verification failed."]);
75
+ setIsVerifying(false);
76
+ }
77
+ });
78
+ return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
79
+ /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
80
+ /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Verify Your Wallet" }),
81
+ /* @__PURE__ */ jsx(InlineText, { variant: "bodyS", color: "secondary", children: "Sign the message with your wallet to complete sign up." }),
82
+ !!(externalWalletError == null ? void 0 : externalWalletError[0]) && /* @__PURE__ */ jsxs(ErrorContainer, { children: [
83
+ /* @__PURE__ */ jsx(ErrorIcon, { icon: "alertCircle" }),
84
+ /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: externalWalletError == null ? void 0 : externalWalletError[0] })
85
+ ] })
86
+ ] }),
87
+ /* @__PURE__ */ jsx(InnerStepContainer, { children: isVerifying ? /* @__PURE__ */ jsx(CpslSpinner, {}) : /* @__PURE__ */ jsx(CpslButton, { onClick: handleVerifyWallet, children: "Retry" }) })
88
+ ] });
89
+ };
90
+ const InlineText = styled(CpslText)`
91
+ text-align: center;
92
+ display: inline-block;
93
+ `;
94
+ export {
95
+ ExternalWalletVerificationStep
96
+ };
@@ -0,0 +1,172 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import styled from "styled-components";
7
+ import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
8
+ import { StyledCpslTileButton } from "../common.js";
9
+ import { CpslButton, CpslIcon, CpslInput, CpslText } from "@getpara/react-components";
10
+ import { useModalStore, useThemeStore } from "../../stores/index.js";
11
+ import { ModalStep } from "../../utils/steps.js";
12
+ import { useState } from "react";
13
+ import { hasEmbeddedAuth } from "../../utils/authLayoutHelpers.js";
14
+ const HAS_MORE_LENGTH = 3;
15
+ const ExternalWallets = () => {
16
+ const { wallets, connectExternalWallet } = useExternalWallets();
17
+ const setSelectedExternalWalletId = useModalStore((state) => state.setSelectedExternalWalletId);
18
+ const setStep = useModalStore((state) => state.setStep);
19
+ const showAll = useModalStore((state) => state.step === ModalStep.EX_WALLET_MORE);
20
+ const authLayout = useThemeStore((state) => state.authLayout);
21
+ const [search, setSearch] = useState("");
22
+ const hasMore = wallets.length > HAS_MORE_LENGTH;
23
+ const walletsToShow = showAll || !hasMore ? search ? wallets.filter((w) => w.name.toLowerCase().includes(search.toLowerCase())) : wallets : wallets.slice(0, HAS_MORE_LENGTH);
24
+ const showMoreButton = !showAll && hasMore;
25
+ const handleShowAll = () => {
26
+ setStep(ModalStep.EX_WALLET_MORE);
27
+ };
28
+ const handleParaClick = () => {
29
+ setStep(ModalStep.AUTH_MORE);
30
+ };
31
+ const handleWalletClick = (wallet) => () => {
32
+ setSelectedExternalWalletId(wallet.id);
33
+ setStep(ModalStep.EX_WALLET_SELECTED);
34
+ if (wallet.installed) {
35
+ connectExternalWallet(wallet);
36
+ } else if (wallet.isMobile) {
37
+ connectExternalWallet(wallet, true);
38
+ }
39
+ };
40
+ return /* @__PURE__ */ jsxs(Container, { $maxHeight: showAll, children: [
41
+ showAll && /* @__PURE__ */ jsxs(Fragment, { children: [
42
+ /* @__PURE__ */ jsx(SearchInputWrapper, { children: /* @__PURE__ */ jsx(
43
+ SearchInput,
44
+ {
45
+ placeholder: "Search for your wallet",
46
+ onCpslInput: (e) => __async(void 0, null, function* () {
47
+ setSearch(e.target.value);
48
+ }),
49
+ value: search,
50
+ style: { width: "100%" },
51
+ children: /* @__PURE__ */ jsx(SearchIcon, { slot: "start", icon: "search" })
52
+ }
53
+ ) }),
54
+ hasEmbeddedAuth(authLayout) && /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleParaClick, children: /* @__PURE__ */ jsxs(WalletButtonOuterContainer, { children: [
55
+ /* @__PURE__ */ jsxs(WalletButtonInnerContainer, { children: [
56
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "paraIcon" }),
57
+ /* @__PURE__ */ jsx(CpslText, { weight: "medium", children: "Para" })
58
+ ] }),
59
+ /* @__PURE__ */ jsx(Badge, { $show: true, $variant: "installed", children: /* @__PURE__ */ jsx(CpslText, { variant: "body2XS", weight: "medium", children: "Available" }) })
60
+ ] }) })
61
+ ] }),
62
+ walletsToShow.map(
63
+ (wallet) => showAll ? /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleWalletClick(wallet), children: /* @__PURE__ */ jsxs(WalletButtonOuterContainer, { children: [
64
+ /* @__PURE__ */ jsxs(WalletButtonInnerContainer, { children: [
65
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", src: wallet.iconUrl }),
66
+ /* @__PURE__ */ jsx(CpslText, { weight: "medium", children: wallet.name })
67
+ ] }),
68
+ /* @__PURE__ */ jsx(Badge, { $show: wallet.isMobile || wallet.installed, $variant: wallet.installed ? "installed" : "mobile", children: /* @__PURE__ */ jsx(CpslText, { variant: "body2XS", weight: "medium", children: wallet.installed ? "Installed" : "Mobile" }) })
69
+ ] }) }, wallet.id) : /* @__PURE__ */ jsx(WalletTileButton, { src: wallet.iconUrl, onClick: handleWalletClick(wallet), children: /* @__PURE__ */ jsxs(TileButtonInnerContainer, { children: [
70
+ wallet.installed && /* @__PURE__ */ jsx(InstalledIndicator, {}),
71
+ /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: wallet.name })
72
+ ] }) }, wallet.id)
73
+ ),
74
+ showMoreButton && /* @__PURE__ */ jsxs(CpslButton, { variant: "tertiary", fullWidth: true, onClick: handleShowAll, children: [
75
+ /* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "wallet" }),
76
+ "More Wallets"
77
+ ] }),
78
+ showAll && /* @__PURE__ */ jsx(BlurContainer, {})
79
+ ] });
80
+ };
81
+ const Container = styled.div`
82
+ position: relative;
83
+ display: flex;
84
+ justify-content: center;
85
+ gap: 8px;
86
+ flex-wrap: wrap;
87
+
88
+ max-height: ${({ $maxHeight }) => $maxHeight ? "348px" : "none"};
89
+ overflow-y: auto;
90
+
91
+ &::-webkit-scrollbar {
92
+ display: none;
93
+ }
94
+ -ms-overflow-style: none;
95
+ scrollbar-width: none;
96
+ `;
97
+ const WalletTileButton = styled(StyledCpslTileButton)`
98
+ flex: 1;
99
+ `;
100
+ const WalletButtonOuterContainer = styled.div`
101
+ width: 100%;
102
+ display: flex;
103
+ align-items: center;
104
+ gap: 8px;
105
+ justify-content: space-between;
106
+ `;
107
+ const WalletButtonInnerContainer = styled.div`
108
+ display: flex;
109
+ align-items: center;
110
+ gap: 8px;
111
+
112
+ cpsl-icon {
113
+ --icon-color: var(--cpsl-color-contrast);
114
+ }
115
+ cpsl-text {
116
+ &::part(text-element) {
117
+ color: var(--cpsl-color-contrast);
118
+ }
119
+ }
120
+ `;
121
+ const Badge = styled.div`
122
+ visibility: ${({ $show }) => $show ? "visible" : "hidden"};
123
+ padding: 2px 4px;
124
+ border-radius: 4px;
125
+ border: 1px solid;
126
+ border-color: ${({ $variant }) => $variant === "installed" ? "var(--cpsl-color-utility-green)" : "var(--cpsl-color-text-primary)"};
127
+ cpsl-text {
128
+ &::part(text-element) {
129
+ color: ${({ $variant }) => $variant === "installed" ? "var(--cpsl-color-utility-green)" : "var(--cpsl-color-text-primary)"};
130
+ }
131
+ }
132
+ `;
133
+ const InstalledIndicator = styled.span`
134
+ width: 8px;
135
+ height: 8px;
136
+ border-radius: 100%;
137
+ background-color: var(--cpsl-color-utility-green);
138
+ `;
139
+ const TileButtonInnerContainer = styled.div`
140
+ display: flex;
141
+ gap: 4px;
142
+ align-items: center;
143
+ `;
144
+ const SearchIcon = styled(CpslIcon)`
145
+ --icon-color: var(--cpsl-color-contrast);
146
+ `;
147
+ const SearchInputWrapper = styled.div`
148
+ width: 100%;
149
+ background-color: var(--cpsl-color-background-0);
150
+
151
+ position: sticky;
152
+ top: 0;
153
+ padding-bottom: 4px;
154
+ margin-bottom: -4px;
155
+ `;
156
+ const SearchInput = styled(CpslInput)`
157
+ width: 100%;
158
+ --container-background-color: var(--cpsl-color-background-8);
159
+ --input-background-color: var(--cpsl-color-background-8);
160
+ `;
161
+ const BlurContainer = styled.div`
162
+ position: sticky;
163
+ height: 56px;
164
+ width: 100%;
165
+ bottom: 0;
166
+
167
+ background: linear-gradient(0deg, var(--cpsl-color-background-0) 0%, rgba(234, 239, 211, 0) 100%);
168
+ pointer-events: none;
169
+ `;
170
+ export {
171
+ ExternalWallets
172
+ };