@getpara/react-sdk 1.8.0 → 2.0.0-alpha.3

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 (248) hide show
  1. package/dist/{modal/components/AddFunds/MoonPayEmbed.js → MoonPayEmbed-Q2HP2BFI.js} +3 -1
  2. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  3. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  4. package/dist/chunk-MMUBH76A.js.br +0 -0
  5. package/dist/chunk-MMUBH76A.js.gz +0 -0
  6. package/dist/cli/cli.mjs +40 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +6499 -6
  9. package/dist/index.js.br +0 -0
  10. package/dist/index.js.gz +0 -0
  11. package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
  12. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
  13. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -1
  14. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
  15. package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
  16. package/dist/modal/components/Controls/Selects.d.ts +1 -1
  17. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
  18. package/dist/modal/components/Footer/Footer.d.ts +1 -1
  19. package/dist/modal/components/WalletCard/WalletCard.d.ts +2 -2
  20. package/dist/modal/components/common.d.ts +7 -7
  21. package/dist/modal/constants/constants.d.ts +1 -1
  22. package/dist/modal/index.d.ts +0 -2
  23. package/dist/modal/stores/index.d.ts +0 -2
  24. package/dist/modal/stores/modal/useModalStore.d.ts +22 -20
  25. package/dist/modal/types/commonTypes.d.ts +4 -9
  26. package/dist/modal/types/externalWallets.d.ts +0 -2
  27. package/dist/modal/types/modalProps.d.ts +1 -33
  28. package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
  29. package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
  30. package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
  31. package/dist/modal/utils/openPopup.d.ts +2 -2
  32. package/dist/modal/utils/stringFormatters.d.ts +0 -1
  33. package/dist/provider/ParaProvider.d.ts +3 -1
  34. package/dist/provider/actions/getAccount.d.ts +19 -7
  35. package/dist/provider/actions/getWallet.d.ts +1 -1
  36. package/dist/provider/actions/index.d.ts +25 -0
  37. package/dist/provider/actions/utils.d.ts +3 -0
  38. package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
  39. package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
  40. package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
  41. package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
  42. package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
  43. package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
  44. package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
  45. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
  46. package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
  47. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
  48. package/dist/provider/hooks/mutations/index.d.ts +25 -10
  49. package/dist/provider/hooks/mutations/utils.d.ts +4 -0
  50. package/dist/provider/hooks/queries/index.d.ts +0 -1
  51. package/dist/provider/hooks/queries/useAccount.d.ts +1 -6
  52. package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
  53. package/dist/provider/hooks/utils/useWalletState.d.ts +3 -2
  54. package/dist/provider/index.d.ts +1 -0
  55. package/dist/provider/providers/AuthProvider.d.ts +31 -0
  56. package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
  57. package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
  58. package/dist/provider/providers/ExternalWalletProvider.d.ts +73 -0
  59. package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
  60. package/dist/provider/stores/getters.d.ts +3 -3
  61. package/dist/provider/stores/setters.d.ts +1 -0
  62. package/dist/provider/stores/slices/config.d.ts +3 -0
  63. package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
  64. package/dist/provider/stores/slices/index.d.ts +1 -0
  65. package/dist/provider/stores/types.d.ts +46 -3
  66. package/dist/provider/types/externalWalletProviders.d.ts +12 -0
  67. package/dist/provider/types/provider.d.ts +119 -16
  68. package/dist/provider/types/utils.d.ts +16 -0
  69. package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
  70. package/dist/provider/utils/renameMutations.d.ts +3 -0
  71. package/package.json +19 -7
  72. package/dist/modal/ParaModal.js +0 -362
  73. package/dist/modal/components/Account/Account.js +0 -77
  74. package/dist/modal/components/AddFunds/AddFunds.js +0 -220
  75. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -72
  76. package/dist/modal/components/AddFunds/AddFundsDone.js +0 -43
  77. package/dist/modal/components/AddFunds/index.js +0 -4
  78. package/dist/modal/components/AuthInput/AuthInput.js +0 -283
  79. package/dist/modal/components/AuthInput/countryCodes.js +0 -42
  80. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -33
  81. package/dist/modal/components/AuthInput/phoneMasks.js +0 -253
  82. package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -37
  83. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -113
  84. package/dist/modal/components/AuthOptions/AuthOptions.js +0 -33
  85. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
  86. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -10
  87. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -18
  88. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -44
  89. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -55
  90. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -93
  91. package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -29
  92. package/dist/modal/components/Body/Body.js +0 -308
  93. package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -94
  94. package/dist/modal/components/ChainSwitch/config.js +0 -17
  95. package/dist/modal/components/Controls/Controls.js +0 -74
  96. package/dist/modal/components/Controls/Selects.js +0 -234
  97. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -140
  98. package/dist/modal/components/ExternalWalletStep/config.js +0 -17
  99. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +0 -96
  100. package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -172
  101. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
  102. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
  103. package/dist/modal/components/Footer/Footer.js +0 -93
  104. package/dist/modal/components/Header/Header.js +0 -43
  105. package/dist/modal/components/Header/hooks/useStepTitle.js +0 -50
  106. package/dist/modal/components/Hero/Hero.js +0 -116
  107. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -55
  108. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -28
  109. package/dist/modal/components/ModalContent/ModalContent.js +0 -324
  110. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
  111. package/dist/modal/components/OAuth/OAuth.js +0 -153
  112. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -139
  113. package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -23
  114. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -77
  115. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -101
  116. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -141
  117. package/dist/modal/components/StripeComponents/StripeComponents.js +0 -88
  118. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -24
  119. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -159
  120. package/dist/modal/components/Waiting/Waiting.js +0 -17
  121. package/dist/modal/components/WalletCard/PartnerIcon.js +0 -34
  122. package/dist/modal/components/WalletCard/WalletCard.js +0 -127
  123. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -52
  124. package/dist/modal/components/common.js +0 -96
  125. package/dist/modal/components/index.js +0 -2
  126. package/dist/modal/constants/constants.js +0 -111
  127. package/dist/modal/constants/defaults.js +0 -10
  128. package/dist/modal/constants/oAuthLogos.js +0 -24
  129. package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
  130. package/dist/modal/hooks/useActiveWallet.js +0 -15
  131. package/dist/modal/hooks/useCreateAccount.d.ts +0 -4
  132. package/dist/modal/hooks/useCreateAccount.js +0 -72
  133. package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
  134. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
  135. package/dist/modal/hooks/useGoBack.js +0 -42
  136. package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
  137. package/dist/modal/hooks/useSetLoginURLs.js +0 -49
  138. package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
  139. package/dist/modal/hooks/useWalletBalance.js +0 -47
  140. package/dist/modal/index.js +0 -33
  141. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
  142. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
  143. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
  144. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
  145. package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
  146. package/dist/modal/providers/ExternalWalletContext.js +0 -394
  147. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
  148. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
  149. package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
  150. package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
  151. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
  152. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
  153. package/dist/modal/stores/index.js +0 -4
  154. package/dist/modal/stores/modal/actions.js +0 -70
  155. package/dist/modal/stores/modal/useModalStore.js +0 -65
  156. package/dist/modal/stores/theme/actions.d.ts +0 -3
  157. package/dist/modal/stores/theme/actions.js +0 -28
  158. package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
  159. package/dist/modal/stores/theme/useThemeStore.js +0 -21
  160. package/dist/modal/stores/userInfo/actions.d.ts +0 -3
  161. package/dist/modal/stores/userInfo/actions.js +0 -30
  162. package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
  163. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
  164. package/dist/modal/types/commonTypes.js +0 -1
  165. package/dist/modal/types/externalWallets.js +0 -32
  166. package/dist/modal/types/modalProps.js +0 -12
  167. package/dist/modal/utils/authLayoutHelpers.js +0 -8
  168. package/dist/modal/utils/getMailtoLink.js +0 -10
  169. package/dist/modal/utils/getTileButtonFlex.js +0 -20
  170. package/dist/modal/utils/openPopup.js +0 -60
  171. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
  172. package/dist/modal/utils/steps.js +0 -232
  173. package/dist/modal/utils/stringFormatters.js +0 -19
  174. package/dist/modal/utils/validateOnRampConfig.js +0 -32
  175. package/dist/package.json +0 -6
  176. package/dist/provider/ParaProvider.js +0 -22
  177. package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
  178. package/dist/provider/actions/checkIfUserExists.js +0 -21
  179. package/dist/provider/actions/createUser.d.ts +0 -12
  180. package/dist/provider/actions/createUser.js +0 -26
  181. package/dist/provider/actions/getAccount.js +0 -22
  182. package/dist/provider/actions/getWallet.js +0 -14
  183. package/dist/provider/actions/getWalletBalance.d.ts +0 -2
  184. package/dist/provider/actions/getWalletBalance.js +0 -14
  185. package/dist/provider/actions/initiateLogin.d.ts +0 -4
  186. package/dist/provider/actions/initiateLogin.js +0 -20
  187. package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
  188. package/dist/provider/actions/keepSessionAlive.js +0 -20
  189. package/dist/provider/actions/logout.d.ts +0 -2
  190. package/dist/provider/actions/logout.js +0 -17
  191. package/dist/provider/actions/signMessage.d.ts +0 -8
  192. package/dist/provider/actions/signMessage.js +0 -20
  193. package/dist/provider/actions/signTransaction.d.ts +0 -8
  194. package/dist/provider/actions/signTransaction.js +0 -20
  195. package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
  196. package/dist/provider/actions/waitForAccountCreation.js +0 -21
  197. package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
  198. package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
  199. package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
  200. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
  201. package/dist/provider/hooks/index.js +0 -4
  202. package/dist/provider/hooks/mutations/index.js +0 -24
  203. package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
  204. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  205. package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
  206. package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
  207. package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
  208. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  209. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
  210. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
  211. package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
  212. package/dist/provider/hooks/mutations/useLogout.js +0 -30
  213. package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
  214. package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
  215. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
  216. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
  217. package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
  218. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  219. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
  220. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  221. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
  222. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  223. package/dist/provider/hooks/queries/index.js +0 -10
  224. package/dist/provider/hooks/queries/useAccount.js +0 -21
  225. package/dist/provider/hooks/queries/useWallet.js +0 -22
  226. package/dist/provider/hooks/queries/useWalletBalance.d.ts +0 -7
  227. package/dist/provider/hooks/queries/useWalletBalance.js +0 -26
  228. package/dist/provider/hooks/utils/index.js +0 -10
  229. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -74
  230. package/dist/provider/hooks/utils/useClient.js +0 -10
  231. package/dist/provider/hooks/utils/useEventListeners.js +0 -105
  232. package/dist/provider/hooks/utils/useInternalClient.js +0 -10
  233. package/dist/provider/hooks/utils/useModal.js +0 -17
  234. package/dist/provider/hooks/utils/useWalletState.js +0 -33
  235. package/dist/provider/index.js +0 -8
  236. package/dist/provider/stores/getters.js +0 -13
  237. package/dist/provider/stores/slices/client.js +0 -9
  238. package/dist/provider/stores/slices/index.js +0 -4
  239. package/dist/provider/stores/slices/modal.js +0 -9
  240. package/dist/provider/stores/slices/wallet.js +0 -13
  241. package/dist/provider/stores/types.js +0 -1
  242. package/dist/provider/stores/useStore.js +0 -27
  243. package/dist/provider/types/provider.js +0 -1
  244. package/dist/provider/types/query.js +0 -1
  245. package/dist/provider/types/utils.js +0 -1
  246. package/dist/provider/utils/constants.d.ts +0 -5
  247. package/dist/provider/utils/constants.js +0 -11
  248. package/dist/provider/utils/renameMutations.js +0 -16
