@dynamic-labs/sdk-react-core 3.0.0-alpha.5 → 3.0.0-alpha.7
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 +40 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +11 -11
- package/src/index.cjs +7 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +4 -1
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.cjs +2 -1
- package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.js +2 -1
- package/src/lib/components/QRCode/QRCode.d.ts +15 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +15 -9
- package/src/lib/context/DynamicContext/DynamicContext.js +15 -9
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +17 -8
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +17 -8
- package/src/lib/context/DynamicContext/types/index.d.ts +4 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +3 -67
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +3 -67
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +3 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +3 -2
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.cjs +128 -0
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.d.ts +6 -0
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.js +122 -0
- package/src/lib/context/WidgetRegistry/index.d.ts +1 -0
- package/src/lib/data/api/externalAuth/externalAuth.d.ts +5 -0
- package/src/lib/data/api/externalAuth/index.d.ts +1 -0
- package/src/lib/data/api/index.d.ts +1 -0
- package/src/lib/data/api/wallets/wallets.cjs +2 -1
- package/src/lib/data/api/wallets/wallets.d.ts +2 -1
- package/src/lib/data/api/wallets/wallets.js +2 -1
- package/src/lib/events/auth.d.ts +1 -0
- package/src/lib/events/dynamicEvents.d.ts +2 -1
- package/src/lib/events/embeddedWallet.d.ts +1 -1
- package/src/lib/events/multiWallet.d.ts +5 -0
- package/src/lib/locale/en/translation.cjs +4 -4
- package/src/lib/locale/en/translation.d.ts +2 -2
- package/src/lib/locale/en/translation.js +4 -4
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +1 -3
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/index.d.ts +1 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.cjs +28 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.d.ts +1 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.js +24 -0
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +2 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +2 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs +20 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +2 -2
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.js +20 -1
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +6 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +6 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +1 -2
- package/src/lib/utils/hooks/useExternalAuth/index.d.ts +1 -0
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.d.ts +9 -0
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +4 -7
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +4 -7
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +6 -2
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +6 -2
- package/src/lib/utils/hooks/useRefreshUser/index.d.ts +1 -0
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.cjs +90 -0
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.d.ts +8 -0
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.js +86 -0
- package/src/lib/utils/hooks/useSwitchNetwork/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.cjs +26 -0
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.d.ts +5 -0
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.js +22 -0
- package/src/lib/utils/hooks/useSwitchWallet/useSwitchWallet.cjs +1 -1
- package/src/lib/utils/hooks/useSwitchWallet/useSwitchWallet.js +1 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +4 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +4 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +7 -6
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +7 -6
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.cjs +1 -1
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.js +1 -1
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +44 -27
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +45 -28
- package/src/lib/views/EmailVerification/EmailVerification.cjs +8 -5
- package/src/lib/views/EmailVerification/EmailVerification.js +8 -5
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +4 -14
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +5 -15
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +3 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +3 -1
- package/src/lib/views/WalletList/WalletList.cjs +1 -3
- package/src/lib/views/WalletList/WalletList.js +1 -3
- package/src/lib/views/WalletList/hooks/useTabState.cjs +6 -81
- package/src/lib/views/WalletList/hooks/useTabState.d.ts +6 -3
- package/src/lib/views/WalletList/hooks/useTabState.js +6 -81
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.cjs +5 -5
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.js +5 -5
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.cjs +4 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.js +4 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +2 -2
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +1 -1
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.cjs +0 -22
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.d.ts +0 -2
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.js +0 -18
- package/src/lib/views/WalletList/utils/getInitialTabIndex/index.d.ts +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import '../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../constants/values.js';
|
|
13
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
15
|
+
import '@dynamic-labs/utils';
|
|
16
|
+
import '../../../shared/consts/index.js';
|
|
17
|
+
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../../../_virtual/_tslib.js';
|
|
19
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
21
|
+
import '@dynamic-labs/multi-wallet';
|
|
22
|
+
import 'react-international-phone';
|
|
23
|
+
import '../../../config/ApiEndpoint.js';
|
|
24
|
+
import '@dynamic-labs/store';
|
|
25
|
+
import '../../../locale/locale.js';
|
|
26
|
+
import { refreshUserJwt } from '../../../data/api/user/user.js';
|
|
27
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
28
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
29
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
30
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
31
|
+
import 'react-dom';
|
|
32
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
33
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
34
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
35
|
+
import '@dynamic-labs/types';
|
|
36
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
37
|
+
import 'yup';
|
|
38
|
+
import '../../../context/MockContext/MockContext.js';
|
|
39
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
40
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
41
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
42
|
+
import '@dynamic-labs/rpc-providers';
|
|
43
|
+
import 'react-i18next';
|
|
44
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
45
|
+
import '../../../components/Alert/Alert.js';
|
|
46
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
47
|
+
import '../../../components/IconButton/IconButton.js';
|
|
48
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
49
|
+
import '../../../components/Input/Input.js';
|
|
50
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
51
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
52
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
53
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
54
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
55
|
+
import '../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
56
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
57
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
58
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
59
|
+
import 'react-focus-lock';
|
|
60
|
+
import 'qrcode';
|
|
61
|
+
import 'formik';
|
|
62
|
+
import '../../../views/WalletList/WalletList.js';
|
|
63
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
64
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
65
|
+
import '@hcaptcha/react-hcaptcha';
|
|
66
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
67
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
68
|
+
import '../../../context/MfaSettingsContext/MfaSettingsContext.js';
|
|
69
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
70
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
71
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
72
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
73
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
74
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
75
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Refresh user state
|
|
79
|
+
* @returns A callback function that can be used to refresh the user state
|
|
80
|
+
*/
|
|
81
|
+
const useRefreshUser = () => {
|
|
82
|
+
const { environmentId } = useInternalDynamicContext();
|
|
83
|
+
return useCallback(() => refreshUserJwt({ environmentId }), [environmentId]);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { useRefreshUser };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSwitchNetwork';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var useDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useDynamicContext.cjs');
|
|
9
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
10
|
+
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
11
|
+
|
|
12
|
+
const useSwitchNetwork = () => {
|
|
13
|
+
const { setShowAuthFlow } = useDynamicContext.useDynamicContext();
|
|
14
|
+
const { setView } = ViewContext.useViewContext();
|
|
15
|
+
const switchNetwork = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ wallet, network, }) {
|
|
16
|
+
if (wallet.connector.switchNetworkOnlyFromWallet) {
|
|
17
|
+
setShowAuthFlow(true);
|
|
18
|
+
setView('network-not-supported-manual');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
yield wallet.connector.switchNetwork({ networkChainId: network });
|
|
22
|
+
}), [setShowAuthFlow, setView]);
|
|
23
|
+
return switchNetwork;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.useSwitchNetwork = useSwitchNetwork;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
|
|
5
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
6
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
7
|
+
|
|
8
|
+
const useSwitchNetwork = () => {
|
|
9
|
+
const { setShowAuthFlow } = useDynamicContext();
|
|
10
|
+
const { setView } = useViewContext();
|
|
11
|
+
const switchNetwork = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ wallet, network, }) {
|
|
12
|
+
if (wallet.connector.switchNetworkOnlyFromWallet) {
|
|
13
|
+
setShowAuthFlow(true);
|
|
14
|
+
setView('network-not-supported-manual');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
yield wallet.connector.switchNetwork({ networkChainId: network });
|
|
18
|
+
}), [setShowAuthFlow, setView]);
|
|
19
|
+
return switchNetwork;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { useSwitchNetwork };
|
|
@@ -112,7 +112,7 @@ const useSwitchWallet = () => {
|
|
|
112
112
|
throw new Error(`Wallet with id ${walletId} not found`);
|
|
113
113
|
}
|
|
114
114
|
if (((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === 'unknown') {
|
|
115
|
-
throw new Error("Cannot
|
|
115
|
+
throw new Error("Cannot make this wallet active, since this wallet doesn't have a compatible connector on this device.");
|
|
116
116
|
}
|
|
117
117
|
const { connector } = wallet;
|
|
118
118
|
const email = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((verifiedCredential) => verifiedCredential.format === 'email')) === null || _b === void 0 ? void 0 : _b.email;
|
|
@@ -108,7 +108,7 @@ const useSwitchWallet = () => {
|
|
|
108
108
|
throw new Error(`Wallet with id ${walletId} not found`);
|
|
109
109
|
}
|
|
110
110
|
if (((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === 'unknown') {
|
|
111
|
-
throw new Error("Cannot
|
|
111
|
+
throw new Error("Cannot make this wallet active, since this wallet doesn't have a compatible connector on this device.");
|
|
112
112
|
}
|
|
113
113
|
const { connector } = wallet;
|
|
114
114
|
const email = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((verifiedCredential) => verifiedCredential.format === 'email')) === null || _b === void 0 ? void 0 : _b.email;
|
|
@@ -83,7 +83,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
83
83
|
|
|
84
84
|
const sleepToShowSuccessMessage = () => utils.sleep(1500);
|
|
85
85
|
const useUserAuth = ({ authMethod, }) => {
|
|
86
|
-
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
86
|
+
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
87
87
|
const { view, setView, goToInitialView } = ViewContext.useViewContext();
|
|
88
88
|
const { setLoading } = LoadingContext.useLoadingContext();
|
|
89
89
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
@@ -110,6 +110,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
110
110
|
verifiedUser = verifyResponse;
|
|
111
111
|
}
|
|
112
112
|
onVerifySuccess === null || onVerifySuccess === void 0 ? void 0 : onVerifySuccess(verifiedUser);
|
|
113
|
+
walletConnectorOptions.forEach((walletOption) => {
|
|
114
|
+
walletOption.walletConnector.setVerifiedCredentials(verifiedUser.verifiedCredentials);
|
|
115
|
+
});
|
|
113
116
|
if ((_b = verifiedUser.scope) === null || _b === void 0 ? void 0 : _b.includes('requiresAdditionalAuth')) {
|
|
114
117
|
const devices = yield mfa.getUserMfaDevices({ environmentId });
|
|
115
118
|
if (devices.length === 0) {
|
|
@@ -79,7 +79,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
79
79
|
|
|
80
80
|
const sleepToShowSuccessMessage = () => sleep(1500);
|
|
81
81
|
const useUserAuth = ({ authMethod, }) => {
|
|
82
|
-
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, } = useInternalDynamicContext();
|
|
82
|
+
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, walletConnectorOptions, } = useInternalDynamicContext();
|
|
83
83
|
const { view, setView, goToInitialView } = useViewContext();
|
|
84
84
|
const { setLoading } = useLoadingContext();
|
|
85
85
|
const { setErrorMessage, setError } = useErrorContext();
|
|
@@ -106,6 +106,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
106
106
|
verifiedUser = verifyResponse;
|
|
107
107
|
}
|
|
108
108
|
onVerifySuccess === null || onVerifySuccess === void 0 ? void 0 : onVerifySuccess(verifiedUser);
|
|
109
|
+
walletConnectorOptions.forEach((walletOption) => {
|
|
110
|
+
walletOption.walletConnector.setVerifiedCredentials(verifiedUser.verifiedCredentials);
|
|
111
|
+
});
|
|
109
112
|
if ((_b = verifiedUser.scope) === null || _b === void 0 ? void 0 : _b.includes('requiresAdditionalAuth')) {
|
|
110
113
|
const devices = yield getUserMfaDevices({ environmentId });
|
|
111
114
|
if (devices.length === 0) {
|
|
@@ -80,6 +80,7 @@ require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWi
|
|
|
80
80
|
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
81
81
|
require('../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
82
82
|
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
83
|
+
var logVerboseTroubleshootingMessage = require('../../functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.cjs');
|
|
83
84
|
|
|
84
85
|
const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, }) => {
|
|
85
86
|
const [showQrcodeModal, setShowQrcodeModal] = React.useState(false);
|
|
@@ -93,6 +94,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
93
94
|
walletConnectorOptions,
|
|
94
95
|
});
|
|
95
96
|
}, [user, primaryWalletId, walletConnectorOptions]);
|
|
97
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('linkedWallets', linkedWallets);
|
|
96
98
|
const walletsBasedOnAuthMode = React.useMemo(() => {
|
|
97
99
|
// Before signing the first message we are using connected wallets list
|
|
98
100
|
// This is because we want the first connected wallet to have events applied by useWalletEventListeners
|
|
@@ -112,6 +114,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
112
114
|
}
|
|
113
115
|
return connectedWallets !== null && connectedWallets !== void 0 ? connectedWallets : [];
|
|
114
116
|
}, [authMode, connectedWallets, linkedWallets, user]);
|
|
117
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('walletsBasedOnAuthMode', walletsBasedOnAuthMode);
|
|
115
118
|
/**
|
|
116
119
|
* This useEffect is temporary.
|
|
117
120
|
* While the wallet connectors don't use the event emitter, we need to manually
|
|
@@ -124,16 +127,14 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
124
127
|
}), [walletsBasedOnAuthMode]);
|
|
125
128
|
const { connectedWalletsMap, didConnectedStateLoad } = useWalletsConnectionState.useWalletsConnectionState(walletsBasedOnAuthMode);
|
|
126
129
|
const wallets = React.useMemo(() => walletsBasedOnAuthMode.map((wallet) => (Object.assign(Object.assign({}, wallet), { connected: Boolean(connectedWalletsMap[getWalletIdentifier.getWalletIdentifier(wallet)]) }))), [connectedWalletsMap, walletsBasedOnAuthMode]);
|
|
130
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('wallets', wallets);
|
|
131
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('didConnectedStateLoad', didConnectedStateLoad);
|
|
127
132
|
const { setUserWallets } = UserWalletsContext.useInternalUserWallets();
|
|
128
133
|
// Keep userWallets in sync whenever linkedWallets changes
|
|
129
134
|
React.useEffect(() => {
|
|
130
|
-
|
|
131
|
-
// but that doesn't matter if the wallets list is empty, and if we return early when
|
|
132
|
-
// the wallets list is empty, we'll never set the user wallets correctly after logout
|
|
133
|
-
if (!didConnectedStateLoad.current && wallets.length)
|
|
134
|
-
return;
|
|
135
|
+
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('[useWalletConnectors] will call setUserWallets', wallets);
|
|
135
136
|
setUserWallets((userWallets) => updateUserWalletsFromLinkedWallets.updateUserWalletsFromLinkedWallets(userWallets, wallets));
|
|
136
|
-
}, [
|
|
137
|
+
}, [setUserWallets, wallets]);
|
|
137
138
|
const primaryWallet = React.useMemo(() => { var _a; return (_a = wallets.find((wallet) => wallet.id === primaryWalletId)) !== null && _a !== void 0 ? _a : null; }, [primaryWalletId, wallets]);
|
|
138
139
|
const secondaryWallets = React.useMemo(() => canHaveMultipleWalletsConnected
|
|
139
140
|
? wallets.filter((wallet) => wallet.id !== primaryWalletId)
|
|
@@ -76,6 +76,7 @@ import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWid
|
|
|
76
76
|
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
77
77
|
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
78
78
|
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
79
|
+
import { logVerboseTroubleshootingMessage } from '../../functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.js';
|
|
79
80
|
|
|
80
81
|
const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOptions, multiWalletWidgetState, setDesktopUri, setMultiWalletWidgetState, setQrcodeUri, primaryWalletId, setPrimaryWalletId, user, canHaveMultipleWalletsConnected, }) => {
|
|
81
82
|
const [showQrcodeModal, setShowQrcodeModal] = useState(false);
|
|
@@ -89,6 +90,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
89
90
|
walletConnectorOptions,
|
|
90
91
|
});
|
|
91
92
|
}, [user, primaryWalletId, walletConnectorOptions]);
|
|
93
|
+
logVerboseTroubleshootingMessage('linkedWallets', linkedWallets);
|
|
92
94
|
const walletsBasedOnAuthMode = useMemo(() => {
|
|
93
95
|
// Before signing the first message we are using connected wallets list
|
|
94
96
|
// This is because we want the first connected wallet to have events applied by useWalletEventListeners
|
|
@@ -108,6 +110,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
108
110
|
}
|
|
109
111
|
return connectedWallets !== null && connectedWallets !== void 0 ? connectedWallets : [];
|
|
110
112
|
}, [authMode, connectedWallets, linkedWallets, user]);
|
|
113
|
+
logVerboseTroubleshootingMessage('walletsBasedOnAuthMode', walletsBasedOnAuthMode);
|
|
111
114
|
/**
|
|
112
115
|
* This useEffect is temporary.
|
|
113
116
|
* While the wallet connectors don't use the event emitter, we need to manually
|
|
@@ -120,16 +123,14 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
120
123
|
}), [walletsBasedOnAuthMode]);
|
|
121
124
|
const { connectedWalletsMap, didConnectedStateLoad } = useWalletsConnectionState(walletsBasedOnAuthMode);
|
|
122
125
|
const wallets = useMemo(() => walletsBasedOnAuthMode.map((wallet) => (Object.assign(Object.assign({}, wallet), { connected: Boolean(connectedWalletsMap[getWalletIdentifier(wallet)]) }))), [connectedWalletsMap, walletsBasedOnAuthMode]);
|
|
126
|
+
logVerboseTroubleshootingMessage('wallets', wallets);
|
|
127
|
+
logVerboseTroubleshootingMessage('didConnectedStateLoad', didConnectedStateLoad);
|
|
123
128
|
const { setUserWallets } = useInternalUserWallets();
|
|
124
129
|
// Keep userWallets in sync whenever linkedWallets changes
|
|
125
130
|
useEffect(() => {
|
|
126
|
-
|
|
127
|
-
// but that doesn't matter if the wallets list is empty, and if we return early when
|
|
128
|
-
// the wallets list is empty, we'll never set the user wallets correctly after logout
|
|
129
|
-
if (!didConnectedStateLoad.current && wallets.length)
|
|
130
|
-
return;
|
|
131
|
+
logVerboseTroubleshootingMessage('[useWalletConnectors] will call setUserWallets', wallets);
|
|
131
132
|
setUserWallets((userWallets) => updateUserWalletsFromLinkedWallets(userWallets, wallets));
|
|
132
|
-
}, [
|
|
133
|
+
}, [setUserWallets, wallets]);
|
|
133
134
|
const primaryWallet = useMemo(() => { var _a; return (_a = wallets.find((wallet) => wallet.id === primaryWalletId)) !== null && _a !== void 0 ? _a : null; }, [primaryWalletId, wallets]);
|
|
134
135
|
const secondaryWallets = useMemo(() => canHaveMultipleWalletsConnected
|
|
135
136
|
? wallets.filter((wallet) => wallet.id !== primaryWalletId)
|
|
@@ -17,7 +17,7 @@ const findWallet = (account, walletOptions) => {
|
|
|
17
17
|
}
|
|
18
18
|
// if we cannot find the correct connector for the wallet, we default to the unknown
|
|
19
19
|
// this way the wallet will appear in user wallets, but will not be able to be interacted with
|
|
20
|
-
return ((_a = walletOptions.find((wallet) => walletKey === wallet.key)) !== null && _a !== void 0 ? _a : walletOptions.find((wallet) => wallet.key === '
|
|
20
|
+
return ((_a = walletOptions.find((wallet) => walletKey === wallet.key)) !== null && _a !== void 0 ? _a : walletOptions.find((wallet) => wallet.key === 'fallbackconnector'));
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
exports.findWallet = findWallet;
|
|
@@ -13,7 +13,7 @@ const findWallet = (account, walletOptions) => {
|
|
|
13
13
|
}
|
|
14
14
|
// if we cannot find the correct connector for the wallet, we default to the unknown
|
|
15
15
|
// this way the wallet will appear in user wallets, but will not be able to be interacted with
|
|
16
|
-
return ((_a = walletOptions.find((wallet) => walletKey === wallet.key)) !== null && _a !== void 0 ? _a : walletOptions.find((wallet) => wallet.key === '
|
|
16
|
+
return ((_a = walletOptions.find((wallet) => walletKey === wallet.key)) !== null && _a !== void 0 ? _a : walletOptions.find((wallet) => wallet.key === 'fallbackconnector'));
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export { findWallet };
|
|
@@ -18,7 +18,7 @@ require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
18
18
|
require('../../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
19
19
|
require('@dynamic-labs/utils');
|
|
20
20
|
require('../../../shared/consts/index.cjs');
|
|
21
|
-
require('
|
|
21
|
+
var useDynamicEvents = require('../events/useDynamicEvents/useDynamicEvents.cjs');
|
|
22
22
|
var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWalletConnectorEvent.cjs');
|
|
23
23
|
|
|
24
24
|
const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, }) => {
|
|
@@ -33,10 +33,29 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
33
33
|
}
|
|
34
34
|
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
37
|
+
const linkedSecondaryWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
38
|
+
// this means the user is linking a new account, so we need proof of ownership...
|
|
39
|
+
if (!linkedSecondaryWallet) {
|
|
40
|
+
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
41
|
+
if (isPrimaryWallet && primaryWallet) {
|
|
42
|
+
setSelectedWalletConnectorKey(primaryWallet.connector.key);
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
47
|
+
setSelectedWalletWithAction(null);
|
|
48
|
+
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
49
|
+
setMultiWalletWidgetState('idle');
|
|
50
|
+
}, [
|
|
51
|
+
setMultiWalletWidgetState,
|
|
52
|
+
primaryWallet,
|
|
53
|
+
secondaryWallets,
|
|
54
|
+
setSelectedWalletConnectorKey,
|
|
55
|
+
setSelectedWalletWithAction,
|
|
56
|
+
setPrimaryWalletId,
|
|
57
|
+
]);
|
|
58
|
+
const calculatePrimaryWalletMultiWalletStateFromAccounts = React.useCallback(({ accounts }) => {
|
|
40
59
|
// change the api here
|
|
41
60
|
if (!primaryWallet)
|
|
42
61
|
return;
|
|
@@ -75,6 +94,26 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
75
94
|
logger.logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
|
|
76
95
|
setMultiWalletWidgetState('idle');
|
|
77
96
|
}
|
|
97
|
+
}, [
|
|
98
|
+
authMode,
|
|
99
|
+
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
100
|
+
multiWallet,
|
|
101
|
+
multiWalletWidgetState,
|
|
102
|
+
primaryWallet,
|
|
103
|
+
refreshConnectedWallet,
|
|
104
|
+
secondaryWallets,
|
|
105
|
+
setMultiWalletWidgetState,
|
|
106
|
+
setPrimaryWalletId,
|
|
107
|
+
setSelectedWalletConnectorKey,
|
|
108
|
+
setSelectedWalletWithAction,
|
|
109
|
+
user,
|
|
110
|
+
]);
|
|
111
|
+
useDynamicEvents.useInternalDynamicEvents('triggerComputePrimaryWalletMultiWalletStateFromAccounts', calculatePrimaryWalletMultiWalletStateFromAccounts);
|
|
112
|
+
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'accountChange', ({ accounts }) => {
|
|
113
|
+
logger.logger.debug('primary wallet account change', {
|
|
114
|
+
accounts,
|
|
115
|
+
});
|
|
116
|
+
calculatePrimaryWalletMultiWalletStateFromAccounts({ accounts });
|
|
78
117
|
});
|
|
79
118
|
const uniqueNonPrimaryWallets = React.useMemo(() => {
|
|
80
119
|
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
@@ -118,28 +157,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
118
157
|
}
|
|
119
158
|
}
|
|
120
159
|
});
|
|
121
|
-
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
122
|
-
const linkedSecondaryWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
123
|
-
// this means the user is linking a new account, so we need proof of ownership...
|
|
124
|
-
if (!linkedSecondaryWallet) {
|
|
125
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
126
|
-
if (isPrimaryWallet && primaryWallet) {
|
|
127
|
-
setSelectedWalletConnectorKey(primaryWallet.connector.key);
|
|
128
|
-
}
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
132
|
-
setSelectedWalletWithAction(null);
|
|
133
|
-
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
134
|
-
setMultiWalletWidgetState('idle');
|
|
135
|
-
}, [
|
|
136
|
-
setMultiWalletWidgetState,
|
|
137
|
-
primaryWallet,
|
|
138
|
-
secondaryWallets,
|
|
139
|
-
setSelectedWalletConnectorKey,
|
|
140
|
-
setSelectedWalletWithAction,
|
|
141
|
-
setPrimaryWalletId,
|
|
142
|
-
]);
|
|
143
160
|
};
|
|
144
161
|
|
|
145
162
|
exports.useWalletEventListeners = useWalletEventListeners;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import {
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
4
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -14,7 +14,7 @@ import '../../../shared/utils/classes/storage/localStorage.js';
|
|
|
14
14
|
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
15
15
|
import '@dynamic-labs/utils';
|
|
16
16
|
import '../../../shared/consts/index.js';
|
|
17
|
-
import '
|
|
17
|
+
import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicEvents.js';
|
|
18
18
|
import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
19
19
|
|
|
20
20
|
const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, }) => {
|
|
@@ -29,10 +29,29 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
29
29
|
}
|
|
30
30
|
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
33
|
+
const linkedSecondaryWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
34
|
+
// this means the user is linking a new account, so we need proof of ownership...
|
|
35
|
+
if (!linkedSecondaryWallet) {
|
|
36
|
+
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
37
|
+
if (isPrimaryWallet && primaryWallet) {
|
|
38
|
+
setSelectedWalletConnectorKey(primaryWallet.connector.key);
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
43
|
+
setSelectedWalletWithAction(null);
|
|
44
|
+
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
45
|
+
setMultiWalletWidgetState('idle');
|
|
46
|
+
}, [
|
|
47
|
+
setMultiWalletWidgetState,
|
|
48
|
+
primaryWallet,
|
|
49
|
+
secondaryWallets,
|
|
50
|
+
setSelectedWalletConnectorKey,
|
|
51
|
+
setSelectedWalletWithAction,
|
|
52
|
+
setPrimaryWalletId,
|
|
53
|
+
]);
|
|
54
|
+
const calculatePrimaryWalletMultiWalletStateFromAccounts = useCallback(({ accounts }) => {
|
|
36
55
|
// change the api here
|
|
37
56
|
if (!primaryWallet)
|
|
38
57
|
return;
|
|
@@ -71,6 +90,26 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
71
90
|
logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
|
|
72
91
|
setMultiWalletWidgetState('idle');
|
|
73
92
|
}
|
|
93
|
+
}, [
|
|
94
|
+
authMode,
|
|
95
|
+
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
96
|
+
multiWallet,
|
|
97
|
+
multiWalletWidgetState,
|
|
98
|
+
primaryWallet,
|
|
99
|
+
refreshConnectedWallet,
|
|
100
|
+
secondaryWallets,
|
|
101
|
+
setMultiWalletWidgetState,
|
|
102
|
+
setPrimaryWalletId,
|
|
103
|
+
setSelectedWalletConnectorKey,
|
|
104
|
+
setSelectedWalletWithAction,
|
|
105
|
+
user,
|
|
106
|
+
]);
|
|
107
|
+
useInternalDynamicEvents('triggerComputePrimaryWalletMultiWalletStateFromAccounts', calculatePrimaryWalletMultiWalletStateFromAccounts);
|
|
108
|
+
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'accountChange', ({ accounts }) => {
|
|
109
|
+
logger.debug('primary wallet account change', {
|
|
110
|
+
accounts,
|
|
111
|
+
});
|
|
112
|
+
calculatePrimaryWalletMultiWalletStateFromAccounts({ accounts });
|
|
74
113
|
});
|
|
75
114
|
const uniqueNonPrimaryWallets = useMemo(() => {
|
|
76
115
|
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
@@ -114,28 +153,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
114
153
|
}
|
|
115
154
|
}
|
|
116
155
|
});
|
|
117
|
-
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
118
|
-
const linkedSecondaryWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
119
|
-
// this means the user is linking a new account, so we need proof of ownership...
|
|
120
|
-
if (!linkedSecondaryWallet) {
|
|
121
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
122
|
-
if (isPrimaryWallet && primaryWallet) {
|
|
123
|
-
setSelectedWalletConnectorKey(primaryWallet.connector.key);
|
|
124
|
-
}
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
128
|
-
setSelectedWalletWithAction(null);
|
|
129
|
-
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
130
|
-
setMultiWalletWidgetState('idle');
|
|
131
|
-
}, [
|
|
132
|
-
setMultiWalletWidgetState,
|
|
133
|
-
primaryWallet,
|
|
134
|
-
secondaryWallets,
|
|
135
|
-
setSelectedWalletConnectorKey,
|
|
136
|
-
setSelectedWalletWithAction,
|
|
137
|
-
setPrimaryWalletId,
|
|
138
|
-
]);
|
|
139
156
|
};
|
|
140
157
|
|
|
141
158
|
export { useWalletEventListeners };
|
|
@@ -102,7 +102,7 @@ require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
|
102
102
|
const SECONDS_TO_RETRY = 15;
|
|
103
103
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
104
104
|
var _a, _b, _c, _d;
|
|
105
|
-
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
105
|
+
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
106
106
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
107
107
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
108
108
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
@@ -177,19 +177,21 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
177
177
|
if (!embeddedWalletVerifiedCredential) {
|
|
178
178
|
throw new Error('Could not find an embedded wallet');
|
|
179
179
|
}
|
|
180
|
+
const walletOption = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.find((option) => option.key === embeddedWalletVerifiedCredential.walletName);
|
|
181
|
+
if (!(walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector)) {
|
|
182
|
+
throw new Error('Could not find connector for embedded wallet');
|
|
183
|
+
}
|
|
180
184
|
const wallet = {
|
|
181
185
|
address: embeddedWalletVerifiedCredential.address,
|
|
182
186
|
authenticated: false,
|
|
183
187
|
chain: embeddedWalletVerifiedCredential.chain,
|
|
184
188
|
connected: true,
|
|
185
|
-
|
|
186
|
-
// @ts-ignore
|
|
187
|
-
connector: undefined,
|
|
189
|
+
connector: walletOption.walletConnector,
|
|
188
190
|
id: embeddedWalletVerifiedCredential.id,
|
|
189
191
|
key: (_k = embeddedWalletVerifiedCredential.walletName) !== null && _k !== void 0 ? _k : '',
|
|
190
192
|
};
|
|
191
193
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
192
|
-
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential,
|
|
194
|
+
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, user);
|
|
193
195
|
}
|
|
194
196
|
if (isUsingPregeneratedWallets || !isAutomaticWalletCreation) {
|
|
195
197
|
setShowAuthFlow(false);
|
|
@@ -210,6 +212,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
210
212
|
setShowAuthFlow,
|
|
211
213
|
setView,
|
|
212
214
|
user,
|
|
215
|
+
walletConnectorOptions,
|
|
213
216
|
]);
|
|
214
217
|
const handleEmailVerification = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
215
218
|
setError(undefined);
|
|
@@ -98,7 +98,7 @@ import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
|
98
98
|
const SECONDS_TO_RETRY = 15;
|
|
99
99
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
100
100
|
var _a, _b, _c, _d;
|
|
101
|
-
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, } = useInternalDynamicContext();
|
|
101
|
+
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, walletConnectorOptions, } = useInternalDynamicContext();
|
|
102
102
|
const { setView, goToInitialView } = useViewContext();
|
|
103
103
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
104
104
|
const { loading, setLoading } = useLoadingContext();
|
|
@@ -173,19 +173,21 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
173
173
|
if (!embeddedWalletVerifiedCredential) {
|
|
174
174
|
throw new Error('Could not find an embedded wallet');
|
|
175
175
|
}
|
|
176
|
+
const walletOption = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.find((option) => option.key === embeddedWalletVerifiedCredential.walletName);
|
|
177
|
+
if (!(walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector)) {
|
|
178
|
+
throw new Error('Could not find connector for embedded wallet');
|
|
179
|
+
}
|
|
176
180
|
const wallet = {
|
|
177
181
|
address: embeddedWalletVerifiedCredential.address,
|
|
178
182
|
authenticated: false,
|
|
179
183
|
chain: embeddedWalletVerifiedCredential.chain,
|
|
180
184
|
connected: true,
|
|
181
|
-
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
connector: undefined,
|
|
185
|
+
connector: walletOption.walletConnector,
|
|
184
186
|
id: embeddedWalletVerifiedCredential.id,
|
|
185
187
|
key: (_k = embeddedWalletVerifiedCredential.walletName) !== null && _k !== void 0 ? _k : '',
|
|
186
188
|
};
|
|
187
189
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
188
|
-
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential,
|
|
190
|
+
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, user);
|
|
189
191
|
}
|
|
190
192
|
if (isUsingPregeneratedWallets || !isAutomaticWalletCreation) {
|
|
191
193
|
setShowAuthFlow(false);
|
|
@@ -206,6 +208,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
206
208
|
setShowAuthFlow,
|
|
207
209
|
setView,
|
|
208
210
|
user,
|
|
211
|
+
walletConnectorOptions,
|
|
209
212
|
]);
|
|
210
213
|
const handleEmailVerification = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
211
214
|
setError(undefined);
|