@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,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { EvmExternalWalletContext } from "../../external/stubs/EvmExternalWalletContextStub.js";
|
|
4
|
+
import { CosmosExternalWalletContext } from "../../external/stubs/CosmosExternalWalletContextStub.js";
|
|
5
|
+
import { SolanaExternalWalletContext } from "../../external/stubs/SolanaExternalWalletContextStub.js";
|
|
6
|
+
import { createRef } from "react";
|
|
7
|
+
const createExternalWalletsSlice = (set) => ({
|
|
8
|
+
externalWallets: [],
|
|
9
|
+
setExternalWallets: (externalWallets) => set({ externalWallets }),
|
|
10
|
+
externalWalletsWithFullAuth: [],
|
|
11
|
+
setExternalWalletsWithFullAuth: (externalWalletsWithFullAuth) => set({ externalWalletsWithFullAuth }),
|
|
12
|
+
evmContext: EvmExternalWalletContext,
|
|
13
|
+
setEvmContext: (evmContext) => set({ evmContext }),
|
|
14
|
+
EvmProvider: void 0,
|
|
15
|
+
setEvmProvider: (EvmProvider) => set({ EvmProvider }),
|
|
16
|
+
evmWallets: [],
|
|
17
|
+
setEvmWallets: (evmWallets) => set({ evmWallets }),
|
|
18
|
+
isLoadingEvmLib: true,
|
|
19
|
+
setIsLoadingEvmLib: (isLoadingEvmLib) => set({ isLoadingEvmLib }),
|
|
20
|
+
cosmosContext: CosmosExternalWalletContext,
|
|
21
|
+
setCosmosContext: (cosmosContext) => set({ cosmosContext }),
|
|
22
|
+
CosmosProvider: void 0,
|
|
23
|
+
setCosmosProvider: (CosmosProvider) => set({ CosmosProvider }),
|
|
24
|
+
cosmosWallets: [],
|
|
25
|
+
setCosmosWallets: (cosmosWallets) => set({ cosmosWallets }),
|
|
26
|
+
isLoadingCosmosLib: true,
|
|
27
|
+
setIsLoadingCosmosLib: (isLoadingCosmosLib) => set({ isLoadingCosmosLib }),
|
|
28
|
+
solanaContext: SolanaExternalWalletContext,
|
|
29
|
+
setSolanaContext: (solanaContext) => set({ solanaContext }),
|
|
30
|
+
SolanaProvider: void 0,
|
|
31
|
+
setSolanaProvider: (SolanaProvider) => set({ SolanaProvider }),
|
|
32
|
+
solanaWallets: [],
|
|
33
|
+
setSolanaWallets: (solanaWallets) => set({ solanaWallets }),
|
|
34
|
+
isLoadingSolanaLib: true,
|
|
35
|
+
setIsLoadingSolanaLib: (isLoadingSolanaLib) => set({ isLoadingSolanaLib }),
|
|
36
|
+
onLoginRef: createRef()
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
createExternalWalletsSlice
|
|
40
|
+
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
const createModalSlice = (set) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const createModalSlice = (set, get) => {
|
|
4
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5
|
+
return {
|
|
6
|
+
modalConfig: void 0,
|
|
7
|
+
setModalConfig: (modalConfig) => set({ modalConfig }),
|
|
8
|
+
isDarkTheme: ((_c = (_b = (_a = get()) == null ? void 0 : _a.modalConfig) == null ? void 0 : _b.theme) == null ? void 0 : _c.mode) === "dark",
|
|
9
|
+
oAuthLogoVariant: (_g = (_f = (_e = (_d = get()) == null ? void 0 : _d.modalConfig) == null ? void 0 : _e.theme) == null ? void 0 : _f.oAuthLogoVariant) != null ? _g : "default",
|
|
10
|
+
isOpen: false,
|
|
11
|
+
setIsOpen: (isOpen) => set({ isOpen })
|
|
12
|
+
};
|
|
13
|
+
};
|
|
7
14
|
export {
|
|
8
15
|
createModalSlice
|
|
9
16
|
};
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Context, MutableRefObject } from 'react';
|
|
2
|
+
import ParaWeb, { TWalletType } from '@getpara/web-sdk';
|
|
3
|
+
import { EvmExternalWalletContextType, ParaEvmProvider, WalletList as EvmWalletList } from '@getpara/evm-wallet-connectors';
|
|
4
|
+
import { CosmosExternalWalletContextType, ParaCosmosProvider, WalletList as CosmosWalletList } from '@getpara/cosmos-wallet-connectors';
|
|
5
|
+
import { ParaSolanaProvider, SolanaExternalWalletContextType, WalletList as SolanaWalletList } from '@getpara/solana-wallet-connectors';
|
|
6
|
+
import { ParaModalProps } from '../../modal/index.js';
|
|
7
|
+
import { OAuthLogoVariantType } from '../../modal/types/modalProps.js';
|
|
8
|
+
import { type TExternalWallet } from '@getpara/react-common';
|
|
2
9
|
export interface ClientSlice {
|
|
3
10
|
client?: ParaWeb;
|
|
4
11
|
setClient: (_: ParaWeb) => void;
|
|
5
12
|
}
|
|
13
|
+
export interface ConfigSlice {
|
|
14
|
+
appName: string;
|
|
15
|
+
setAppName: (_: string) => void;
|
|
16
|
+
}
|
|
6
17
|
export interface ModalSlice {
|
|
18
|
+
modalConfig?: ParaModalProps;
|
|
19
|
+
setModalConfig: (_?: ParaModalProps) => void;
|
|
20
|
+
isDarkTheme: boolean;
|
|
21
|
+
oAuthLogoVariant: OAuthLogoVariantType;
|
|
7
22
|
isOpen: boolean;
|
|
8
23
|
setIsOpen: (_: boolean) => void;
|
|
9
24
|
}
|
|
@@ -11,8 +26,39 @@ export interface WalletSlice {
|
|
|
11
26
|
rpcUrl?: string;
|
|
12
27
|
setRpcUrl: (_?: string) => void;
|
|
13
28
|
selectedWalletId?: string;
|
|
14
|
-
selectedWalletType?:
|
|
15
|
-
setSelectedWallet: (_?: string, __?:
|
|
29
|
+
selectedWalletType?: TWalletType;
|
|
30
|
+
setSelectedWallet: (_?: string, __?: TWalletType) => void;
|
|
16
31
|
clearSelectedWallet: () => void;
|
|
17
32
|
}
|
|
18
|
-
export
|
|
33
|
+
export interface ExternalWalletsSlice {
|
|
34
|
+
externalWallets: TExternalWallet[];
|
|
35
|
+
setExternalWallets: (_: TExternalWallet[]) => void;
|
|
36
|
+
externalWalletsWithFullAuth: TExternalWallet[];
|
|
37
|
+
setExternalWalletsWithFullAuth: (_: TExternalWallet[]) => void;
|
|
38
|
+
evmContext: Context<EvmExternalWalletContextType>;
|
|
39
|
+
setEvmContext: (_: Context<EvmExternalWalletContextType>) => void;
|
|
40
|
+
EvmProvider?: typeof ParaEvmProvider;
|
|
41
|
+
setEvmProvider: (_: typeof ParaEvmProvider) => void;
|
|
42
|
+
evmWallets: EvmWalletList;
|
|
43
|
+
setEvmWallets: (_: EvmWalletList) => void;
|
|
44
|
+
isLoadingEvmLib: boolean;
|
|
45
|
+
setIsLoadingEvmLib: (_: boolean) => void;
|
|
46
|
+
cosmosContext: Context<CosmosExternalWalletContextType>;
|
|
47
|
+
setCosmosContext: (_: Context<CosmosExternalWalletContextType>) => void;
|
|
48
|
+
CosmosProvider?: typeof ParaCosmosProvider;
|
|
49
|
+
setCosmosProvider: (_: typeof ParaCosmosProvider) => void;
|
|
50
|
+
cosmosWallets: CosmosWalletList;
|
|
51
|
+
setCosmosWallets: (_: CosmosWalletList) => void;
|
|
52
|
+
isLoadingCosmosLib: boolean;
|
|
53
|
+
setIsLoadingCosmosLib: (_: boolean) => void;
|
|
54
|
+
solanaContext: Context<SolanaExternalWalletContextType>;
|
|
55
|
+
setSolanaContext: (_: Context<SolanaExternalWalletContextType>) => void;
|
|
56
|
+
SolanaProvider?: typeof ParaSolanaProvider;
|
|
57
|
+
setSolanaProvider: (_: typeof ParaSolanaProvider) => void;
|
|
58
|
+
solanaWallets: SolanaWalletList;
|
|
59
|
+
setSolanaWallets: (_: SolanaWalletList) => void;
|
|
60
|
+
isLoadingSolanaLib: boolean;
|
|
61
|
+
setIsLoadingSolanaLib: (_: boolean) => void;
|
|
62
|
+
onLoginRef: MutableRefObject<(() => Promise<void>) | null>;
|
|
63
|
+
}
|
|
64
|
+
export type Store = ClientSlice & ModalSlice & WalletSlice & ExternalWalletsSlice & ConfigSlice;
|
|
@@ -3,14 +3,15 @@ import {
|
|
|
3
3
|
__spreadValues
|
|
4
4
|
} from "../../chunk-MMUBH76A.js";
|
|
5
5
|
import { createStore, useStore as useZustandStore } from "zustand";
|
|
6
|
-
import { createClientSlice, createModalSlice, createWalletSlice } from "./slices/index.js";
|
|
6
|
+
import { createClientSlice, createExternalWalletsSlice, createModalSlice, createWalletSlice } from "./slices/index.js";
|
|
7
7
|
import { createJSONStorage, persist } from "zustand/middleware";
|
|
8
|
+
import { createConfigSlice } from "./slices/config.js";
|
|
8
9
|
const vanillaStore = createStore()(
|
|
9
10
|
persist(
|
|
10
|
-
(...a) => __spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)),
|
|
11
|
+
(...a) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)), createExternalWalletsSlice(...a)), createConfigSlice(...a)),
|
|
11
12
|
{
|
|
12
13
|
version: 1,
|
|
13
|
-
name: "@PARA/
|
|
14
|
+
name: "@PARA/provider-state",
|
|
14
15
|
storage: createJSONStorage(() => localStorage),
|
|
15
16
|
partialize: (state) => ({
|
|
16
17
|
selectedWalletId: state.selectedWalletId,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ParaCosmosProviderConfig } from '@getpara/cosmos-wallet-connectors';
|
|
2
|
+
import { ParaSolanaProviderConfig } from '@getpara/solana-wallet-connectors';
|
|
3
|
+
import { Chain, Transport } from 'viem';
|
|
4
|
+
import { type ParaEvmProviderConfig } from '@getpara/evm-wallet-connectors';
|
|
5
|
+
import { type TExternalWallet } from '@getpara/react-common';
|
|
6
|
+
export type ExternalWalletProviderCommon = {
|
|
7
|
+
isUsing: boolean;
|
|
8
|
+
wallets: TExternalWallet[];
|
|
9
|
+
};
|
|
10
|
+
export type ParaEvmProviderConfigNoWallets<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> = Omit<ParaEvmProviderConfig<chains, transports>, 'wallets'>;
|
|
11
|
+
export type ParaCosmosProviderConfigNoWallets = Omit<ParaCosmosProviderConfig, 'wallets'>;
|
|
12
|
+
export type ParaSolanaProviderConfigNoWallets = Omit<ParaSolanaProviderConfig, 'wallets'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ParaWagmiProviderProps } from '@getpara/evm-wallet-connectors';
|
|
2
|
+
import ParaWeb, { AccountCreationEvent, AccountSetupEvent, ConstructorOpts, Environment, ExternalWalletChangeEvent, LoginEvent, LogoutEvent, PregenWalletClaimedEvent, SignMessageEvent, SignTransactionEvent, WalletCreatedEvent, WalletsChangeEvent, GuestWalletsCreatedEvent } from '@getpara/web-sdk';
|
|
2
3
|
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { Chain, Transport } from 'viem';
|
|
5
|
+
import { ParaModalProps } from '../../modal/index.js';
|
|
6
|
+
import { ParaGrazProviderProps } from '@getpara/cosmos-wallet-connectors';
|
|
7
|
+
import { ParaCosmosProviderConfigNoWallets, ParaEvmProviderConfigNoWallets, ParaSolanaProviderConfigNoWallets } from './externalWalletProviders.js';
|
|
8
|
+
import { type TExternalWallet } from '@getpara/react-common';
|
|
3
9
|
export type Callbacks = {
|
|
4
10
|
onLogout?: (event: LogoutEvent) => void;
|
|
5
11
|
onLogin?: (event: LoginEvent) => void;
|
|
@@ -11,28 +17,131 @@ export type Callbacks = {
|
|
|
11
17
|
onWalletsChange?: (event: WalletsChangeEvent) => void;
|
|
12
18
|
onWalletCreated?: (event: WalletCreatedEvent) => void;
|
|
13
19
|
onPregenWalletClaimed?: (event: PregenWalletClaimedEvent) => void;
|
|
20
|
+
onGuestWalletsCreated?: (event: GuestWalletsCreatedEvent) => void;
|
|
14
21
|
};
|
|
15
22
|
export type ParaProviderConfig = {
|
|
23
|
+
/**
|
|
24
|
+
* The name of your app, used throughout the modal and any configured external wallets.
|
|
25
|
+
*/
|
|
26
|
+
appName: string;
|
|
27
|
+
/**
|
|
28
|
+
* Disables the automatic session keep alive that's provided by ParaProvider.
|
|
29
|
+
*/
|
|
16
30
|
disableAutoSessionKeepAlive?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Disables the ParaModal that's provided by ParaProvider. Use this is you're providing a separate modal in another location in your app.
|
|
33
|
+
*/
|
|
34
|
+
disableEmbeddedModal?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* RPC url to use for retrieving the embedded wallet balance
|
|
37
|
+
*/
|
|
38
|
+
rpcUrl?: string;
|
|
17
39
|
};
|
|
18
|
-
|
|
19
|
-
|
|
40
|
+
export type ExternalWalletConfig<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> = {
|
|
41
|
+
/**
|
|
42
|
+
* A description of your app, displayed in some external wallets.
|
|
43
|
+
*/
|
|
44
|
+
appDescription?: string;
|
|
45
|
+
/**
|
|
46
|
+
* A URL for your app, displayed in some external wallets.
|
|
47
|
+
*/
|
|
48
|
+
appUrl?: string;
|
|
49
|
+
/**
|
|
50
|
+
* An icon for your app, displayed in some external wallets.
|
|
51
|
+
*/
|
|
52
|
+
appIcon?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Config for the EVM external wallets connector using Wagmi.
|
|
55
|
+
*
|
|
56
|
+
* NOTE: In addition to this config, you MUST also have the `@getpara/evm-wallet-connectors` package installed.
|
|
57
|
+
*/
|
|
58
|
+
evmConnector?: {
|
|
59
|
+
/**
|
|
60
|
+
* Config for the Para EVM external wallets connector.
|
|
61
|
+
*/
|
|
62
|
+
config: Omit<ParaEvmProviderConfigNoWallets<chains, transports>, 'appName' | 'appDescription' | 'appUrl' | 'appIcon' | 'projectId'>;
|
|
63
|
+
/**
|
|
64
|
+
* Config for the Wagmi provider.
|
|
65
|
+
*/
|
|
66
|
+
wagmiProviderProps?: ParaWagmiProviderProps;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Config for the Cosmos external wallets connector using Graz.
|
|
70
|
+
*
|
|
71
|
+
* NOTE: In addition to this config, you MUST also have the `@getpara/cosmos-wallet-connectors` package installed.
|
|
72
|
+
*/
|
|
73
|
+
cosmosConnector?: {
|
|
74
|
+
/**
|
|
75
|
+
* Config for the Para Cosmos external wallets connector.
|
|
76
|
+
*/
|
|
77
|
+
config: ParaCosmosProviderConfigNoWallets;
|
|
78
|
+
/**
|
|
79
|
+
* Config for the Graz provider.
|
|
80
|
+
*/
|
|
81
|
+
grazProviderProps?: ParaGrazProviderProps;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Config for the Solana external wallets connector using @solana/wallet-adapter-react.
|
|
85
|
+
*
|
|
86
|
+
* NOTE: In addition to this config, you MUST also have the `@getpara/solana-wallet-connectors` package installed.
|
|
87
|
+
*/
|
|
88
|
+
solanaConnector?: {
|
|
89
|
+
/**
|
|
90
|
+
* Config for the Para Solana external wallets connector.
|
|
91
|
+
*/
|
|
92
|
+
config: Omit<ParaSolanaProviderConfigNoWallets, 'appIdentity'> & Pick<Partial<ParaSolanaProviderConfigNoWallets>, 'appIdentity'>;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Config for any connectors that use Wallet Connect.
|
|
96
|
+
*/
|
|
97
|
+
walletConnect?: {
|
|
98
|
+
/**
|
|
99
|
+
* Your Wallet Connect project ID.
|
|
100
|
+
*/
|
|
101
|
+
projectId: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Which external wallets to show and in what order they should be displayed.
|
|
105
|
+
*
|
|
106
|
+
* NOTE: Any wallets that are detected as installed will be sorted first, followed by those that are not detected or not installed.
|
|
107
|
+
*/
|
|
108
|
+
wallets?: TExternalWallet[];
|
|
109
|
+
/**
|
|
110
|
+
* Which external wallets will include full verification and Para auth.
|
|
111
|
+
*/
|
|
112
|
+
walletsWithParaAuth?: TExternalWallet[];
|
|
113
|
+
};
|
|
114
|
+
export interface ParaProviderProps<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> extends PropsWithChildren {
|
|
115
|
+
/**
|
|
116
|
+
* Arguments to setup a new Para instance, or a Para instance you have already instantiated.
|
|
117
|
+
*/
|
|
118
|
+
paraClientConfig: {
|
|
119
|
+
/**
|
|
120
|
+
* Environment for your Para instance.
|
|
121
|
+
*/
|
|
20
122
|
env: Environment;
|
|
123
|
+
/**
|
|
124
|
+
* API key for you Para instance.
|
|
125
|
+
*
|
|
126
|
+
* NOTE: Be sure this key matches the environment.
|
|
127
|
+
*/
|
|
21
128
|
apiKey: string;
|
|
22
129
|
opts?: ConstructorOpts;
|
|
23
|
-
};
|
|
130
|
+
} | ParaWeb;
|
|
131
|
+
/**
|
|
132
|
+
* Configuration used for the Para modal.
|
|
133
|
+
*/
|
|
134
|
+
paraModalConfig?: ParaModalProps;
|
|
135
|
+
/**
|
|
136
|
+
* Callbacks fired for events from the Para instance.
|
|
137
|
+
*/
|
|
24
138
|
callbacks?: Callbacks;
|
|
25
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Config for the ParaProvider.
|
|
141
|
+
*/
|
|
142
|
+
config: ParaProviderConfig;
|
|
143
|
+
/**
|
|
144
|
+
* Config for any external wallets.
|
|
145
|
+
*/
|
|
146
|
+
externalWalletConfig?: ExternalWalletConfig<chains, transports>;
|
|
26
147
|
}
|
|
27
|
-
export type ParaProviderProps = ({
|
|
28
|
-
config: ParaProviderConfig & {
|
|
29
|
-
paraClientOverride: ParaWeb;
|
|
30
|
-
};
|
|
31
|
-
paraClientConfig?: never;
|
|
32
|
-
} & ParaProviderPropsBase) | ({
|
|
33
|
-
config?: ParaProviderConfig & {
|
|
34
|
-
paraClientOverride?: never;
|
|
35
|
-
};
|
|
36
|
-
paraClientConfig: ParaProviderPropsBase['paraClientConfig'];
|
|
37
|
-
} & ParaProviderPropsBase);
|
|
38
|
-
export {};
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
import { CoreMethodName, CoreMethodParams, CoreMethodResponse, CoreMethods } from '@getpara/web-sdk';
|
|
2
|
+
import { UseMutationReturnType } from './query.js';
|
|
3
|
+
import { UseMutateFunction, UseMutateAsyncFunction, MutationState, Mutation } from '@tanstack/react-query';
|
|
1
4
|
export type Compute<type> = {
|
|
2
5
|
[key in keyof type]: type[key];
|
|
3
6
|
} & unknown;
|
|
4
7
|
/** Strict version of built-in Omit type */
|
|
5
8
|
export type StrictOmit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
|
|
6
9
|
export type UnionStrictOmit<type, keys extends keyof type> = type extends any ? StrictOmit<type, keys> : never;
|
|
10
|
+
export type ChangeFields<T, R> = Omit<T, keyof R> & R;
|
|
11
|
+
type SyncHook<method extends CoreMethodName & keyof CoreMethods> = {
|
|
12
|
+
mutate: UseMutateFunction<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
13
|
+
} & {
|
|
14
|
+
[K in method]: UseMutateFunction<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
15
|
+
};
|
|
16
|
+
type AsyncHook<method extends CoreMethodName & keyof CoreMethods> = {
|
|
17
|
+
mutateAsync: UseMutateAsyncFunction<CoreMethodResponse<method>, Error, CoreMethodParams<method> | void, unknown>;
|
|
18
|
+
} & {
|
|
19
|
+
[K in `${method}Async`]: UseMutateAsyncFunction<CoreMethodResponse<method>, Error, CoreMethodParams<method> | void, unknown>;
|
|
20
|
+
};
|
|
21
|
+
export type CoreMethodUseMutationReturnType<method extends CoreMethodName & keyof CoreMethods> = UseMutationReturnType<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
22
|
+
export type CoreMethodMutation<method extends CoreMethodName & keyof CoreMethods> = Mutation<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
23
|
+
export type CoreMethodMutationState<method extends CoreMethodName & keyof CoreMethods> = MutationState<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
24
|
+
export type CoreMethodHook<method extends CoreMethodName & keyof CoreMethods> = Compute<CoreMethodUseMutationReturnType<method> & SyncHook<method> & AsyncHook<method>>;
|
|
25
|
+
export type CoreMethodStateHook<method extends CoreMethodName & keyof CoreMethods> = () => Omit<CoreMethodUseMutationReturnType<method>, 'reset'>;
|
|
26
|
+
export {};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../chunk-MMUBH76A.js";
|
|
3
|
-
import { WalletType } from "@getpara/web-sdk";
|
|
4
3
|
const EXTERNAL_WALLET_PACKAGE_BY_TYPE = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
EVM: "Wagmi",
|
|
5
|
+
COSMOS: "Graz",
|
|
6
|
+
SOLANA: "@solana/wallet-adapter-react"
|
|
8
7
|
};
|
|
9
8
|
export {
|
|
10
9
|
EXTERNAL_WALLET_PACKAGE_BY_TYPE
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import ParaWeb from "@getpara/web-sdk";
|
|
4
|
+
function isConfigType(obj) {
|
|
5
|
+
return !!obj && typeof obj === "object" && "env" in obj && "apiKey" in obj;
|
|
6
|
+
}
|
|
7
|
+
function isParaWeb(obj) {
|
|
8
|
+
return obj instanceof ParaWeb;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
isConfigType,
|
|
12
|
+
isParaWeb
|
|
13
|
+
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { CoreMethodName, CoreMethodParams, CoreMethodResponse, CoreMethods } from '@getpara/web-sdk';
|
|
1
2
|
import { DefaultError, UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { CoreMethodHook } from '../types/utils.js';
|
|
2
4
|
export declare function renameMutations<TResp = unknown, TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(mutationObj: UseMutationResult<TData, TError, TVariables, TContext>, name: string): TResp;
|
|
5
|
+
export declare function renameCoreMutations<method extends CoreMethodName & keyof CoreMethods>(mutationObj: UseMutationResult<CoreMethodResponse<method>, Error, CoreMethodParams<method> | undefined, unknown>, name: method): CoreMethodHook<method>;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
__objRest,
|
|
4
3
|
__spreadValues
|
|
5
4
|
} from "../../chunk-MMUBH76A.js";
|
|
6
5
|
function renameMutations(mutationObj, name) {
|
|
7
|
-
const _a = mutationObj, { mutate: _, mutateAsync: __ } = _a, mutationNoMutate = __objRest(_a, ["mutate", "mutateAsync"]);
|
|
8
6
|
const newMutations = {
|
|
9
7
|
[name]: mutationObj.mutate,
|
|
10
8
|
[`${name}Async`]: mutationObj.mutateAsync
|
|
11
9
|
};
|
|
12
|
-
return __spreadValues(__spreadValues({}, newMutations),
|
|
10
|
+
return __spreadValues(__spreadValues({}, newMutations), mutationObj);
|
|
11
|
+
}
|
|
12
|
+
function renameCoreMutations(mutationObj, name) {
|
|
13
|
+
return renameMutations(mutationObj, name);
|
|
13
14
|
}
|
|
14
15
|
export {
|
|
16
|
+
renameCoreMutations,
|
|
15
17
|
renameMutations
|
|
16
18
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"setup-para": "dist/cli/cli.mjs"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": "./dist/index.js",
|
|
9
12
|
"./styles.css": "./dist/css/modal.css"
|
|
@@ -12,10 +15,9 @@
|
|
|
12
15
|
"*.css"
|
|
13
16
|
],
|
|
14
17
|
"dependencies": {
|
|
15
|
-
"@getpara/react-common": "
|
|
16
|
-
"@getpara/react-components": "
|
|
17
|
-
"@getpara/web-sdk": "
|
|
18
|
-
"@tanstack/react-query": "^5.0.0",
|
|
18
|
+
"@getpara/react-common": "2.0.0-alpha.10",
|
|
19
|
+
"@getpara/react-components": "2.0.0-alpha.10",
|
|
20
|
+
"@getpara/web-sdk": "2.0.0-alpha.10",
|
|
19
21
|
"date-fns": "^3.6.0",
|
|
20
22
|
"framer-motion": "11.3.28",
|
|
21
23
|
"libphonenumber-js": "^1.11.1",
|
|
@@ -27,9 +29,13 @@
|
|
|
27
29
|
"post-build": "./scripts/post-build.sh",
|
|
28
30
|
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
|
|
29
31
|
"typegen": "tsc --emitDeclarationOnly",
|
|
30
|
-
"test": "vitest run --coverage"
|
|
32
|
+
"test": "vitest run --coverage",
|
|
33
|
+
"cli": "node ./dist/cli/cli.mjs"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
36
|
+
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.10",
|
|
37
|
+
"@getpara/evm-wallet-connectors": "2.0.0-alpha.10",
|
|
38
|
+
"@getpara/solana-wallet-connectors": "2.0.0-alpha.10",
|
|
33
39
|
"@testing-library/dom": "^10.4.0",
|
|
34
40
|
"@testing-library/react": "^16.3.0",
|
|
35
41
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -37,9 +43,15 @@
|
|
|
37
43
|
"@types/chrome": "^0.0.237",
|
|
38
44
|
"@types/react": "^18.0.31",
|
|
39
45
|
"@types/react-dom": "^18.2.7",
|
|
40
|
-
"typescript": "^5.4.3"
|
|
46
|
+
"typescript": "^5.4.3",
|
|
47
|
+
"viem": "^2.24.2",
|
|
48
|
+
"wagmi": "^2.14.16"
|
|
41
49
|
},
|
|
42
50
|
"peerDependencies": {
|
|
51
|
+
"@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.10",
|
|
52
|
+
"@getpara/evm-wallet-connectors": "^2.0.0-alpha.10",
|
|
53
|
+
"@getpara/solana-wallet-connectors": "^2.0.0-alpha.10",
|
|
54
|
+
"@tanstack/react-query": ">=5.0.0",
|
|
43
55
|
"react": "*",
|
|
44
56
|
"react-dom": "*"
|
|
45
57
|
},
|
|
@@ -51,5 +63,5 @@
|
|
|
51
63
|
"resolutions": {
|
|
52
64
|
"styled-components": "^6"
|
|
53
65
|
},
|
|
54
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "92904c321f1dd8101046d8d2d70aa341bac99842"
|
|
55
67
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { TExternalWallet } from '../../types/externalWallets.js';
|
|
3
|
-
interface ExternalWalletsWrapperProps extends PropsWithChildren {
|
|
4
|
-
wallets?: TExternalWallet[];
|
|
5
|
-
externalWalletsWithFullAuth?: TExternalWallet[];
|
|
6
|
-
}
|
|
7
|
-
export declare const ExternalWalletsWrapper: ({ children, wallets, externalWalletsWithFullAuth }: ExternalWalletsWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { ExternalWalletProvider } from "../../providers/ExternalWalletContext.js";
|
|
8
|
-
import {
|
|
9
|
-
EvmExternalWalletContext,
|
|
10
|
-
EvmExternalWalletProvider
|
|
11
|
-
} from "../../providers/EvmExternalWalletContextStub.js";
|
|
12
|
-
import { CosmosWallet, EvmWallet, SolanaWallet } from "../../types/externalWallets.js";
|
|
13
|
-
import {
|
|
14
|
-
SolanaExternalWalletContext,
|
|
15
|
-
SolanaExternalWalletProvider
|
|
16
|
-
} from "../../providers/SolanaExternalWalletContextStub.js";
|
|
17
|
-
import {
|
|
18
|
-
CosmosExternalWalletContext,
|
|
19
|
-
CosmosExternalWalletProvider
|
|
20
|
-
} from "../../providers/CosmosExternalWalletContextStub.js";
|
|
21
|
-
import { useModalStore, useUserInfoStore } from "../../stores/index.js";
|
|
22
|
-
import { useExternalWalletProviderStore } from "../../stores/externalWalletProvider/useExternalWalletProviderStore.js";
|
|
23
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
24
|
-
const ExternalWalletsWrapper = ({ children, wallets, externalWalletsWithFullAuth }) => {
|
|
25
|
-
const para = useInternalClient();
|
|
26
|
-
const resetModalState = useModalStore((state) => state.resetState);
|
|
27
|
-
const resetUserInfoState = useUserInfoStore((state) => state.resetState);
|
|
28
|
-
const StoredEvmProvider = useExternalWalletProviderStore((state) => state.EvmProvider);
|
|
29
|
-
const storedEvmContext = useExternalWalletProviderStore((state) => state.evmContext);
|
|
30
|
-
const StoredSolanaProvider = useExternalWalletProviderStore((state) => state.SolanaProvider);
|
|
31
|
-
const storedSolanaContext = useExternalWalletProviderStore((state) => state.solanaContext);
|
|
32
|
-
const StoredCosmosProvider = useExternalWalletProviderStore((state) => state.CosmosProvider);
|
|
33
|
-
const storedCosmosContext = useExternalWalletProviderStore((state) => state.cosmosContext);
|
|
34
|
-
const [EvmProvider, setEvmProvider] = useState(null);
|
|
35
|
-
const [evmContext, setEvmContext] = useState(null);
|
|
36
|
-
const [SolanaProvider, setSolanaProvider] = useState(null);
|
|
37
|
-
const [solanaContext, setSolanaContext] = useState(null);
|
|
38
|
-
const [CosmosProvider, setCosmosProvider] = useState(null);
|
|
39
|
-
const [cosmosContext, setCosmosContext] = useState(null);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const loadProviders = () => __async(void 0, null, function* () {
|
|
42
|
-
let newEvmContext = EvmExternalWalletContext;
|
|
43
|
-
let newEvmProvider = EvmExternalWalletProvider;
|
|
44
|
-
let newSolanaContext = SolanaExternalWalletContext;
|
|
45
|
-
let newSolanaProvider = SolanaExternalWalletProvider;
|
|
46
|
-
let newCosmosContext = CosmosExternalWalletContext;
|
|
47
|
-
let newCosmosProvider = CosmosExternalWalletProvider;
|
|
48
|
-
if (!(wallets == null ? void 0 : wallets.length)) {
|
|
49
|
-
newEvmContext = EvmExternalWalletContext;
|
|
50
|
-
newEvmProvider = EvmExternalWalletProvider;
|
|
51
|
-
newSolanaContext = SolanaExternalWalletContext;
|
|
52
|
-
newSolanaProvider = SolanaExternalWalletProvider;
|
|
53
|
-
newCosmosContext = CosmosExternalWalletContext;
|
|
54
|
-
newCosmosProvider = CosmosExternalWalletProvider;
|
|
55
|
-
} else {
|
|
56
|
-
for (let i = 0; i < wallets.length; i++) {
|
|
57
|
-
const wallet = wallets[i];
|
|
58
|
-
if (wallet in EvmWallet) {
|
|
59
|
-
if (!StoredEvmProvider || !storedEvmContext) {
|
|
60
|
-
throw new Error("@getpara/evm-wallet-connectors is required to use an external EVM wallet.");
|
|
61
|
-
} else {
|
|
62
|
-
newEvmContext = storedEvmContext;
|
|
63
|
-
newEvmProvider = StoredEvmProvider;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (wallet in SolanaWallet) {
|
|
67
|
-
if (!StoredSolanaProvider || !storedSolanaContext) {
|
|
68
|
-
throw new Error("@getpara/solana-wallet-connectors is required to use an external Solana wallet.");
|
|
69
|
-
} else {
|
|
70
|
-
newSolanaContext = storedSolanaContext;
|
|
71
|
-
newSolanaProvider = StoredSolanaProvider;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (wallet in CosmosWallet) {
|
|
75
|
-
if (!StoredCosmosProvider || !storedCosmosContext) {
|
|
76
|
-
throw new Error("@getpara/cosmos-wallet-connectors is required to use an external Cosmos wallet.");
|
|
77
|
-
} else {
|
|
78
|
-
newCosmosContext = storedCosmosContext;
|
|
79
|
-
newCosmosProvider = StoredCosmosProvider;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
setEvmContext(newEvmContext);
|
|
85
|
-
setEvmProvider(() => newEvmProvider);
|
|
86
|
-
setSolanaContext(newSolanaContext);
|
|
87
|
-
setSolanaProvider(() => newSolanaProvider);
|
|
88
|
-
setCosmosContext(newCosmosContext);
|
|
89
|
-
setCosmosProvider(() => newCosmosProvider);
|
|
90
|
-
});
|
|
91
|
-
loadProviders();
|
|
92
|
-
}, [
|
|
93
|
-
wallets,
|
|
94
|
-
storedEvmContext,
|
|
95
|
-
StoredEvmProvider,
|
|
96
|
-
storedSolanaContext,
|
|
97
|
-
StoredSolanaProvider,
|
|
98
|
-
storedCosmosContext,
|
|
99
|
-
StoredCosmosProvider
|
|
100
|
-
]);
|
|
101
|
-
const handleSwitchWallet = ({ address, error }) => {
|
|
102
|
-
if (error || !address) {
|
|
103
|
-
resetModalState();
|
|
104
|
-
resetUserInfoState();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
if (!para || !EvmProvider || !SolanaProvider || !CosmosProvider) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
return /* @__PURE__ */ jsx(EvmProvider, { para, onSwitchWallet: handleSwitchWallet, children: /* @__PURE__ */ jsx(SolanaProvider, { para, onSwitchWallet: handleSwitchWallet, children: /* @__PURE__ */ jsx(CosmosProvider, { para, onSwitchWallet: handleSwitchWallet, children: /* @__PURE__ */ jsx(
|
|
111
|
-
ExternalWalletProvider,
|
|
112
|
-
{
|
|
113
|
-
evmContext,
|
|
114
|
-
solanaContext,
|
|
115
|
-
cosmosContext,
|
|
116
|
-
walletSort: wallets,
|
|
117
|
-
externalWalletsWithFullAuth,
|
|
118
|
-
children
|
|
119
|
-
}
|
|
120
|
-
) }) }) });
|
|
121
|
-
};
|
|
122
|
-
export {
|
|
123
|
-
ExternalWalletsWrapper
|
|
124
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useActiveWallet(): Omit<import("@getpara/core-sdk").Wallet, "signer">;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../chunk-MMUBH76A.js";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import { useWalletState } from "../../provider/index.js";
|
|
5
|
-
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
6
|
-
function useActiveWallet() {
|
|
7
|
-
const client = useInternalClient();
|
|
8
|
-
const { selectedWallet } = useWalletState();
|
|
9
|
-
return useMemo(() => {
|
|
10
|
-
return client.findWallet(selectedWallet.id, selectedWallet.type, { forbidPregen: true });
|
|
11
|
-
}, [client, selectedWallet]);
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
useActiveWallet
|
|
15
|
-
};
|