@@ -1,394 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../chunk-MMUBH76A.js";
5
- import { jsx } from "react/jsx-runtime";
6
- import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
7
- import { useModalStore, useUserInfoStore } from "../stores/index.js";
8
- import { ModalStep } from "../utils/steps.js";
9
- import { AuthMethod, WalletType, isIOS, isIOSWebview, isMobile, truncateAddress } from "@getpara/web-sdk";
10
- import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
11
- import { getExternalWalletDisplayName } from "@getpara/react-common";
12
- import { useSetLoginURLs } from "../hooks/useSetLoginURLs.js";
13
- const defaultExternalWallet = {
14
- wallets: [],
15
- chains: [],
16
- chainId: void 0,
17
- wallet: void 0,
18
- qrUri: void 0,
19
- chainIdSwitchingTo: void 0,
20
- walletDisplayHelpers: {
21
- showExtension: false,
22
- showMobile: false,
23
- isSolanaMobileIOS: false,
24
- isCosmosMobileWallet: false
25
- },
26
- username: void 0,
27
- avatar: void 0,
28
- balance: void 0,
29
- connectExternalWallet: () => {
30
- },
31
- disconnectExternalWallet: () => Promise.resolve(),
32
- switchChain: () => Promise.resolve(),
33
- setChainIdSwitchingTo: () => {
34
- },
35
- verifyWalletSignature: () => Promise.resolve({})
36
- };
37
- const ExternalWalletContext = createContext(defaultExternalWallet);
38
- function ExternalWalletProvider({
39
- children,
40
- evmContext,
41
- solanaContext,
42
- cosmosContext,
43
- walletSort,
44
- externalWalletsWithFullAuth
45
- }) {
46
- const {
47
- wallets: evmWallets,
48
- disconnect: evmDisconnect,
49
- chains: evmChains,
50
- chainId: evmChainId,
51
- switchChain: evmSwitchChain,
52
- username: evmUsername,
53
- avatar: evmAvatar,
54
- balance: evmBalance,
55
- signVerificationMessage: evmSignVerificationMessage
56
- } = useContext(evmContext);
57
- const {
58
- wallets: solanaWallets,
59
- disconnect: solanaDisconnect,
60
- signVerificationMessage: solanaSignVerificationMessage
61
- } = useContext(solanaContext);
62
- const {
63
- wallets: cosmosWallets,
64
- disconnect: cosmosDisconnect,
65
- chains: cosmosChains,
66
- chainId: cosmosChainId,
67
- switchChain: cosmosSwitchChain,
68
- signVerificationMessage: cosmosSignVerificationMessage
69
- } = useContext(cosmosContext);
70
- const setStep = useModalStore((state) => state.setStep);
71
- const setFlow = useModalStore((state) => state.setFlow);
72
- const setSupportedAuthMethods = useModalStore((state) => state.setSupportedAuthMethods);
73
- const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
74
- const setStepDirection = useModalStore((state) => state.setStepDirection);
75
- const setIsExternalWalletConnecting = useModalStore((state) => state.setIsExternalWalletConnecting);
76
- const isExternalWalletConnecting = useModalStore((state) => state.isExternalWalletConnecting);
77
- const setSelectedExternalWalletId = useModalStore((state) => state.setSelectedExternalWalletId);
78
- const selectedExternalWalletId = useModalStore((state) => state.selectedExternalWalletId);
79
- const setExternalWalletError = useModalStore((state) => state.setExternalWalletError);
80
- const setIsUsingMobileConnector = useModalStore((state) => state.setIsUsingMobileConnector);
81
- const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
82
- const para = useInternalClient();
83
- const setAuthInfo = useUserInfoStore((state) => state.setAuthInfo);
84
- const setLoginURLs = useSetLoginURLs();
85
- const [qrUri, setQrUri] = useState();
86
- const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
87
- const wallets = [...evmWallets, ...solanaWallets, ...cosmosWallets].filter((w) => walletSort.includes(w.id.toUpperCase())).sort(
88
- (a, b) => walletSort.indexOf(a.id.toUpperCase()) - walletSort.indexOf(b.id.toUpperCase())
89
- ).sort((a, b) => a.installed === b.installed ? 0 : a.installed ? -1 : 1);
90
- const wallet = useMemo(() => wallets.find((w) => w.id === selectedExternalWalletId), [wallets, selectedExternalWalletId]);
91
- const updateQrUri = () => __async(this, null, function* () {
92
- var _a;
93
- const uri = yield (_a = wallet == null ? void 0 : wallet.getQrUri) == null ? void 0 : _a.call(wallet);
94
- setQrUri(uri);
95
- });
96
- useEffect(() => {
97
- if (wallet) {
98
- if (!qrUri) {
99
- updateQrUri();
100
- }
101
- } else if (qrUri) {
102
- setQrUri(void 0);
103
- }
104
- }, [wallet]);
105
- const balance = useMemo(() => {
106
- var _a;
107
- const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
108
- switch (walletType) {
109
- case WalletType.EVM: {
110
- return evmBalance;
111
- }
112
- default: {
113
- return void 0;
114
- }
115
- }
116
- }, [evmBalance, selectedExternalWalletId]);
117
- const chains = useMemo(() => {
118
- var _a;
119
- const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
120
- switch (walletType) {
121
- case WalletType.COSMOS: {
122
- return cosmosChains;
123
- }
124
- case WalletType.EVM: {
125
- return evmChains;
126
- }
127
- default: {
128
- return [];
129
- }
130
- }
131
- }, [cosmosChains, evmChains, selectedExternalWalletId]);
132
- const chainId = useMemo(() => {
133
- var _a;
134
- const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
135
- switch (walletType) {
136
- case WalletType.COSMOS: {
137
- return cosmosChainId;
138
- }
139
- case WalletType.EVM: {
140
- return evmChainId == null ? void 0 : evmChainId.toString();
141
- }
142
- default: {
143
- return void 0;
144
- }
145
- }
146
- }, [cosmosChains, evmChains, selectedExternalWalletId]);
147
- const switchChain = useCallback(
148
- (chainId2) => __async(this, null, function* () {
149
- var _a;
150
- const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
151
- if (walletType) {
152
- let resp;
153
- setExternalWalletError();
154
- setChainIdSwitchingTo(chainId2);
155
- switch (walletType) {
156
- case WalletType.COSMOS: {
157
- setStep(ModalStep.CHAIN_SWITCH);
158
- resp = yield cosmosSwitchChain(chainId2);
159
- break;
160
- }
161
- case WalletType.EVM: {
162
- setStep(ModalStep.CHAIN_SWITCH);
163
- resp = yield evmSwitchChain(parseInt(chainId2));
164
- break;
165
- }
166
- default: {
167
- break;
168
- }
169
- }
170
- if (resp.error) {
171
- setExternalWalletError(resp.error);
172
- } else {
173
- setChainIdSwitchingTo(void 0);
174
- setStepDirection(-1);
175
- setStep(ModalStep.ACCOUNT_MAIN);
176
- }
177
- }
178
- }),
179
- [evmSwitchChain, cosmosSwitchChain]
180
- );
181
- const verifyWalletSignature = useCallback(() => __async(this, null, function* () {
182
- var _a;
183
- setExternalWalletError();
184
- const walletType = (_a = Object.values(para.externalWallets)[0]) == null ? void 0 : _a.type;
185
- if (walletType) {
186
- const resp = {
187
- address: "",
188
- signature: "",
189
- cosmosPublicKeyHex: "",
190
- cosmosSigner: ""
191
- };
192
- switch (walletType) {
193
- case WalletType.COSMOS: {
194
- const { signature, error, cosmosPublicKeyHex, cosmosSigner, address } = yield cosmosSignVerificationMessage();
195
- if (error) {
196
- setExternalWalletError([error]);
197
- } else if (signature) {
198
- resp.address = address;
199
- resp.signature = signature;
200
- resp.cosmosPublicKeyHex = cosmosPublicKeyHex;
201
- resp.cosmosSigner = cosmosSigner;
202
- }
203
- return resp;
204
- }
205
- case WalletType.EVM: {
206
- const { signature, error, address } = yield evmSignVerificationMessage();
207
- if (error) {
208
- setExternalWalletError([error]);
209
- } else if (signature && address) {
210
- resp.address = address;
211
- resp.signature = signature;
212
- }
213
- return resp;
214
- }
215
- case WalletType.SOLANA: {
216
- const { signature, error, address } = yield solanaSignVerificationMessage();
217
- if (error) {
218
- setExternalWalletError([error]);
219
- } else if (signature && address) {
220
- resp.address = address;
221
- resp.signature = signature;
222
- }
223
- return resp;
224
- }
225
- default: {
226
- break;
227
- }
228
- }
229
- }
230
- }), [evmSwitchChain, cosmosSwitchChain]);
231
- const completeFullAuth = (address, type, userExists, isVerified, bufferAddress) => __async(this, null, function* () {
232
- setAuthInfo({
233
- displayName: getExternalWalletDisplayName({
234
- address,
235
- type
236
- }),
237
- externalWalletAddress: bufferAddress != null ? bufferAddress : address
238
- });
239
- if (userExists && isVerified) {
240
- const supportedAuthMethods = yield para.supportedAuthMethods({
241
- externalWalletAddress: bufferAddress != null ? bufferAddress : address
242
- });
243
- if (!supportedAuthMethods.size) {
244
- setFlow("signUp");
245
- setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
246
- return;
247
- }
248
- yield para.initiateUserLoginV2({
249
- externalWalletAddress: bufferAddress != null ? bufferAddress : address
250
- });
251
- const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY) ? yield para.getUserBiometricLocationHints() : [];
252
- yield setLoginURLs({ supportedAuthMethods, authType: "externalWallet" });
253
- setFlow("login");
254
- setStep(ModalStep.BIOMETRIC_LOGIN);
255
- setSupportedAuthMethods(supportedAuthMethods);
256
- setBiometricLocationHints(biometricLocationHints);
257
- } else {
258
- setFlow("signUp");
259
- setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
260
- }
261
- });
262
- const connectExternalWallet = useCallback(
263
- (wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
264
- if (isExternalWalletConnecting && isManualWalletConnect) {
265
- yield evmDisconnect();
266
- yield solanaDisconnect();
267
- yield cosmosDisconnect();
268
- setQrUri(void 0);
269
- setIsExternalWalletConnecting(false);
270
- }
271
- if (isResetAfterManualWalletConnect || isManualWalletConnect || !isExternalWalletConnecting) {
272
- setExternalWalletError();
273
- setIsExternalWalletConnecting(true);
274
- setIsUsingMobileConnector(isMobileConnect);
275
- const { address, bufferAddress, error, userExists, isVerified } = yield isMobileConnect ? wallet2.connectMobile({ isManualWalletConnect }) : wallet2.connect();
276
- if (error) {
277
- setExternalWalletError([error]);
278
- setIsUsingMobileConnector();
279
- if (isManualWalletConnect && error === "Connection request rejected") {
280
- setExternalWalletError();
281
- yield connectExternalWallet(wallet2, false, false, true);
282
- yield updateQrUri();
283
- return;
284
- }
285
- } else if (address) {
286
- if (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase())) {
287
- yield completeFullAuth(address, wallet2.type, userExists, isVerified, bufferAddress);
288
- } else {
289
- setStep(ModalStep.LOGIN_DONE);
290
- }
291
- }
292
- setIsExternalWalletConnecting(false);
293
- }
294
- }),
295
- [isExternalWalletConnecting, externalWalletsWithFullAuth]
296
- );
297
- const disconnectExternalWallet = () => __async(this, null, function* () {
298
- yield para.logout();
299
- yield evmDisconnect();
300
- yield cosmosDisconnect();
301
- setSelectedExternalWalletId();
302
- yield solanaDisconnect();
303
- });
304
- const walletDisplayHelpers = {
305
- // Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
306
- // Also show the extension connection if on desktop for a solana wallet (no walletConnect)
307
- showExtension: !isMobile() && ((wallet == null ? void 0 : wallet.isExtension) && (wallet == null ? void 0 : wallet.installed) || !(wallet == null ? void 0 : wallet.isMobile) || (wallet == null ? void 0 : wallet.type) === WalletType.SOLANA),
308
- // Show the mobile screen if on mobile and the wallet is a mobile wallet or if on desktop and the wallet isn't installed
309
- showMobile: isMobile() && (wallet == null ? void 0 : wallet.isMobile) || !isMobile() && !(wallet == null ? void 0 : wallet.installed),
310
- isSolanaMobileIOS: isIOS() && isMobile() && !isIOSWebview() && (wallet == null ? void 0 : wallet.type) === WalletType.SOLANA,
311
- isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) === WalletType.COSMOS && isUsingMobileConnector
312
- };
313
- const username = useMemo(() => {
314
- let username2;
315
- const storedExternalWallet = Object.values(para.externalWallets || {})[0];
316
- if (storedExternalWallet) {
317
- const walletType = storedExternalWallet == null ? void 0 : storedExternalWallet.type;
318
- switch (walletType) {
319
- case WalletType.EVM: {
320
- username2 = evmUsername ? evmUsername.startsWith("0x") ? truncateAddress(evmUsername, "EVM") : evmUsername : void 0;
321
- break;
322
- }
323
- default: {
324
- username2 = storedExternalWallet.address ? truncateAddress(storedExternalWallet.address, storedExternalWallet.type) : void 0;
325
- break;
326
- }
327
- }
328
- }
329
- return username2;
330
- }, [evmUsername, wallet]);
331
- const avatar = useMemo(() => {
332
- var _a;
333
- const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
334
- if (walletType) {
335
- switch (walletType) {
336
- case WalletType.EVM: {
337
- return evmAvatar;
338
- }
339
- default: {
340
- return void 0;
341
- }
342
- }
343
- }
344
- }, [evmAvatar, wallet]);
345
- return /* @__PURE__ */ jsx(
346
- ExternalWalletContext.Provider,
347
- {
348
- value: useMemo(
349
- () => ({
350
- wallets,
351
- chains,
352
- chainId,
353
- wallet,
354
- qrUri,
355
- walletDisplayHelpers,
356
- chainIdSwitchingTo,
357
- username,
358
- avatar,
359
- balance,
360
- connectExternalWallet,
361
- disconnectExternalWallet,
362
- switchChain,
363
- setChainIdSwitchingTo,
364
- verifyWalletSignature
365
- }),
366
- [
367
- wallets,
368
- chains,
369
- chainId,
370
- wallet,
371
- qrUri,
372
- walletDisplayHelpers,
373
- chainIdSwitchingTo,
374
- username,
375
- avatar,
376
- balance,
377
- disconnectExternalWallet,
378
- connectExternalWallet,
379
- switchChain,
380
- setChainIdSwitchingTo,
381
- verifyWalletSignature
382
- ]
383
- ),
384
- children
385
- }
386
- );
387
- }
388
- const useExternalWallets = () => useContext(ExternalWalletContext);
389
- export {
390
- ExternalWalletContext,
391
- ExternalWalletProvider,
392
- defaultExternalWallet,
393
- useExternalWallets
394
- };
@@ -1,32 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { CommonWallet } from '../types/commonTypes.js';
3
- import ParaWeb from '@getpara/web-sdk';
4
- export declare const defaultSolanaExternalWallet: {
5
- wallets: any[];
6
- disconnect: () => Promise<void>;
7
- signMessage: () => Promise<{}>;
8
- signVerificationMessage: () => Promise<{}>;
9
- };
10
- export type SolanaExternalWalletContextType = {
11
- wallets: CommonWallet[];
12
- disconnect: () => Promise<void>;
13
- signMessage: (message: string) => Promise<{
14
- signature?: string;
15
- error?: string;
16
- }>;
17
- signVerificationMessage: () => Promise<{
18
- address?: string;
19
- signature?: string;
20
- error?: string;
21
- }>;
22
- };
23
- export declare const SolanaExternalWalletContext: import("react").Context<SolanaExternalWalletContextType>;
24
- export interface SolanaExternalWalletProviderProps {
25
- children: ReactNode;
26
- para: ParaWeb;
27
- onSwitchWallet: (args: {
28
- address?: string;
29
- error?: string;
30
- }) => void;
31
- }
32
- export declare function SolanaExternalWalletProvider({ children }: SolanaExternalWalletProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,32 +0,0 @@
1
- "use client";
2
- import "../../chunk-MMUBH76A.js";
3
- import { jsx } from "react/jsx-runtime";
4
- import { createContext, useMemo } from "react";
5
- const defaultSolanaExternalWallet = {
6
- wallets: [],
7
- disconnect: () => Promise.resolve(),
8
- signMessage: () => Promise.resolve({}),
9
- signVerificationMessage: () => Promise.resolve({})
10
- };
11
- const SolanaExternalWalletContext = createContext(defaultSolanaExternalWallet);
12
- function SolanaExternalWalletProvider({ children }) {
13
- const wallets = [];
14
- const disconnect = () => Promise.resolve();
15
- const signMessage = () => Promise.resolve({});
16
- const signVerificationMessage = () => Promise.resolve({});
17
- return /* @__PURE__ */ jsx(
18
- SolanaExternalWalletContext.Provider,
19
- {
20
- value: useMemo(
21
- () => ({ wallets, disconnect, signMessage, signVerificationMessage }),
22
- [wallets, disconnect, signMessage, signVerificationMessage]
23
- ),
24
- children
25
- }
26
- );
27
- }
28
- export {
29
- SolanaExternalWalletContext,
30
- SolanaExternalWalletProvider,
31
- defaultSolanaExternalWallet
32
- };
@@ -1,3 +0,0 @@
1
- import { StoreApi } from 'zustand';
2
- import { ExternalWalletProviderActions, ExternalWalletProviderStore } from './useExternalWalletProviderStore.js';
3
- export declare const getActions: (set: StoreApi<ExternalWalletProviderStore>["setState"]) => ExternalWalletProviderActions;
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- const getActions = (set) => ({
4
- updateState: (state) => {
5
- set(state);
6
- }
7
- });
8
- export {
9
- getActions
10
- };
@@ -1,22 +0,0 @@
1
- import { EvmExternalWalletContextType, EvmExternalWalletProvider } from '../../providers/EvmExternalWalletContextStub.js';
2
- import { Context } from 'react';
3
- import { SolanaExternalWalletContextType, SolanaExternalWalletProvider } from '../../providers/SolanaExternalWalletContextStub.js';
4
- import { CosmosExternalWalletContextType, CosmosExternalWalletProvider } from '../../providers/CosmosExternalWalletContextStub.js';
5
- import { TExternalWallet } from '../../types/externalWallets.js';
6
- interface ExternalWalletProviderState {
7
- EvmProvider?: typeof EvmExternalWalletProvider;
8
- evmContext?: Context<EvmExternalWalletContextType>;
9
- SolanaProvider?: typeof SolanaExternalWalletProvider;
10
- solanaContext?: Context<SolanaExternalWalletContextType>;
11
- CosmosProvider?: typeof CosmosExternalWalletProvider;
12
- cosmosContext?: Context<CosmosExternalWalletContextType>;
13
- connectParaEvmWallet?: () => Promise<any>;
14
- connectParaCosmosWallet?: () => Promise<any>;
15
- fullAuthWallets: TExternalWallet[];
16
- }
17
- export interface ExternalWalletProviderActions {
18
- updateState: (state: Partial<ExternalWalletProviderState>) => void;
19
- }
20
- export type ExternalWalletProviderStore = ExternalWalletProviderState & ExternalWalletProviderActions;
21
- export declare const useExternalWalletProviderStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ExternalWalletProviderStore>>;
22
- export {};
@@ -1,21 +0,0 @@
1
- "use client";
2
- import {
3
- __spreadValues
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { create } from "zustand";
6
- import { getActions } from "./actions.js";
7
- const DEFAULT_EX_WALLET_PROVIDER_STATE = {
8
- EvmProvider: void 0,
9
- evmContext: void 0,
10
- SolanaProvider: void 0,
11
- solanaContext: void 0,
12
- CosmosProvider: void 0,
13
- cosmosContext: void 0,
14
- connectParaEvmWallet: void 0,
15
- connectParaCosmosWallet: void 0,
16
- fullAuthWallets: []
17
- };
18
- const useExternalWalletProviderStore = create((set) => __spreadValues(__spreadValues({}, DEFAULT_EX_WALLET_PROVIDER_STATE), getActions(set)));
19
- export {
20
- useExternalWalletProviderStore
21
- };
@@ -1,4 +0,0 @@
1
- "use client";
2
- export * from "./modal/useModalStore.js";
3
- export * from "./userInfo/useUserInfoStore.js";
4
- export * from "./theme/useThemeStore.js";
@@ -1,70 +0,0 @@
1
- "use client";
2
- import {
3
- __spreadValues
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { DEFAULT_MODAL_STATE } from "./useModalStore.js";
6
- import { AccountPreviousStep, LoginPreviousStep, ModalStep, SignUpPreviousStep } from "../../utils/steps.js";
7
- const getActions = (set, get) => ({
8
- resetState: () => set(DEFAULT_MODAL_STATE),
9
- setOnModalStepChange: (onModalStepChange) => set({ onModalStepChange }),
10
- setStep: (step) => {
11
- const onModalStepChange = get().onModalStepChange;
12
- const previousStep = get().step;
13
- set({ step });
14
- onModalStepChange == null ? void 0 : onModalStepChange({ previousStep, currentStep: step, canGoBack: get().hasPreviousStep() });
15
- },
16
- decrementStep: () => {
17
- var _a;
18
- const onModalStepChange = get().onModalStepChange;
19
- const isLogin = get().flow === "login";
20
- const isAccount = get().flow === "account";
21
- const currentStep = get().step;
22
- const webAuthURLForCreate = get().webAuthURLForCreate;
23
- const iFrameUrl = get().iFrameUrl;
24
- const refs = get().refs;
25
- let prevStep = (isAccount ? AccountPreviousStep : isLogin ? LoginPreviousStep : SignUpPreviousStep)[currentStep];
26
- if (currentStep === ModalStep.PASSWORD_CREATION && iFrameUrl && !webAuthURLForCreate) {
27
- prevStep = ModalStep.AUTH_MAIN;
28
- }
29
- if (currentStep === ModalStep.EX_WALLET_SELECTED) {
30
- set({ selectedExternalWalletId: void 0, isExternalWalletConnecting: false, externalWalletError: void 0 });
31
- }
32
- if (prevStep) {
33
- set({ step: prevStep, stepDirection: -1 });
34
- onModalStepChange == null ? void 0 : onModalStepChange({ previousStep: currentStep, currentStep: prevStep, canGoBack: get().hasPreviousStep() });
35
- }
36
- (_a = refs.popupWindow.current) == null ? void 0 : _a.close();
37
- refs.popupWindow.current = void 0;
38
- },
39
- hasPreviousStep: () => {
40
- const isLogin = get().flow === "login";
41
- const isAccount = get().flow === "account";
42
- const currentStep = get().step;
43
- return !!(isAccount ? AccountPreviousStep[currentStep] : isLogin ? LoginPreviousStep[currentStep] : SignUpPreviousStep[currentStep]);
44
- },
45
- setFlow: (flow) => set({ flow }),
46
- isLogin: () => get().flow === "login",
47
- isAccount: () => get().flow === "account",
48
- setWebAuthURLForLogin: (url) => set({ webAuthURLForLogin: url }),
49
- setWebAuthURLForCreate: (url) => set({ webAuthURLForCreate: url }),
50
- setPasswordUrlForLogin: (url) => set({ passwordUrlForLogin: url }),
51
- setSupportedAuthMethods: (supportedAuthMethods) => set({ supportedAuthMethods }),
52
- setOnRampPurchase: (onRampPurchase) => set((state) => ({ onRampPurchase: __spreadValues(__spreadValues({}, state.onRampPurchase || {}), onRampPurchase) })),
53
- setOnRampConfig: (onRampConfig) => set({ onRampConfig }),
54
- setIsFullyLoggedIn: (isFullyLoggedIn) => set({ isFullyLoggedIn }),
55
- setAccountAddFundTab: (accountAddFundTab) => set({ accountAddFundTab }),
56
- setSelectedExternalWalletId: (selectedExternalWalletId) => set({ selectedExternalWalletId }),
57
- setIsExternalWalletConnecting: (isExternalWalletConnecting) => set({ isExternalWalletConnecting }),
58
- setExternalWalletError: (externalWalletError) => set({ externalWalletError }),
59
- setIsUsingMobileConnector: (isUsingMobileConnector) => set({ isUsingMobileConnector }),
60
- setStepDirection: (stepDirection) => set({ stepDirection }),
61
- setFarcasterConnectUri: (farcasterConnectUri) => set({ farcasterConnectUri }),
62
- setBiometricLocationHints: (biometricLocationHints) => set({ biometricLocationHints }),
63
- setIFrameUrl: (iFrameUrl) => set({ iFrameUrl }),
64
- setIsIFrameReady: (isIFrameReady) => set({ isIFrameReady }),
65
- setAuthStepRoute: (authStepRoute) => set({ authStepRoute }),
66
- setIsPasskeySupported: (isPasskeySupported) => set({ isPasskeySupported })
67
- });
68
- export {
69
- getActions
70
- };
@@ -1,65 +0,0 @@
1
- "use client";
2
- import {
3
- __spreadValues
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { create } from "zustand";
6
- import { persist, createJSONStorage } from "zustand/middleware";
7
- import { ModalStep } from "../../utils/steps.js";
8
- import { getActions } from "./actions.js";
9
- import { createRef } from "react";
10
- const DEFAULT_MODAL_STATE = {
11
- flow: void 0,
12
- stepDirection: 1,
13
- webAuthURLForLogin: void 0,
14
- webAuthURLForCreate: void 0,
15
- passwordUrlForLogin: void 0,
16
- supportedAuthMethods: /* @__PURE__ */ new Set(),
17
- onModalStepChange: void 0,
18
- onRampPurchase: void 0,
19
- isFullyLoggedIn: false,
20
- accountAddFundTab: void 0,
21
- isExternalWalletConnecting: false,
22
- externalWalletError: void 0,
23
- activeWallet: [void 0, void 0],
24
- farcasterConnectUri: void 0,
25
- biometricLocationHints: void 0,
26
- iFrameUrl: void 0,
27
- isIFrameReady: void 0,
28
- refs: {
29
- popupWindow: createRef(),
30
- poll: createRef(),
31
- currentStep: createRef()
32
- },
33
- authStepRoute: void 0,
34
- isPasskeySupported: true
35
- };
36
- const useModalStore = create()(
37
- persist(
38
- (set, get) => __spreadValues(__spreadValues({
39
- step: ModalStep.AUTH_MAIN,
40
- onRampConfig: void 0,
41
- activeWallet: void 0
42
- }, DEFAULT_MODAL_STATE), getActions(set, get)),
43
- {
44
- version: 1,
45
- name: "@PARA/modalState",
46
- storage: createJSONStorage(() => localStorage),
47
- partialize: (state) => ({
48
- step: state.step,
49
- webAuthURLForLogin: state.webAuthURLForLogin,
50
- webAuthURLForCreate: state.webAuthURLForCreate,
51
- passwordUrlForLogin: state.passwordUrlForLogin,
52
- biometricLocationHints: state.biometricLocationHints,
53
- onRampPurchase: state.onRampPurchase,
54
- selectedExternalWalletId: state.selectedExternalWalletId,
55
- isUsingMobileConnector: state.isUsingMobileConnector,
56
- supportedAuthMethods: state.supportedAuthMethods,
57
- isPasskeySupported: state.isPasskeySupported
58
- })
59
- }
60
- )
61
- );
62
- export {
63
- DEFAULT_MODAL_STATE,
64
- useModalStore
65
- };
@@ -1,3 +0,0 @@
1
- import { StoreApi } from 'zustand';
2
- import { ThemeActions, ThemeStore } from './useThemeStore.js';
3
- export declare const getActions: (set: StoreApi<ThemeStore>["setState"], get: StoreApi<ThemeStore>["getState"]) => ThemeActions;