@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { CommonChain, CommonWallet } from '@getpara/react-common';
|
|
3
|
+
import { VerifyExternalWalletParams } from '@getpara/user-management-client';
|
|
4
|
+
export declare const defaultExternalWallet: {
|
|
5
|
+
wallets: never[];
|
|
6
|
+
chains: never[];
|
|
7
|
+
chainId: undefined;
|
|
8
|
+
wallet: undefined;
|
|
9
|
+
qrUri: undefined;
|
|
10
|
+
chainIdSwitchingTo: undefined;
|
|
11
|
+
walletDisplayHelpers: {
|
|
12
|
+
showExtension: boolean;
|
|
13
|
+
showMobile: boolean;
|
|
14
|
+
isSolanaMobileIOS: boolean;
|
|
15
|
+
isCosmosMobileWallet: boolean;
|
|
16
|
+
};
|
|
17
|
+
username: undefined;
|
|
18
|
+
avatar: undefined;
|
|
19
|
+
connectExternalWallet: () => Promise<void>;
|
|
20
|
+
disconnectExternalWallet: () => Promise<void>;
|
|
21
|
+
switchChain: () => Promise<void>;
|
|
22
|
+
setChainIdSwitchingTo: () => void;
|
|
23
|
+
connectEmbeddedToExternalConnectors: () => Promise<void>;
|
|
24
|
+
verifyWalletSignature: () => Promise<any>;
|
|
25
|
+
getWalletBalance: () => Promise<undefined>;
|
|
26
|
+
isExternalWalletVerifying: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare const ExternalWalletContext: import("react").Context<{
|
|
29
|
+
wallets: CommonWallet[];
|
|
30
|
+
chains: CommonChain[];
|
|
31
|
+
chainId?: string;
|
|
32
|
+
wallet?: CommonWallet;
|
|
33
|
+
qrUri?: string;
|
|
34
|
+
chainIdSwitchingTo?: string;
|
|
35
|
+
walletDisplayHelpers: {
|
|
36
|
+
showExtension: boolean;
|
|
37
|
+
showMobile: boolean;
|
|
38
|
+
isSolanaMobileIOS: boolean;
|
|
39
|
+
isCosmosMobileWallet: boolean;
|
|
40
|
+
};
|
|
41
|
+
username?: string;
|
|
42
|
+
avatar?: string;
|
|
43
|
+
connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
|
|
44
|
+
disconnectExternalWallet: () => Promise<void>;
|
|
45
|
+
switchChain: (chainId: string) => Promise<void>;
|
|
46
|
+
setChainIdSwitchingTo: (chainId?: string) => void;
|
|
47
|
+
connectEmbeddedToExternalConnectors: () => Promise<void>;
|
|
48
|
+
verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
|
|
49
|
+
getWalletBalance: () => Promise<string | undefined>;
|
|
50
|
+
isExternalWalletVerifying?: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
export declare function ExternalWalletProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare const useExternalWallets: () => {
|
|
54
|
+
wallets: CommonWallet[];
|
|
55
|
+
chains: CommonChain[];
|
|
56
|
+
chainId?: string;
|
|
57
|
+
wallet?: CommonWallet;
|
|
58
|
+
qrUri?: string;
|
|
59
|
+
chainIdSwitchingTo?: string;
|
|
60
|
+
walletDisplayHelpers: {
|
|
61
|
+
showExtension: boolean;
|
|
62
|
+
showMobile: boolean;
|
|
63
|
+
isSolanaMobileIOS: boolean;
|
|
64
|
+
isCosmosMobileWallet: boolean;
|
|
65
|
+
};
|
|
66
|
+
username?: string;
|
|
67
|
+
avatar?: string;
|
|
68
|
+
connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => Promise<void>;
|
|
69
|
+
disconnectExternalWallet: () => Promise<void>;
|
|
70
|
+
switchChain: (chainId: string) => Promise<void>;
|
|
71
|
+
setChainIdSwitchingTo: (chainId?: string) => void;
|
|
72
|
+
connectEmbeddedToExternalConnectors: () => Promise<void>;
|
|
73
|
+
verifyWalletSignature: () => Promise<VerifyExternalWalletParams | undefined>;
|
|
74
|
+
getWalletBalance: () => Promise<string | undefined>;
|
|
75
|
+
isExternalWalletVerifying?: boolean;
|
|
76
|
+
};
|
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
} from "../../chunk-MMUBH76A.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { isIOS, isIOSWebview, isMobile, truncateAddress } from "@getpara/web-sdk";
|
|
8
|
+
import { useInternalClient } from "../hooks/utils/useInternalClient.js";
|
|
9
|
+
import { useStore } from "../stores/useStore.js";
|
|
10
|
+
import { ModalStep } from "../../modal/index.js";
|
|
11
|
+
import { useModalStore } from "../../modal/stores/index.js";
|
|
12
|
+
import { useVerifyExternalWallet, useWalletState } from "../hooks/index.js";
|
|
13
|
+
import { useAuthActions } from "./AuthProvider.js";
|
|
13
14
|
const defaultExternalWallet = {
|
|
14
15
|
wallets: [],
|
|
15
16
|
chains: [],
|
|
@@ -17,32 +18,26 @@ const defaultExternalWallet = {
|
|
|
17
18
|
wallet: void 0,
|
|
18
19
|
qrUri: void 0,
|
|
19
20
|
chainIdSwitchingTo: void 0,
|
|
20
|
-
walletDisplayHelpers: {
|
|
21
|
-
showExtension: false,
|
|
22
|
-
showMobile: false,
|
|
23
|
-
isSolanaMobileIOS: false,
|
|
24
|
-
isCosmosMobileWallet: false
|
|
25
|
-
},
|
|
21
|
+
walletDisplayHelpers: { showExtension: false, showMobile: false, isSolanaMobileIOS: false, isCosmosMobileWallet: false },
|
|
26
22
|
username: void 0,
|
|
27
23
|
avatar: void 0,
|
|
28
|
-
|
|
29
|
-
connectExternalWallet: () => {
|
|
30
|
-
},
|
|
24
|
+
connectExternalWallet: () => Promise.resolve(),
|
|
31
25
|
disconnectExternalWallet: () => Promise.resolve(),
|
|
32
26
|
switchChain: () => Promise.resolve(),
|
|
33
27
|
setChainIdSwitchingTo: () => {
|
|
34
28
|
},
|
|
35
|
-
|
|
29
|
+
connectEmbeddedToExternalConnectors: () => Promise.resolve(),
|
|
30
|
+
verifyWalletSignature: () => Promise.resolve({}),
|
|
31
|
+
getWalletBalance: () => Promise.resolve(void 0),
|
|
32
|
+
isExternalWalletVerifying: false
|
|
36
33
|
};
|
|
37
34
|
const ExternalWalletContext = createContext(defaultExternalWallet);
|
|
38
|
-
function ExternalWalletProvider({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
solanaContext
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
externalWalletsWithFullAuth
|
|
45
|
-
}) {
|
|
35
|
+
function ExternalWalletProvider({ children }) {
|
|
36
|
+
const evmContext = useStore((state) => state.evmContext);
|
|
37
|
+
const cosmosContext = useStore((state) => state.cosmosContext);
|
|
38
|
+
const solanaContext = useStore((state) => state.solanaContext);
|
|
39
|
+
const externalWallets = useStore((state) => state.externalWallets);
|
|
40
|
+
const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
|
|
46
41
|
const {
|
|
47
42
|
wallets: evmWallets,
|
|
48
43
|
disconnect: evmDisconnect,
|
|
@@ -51,8 +46,9 @@ function ExternalWalletProvider({
|
|
|
51
46
|
switchChain: evmSwitchChain,
|
|
52
47
|
username: evmUsername,
|
|
53
48
|
avatar: evmAvatar,
|
|
54
|
-
|
|
55
|
-
signVerificationMessage: evmSignVerificationMessage
|
|
49
|
+
connectParaEmbedded: evmConnectParaEmbedded,
|
|
50
|
+
signVerificationMessage: evmSignVerificationMessage,
|
|
51
|
+
getWalletBalance: evmGetWalletBalance
|
|
56
52
|
} = useContext(evmContext);
|
|
57
53
|
const {
|
|
58
54
|
wallets: solanaWallets,
|
|
@@ -65,12 +61,11 @@ function ExternalWalletProvider({
|
|
|
65
61
|
chains: cosmosChains,
|
|
66
62
|
chainId: cosmosChainId,
|
|
67
63
|
switchChain: cosmosSwitchChain,
|
|
64
|
+
connectParaEmbedded: cosmosConnectParaEmbedded,
|
|
68
65
|
signVerificationMessage: cosmosSignVerificationMessage
|
|
69
66
|
} = useContext(cosmosContext);
|
|
67
|
+
const onLoginRef = useStore((state) => state.onLoginRef);
|
|
70
68
|
const setStep = useModalStore((state) => state.setStep);
|
|
71
|
-
const setFlow = useModalStore((state) => state.setFlow);
|
|
72
|
-
const setSupportedAuthMethods = useModalStore((state) => state.setSupportedAuthMethods);
|
|
73
|
-
const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
|
|
74
69
|
const setStepDirection = useModalStore((state) => state.setStepDirection);
|
|
75
70
|
const setIsExternalWalletConnecting = useModalStore((state) => state.setIsExternalWalletConnecting);
|
|
76
71
|
const isExternalWalletConnecting = useModalStore((state) => state.isExternalWalletConnecting);
|
|
@@ -80,12 +75,14 @@ function ExternalWalletProvider({
|
|
|
80
75
|
const setIsUsingMobileConnector = useModalStore((state) => state.setIsUsingMobileConnector);
|
|
81
76
|
const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
|
|
82
77
|
const para = useInternalClient();
|
|
83
|
-
const
|
|
84
|
-
const
|
|
78
|
+
const { setSelectedWallet } = useWalletState();
|
|
79
|
+
const { onNewAuthState } = useAuthActions();
|
|
80
|
+
const { mutate: verifyExternalWallet } = useVerifyExternalWallet();
|
|
85
81
|
const [qrUri, setQrUri] = useState();
|
|
86
82
|
const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
|
|
87
|
-
const
|
|
88
|
-
|
|
83
|
+
const [isExternalWalletVerifying, setIsExternalWalletVerifying] = useState(false);
|
|
84
|
+
const wallets = [...evmWallets, ...solanaWallets, ...cosmosWallets].filter((w) => externalWallets.includes(w.id.toUpperCase())).sort(
|
|
85
|
+
(a, b) => externalWallets.indexOf(a.id.toUpperCase()) - externalWallets.indexOf(b.id.toUpperCase())
|
|
89
86
|
).sort((a, b) => a.installed === b.installed ? 0 : a.installed ? -1 : 1);
|
|
90
87
|
const wallet = useMemo(() => wallets.find((w) => w.id === selectedExternalWalletId), [wallets, selectedExternalWalletId]);
|
|
91
88
|
const updateQrUri = () => __async(this, null, function* () {
|
|
@@ -102,26 +99,26 @@ function ExternalWalletProvider({
|
|
|
102
99
|
setQrUri(void 0);
|
|
103
100
|
}
|
|
104
101
|
}, [wallet]);
|
|
105
|
-
const
|
|
102
|
+
const getWalletBalance = useCallback(() => __async(this, null, function* () {
|
|
106
103
|
var _a;
|
|
107
104
|
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
108
105
|
switch (walletType) {
|
|
109
|
-
case
|
|
110
|
-
return
|
|
106
|
+
case "EVM": {
|
|
107
|
+
return yield evmGetWalletBalance();
|
|
111
108
|
}
|
|
112
109
|
default: {
|
|
113
110
|
return void 0;
|
|
114
111
|
}
|
|
115
112
|
}
|
|
116
|
-
}, [
|
|
113
|
+
}), [evmGetWalletBalance, selectedExternalWalletId]);
|
|
117
114
|
const chains = useMemo(() => {
|
|
118
115
|
var _a;
|
|
119
116
|
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
120
117
|
switch (walletType) {
|
|
121
|
-
case
|
|
118
|
+
case "COSMOS": {
|
|
122
119
|
return cosmosChains;
|
|
123
120
|
}
|
|
124
|
-
case
|
|
121
|
+
case "EVM": {
|
|
125
122
|
return evmChains;
|
|
126
123
|
}
|
|
127
124
|
default: {
|
|
@@ -133,10 +130,10 @@ function ExternalWalletProvider({
|
|
|
133
130
|
var _a;
|
|
134
131
|
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
135
132
|
switch (walletType) {
|
|
136
|
-
case
|
|
133
|
+
case "COSMOS": {
|
|
137
134
|
return cosmosChainId;
|
|
138
135
|
}
|
|
139
|
-
case
|
|
136
|
+
case "EVM": {
|
|
140
137
|
return evmChainId == null ? void 0 : evmChainId.toString();
|
|
141
138
|
}
|
|
142
139
|
default: {
|
|
@@ -153,17 +150,18 @@ function ExternalWalletProvider({
|
|
|
153
150
|
setExternalWalletError();
|
|
154
151
|
setChainIdSwitchingTo(chainId2);
|
|
155
152
|
switch (walletType) {
|
|
156
|
-
case
|
|
153
|
+
case "COSMOS": {
|
|
157
154
|
setStep(ModalStep.CHAIN_SWITCH);
|
|
158
155
|
resp = yield cosmosSwitchChain(chainId2);
|
|
159
156
|
break;
|
|
160
157
|
}
|
|
161
|
-
case
|
|
158
|
+
case "EVM": {
|
|
162
159
|
setStep(ModalStep.CHAIN_SWITCH);
|
|
163
160
|
resp = yield evmSwitchChain(parseInt(chainId2));
|
|
164
161
|
break;
|
|
165
162
|
}
|
|
166
163
|
default: {
|
|
164
|
+
resp = {};
|
|
167
165
|
break;
|
|
168
166
|
}
|
|
169
167
|
}
|
|
@@ -181,84 +179,83 @@ function ExternalWalletProvider({
|
|
|
181
179
|
const verifyWalletSignature = useCallback(() => __async(this, null, function* () {
|
|
182
180
|
var _a;
|
|
183
181
|
setExternalWalletError();
|
|
182
|
+
setIsExternalWalletVerifying(true);
|
|
184
183
|
const walletType = (_a = Object.values(para.externalWallets)[0]) == null ? void 0 : _a.type;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
cosmosSigner: ""
|
|
191
|
-
};
|
|
192
|
-
switch (walletType) {
|
|
193
|
-
case WalletType.COSMOS: {
|
|
194
|
-
const { signature, error, cosmosPublicKeyHex, cosmosSigner, address } = yield cosmosSignVerificationMessage();
|
|
184
|
+
let verifyExternalWalletParams;
|
|
185
|
+
switch (walletType) {
|
|
186
|
+
case "COSMOS":
|
|
187
|
+
{
|
|
188
|
+
const { address, signature, error, cosmosPublicKeyHex, cosmosSigner } = yield cosmosSignVerificationMessage();
|
|
195
189
|
if (error) {
|
|
196
190
|
setExternalWalletError([error]);
|
|
197
|
-
} else if (signature) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
} else if (signature && address) {
|
|
192
|
+
verifyExternalWalletParams = {
|
|
193
|
+
externalWallet: {
|
|
194
|
+
type: "COSMOS",
|
|
195
|
+
address
|
|
196
|
+
},
|
|
197
|
+
signedMessage: signature,
|
|
198
|
+
cosmosPublicKeyHex,
|
|
199
|
+
cosmosSigner
|
|
200
|
+
};
|
|
202
201
|
}
|
|
203
|
-
return resp;
|
|
204
202
|
}
|
|
205
|
-
|
|
203
|
+
break;
|
|
204
|
+
case "EVM":
|
|
205
|
+
{
|
|
206
206
|
const { signature, error, address } = yield evmSignVerificationMessage();
|
|
207
207
|
if (error) {
|
|
208
208
|
setExternalWalletError([error]);
|
|
209
209
|
} else if (signature && address) {
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
verifyExternalWalletParams = {
|
|
211
|
+
externalWallet: {
|
|
212
|
+
type: "EVM",
|
|
213
|
+
address
|
|
214
|
+
},
|
|
215
|
+
signedMessage: signature
|
|
216
|
+
};
|
|
212
217
|
}
|
|
213
|
-
return resp;
|
|
214
218
|
}
|
|
215
|
-
|
|
219
|
+
break;
|
|
220
|
+
case "SOLANA":
|
|
221
|
+
{
|
|
216
222
|
const { signature, error, address } = yield solanaSignVerificationMessage();
|
|
217
223
|
if (error) {
|
|
218
224
|
setExternalWalletError([error]);
|
|
219
225
|
} else if (signature && address) {
|
|
220
|
-
|
|
221
|
-
|
|
226
|
+
verifyExternalWalletParams = {
|
|
227
|
+
externalWallet: {
|
|
228
|
+
type: "SOLANA",
|
|
229
|
+
address
|
|
230
|
+
},
|
|
231
|
+
signedMessage: signature
|
|
232
|
+
};
|
|
222
233
|
}
|
|
223
|
-
return resp;
|
|
224
234
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
235
|
+
break;
|
|
236
|
+
default:
|
|
237
|
+
break;
|
|
229
238
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
displayName: getExternalWalletDisplayName({
|
|
234
|
-
address,
|
|
235
|
-
type
|
|
236
|
-
}),
|
|
237
|
-
externalWalletAddress: bufferAddress != null ? bufferAddress : address
|
|
238
|
-
});
|
|
239
|
-
if (userExists && isVerified) {
|
|
240
|
-
const supportedAuthMethods = yield para.supportedAuthMethods({
|
|
241
|
-
externalWalletAddress: bufferAddress != null ? bufferAddress : address
|
|
242
|
-
});
|
|
243
|
-
if (!supportedAuthMethods.size) {
|
|
244
|
-
setFlow("signUp");
|
|
245
|
-
setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
|
|
239
|
+
if (verifyExternalWalletParams) {
|
|
240
|
+
if (!(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.externalWallet) || !(verifyExternalWalletParams == null ? void 0 : verifyExternalWalletParams.signedMessage)) {
|
|
241
|
+
console.error("No signature or address found on the verifyWalletSignature response.");
|
|
246
242
|
return;
|
|
247
243
|
}
|
|
248
|
-
|
|
249
|
-
|
|
244
|
+
verifyExternalWallet(verifyExternalWalletParams, {
|
|
245
|
+
onSuccess: onNewAuthState,
|
|
246
|
+
onError: (e) => {
|
|
247
|
+
console.error("Error verifying signature:", e);
|
|
248
|
+
setExternalWalletError(["Signature verification failed."]);
|
|
249
|
+
},
|
|
250
|
+
onSettled: () => {
|
|
251
|
+
setIsExternalWalletVerifying(false);
|
|
252
|
+
}
|
|
250
253
|
});
|
|
251
|
-
|
|
252
|
-
yield setLoginURLs({ supportedAuthMethods, authType: "externalWallet" });
|
|
253
|
-
setFlow("login");
|
|
254
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
255
|
-
setSupportedAuthMethods(supportedAuthMethods);
|
|
256
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
257
|
-
} else {
|
|
258
|
-
setFlow("signUp");
|
|
259
|
-
setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
|
|
254
|
+
return verifyExternalWalletParams;
|
|
260
255
|
}
|
|
261
|
-
|
|
256
|
+
setIsExternalWalletVerifying(false);
|
|
257
|
+
return void 0;
|
|
258
|
+
}), [cosmosSignVerificationMessage, evmSignVerificationMessage, solanaSignVerificationMessage]);
|
|
262
259
|
const connectExternalWallet = useCallback(
|
|
263
260
|
(wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
|
|
264
261
|
if (isExternalWalletConnecting && isManualWalletConnect) {
|
|
@@ -272,7 +269,7 @@ function ExternalWalletProvider({
|
|
|
272
269
|
setExternalWalletError();
|
|
273
270
|
setIsExternalWalletConnecting(true);
|
|
274
271
|
setIsUsingMobileConnector(isMobileConnect);
|
|
275
|
-
const { address,
|
|
272
|
+
const { address, error, authState } = yield isMobileConnect ? wallet2.connectMobile(isManualWalletConnect) : wallet2.connect();
|
|
276
273
|
if (error) {
|
|
277
274
|
setExternalWalletError([error]);
|
|
278
275
|
setIsUsingMobileConnector();
|
|
@@ -283,8 +280,8 @@ function ExternalWalletProvider({
|
|
|
283
280
|
return;
|
|
284
281
|
}
|
|
285
282
|
} else if (address) {
|
|
286
|
-
if (
|
|
287
|
-
|
|
283
|
+
if (!!authState && (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase()))) {
|
|
284
|
+
onNewAuthState(authState);
|
|
288
285
|
} else {
|
|
289
286
|
setStep(ModalStep.LOGIN_DONE);
|
|
290
287
|
}
|
|
@@ -304,11 +301,11 @@ function ExternalWalletProvider({
|
|
|
304
301
|
const walletDisplayHelpers = {
|
|
305
302
|
// Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
|
|
306
303
|
// Also show the extension connection if on desktop for a solana wallet (no walletConnect)
|
|
307
|
-
showExtension: !isMobile() && ((wallet == null ? void 0 : wallet.isExtension) && (wallet == null ? void 0 : wallet.installed) || !(wallet == null ? void 0 : wallet.isMobile) || (wallet == null ? void 0 : wallet.type) ===
|
|
304
|
+
showExtension: !isMobile() && ((wallet == null ? void 0 : wallet.isExtension) && (wallet == null ? void 0 : wallet.installed) || !(wallet == null ? void 0 : wallet.isMobile) || (wallet == null ? void 0 : wallet.type) === "SOLANA"),
|
|
308
305
|
// Show the mobile screen if on mobile and the wallet is a mobile wallet or if on desktop and the wallet isn't installed
|
|
309
306
|
showMobile: isMobile() && (wallet == null ? void 0 : wallet.isMobile) || !isMobile() && !(wallet == null ? void 0 : wallet.installed),
|
|
310
|
-
isSolanaMobileIOS: isIOS() && isMobile() && !isIOSWebview() && (wallet == null ? void 0 : wallet.type) ===
|
|
311
|
-
isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) ===
|
|
307
|
+
isSolanaMobileIOS: isIOS() && isMobile() && !isIOSWebview() && (wallet == null ? void 0 : wallet.type) === "SOLANA",
|
|
308
|
+
isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) === "COSMOS" && !!isUsingMobileConnector
|
|
312
309
|
};
|
|
313
310
|
const username = useMemo(() => {
|
|
314
311
|
let username2;
|
|
@@ -316,12 +313,12 @@ function ExternalWalletProvider({
|
|
|
316
313
|
if (storedExternalWallet) {
|
|
317
314
|
const walletType = storedExternalWallet == null ? void 0 : storedExternalWallet.type;
|
|
318
315
|
switch (walletType) {
|
|
319
|
-
case
|
|
316
|
+
case "EVM": {
|
|
320
317
|
username2 = evmUsername ? evmUsername.startsWith("0x") ? truncateAddress(evmUsername, "EVM") : evmUsername : void 0;
|
|
321
318
|
break;
|
|
322
319
|
}
|
|
323
320
|
default: {
|
|
324
|
-
username2 = storedExternalWallet.address ? truncateAddress(storedExternalWallet.address, storedExternalWallet.type) : void 0;
|
|
321
|
+
username2 = storedExternalWallet.address && storedExternalWallet.type ? truncateAddress(storedExternalWallet.address, storedExternalWallet.type) : void 0;
|
|
325
322
|
break;
|
|
326
323
|
}
|
|
327
324
|
}
|
|
@@ -333,7 +330,7 @@ function ExternalWalletProvider({
|
|
|
333
330
|
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
334
331
|
if (walletType) {
|
|
335
332
|
switch (walletType) {
|
|
336
|
-
case
|
|
333
|
+
case "EVM": {
|
|
337
334
|
return evmAvatar;
|
|
338
335
|
}
|
|
339
336
|
default: {
|
|
@@ -342,6 +339,39 @@ function ExternalWalletProvider({
|
|
|
342
339
|
}
|
|
343
340
|
}
|
|
344
341
|
}, [evmAvatar, wallet]);
|
|
342
|
+
const connectEmbeddedToExternalConnectors = useCallback(() => __async(this, null, function* () {
|
|
343
|
+
try {
|
|
344
|
+
const { error } = yield evmConnectParaEmbedded();
|
|
345
|
+
if (error) {
|
|
346
|
+
console.warn("Failed to connect Para EVM wallet to Wagmi:", error);
|
|
347
|
+
} else {
|
|
348
|
+
const wallet2 = para.findWallet(void 0, void 0, { type: ["EVM"] });
|
|
349
|
+
if (wallet2) {
|
|
350
|
+
setSelectedWallet({ id: wallet2.id, type: "EVM" });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} catch (err) {
|
|
354
|
+
console.warn("Error calling connectParaEvmWallet:", err);
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
const { error } = yield cosmosConnectParaEmbedded();
|
|
358
|
+
if (error) {
|
|
359
|
+
console.warn("Failed to connect Para Cosmos wallet to Graz:", error);
|
|
360
|
+
} else {
|
|
361
|
+
const wallet2 = para.findWallet(void 0, void 0, { type: ["COSMOS"] });
|
|
362
|
+
if (wallet2) {
|
|
363
|
+
setSelectedWallet({ id: wallet2.id, type: "COSMOS" });
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} catch (err) {
|
|
367
|
+
console.warn("Error calling connectParaCosmosWallet:", err);
|
|
368
|
+
}
|
|
369
|
+
}), [evmConnectParaEmbedded, cosmosConnectParaEmbedded]);
|
|
370
|
+
useEffect(() => {
|
|
371
|
+
onLoginRef.current = () => __async(this, null, function* () {
|
|
372
|
+
yield connectEmbeddedToExternalConnectors();
|
|
373
|
+
});
|
|
374
|
+
}, [connectEmbeddedToExternalConnectors]);
|
|
345
375
|
return /* @__PURE__ */ jsx(
|
|
346
376
|
ExternalWalletContext.Provider,
|
|
347
377
|
{
|
|
@@ -356,12 +386,14 @@ function ExternalWalletProvider({
|
|
|
356
386
|
chainIdSwitchingTo,
|
|
357
387
|
username,
|
|
358
388
|
avatar,
|
|
359
|
-
balance,
|
|
360
389
|
connectExternalWallet,
|
|
361
390
|
disconnectExternalWallet,
|
|
362
391
|
switchChain,
|
|
363
392
|
setChainIdSwitchingTo,
|
|
364
|
-
|
|
393
|
+
connectEmbeddedToExternalConnectors,
|
|
394
|
+
verifyWalletSignature,
|
|
395
|
+
isExternalWalletVerifying,
|
|
396
|
+
getWalletBalance
|
|
365
397
|
}),
|
|
366
398
|
[
|
|
367
399
|
wallets,
|
|
@@ -373,12 +405,14 @@ function ExternalWalletProvider({
|
|
|
373
405
|
chainIdSwitchingTo,
|
|
374
406
|
username,
|
|
375
407
|
avatar,
|
|
376
|
-
balance,
|
|
377
408
|
disconnectExternalWallet,
|
|
378
409
|
connectExternalWallet,
|
|
379
410
|
switchChain,
|
|
380
411
|
setChainIdSwitchingTo,
|
|
381
|
-
|
|
412
|
+
connectEmbeddedToExternalConnectors,
|
|
413
|
+
verifyWalletSignature,
|
|
414
|
+
isExternalWalletVerifying,
|
|
415
|
+
getWalletBalance
|
|
382
416
|
]
|
|
383
417
|
),
|
|
384
418
|
children
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { ParaSolanaProviderProps } from '@getpara/solana-wallet-connectors';
|
|
3
|
+
import { ExternalWalletProviderCommon, ParaSolanaProviderConfigNoWallets } from '../types/externalWalletProviders.js';
|
|
4
|
+
export declare function SolanaExternalWalletProvider({ children, isUsing, wallets: walletsFromProps, ...rest }: Omit<ParaSolanaProviderProps, 'config'> & {
|
|
5
|
+
config: ParaSolanaProviderConfigNoWallets;
|
|
6
|
+
} & PropsWithChildren & ExternalWalletProviderCommon): string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
7
|
+
export declare const MemoizedSolanaExternalWalletProvider: import("react").MemoExoticComponent<typeof SolanaExternalWalletProvider>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__objRest,
|
|
5
|
+
__spreadProps,
|
|
6
|
+
__spreadValues
|
|
7
|
+
} from "../../chunk-MMUBH76A.js";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { memo, useEffect, useMemo } from "react";
|
|
10
|
+
import { useStore } from "../stores/useStore.js";
|
|
11
|
+
import { getParaSolanaConnector } from "../external/getParaSolanaConnector.js";
|
|
12
|
+
function SolanaExternalWalletProvider(_a) {
|
|
13
|
+
var _b = _a, {
|
|
14
|
+
children,
|
|
15
|
+
isUsing,
|
|
16
|
+
wallets: walletsFromProps
|
|
17
|
+
} = _b, rest = __objRest(_b, [
|
|
18
|
+
"children",
|
|
19
|
+
"isUsing",
|
|
20
|
+
"wallets"
|
|
21
|
+
]);
|
|
22
|
+
const setSolanaContext = useStore((state) => state.setSolanaContext);
|
|
23
|
+
const setSolanaProvider = useStore((state) => state.setSolanaProvider);
|
|
24
|
+
const SolanaProvider = useStore((state) => state.SolanaProvider);
|
|
25
|
+
const setSolanaWallets = useStore((state) => state.setSolanaWallets);
|
|
26
|
+
const solanaWallets = useStore((state) => state.solanaWallets);
|
|
27
|
+
const isLoadingLib = useStore((state) => state.isLoadingSolanaLib);
|
|
28
|
+
const setIsLoadingLib = useStore((state) => state.setIsLoadingSolanaLib);
|
|
29
|
+
const filteredWallets = useMemo(
|
|
30
|
+
() => solanaWallets.filter((w) => walletsFromProps.includes(w().id.toUpperCase())),
|
|
31
|
+
[solanaWallets, walletsFromProps]
|
|
32
|
+
);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const loadLib = () => __async(this, null, function* () {
|
|
35
|
+
if (SolanaProvider) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const { Provider, context, wallets } = yield getParaSolanaConnector();
|
|
39
|
+
if (Provider) {
|
|
40
|
+
setSolanaProvider(Provider);
|
|
41
|
+
}
|
|
42
|
+
if (wallets) {
|
|
43
|
+
setSolanaWallets(wallets);
|
|
44
|
+
}
|
|
45
|
+
if (context) {
|
|
46
|
+
setSolanaContext(context);
|
|
47
|
+
}
|
|
48
|
+
setIsLoadingLib(false);
|
|
49
|
+
});
|
|
50
|
+
loadLib();
|
|
51
|
+
}, []);
|
|
52
|
+
if (isLoadingLib) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (SolanaProvider) {
|
|
56
|
+
return /* @__PURE__ */ jsx(SolanaProvider, __spreadProps(__spreadValues({}, rest), { config: __spreadProps(__spreadValues({}, rest == null ? void 0 : rest.config), { wallets: filteredWallets }), children }));
|
|
57
|
+
} else if (isUsing) {
|
|
58
|
+
console.warn("@getpara/solana-wallet-connectors is required to use an external Solana wallet.");
|
|
59
|
+
}
|
|
60
|
+
return children;
|
|
61
|
+
}
|
|
62
|
+
const MemoizedSolanaExternalWalletProvider = memo(SolanaExternalWalletProvider);
|
|
63
|
+
export {
|
|
64
|
+
MemoizedSolanaExternalWalletProvider,
|
|
65
|
+
SolanaExternalWalletProvider
|
|
66
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const getClient: () => import("@getpara/web-sdk").ParaWeb;
|
|
1
|
+
export declare const getClient: () => import("@getpara/web-sdk").ParaWeb | undefined;
|
|
2
2
|
export declare const getIsOpen: () => boolean;
|
|
3
|
-
export declare const getSelectedWalletId: () => string;
|
|
4
|
-
export declare const getSelectedWalletType: () =>
|
|
3
|
+
export declare const getSelectedWalletId: () => string | undefined;
|
|
4
|
+
export declare const getSelectedWalletType: () => "EVM" | "SOLANA" | "COSMOS" | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setIsOpen: (isOpen: boolean) => void;
|