@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,39 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "../../../chunk-MMUBH76A.js";
7
- import { useMutation } from "@tanstack/react-query";
8
- import { useClient, useWallet } from "../index.js";
9
- import { signTransaction } from "../../actions/signTransaction.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- import { EXTERNAL_WALLET_PACKAGE_BY_TYPE } from "../../utils/constants.js";
12
- const useSignTransaction = () => {
13
- const client = useClient();
14
- const { data: wallet } = useWallet();
15
- const mutation = useMutation({
16
- mutationFn: (args) => __async(void 0, null, function* () {
17
- let walletId = args == null ? void 0 : args.walletId;
18
- if (!walletId) {
19
- if (wallet.isExternal) {
20
- throw Error(
21
- `Cannot sign with Capsule using an external wallet. Try using the methods from ${wallet.type ? EXTERNAL_WALLET_PACKAGE_BY_TYPE[wallet.type] : "the external wallet provider package"}.`
22
- );
23
- }
24
- walletId = wallet == null ? void 0 : wallet.id;
25
- }
26
- if (!walletId) {
27
- throw Error("no wallet id found");
28
- }
29
- return yield signTransaction(client, __spreadProps(__spreadValues({}, args), { walletId }));
30
- })
31
- });
32
- return renameMutations(
33
- mutation,
34
- "signTransaction"
35
- );
36
- };
37
- export {
38
- useSignTransaction
39
- };
@@ -1,12 +0,0 @@
1
- import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
- import { UseMutationReturnType } from '../../types/query.js';
3
- import { Compute } from '../../types/utils.js';
4
- type UseWaitForAccountCreationReturnType<TData = boolean, TError = Error, TVariables = void, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
5
- waitForAccountCreation: UseMutateFunction<TData, TError, TVariables, TContext>;
6
- waitForAccountCreationAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
7
- }>;
8
- /**
9
- * Hook for waiting for account creation
10
- */
11
- export declare const useWaitForAccountCreation: () => UseWaitForAccountCreationReturnType<boolean, Error, void, unknown>;
12
- export {};
@@ -1,30 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { waitForAccountCreation } from "../../actions/waitForAccountCreation.js";
8
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
9
- import { WALLET_BASE_KEY } from "../queries/useWallet.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useWaitForAccountCreation = () => {
12
- const client = useClient();
13
- const queryClient = useQueryClient();
14
- const mutation = useMutation({
15
- mutationFn: () => __async(void 0, null, function* () {
16
- return yield waitForAccountCreation(client);
17
- }),
18
- onSettled: () => __async(void 0, null, function* () {
19
- yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
20
- yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
21
- })
22
- });
23
- return renameMutations(
24
- mutation,
25
- "waitForAccountCreation"
26
- );
27
- };
28
- export {
29
- useWaitForAccountCreation
30
- };
@@ -1,14 +0,0 @@
1
- import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
- import { WaitForLoginAndSetupArgs } from '../../actions/waitForLoginAndSetup.js';
3
- import { Compute } from '../../types/utils.js';
4
- import { UseMutationReturnType } from '../../types/query.js';
5
- import { LoginResponse } from '@getpara/web-sdk';
6
- type UseWaitForLoginAndSetupReturnType<TData = LoginResponse, TError = Error, TVariables = WaitForLoginAndSetupArgs, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
7
- waitForLoginAndSetup: UseMutateFunction<TData, TError, TVariables, TContext>;
8
- waitForLoginAndSetupAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
9
- }>;
10
- /**
11
- * Hook for waiting for user login and account setup
12
- */
13
- export declare const useWaitForLoginAndSetup: () => UseWaitForLoginAndSetupReturnType<LoginResponse, Error, WaitForLoginAndSetupArgs, unknown>;
14
- export {};
@@ -1,30 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { waitForLoginAndSetup } from "../../actions/waitForLoginAndSetup.js";
8
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
9
- import { WALLET_BASE_KEY } from "../queries/useWallet.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useWaitForLoginAndSetup = () => {
12
- const client = useClient();
13
- const queryClient = useQueryClient();
14
- const mutation = useMutation({
15
- mutationFn: (args) => __async(void 0, null, function* () {
16
- return yield waitForLoginAndSetup(client, args);
17
- }),
18
- onSettled: () => __async(void 0, null, function* () {
19
- yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
20
- yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
21
- })
22
- });
23
- return renameMutations(
24
- mutation,
25
- "waitForLoginAndSetup"
26
- );
27
- };
28
- export {
29
- useWaitForLoginAndSetup
30
- };
@@ -1,13 +0,0 @@
1
- import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
- import { UseMutationReturnType } from '../../types/query.js';
3
- import { Compute } from '../../types/utils.js';
4
- import { AccountSetupResponse } from '@getpara/web-sdk';
5
- type UseWaitForPasskeyAndCreateWalletReturnType<TData = AccountSetupResponse, TError = Error, TVariables = void, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
6
- waitForPasskeyAndCreateWallet: UseMutateFunction<TData, TError, TVariables, TContext>;
7
- waitForPasskeyAndCreateWalletAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
8
- }>;
9
- /**
10
- * Hook for waiting for session setup and wallet creation
11
- */
12
- export declare const useWaitForPasskeyAndCreateWallet: () => UseWaitForPasskeyAndCreateWalletReturnType<AccountSetupResponse, Error, void, unknown>;
13
- export {};
@@ -1,30 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { waitForPasskeyAndCreateWallet } from "../../actions/waitForPasskeyAndCreateWallet.js";
8
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
9
- import { WALLET_BASE_KEY } from "../queries/useWallet.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useWaitForPasskeyAndCreateWallet = () => {
12
- const client = useClient();
13
- const queryClient = useQueryClient();
14
- const mutation = useMutation({
15
- mutationFn: () => __async(void 0, null, function* () {
16
- return yield waitForPasskeyAndCreateWallet(client);
17
- }),
18
- onSettled: () => __async(void 0, null, function* () {
19
- yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
20
- yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
21
- })
22
- });
23
- return renameMutations(
24
- mutation,
25
- "waitForPasskeyAndCreateWallet"
26
- );
27
- };
28
- export {
29
- useWaitForPasskeyAndCreateWallet
30
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useAccount } from "./useAccount.js";
4
- import { useWallet } from "./useWallet.js";
5
- import { useWalletBalance } from "./useWalletBalance.js";
6
- export {
7
- useAccount,
8
- useWallet,
9
- useWalletBalance
10
- };
@@ -1,21 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useQuery } from "@tanstack/react-query";
6
- import { getAccount } from "../../actions/getAccount.js";
7
- import { useInternalClient } from "../utils/useInternalClient.js";
8
- const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
9
- const useAccount = () => {
10
- const client = useInternalClient();
11
- return useQuery({
12
- queryKey: [ACCOUNT_BASE_KEY, client == null ? void 0 : client.getUserId()],
13
- queryFn: () => __async(void 0, null, function* () {
14
- return yield getAccount(client);
15
- })
16
- });
17
- };
18
- export {
19
- ACCOUNT_BASE_KEY,
20
- useAccount
21
- };
@@ -1,22 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useQuery } from "@tanstack/react-query";
6
- import { useClient, useWalletState } from "../index.js";
7
- import { getWallet } from "../../actions/getWallet.js";
8
- const WALLET_BASE_KEY = "PARA_WALLET";
9
- const useWallet = () => {
10
- const client = useClient();
11
- const { selectedWallet } = useWalletState();
12
- return useQuery({
13
- queryKey: [WALLET_BASE_KEY, client == null ? void 0 : client.getUserId(), selectedWallet.id, selectedWallet.type],
14
- queryFn: () => __async(void 0, null, function* () {
15
- return yield getWallet(client, selectedWallet);
16
- })
17
- });
18
- };
19
- export {
20
- WALLET_BASE_KEY,
21
- useWallet
22
- };
@@ -1,7 +0,0 @@
1
- import { UseQueryOptions } from '@tanstack/react-query';
2
- import { GetWalletBalanceParams } from '@getpara/web-sdk';
3
- export declare const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
4
- /**
5
- * Hook for retrieving a wallet balance
6
- */
7
- export declare const useWalletBalance: (args?: Partial<GetWalletBalanceParams>, queryOptions?: Pick<UseQueryOptions, "refetchInterval">) => import("@tanstack/react-query").UseQueryResult<unknown, Error>;
@@ -1,26 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadValues
5
- } from "../../../chunk-MMUBH76A.js";
6
- import { useQuery } from "@tanstack/react-query";
7
- import { useClient, useWalletState } from "../index.js";
8
- import { getWalletBalance } from "../../actions/getWalletBalance.js";
9
- import { useStore } from "../../stores/useStore.js";
10
- const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
11
- const useWalletBalance = (args, queryOptions) => {
12
- const client = useClient();
13
- const { selectedWallet } = useWalletState();
14
- const rpcUrl = useStore((state) => state.rpcUrl);
15
- const completeArgs = __spreadValues({ walletId: selectedWallet.id, rpcUrl }, args);
16
- return useQuery(__spreadValues({
17
- queryKey: [WALLET_BALANCE_BASE_KEY, client == null ? void 0 : client.getUserId(), completeArgs],
18
- queryFn: () => __async(void 0, null, function* () {
19
- return yield getWalletBalance(client, completeArgs);
20
- })
21
- }, queryOptions));
22
- };
23
- export {
24
- WALLET_BALANCE_BASE_KEY,
25
- useWalletBalance
26
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useClient } from "./useClient.js";
4
- import { useModal } from "./useModal.js";
5
- import { useWalletState } from "./useWalletState.js";
6
- export {
7
- useClient,
8
- useModal,
9
- useWalletState
10
- };
@@ -1,74 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useEffect, useRef } from "react";
6
- import { useAccount, useKeepSessionAlive, useLogout } from "../index.js";
7
- import { useInternalClient } from "./useInternalClient.js";
8
- const SESSION_CHECK_INTERVAL = 6e4;
9
- const SESSION_REFRESH_THRESHOLD = 3e5;
10
- const useAutoSessionKeepAlive = ({ disabled }) => {
11
- const client = useInternalClient();
12
- const { data: account } = useAccount();
13
- const { logoutAsync } = useLogout();
14
- const { keepSessionAliveAsync } = useKeepSessionAlive();
15
- const sessionCheckInterval = useRef(null);
16
- useEffect(() => {
17
- if (!client || disabled) {
18
- clearSessionMonitoring();
19
- return;
20
- }
21
- if ((account == null ? void 0 : account.isConnected) && !client.isUsingExternalWallet()) {
22
- setupSessionMonitoring();
23
- } else {
24
- clearSessionMonitoring();
25
- }
26
- return () => clearSessionMonitoring();
27
- }, [client, account, disabled]);
28
- const getSessionExpiry = () => __async(void 0, null, function* () {
29
- try {
30
- const sessionCookie = yield client.retrieveSessionCookie();
31
- if (!sessionCookie) return null;
32
- const expiresMatch = sessionCookie.match(/Expires=([^;]+)/);
33
- return expiresMatch ? new Date(expiresMatch[1]) : null;
34
- } catch (err) {
35
- return null;
36
- }
37
- });
38
- const setupSessionMonitoring = () => {
39
- clearSessionMonitoring();
40
- sessionCheckInterval.current = setInterval(() => __async(void 0, null, function* () {
41
- const expiry = yield getSessionExpiry();
42
- if (!expiry) {
43
- yield logoutAsync();
44
- clearSessionMonitoring();
45
- return;
46
- }
47
- const timeUntilExpiry = expiry.getTime() - Date.now();
48
- if (timeUntilExpiry <= 0) {
49
- yield logoutAsync();
50
- clearSessionMonitoring();
51
- return;
52
- }
53
- if (timeUntilExpiry <= SESSION_REFRESH_THRESHOLD) {
54
- try {
55
- yield keepSessionAliveAsync();
56
- setupSessionMonitoring();
57
- } catch (err) {
58
- console.error("Failed to keep session alive:", err);
59
- yield logoutAsync();
60
- clearSessionMonitoring();
61
- }
62
- return;
63
- }
64
- }), SESSION_CHECK_INTERVAL);
65
- };
66
- const clearSessionMonitoring = () => {
67
- if (sessionCheckInterval.current) {
68
- clearInterval(sessionCheckInterval.current);
69
- }
70
- };
71
- };
72
- export {
73
- useAutoSessionKeepAlive
74
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useStore } from "../../stores/useStore.js";
4
- const useClient = () => {
5
- const client = useStore((state) => state.client);
6
- return client;
7
- };
8
- export {
9
- useClient
10
- };
@@ -1,105 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useQueryClient } from "@tanstack/react-query";
4
- import { useEffect } from "react";
5
- import { useClient, useWalletState } from "../index.js";
6
- import {
7
- ParaEvent
8
- } from "@getpara/web-sdk";
9
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
10
- import { useStore } from "../../stores/useStore.js";
11
- import { WALLET_BASE_KEY } from "../../hooks/queries/useWallet.js";
12
- const useEventListeners = ({
13
- onLogin,
14
- onLogout,
15
- onAccountSetup,
16
- onAccountCreation,
17
- onSignMessage,
18
- onSignTransaction,
19
- onWalletCreated,
20
- onPregenWalletClaimed,
21
- onExternalWalletChange,
22
- onWalletsChange
23
- } = {}) => {
24
- const queryClient = useQueryClient();
25
- const client = useClient();
26
- const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
27
- const { selectedWallet, setSelectedWallet } = useWalletState();
28
- const loginListener = (event) => {
29
- loginOrSetupListener();
30
- onLogin == null ? void 0 : onLogin(event);
31
- };
32
- const accountSetupListener = (event) => {
33
- loginOrSetupListener();
34
- onAccountSetup == null ? void 0 : onAccountSetup(event);
35
- };
36
- const loginOrSetupListener = () => {
37
- queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
38
- queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
39
- };
40
- const accountCreationListener = (event) => {
41
- onAccountCreation == null ? void 0 : onAccountCreation(event);
42
- };
43
- const logoutListener = (event) => {
44
- queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
45
- clearSelectedWallet();
46
- onLogout == null ? void 0 : onLogout(event);
47
- };
48
- const signMessageListener = (event) => {
49
- onSignMessage == null ? void 0 : onSignMessage(event);
50
- };
51
- const signTransactionListener = (event) => {
52
- onSignTransaction == null ? void 0 : onSignTransaction(event);
53
- };
54
- const walletChangeListener = (event) => {
55
- updateSelectedWallet();
56
- onWalletsChange == null ? void 0 : onWalletsChange(event);
57
- };
58
- const externalWalletChangeListener = (event) => {
59
- updateSelectedWallet();
60
- onExternalWalletChange == null ? void 0 : onExternalWalletChange(event);
61
- };
62
- const walletCreatedListener = (event) => {
63
- onWalletCreated == null ? void 0 : onWalletCreated(event);
64
- };
65
- const pregenWalletClaimedListener = (event) => {
66
- onPregenWalletClaimed == null ? void 0 : onPregenWalletClaimed(event);
67
- };
68
- const updateSelectedWallet = () => {
69
- if (!client) {
70
- clearSelectedWallet();
71
- return;
72
- }
73
- if (!(selectedWallet == null ? void 0 : selectedWallet.id) || !client.findWallet(selectedWallet == null ? void 0 : selectedWallet.id)) {
74
- const defaultWallet = client.findWallet(void 0, void 0, { forbidPregen: true });
75
- setSelectedWallet({ id: defaultWallet == null ? void 0 : defaultWallet.id, type: defaultWallet == null ? void 0 : defaultWallet.type });
76
- }
77
- };
78
- useEffect(() => {
79
- window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
80
- window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
81
- window.addEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
82
- window.addEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
83
- window.addEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
84
- window.addEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
85
- window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
86
- window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
87
- window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
88
- window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
89
- return () => {
90
- window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
91
- window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
92
- window.removeEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
93
- window.removeEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
94
- window.removeEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
95
- window.removeEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
96
- window.removeEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
97
- window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
98
- window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
99
- window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
100
- };
101
- }, [client]);
102
- };
103
- export {
104
- useEventListeners
105
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useStore } from "../../stores/useStore.js";
4
- const useInternalClient = () => {
5
- const client = useStore((state) => state.client);
6
- return client;
7
- };
8
- export {
9
- useInternalClient
10
- };
@@ -1,17 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useStore } from "../../stores/useStore.js";
4
- const useModal = () => {
5
- const isOpen = useStore((state) => state.isOpen);
6
- const setIsOpen = useStore((state) => state.setIsOpen);
7
- const openModal = () => {
8
- setIsOpen(true);
9
- };
10
- const closeModal = () => {
11
- setIsOpen(false);
12
- };
13
- return { isOpen, openModal, closeModal };
14
- };
15
- export {
16
- useModal
17
- };
@@ -1,33 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useStore } from "../../stores/useStore.js";
4
- import { useClient } from "./useClient.js";
5
- const useWalletState = () => {
6
- const client = useClient();
7
- const selectedWalletId = useStore((state) => state.selectedWalletId);
8
- const selectedWalletType = useStore((state) => state.selectedWalletType);
9
- const setStoredSelectedWallet = useStore((state) => state.setSelectedWallet);
10
- const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
11
- const setSelectedWallet = ({ id, type }) => {
12
- try {
13
- const validId = client.findWalletId(id, { type: [type] });
14
- if (validId !== id) {
15
- clearSelectedWallet();
16
- } else {
17
- setStoredSelectedWallet(id, type);
18
- }
19
- } catch (e) {
20
- clearSelectedWallet();
21
- }
22
- };
23
- return {
24
- selectedWallet: {
25
- id: selectedWalletId,
26
- type: selectedWalletType
27
- },
28
- setSelectedWallet
29
- };
30
- };
31
- export {
32
- useWalletState
33
- };
@@ -1,8 +0,0 @@
1
- "use client";
2
- import "../chunk-MMUBH76A.js";
3
- import { ParaProvider } from "./ParaProvider.js";
4
- export * from "./hooks/index.js";
5
- export * from "./stores/getters.js";
6
- export {
7
- ParaProvider
8
- };
@@ -1,13 +0,0 @@
1
- "use client";
2
- import "../../chunk-MMUBH76A.js";
3
- import { vanillaStore } from "./useStore.js";
4
- const getClient = () => vanillaStore.getState().client;
5
- const getIsOpen = () => vanillaStore.getState().isOpen;
6
- const getSelectedWalletId = () => vanillaStore.getState().selectedWalletId;
7
- const getSelectedWalletType = () => vanillaStore.getState().selectedWalletType;
8
- export {
9
- getClient,
10
- getIsOpen,
11
- getSelectedWalletId,
12
- getSelectedWalletType
13
- };
@@ -1,9 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- const createClientSlice = (set) => ({
4
- client: void 0,
5
- setClient: (client) => set({ client })
6
- });
7
- export {
8
- createClientSlice
9
- };
@@ -1,4 +0,0 @@
1
- "use client";
2
- export * from "./client.js";
3
- export * from "./modal.js";
4
- export * from "./wallet.js";
@@ -1,9 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- const createModalSlice = (set) => ({
4
- isOpen: false,
5
- setIsOpen: (isOpen) => set({ isOpen })
6
- });
7
- export {
8
- createModalSlice
9
- };
@@ -1,13 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- const createWalletSlice = (set) => ({
4
- rpcUrl: void 0,
5
- setRpcUrl: (rpcUrl) => set({ rpcUrl }),
6
- selectedWalletId: void 0,
7
- selectedWalletType: void 0,
8
- setSelectedWallet: (selectedWalletId, selectedWalletType) => set({ selectedWalletId, selectedWalletType }),
9
- clearSelectedWallet: () => set({ selectedWalletId: void 0, selectedWalletType: void 0 })
10
- });
11
- export {
12
- createWalletSlice
13
- };
@@ -1 +0,0 @@
1
- "use client";
@@ -1,27 +0,0 @@
1
- "use client";
2
- import {
3
- __spreadValues
4
- } from "../../chunk-MMUBH76A.js";
5
- import { createStore, useStore as useZustandStore } from "zustand";
6
- import { createClientSlice, createModalSlice, createWalletSlice } from "./slices/index.js";
7
- import { createJSONStorage, persist } from "zustand/middleware";
8
- const vanillaStore = createStore()(
9
- persist(
10
- (...a) => __spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)),
11
- {
12
- version: 1,
13
- name: "@PARA/web-state",
14
- storage: createJSONStorage(() => localStorage),
15
- partialize: (state) => ({
16
- selectedWalletId: state.selectedWalletId,
17
- selectedWalletType: state.selectedWalletType
18
- })
19
- }
20
- )
21
- );
22
- const createBoundedUseStore = (store) => (selector) => useZustandStore(store, selector);
23
- const useStore = createBoundedUseStore(vanillaStore);
24
- export {
25
- useStore,
26
- vanillaStore
27
- };
@@ -1 +0,0 @@
1
- "use client";
@@ -1 +0,0 @@
1
- "use client";
@@ -1 +0,0 @@
1
- "use client";
@@ -1,5 +0,0 @@
1
- export declare const EXTERNAL_WALLET_PACKAGE_BY_TYPE: {
2
- EVM: string;
3
- COSMOS: string;
4
- SOLANA: string;
5
- };