@getpara/react-sdk 1.7.1 → 1.9.0
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/index.js +6 -6659
- package/dist/modal/ParaModal.js +364 -0
- package/dist/modal/components/Account/Account.js +77 -0
- package/dist/modal/components/AddFunds/AddFunds.js +220 -0
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +72 -0
- package/dist/modal/components/AddFunds/AddFundsDone.js +43 -0
- package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
- package/dist/modal/components/AddFunds/index.js +4 -0
- package/dist/modal/components/AuthInput/AuthInput.js +283 -0
- package/dist/modal/components/AuthInput/countryCodes.js +42 -0
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
- package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +37 -0
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +113 -0
- package/dist/modal/components/AuthOptions/AuthOptions.js +33 -0
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +44 -0
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +3 -1
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +55 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +93 -0
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
- package/dist/modal/components/Body/Body.js +308 -0
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +94 -0
- package/dist/modal/components/ChainSwitch/config.js +17 -0
- package/dist/modal/components/Controls/Controls.js +74 -0
- package/dist/modal/components/Controls/Selects.js +234 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +140 -0
- package/dist/modal/components/ExternalWalletStep/config.js +17 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +96 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +172 -0
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +124 -0
- package/dist/modal/components/Footer/Footer.js +93 -0
- package/dist/modal/components/Header/Header.js +43 -0
- package/dist/modal/components/Header/hooks/useStepTitle.js +50 -0
- package/dist/modal/components/Hero/Hero.js +116 -0
- package/dist/modal/components/IFrameStep/IFrameStep.js +55 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +28 -0
- package/dist/modal/components/ModalContent/ModalContent.js +324 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
- package/dist/modal/components/OAuth/OAuth.js +153 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +139 -0
- package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +101 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +141 -0
- package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +24 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +159 -0
- package/dist/modal/components/Waiting/Waiting.js +17 -0
- package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
- package/dist/modal/components/WalletCard/WalletCard.js +127 -0
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +52 -0
- package/dist/modal/components/common.d.ts +6 -6
- package/dist/modal/components/common.js +96 -0
- package/dist/modal/components/index.js +2 -0
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/constants.js +112 -0
- package/dist/modal/constants/defaults.js +10 -0
- package/dist/modal/constants/oAuthLogos.js +24 -0
- package/dist/modal/hooks/useActiveWallet.js +15 -0
- package/dist/modal/hooks/useCreateAccount.d.ts +3 -1
- package/dist/modal/hooks/useCreateAccount.js +77 -0
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +54 -0
- package/dist/modal/hooks/useGoBack.js +42 -0
- package/dist/modal/hooks/useSetLoginURLs.js +49 -0
- package/dist/modal/hooks/useWalletBalance.d.ts +4 -0
- package/dist/modal/hooks/useWalletBalance.js +47 -0
- package/dist/modal/index.js +33 -0
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +38 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +2 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.js +55 -0
- package/dist/modal/providers/ExternalWalletContext.d.ts +3 -0
- package/dist/modal/providers/ExternalWalletContext.js +394 -0
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +32 -0
- package/dist/modal/stores/externalWalletProvider/actions.js +10 -0
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +21 -0
- package/dist/modal/stores/index.js +4 -0
- package/dist/modal/stores/modal/actions.js +70 -0
- package/dist/modal/stores/modal/useModalStore.js +65 -0
- package/dist/modal/stores/theme/actions.js +28 -0
- package/dist/modal/stores/theme/useThemeStore.js +21 -0
- package/dist/modal/stores/userInfo/actions.js +30 -0
- package/dist/modal/stores/userInfo/useUserInfoStore.js +17 -0
- package/dist/modal/types/commonTypes.js +1 -0
- package/dist/modal/types/externalWallets.js +32 -0
- package/dist/modal/types/modalProps.d.ts +4 -0
- package/dist/modal/types/modalProps.js +12 -0
- package/dist/modal/utils/authLayoutHelpers.js +8 -0
- package/dist/modal/utils/getMailtoLink.js +10 -0
- package/dist/modal/utils/getTileButtonFlex.js +20 -0
- package/dist/modal/utils/openPopup.js +60 -0
- package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
- package/dist/modal/utils/steps.js +232 -0
- package/dist/modal/utils/stringFormatters.d.ts +1 -0
- package/dist/modal/utils/stringFormatters.js +19 -0
- package/dist/modal/utils/validateOnRampConfig.js +32 -0
- package/dist/package.json +3 -1
- package/dist/provider/ParaProvider.js +22 -0
- package/dist/provider/actions/checkIfUserExists.js +21 -0
- package/dist/provider/actions/createUser.js +26 -0
- package/dist/provider/actions/getAccount.js +22 -0
- package/dist/provider/actions/getWallet.js +14 -0
- package/dist/provider/actions/getWalletBalance.d.ts +2 -0
- package/dist/provider/actions/getWalletBalance.js +14 -0
- package/dist/provider/actions/initiateLogin.js +20 -0
- package/dist/provider/actions/keepSessionAlive.js +20 -0
- package/dist/provider/actions/logout.js +17 -0
- package/dist/provider/actions/signMessage.js +20 -0
- package/dist/provider/actions/signTransaction.js +20 -0
- package/dist/provider/actions/waitForAccountCreation.js +21 -0
- package/dist/provider/actions/waitForLoginAndSetup.js +24 -0
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +21 -0
- package/dist/provider/hooks/index.js +4 -0
- package/dist/provider/hooks/mutations/index.js +24 -0
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
- package/dist/provider/hooks/mutations/useCreateUser.js +20 -0
- package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +20 -0
- package/dist/provider/hooks/mutations/useLogout.js +30 -0
- package/dist/provider/hooks/mutations/useSignMessage.js +39 -0
- package/dist/provider/hooks/mutations/useSignTransaction.js +39 -0
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +10 -0
- package/dist/provider/hooks/queries/useAccount.js +21 -0
- package/dist/provider/hooks/queries/useWallet.js +22 -0
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +7 -0
- package/dist/provider/hooks/queries/useWalletBalance.js +26 -0
- package/dist/provider/hooks/utils/index.js +10 -0
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
- package/dist/provider/hooks/utils/useClient.js +10 -0
- package/dist/provider/hooks/utils/useEventListeners.js +105 -0
- package/dist/provider/hooks/utils/useInternalClient.js +10 -0
- package/dist/provider/hooks/utils/useModal.js +17 -0
- package/dist/provider/hooks/utils/useWalletState.js +33 -0
- package/dist/provider/index.js +8 -0
- package/dist/provider/stores/getters.js +13 -0
- package/dist/provider/stores/slices/client.js +9 -0
- package/dist/provider/stores/slices/index.js +4 -0
- package/dist/provider/stores/slices/modal.js +9 -0
- package/dist/provider/stores/slices/wallet.js +13 -0
- package/dist/provider/stores/types.d.ts +2 -0
- package/dist/provider/stores/types.js +1 -0
- package/dist/provider/stores/useStore.js +27 -0
- package/dist/provider/types/provider.js +1 -0
- package/dist/provider/types/query.js +1 -0
- package/dist/provider/types/utils.js +1 -0
- package/dist/provider/utils/constants.js +11 -0
- package/dist/provider/utils/renameMutations.js +16 -0
- package/package.json +5 -5
- package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
- package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
- package/dist/chunk-MMUBH76A.js.br +0 -0
- package/dist/chunk-MMUBH76A.js.gz +0 -0
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useEffect, useRef } from "react";
|
|
6
|
+
import { useAccount, useKeepSessionAlive, useLogout } from "../index.js";
|
|
7
|
+
import { useInternalClient } from "./useInternalClient.js";
|
|
8
|
+
const SESSION_CHECK_INTERVAL = 6e4;
|
|
9
|
+
const SESSION_REFRESH_THRESHOLD = 3e5;
|
|
10
|
+
const useAutoSessionKeepAlive = ({ disabled }) => {
|
|
11
|
+
const client = useInternalClient();
|
|
12
|
+
const { data: account } = useAccount();
|
|
13
|
+
const { logoutAsync } = useLogout();
|
|
14
|
+
const { keepSessionAliveAsync } = useKeepSessionAlive();
|
|
15
|
+
const sessionCheckInterval = useRef(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!client || disabled) {
|
|
18
|
+
clearSessionMonitoring();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if ((account == null ? void 0 : account.isConnected) && !client.isUsingExternalWallet()) {
|
|
22
|
+
setupSessionMonitoring();
|
|
23
|
+
} else {
|
|
24
|
+
clearSessionMonitoring();
|
|
25
|
+
}
|
|
26
|
+
return () => clearSessionMonitoring();
|
|
27
|
+
}, [client, account, disabled]);
|
|
28
|
+
const getSessionExpiry = () => __async(void 0, null, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const sessionCookie = yield client.retrieveSessionCookie();
|
|
31
|
+
if (!sessionCookie) return null;
|
|
32
|
+
const expiresMatch = sessionCookie.match(/Expires=([^;]+)/);
|
|
33
|
+
return expiresMatch ? new Date(expiresMatch[1]) : null;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const setupSessionMonitoring = () => {
|
|
39
|
+
clearSessionMonitoring();
|
|
40
|
+
sessionCheckInterval.current = setInterval(() => __async(void 0, null, function* () {
|
|
41
|
+
const expiry = yield getSessionExpiry();
|
|
42
|
+
if (!expiry) {
|
|
43
|
+
yield logoutAsync();
|
|
44
|
+
clearSessionMonitoring();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const timeUntilExpiry = expiry.getTime() - Date.now();
|
|
48
|
+
if (timeUntilExpiry <= 0) {
|
|
49
|
+
yield logoutAsync();
|
|
50
|
+
clearSessionMonitoring();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (timeUntilExpiry <= SESSION_REFRESH_THRESHOLD) {
|
|
54
|
+
try {
|
|
55
|
+
yield keepSessionAliveAsync();
|
|
56
|
+
setupSessionMonitoring();
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error("Failed to keep session alive:", err);
|
|
59
|
+
yield logoutAsync();
|
|
60
|
+
clearSessionMonitoring();
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}), SESSION_CHECK_INTERVAL);
|
|
65
|
+
};
|
|
66
|
+
const clearSessionMonitoring = () => {
|
|
67
|
+
if (sessionCheckInterval.current) {
|
|
68
|
+
clearInterval(sessionCheckInterval.current);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
useAutoSessionKeepAlive
|
|
74
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { useClient, useWalletState } from "../index.js";
|
|
6
|
+
import {
|
|
7
|
+
ParaEvent
|
|
8
|
+
} from "@getpara/web-sdk";
|
|
9
|
+
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
10
|
+
import { useStore } from "../../stores/useStore.js";
|
|
11
|
+
import { WALLET_BASE_KEY } from "../../hooks/queries/useWallet.js";
|
|
12
|
+
const useEventListeners = ({
|
|
13
|
+
onLogin,
|
|
14
|
+
onLogout,
|
|
15
|
+
onAccountSetup,
|
|
16
|
+
onAccountCreation,
|
|
17
|
+
onSignMessage,
|
|
18
|
+
onSignTransaction,
|
|
19
|
+
onWalletCreated,
|
|
20
|
+
onPregenWalletClaimed,
|
|
21
|
+
onExternalWalletChange,
|
|
22
|
+
onWalletsChange
|
|
23
|
+
} = {}) => {
|
|
24
|
+
const queryClient = useQueryClient();
|
|
25
|
+
const client = useClient();
|
|
26
|
+
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
27
|
+
const { selectedWallet, setSelectedWallet } = useWalletState();
|
|
28
|
+
const loginListener = (event) => {
|
|
29
|
+
loginOrSetupListener();
|
|
30
|
+
onLogin == null ? void 0 : onLogin(event);
|
|
31
|
+
};
|
|
32
|
+
const accountSetupListener = (event) => {
|
|
33
|
+
loginOrSetupListener();
|
|
34
|
+
onAccountSetup == null ? void 0 : onAccountSetup(event);
|
|
35
|
+
};
|
|
36
|
+
const loginOrSetupListener = () => {
|
|
37
|
+
queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
|
|
38
|
+
queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
|
|
39
|
+
};
|
|
40
|
+
const accountCreationListener = (event) => {
|
|
41
|
+
onAccountCreation == null ? void 0 : onAccountCreation(event);
|
|
42
|
+
};
|
|
43
|
+
const logoutListener = (event) => {
|
|
44
|
+
queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
|
|
45
|
+
clearSelectedWallet();
|
|
46
|
+
onLogout == null ? void 0 : onLogout(event);
|
|
47
|
+
};
|
|
48
|
+
const signMessageListener = (event) => {
|
|
49
|
+
onSignMessage == null ? void 0 : onSignMessage(event);
|
|
50
|
+
};
|
|
51
|
+
const signTransactionListener = (event) => {
|
|
52
|
+
onSignTransaction == null ? void 0 : onSignTransaction(event);
|
|
53
|
+
};
|
|
54
|
+
const walletChangeListener = (event) => {
|
|
55
|
+
updateSelectedWallet();
|
|
56
|
+
onWalletsChange == null ? void 0 : onWalletsChange(event);
|
|
57
|
+
};
|
|
58
|
+
const externalWalletChangeListener = (event) => {
|
|
59
|
+
updateSelectedWallet();
|
|
60
|
+
onExternalWalletChange == null ? void 0 : onExternalWalletChange(event);
|
|
61
|
+
};
|
|
62
|
+
const walletCreatedListener = (event) => {
|
|
63
|
+
onWalletCreated == null ? void 0 : onWalletCreated(event);
|
|
64
|
+
};
|
|
65
|
+
const pregenWalletClaimedListener = (event) => {
|
|
66
|
+
onPregenWalletClaimed == null ? void 0 : onPregenWalletClaimed(event);
|
|
67
|
+
};
|
|
68
|
+
const updateSelectedWallet = () => {
|
|
69
|
+
if (!client) {
|
|
70
|
+
clearSelectedWallet();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!(selectedWallet == null ? void 0 : selectedWallet.id) || !client.findWallet(selectedWallet == null ? void 0 : selectedWallet.id)) {
|
|
74
|
+
const defaultWallet = client.findWallet(void 0, void 0, { forbidPregen: true });
|
|
75
|
+
setSelectedWallet({ id: defaultWallet == null ? void 0 : defaultWallet.id, type: defaultWallet == null ? void 0 : defaultWallet.type });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
80
|
+
window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
81
|
+
window.addEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
|
|
82
|
+
window.addEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
|
|
83
|
+
window.addEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
|
|
84
|
+
window.addEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
|
|
85
|
+
window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
|
|
86
|
+
window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
|
|
87
|
+
window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
88
|
+
window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
89
|
+
return () => {
|
|
90
|
+
window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
91
|
+
window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
|
|
92
|
+
window.removeEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
|
|
93
|
+
window.removeEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
|
|
94
|
+
window.removeEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
|
|
95
|
+
window.removeEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
|
|
96
|
+
window.removeEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
|
|
97
|
+
window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
|
|
98
|
+
window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
|
|
99
|
+
window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
|
|
100
|
+
};
|
|
101
|
+
}, [client]);
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
useEventListeners
|
|
105
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useStore } from "../../stores/useStore.js";
|
|
4
|
+
const useModal = () => {
|
|
5
|
+
const isOpen = useStore((state) => state.isOpen);
|
|
6
|
+
const setIsOpen = useStore((state) => state.setIsOpen);
|
|
7
|
+
const openModal = () => {
|
|
8
|
+
setIsOpen(true);
|
|
9
|
+
};
|
|
10
|
+
const closeModal = () => {
|
|
11
|
+
setIsOpen(false);
|
|
12
|
+
};
|
|
13
|
+
return { isOpen, openModal, closeModal };
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useModal
|
|
17
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useStore } from "../../stores/useStore.js";
|
|
4
|
+
import { useClient } from "./useClient.js";
|
|
5
|
+
const useWalletState = () => {
|
|
6
|
+
const client = useClient();
|
|
7
|
+
const selectedWalletId = useStore((state) => state.selectedWalletId);
|
|
8
|
+
const selectedWalletType = useStore((state) => state.selectedWalletType);
|
|
9
|
+
const setStoredSelectedWallet = useStore((state) => state.setSelectedWallet);
|
|
10
|
+
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
11
|
+
const setSelectedWallet = ({ id, type }) => {
|
|
12
|
+
try {
|
|
13
|
+
const validId = client.findWalletId(id, { type: [type] });
|
|
14
|
+
if (validId !== id) {
|
|
15
|
+
clearSelectedWallet();
|
|
16
|
+
} else {
|
|
17
|
+
setStoredSelectedWallet(id, type);
|
|
18
|
+
}
|
|
19
|
+
} catch (e) {
|
|
20
|
+
clearSelectedWallet();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
selectedWallet: {
|
|
25
|
+
id: selectedWalletId,
|
|
26
|
+
type: selectedWalletType
|
|
27
|
+
},
|
|
28
|
+
setSelectedWallet
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
useWalletState
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { vanillaStore } from "./useStore.js";
|
|
4
|
+
const getClient = () => vanillaStore.getState().client;
|
|
5
|
+
const getIsOpen = () => vanillaStore.getState().isOpen;
|
|
6
|
+
const getSelectedWalletId = () => vanillaStore.getState().selectedWalletId;
|
|
7
|
+
const getSelectedWalletType = () => vanillaStore.getState().selectedWalletType;
|
|
8
|
+
export {
|
|
9
|
+
getClient,
|
|
10
|
+
getIsOpen,
|
|
11
|
+
getSelectedWalletId,
|
|
12
|
+
getSelectedWalletType
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
const createWalletSlice = (set) => ({
|
|
4
|
+
rpcUrl: void 0,
|
|
5
|
+
setRpcUrl: (rpcUrl) => set({ rpcUrl }),
|
|
6
|
+
selectedWalletId: void 0,
|
|
7
|
+
selectedWalletType: void 0,
|
|
8
|
+
setSelectedWallet: (selectedWalletId, selectedWalletType) => set({ selectedWalletId, selectedWalletType }),
|
|
9
|
+
clearSelectedWallet: () => set({ selectedWalletId: void 0, selectedWalletType: void 0 })
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
createWalletSlice
|
|
13
|
+
};
|
|
@@ -8,6 +8,8 @@ export interface ModalSlice {
|
|
|
8
8
|
setIsOpen: (_: boolean) => void;
|
|
9
9
|
}
|
|
10
10
|
export interface WalletSlice {
|
|
11
|
+
rpcUrl?: string;
|
|
12
|
+
setRpcUrl: (_?: string) => void;
|
|
11
13
|
selectedWalletId?: string;
|
|
12
14
|
selectedWalletType?: WalletType;
|
|
13
15
|
setSelectedWallet: (_?: string, __?: WalletType) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
import { createStore, useStore as useZustandStore } from "zustand";
|
|
6
|
+
import { createClientSlice, createModalSlice, createWalletSlice } from "./slices/index.js";
|
|
7
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
8
|
+
const vanillaStore = createStore()(
|
|
9
|
+
persist(
|
|
10
|
+
(...a) => __spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)),
|
|
11
|
+
{
|
|
12
|
+
version: 1,
|
|
13
|
+
name: "@PARA/web-state",
|
|
14
|
+
storage: createJSONStorage(() => localStorage),
|
|
15
|
+
partialize: (state) => ({
|
|
16
|
+
selectedWalletId: state.selectedWalletId,
|
|
17
|
+
selectedWalletType: state.selectedWalletType
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
const createBoundedUseStore = (store) => (selector) => useZustandStore(store, selector);
|
|
23
|
+
const useStore = createBoundedUseStore(vanillaStore);
|
|
24
|
+
export {
|
|
25
|
+
useStore,
|
|
26
|
+
vanillaStore
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { WalletType } from "@getpara/web-sdk";
|
|
4
|
+
const EXTERNAL_WALLET_PACKAGE_BY_TYPE = {
|
|
5
|
+
[WalletType.EVM]: "Wagmi",
|
|
6
|
+
[WalletType.COSMOS]: "Graz",
|
|
7
|
+
[WalletType.SOLANA]: "@solana/wallet-adapter-react"
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
EXTERNAL_WALLET_PACKAGE_BY_TYPE
|
|
11
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../../chunk-MMUBH76A.js";
|
|
6
|
+
function renameMutations(mutationObj, name) {
|
|
7
|
+
const _a = mutationObj, { mutate: _, mutateAsync: __ } = _a, mutationNoMutate = __objRest(_a, ["mutate", "mutateAsync"]);
|
|
8
|
+
const newMutations = {
|
|
9
|
+
[name]: mutationObj.mutate,
|
|
10
|
+
[`${name}Async`]: mutationObj.mutateAsync
|
|
11
|
+
};
|
|
12
|
+
return __spreadValues(__spreadValues({}, newMutations), mutationNoMutate);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
renameMutations
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"*.css"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getpara/react-common": "1.
|
|
16
|
-
"@getpara/react-components": "1.
|
|
17
|
-
"@getpara/web-sdk": "1.
|
|
15
|
+
"@getpara/react-common": "1.9.0",
|
|
16
|
+
"@getpara/react-components": "1.9.0",
|
|
17
|
+
"@getpara/web-sdk": "1.9.0",
|
|
18
18
|
"@tanstack/react-query": "^5.0.0",
|
|
19
19
|
"date-fns": "^3.6.0",
|
|
20
20
|
"framer-motion": "11.3.28",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"resolutions": {
|
|
50
50
|
"styled-components": "^6"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "3d749844bf071e2c8de2769dd16e17c026951109"
|
|
53
53
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.js.br
DELETED
|
Binary file
|
package/dist/index.js.gz
DELETED
|
Binary file
|