@dynamic-labs/sdk-react-core 0.18.100-viem.0 → 0.18.100-viem.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -1
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +10 -10
- package/src/index.cjs +4 -0
- package/src/index.js +2 -0
- package/src/lib/Main.cjs +5 -0
- package/src/lib/Main.js +5 -0
- package/src/lib/components/Button/Button.cjs +10 -7
- package/src/lib/components/Button/Button.js +10 -7
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
- package/src/lib/components/ListTile/ListTile.cjs +1 -1
- package/src/lib/components/ListTile/ListTile.js +1 -1
- package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
- package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +1 -1
- package/src/lib/components/MenuList/Dropdown/Dropdown.js +1 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +6 -2
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +2 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +6 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +2 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
- package/src/lib/components/UserProfile/UserProfile.js +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +15 -4
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -6
- package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
- package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
- package/src/lib/context/DynamicContext/internalEvents/index.d.ts +2 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.cjs +14 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.d.ts +8 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.js +6 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +6 -3
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/SendBalanceContext/SendBalanceContext.types.d.ts +2 -2
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +2 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +2 -1
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/data/api.cjs +33 -1
- package/src/lib/data/api.d.ts +3 -1
- package/src/lib/data/api.js +34 -4
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +10 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +10 -2
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.d.ts +2 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +11 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +11 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +6 -3
- package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
- package/src/lib/shared/assets/double-arrow-right.js +29 -0
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs +28 -2
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js +28 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/errors.cjs +7 -0
- package/src/lib/utils/constants/errors.d.ts +1 -0
- package/src/lib/utils/constants/errors.js +3 -0
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -0
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +2 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
- package/src/lib/utils/functions/digestSHA256/digestSHA256.cjs +11 -0
- package/src/lib/utils/functions/digestSHA256/digestSHA256.d.ts +1 -0
- package/src/lib/utils/functions/digestSHA256/digestSHA256.js +7 -0
- package/src/lib/utils/functions/digestSHA256/index.d.ts +1 -0
- package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.cjs +14 -0
- package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.d.ts +1 -0
- package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.js +10 -0
- package/src/lib/utils/functions/encodeBase64URL/index.d.ts +1 -0
- package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.cjs +33 -0
- package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.d.ts +1 -0
- package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.js +29 -0
- package/src/lib/utils/functions/getRedirectURIOrigin/index.d.ts +1 -0
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
- package/src/lib/utils/functions/index.d.ts +7 -0
- package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
- package/src/lib/utils/functions/randomString/index.d.ts +1 -0
- package/src/lib/utils/functions/randomString/randomString.cjs +14 -0
- package/src/lib/utils/functions/randomString/randomString.d.ts +1 -0
- package/src/lib/utils/functions/randomString/randomString.js +10 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +1 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +48 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +18 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +43 -0
- package/src/lib/utils/functions/stringifyURIQuery/index.d.ts +1 -0
- package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.cjs +13 -0
- package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.d.ts +1 -0
- package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.js +9 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +10 -4
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +11 -5
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +15 -9
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +15 -9
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +16 -18
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +17 -19
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +7 -6
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +7 -6
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -2
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +2 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +149 -26
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +151 -28
- package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +31 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +27 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +56 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +52 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +9 -3
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +9 -3
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +13 -4
- package/src/lib/views/EmailUpdate/EmailUpdate.js +13 -4
- package/src/lib/views/EmailVerification/EmailVerification.cjs +12 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +14 -3
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +111 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +107 -0
- package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +4 -2
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +4 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +4 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +4 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +14 -35
- package/src/lib/views/SendBalanceView/SendBalanceView.d.ts +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +15 -36
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +67 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +63 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
- package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +31 -8
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.d.ts +4 -3
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +32 -9
- package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.cjs +69 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.js +65 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +6 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +1 -0
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +1 -0
- package/src/lib/views/WalletList/WalletList.cjs +4 -1
- package/src/lib/views/WalletList/WalletList.js +4 -1
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +1 -1
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +1 -1
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
- package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +4 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +4 -1
- package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.cjs +13 -0
- package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.d.ts +2 -0
- package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.js +9 -0
- package/src/lib/widgets/OAuthIFrameContainer/index.d.ts +1 -0
- package/src/lib/widgets/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +0 -104
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -17
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +0 -100
|
@@ -41,6 +41,7 @@ require('../../../components/Alert/Alert.cjs');
|
|
|
41
41
|
require('../../../context/MockContext/MockContext.cjs');
|
|
42
42
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
43
43
|
require('../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
44
|
+
var Tooltip = require('../../../components/Tooltip/Tooltip.cjs');
|
|
44
45
|
require('../../../components/Popper/Popper/Popper.cjs');
|
|
45
46
|
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
46
47
|
require('yup');
|
|
@@ -63,6 +64,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
|
|
|
63
64
|
else if (name === 'policiesConsent') {
|
|
64
65
|
return (jsxRuntime.jsx("div", { role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container', children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxRuntime.jsxs("div", { className: 'user-data-fields__consent-checkbox', children: [jsxRuntime.jsx(formik.Field, { as: Checkbox.Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsxRuntime.jsx("label", { htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', children: component }) })] }, `policiesConsent_${index}`))) }, 'policiesConsentGroup'));
|
|
65
66
|
}
|
|
67
|
+
else if (name === 'email' && !enabled) {
|
|
68
|
+
return (jsxRuntime.jsx(Tooltip.Tooltip, { content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip', children: jsxRuntime.jsx(formik.Field, { disabled: true, as: Input.Input, type: type, id: name, name: name, label: label }, name) }, 'disabled-email-tooltip'));
|
|
69
|
+
}
|
|
66
70
|
else {
|
|
67
71
|
return (jsxRuntime.jsx(formik.Field, { disabled: !enabled, as: Input.Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage.getDisplayErrorMessage(label, errors[name]) }, name));
|
|
68
72
|
}
|
|
@@ -37,6 +37,7 @@ import '../../../components/Alert/Alert.js';
|
|
|
37
37
|
import '../../../context/MockContext/MockContext.js';
|
|
38
38
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
39
39
|
import '../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
40
|
+
import { Tooltip } from '../../../components/Tooltip/Tooltip.js';
|
|
40
41
|
import '../../../components/Popper/Popper/Popper.js';
|
|
41
42
|
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
42
43
|
import 'yup';
|
|
@@ -59,6 +60,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
|
|
|
59
60
|
else if (name === 'policiesConsent') {
|
|
60
61
|
return (jsx("div", { role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container', children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxs("div", { className: 'user-data-fields__consent-checkbox', children: [jsx(Field, { as: Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsx("label", { htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label', children: jsx(Typography, { variant: 'body_small', color: 'secondary', children: component }) })] }, `policiesConsent_${index}`))) }, 'policiesConsentGroup'));
|
|
61
62
|
}
|
|
63
|
+
else if (name === 'email' && !enabled) {
|
|
64
|
+
return (jsx(Tooltip, { content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip', children: jsx(Field, { disabled: true, as: Input, type: type, id: name, name: name, label: label }, name) }, 'disabled-email-tooltip'));
|
|
65
|
+
}
|
|
62
66
|
else {
|
|
63
67
|
return (jsx(Field, { disabled: !enabled, as: Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage(label, errors[name]) }, name));
|
|
64
68
|
}
|
|
@@ -6,6 +6,7 @@ var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var iconic = require('@dynamic-labs/iconic');
|
|
9
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
10
|
var Typography = require('../../components/Typography/Typography.cjs');
|
|
10
11
|
require('@dynamic-labs/sdk-api');
|
|
11
12
|
var logger = require('../../shared/logger.cjs');
|
|
@@ -13,7 +14,6 @@ require('@dynamic-labs/wallet-connector-core');
|
|
|
13
14
|
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
14
15
|
var chevronLeft = require('../../shared/assets/chevron-left.cjs');
|
|
15
16
|
require('@dynamic-labs/wallet-book');
|
|
16
|
-
require('@dynamic-labs/utils');
|
|
17
17
|
require('../../utils/constants/colors.cjs');
|
|
18
18
|
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
19
|
require('viem');
|
|
@@ -55,18 +55,23 @@ const EmailUpdate = () => {
|
|
|
55
55
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
56
56
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
57
57
|
const { email, setEmail, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
58
|
-
const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
|
+
const { environmentId, handleLogOut, onboardingOnlyJwt, authToken } = useInternalDynamicContext.useInternalDynamicContext();
|
|
59
|
+
const [emailError, setEmailError] = React.useState(undefined);
|
|
59
60
|
const handleBackClick = () => {
|
|
60
61
|
setView('verify-email');
|
|
61
62
|
setError(undefined);
|
|
62
63
|
};
|
|
64
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
65
|
+
// If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
|
|
66
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
63
67
|
const handleEmailUpdate = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
68
|
try {
|
|
65
69
|
if (!updatedEmail) {
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
72
|
+
setEmailError(undefined);
|
|
68
73
|
setLoading(true);
|
|
69
|
-
const { emailVerification } = yield api.updateUserProfileFields(
|
|
74
|
+
const { emailVerification } = yield api.updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
|
|
70
75
|
if (!emailVerification) {
|
|
71
76
|
yield handleLogOut();
|
|
72
77
|
goToInitialView();
|
|
@@ -79,6 +84,10 @@ const EmailUpdate = () => {
|
|
|
79
84
|
}
|
|
80
85
|
catch (error) {
|
|
81
86
|
logger.logger.debug(error);
|
|
87
|
+
if (error instanceof utils.EmailAlreadyExistsError) {
|
|
88
|
+
setEmailError('Email already exists');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
82
91
|
setErrorMessage(error.code);
|
|
83
92
|
}
|
|
84
93
|
finally {
|
|
@@ -90,7 +99,7 @@ const EmailUpdate = () => {
|
|
|
90
99
|
width: '3.125rem',
|
|
91
100
|
}, className: 'email-update__icon' }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'title', className: 'email-update__title', children: "Update Email" }), jsxRuntime.jsxs("div", { className: 'email-update__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', children: "Your current email address is" }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: email })] }), jsxRuntime.jsx(Input.Input, { id: 'email_field', onChange: (e) => {
|
|
92
101
|
setUpdatedEmail(e.target.value);
|
|
93
|
-
}, type: 'email', label: 'Email address', className: 'email-update__input' }), jsxRuntime.jsx(Button.Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
102
|
+
}, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsxRuntime.jsx(Button.Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
94
103
|
};
|
|
95
104
|
|
|
96
105
|
exports.EmailUpdate = EmailUpdate;
|
|
@@ -2,6 +2,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
|
|
5
|
+
import { EmailAlreadyExistsError } from '@dynamic-labs/utils';
|
|
5
6
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
6
7
|
import '@dynamic-labs/sdk-api';
|
|
7
8
|
import { logger } from '../../shared/logger.js';
|
|
@@ -9,7 +10,6 @@ import '@dynamic-labs/wallet-connector-core';
|
|
|
9
10
|
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
10
11
|
import { ReactComponent as SvgChevronLeft } from '../../shared/assets/chevron-left.js';
|
|
11
12
|
import '@dynamic-labs/wallet-book';
|
|
12
|
-
import '@dynamic-labs/utils';
|
|
13
13
|
import '../../utils/constants/colors.js';
|
|
14
14
|
import '../../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import 'viem';
|
|
@@ -51,18 +51,23 @@ const EmailUpdate = () => {
|
|
|
51
51
|
const { loading, setLoading } = useLoadingContext();
|
|
52
52
|
const { setView, goToInitialView } = useViewContext();
|
|
53
53
|
const { email, setEmail, setVerificationUUID } = useEmailVerificationContext();
|
|
54
|
-
const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext();
|
|
54
|
+
const { environmentId, handleLogOut, onboardingOnlyJwt, authToken } = useInternalDynamicContext();
|
|
55
|
+
const [emailError, setEmailError] = useState(undefined);
|
|
55
56
|
const handleBackClick = () => {
|
|
56
57
|
setView('verify-email');
|
|
57
58
|
setError(undefined);
|
|
58
59
|
};
|
|
60
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
61
|
+
// If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
|
|
62
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
59
63
|
const handleEmailUpdate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
64
|
try {
|
|
61
65
|
if (!updatedEmail) {
|
|
62
66
|
return;
|
|
63
67
|
}
|
|
68
|
+
setEmailError(undefined);
|
|
64
69
|
setLoading(true);
|
|
65
|
-
const { emailVerification } = yield updateUserProfileFields(
|
|
70
|
+
const { emailVerification } = yield updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
|
|
66
71
|
if (!emailVerification) {
|
|
67
72
|
yield handleLogOut();
|
|
68
73
|
goToInitialView();
|
|
@@ -75,6 +80,10 @@ const EmailUpdate = () => {
|
|
|
75
80
|
}
|
|
76
81
|
catch (error) {
|
|
77
82
|
logger.debug(error);
|
|
83
|
+
if (error instanceof EmailAlreadyExistsError) {
|
|
84
|
+
setEmailError('Email already exists');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
78
87
|
setErrorMessage(error.code);
|
|
79
88
|
}
|
|
80
89
|
finally {
|
|
@@ -86,7 +95,7 @@ const EmailUpdate = () => {
|
|
|
86
95
|
width: '3.125rem',
|
|
87
96
|
}, className: 'email-update__icon' }), jsx(Typography, { weight: 'medium', variant: 'title', className: 'email-update__title', children: "Update Email" }), jsxs("div", { className: 'email-update__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', children: "Your current email address is" }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: email })] }), jsx(Input, { id: 'email_field', onChange: (e) => {
|
|
88
97
|
setUpdatedEmail(e.target.value);
|
|
89
|
-
}, type: 'email', label: 'Email address', className: 'email-update__input' }), jsx(Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
98
|
+
}, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsx(Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
90
99
|
};
|
|
91
100
|
|
|
92
101
|
export { EmailUpdate };
|
|
@@ -69,7 +69,7 @@ const EmailVerification = () => {
|
|
|
69
69
|
const { view, setView, goToInitialView } = ViewContext.useViewContext();
|
|
70
70
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
71
71
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
72
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
72
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
73
73
|
const { email, verificationUUID, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
74
74
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
75
75
|
const { remainingSeconds, startCountdown } = useCountdown.useCountdown({
|
|
@@ -79,6 +79,11 @@ const EmailVerification = () => {
|
|
|
79
79
|
const isLoginView = view === 'login-with-email-verification';
|
|
80
80
|
const { verifyEmail } = useEmailVerificationRequest.useEmailVerificationRequest();
|
|
81
81
|
const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback.useCreateUserProfileByJWTCallback();
|
|
82
|
+
// Set verification in progress
|
|
83
|
+
// It should be disabled by either clearStatesOnBackClick, the close button, or onAuthSuccess
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
setIsVerificationInProgress(true);
|
|
86
|
+
}, []);
|
|
82
87
|
const handleComplete = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
83
88
|
setError(undefined);
|
|
84
89
|
setLoading(true);
|
|
@@ -101,6 +106,11 @@ const EmailVerification = () => {
|
|
|
101
106
|
}
|
|
102
107
|
catch (error) {
|
|
103
108
|
logger.logger.debug(error);
|
|
109
|
+
// Handle the case where the user has already an account with the email
|
|
110
|
+
if (error instanceof utils.UserHasAccountWithEmailError) {
|
|
111
|
+
setView('merge-user-accounts');
|
|
112
|
+
return; // Early return to not show the error message
|
|
113
|
+
}
|
|
104
114
|
setErrorMessage(error.code);
|
|
105
115
|
}
|
|
106
116
|
finally {
|
|
@@ -119,6 +129,7 @@ const EmailVerification = () => {
|
|
|
119
129
|
setOnboardingOnlyJwt,
|
|
120
130
|
setCallback,
|
|
121
131
|
setErrorMessage,
|
|
132
|
+
setView,
|
|
122
133
|
]);
|
|
123
134
|
const handleEmailLogin = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
124
135
|
setError(undefined);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { useState, useCallback } from 'react';
|
|
3
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
4
4
|
import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
|
|
5
|
-
import { NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
5
|
+
import { UserHasAccountWithEmailError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
6
6
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
7
7
|
import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
8
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
@@ -65,7 +65,7 @@ const EmailVerification = () => {
|
|
|
65
65
|
const { view, setView, goToInitialView } = useViewContext();
|
|
66
66
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
67
67
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
68
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
68
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
69
69
|
const { email, verificationUUID, setVerificationUUID } = useEmailVerificationContext();
|
|
70
70
|
const { loading, setLoading } = useLoadingContext();
|
|
71
71
|
const { remainingSeconds, startCountdown } = useCountdown({
|
|
@@ -75,6 +75,11 @@ const EmailVerification = () => {
|
|
|
75
75
|
const isLoginView = view === 'login-with-email-verification';
|
|
76
76
|
const { verifyEmail } = useEmailVerificationRequest();
|
|
77
77
|
const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback();
|
|
78
|
+
// Set verification in progress
|
|
79
|
+
// It should be disabled by either clearStatesOnBackClick, the close button, or onAuthSuccess
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
setIsVerificationInProgress(true);
|
|
82
|
+
}, []);
|
|
78
83
|
const handleComplete = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
84
|
setError(undefined);
|
|
80
85
|
setLoading(true);
|
|
@@ -97,6 +102,11 @@ const EmailVerification = () => {
|
|
|
97
102
|
}
|
|
98
103
|
catch (error) {
|
|
99
104
|
logger.debug(error);
|
|
105
|
+
// Handle the case where the user has already an account with the email
|
|
106
|
+
if (error instanceof UserHasAccountWithEmailError) {
|
|
107
|
+
setView('merge-user-accounts');
|
|
108
|
+
return; // Early return to not show the error message
|
|
109
|
+
}
|
|
100
110
|
setErrorMessage(error.code);
|
|
101
111
|
}
|
|
102
112
|
finally {
|
|
@@ -115,6 +125,7 @@ const EmailVerification = () => {
|
|
|
115
125
|
setOnboardingOnlyJwt,
|
|
116
126
|
setCallback,
|
|
117
127
|
setErrorMessage,
|
|
128
|
+
setView,
|
|
118
129
|
]);
|
|
119
130
|
const handleEmailLogin = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
131
|
setError(undefined);
|
|
@@ -47,7 +47,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
47
47
|
const EmailWalletOTPVerificationView = () => {
|
|
48
48
|
const { setView } = ViewContext.useViewContext();
|
|
49
49
|
const [error, setError] = React.useState();
|
|
50
|
-
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
50
|
+
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
51
51
|
if (!emailWalletConnector ||
|
|
52
52
|
!walletConnectorCore.isEmailOTPWalletConnector(emailWalletConnector)) {
|
|
53
53
|
throw new Error('Current wallet is not EmailWalletConnector');
|
|
@@ -61,10 +61,11 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
61
61
|
clearStatesOnBackClick();
|
|
62
62
|
setView('login-with-email-or-wallet');
|
|
63
63
|
};
|
|
64
|
+
const handleOnClickClose = () => setShowAuthFlow(false);
|
|
64
65
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
65
66
|
onFailure: (error) => setError(error),
|
|
66
67
|
});
|
|
67
|
-
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
|
|
68
|
+
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true, successBannerText: 'Sign in to access your email based wallet' }));
|
|
68
69
|
};
|
|
69
70
|
|
|
70
71
|
exports.EmailWalletOTPVerificationView = EmailWalletOTPVerificationView;
|
|
@@ -43,7 +43,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
43
43
|
const EmailWalletOTPVerificationView = () => {
|
|
44
44
|
const { setView } = useViewContext();
|
|
45
45
|
const [error, setError] = useState();
|
|
46
|
-
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext();
|
|
46
|
+
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext();
|
|
47
47
|
if (!emailWalletConnector ||
|
|
48
48
|
!isEmailOTPWalletConnector(emailWalletConnector)) {
|
|
49
49
|
throw new Error('Current wallet is not EmailWalletConnector');
|
|
@@ -57,10 +57,11 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
57
57
|
clearStatesOnBackClick();
|
|
58
58
|
setView('login-with-email-or-wallet');
|
|
59
59
|
};
|
|
60
|
+
const handleOnClickClose = () => setShowAuthFlow(false);
|
|
60
61
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
61
62
|
onFailure: (error) => setError(error),
|
|
62
63
|
});
|
|
63
|
-
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
|
|
64
|
+
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true, successBannerText: 'Sign in to access your email based wallet' }));
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
export { EmailWalletOTPVerificationView };
|
|
@@ -26,7 +26,10 @@ const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
|
|
|
26
26
|
const { setView } = ViewContext.useViewContext();
|
|
27
27
|
const { projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
28
28
|
const isUsingMultiWallet = Boolean(localStorage.LocalStorage.getFromLS(localStorage$1.AUTH_USER));
|
|
29
|
-
return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", { className: 'login-with-email-wallet-list__container', children: [walletsList.map((wallet) =>
|
|
29
|
+
return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", { className: 'login-with-email-wallet-list__container', children: [walletsList.map((wallet) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
|
|
32
|
+
}), jsxRuntime.jsx(ListItemButton.ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] }));
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
exports.LoginWithEmailWalletList = LoginWithEmailWalletList;
|
|
@@ -22,7 +22,10 @@ const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
|
|
|
22
22
|
const { setView } = useViewContext();
|
|
23
23
|
const { projectSettings } = useInternalDynamicContext();
|
|
24
24
|
const isUsingMultiWallet = Boolean(LocalStorage.getFromLS(AUTH_USER));
|
|
25
|
-
return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", { className: 'login-with-email-wallet-list__container', children: [walletsList.map((wallet) =>
|
|
25
|
+
return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", { className: 'login-with-email-wallet-list__container', children: [walletsList.map((wallet) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
|
|
28
|
+
}), jsx(ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] }));
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
export { LoginWithEmailWalletList, NUMBER_OF_WALLETS };
|
|
@@ -78,7 +78,7 @@ const SocialSignIn = () => {
|
|
|
78
78
|
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
79
79
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'social-sign-in', style: {
|
|
80
80
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
81
|
-
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', children: ["Connect with ", capitalize.capitalize(provider)] }))] }, provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsxRuntime.jsx(Icon.Icon, { color: 'text-primary', children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) }) }, 'show-more-options'))] }), jsxRuntime.jsx(OverlayCard.OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxRuntime.jsxs("div", { className: 'social-sign-in--card', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsxRuntime.jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile', children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
81
|
+
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', children: ["Connect with ", capitalize.capitalize(provider)] }))] }, provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsxRuntime.jsx(Icon.Icon, { color: 'text-primary', children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) }) }, 'show-more-options'))] }), jsxRuntime.jsx(OverlayCard.OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxRuntime.jsxs("div", { className: 'social-sign-in--card', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsxRuntime.jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile', children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
exports.SocialSignIn = SocialSignIn;
|
|
@@ -74,7 +74,7 @@ const SocialSignIn = () => {
|
|
|
74
74
|
const closeButton = (jsx(IconButton, { onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button', children: jsx(SvgClose, {}) }));
|
|
75
75
|
return (jsxs(Fragment, { children: [jsxs("div", { className: 'social-sign-in', style: {
|
|
76
76
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
77
|
-
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile', children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, { variant: 'button_primary', children: ["Connect with ", capitalize(provider)] }))] }, provider))), showCardButton && (jsx(IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsx(Icon, { color: 'text-primary', children: jsx(SvgDotsHorizontal, {}) }) }, 'show-more-options'))] }), jsx(OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxs("div", { className: 'social-sign-in--card', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsx(IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile', children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
77
|
+
}, children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, { dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile', children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, { variant: 'button_primary', children: ["Connect with ", capitalize(provider)] }))] }, provider))), showCardButton && (jsx(IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), children: jsx(Icon, { color: 'text-primary', children: jsx(SvgDotsHorizontal, {}) }) }, 'show-more-options'))] }), jsx(OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxs("div", { className: 'social-sign-in--card', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsx("div", { className: 'social-sign-in--card--body', children: socialProviders.map((provider) => (jsx(IconListTile, { dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile', children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }, provider))) })] }) })] }));
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
export { SocialSignIn };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
|
+
var iconic = require('@dynamic-labs/iconic');
|
|
10
|
+
require('react');
|
|
11
|
+
var Typography = require('../../components/Typography/Typography.cjs');
|
|
12
|
+
var decodeJwt = require('../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
13
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
var doubleArrowRight = require('../../shared/assets/double-arrow-right.cjs');
|
|
16
|
+
require('../../shared/logger.cjs');
|
|
17
|
+
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
18
|
+
require('../../utils/constants/colors.cjs');
|
|
19
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
|
+
require('viem');
|
|
21
|
+
require('../../shared/consts/index.cjs');
|
|
22
|
+
var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
23
|
+
var index = require('../../utils/functions/storeAuthToken/index.cjs');
|
|
24
|
+
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
var createUserProfile = require('../../utils/functions/createUserProfile/createUserProfile.cjs');
|
|
26
|
+
require('@dynamic-labs/sdk-api');
|
|
27
|
+
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
28
|
+
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
29
|
+
var Icon = require('../../components/Icon/Icon.cjs');
|
|
30
|
+
require('react-dom');
|
|
31
|
+
require('react-focus-lock');
|
|
32
|
+
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
33
|
+
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
34
|
+
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
35
|
+
var api = require('../../data/api.cjs');
|
|
36
|
+
require('@dynamic-labs/rpc-providers');
|
|
37
|
+
require('../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
38
|
+
var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
|
|
39
|
+
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
40
|
+
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
41
|
+
require('../../components/IconButton/IconButton.cjs');
|
|
42
|
+
var Button = require('../../components/Button/Button.cjs');
|
|
43
|
+
require('../../components/Alert/Alert.cjs');
|
|
44
|
+
require('../../context/MockContext/MockContext.cjs');
|
|
45
|
+
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
46
|
+
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
47
|
+
var shortenEmail = require('../../shared/utils/functions/shortenEmail/shortenEmail.cjs');
|
|
48
|
+
require('../../components/Popper/Popper/Popper.cjs');
|
|
49
|
+
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
50
|
+
require('formik');
|
|
51
|
+
require('yup');
|
|
52
|
+
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
53
|
+
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
54
|
+
var EmailVerificationContext = require('../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
55
|
+
|
|
56
|
+
const MergeUserAccountsView = () => {
|
|
57
|
+
const { environmentId, setUser, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, primaryWallet, user, authToken, onboardingOnlyJwt, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
|
+
const { setError } = ErrorContext.useErrorContext();
|
|
59
|
+
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
60
|
+
const { email } = EmailVerificationContext.useEmailVerificationContext();
|
|
61
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
62
|
+
// If user tries to merge during KYC step, authToken is undefined and onboardingOnlyJwt is defined
|
|
63
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
64
|
+
const handleMergeUserAccounts = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
if (!jwtToken) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const newJwt = yield api.mergeUserAccounts(jwtToken, environmentId);
|
|
70
|
+
if (newJwt) {
|
|
71
|
+
index.storeAuthToken(newJwt);
|
|
72
|
+
const decodedJwt = decodeJwt.decodeJwt(newJwt);
|
|
73
|
+
if (decodedJwt === undefined) {
|
|
74
|
+
throw new utils.DynamicError('Invalid token!');
|
|
75
|
+
}
|
|
76
|
+
const newUser = createUserProfile.createUserProfile(decodedJwt);
|
|
77
|
+
setOnboardingOnlyJwt(undefined);
|
|
78
|
+
setUser(newUser);
|
|
79
|
+
setShowAuthFlow(false);
|
|
80
|
+
setCallback('authSuccess');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw new utils.DynamicError('Something went wrong, please try again.');
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
setError('Something went wrong, please try again.');
|
|
87
|
+
if (user) {
|
|
88
|
+
setShowAuthFlow(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
goToInitialView();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const handleUseDifferentEmail = () => {
|
|
95
|
+
setError(undefined);
|
|
96
|
+
if (user) {
|
|
97
|
+
setShowAuthFlow(false);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
setView('collect-user-data');
|
|
101
|
+
};
|
|
102
|
+
return (jsxRuntime.jsxs("div", { className: 'merge-user-accounts__container', children: [jsxRuntime.jsxs("div", { className: 'merge-user-accounts__accounts', children: [jsxRuntime.jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsxRuntime.jsx(walletBook.WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenWalletAddress.shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) })] }), jsxRuntime.jsx("div", { className: 'merge-user-accounts__accounts__divider', children: jsxRuntime.jsx(Icon.Icon, { color: 'text-secondary', size: 'small', children: jsxRuntime.jsx(doubleArrowRight.ReactComponent, {}) }) }), jsxRuntime.jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenEmail.shortenEmail(email, {
|
|
103
|
+
breakpoint: 4,
|
|
104
|
+
cutEnd: 1,
|
|
105
|
+
cutStart: 2,
|
|
106
|
+
}) })] })] }), jsxRuntime.jsx(Typography.Typography, { weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header', children: "Would you like to link this wallet to this existing account?" }), jsxRuntime.jsxs(Typography.Typography, { weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body', children: ["An account already exists that uses", ' ', jsxRuntime.jsx("span", { className: 'merge-user-accounts__text--bold', children: shortenEmail.shortenEmail(email, {
|
|
107
|
+
breakpoint: 14,
|
|
108
|
+
}) }), ' ', "email."] }), jsxRuntime.jsxs("div", { className: 'merge-user-accounts__buttons', children: [jsxRuntime.jsx(Button.Button, { className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default', children: "Yes, link to existing account" }), jsxRuntime.jsx(Button.Button, { className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default', children: "No, I'll use a different email" })] })] }));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
exports.MergeUserAccountsView = MergeUserAccountsView;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
|
+
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
5
|
+
import { UserProfileIcon } from '@dynamic-labs/iconic';
|
|
6
|
+
import 'react';
|
|
7
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
8
|
+
import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import { ReactComponent as SvgDoubleArrowRight } from '../../shared/assets/double-arrow-right.js';
|
|
12
|
+
import '../../shared/logger.js';
|
|
13
|
+
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
14
|
+
import '../../utils/constants/colors.js';
|
|
15
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
+
import 'viem';
|
|
17
|
+
import '../../shared/consts/index.js';
|
|
18
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
|
|
19
|
+
import { storeAuthToken } from '../../utils/functions/storeAuthToken/index.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import { createUserProfile } from '../../utils/functions/createUserProfile/createUserProfile.js';
|
|
22
|
+
import '@dynamic-labs/sdk-api';
|
|
23
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
24
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
25
|
+
import { Icon } from '../../components/Icon/Icon.js';
|
|
26
|
+
import 'react-dom';
|
|
27
|
+
import 'react-focus-lock';
|
|
28
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
29
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
30
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
31
|
+
import { mergeUserAccounts } from '../../data/api.js';
|
|
32
|
+
import '@dynamic-labs/rpc-providers';
|
|
33
|
+
import '../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
34
|
+
import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
|
|
35
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
36
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
37
|
+
import '../../components/IconButton/IconButton.js';
|
|
38
|
+
import { Button } from '../../components/Button/Button.js';
|
|
39
|
+
import '../../components/Alert/Alert.js';
|
|
40
|
+
import '../../context/MockContext/MockContext.js';
|
|
41
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
42
|
+
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
43
|
+
import { shortenEmail } from '../../shared/utils/functions/shortenEmail/shortenEmail.js';
|
|
44
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
45
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
46
|
+
import 'formik';
|
|
47
|
+
import 'yup';
|
|
48
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
49
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
50
|
+
import { useEmailVerificationContext } from '../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
51
|
+
|
|
52
|
+
const MergeUserAccountsView = () => {
|
|
53
|
+
const { environmentId, setUser, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, primaryWallet, user, authToken, onboardingOnlyJwt, } = useInternalDynamicContext();
|
|
54
|
+
const { setError } = useErrorContext();
|
|
55
|
+
const { setView, goToInitialView } = useViewContext();
|
|
56
|
+
const { email } = useEmailVerificationContext();
|
|
57
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
58
|
+
// If user tries to merge during KYC step, authToken is undefined and onboardingOnlyJwt is defined
|
|
59
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
60
|
+
const handleMergeUserAccounts = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
if (!jwtToken) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const newJwt = yield mergeUserAccounts(jwtToken, environmentId);
|
|
66
|
+
if (newJwt) {
|
|
67
|
+
storeAuthToken(newJwt);
|
|
68
|
+
const decodedJwt = decodeJwt(newJwt);
|
|
69
|
+
if (decodedJwt === undefined) {
|
|
70
|
+
throw new DynamicError('Invalid token!');
|
|
71
|
+
}
|
|
72
|
+
const newUser = createUserProfile(decodedJwt);
|
|
73
|
+
setOnboardingOnlyJwt(undefined);
|
|
74
|
+
setUser(newUser);
|
|
75
|
+
setShowAuthFlow(false);
|
|
76
|
+
setCallback('authSuccess');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
throw new DynamicError('Something went wrong, please try again.');
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
setError('Something went wrong, please try again.');
|
|
83
|
+
if (user) {
|
|
84
|
+
setShowAuthFlow(false);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
goToInitialView();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const handleUseDifferentEmail = () => {
|
|
91
|
+
setError(undefined);
|
|
92
|
+
if (user) {
|
|
93
|
+
setShowAuthFlow(false);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setView('collect-user-data');
|
|
97
|
+
};
|
|
98
|
+
return (jsxs("div", { className: 'merge-user-accounts__container', children: [jsxs("div", { className: 'merge-user-accounts__accounts', children: [jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsx(WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) })] }), jsx("div", { className: 'merge-user-accounts__accounts__divider', children: jsx(Icon, { color: 'text-secondary', size: 'small', children: jsx(SvgDoubleArrowRight, {}) }) }), jsxs("div", { className: 'merge-user-accounts__accounts__item', children: [jsx(UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, { variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text', children: shortenEmail(email, {
|
|
99
|
+
breakpoint: 4,
|
|
100
|
+
cutEnd: 1,
|
|
101
|
+
cutStart: 2,
|
|
102
|
+
}) })] })] }), jsx(Typography, { weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header', children: "Would you like to link this wallet to this existing account?" }), jsxs(Typography, { weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body', children: ["An account already exists that uses", ' ', jsx("span", { className: 'merge-user-accounts__text--bold', children: shortenEmail(email, {
|
|
103
|
+
breakpoint: 14,
|
|
104
|
+
}) }), ' ', "email."] }), jsxs("div", { className: 'merge-user-accounts__buttons', children: [jsx(Button, { className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default', children: "Yes, link to existing account" }), jsx(Button, { className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default', children: "No, I'll use a different email" })] })] }));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { MergeUserAccountsView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MergeUserAccountsView } from './MergeUserAccountsView';
|
|
@@ -53,11 +53,13 @@ var SelectNetworkButton = require('../../components/SelectNetworkButton/SelectNe
|
|
|
53
53
|
var useApplyWalletConnectorNetwork = require('../../utils/hooks/useApplyWalletConnectorNetwork/useApplyWalletConnectorNetwork.cjs');
|
|
54
54
|
|
|
55
55
|
const NetworkNotSupported = () => {
|
|
56
|
-
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
56
|
+
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, walletsToConnectByChain, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
57
57
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
58
58
|
const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
59
59
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
60
|
-
|
|
60
|
+
shouldCallCallback: false,
|
|
61
|
+
shouldUpdateWallets: !isFullyConnected ||
|
|
62
|
+
(isFullyConnected && Boolean(walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.length)),
|
|
61
63
|
});
|
|
62
64
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
63
65
|
// Finishes auth flow when wallet switches to proper network
|