@getpara/react-sdk 0.1.0 → 0.2.1

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 (124) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/modal/ParaModal.js +47 -16
  4. package/dist/modal/components/Account/Account.js +3 -2
  5. package/dist/modal/components/AddFunds/AddFunds.js +3 -2
  6. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +3 -2
  7. package/dist/modal/components/AuthInput/AuthInput.js +12 -5
  8. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +7 -3
  9. package/dist/modal/components/Controls/Selects.js +6 -4
  10. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +3 -2
  11. package/dist/modal/components/Hero/Hero.js +3 -2
  12. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +3 -2
  13. package/dist/modal/components/ModalContent/ModalContent.js +6 -2
  14. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -2
  15. package/dist/modal/components/OAuth/OAuth.js +4 -3
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +4 -3
  17. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -3
  18. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +10 -5
  19. package/dist/modal/components/WalletCard/WalletCard.js +7 -5
  20. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +3 -2
  21. package/dist/modal/constants/constants.d.ts +1 -1
  22. package/dist/modal/constants/constants.js +1 -1
  23. package/dist/modal/hooks/useActiveWallet.js +7 -5
  24. package/dist/modal/providers/ExternalWalletContext.js +3 -2
  25. package/dist/modal/stores/index.d.ts +0 -1
  26. package/dist/modal/stores/index.js +0 -1
  27. package/dist/modal/stores/modal/actions.js +0 -1
  28. package/dist/modal/stores/modal/useModalStore.d.ts +0 -1
  29. package/dist/modal/types/modalProps.d.ts +3 -3
  30. package/dist/provider/ParaProvider.d.ts +2 -0
  31. package/dist/provider/ParaProvider.js +16 -0
  32. package/dist/provider/actions/checkIfUserExists.d.ts +9 -0
  33. package/dist/provider/actions/checkIfUserExists.js +26 -0
  34. package/dist/provider/actions/createUser.d.ts +12 -0
  35. package/dist/provider/actions/createUser.js +30 -0
  36. package/dist/provider/actions/getAccount.d.ts +7 -0
  37. package/dist/provider/actions/getAccount.js +24 -0
  38. package/dist/provider/actions/getWallet.d.ts +5 -0
  39. package/dist/provider/actions/getWallet.js +16 -0
  40. package/dist/provider/actions/initiateLogin.d.ts +4 -0
  41. package/dist/provider/actions/initiateLogin.js +23 -0
  42. package/dist/provider/actions/keepSessionAlive.d.ts +2 -0
  43. package/dist/provider/actions/keepSessionAlive.js +23 -0
  44. package/dist/provider/actions/logout.d.ts +2 -0
  45. package/dist/provider/actions/logout.js +20 -0
  46. package/dist/provider/actions/signMessage.d.ts +8 -0
  47. package/dist/provider/actions/signMessage.js +23 -0
  48. package/dist/provider/actions/signTransaction.d.ts +8 -0
  49. package/dist/provider/actions/signTransaction.js +23 -0
  50. package/dist/provider/actions/waitForAccountCreation.d.ts +2 -0
  51. package/dist/provider/actions/waitForAccountCreation.js +24 -0
  52. package/dist/provider/actions/waitForLoginAndSetup.d.ts +6 -0
  53. package/dist/provider/actions/waitForLoginAndSetup.js +27 -0
  54. package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +2 -0
  55. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +24 -0
  56. package/dist/provider/hooks/index.d.ts +3 -0
  57. package/dist/provider/hooks/index.js +3 -0
  58. package/dist/provider/hooks/mutations/index.d.ts +10 -0
  59. package/dist/provider/hooks/mutations/index.js +10 -0
  60. package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +13 -0
  61. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
  62. package/dist/provider/hooks/mutations/useCreateUser.d.ts +13 -0
  63. package/dist/provider/hooks/mutations/useCreateUser.js +23 -0
  64. package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +14 -0
  65. package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
  66. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +12 -0
  67. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +23 -0
  68. package/dist/provider/hooks/mutations/useLogout.d.ts +12 -0
  69. package/dist/provider/hooks/mutations/useLogout.js +33 -0
  70. package/dist/provider/hooks/mutations/useSignMessage.d.ts +15 -0
  71. package/dist/provider/hooks/mutations/useSignMessage.js +33 -0
  72. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +14 -0
  73. package/dist/provider/hooks/mutations/useSignTransaction.js +33 -0
  74. package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +12 -0
  75. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
  76. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +14 -0
  77. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
  78. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +13 -0
  79. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
  80. package/dist/provider/hooks/queries/index.d.ts +2 -0
  81. package/dist/provider/hooks/queries/index.js +2 -0
  82. package/dist/provider/hooks/queries/useAccount.d.ts +10 -0
  83. package/dist/provider/hooks/queries/useAccount.js +23 -0
  84. package/dist/provider/hooks/queries/useWallet.d.ts +5 -0
  85. package/dist/provider/hooks/queries/useWallet.js +24 -0
  86. package/dist/provider/hooks/utils/index.d.ts +3 -0
  87. package/dist/provider/hooks/utils/index.js +3 -0
  88. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.d.ts +3 -0
  89. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +79 -0
  90. package/dist/provider/hooks/utils/useClient.d.ts +4 -0
  91. package/dist/provider/hooks/utils/useClient.js +8 -0
  92. package/dist/provider/hooks/utils/useEventListeners.d.ts +2 -0
  93. package/dist/provider/hooks/utils/useEventListeners.js +87 -0
  94. package/dist/provider/hooks/utils/useInternalClient.d.ts +5 -0
  95. package/dist/provider/hooks/utils/useInternalClient.js +9 -0
  96. package/dist/provider/hooks/utils/useModal.d.ts +8 -0
  97. package/dist/provider/hooks/utils/useModal.js +15 -0
  98. package/dist/provider/hooks/utils/useWalletState.d.ts +14 -0
  99. package/dist/provider/hooks/utils/useWalletState.js +33 -0
  100. package/dist/provider/index.d.ts +3 -0
  101. package/dist/provider/index.js +3 -0
  102. package/dist/provider/stores/getters.d.ts +4 -0
  103. package/dist/provider/stores/getters.js +5 -0
  104. package/dist/provider/stores/slices/client.d.ts +3 -0
  105. package/dist/provider/stores/slices/client.js +4 -0
  106. package/dist/provider/stores/slices/index.d.ts +3 -0
  107. package/dist/provider/stores/slices/index.js +3 -0
  108. package/dist/provider/stores/slices/modal.d.ts +3 -0
  109. package/dist/provider/stores/slices/modal.js +4 -0
  110. package/dist/provider/stores/slices/wallet.d.ts +3 -0
  111. package/dist/provider/stores/slices/wallet.js +6 -0
  112. package/dist/provider/stores/types.d.ts +16 -0
  113. package/dist/provider/stores/types.js +1 -0
  114. package/dist/provider/stores/useStore.d.ts +12 -0
  115. package/dist/provider/stores/useStore.js +12 -0
  116. package/dist/provider/types/provider.d.ts +26 -0
  117. package/dist/provider/types/provider.js +1 -0
  118. package/dist/provider/types/query.d.ts +3 -0
  119. package/dist/provider/types/query.js +1 -0
  120. package/dist/provider/types/utils.d.ts +6 -0
  121. package/dist/provider/types/utils.js +1 -0
  122. package/dist/provider/utils/renameMutations.d.ts +2 -0
  123. package/dist/provider/utils/renameMutations.js +19 -0
  124. package/package.json +6 -5
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const waitForPasskeyAndCreateWallet = (para) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ try {
15
+ const resp = yield para.waitForPasskeyAndCreateWallet();
16
+ if (!resp) {
17
+ throw new Error('error during waitForAccountCreation');
18
+ }
19
+ return resp;
20
+ }
21
+ catch (e) {
22
+ throw new Error(e);
23
+ }
24
+ });
@@ -0,0 +1,3 @@
1
+ export * from './utils/index.js';
2
+ export * from './queries/index.js';
3
+ export * from './mutations/index.js';
@@ -0,0 +1,3 @@
1
+ export * from './utils/index.js';
2
+ export * from './queries/index.js';
3
+ export * from './mutations/index.js';
@@ -0,0 +1,10 @@
1
+ export { useWaitForLoginAndSetup } from './useWaitForLoginAndSetup.js';
2
+ export { useWaitForAccountCreation } from './useWaitForAccountCreation.js';
3
+ export { useWaitForPasskeyAndCreateWallet } from './useWaitForPasskeyAndCreateWallet.js';
4
+ export { useCreateUser } from './useCreateUser.js';
5
+ export { useCheckIfUserExists } from './useCheckIfUserExists.js';
6
+ export { useInitiateLogin } from './useInitiateLogin.js';
7
+ export { useLogout } from './useLogout.js';
8
+ export { useKeepSessionAlive } from './useKeepSessionAlive.js';
9
+ export { useSignMessage } from './useSignMessage.js';
10
+ export { useSignTransaction } from './useSignTransaction.js';
@@ -0,0 +1,10 @@
1
+ export { useWaitForLoginAndSetup } from './useWaitForLoginAndSetup.js';
2
+ export { useWaitForAccountCreation } from './useWaitForAccountCreation.js';
3
+ export { useWaitForPasskeyAndCreateWallet } from './useWaitForPasskeyAndCreateWallet.js';
4
+ export { useCreateUser } from './useCreateUser.js';
5
+ export { useCheckIfUserExists } from './useCheckIfUserExists.js';
6
+ export { useInitiateLogin } from './useInitiateLogin.js';
7
+ export { useLogout } from './useLogout.js';
8
+ export { useKeepSessionAlive } from './useKeepSessionAlive.js';
9
+ export { useSignMessage } from './useSignMessage.js';
10
+ export { useSignTransaction } from './useSignTransaction.js';
@@ -0,0 +1,13 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { CheckIfUserExistsArgs } from '../../actions/checkIfUserExists.js';
3
+ import { Compute } from '../../types/utils.js';
4
+ import { UseMutationReturnType } from '../../types/query.js';
5
+ type UseCheckIfUserExistsReturnType<TData = boolean, TError = Error, TVariables = CheckIfUserExistsArgs, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
6
+ checkIfUserExists: UseMutateFunction<TData, TError, TVariables, TContext>;
7
+ checkIfUserExistsAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
8
+ }>;
9
+ /**
10
+ * Hook for checking is a user exists
11
+ */
12
+ export declare const useCheckIfUserExists: () => UseCheckIfUserExistsReturnType<boolean, Error, CheckIfUserExistsArgs, unknown>;
13
+ export {};
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { checkIfUserExists } from '../../actions/checkIfUserExists.js';
13
+ import { renameMutations } from '../../utils/renameMutations.js';
14
+ /**
15
+ * Hook for checking is a user exists
16
+ */
17
+ export const useCheckIfUserExists = () => {
18
+ const client = useClient();
19
+ const mutation = useMutation({
20
+ mutationFn: (args) => __awaiter(void 0, void 0, void 0, function* () { return yield checkIfUserExists(client, args); }),
21
+ });
22
+ return renameMutations(mutation, 'checkIfUserExists');
23
+ };
@@ -0,0 +1,13 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { CreateUserArgs } from '../../actions/createUser.js';
3
+ import { Compute } from '../../types/utils.js';
4
+ import { UseMutationReturnType } from '../../types/query.js';
5
+ type UseCreateUserReturnType<TData = void, TError = Error, TVariables = CreateUserArgs, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
6
+ createUser: UseMutateFunction<TData, TError, TVariables, TContext>;
7
+ createUserAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
8
+ }>;
9
+ /**
10
+ * Hook for creating a new user
11
+ */
12
+ export declare const useCreateUser: () => UseCreateUserReturnType<void, Error, CreateUserArgs, unknown>;
13
+ export {};
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { createUser } from '../../actions/createUser.js';
13
+ import { renameMutations } from '../../utils/renameMutations.js';
14
+ /**
15
+ * Hook for creating a new user
16
+ */
17
+ export const useCreateUser = () => {
18
+ const client = useClient();
19
+ const mutation = useMutation({
20
+ mutationFn: (args) => __awaiter(void 0, void 0, void 0, function* () { return yield createUser(client, args); }),
21
+ });
22
+ return renameMutations(mutation, 'createUser');
23
+ };
@@ -0,0 +1,14 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { InitiateLoginArgs } from '../../actions/initiateLogin.js';
3
+ import { Compute } from '../../types/utils.js';
4
+ import { UseMutationReturnType } from '../../types/query.js';
5
+ import { AuthMethod } from '@getpara/web-sdk';
6
+ type UseInitiateLoginReturnType<TData = Set<AuthMethod>, TError = Error, TVariables = InitiateLoginArgs, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
7
+ initiateLogin: UseMutateFunction<TData, TError, TVariables, TContext>;
8
+ initiateLoginAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
9
+ }>;
10
+ /**
11
+ * Hook for initiating a user login
12
+ */
13
+ export declare const useInitiateLogin: () => UseInitiateLoginReturnType<Set<AuthMethod>, Error, InitiateLoginArgs, unknown>;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { initiateLogin } from '../../actions/initiateLogin.js';
13
+ import { renameMutations } from '../../utils/renameMutations.js';
14
+ /**
15
+ * Hook for initiating a user login
16
+ */
17
+ export const useInitiateLogin = () => {
18
+ const client = useClient();
19
+ const mutation = useMutation({
20
+ mutationFn: (args) => __awaiter(void 0, void 0, void 0, function* () { return yield initiateLogin(client, args); }),
21
+ });
22
+ return renameMutations(mutation, 'initiateLogin');
23
+ };
@@ -0,0 +1,12 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { Compute } from '../../types/utils.js';
3
+ import { UseMutationReturnType } from '../../types/query.js';
4
+ type UseKeepSessionAliveReturnType<TData = void, TError = Error, TVariables = void, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
5
+ keepSessionAlive: UseMutateFunction<TData, TError, TVariables, TContext>;
6
+ keepSessionAliveAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
7
+ }>;
8
+ /**
9
+ * Hook for keeping a session alive
10
+ */
11
+ export declare const useKeepSessionAlive: () => UseKeepSessionAliveReturnType<void, Error, void, unknown>;
12
+ export {};
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { keepSessionAlive } from '../../actions/keepSessionAlive.js';
13
+ import { renameMutations } from '../../utils/renameMutations.js';
14
+ /**
15
+ * Hook for keeping a session alive
16
+ */
17
+ export const useKeepSessionAlive = () => {
18
+ const client = useClient();
19
+ const mutation = useMutation({
20
+ mutationFn: () => __awaiter(void 0, void 0, void 0, function* () { return yield keepSessionAlive(client); }),
21
+ });
22
+ return renameMutations(mutation, 'keepSessionAlive');
23
+ };
@@ -0,0 +1,12 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { Compute } from '../../types/utils.js';
3
+ import { UseMutationReturnType } from '../../types/query.js';
4
+ type UseLogoutReturnType<TData = void, TError = Error, TVariables = void, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
5
+ logout: UseMutateFunction<TData, TError, TVariables, TContext>;
6
+ logoutAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
7
+ }>;
8
+ /**
9
+ * Hook for logging out a user
10
+ */
11
+ export declare const useLogout: () => UseLogoutReturnType<void, Error, void, unknown>;
12
+ export {};
@@ -0,0 +1,33 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { logout } from '../../actions/logout.js';
13
+ import { useStore } from '../../stores/useStore.js';
14
+ import { ACCOUNT_BASE_KEY } from '../queries/useAccount.js';
15
+ import { WALLET_BASE_KEY } from '../queries/useWallet.js';
16
+ import { renameMutations } from '../../utils/renameMutations.js';
17
+ /**
18
+ * Hook for logging out a user
19
+ */
20
+ export const useLogout = () => {
21
+ const client = useClient();
22
+ const queryClient = useQueryClient();
23
+ const clearSelectedWallet = useStore(state => state.clearSelectedWallet);
24
+ const mutation = useMutation({
25
+ mutationFn: () => __awaiter(void 0, void 0, void 0, function* () { return yield logout(client); }),
26
+ onSettled: () => __awaiter(void 0, void 0, void 0, function* () {
27
+ yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
28
+ yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
29
+ clearSelectedWallet();
30
+ }),
31
+ });
32
+ return renameMutations(mutation, 'logout');
33
+ };
@@ -0,0 +1,15 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { SignMessageArgs } from '../../actions/signMessage.js';
3
+ import { Compute } from '../../types/utils.js';
4
+ import { UseMutationReturnType } from '../../types/query.js';
5
+ import { FullSignatureRes } from '@getpara/web-sdk';
6
+ type SignMessageMutationArgs = Omit<SignMessageArgs, 'walletId'> & Partial<Pick<SignMessageArgs, 'walletId'>>;
7
+ type UseSignMessageReturnType<TData = FullSignatureRes, TError = Error, TVariables = SignMessageMutationArgs, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
8
+ signMessage: UseMutateFunction<TData, TError, TVariables, TContext>;
9
+ signMessageAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
10
+ }>;
11
+ /**
12
+ * Hook for signing a message
13
+ */
14
+ export declare const useSignMessage: () => UseSignMessageReturnType<FullSignatureRes, Error, SignMessageMutationArgs, unknown>;
15
+ export {};
@@ -0,0 +1,33 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation } from '@tanstack/react-query';
11
+ import { useClient, useWallet } from '../index.js';
12
+ import { signMessage } from '../../actions/signMessage.js';
13
+ import { renameMutations } from '../../utils/renameMutations.js';
14
+ /**
15
+ * Hook for signing a message
16
+ */
17
+ export const useSignMessage = () => {
18
+ const client = useClient();
19
+ const { data: wallet } = useWallet();
20
+ const mutation = useMutation({
21
+ mutationFn: (args) => __awaiter(void 0, void 0, void 0, function* () {
22
+ let walletId = args === null || args === void 0 ? void 0 : args.walletId;
23
+ if (!walletId) {
24
+ walletId = wallet === null || wallet === void 0 ? void 0 : wallet.id;
25
+ }
26
+ if (!walletId) {
27
+ throw Error('no wallet id found');
28
+ }
29
+ return yield signMessage(client, Object.assign(Object.assign({}, args), { walletId }));
30
+ }),
31
+ });
32
+ return renameMutations(mutation, 'signMessage');
33
+ };
@@ -0,0 +1,14 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { SignTransactionArgs } from '../../actions/signTransaction.js';
3
+ import { Compute } from '../../types/utils.js';
4
+ import { UseMutationReturnType } from '../../types/query.js';
5
+ import { FullSignatureRes } from '@getpara/web-sdk';
6
+ type UseSignTransactionReturnType<TData = FullSignatureRes, TError = Error, TVariables = SignTransactionArgs, TContext = unknown> = Compute<UseMutationReturnType<TData, TError, TVariables, TContext> & {
7
+ signTransaction: UseMutateFunction<TData, TError, TVariables, TContext>;
8
+ signTransactionAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>;
9
+ }>;
10
+ /**
11
+ * Hook for signing a transaction
12
+ */
13
+ export declare const useSignTransaction: () => UseSignTransactionReturnType<FullSignatureRes, Error, SignTransactionArgs, unknown>;
14
+ export {};
@@ -0,0 +1,33 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation } from '@tanstack/react-query';
11
+ import { useClient, useWallet } from '../index.js';
12
+ import { signTransaction } from '../../actions/signTransaction.js';
13
+ import { renameMutations } from '../../utils/renameMutations.js';
14
+ /**
15
+ * Hook for signing a transaction
16
+ */
17
+ export const useSignTransaction = () => {
18
+ const client = useClient();
19
+ const { data: wallet } = useWallet();
20
+ const mutation = useMutation({
21
+ mutationFn: (args) => __awaiter(void 0, void 0, void 0, function* () {
22
+ let walletId = args === null || args === void 0 ? void 0 : args.walletId;
23
+ if (!walletId) {
24
+ walletId = wallet === null || wallet === void 0 ? void 0 : wallet.id;
25
+ }
26
+ if (!walletId) {
27
+ throw Error('no wallet id found');
28
+ }
29
+ return yield signTransaction(client, Object.assign(Object.assign({}, args), { walletId }));
30
+ }),
31
+ });
32
+ return renameMutations(mutation, 'signTransaction');
33
+ };
@@ -0,0 +1,12 @@
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 {};
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { waitForAccountCreation } from '../../actions/waitForAccountCreation.js';
13
+ import { ACCOUNT_BASE_KEY } from '../queries/useAccount.js';
14
+ import { WALLET_BASE_KEY } from '../queries/useWallet.js';
15
+ import { renameMutations } from '../../utils/renameMutations.js';
16
+ /**
17
+ * Hook for waiting for account creation
18
+ */
19
+ export const useWaitForAccountCreation = () => {
20
+ const client = useClient();
21
+ const queryClient = useQueryClient();
22
+ const mutation = useMutation({
23
+ mutationFn: () => __awaiter(void 0, void 0, void 0, function* () { return yield waitForAccountCreation(client); }),
24
+ onSettled: () => __awaiter(void 0, void 0, void 0, function* () {
25
+ yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
26
+ yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
27
+ }),
28
+ });
29
+ return renameMutations(mutation, 'waitForAccountCreation');
30
+ };
@@ -0,0 +1,14 @@
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 { LoginResp } from '@getpara/web-sdk';
6
+ type UseWaitForLoginAndSetupReturnType<TData = LoginResp, 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<LoginResp, Error, WaitForLoginAndSetupArgs, unknown>;
14
+ export {};
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { waitForLoginAndSetup } from '../../actions/waitForLoginAndSetup.js';
13
+ import { ACCOUNT_BASE_KEY } from '../queries/useAccount.js';
14
+ import { WALLET_BASE_KEY } from '../queries/useWallet.js';
15
+ import { renameMutations } from '../../utils/renameMutations.js';
16
+ /**
17
+ * Hook for waiting for user login and account setup
18
+ */
19
+ export const useWaitForLoginAndSetup = () => {
20
+ const client = useClient();
21
+ const queryClient = useQueryClient();
22
+ const mutation = useMutation({
23
+ mutationFn: (args) => __awaiter(void 0, void 0, void 0, function* () { return yield waitForLoginAndSetup(client, args); }),
24
+ onSettled: () => __awaiter(void 0, void 0, void 0, function* () {
25
+ yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
26
+ yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
27
+ }),
28
+ });
29
+ return renameMutations(mutation, 'waitForLoginAndSetup');
30
+ };
@@ -0,0 +1,13 @@
1
+ import { UseMutateAsyncFunction, UseMutateFunction } from '@tanstack/react-query';
2
+ import { UseMutationReturnType } from '../../types/query.js';
3
+ import { Compute } from '../../types/utils.js';
4
+ import { AccountSetupResp } from '@getpara/web-sdk';
5
+ type UseWaitForPasskeyAndCreateWalletReturnType<TData = AccountSetupResp, 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<AccountSetupResp, Error, void, unknown>;
13
+ export {};
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { waitForPasskeyAndCreateWallet } from '../../actions/waitForPasskeyAndCreateWallet.js';
13
+ import { ACCOUNT_BASE_KEY } from '../queries/useAccount.js';
14
+ import { WALLET_BASE_KEY } from '../queries/useWallet.js';
15
+ import { renameMutations } from '../../utils/renameMutations.js';
16
+ /**
17
+ * Hook for waiting for session setup and wallet creation
18
+ */
19
+ export const useWaitForPasskeyAndCreateWallet = () => {
20
+ const client = useClient();
21
+ const queryClient = useQueryClient();
22
+ const mutation = useMutation({
23
+ mutationFn: () => __awaiter(void 0, void 0, void 0, function* () { return yield waitForPasskeyAndCreateWallet(client); }),
24
+ onSettled: () => __awaiter(void 0, void 0, void 0, function* () {
25
+ yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
26
+ yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
27
+ }),
28
+ });
29
+ return renameMutations(mutation, 'waitForPasskeyAndCreateWallet');
30
+ };
@@ -0,0 +1,2 @@
1
+ export { useAccount } from './useAccount.js';
2
+ export { useWallet } from './useWallet.js';
@@ -0,0 +1,2 @@
1
+ export { useAccount } from './useAccount.js';
2
+ export { useWallet } from './useWallet.js';
@@ -0,0 +1,10 @@
1
+ export declare const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
2
+ /**
3
+ * Hook for retrieving a user account
4
+ */
5
+ export declare const useAccount: () => import("@tanstack/react-query").UseQueryResult<{
6
+ isConnected: boolean;
7
+ email: any;
8
+ phone: any;
9
+ wallets: any;
10
+ }, Error>;
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useQuery } from '@tanstack/react-query';
11
+ import { useClient } from '../index.js';
12
+ import { getAccount } from '../../actions/getAccount.js';
13
+ export const ACCOUNT_BASE_KEY = 'PARA_ACCOUNT';
14
+ /**
15
+ * Hook for retrieving a user account
16
+ */
17
+ export const useAccount = () => {
18
+ const client = useClient();
19
+ return useQuery({
20
+ queryKey: [ACCOUNT_BASE_KEY, client === null || client === void 0 ? void 0 : client.getUserId()],
21
+ queryFn: () => __awaiter(void 0, void 0, void 0, function* () { return yield getAccount(client); }),
22
+ });
23
+ };
@@ -0,0 +1,5 @@
1
+ export declare const WALLET_BASE_KEY = "PARA_WALLET";
2
+ /**
3
+ * Hook for retrieving the selected wallet
4
+ */
5
+ export declare const useWallet: () => import("@tanstack/react-query").UseQueryResult<Omit<import("@getpara/core-sdk").Wallet, "signer">, Error>;
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useQuery } from '@tanstack/react-query';
11
+ import { useClient, useWalletState } from '../index.js';
12
+ import { getWallet } from '../../actions/getWallet.js';
13
+ export const WALLET_BASE_KEY = 'PARA_WALLET';
14
+ /**
15
+ * Hook for retrieving the selected wallet
16
+ */
17
+ export const useWallet = () => {
18
+ const client = useClient();
19
+ const { selectedWallet } = useWalletState();
20
+ return useQuery({
21
+ queryKey: [WALLET_BASE_KEY, client === null || client === void 0 ? void 0 : client.getUserId(), selectedWallet.id, selectedWallet.type],
22
+ queryFn: () => __awaiter(void 0, void 0, void 0, function* () { return yield getWallet(client, selectedWallet); }),
23
+ });
24
+ };
@@ -0,0 +1,3 @@
1
+ export { useClient } from './useClient.js';
2
+ export { useModal } from './useModal.js';
3
+ export { useWalletState } from './useWalletState.js';
@@ -0,0 +1,3 @@
1
+ export { useClient } from './useClient.js';
2
+ export { useModal } from './useModal.js';
3
+ export { useWalletState } from './useWalletState.js';
@@ -0,0 +1,3 @@
1
+ export declare const useAutoSessionKeepAlive: ({ disabled }: {
2
+ disabled?: boolean;
3
+ }) => void;