@dynamic-labs/sdk-react-core 4.4.2 → 4.4.4
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/CHANGELOG.md +20 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/lib/Main.cjs +3 -3
- package/src/lib/Main.js +3 -3
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.cjs +2 -3
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.js +2 -3
- package/src/lib/components/HardwareWalletToggle/HardwareWalletToggle.cjs +12 -11
- package/src/lib/components/HardwareWalletToggle/HardwareWalletToggle.js +12 -11
- package/src/lib/components/NeedHelpSection/NeedHelpSection.cjs +2 -2
- package/src/lib/components/NeedHelpSection/NeedHelpSection.js +2 -2
- package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.cjs +2 -2
- package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.js +2 -2
- package/src/lib/components/Toggle/Toggle.cjs +1 -5
- package/src/lib/components/Toggle/Toggle.d.ts +6 -2
- package/src/lib/components/Toggle/Toggle.js +1 -5
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/utils.cjs +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/utils.d.ts +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/utils.js +2 -2
- package/src/lib/context/CaptchaContext/CaptchaContext.cjs +3 -3
- package/src/lib/context/CaptchaContext/CaptchaContext.js +3 -3
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -2
- package/src/lib/context/MockContext/MockContext.cjs +0 -2
- package/src/lib/context/MockContext/MockContext.js +0 -2
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +5 -5
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +5 -5
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +8 -9
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +8 -9
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +8 -3
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +8 -3
- package/src/lib/context/ViewContext/ViewContext.cjs +0 -2
- package/src/lib/context/ViewContext/ViewContext.d.ts +0 -10
- package/src/lib/context/ViewContext/ViewContext.js +0 -2
- package/src/lib/context/ViewContext/types/index.d.ts +1 -2
- package/src/lib/context/WalletGroupContext/WalletGroupContext.cjs +3 -3
- package/src/lib/context/WalletGroupContext/WalletGroupContext.js +3 -3
- package/src/lib/data/api/exchangeRates/exchangeRates.cjs +9 -5
- package/src/lib/data/api/exchangeRates/exchangeRates.js +9 -5
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +2 -6
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +2 -6
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +4 -4
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +4 -4
- package/src/lib/store/internalImplementation/store.cjs +1 -0
- package/src/lib/store/internalImplementation/store.d.ts +5 -1
- package/src/lib/store/internalImplementation/store.js +1 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.cjs +4 -0
- package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.js +4 -0
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.cjs +3 -3
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.d.ts +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.js +3 -3
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +8 -8
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +8 -8
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +7 -7
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +7 -7
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +2 -2
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +5 -0
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +5 -0
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +3 -3
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +3 -3
- package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.cjs +3 -3
- package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +3 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.cjs +2 -2
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +4 -4
- package/src/lib/utils/hooks/useFunding/useConnectWalletForFunding/useConnectWalletForFunding.cjs +28 -10
- package/src/lib/utils/hooks/useFunding/useConnectWalletForFunding/useConnectWalletForFunding.js +25 -7
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +6 -6
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +6 -6
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.cjs +2 -2
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.js +2 -2
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.cjs +12 -12
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.js +12 -12
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +5 -7
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +5 -7
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +38 -24
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +3 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +38 -24
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.cjs +3 -3
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.js +3 -3
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +5 -5
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +5 -5
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +5 -5
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +5 -5
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +9 -9
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +9 -9
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs +6 -6
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js +6 -6
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/handleStoreVersionChanged.cjs +12 -0
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/handleStoreVersionChanged.d.ts +7 -0
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/handleStoreVersionChanged.js +8 -0
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/index.d.ts +1 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +5 -3
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.d.ts +3 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +5 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +12 -12
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +12 -12
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +8 -8
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +8 -8
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +14 -22
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.d.ts +6 -5
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +14 -22
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +3 -3
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +3 -3
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs +2 -2
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js +2 -2
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.cjs +2 -2
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.js +2 -2
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.cjs +2 -2
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.js +2 -2
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +3 -3
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +2 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +2 -2
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +4 -4
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +4 -4
- package/src/lib/views/LoginView/LoginView.cjs +2 -2
- package/src/lib/views/LoginView/LoginView.js +2 -2
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.cjs +4 -4
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.js +4 -4
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +3 -3
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +3 -3
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +5 -5
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +5 -5
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +3 -3
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +3 -3
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +4 -4
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +4 -4
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +4 -9
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +4 -9
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +8 -10
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +8 -10
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +5 -5
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +5 -5
- package/src/lib/views/NoAccess/NoAccess.cjs +2 -2
- package/src/lib/views/NoAccess/NoAccess.js +2 -2
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.cjs +2 -4
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.js +2 -4
- package/src/lib/views/SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.cjs +2 -2
- package/src/lib/views/SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.js +2 -2
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.cjs +2 -2
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.js +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +2 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +2 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.cjs +9 -4
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.js +10 -5
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.cjs +0 -17
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.js +0 -17
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +4 -4
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +4 -4
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js +2 -2
package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js
CHANGED
|
@@ -89,7 +89,7 @@ import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
89
89
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
90
90
|
|
|
91
91
|
/** Saves the values updated by the user */
|
|
92
|
-
const saveUserValues = (_a, setShowAuthFlow_1,
|
|
92
|
+
const saveUserValues = (_a, setShowAuthFlow_1, pushView_1, resolve_1, reject_1) => __awaiter(void 0, [_a, setShowAuthFlow_1, pushView_1, resolve_1, reject_1], void 0, function* ({ fields: newValues, updateUserResult: { isEmailVerificationRequired, isSmsVerificationRequired, }, }, setShowAuthFlow, pushView, resolve, reject) {
|
|
93
93
|
// If no verification is needed, we are done
|
|
94
94
|
if (!isEmailVerificationRequired && !isSmsVerificationRequired) {
|
|
95
95
|
resolve(newValues);
|
|
@@ -101,7 +101,7 @@ const saveUserValues = (_a, setShowAuthFlow_1, setView_1, resolve_1, reject_1) =
|
|
|
101
101
|
performMultiWalletChecks: false,
|
|
102
102
|
});
|
|
103
103
|
if (isEmailVerificationRequired) {
|
|
104
|
-
|
|
104
|
+
pushView('verify-email');
|
|
105
105
|
// Subscribe to email verification result
|
|
106
106
|
dynamicEvents.once('emailVerificationResult', (wasSuccessful, newEmail) => {
|
|
107
107
|
// Make sure we're using the correct, updated email. User might have changed it mid-OTP
|
|
@@ -112,7 +112,7 @@ const saveUserValues = (_a, setShowAuthFlow_1, setView_1, resolve_1, reject_1) =
|
|
|
112
112
|
});
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
pushView('verify-sms');
|
|
116
116
|
// Subscribe to sms verification result
|
|
117
117
|
dynamicEvents.once('smsVerificationResult', (wasSuccessful, { phone: newPhone }) => {
|
|
118
118
|
// Make sure we're using the correct, updated phone number. User might have changed it mid-OTP
|
|
@@ -128,7 +128,7 @@ const saveUserValues = (_a, setShowAuthFlow_1, setView_1, resolve_1, reject_1) =
|
|
|
128
128
|
*/
|
|
129
129
|
const useUpdateUserWithModal = (updateUser) => {
|
|
130
130
|
const { user, projectSettings, setShowAuthFlow } = useInternalDynamicContext();
|
|
131
|
-
const {
|
|
131
|
+
const { pushView } = useViewContext();
|
|
132
132
|
const editorContext = useContext(UserFieldEditorContext);
|
|
133
133
|
if (!editorContext)
|
|
134
134
|
throw new DynamicError('useUserUpdateRequest can only be used inside the context of DynamicContextProvider');
|
|
@@ -147,7 +147,7 @@ const useUpdateUserWithModal = (updateUser) => {
|
|
|
147
147
|
subtitle: options === null || options === void 0 ? void 0 : options.subtitle,
|
|
148
148
|
title: options === null || options === void 0 ? void 0 : options.title,
|
|
149
149
|
}, updateUser)
|
|
150
|
-
.then((updateValues) => saveUserValues(updateValues, setShowAuthFlow,
|
|
150
|
+
.then((updateValues) => saveUserValues(updateValues, setShowAuthFlow, pushView, resolve, reject))
|
|
151
151
|
.catch((error) => {
|
|
152
152
|
if (/email already exists/gi.test(error))
|
|
153
153
|
throw error;
|
|
@@ -159,7 +159,7 @@ const useUpdateUserWithModal = (updateUser) => {
|
|
|
159
159
|
promptUserForValues,
|
|
160
160
|
updateUser,
|
|
161
161
|
setShowAuthFlow,
|
|
162
|
-
|
|
162
|
+
pushView,
|
|
163
163
|
]);
|
|
164
164
|
return updateUserWithModal;
|
|
165
165
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const handleStoreVersionChanged = ({ didStoreVersionChangedRef, logout, }) => {
|
|
7
|
+
if (didStoreVersionChangedRef.current) {
|
|
8
|
+
logout('store version changed', {});
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.handleStoreVersionChanged = handleStoreVersionChanged;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
type HandleStoreVersionChangedParams = {
|
|
3
|
+
logout: (reason: string, params: any) => Promise<void>;
|
|
4
|
+
didStoreVersionChangedRef: MutableRefObject<boolean>;
|
|
5
|
+
};
|
|
6
|
+
export declare const handleStoreVersionChanged: ({ didStoreVersionChangedRef, logout, }: HandleStoreVersionChangedParams) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handleStoreVersionChanged } from './handleStoreVersionChanged';
|
|
@@ -11,8 +11,9 @@ var loadingAndLifecycle = require('../../../store/state/loadingAndLifecycle.cjs'
|
|
|
11
11
|
var useDynamicEvents = require('../events/useDynamicEvents/useDynamicEvents.cjs');
|
|
12
12
|
var handleStoreAndEnvironmentMismatch = require('./handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs');
|
|
13
13
|
var handleUserDataOutOfSync = require('./handleUserDataOutOfSync/handleUserDataOutOfSync.cjs');
|
|
14
|
+
var handleStoreVersionChanged = require('./handleStoreVersionChanged/handleStoreVersionChanged.cjs');
|
|
14
15
|
|
|
15
|
-
const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
16
|
+
const useValidateSession = ({ environmentId, handleLogOut, didStoreVersionChangedRef, }) => {
|
|
16
17
|
const logout = React.useCallback(
|
|
17
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
19
|
(reason, params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -20,14 +21,15 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
20
21
|
return handleLogOut();
|
|
21
22
|
}), [handleLogOut]);
|
|
22
23
|
const validateSession = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const params = { environmentId, logout };
|
|
24
|
+
const params = { didStoreVersionChangedRef, environmentId, logout };
|
|
24
25
|
yield Promise.all([
|
|
25
26
|
handleStoreAndEnvironmentMismatch.handleStoreAndEnvironmentMismatch(params),
|
|
26
27
|
handleUserDataOutOfSync.handleUserDataOutOfSync(params),
|
|
28
|
+
handleStoreVersionChanged.handleStoreVersionChanged(params),
|
|
27
29
|
]);
|
|
28
30
|
// Regardless of whether we logged out or not, session validation is now complete
|
|
29
31
|
loadingAndLifecycle.setLoadingAndLifecycle({ sessionValidation: true });
|
|
30
|
-
}), [environmentId, logout]);
|
|
32
|
+
}), [environmentId, logout, didStoreVersionChangedRef]);
|
|
31
33
|
useEffectOnce.useEffectOnce(() => {
|
|
32
34
|
validateSession();
|
|
33
35
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
1
2
|
type Props = {
|
|
2
3
|
environmentId: string;
|
|
3
4
|
handleLogOut: () => Promise<void>;
|
|
5
|
+
didStoreVersionChangedRef: MutableRefObject<boolean>;
|
|
4
6
|
};
|
|
5
|
-
export declare const useValidateSession: ({ environmentId, handleLogOut }: Props) => void;
|
|
7
|
+
export declare const useValidateSession: ({ environmentId, handleLogOut, didStoreVersionChangedRef, }: Props) => void;
|
|
6
8
|
export {};
|
|
@@ -7,8 +7,9 @@ import { setLoadingAndLifecycle } from '../../../store/state/loadingAndLifecycle
|
|
|
7
7
|
import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicEvents.js';
|
|
8
8
|
import { handleStoreAndEnvironmentMismatch } from './handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js';
|
|
9
9
|
import { handleUserDataOutOfSync } from './handleUserDataOutOfSync/handleUserDataOutOfSync.js';
|
|
10
|
+
import { handleStoreVersionChanged } from './handleStoreVersionChanged/handleStoreVersionChanged.js';
|
|
10
11
|
|
|
11
|
-
const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
12
|
+
const useValidateSession = ({ environmentId, handleLogOut, didStoreVersionChangedRef, }) => {
|
|
12
13
|
const logout = useCallback(
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
15
|
(reason, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -16,14 +17,15 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
16
17
|
return handleLogOut();
|
|
17
18
|
}), [handleLogOut]);
|
|
18
19
|
const validateSession = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
const params = { environmentId, logout };
|
|
20
|
+
const params = { didStoreVersionChangedRef, environmentId, logout };
|
|
20
21
|
yield Promise.all([
|
|
21
22
|
handleStoreAndEnvironmentMismatch(params),
|
|
22
23
|
handleUserDataOutOfSync(params),
|
|
24
|
+
handleStoreVersionChanged(params),
|
|
23
25
|
]);
|
|
24
26
|
// Regardless of whether we logged out or not, session validation is now complete
|
|
25
27
|
setLoadingAndLifecycle({ sessionValidation: true });
|
|
26
|
-
}), [environmentId, logout]);
|
|
28
|
+
}), [environmentId, logout, didStoreVersionChangedRef]);
|
|
27
29
|
useEffectOnce(() => {
|
|
28
30
|
validateSession();
|
|
29
31
|
});
|
|
@@ -106,7 +106,7 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
106
106
|
const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
107
107
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
108
108
|
const { setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
109
|
-
const {
|
|
109
|
+
const { pushView, clearStackAndPushInitialView } = ViewContext.useViewContext();
|
|
110
110
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
111
111
|
const { multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setShowAuthFlow, siweStatement, connectedWallets, authMode, user, setAuthMode, removeConnectedWalletsInfo, events, primaryWallet, enableConnectOnlyFallback, selectedWalletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
112
112
|
const { addedWalletsIds } = UserWalletsContext.useInternalUserWallets();
|
|
@@ -169,11 +169,11 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
169
169
|
// This is a special case where the user is trying to link a wallet
|
|
170
170
|
// and the wallet is already linked and we don't want to kill the session.
|
|
171
171
|
setShowAuthFlow(true);
|
|
172
|
-
|
|
172
|
+
pushView('wallet-used');
|
|
173
173
|
setIsSingleWalletAccount(false);
|
|
174
174
|
if (e.code === 'reassign_wallet_error') {
|
|
175
175
|
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.preventOrphanedAccounts) {
|
|
176
|
-
|
|
176
|
+
pushView('wallet-cannot-be-transferred');
|
|
177
177
|
}
|
|
178
178
|
setIsSingleWalletAccount(true);
|
|
179
179
|
}
|
|
@@ -199,7 +199,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
199
199
|
type: 'wallet',
|
|
200
200
|
}, { error: e });
|
|
201
201
|
if (e instanceof utils.EmbeddedWalletExistsError) {
|
|
202
|
-
|
|
202
|
+
pushView('embedded-wallet-exists');
|
|
203
203
|
setShowAuthFlow(true);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
@@ -208,24 +208,24 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
208
208
|
return handleWalletUsedError(e);
|
|
209
209
|
}
|
|
210
210
|
if (e instanceof utils.MergeAccountsConfirmationError) {
|
|
211
|
-
|
|
211
|
+
pushView('merge-user-accounts', Object.assign({}, e));
|
|
212
212
|
setShowAuthFlow(true);
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
if (e instanceof utils.ChainalysisError) {
|
|
216
216
|
handleDisconnectWallet({ walletConnector });
|
|
217
217
|
setDeniedAddress(address);
|
|
218
|
-
|
|
218
|
+
pushView('chainalysis-blocked-wallet');
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
221
|
if (e instanceof utils.GateBlockedError) {
|
|
222
222
|
handleDisconnectWallet({ walletConnector });
|
|
223
223
|
setDeniedAddress(address);
|
|
224
|
-
|
|
224
|
+
pushView('gate-blocked-wallet');
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
227
|
if (e instanceof utils.SandboxMaximumThresholdReachedError) {
|
|
228
|
-
|
|
228
|
+
pushView('sandbox-maximum-threshold-reached');
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
if (e instanceof utils.NoAccessError) {
|
|
@@ -235,13 +235,13 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
235
235
|
if (walletConnectorCore.isSocialWalletConnector(walletConnector)) {
|
|
236
236
|
setDeniedOauthProvider(oauth === null || oauth === void 0 ? void 0 : oauth.provider);
|
|
237
237
|
}
|
|
238
|
-
|
|
238
|
+
pushView('no-access');
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
241
|
if (e instanceof utils.AccountExistsError) {
|
|
242
242
|
handleDisconnectWallet({ walletConnector });
|
|
243
243
|
setExistentAccountData(e.errorPayload);
|
|
244
|
-
|
|
244
|
+
pushView('account-exists');
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
if (connectedWallets.length && authMode === 'connect-only') {
|
|
@@ -253,12 +253,12 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
253
253
|
logger.logger.warn('Verification failed, changing to connect-only');
|
|
254
254
|
// verification failed for unknown reason, set authmode to connect-only and show wallet list
|
|
255
255
|
setAuthMode('connect-only');
|
|
256
|
-
|
|
256
|
+
pushView('wallet-list');
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
259
|
else {
|
|
260
260
|
handleDisconnectWallet({ walletConnector });
|
|
261
|
-
|
|
261
|
+
clearStackAndPushInitialView();
|
|
262
262
|
}
|
|
263
263
|
logger.logger.error(e);
|
|
264
264
|
if (debugError) {
|
|
@@ -102,7 +102,7 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
102
102
|
const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
103
103
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
104
104
|
const { setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
105
|
-
const {
|
|
105
|
+
const { pushView, clearStackAndPushInitialView } = useViewContext();
|
|
106
106
|
const { setErrorMessage, setError } = useErrorContext();
|
|
107
107
|
const { multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setShowAuthFlow, siweStatement, connectedWallets, authMode, user, setAuthMode, removeConnectedWalletsInfo, events, primaryWallet, enableConnectOnlyFallback, selectedWalletConnector, } = useInternalDynamicContext();
|
|
108
108
|
const { addedWalletsIds } = useInternalUserWallets();
|
|
@@ -165,11 +165,11 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
165
165
|
// This is a special case where the user is trying to link a wallet
|
|
166
166
|
// and the wallet is already linked and we don't want to kill the session.
|
|
167
167
|
setShowAuthFlow(true);
|
|
168
|
-
|
|
168
|
+
pushView('wallet-used');
|
|
169
169
|
setIsSingleWalletAccount(false);
|
|
170
170
|
if (e.code === 'reassign_wallet_error') {
|
|
171
171
|
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.preventOrphanedAccounts) {
|
|
172
|
-
|
|
172
|
+
pushView('wallet-cannot-be-transferred');
|
|
173
173
|
}
|
|
174
174
|
setIsSingleWalletAccount(true);
|
|
175
175
|
}
|
|
@@ -195,7 +195,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
195
195
|
type: 'wallet',
|
|
196
196
|
}, { error: e });
|
|
197
197
|
if (e instanceof EmbeddedWalletExistsError) {
|
|
198
|
-
|
|
198
|
+
pushView('embedded-wallet-exists');
|
|
199
199
|
setShowAuthFlow(true);
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
@@ -204,24 +204,24 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
204
204
|
return handleWalletUsedError(e);
|
|
205
205
|
}
|
|
206
206
|
if (e instanceof MergeAccountsConfirmationError) {
|
|
207
|
-
|
|
207
|
+
pushView('merge-user-accounts', Object.assign({}, e));
|
|
208
208
|
setShowAuthFlow(true);
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
211
211
|
if (e instanceof ChainalysisError) {
|
|
212
212
|
handleDisconnectWallet({ walletConnector });
|
|
213
213
|
setDeniedAddress(address);
|
|
214
|
-
|
|
214
|
+
pushView('chainalysis-blocked-wallet');
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
if (e instanceof GateBlockedError) {
|
|
218
218
|
handleDisconnectWallet({ walletConnector });
|
|
219
219
|
setDeniedAddress(address);
|
|
220
|
-
|
|
220
|
+
pushView('gate-blocked-wallet');
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
if (e instanceof SandboxMaximumThresholdReachedError) {
|
|
224
|
-
|
|
224
|
+
pushView('sandbox-maximum-threshold-reached');
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
227
|
if (e instanceof NoAccessError) {
|
|
@@ -231,13 +231,13 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
231
231
|
if (isSocialWalletConnector(walletConnector)) {
|
|
232
232
|
setDeniedOauthProvider(oauth === null || oauth === void 0 ? void 0 : oauth.provider);
|
|
233
233
|
}
|
|
234
|
-
|
|
234
|
+
pushView('no-access');
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
if (e instanceof AccountExistsError) {
|
|
238
238
|
handleDisconnectWallet({ walletConnector });
|
|
239
239
|
setExistentAccountData(e.errorPayload);
|
|
240
|
-
|
|
240
|
+
pushView('account-exists');
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
243
|
if (connectedWallets.length && authMode === 'connect-only') {
|
|
@@ -249,12 +249,12 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
249
249
|
logger.warn('Verification failed, changing to connect-only');
|
|
250
250
|
// verification failed for unknown reason, set authmode to connect-only and show wallet list
|
|
251
251
|
setAuthMode('connect-only');
|
|
252
|
-
|
|
252
|
+
pushView('wallet-list');
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
255
|
else {
|
|
256
256
|
handleDisconnectWallet({ walletConnector });
|
|
257
|
-
|
|
257
|
+
clearStackAndPushInitialView();
|
|
258
258
|
}
|
|
259
259
|
logger.error(e);
|
|
260
260
|
if (debugError) {
|
package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs
CHANGED
|
@@ -98,7 +98,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
98
98
|
const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnectorKey, walletConnectorOptions, setQrcodeUri, setDesktopUri, user, linkedWallets, setLegacyIsVerifying, authMode, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
99
99
|
const { mockedSDK } = MockContext.useMockContext();
|
|
100
100
|
const { setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
101
|
-
const {
|
|
101
|
+
const { pushView, clearStackAndPushInitialView } = ViewContext.useViewContext();
|
|
102
102
|
const handleCustodialWalletClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
103
103
|
logger.logger.debug('handleCustodialWalletClick', walletConnector);
|
|
104
104
|
const twoStepAuthentication = requiresTwoStepAuthentication.requiresTwoStepAuthentication(walletConnector);
|
|
@@ -133,7 +133,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
133
133
|
const attemptConnection = () => {
|
|
134
134
|
onConnectOnly({ shouldShowPendingConnectView: false, walletConnector });
|
|
135
135
|
};
|
|
136
|
-
|
|
136
|
+
pushView('mobile-wallet-redirect-view', { onRetry: attemptConnection });
|
|
137
137
|
attemptConnection();
|
|
138
138
|
});
|
|
139
139
|
const handleInstalledExtensionClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -145,7 +145,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
145
145
|
logger.logger.debug('handleUninstalledClick', walletConnector);
|
|
146
146
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
147
147
|
if (!walletConnector.canConnectViaQrCode) {
|
|
148
|
-
|
|
148
|
+
pushView('no-qr-not-installed');
|
|
149
149
|
}
|
|
150
150
|
else {
|
|
151
151
|
onQrCodeConnect({
|
|
@@ -159,7 +159,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
159
159
|
},
|
|
160
160
|
walletConnector,
|
|
161
161
|
});
|
|
162
|
-
|
|
162
|
+
pushView('qr-code');
|
|
163
163
|
}
|
|
164
164
|
setError(undefined);
|
|
165
165
|
});
|
|
@@ -224,13 +224,13 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
224
224
|
if (authMode !== 'connect-only' && isMetamask) {
|
|
225
225
|
try {
|
|
226
226
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
227
|
-
|
|
227
|
+
pushView('pending-connect');
|
|
228
228
|
yield walletConnector.chooseAccountsToConnect();
|
|
229
229
|
}
|
|
230
230
|
catch (error) {
|
|
231
231
|
if (error instanceof utils.UserRejectedRequestError) {
|
|
232
232
|
setErrorMessage('connection_rejected');
|
|
233
|
-
|
|
233
|
+
clearStackAndPushInitialView();
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
236
236
|
}
|
|
@@ -242,13 +242,13 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
242
242
|
handleAlreadyConnectedWallet(walletConnector);
|
|
243
243
|
}
|
|
244
244
|
else if (walletConnector.canConnectViaCustodialService) {
|
|
245
|
-
// providers like blocto and dapper
|
|
245
|
+
// providers like coinbase, blocto and dapper
|
|
246
246
|
handleCustodialWalletClick(walletConnector);
|
|
247
247
|
}
|
|
248
248
|
else if (utils.isMobile()) {
|
|
249
249
|
// mobile wallets
|
|
250
250
|
if (walletConnector.key === 'walletconnect') {
|
|
251
|
-
|
|
251
|
+
pushView('wallet-connect-mobile-wallets-list');
|
|
252
252
|
}
|
|
253
253
|
else {
|
|
254
254
|
handleMobileWalletClick(walletConnector);
|
|
@@ -94,7 +94,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
94
94
|
const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnectorKey, walletConnectorOptions, setQrcodeUri, setDesktopUri, user, linkedWallets, setLegacyIsVerifying, authMode, } = useInternalDynamicContext();
|
|
95
95
|
const { mockedSDK } = useMockContext();
|
|
96
96
|
const { setError, setErrorMessage } = useErrorContext();
|
|
97
|
-
const {
|
|
97
|
+
const { pushView, clearStackAndPushInitialView } = useViewContext();
|
|
98
98
|
const handleCustodialWalletClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
99
|
logger.debug('handleCustodialWalletClick', walletConnector);
|
|
100
100
|
const twoStepAuthentication = requiresTwoStepAuthentication(walletConnector);
|
|
@@ -129,7 +129,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
129
129
|
const attemptConnection = () => {
|
|
130
130
|
onConnectOnly({ shouldShowPendingConnectView: false, walletConnector });
|
|
131
131
|
};
|
|
132
|
-
|
|
132
|
+
pushView('mobile-wallet-redirect-view', { onRetry: attemptConnection });
|
|
133
133
|
attemptConnection();
|
|
134
134
|
});
|
|
135
135
|
const handleInstalledExtensionClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -141,7 +141,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
141
141
|
logger.debug('handleUninstalledClick', walletConnector);
|
|
142
142
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
143
143
|
if (!walletConnector.canConnectViaQrCode) {
|
|
144
|
-
|
|
144
|
+
pushView('no-qr-not-installed');
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
147
|
onQrCodeConnect({
|
|
@@ -155,7 +155,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
155
155
|
},
|
|
156
156
|
walletConnector,
|
|
157
157
|
});
|
|
158
|
-
|
|
158
|
+
pushView('qr-code');
|
|
159
159
|
}
|
|
160
160
|
setError(undefined);
|
|
161
161
|
});
|
|
@@ -220,13 +220,13 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
220
220
|
if (authMode !== 'connect-only' && isMetamask) {
|
|
221
221
|
try {
|
|
222
222
|
setSelectedWalletConnectorKey(walletConnector.key);
|
|
223
|
-
|
|
223
|
+
pushView('pending-connect');
|
|
224
224
|
yield walletConnector.chooseAccountsToConnect();
|
|
225
225
|
}
|
|
226
226
|
catch (error) {
|
|
227
227
|
if (error instanceof UserRejectedRequestError) {
|
|
228
228
|
setErrorMessage('connection_rejected');
|
|
229
|
-
|
|
229
|
+
clearStackAndPushInitialView();
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
@@ -238,13 +238,13 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
238
238
|
handleAlreadyConnectedWallet(walletConnector);
|
|
239
239
|
}
|
|
240
240
|
else if (walletConnector.canConnectViaCustodialService) {
|
|
241
|
-
// providers like blocto and dapper
|
|
241
|
+
// providers like coinbase, blocto and dapper
|
|
242
242
|
handleCustodialWalletClick(walletConnector);
|
|
243
243
|
}
|
|
244
244
|
else if (isMobile()) {
|
|
245
245
|
// mobile wallets
|
|
246
246
|
if (walletConnector.key === 'walletconnect') {
|
|
247
|
-
|
|
247
|
+
pushView('wallet-connect-mobile-wallets-list');
|
|
248
248
|
}
|
|
249
249
|
else {
|
|
250
250
|
handleMobileWalletClick(walletConnector);
|
|
@@ -95,33 +95,25 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
95
95
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
96
96
|
|
|
97
97
|
const useWalletItemActions = () => {
|
|
98
|
+
const { setMultiWalletWidgetState, authMode } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
99
|
const { onlyConnectUser } = useConnectAndSignSplitSteps.useConnectAndSignSplitSteps();
|
|
99
100
|
const connectAndSignWallet = useConnectAndSign.useConnectAndSign();
|
|
100
|
-
const {
|
|
101
|
-
const
|
|
101
|
+
const { pushView } = ViewContext.useViewContext();
|
|
102
|
+
const handleExtensionAndCustodial = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ requiresTwoStepAuthentication, walletConnector, }) {
|
|
103
|
+
if (requiresTwoStepAuthentication || authMode === 'connect-only') {
|
|
104
|
+
pushView('pending-connect');
|
|
105
|
+
yield onlyConnectUser({ walletConnector });
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// See useVerifyOnAwaitingSignature's useEffect for more context.
|
|
109
|
+
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
110
|
+
}
|
|
111
|
+
});
|
|
102
112
|
return useHandleWalletItem.useHandleWalletItem({
|
|
103
113
|
allowAlreadyConnectedWallet: false,
|
|
104
114
|
onConnectOnly: onlyConnectUser,
|
|
105
|
-
onCustodialWallet:
|
|
106
|
-
|
|
107
|
-
yield onlyConnectUser({
|
|
108
|
-
walletConnector,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
113
|
-
}
|
|
114
|
-
setView('pending-signature');
|
|
115
|
-
}),
|
|
116
|
-
onInstalledExtension: (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ walletConnector }) {
|
|
117
|
-
if (authMode === 'connect-only') {
|
|
118
|
-
setView('pending-connect');
|
|
119
|
-
onlyConnectUser({ walletConnector });
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
123
|
-
}
|
|
124
|
-
}),
|
|
115
|
+
onCustodialWallet: handleExtensionAndCustodial,
|
|
116
|
+
onInstalledExtension: handleExtensionAndCustodial,
|
|
125
117
|
onQrCodeConnect: connectAndSignWallet,
|
|
126
118
|
});
|
|
127
119
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { WalletConnectorCore } from '@dynamic-labs/wallet-connector-core';
|
|
1
2
|
export declare const useWalletItemActions: () => {
|
|
2
|
-
handleAlreadyConnectedWallet: (walletConnector:
|
|
3
|
-
handleCustodialWalletClick: (walletConnector:
|
|
4
|
-
handleInstalledExtensionClick: (walletConnector:
|
|
5
|
-
handleMobileWalletClick: (walletConnector:
|
|
6
|
-
handleUninstalledClick: (walletConnector:
|
|
3
|
+
handleAlreadyConnectedWallet: (walletConnector: WalletConnectorCore.WalletConnector) => Promise<void>;
|
|
4
|
+
handleCustodialWalletClick: (walletConnector: WalletConnectorCore.WalletConnector) => Promise<void>;
|
|
5
|
+
handleInstalledExtensionClick: (walletConnector: WalletConnectorCore.WalletConnector) => Promise<void>;
|
|
6
|
+
handleMobileWalletClick: (walletConnector: WalletConnectorCore.WalletConnector) => Promise<void>;
|
|
7
|
+
handleUninstalledClick: (walletConnector: WalletConnectorCore.WalletConnector) => Promise<void>;
|
|
7
8
|
handleWalletItemClick: (wallet: import("../../../shared").WalletOption) => Promise<void>;
|
|
8
9
|
openWallet: import("./useWalletItemActions.types").OpenWalletHandler;
|
|
9
10
|
};
|
|
@@ -91,33 +91,25 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
91
91
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
92
92
|
|
|
93
93
|
const useWalletItemActions = () => {
|
|
94
|
+
const { setMultiWalletWidgetState, authMode } = useInternalDynamicContext();
|
|
94
95
|
const { onlyConnectUser } = useConnectAndSignSplitSteps();
|
|
95
96
|
const connectAndSignWallet = useConnectAndSign();
|
|
96
|
-
const {
|
|
97
|
-
const
|
|
97
|
+
const { pushView } = useViewContext();
|
|
98
|
+
const handleExtensionAndCustodial = (_a) => __awaiter(void 0, [_a], void 0, function* ({ requiresTwoStepAuthentication, walletConnector, }) {
|
|
99
|
+
if (requiresTwoStepAuthentication || authMode === 'connect-only') {
|
|
100
|
+
pushView('pending-connect');
|
|
101
|
+
yield onlyConnectUser({ walletConnector });
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// See useVerifyOnAwaitingSignature's useEffect for more context.
|
|
105
|
+
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
106
|
+
}
|
|
107
|
+
});
|
|
98
108
|
return useHandleWalletItem({
|
|
99
109
|
allowAlreadyConnectedWallet: false,
|
|
100
110
|
onConnectOnly: onlyConnectUser,
|
|
101
|
-
onCustodialWallet:
|
|
102
|
-
|
|
103
|
-
yield onlyConnectUser({
|
|
104
|
-
walletConnector,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
109
|
-
}
|
|
110
|
-
setView('pending-signature');
|
|
111
|
-
}),
|
|
112
|
-
onInstalledExtension: (_b) => __awaiter(void 0, [_b], void 0, function* ({ walletConnector }) {
|
|
113
|
-
if (authMode === 'connect-only') {
|
|
114
|
-
setView('pending-connect');
|
|
115
|
-
onlyConnectUser({ walletConnector });
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
119
|
-
}
|
|
120
|
-
}),
|
|
111
|
+
onCustodialWallet: handleExtensionAndCustodial,
|
|
112
|
+
onInstalledExtension: handleExtensionAndCustodial,
|
|
121
113
|
onQrCodeConnect: connectAndSignWallet,
|
|
122
114
|
});
|
|
123
115
|
};
|
|
@@ -106,7 +106,7 @@ const embeddedWalletsKeys = [
|
|
|
106
106
|
const useWalletOptions = () => {
|
|
107
107
|
const { walletConnectorOptions, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
108
108
|
const walletGroups = walletOptions.useWalletGroups();
|
|
109
|
-
const {
|
|
109
|
+
const { pushView } = ViewContext.useViewContext();
|
|
110
110
|
const { navigateToWalletGroup } = WalletGroupContext.useWalletGroupContext();
|
|
111
111
|
const { handleWalletItemClick } = useWalletItemActions.useWalletItemActions();
|
|
112
112
|
const getFilteredWalletOptions = React.useCallback((filter) => {
|
|
@@ -143,7 +143,7 @@ const useWalletOptions = () => {
|
|
|
143
143
|
}
|
|
144
144
|
else if (walletConnectorCore.isHardwareWalletConnector(walletOption.walletConnector) &&
|
|
145
145
|
walletOption.walletConnector.canConnectWithHardwareWallet()) {
|
|
146
|
-
|
|
146
|
+
pushView('select-hardware-wallet', {
|
|
147
147
|
onSelectWallet: handleWalletItemClick,
|
|
148
148
|
wallet: walletOption,
|
|
149
149
|
});
|
|
@@ -156,7 +156,7 @@ const useWalletOptions = () => {
|
|
|
156
156
|
handleWalletItemClick,
|
|
157
157
|
navigateToWalletGroup,
|
|
158
158
|
setShowAuthFlow,
|
|
159
|
-
|
|
159
|
+
pushView,
|
|
160
160
|
walletConnectorOptions,
|
|
161
161
|
walletGroups,
|
|
162
162
|
]);
|