@getpara/react-sdk 1.6.0 → 1.6.1-dev.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 (142) hide show
  1. package/dist/index.js +6 -6367
  2. package/dist/modal/ParaModal.js +337 -0
  3. package/dist/modal/components/Account/Account.js +69 -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 +52 -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 +304 -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 +213 -0
  28. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +151 -0
  29. package/dist/modal/components/ExternalWalletStep/config.js +17 -0
  30. package/dist/modal/components/ExternalWallets/ExternalWallets.js +172 -0
  31. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +123 -0
  32. package/dist/modal/components/Footer/Footer.js +93 -0
  33. package/dist/modal/components/Header/Header.js +43 -0
  34. package/dist/modal/components/Header/hooks/useStepTitle.js +50 -0
  35. package/dist/modal/components/Hero/Hero.js +122 -0
  36. package/dist/modal/components/IFrameStep/IFrameStep.js +55 -0
  37. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +28 -0
  38. package/dist/modal/components/ModalContent/ModalContent.js +310 -0
  39. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
  40. package/dist/modal/components/OAuth/OAuth.js +153 -0
  41. package/dist/modal/components/OAuth/TelegramOAuthStep.js +139 -0
  42. package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
  43. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
  44. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +101 -0
  45. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +141 -0
  46. package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
  47. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +24 -0
  48. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +159 -0
  49. package/dist/modal/components/Waiting/Waiting.js +17 -0
  50. package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
  51. package/dist/modal/components/WalletCard/WalletCard.js +127 -0
  52. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +52 -0
  53. package/dist/modal/components/common.js +83 -0
  54. package/dist/modal/components/index.js +2 -0
  55. package/dist/modal/constants/constants.js +111 -0
  56. package/dist/modal/constants/defaults.js +10 -0
  57. package/dist/modal/constants/oAuthLogos.js +24 -0
  58. package/dist/modal/hooks/useActiveWallet.js +15 -0
  59. package/dist/modal/hooks/useCreateAccount.js +72 -0
  60. package/dist/modal/hooks/useEmbeddedExternalConnection.js +39 -0
  61. package/dist/modal/hooks/useGoBack.js +35 -0
  62. package/dist/modal/hooks/useSetLoginURLs.d.ts +8 -0
  63. package/dist/modal/hooks/useSetLoginURLs.js +45 -0
  64. package/dist/modal/index.js +32 -0
  65. package/dist/modal/providers/CosmosExternalWalletContextStub.js +34 -0
  66. package/dist/modal/providers/EvmExternalWalletContextStub.js +38 -0
  67. package/dist/modal/providers/ExternalWalletContext.js +275 -0
  68. package/dist/modal/providers/SolanaExternalWalletContextStub.js +19 -0
  69. package/dist/modal/stores/externalWalletProvider/actions.js +10 -0
  70. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +20 -0
  71. package/dist/modal/stores/index.js +4 -0
  72. package/dist/modal/stores/modal/actions.js +70 -0
  73. package/dist/modal/stores/modal/useModalStore.js +65 -0
  74. package/dist/modal/stores/theme/actions.js +28 -0
  75. package/dist/modal/stores/theme/useThemeStore.js +21 -0
  76. package/dist/modal/stores/userInfo/actions.js +30 -0
  77. package/dist/modal/stores/userInfo/useUserInfoStore.js +17 -0
  78. package/dist/modal/types/commonTypes.js +1 -0
  79. package/dist/modal/types/externalWallets.js +31 -0
  80. package/dist/modal/types/modalProps.js +12 -0
  81. package/dist/modal/utils/authLayoutHelpers.js +8 -0
  82. package/dist/modal/utils/getMailtoLink.js +10 -0
  83. package/dist/modal/utils/getTileButtonFlex.js +20 -0
  84. package/dist/modal/utils/openPopup.js +60 -0
  85. package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
  86. package/dist/modal/utils/steps.js +228 -0
  87. package/dist/modal/utils/stringFormatters.js +14 -0
  88. package/dist/modal/utils/validateOnRampConfig.js +32 -0
  89. package/dist/provider/ParaProvider.js +22 -0
  90. package/dist/provider/actions/checkIfUserExists.js +21 -0
  91. package/dist/provider/actions/createUser.js +26 -0
  92. package/dist/provider/actions/getAccount.js +22 -0
  93. package/dist/provider/actions/getWallet.js +14 -0
  94. package/dist/provider/actions/initiateLogin.js +20 -0
  95. package/dist/provider/actions/keepSessionAlive.js +20 -0
  96. package/dist/provider/actions/logout.js +17 -0
  97. package/dist/provider/actions/signMessage.js +20 -0
  98. package/dist/provider/actions/signTransaction.js +20 -0
  99. package/dist/provider/actions/waitForAccountCreation.js +21 -0
  100. package/dist/provider/actions/waitForLoginAndSetup.js +24 -0
  101. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +21 -0
  102. package/dist/provider/hooks/index.js +4 -0
  103. package/dist/provider/hooks/mutations/index.js +24 -0
  104. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
  105. package/dist/provider/hooks/mutations/useCreateUser.js +20 -0
  106. package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
  107. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +20 -0
  108. package/dist/provider/hooks/mutations/useLogout.js +30 -0
  109. package/dist/provider/hooks/mutations/useSignMessage.js +33 -0
  110. package/dist/provider/hooks/mutations/useSignTransaction.js +33 -0
  111. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
  112. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
  113. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
  114. package/dist/provider/hooks/queries/index.js +8 -0
  115. package/dist/provider/hooks/queries/useAccount.js +21 -0
  116. package/dist/provider/hooks/queries/useWallet.js +22 -0
  117. package/dist/provider/hooks/utils/index.js +10 -0
  118. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
  119. package/dist/provider/hooks/utils/useClient.js +10 -0
  120. package/dist/provider/hooks/utils/useEventListeners.js +105 -0
  121. package/dist/provider/hooks/utils/useInternalClient.js +10 -0
  122. package/dist/provider/hooks/utils/useModal.js +17 -0
  123. package/dist/provider/hooks/utils/useWalletState.js +33 -0
  124. package/dist/provider/index.js +8 -0
  125. package/dist/provider/stores/getters.js +13 -0
  126. package/dist/provider/stores/slices/client.js +9 -0
  127. package/dist/provider/stores/slices/index.js +4 -0
  128. package/dist/provider/stores/slices/modal.js +9 -0
  129. package/dist/provider/stores/slices/wallet.js +11 -0
  130. package/dist/provider/stores/types.js +1 -0
  131. package/dist/provider/stores/useStore.js +27 -0
  132. package/dist/provider/types/provider.js +1 -0
  133. package/dist/provider/types/query.js +1 -0
  134. package/dist/provider/types/utils.js +1 -0
  135. package/dist/provider/utils/renameMutations.js +16 -0
  136. package/package.json +2 -2
  137. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  138. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  139. package/dist/chunk-MMUBH76A.js.br +0 -0
  140. package/dist/chunk-MMUBH76A.js.gz +0 -0
  141. package/dist/index.js.br +0 -0
  142. package/dist/index.js.gz +0 -0
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import "../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createContext, useMemo } from "react";
5
+ const defaultCosmosExternalWallet = {
6
+ wallets: [],
7
+ chains: [],
8
+ chainId: void 0,
9
+ disconnect: () => Promise.resolve(),
10
+ switchChain: () => Promise.resolve({})
11
+ };
12
+ const CosmosExternalWalletContext = createContext(defaultCosmosExternalWallet);
13
+ function CosmosExternalWalletProvider({ children }) {
14
+ const wallets = [];
15
+ const chains = [];
16
+ const chainId = void 0;
17
+ const disconnect = () => Promise.resolve();
18
+ const switchChain = () => Promise.resolve({});
19
+ return /* @__PURE__ */ jsx(
20
+ CosmosExternalWalletContext.Provider,
21
+ {
22
+ value: useMemo(
23
+ () => ({ wallets, chains, chainId, disconnect, switchChain }),
24
+ [wallets, chains, chainId, disconnect, switchChain]
25
+ ),
26
+ children
27
+ }
28
+ );
29
+ }
30
+ export {
31
+ CosmosExternalWalletContext,
32
+ CosmosExternalWalletProvider,
33
+ defaultCosmosExternalWallet
34
+ };
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import "../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createContext, useMemo } from "react";
5
+ const defaultEvmExternalWallet = {
6
+ wallets: [],
7
+ chains: [],
8
+ chainId: void 0,
9
+ username: void 0,
10
+ avatar: void 0,
11
+ disconnect: () => Promise.resolve(),
12
+ switchChain: () => Promise.resolve({})
13
+ };
14
+ const EvmExternalWalletContext = createContext(defaultEvmExternalWallet);
15
+ function EvmExternalWalletProvider({ children }) {
16
+ const wallets = [];
17
+ const chains = [];
18
+ const chainId = void 0;
19
+ const username = void 0;
20
+ const avatar = void 0;
21
+ const disconnect = () => Promise.resolve();
22
+ const switchChain = () => Promise.resolve({});
23
+ return /* @__PURE__ */ jsx(
24
+ EvmExternalWalletContext.Provider,
25
+ {
26
+ value: useMemo(
27
+ () => ({ wallets, chains, chainId, username, avatar, disconnect, switchChain }),
28
+ [wallets, chains, chainId, username, avatar, disconnect, switchChain]
29
+ ),
30
+ children
31
+ }
32
+ );
33
+ }
34
+ export {
35
+ EvmExternalWalletContext,
36
+ EvmExternalWalletProvider,
37
+ defaultEvmExternalWallet
38
+ };
@@ -0,0 +1,275 @@
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 } from "../stores/index.js";
8
+ import { ModalStep } from "../utils/steps.js";
9
+ import { WalletType, isIOS, isIOSWebview, isMobile, truncateAddress } from "@getpara/web-sdk";
10
+ import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
11
+ const defaultExternalWallet = {
12
+ wallets: [],
13
+ chains: [],
14
+ chainId: void 0,
15
+ wallet: void 0,
16
+ qrUri: void 0,
17
+ chainIdSwitchingTo: void 0,
18
+ walletDisplayHelpers: {
19
+ showExtension: false,
20
+ showMobile: false,
21
+ isSolanaMobileIOS: false,
22
+ isCosmosMobileWallet: false
23
+ },
24
+ username: void 0,
25
+ avatar: void 0,
26
+ connectExternalWallet: () => {
27
+ },
28
+ disconnectExternalWallet: () => Promise.resolve(),
29
+ switchChain: () => Promise.resolve(),
30
+ setChainIdSwitchingTo: () => {
31
+ }
32
+ };
33
+ const ExternalWalletContext = createContext(defaultExternalWallet);
34
+ function ExternalWalletProvider({
35
+ children,
36
+ evmContext,
37
+ solanaContext,
38
+ cosmosContext,
39
+ walletSort
40
+ }) {
41
+ const {
42
+ wallets: evmWallets,
43
+ disconnect: evmDisconnect,
44
+ chains: evmChains,
45
+ chainId: evmChainId,
46
+ switchChain: evmSwitchChain,
47
+ username: evmUsername,
48
+ avatar: evmAvatar
49
+ } = useContext(evmContext);
50
+ const { wallets: solanaWallets, disconnect: solanaDisconnect } = useContext(solanaContext);
51
+ const {
52
+ wallets: cosmosWallets,
53
+ disconnect: cosmosDisconnect,
54
+ chains: cosmosChains,
55
+ chainId: cosmosChainId,
56
+ switchChain: cosmosSwitchChain
57
+ } = useContext(cosmosContext);
58
+ const setStep = useModalStore((state) => state.setStep);
59
+ const setStepDirection = useModalStore((state) => state.setStepDirection);
60
+ const setIsExternalWalletConnecting = useModalStore((state) => state.setIsExternalWalletConnecting);
61
+ const isExternalWalletConnecting = useModalStore((state) => state.isExternalWalletConnecting);
62
+ const setSelectedExternalWalletId = useModalStore((state) => state.setSelectedExternalWalletId);
63
+ const selectedExternalWalletId = useModalStore((state) => state.selectedExternalWalletId);
64
+ const setExternalWalletError = useModalStore((state) => state.setExternalWalletError);
65
+ const setIsUsingMobileConnector = useModalStore((state) => state.setIsUsingMobileConnector);
66
+ const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
67
+ const para = useInternalClient();
68
+ const [qrUri, setQrUri] = useState();
69
+ const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
70
+ const wallets = [...evmWallets, ...solanaWallets, ...cosmosWallets].filter((w) => walletSort.includes(w.id.toUpperCase())).sort(
71
+ (a, b) => walletSort.indexOf(a.id.toUpperCase()) - walletSort.indexOf(b.id.toUpperCase())
72
+ ).sort((a, b) => a.installed === b.installed ? 0 : a.installed ? -1 : 1);
73
+ const wallet = useMemo(() => wallets.find((w) => w.id === selectedExternalWalletId), [wallets, selectedExternalWalletId]);
74
+ const updateQrUri = () => __async(this, null, function* () {
75
+ var _a;
76
+ const uri = yield (_a = wallet == null ? void 0 : wallet.getQrUri) == null ? void 0 : _a.call(wallet);
77
+ setQrUri(uri);
78
+ });
79
+ useEffect(() => {
80
+ if (wallet) {
81
+ if (!qrUri) {
82
+ updateQrUri();
83
+ }
84
+ } else if (qrUri) {
85
+ setQrUri(void 0);
86
+ }
87
+ }, [wallet]);
88
+ const chains = useMemo(() => {
89
+ var _a;
90
+ const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
91
+ switch (walletType) {
92
+ case WalletType.COSMOS: {
93
+ return cosmosChains;
94
+ }
95
+ case WalletType.EVM: {
96
+ return evmChains;
97
+ }
98
+ default: {
99
+ return [];
100
+ }
101
+ }
102
+ }, [cosmosChains, evmChains, selectedExternalWalletId]);
103
+ const chainId = useMemo(() => {
104
+ var _a;
105
+ const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
106
+ switch (walletType) {
107
+ case WalletType.COSMOS: {
108
+ return cosmosChainId;
109
+ }
110
+ case WalletType.EVM: {
111
+ return evmChainId == null ? void 0 : evmChainId.toString();
112
+ }
113
+ default: {
114
+ return void 0;
115
+ }
116
+ }
117
+ }, [cosmosChains, evmChains, selectedExternalWalletId]);
118
+ const switchChain = useCallback(
119
+ (chainId2) => __async(this, null, function* () {
120
+ var _a;
121
+ const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
122
+ if (walletType) {
123
+ let resp;
124
+ setExternalWalletError();
125
+ setChainIdSwitchingTo(chainId2);
126
+ switch (walletType) {
127
+ case WalletType.COSMOS: {
128
+ setStep(ModalStep.CHAIN_SWITCH);
129
+ resp = yield cosmosSwitchChain(chainId2);
130
+ break;
131
+ }
132
+ case WalletType.EVM: {
133
+ setStep(ModalStep.CHAIN_SWITCH);
134
+ resp = yield evmSwitchChain(parseInt(chainId2));
135
+ break;
136
+ }
137
+ default: {
138
+ break;
139
+ }
140
+ }
141
+ if (resp.error) {
142
+ setExternalWalletError(resp.error);
143
+ } else {
144
+ setChainIdSwitchingTo(void 0);
145
+ setStepDirection(-1);
146
+ setStep(ModalStep.ACCOUNT_MAIN);
147
+ }
148
+ }
149
+ }),
150
+ [evmSwitchChain, cosmosSwitchChain]
151
+ );
152
+ const connectExternalWallet = useCallback(
153
+ (wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
154
+ if (isExternalWalletConnecting && isManualWalletConnect) {
155
+ yield evmDisconnect();
156
+ yield solanaDisconnect();
157
+ yield cosmosDisconnect();
158
+ setQrUri(void 0);
159
+ setIsExternalWalletConnecting(false);
160
+ }
161
+ if (isResetAfterManualWalletConnect || isManualWalletConnect || !isExternalWalletConnecting) {
162
+ setExternalWalletError();
163
+ setIsExternalWalletConnecting(true);
164
+ setIsUsingMobileConnector(isMobileConnect);
165
+ const { address, error } = yield isMobileConnect ? wallet2.connectMobile(isManualWalletConnect) : wallet2.connect();
166
+ if (error) {
167
+ setExternalWalletError([error]);
168
+ setIsUsingMobileConnector();
169
+ if (isManualWalletConnect && error === "Connection request rejected") {
170
+ setExternalWalletError();
171
+ yield connectExternalWallet(wallet2, false, false, true);
172
+ yield updateQrUri();
173
+ return;
174
+ }
175
+ } else if (address) {
176
+ setStep(ModalStep.LOGIN_DONE);
177
+ }
178
+ setIsExternalWalletConnecting(false);
179
+ }
180
+ }),
181
+ [isExternalWalletConnecting]
182
+ );
183
+ const disconnectExternalWallet = () => __async(this, null, function* () {
184
+ yield evmDisconnect();
185
+ yield solanaDisconnect();
186
+ yield cosmosDisconnect();
187
+ setSelectedExternalWalletId();
188
+ });
189
+ const walletDisplayHelpers = {
190
+ // Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
191
+ // Also show the extension connection if on desktop for a solana wallet (no walletConnect)
192
+ 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),
193
+ // Show the mobile screen if on mobile and the wallet is a mobile wallet or if on desktop and the wallet isn't installed
194
+ showMobile: isMobile() && (wallet == null ? void 0 : wallet.isMobile) || !isMobile() && !(wallet == null ? void 0 : wallet.installed),
195
+ isSolanaMobileIOS: isIOS() && isMobile() && !isIOSWebview() && (wallet == null ? void 0 : wallet.type) === WalletType.SOLANA,
196
+ isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) === WalletType.COSMOS && isUsingMobileConnector
197
+ };
198
+ const username = useMemo(() => {
199
+ let username2;
200
+ const storedExternalWallet = Object.values(para.externalWallets || {})[0];
201
+ if (storedExternalWallet) {
202
+ const walletType = storedExternalWallet == null ? void 0 : storedExternalWallet.type;
203
+ switch (walletType) {
204
+ case WalletType.EVM: {
205
+ username2 = evmUsername ? evmUsername.startsWith("0x") ? truncateAddress(evmUsername, "EVM") : evmUsername : void 0;
206
+ break;
207
+ }
208
+ default: {
209
+ username2 = storedExternalWallet.address ? truncateAddress(storedExternalWallet.address, storedExternalWallet.type) : void 0;
210
+ break;
211
+ }
212
+ }
213
+ }
214
+ return username2;
215
+ }, [evmUsername, wallet]);
216
+ const avatar = useMemo(() => {
217
+ var _a;
218
+ const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
219
+ if (walletType) {
220
+ switch (walletType) {
221
+ case WalletType.EVM: {
222
+ return evmAvatar;
223
+ }
224
+ default: {
225
+ return void 0;
226
+ }
227
+ }
228
+ }
229
+ }, [evmAvatar, wallet]);
230
+ return /* @__PURE__ */ jsx(
231
+ ExternalWalletContext.Provider,
232
+ {
233
+ value: useMemo(
234
+ () => ({
235
+ wallets,
236
+ chains,
237
+ chainId,
238
+ wallet,
239
+ qrUri,
240
+ walletDisplayHelpers,
241
+ chainIdSwitchingTo,
242
+ username,
243
+ avatar,
244
+ connectExternalWallet,
245
+ disconnectExternalWallet,
246
+ switchChain,
247
+ setChainIdSwitchingTo
248
+ }),
249
+ [
250
+ wallets,
251
+ chains,
252
+ chainId,
253
+ wallet,
254
+ qrUri,
255
+ walletDisplayHelpers,
256
+ chainIdSwitchingTo,
257
+ username,
258
+ avatar,
259
+ disconnectExternalWallet,
260
+ connectExternalWallet,
261
+ switchChain,
262
+ setChainIdSwitchingTo
263
+ ]
264
+ ),
265
+ children
266
+ }
267
+ );
268
+ }
269
+ const useExternalWallets = () => useContext(ExternalWalletContext);
270
+ export {
271
+ ExternalWalletContext,
272
+ ExternalWalletProvider,
273
+ defaultExternalWallet,
274
+ useExternalWallets
275
+ };
@@ -0,0 +1,19 @@
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
+ };
9
+ const SolanaExternalWalletContext = createContext(defaultSolanaExternalWallet);
10
+ function SolanaExternalWalletProvider({ children }) {
11
+ const wallets = [];
12
+ const disconnect = () => Promise.resolve();
13
+ return /* @__PURE__ */ jsx(SolanaExternalWalletContext.Provider, { value: useMemo(() => ({ wallets, disconnect }), [wallets, disconnect]), children });
14
+ }
15
+ export {
16
+ SolanaExternalWalletContext,
17
+ SolanaExternalWalletProvider,
18
+ defaultSolanaExternalWallet
19
+ };
@@ -0,0 +1,10 @@
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
+ };
@@ -0,0 +1,20 @@
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
+ };
17
+ const useExternalWalletProviderStore = create((set) => __spreadValues(__spreadValues({}, DEFAULT_EX_WALLET_PROVIDER_STATE), getActions(set)));
18
+ export {
19
+ useExternalWalletProviderStore
20
+ };
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ export * from "./modal/useModalStore.js";
3
+ export * from "./userInfo/useUserInfoStore.js";
4
+ export * from "./theme/useThemeStore.js";
@@ -0,0 +1,70 @@
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
+ };
@@ -0,0 +1,65 @@
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
+ };
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ const getActions = (set, get) => ({
4
+ updateState: (state) => {
5
+ set(state);
6
+ },
7
+ getLogo: () => {
8
+ var _a;
9
+ return (_a = get().logo) != null ? _a : void 0;
10
+ },
11
+ setAuthLayout: (authLayout) => {
12
+ const types = [];
13
+ const uniqueLayouts = [];
14
+ authLayout.map((layout) => {
15
+ const type = layout.split(":")[0];
16
+ if (!types.includes(type)) {
17
+ uniqueLayouts.push(layout);
18
+ types.push(type);
19
+ } else {
20
+ console.warn(`${layout} is a duplicate ${type} layout type. Please remove the duplicate type from your config.`);
21
+ }
22
+ });
23
+ set({ authLayout: uniqueLayouts });
24
+ }
25
+ });
26
+ export {
27
+ getActions
28
+ };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import {
3
+ __spreadValues
4
+ } from "../../../chunk-MMUBH76A.js";
5
+ import { create } from "zustand";
6
+ import { getActions } from "./actions.js";
7
+ import { AuthLayout } from "../../types/modalProps.js";
8
+ const DEFAULT_THEME = {
9
+ isDark: false,
10
+ logo: void 0,
11
+ appName: void 0,
12
+ bareModal: false,
13
+ embeddedModal: false,
14
+ oAuthLogoVariant: void 0,
15
+ authLayout: [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL],
16
+ hideWallets: false
17
+ };
18
+ const useThemeStore = create((set, get) => __spreadValues(__spreadValues({}, DEFAULT_THEME), getActions(set, get)));
19
+ export {
20
+ useThemeStore
21
+ };
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import {
3
+ __objRest,
4
+ __spreadProps,
5
+ __spreadValues
6
+ } from "../../../chunk-MMUBH76A.js";
7
+ import { DEFAULT_USER_INFO_STATE } from "./useUserInfoStore.js";
8
+ import { extractAuthInfo } from "@getpara/user-management-client";
9
+ const getActions = (set, get) => ({
10
+ resetState: () => {
11
+ set(DEFAULT_USER_INFO_STATE);
12
+ },
13
+ setAuthInfo: (_a) => {
14
+ var _b = _a, { pfpUrl, displayName } = _b, auth = __objRest(_b, ["pfpUrl", "displayName"]);
15
+ set({ auth, pfpUrl: pfpUrl || null, displayName: displayName || null });
16
+ },
17
+ getAuthInfo: () => {
18
+ try {
19
+ return get().auth ? __spreadProps(__spreadValues({}, extractAuthInfo(get().auth, { isRequired: true })), { pfpUrl: get().pfpUrl, displayName: get().displayName }) : null;
20
+ } catch (e) {
21
+ return null;
22
+ }
23
+ },
24
+ setRecoveryShare: (recoveryShare) => {
25
+ set({ recoveryShare });
26
+ }
27
+ });
28
+ export {
29
+ getActions
30
+ };
@@ -0,0 +1,17 @@
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_USER_INFO_STATE = {
8
+ auth: null,
9
+ recoveryShare: null,
10
+ pfpUrl: null,
11
+ displayName: null
12
+ };
13
+ const useUserInfoStore = create((set, get) => __spreadValues(__spreadValues({}, DEFAULT_USER_INFO_STATE), getActions(set, get)));
14
+ export {
15
+ DEFAULT_USER_INFO_STATE,
16
+ useUserInfoStore
17
+ };
@@ -0,0 +1 @@
1
+ "use client";
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import {
3
+ __spreadValues
4
+ } from "../../chunk-MMUBH76A.js";
5
+ var EvmWallet = /* @__PURE__ */ ((EvmWallet2) => {
6
+ EvmWallet2["METAMASK"] = "METAMASK";
7
+ EvmWallet2["RAINBOW"] = "RAINBOW";
8
+ EvmWallet2["COINBASE"] = "COINBASE";
9
+ EvmWallet2["WALLETCONNECT"] = "WALLETCONNECT";
10
+ EvmWallet2["ZERION"] = "ZERION";
11
+ EvmWallet2["RABBY"] = "RABBY";
12
+ return EvmWallet2;
13
+ })(EvmWallet || {});
14
+ var SolanaWallet = /* @__PURE__ */ ((SolanaWallet2) => {
15
+ SolanaWallet2["PHANTOM"] = "PHANTOM";
16
+ SolanaWallet2["GLOW"] = "GLOW";
17
+ SolanaWallet2["BACKPACK"] = "BACKPACK";
18
+ return SolanaWallet2;
19
+ })(SolanaWallet || {});
20
+ var CosmosWallet = /* @__PURE__ */ ((CosmosWallet2) => {
21
+ CosmosWallet2["KEPLR"] = "KEPLR";
22
+ CosmosWallet2["LEAP"] = "LEAP";
23
+ return CosmosWallet2;
24
+ })(CosmosWallet || {});
25
+ const ExternalWallet = __spreadValues(__spreadValues(__spreadValues({}, EvmWallet), SolanaWallet), CosmosWallet);
26
+ export {
27
+ CosmosWallet,
28
+ EvmWallet,
29
+ ExternalWallet,
30
+ SolanaWallet
31
+ };