@getpara/react-sdk 1.12.0 → 2.0.0-alpha.10
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.
- package/dist/cli/cli.mjs +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/modal/ParaModal.js +211 -313
- package/dist/modal/components/Account/Account.js +73 -16
- package/dist/modal/components/AddFunds/AddFunds.js +5 -6
- package/dist/modal/components/AddFunds/AddFundsAsset.js +15 -13
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +16 -10
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +2 -2
- package/dist/modal/components/AddFunds/AddFundsContext.js +20 -14
- package/dist/modal/components/AddFunds/AddFundsDone.js +10 -4
- package/dist/modal/components/AddFunds/AddFundsProvider.js +11 -7
- package/dist/modal/components/AddFunds/AddFundsReceive.js +17 -13
- package/dist/modal/components/AddFunds/AddFundsSettings.js +10 -6
- package/dist/modal/components/AddFunds/common.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.js +70 -91
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +4 -4
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +20 -7
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +54 -10
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +35 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +9 -4
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -3
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +25 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +34 -72
- package/dist/modal/components/Body/Body.d.ts +4 -3
- package/dist/modal/components/Body/Body.js +27 -10
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +5 -4
- package/dist/modal/components/Controls/Controls.js +5 -2
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.js +30 -25
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +10 -6
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +7 -69
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +7 -6
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.js +6 -4
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -3
- package/dist/modal/components/Hero/Hero.js +5 -5
- package/dist/modal/components/IFrameStep/IFrameStep.js +8 -4
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +7 -4
- package/dist/modal/components/ModalContent/ModalContent.js +14 -243
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -57
- package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
- package/dist/modal/components/OAuth/OAuth.js +11 -85
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +11 -60
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +10 -4
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +23 -32
- package/dist/modal/components/StripeComponents/StripeComponents.js +1 -1
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +5 -2
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +44 -60
- package/dist/modal/components/WalletCard/WalletCard.d.ts +5 -5
- package/dist/modal/components/WalletCard/WalletCard.js +8 -7
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +33 -12
- package/dist/modal/components/common.d.ts +5 -5
- package/dist/modal/components/common.js +10 -4
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +3 -3
- package/dist/modal/hooks/useGoBack.js +6 -5
- package/dist/modal/index.d.ts +0 -3
- package/dist/modal/index.js +1 -5
- package/dist/modal/stores/index.d.ts +0 -2
- package/dist/modal/stores/index.js +0 -2
- package/dist/modal/stores/modal/actions.js +69 -16
- package/dist/modal/stores/modal/useModalStore.d.ts +26 -22
- package/dist/modal/stores/modal/useModalStore.js +9 -13
- package/dist/modal/types/commonTypes.d.ts +0 -52
- package/dist/modal/types/modalProps.d.ts +8 -32
- package/dist/modal/utils/authInputHelpers.d.ts +7 -0
- package/dist/modal/utils/authInputHelpers.js +38 -0
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/{components/AuthInput → utils}/countryCodes.js +6 -3
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/isPasskeySupported.js +15 -0
- package/dist/modal/utils/openPopup.d.ts +2 -2
- package/dist/modal/utils/openPopup.js +2 -2
- package/dist/modal/utils/steps.d.ts +6 -0
- package/dist/modal/utils/steps.js +15 -0
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/ParaProvider.js +69 -8
- package/dist/provider/actions/getAccount.d.ts +26 -8
- package/dist/provider/actions/getAccount.js +42 -14
- package/dist/provider/actions/getWallet.d.ts +3 -3
- package/dist/provider/actions/index.d.ts +27 -0
- package/dist/provider/actions/index.js +59 -0
- package/dist/provider/actions/utils.d.ts +3 -0
- package/dist/provider/actions/utils.js +15 -0
- package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
- package/dist/provider/components/CosmosWalletWrapper.js +34 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/EvmWalletWrapper.js +34 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/ExternalWalletWrapper.js +139 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/components/SolanaWalletWrapper.js +36 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaCosmosConnector.js +22 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.js +22 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.js +22 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
- package/dist/provider/hooks/mutations/index.d.ts +27 -11
- package/dist/provider/hooks/mutations/index.js +54 -17
- package/dist/provider/hooks/mutations/utils.d.ts +5 -0
- package/dist/provider/hooks/mutations/utils.js +59 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -7
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +1 -2
- package/dist/provider/hooks/queries/useWalletBalance.js +40 -11
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +5 -5
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +100 -56
- package/dist/provider/hooks/utils/useWalletState.d.ts +5 -4
- package/dist/provider/hooks/utils/useWalletState.js +24 -9
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +1 -0
- package/dist/provider/providers/AuthProvider.d.ts +35 -0
- package/dist/provider/providers/AuthProvider.js +498 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +76 -0
- package/dist/{modal/providers/ExternalWalletContext.js → provider/providers/ExternalWalletProvider.js} +146 -112
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/setters.js +7 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.js +40 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +1 -0
- package/dist/provider/stores/slices/modal.js +11 -4
- package/dist/provider/stores/types.d.ts +50 -4
- package/dist/provider/stores/useStore.js +4 -3
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +126 -17
- package/dist/provider/types/utils.d.ts +20 -0
- package/dist/provider/utils/constants.js +3 -4
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
- package/dist/provider/utils/renameMutations.d.ts +3 -0
- package/dist/provider/utils/renameMutations.js +5 -3
- package/package.json +20 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
- package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
- package/dist/modal/hooks/useActiveWallet.js +0 -15
- package/dist/modal/hooks/useCreateAccount.d.ts +0 -6
- package/dist/modal/hooks/useCreateAccount.js +0 -77
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
- package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
- package/dist/modal/hooks/useSetLoginURLs.js +0 -49
- package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
- package/dist/modal/hooks/useWalletBalance.js +0 -49
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
- package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
- package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
- package/dist/modal/stores/theme/actions.d.ts +0 -3
- package/dist/modal/stores/theme/actions.js +0 -28
- package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
- package/dist/modal/stores/theme/useThemeStore.js +0 -21
- package/dist/modal/stores/userInfo/actions.d.ts +0 -3
- package/dist/modal/stores/userInfo/actions.js +0 -30
- package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createGuestWallets.d.ts +0 -2
- package/dist/provider/actions/createGuestWallets.js +0 -13
- package/dist/provider/actions/createUser.d.ts +0 -12
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getWalletBalance.d.ts +0 -2
- package/dist/provider/actions/getWalletBalance.js +0 -14
- package/dist/provider/actions/initiateLogin.d.ts +0 -4
- package/dist/provider/actions/initiateLogin.js +0 -20
- package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
- package/dist/provider/actions/keepSessionAlive.js +0 -20
- package/dist/provider/actions/logout.d.ts +0 -2
- package/dist/provider/actions/logout.js +0 -17
- package/dist/provider/actions/signMessage.d.ts +0 -8
- package/dist/provider/actions/signMessage.js +0 -20
- package/dist/provider/actions/signTransaction.d.ts +0 -8
- package/dist/provider/actions/signTransaction.js +0 -20
- package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
- package/dist/provider/actions/waitForAccountCreation.js +0 -21
- package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +0 -15
- package/dist/provider/hooks/mutations/useCreateGuestWallets.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
- package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
- package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
- package/dist/provider/hooks/mutations/useLogout.js +0 -30
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -1,26 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
import * as actions from "../../actions/index.js";
|
|
4
|
+
import { generateHook, generateStateHook } from "./utils.js";
|
|
5
|
+
const useSignUpOrLogIn = generateHook("signUpOrLogIn", actions.signUpOrLogIn);
|
|
6
|
+
const useVerifyNewAccount = generateHook("verifyNewAccount", actions.verifyNewAccount);
|
|
7
|
+
const useWaitForLogin = generateHook("waitForLogin", actions.waitForLogin);
|
|
8
|
+
const useWaitForSignup = generateHook("waitForSignup", actions.waitForSignup);
|
|
9
|
+
const useWaitForWalletCreation = generateHook("waitForWalletCreation", actions.waitForWalletCreation);
|
|
10
|
+
const useVerifyOAuth = generateHook("verifyOAuth", actions.verifyOAuth);
|
|
11
|
+
const useVerifyFarcaster = generateHook("verifyFarcaster", actions.verifyFarcaster);
|
|
12
|
+
const useVerifyTelegram = generateHook("verifyTelegram", actions.verifyTelegram);
|
|
13
|
+
const useLoginExternalWallet = generateHook("loginExternalWallet", actions.loginExternalWallet);
|
|
14
|
+
const useVerifyExternalWallet = generateHook("verifyExternalWallet", actions.verifyExternalWallet);
|
|
15
|
+
const useSetup2fa = generateHook("setup2fa", actions.setup2fa);
|
|
16
|
+
const useEnable2fa = generateHook("enable2fa", actions.enable2fa);
|
|
17
|
+
const useVerify2fa = generateHook("verify2fa", actions.verify2fa);
|
|
18
|
+
const useKeepSessionAlive = generateHook("keepSessionAlive", actions.keepSessionAlive);
|
|
19
|
+
const useLogout = generateHook("logout", actions.logout);
|
|
20
|
+
const useResendVerificationCode = generateHook("resendVerificationCode", actions.resendVerificationCode);
|
|
21
|
+
const useCreateWallet = generateHook("createWallet", actions.createWallet);
|
|
22
|
+
const useCreateWalletPerType = generateHook("createWalletPerType", actions.createWalletPerType);
|
|
23
|
+
const useCreatePregenWallet = generateHook("createPregenWallet", actions.createPregenWallet);
|
|
24
|
+
const useCreatePregenWalletPerType = generateHook("createPregenWalletPerType", actions.createPregenWalletPerType);
|
|
25
|
+
const useClaimPregenWallets = generateHook("claimPregenWallets", actions.claimPregenWallets);
|
|
26
|
+
const useHasPregenWallet = generateHook("hasPregenWallet", actions.hasPregenWallet);
|
|
27
|
+
const useUpdatePregenWalletIdentifier = generateHook(
|
|
28
|
+
"updatePregenWalletIdentifier",
|
|
29
|
+
actions.updatePregenWalletIdentifier
|
|
30
|
+
);
|
|
31
|
+
const useCreateGuestWallets = generateHook("createGuestWallets", actions.createGuestWallets);
|
|
32
|
+
const useSignMessage = generateHook("signMessage", actions.signMessage);
|
|
33
|
+
const useSignTransaction = generateHook("signTransaction", actions.signTransaction);
|
|
34
|
+
const useCreateGuestWalletsState = generateStateHook("createGuestWallets");
|
|
14
35
|
export {
|
|
15
|
-
|
|
36
|
+
useClaimPregenWallets,
|
|
16
37
|
useCreateGuestWallets,
|
|
17
|
-
|
|
18
|
-
|
|
38
|
+
useCreateGuestWalletsState,
|
|
39
|
+
useCreatePregenWallet,
|
|
40
|
+
useCreatePregenWalletPerType,
|
|
41
|
+
useCreateWallet,
|
|
42
|
+
useCreateWalletPerType,
|
|
43
|
+
useEnable2fa,
|
|
44
|
+
useHasPregenWallet,
|
|
19
45
|
useKeepSessionAlive,
|
|
46
|
+
useLoginExternalWallet,
|
|
20
47
|
useLogout,
|
|
48
|
+
useResendVerificationCode,
|
|
49
|
+
useSetup2fa,
|
|
21
50
|
useSignMessage,
|
|
22
51
|
useSignTransaction,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
52
|
+
useSignUpOrLogIn,
|
|
53
|
+
useUpdatePregenWalletIdentifier,
|
|
54
|
+
useVerify2fa,
|
|
55
|
+
useVerifyExternalWallet,
|
|
56
|
+
useVerifyFarcaster,
|
|
57
|
+
useVerifyNewAccount,
|
|
58
|
+
useVerifyOAuth,
|
|
59
|
+
useVerifyTelegram,
|
|
60
|
+
useWaitForLogin,
|
|
61
|
+
useWaitForSignup,
|
|
62
|
+
useWaitForWalletCreation
|
|
26
63
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CoreMethodName, CoreMethodParams, CoreMethods } from '@getpara/web-sdk';
|
|
2
|
+
import { CoreMethodHook, CoreMethodStateHook } from '../../types/utils.js';
|
|
3
|
+
import { CoreAction } from '../../actions/utils.js';
|
|
4
|
+
export declare function generateHook<const method extends CoreMethodName & keyof CoreMethods>(method: method, action: CoreAction<method>, defaultParams?: CoreMethodParams<method>): () => CoreMethodHook<method>;
|
|
5
|
+
export declare function generateStateHook<const method extends CoreMethodName & keyof CoreMethods>(method: method): CoreMethodStateHook<method>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
+
import { renameCoreMutations } from "../../utils/renameMutations.js";
|
|
8
|
+
import { useClient } from "../utils/index.js";
|
|
9
|
+
import { useMutation, useMutationState } from "@tanstack/react-query";
|
|
10
|
+
function generateHook(method, action, defaultParams) {
|
|
11
|
+
return () => {
|
|
12
|
+
const para = useClient();
|
|
13
|
+
const mutation = useMutation({
|
|
14
|
+
mutationKey: [method],
|
|
15
|
+
mutationFn: (args) => __async(this, null, function* () {
|
|
16
|
+
const result = yield action(para, args != null ? args : defaultParams);
|
|
17
|
+
return result;
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
return renameCoreMutations(mutation, method);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function generateStateHook(method) {
|
|
24
|
+
return () => {
|
|
25
|
+
const frames = useMutationState({
|
|
26
|
+
filters: { mutationKey: [method] },
|
|
27
|
+
select: (mutation) => mutation.state
|
|
28
|
+
});
|
|
29
|
+
const latest = frames[frames.length - 1];
|
|
30
|
+
if (!latest) {
|
|
31
|
+
return {
|
|
32
|
+
data: void 0,
|
|
33
|
+
error: null,
|
|
34
|
+
failureCount: 0,
|
|
35
|
+
isLoading: false,
|
|
36
|
+
isPaused: false,
|
|
37
|
+
isPending: false,
|
|
38
|
+
isError: false,
|
|
39
|
+
isSuccess: false,
|
|
40
|
+
isIdle: true,
|
|
41
|
+
status: "idle",
|
|
42
|
+
variables: void 0,
|
|
43
|
+
context: null,
|
|
44
|
+
failureReason: null,
|
|
45
|
+
submittedAt: 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return __spreadProps(__spreadValues({}, latest), {
|
|
49
|
+
isPending: latest.status === "pending",
|
|
50
|
+
isError: latest.status === "error",
|
|
51
|
+
isSuccess: latest.status === "success",
|
|
52
|
+
isIdle: latest.status === "idle"
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
generateHook,
|
|
58
|
+
generateStateHook
|
|
59
|
+
};
|
|
@@ -2,10 +2,4 @@ export declare const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook for retrieving a user account
|
|
4
4
|
*/
|
|
5
|
-
export declare const useAccount: () => import("@tanstack/react-query").UseQueryResult<
|
|
6
|
-
isConnected: boolean;
|
|
7
|
-
isGuestMode: boolean;
|
|
8
|
-
email: any;
|
|
9
|
-
phone: any;
|
|
10
|
-
wallets: any;
|
|
11
|
-
}, Error>;
|
|
5
|
+
export declare const useAccount: () => import("@tanstack/react-query").UseQueryResult<import("../../actions/getAccount.js").Account, Error>;
|
|
@@ -2,4 +2,4 @@ export declare const WALLET_BASE_KEY = "PARA_WALLET";
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook for retrieving the selected wallet
|
|
4
4
|
*/
|
|
5
|
-
export declare const useWallet: () => import("@tanstack/react-query").UseQueryResult<Omit<import("@getpara/core-sdk").Wallet, "signer"
|
|
5
|
+
export declare const useWallet: () => import("@tanstack/react-query").UseQueryResult<Omit<import("@getpara/core-sdk").Wallet, "signer"> | null | undefined, Error>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
1
|
import { GetWalletBalanceParams } from '@getpara/web-sdk';
|
|
3
2
|
export declare const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
|
|
4
3
|
/**
|
|
5
4
|
* Hook for retrieving a wallet balance
|
|
6
5
|
*/
|
|
7
|
-
export declare const useWalletBalance: (args?: Partial<GetWalletBalanceParams
|
|
6
|
+
export declare const useWalletBalance: (args?: Partial<GetWalletBalanceParams>) => import("@tanstack/react-query").UseQueryResult<string | null, Error>;
|
|
@@ -4,21 +4,50 @@ import {
|
|
|
4
4
|
__spreadValues
|
|
5
5
|
} from "../../../chunk-MMUBH76A.js";
|
|
6
6
|
import { useQuery } from "@tanstack/react-query";
|
|
7
|
-
import { useClient, useWalletState } from "../index.js";
|
|
8
|
-
import { getWalletBalance } from "../../actions/getWalletBalance.js";
|
|
7
|
+
import { useAccount, useClient, useWallet, useWalletState } from "../index.js";
|
|
9
8
|
import { useStore } from "../../stores/useStore.js";
|
|
9
|
+
import { getWalletBalance } from "../../actions/index.js";
|
|
10
|
+
import { useExternalWallets } from "../../providers/ExternalWalletProvider.js";
|
|
11
|
+
import { useCallback } from "react";
|
|
10
12
|
const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
|
|
11
|
-
const useWalletBalance = (args
|
|
13
|
+
const useWalletBalance = (args) => {
|
|
12
14
|
const client = useClient();
|
|
13
|
-
const { selectedWallet } =
|
|
15
|
+
const { data: selectedWallet } = useWallet();
|
|
16
|
+
const {
|
|
17
|
+
selectedWallet: { type: selectedWalletType }
|
|
18
|
+
} = useWalletState();
|
|
19
|
+
const { data: account } = useAccount();
|
|
14
20
|
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const { getWalletBalance: getExternalWalletBalance, chainId } = useExternalWallets();
|
|
22
|
+
const queryFn = useCallback(() => __async(void 0, null, function* () {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
const skipGetBalance = !selectedWallet || selectedWalletType && ["COSMOS", "SOLANA"].includes(selectedWalletType);
|
|
25
|
+
if (skipGetBalance) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
if (selectedWallet.isExternal) {
|
|
30
|
+
return (_a = yield getExternalWalletBalance()) != null ? _a : null;
|
|
31
|
+
} else {
|
|
32
|
+
const completeArgs = __spreadValues({ walletId: (_b = selectedWallet == null ? void 0 : selectedWallet.id) != null ? _b : "", rpcUrl }, args);
|
|
33
|
+
return (_c = yield getWalletBalance(client, completeArgs)) != null ? _c : null;
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.error("Error fetching wallet balance: ", err);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}), [account, selectedWallet, selectedWalletType, rpcUrl, getExternalWalletBalance]);
|
|
40
|
+
return useQuery({
|
|
41
|
+
queryKey: [
|
|
42
|
+
WALLET_BALANCE_BASE_KEY,
|
|
43
|
+
client == null ? void 0 : client.userId,
|
|
44
|
+
selectedWallet == null ? void 0 : selectedWallet.id,
|
|
45
|
+
selectedWallet == null ? void 0 : selectedWallet.type,
|
|
46
|
+
(selectedWallet == null ? void 0 : selectedWallet.isExternal) ? chainId : ""
|
|
47
|
+
],
|
|
48
|
+
queryFn,
|
|
49
|
+
enabled: !!selectedWallet && !!rpcUrl && !!(account == null ? void 0 : account.isConnected)
|
|
50
|
+
});
|
|
22
51
|
};
|
|
23
52
|
export {
|
|
24
53
|
WALLET_BALANCE_BASE_KEY,
|
|
@@ -18,7 +18,7 @@ const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
|
18
18
|
clearSessionMonitoring();
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
if ((account == null ? void 0 : account.isConnected) && !client.
|
|
21
|
+
if ((account == null ? void 0 : account.isConnected) && !account.isGuestMode && client.externalWalletConnectionType !== "CONNECTION_ONLY") {
|
|
22
22
|
setupSessionMonitoring();
|
|
23
23
|
} else {
|
|
24
24
|
clearSessionMonitoring();
|
|
@@ -27,7 +27,7 @@ const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
|
27
27
|
}, [client, account, disabled]);
|
|
28
28
|
const getSessionExpiry = () => __async(void 0, null, function* () {
|
|
29
29
|
try {
|
|
30
|
-
const sessionCookie = yield client.retrieveSessionCookie();
|
|
30
|
+
const sessionCookie = yield client == null ? void 0 : client.retrieveSessionCookie();
|
|
31
31
|
if (!sessionCookie) return null;
|
|
32
32
|
const expiresMatch = sessionCookie.match(/Expires=([^;]+)/);
|
|
33
33
|
return expiresMatch ? new Date(expiresMatch[1]) : null;
|
|
@@ -40,13 +40,13 @@ const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
|
40
40
|
sessionCheckInterval.current = setInterval(() => __async(void 0, null, function* () {
|
|
41
41
|
const expiry = yield getSessionExpiry();
|
|
42
42
|
if (!expiry) {
|
|
43
|
-
yield logoutAsync();
|
|
43
|
+
yield logoutAsync({});
|
|
44
44
|
clearSessionMonitoring();
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
const timeUntilExpiry = expiry.getTime() - Date.now();
|
|
48
48
|
if (timeUntilExpiry <= 0) {
|
|
49
|
-
yield logoutAsync();
|
|
49
|
+
yield logoutAsync({});
|
|
50
50
|
clearSessionMonitoring();
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
@@ -56,7 +56,7 @@ const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
|
56
56
|
setupSessionMonitoring();
|
|
57
57
|
} catch (err) {
|
|
58
58
|
console.error("Failed to keep session alive:", err);
|
|
59
|
-
yield logoutAsync();
|
|
59
|
+
yield logoutAsync({});
|
|
60
60
|
clearSessionMonitoring();
|
|
61
61
|
}
|
|
62
62
|
return;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Callbacks } from '../../types/provider.js';
|
|
2
|
-
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, }?: Callbacks) => void;
|
|
2
|
+
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, onGuestWalletsCreated, }?: Callbacks) => void;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
3
|
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import {
|
|
4
|
+
import { useCallback, useEffect } from "react";
|
|
5
|
+
import { useWalletState } from "../index.js";
|
|
6
6
|
import {
|
|
7
7
|
ParaEvent
|
|
8
8
|
} from "@getpara/web-sdk";
|
|
9
9
|
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
10
10
|
import { useStore } from "../../stores/useStore.js";
|
|
11
|
-
import { WALLET_BASE_KEY } from "
|
|
11
|
+
import { WALLET_BASE_KEY } from "../queries/useWallet.js";
|
|
12
12
|
const useEventListeners = ({
|
|
13
13
|
onLogin,
|
|
14
14
|
onLogout,
|
|
@@ -19,62 +19,92 @@ const useEventListeners = ({
|
|
|
19
19
|
onWalletCreated,
|
|
20
20
|
onPregenWalletClaimed,
|
|
21
21
|
onExternalWalletChange,
|
|
22
|
-
onWalletsChange
|
|
22
|
+
onWalletsChange,
|
|
23
|
+
onGuestWalletsCreated
|
|
23
24
|
} = {}) => {
|
|
24
25
|
const queryClient = useQueryClient();
|
|
25
|
-
const client = useClient();
|
|
26
26
|
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
27
|
-
const {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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) {
|
|
27
|
+
const { updateSelectedWallet } = useWalletState();
|
|
28
|
+
const loginOrSetupListener = useCallback(() => {
|
|
29
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
30
|
+
queryClient.refetchQueries({ queryKey: [WALLET_BASE_KEY] });
|
|
31
|
+
}, [queryClient]);
|
|
32
|
+
const loginListener = useCallback(
|
|
33
|
+
(event) => {
|
|
34
|
+
loginOrSetupListener();
|
|
35
|
+
onLogin == null ? void 0 : onLogin(event);
|
|
36
|
+
},
|
|
37
|
+
[loginOrSetupListener, onLogin]
|
|
38
|
+
);
|
|
39
|
+
const accountSetupListener = useCallback(
|
|
40
|
+
(event) => {
|
|
41
|
+
loginOrSetupListener();
|
|
42
|
+
onAccountSetup == null ? void 0 : onAccountSetup(event);
|
|
43
|
+
},
|
|
44
|
+
[loginOrSetupListener, onAccountSetup]
|
|
45
|
+
);
|
|
46
|
+
const accountCreationListener = useCallback(
|
|
47
|
+
(event) => {
|
|
48
|
+
onAccountCreation == null ? void 0 : onAccountCreation(event);
|
|
49
|
+
},
|
|
50
|
+
[onAccountCreation]
|
|
51
|
+
);
|
|
52
|
+
const logoutListener = useCallback(
|
|
53
|
+
(event) => {
|
|
54
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
70
55
|
clearSelectedWallet();
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
56
|
+
onLogout == null ? void 0 : onLogout(event);
|
|
57
|
+
},
|
|
58
|
+
[queryClient, clearSelectedWallet, onLogout]
|
|
59
|
+
);
|
|
60
|
+
const signMessageListener = useCallback(
|
|
61
|
+
(event) => {
|
|
62
|
+
onSignMessage == null ? void 0 : onSignMessage(event);
|
|
63
|
+
},
|
|
64
|
+
[onSignMessage]
|
|
65
|
+
);
|
|
66
|
+
const signTransactionListener = useCallback(
|
|
67
|
+
(event) => {
|
|
68
|
+
onSignTransaction == null ? void 0 : onSignTransaction(event);
|
|
69
|
+
},
|
|
70
|
+
[onSignTransaction]
|
|
71
|
+
);
|
|
72
|
+
const walletChangeListener = useCallback(
|
|
73
|
+
(event) => {
|
|
74
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
75
|
+
updateSelectedWallet();
|
|
76
|
+
onWalletsChange == null ? void 0 : onWalletsChange(event);
|
|
77
|
+
},
|
|
78
|
+
[queryClient, updateSelectedWallet, onWalletsChange]
|
|
79
|
+
);
|
|
80
|
+
const externalWalletChangeListener = useCallback(
|
|
81
|
+
(event) => {
|
|
82
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
83
|
+
updateSelectedWallet();
|
|
84
|
+
onExternalWalletChange == null ? void 0 : onExternalWalletChange(event);
|
|
85
|
+
},
|
|
86
|
+
[queryClient, updateSelectedWallet, onExternalWalletChange]
|
|
87
|
+
);
|
|
88
|
+
const walletCreatedListener = useCallback(
|
|
89
|
+
(event) => {
|
|
90
|
+
onWalletCreated == null ? void 0 : onWalletCreated(event);
|
|
91
|
+
},
|
|
92
|
+
[onWalletCreated]
|
|
93
|
+
);
|
|
94
|
+
const pregenWalletClaimedListener = useCallback(
|
|
95
|
+
(event) => {
|
|
96
|
+
onPregenWalletClaimed == null ? void 0 : onPregenWalletClaimed(event);
|
|
97
|
+
},
|
|
98
|
+
[onPregenWalletClaimed]
|
|
99
|
+
);
|
|
100
|
+
const guestWalletsCreatedListener = useCallback(
|
|
101
|
+
(event) => {
|
|
102
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
103
|
+
updateSelectedWallet();
|
|
104
|
+
onGuestWalletsCreated == null ? void 0 : onGuestWalletsCreated(event);
|
|
105
|
+
},
|
|
106
|
+
[onGuestWalletsCreated]
|
|
107
|
+
);
|
|
78
108
|
useEffect(() => {
|
|
79
109
|
window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
80
110
|
window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
@@ -86,6 +116,7 @@ const useEventListeners = ({
|
|
|
86
116
|
window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
|
|
87
117
|
window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
88
118
|
window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
119
|
+
window.addEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
89
120
|
return () => {
|
|
90
121
|
window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
91
122
|
window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
@@ -97,8 +128,21 @@ const useEventListeners = ({
|
|
|
97
128
|
window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
|
|
98
129
|
window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
99
130
|
window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
131
|
+
window.removeEventListener(ParaEvent.GUEST_WALLETS_CREATED, guestWalletsCreatedListener);
|
|
100
132
|
};
|
|
101
|
-
}, [
|
|
133
|
+
}, [
|
|
134
|
+
loginListener,
|
|
135
|
+
accountSetupListener,
|
|
136
|
+
accountCreationListener,
|
|
137
|
+
logoutListener,
|
|
138
|
+
signMessageListener,
|
|
139
|
+
signTransactionListener,
|
|
140
|
+
walletChangeListener,
|
|
141
|
+
externalWalletChangeListener,
|
|
142
|
+
walletCreatedListener,
|
|
143
|
+
pregenWalletClaimedListener,
|
|
144
|
+
guestWalletsCreatedListener
|
|
145
|
+
]);
|
|
102
146
|
};
|
|
103
147
|
export {
|
|
104
148
|
useEventListeners
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TWalletType } from '@getpara/web-sdk';
|
|
2
2
|
/**
|
|
3
3
|
* Hook for controlling selected wallet
|
|
4
4
|
*/
|
|
5
5
|
export declare const useWalletState: () => {
|
|
6
6
|
selectedWallet: {
|
|
7
|
-
id: string;
|
|
8
|
-
type:
|
|
7
|
+
id: string | undefined;
|
|
8
|
+
type: "EVM" | "SOLANA" | "COSMOS" | undefined;
|
|
9
9
|
};
|
|
10
10
|
setSelectedWallet: ({ id, type }: {
|
|
11
11
|
id?: string;
|
|
12
|
-
type?:
|
|
12
|
+
type?: TWalletType;
|
|
13
13
|
}) => void;
|
|
14
|
+
updateSelectedWallet: () => void;
|
|
14
15
|
};
|
|
@@ -2,30 +2,45 @@
|
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
3
|
import { useStore } from "../../stores/useStore.js";
|
|
4
4
|
import { useClient } from "./useClient.js";
|
|
5
|
+
import { useCallback } from "react";
|
|
5
6
|
const useWalletState = () => {
|
|
6
7
|
const client = useClient();
|
|
7
8
|
const selectedWalletId = useStore((state) => state.selectedWalletId);
|
|
8
9
|
const selectedWalletType = useStore((state) => state.selectedWalletType);
|
|
9
10
|
const setStoredSelectedWallet = useStore((state) => state.setSelectedWallet);
|
|
10
11
|
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
11
|
-
const setSelectedWallet = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const setSelectedWallet = useCallback(
|
|
13
|
+
({ id, type }) => {
|
|
14
|
+
try {
|
|
15
|
+
const validId = client == null ? void 0 : client.findWalletId(id, type ? { type: [type] } : void 0);
|
|
16
|
+
if (validId !== id) {
|
|
17
|
+
clearSelectedWallet();
|
|
18
|
+
} else {
|
|
19
|
+
setStoredSelectedWallet(id, type);
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
15
22
|
clearSelectedWallet();
|
|
16
|
-
} else {
|
|
17
|
-
setStoredSelectedWallet(id, type);
|
|
18
23
|
}
|
|
19
|
-
}
|
|
24
|
+
},
|
|
25
|
+
[client, clearSelectedWallet, setStoredSelectedWallet]
|
|
26
|
+
);
|
|
27
|
+
const updateSelectedWallet = useCallback(() => {
|
|
28
|
+
if (!client) {
|
|
20
29
|
clearSelectedWallet();
|
|
30
|
+
return;
|
|
21
31
|
}
|
|
22
|
-
|
|
32
|
+
if (!selectedWalletId || !client.findWallet(selectedWalletId)) {
|
|
33
|
+
const defaultWallet = client.findWallet(void 0, void 0, { forbidPregen: true });
|
|
34
|
+
setSelectedWallet({ id: defaultWallet == null ? void 0 : defaultWallet.id, type: defaultWallet == null ? void 0 : defaultWallet.type });
|
|
35
|
+
}
|
|
36
|
+
}, [clearSelectedWallet, setSelectedWallet, client, selectedWalletId]);
|
|
23
37
|
return {
|
|
24
38
|
selectedWallet: {
|
|
25
39
|
id: selectedWalletId,
|
|
26
40
|
type: selectedWalletType
|
|
27
41
|
},
|
|
28
|
-
setSelectedWallet
|
|
42
|
+
setSelectedWallet,
|
|
43
|
+
updateSelectedWallet
|
|
29
44
|
};
|
|
30
45
|
};
|
|
31
46
|
export {
|
package/dist/provider/index.d.ts
CHANGED
package/dist/provider/index.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BiometricHints } from '@getpara/react-common';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { AuthMethod, CoreMethodParams, AuthState, AuthStateSignup, AuthStateLogin } from '@getpara/web-sdk';
|
|
4
|
+
import { ParaModalProps } from '../../modal/types/modalProps.js';
|
|
5
|
+
import { TelegramAuthResponse, VerifiedAuth } from '@getpara/user-management-client';
|
|
6
|
+
type Value = {
|
|
7
|
+
signUpOrLogIn: (_: VerifiedAuth) => void;
|
|
8
|
+
isSignUpOrLogInPending: boolean;
|
|
9
|
+
verifyNewAccount: (_: string) => void;
|
|
10
|
+
isVerifyNewAccountPending: boolean;
|
|
11
|
+
verifyNewAccountError: Error | null;
|
|
12
|
+
verifyOAuth: (_: CoreMethodParams<'verifyOAuth'>['method']) => void;
|
|
13
|
+
verifyFarcaster: () => void;
|
|
14
|
+
verifyTelegram: (_: TelegramAuthResponse) => void;
|
|
15
|
+
onNewAuthState: (_: AuthState) => void;
|
|
16
|
+
presentSignupUi: (_: AuthMethod, __: AuthStateSignup) => void;
|
|
17
|
+
presentLoginUi: (_: AuthMethod, __: AuthStateLogin) => void;
|
|
18
|
+
isSetup2faPending: boolean;
|
|
19
|
+
createGuestWallets: () => void;
|
|
20
|
+
isCreateGuestWalletsPending: boolean;
|
|
21
|
+
logout: () => void;
|
|
22
|
+
biometricHints?: BiometricHints;
|
|
23
|
+
};
|
|
24
|
+
type Props = PropsWithChildren<{
|
|
25
|
+
is2faEnabled?: boolean;
|
|
26
|
+
isRecoverySecretStepEnabled?: boolean;
|
|
27
|
+
overrides?: {
|
|
28
|
+
login?: ParaModalProps['loginTransitionOverride'];
|
|
29
|
+
createWallets?: ParaModalProps['createWalletOverride'];
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
export declare const AuthContext: import("react").Context<Value>;
|
|
33
|
+
export declare function AuthProvider({ children, is2faEnabled, isRecoverySecretStepEnabled, overrides, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare const useAuthActions: () => Value;
|
|
35
|
+
export {};
|