@dynamic-labs/sdk-react-core 0.18.0-RC.16 → 0.18.0-RC.18
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 +32 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/index.cjs +3 -0
- package/src/index.js +2 -0
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.cjs +1 -0
- package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.js +1 -0
- package/src/lib/components/AnimatePresence/AnimatePresence.cjs +1 -0
- package/src/lib/components/AnimatePresence/AnimatePresence.js +1 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +1 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +1 -0
- package/src/lib/components/Button/Button.cjs +12 -4
- package/src/lib/components/Button/Button.d.ts +3 -2
- package/src/lib/components/Button/Button.js +12 -4
- package/src/lib/components/ChainCard/ChainCard.cjs +1 -1
- package/src/lib/components/ChainCard/ChainCard.js +1 -1
- package/src/lib/components/Divider/Divider.cjs +1 -0
- package/src/lib/components/Divider/Divider.js +1 -0
- package/src/lib/components/IconWithSpinner/IconWithSpinner.cjs +2 -2
- package/src/lib/components/IconWithSpinner/IconWithSpinner.js +2 -2
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.cjs +9 -0
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.d.ts +2 -0
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.js +5 -0
- package/src/lib/components/LegacySafariCssOverrides/index.d.ts +1 -0
- package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +85 -0
- package/src/lib/components/MenuList/Dropdown/Dropdown.d.ts +16 -0
- package/src/lib/components/MenuList/Dropdown/Dropdown.js +81 -0
- package/src/lib/components/MenuList/Dropdown/index.d.ts +1 -0
- package/src/lib/components/MenuList/MenuList/MenuList.cjs +34 -0
- package/src/lib/components/MenuList/MenuList/MenuList.d.ts +15 -0
- package/src/lib/components/MenuList/MenuList/MenuList.js +30 -0
- package/src/lib/components/MenuList/MenuList/index.d.ts +1 -0
- package/src/lib/components/MenuList/index.d.ts +1 -0
- package/src/lib/components/MenuList/utils/index.d.ts +1 -0
- package/src/lib/components/{Popper → MenuList}/utils/watchToScrollInHierarchy/watchToScrollInHierarchy.cjs +6 -1
- package/src/lib/components/MenuList/utils/watchToScrollInHierarchy/watchToScrollInHierarchy.d.ts +5 -0
- package/src/lib/components/{Popper → MenuList}/utils/watchToScrollInHierarchy/watchToScrollInHierarchy.js +6 -1
- package/src/lib/components/Modal/Modal.cjs +1 -0
- package/src/lib/components/Modal/Modal.js +1 -0
- package/src/lib/components/NetworkPicker/NetworkPicker.cjs +9 -12
- package/src/lib/components/NetworkPicker/NetworkPicker.js +9 -12
- package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.cjs +1 -0
- package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.js +1 -0
- package/src/lib/components/NetworkPicker/components/Network/Network.cjs +1 -0
- package/src/lib/components/NetworkPicker/components/Network/Network.js +1 -0
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +1 -0
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +1 -0
- package/src/lib/components/OverlayCard/OverlayCard.cjs +10 -11
- package/src/lib/components/OverlayCard/OverlayCard.d.ts +4 -2
- package/src/lib/components/OverlayCard/OverlayCard.js +11 -11
- package/src/lib/components/Popper/Popper/Popper.cjs +12 -12
- package/src/lib/components/Popper/Popper/Popper.d.ts +7 -4
- package/src/lib/components/Popper/Popper/Popper.js +12 -12
- package/src/lib/components/Popper/PopperContent/PopperContent.cjs +1 -1
- package/src/lib/components/Popper/PopperContent/PopperContent.d.ts +2 -1
- package/src/lib/components/Popper/PopperContent/PopperContent.js +1 -1
- package/src/lib/components/Popper/utils/getChildPosition/getChildPosition.cjs +1 -0
- package/src/lib/components/Popper/utils/getChildPosition/getChildPosition.d.ts +1 -0
- package/src/lib/components/Popper/utils/getChildPosition/getChildPosition.js +1 -0
- package/src/lib/components/Popper/utils/index.d.ts +0 -1
- package/src/lib/components/Portal/Portal.cjs +3 -2
- package/src/lib/components/Portal/Portal.js +3 -2
- package/src/lib/components/ShadowDOM/ShadowDOM.cjs +4 -2
- package/src/lib/components/ShadowDOM/ShadowDOM.js +4 -2
- package/src/lib/components/Tooltip/Tooltip.cjs +1 -0
- package/src/lib/components/Tooltip/Tooltip.js +1 -0
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +1 -0
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +1 -0
- package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.cjs +1 -0
- package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.js +1 -0
- package/src/lib/components/UserAddress/UserAddress.cjs +1 -0
- package/src/lib/components/UserAddress/UserAddress.js +1 -0
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.cjs +1 -0
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.js +1 -0
- package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.cjs +1 -0
- package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.js +1 -0
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -0
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -0
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +80 -49
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +7 -134
- package/src/lib/context/DynamicContext/DynamicContext.js +81 -50
- package/src/lib/context/DynamicContext/types/index.d.ts +144 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +5 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.cjs +1 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.js +1 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +9 -3
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +2 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +9 -3
- package/src/lib/context/DynamicContext/useCustomerCallbacks/utils/disableAuthVerificationFlag/disableAuthVerificationFlag.cjs +27 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/utils/disableAuthVerificationFlag/disableAuthVerificationFlag.d.ts +3 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/utils/disableAuthVerificationFlag/disableAuthVerificationFlag.js +23 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/utils/disableAuthVerificationFlag/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/useCustomerCallbacks/utils/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +5 -1
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +4 -2
- package/src/lib/context/DynamicContext/useDynamicContext.js +5 -1
- package/src/lib/context/DynamicContext/useInternalDynamicContext.d.ts +1 -1
- package/src/lib/context/QrCodeContext/QrCodeContext.cjs +1 -0
- package/src/lib/context/QrCodeContext/QrCodeContext.js +1 -0
- package/src/lib/context/SendBalanceContext/SendBalanceContext.cjs +1 -0
- package/src/lib/context/SendBalanceContext/SendBalanceContext.js +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +2 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +2 -1
- package/src/lib/context/WalletContext/WalletContext.cjs +3 -3
- package/src/lib/context/WalletContext/WalletContext.d.ts +1 -3
- package/src/lib/context/WalletContext/WalletContext.js +3 -3
- package/src/lib/data/api.cjs +14 -0
- package/src/lib/data/api.d.ts +1 -0
- package/src/lib/data/api.js +14 -1
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +1 -0
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +1 -0
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +2 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +2 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.cjs +2 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.js +2 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/Item/Item.cjs +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/Item/Item.js +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.cjs +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.js +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.cjs +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.js +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletMoreInfoContent/WalletMoreInfoContent.cjs +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletMoreInfoContent/WalletMoreInfoContent.js +1 -0
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.cjs +1 -0
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.js +1 -0
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.cjs +1 -0
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.js +1 -0
- package/src/lib/layouts/BridgeNextWalletToConnectLayout/BridgeNextWalletToConnectLayout.cjs +1 -0
- package/src/lib/layouts/BridgeNextWalletToConnectLayout/BridgeNextWalletToConnectLayout.js +1 -0
- package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.cjs +1 -0
- package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.js +1 -0
- package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.cjs +1 -0
- package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.js +1 -0
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +1 -0
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +1 -0
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +1 -0
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +1 -0
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +1 -0
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +1 -0
- package/src/lib/shared/types/index.d.ts +2 -1
- package/src/lib/shared/utils/hooks/index.d.ts +1 -0
- package/src/lib/shared/utils/hooks/useForwardedRef/index.d.ts +1 -0
- package/src/lib/shared/utils/hooks/useForwardedRef/useForwardedRef.cjs +25 -0
- package/src/lib/shared/utils/hooks/useForwardedRef/useForwardedRef.d.ts +2 -0
- package/src/lib/shared/utils/hooks/useForwardedRef/useForwardedRef.js +21 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -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/getMissingChains/getMissingChains.cjs +1 -1
- package/src/lib/utils/functions/getMissingChains/getMissingChains.d.ts +1 -1
- package/src/lib/utils/functions/getMissingChains/getMissingChains.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +9 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +9 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +7 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +7 -1
- package/src/lib/utils/hooks/index.d.ts +0 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +3 -3
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +3 -3
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +3 -3
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +8 -11
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +8 -11
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +97 -84
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +5 -7
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +99 -86
- package/src/lib/utils/hooks/useConnectWithEmail/useConnectWithEmail.cjs +5 -0
- package/src/lib/utils/hooks/useConnectWithEmail/useConnectWithEmail.js +5 -0
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +69 -0
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.d.ts +1 -0
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +65 -0
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +2 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.d.ts +3 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +3 -2
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +5 -0
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +5 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +20 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +4 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +20 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +3 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +3 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +11 -2
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.d.ts +3 -2
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +11 -2
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +18 -8
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +3 -3
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +18 -8
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +4 -4
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +4 -4
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +1 -0
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +1 -0
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +2 -1
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +2 -1
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +1 -0
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +1 -0
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +9 -2
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +9 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +1 -0
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +1 -0
- package/src/lib/views/CollectUserDataView/fieldsConfig.cjs +8 -4
- package/src/lib/views/CollectUserDataView/fieldsConfig.js +8 -4
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.cjs +1 -0
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.js +1 -0
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +1 -0
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +1 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +1 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.js +1 -0
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -0
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -0
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -0
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -0
- package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.cjs +1 -0
- package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.js +1 -0
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +1 -0
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +1 -0
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -0
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +9 -10
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +10 -11
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +12 -12
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +13 -13
- package/src/lib/views/NoAccess/NoAccess.cjs +1 -0
- package/src/lib/views/NoAccess/NoAccess.js +1 -0
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.cjs +1 -0
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.js +1 -0
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.cjs +1 -0
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.js +1 -0
- package/src/lib/views/PendingConnectView/PendingConnectView.cjs +1 -0
- package/src/lib/views/PendingConnectView/PendingConnectView.js +1 -0
- package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +1 -0
- package/src/lib/views/PendingSignatureView/PendingSignatureView.js +1 -0
- package/src/lib/views/QrCodeView/QRCode.cjs +1 -0
- package/src/lib/views/QrCodeView/QRCode.js +1 -0
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +1 -0
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +1 -0
- package/src/lib/views/QrCodeView/QrCodeView.cjs +1 -0
- package/src/lib/views/QrCodeView/QrCodeView.js +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -0
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -0
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -0
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +1 -0
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +1 -0
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -0
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +1 -0
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.cjs +1 -0
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.js +1 -0
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +2 -1
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +2 -1
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +1 -0
- package/src/lib/views/WalletLockedView/WalletLockedView.js +1 -0
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +1 -0
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +1 -0
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -0
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +2 -1
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +2 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.cjs +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.cjs +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.cjs +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs +2 -0
- package/src/lib/widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js +2 -0
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +2 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +2 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +10 -3
- package/src/lib/widgets/DynamicWidget/DynamicWidget.js +12 -5
- package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +5 -4
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +5 -4
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.cjs +5 -4
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.d.ts +4 -7
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.js +5 -4
- package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.js +1 -0
- 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/DynamicWidgetHeader/DynamicWidgetHeader.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +4 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +4 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +2 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +2 -1
- package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.js +1 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -0
- package/src/lib/widgets/DynamicWidget/helpers/helpers.cjs +17 -1
- package/src/lib/widgets/DynamicWidget/helpers/helpers.js +17 -1
- package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +1 -0
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +1 -0
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.js +1 -0
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +1 -0
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +1 -0
- package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.cjs +1 -0
- package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.js +1 -0
- package/src/lib/components/NetworkPicker/components/ActionList/ActionList.cjs +0 -71
- package/src/lib/components/NetworkPicker/components/ActionList/ActionList.d.ts +0 -12
- package/src/lib/components/NetworkPicker/components/ActionList/ActionList.js +0 -65
- package/src/lib/components/NetworkPicker/components/ActionList/index.d.ts +0 -1
- package/src/lib/components/Popper/utils/watchToScrollInHierarchy/watchToScrollInHierarchy.d.ts +0 -1
- package/src/lib/utils/hooks/useWalletConnectorEvents/useWalletConnectorEvents.cjs +0 -17
- package/src/lib/utils/hooks/useWalletConnectorEvents/useWalletConnectorEvents.d.ts +0 -2
- package/src/lib/utils/hooks/useWalletConnectorEvents/useWalletConnectorEvents.js +0 -13
- /package/src/lib/components/{Popper → MenuList}/utils/watchToScrollInHierarchy/index.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useCallback, useMemo } from 'react';
|
|
3
|
-
import { getWalletConnectorByName,
|
|
2
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import { getWalletConnectorByName, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
@@ -21,10 +21,52 @@ import { shouldManuallyReconnectOnRefresh } from '../../functions/shouldManually
|
|
|
21
21
|
|
|
22
22
|
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, wallets, onUnlink, }) => {
|
|
23
23
|
const [connectedWalletsInfo, setConnectedWalletsInfo, removeConnectedWalletsInfo,] = useLocalStorage(CONNECTED_WALLETS_INFO, []);
|
|
24
|
+
const [connectedWallets, setConnectedWallets] = useState([]);
|
|
25
|
+
// The function to update and define the connectedWallets list.
|
|
26
|
+
// It uses walletConnector to get the current wallet address and network
|
|
27
|
+
// The address and network in the runtime are updated by the event listeners
|
|
28
|
+
// The event listeners are updating `connectedWallets` list.
|
|
29
|
+
// It should be called on the first render and when connectedWalletsInfo updates
|
|
30
|
+
const updateConnectedWalletsList = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const walletConnectors = wallets.map((wallet) => wallet.walletConnector);
|
|
32
|
+
if (!walletConnectors.length) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const nextConnectedWallets = (yield Promise.all(connectedWalletsInfo.map((storedConnectedWalletInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const walletConnector = getWalletConnectorByName(walletConnectors, storedConnectedWalletInfo.walletConnectorKey);
|
|
37
|
+
if (!walletConnector) {
|
|
38
|
+
logger.error('Could not find walletConnector: ' +
|
|
39
|
+
storedConnectedWalletInfo.walletConnectorKey);
|
|
40
|
+
return Promise.resolve(null);
|
|
41
|
+
}
|
|
42
|
+
const [walletAddress] = yield walletConnector.getConnectedAccounts();
|
|
43
|
+
const walletNetwork = yield walletConnector.getNetwork();
|
|
44
|
+
const walletChain = walletConnector.connectedChain;
|
|
45
|
+
const walletObject = {
|
|
46
|
+
address:
|
|
47
|
+
// We use `storedConnectedWalletInfo.lastWalletAddress` as a workaround to Braavos issue
|
|
48
|
+
// Braavos during initialization returns an empty string as a wallet address
|
|
49
|
+
walletAddress ||
|
|
50
|
+
storedConnectedWalletInfo.lastWalletAddress ||
|
|
51
|
+
'',
|
|
52
|
+
chain: walletChain || '',
|
|
53
|
+
connected: true,
|
|
54
|
+
connector: walletConnector,
|
|
55
|
+
id: storedConnectedWalletInfo.id,
|
|
56
|
+
network: walletNetwork,
|
|
57
|
+
};
|
|
58
|
+
return Promise.resolve(walletObject);
|
|
59
|
+
})))).filter((wallet) => Boolean(wallet));
|
|
60
|
+
setConnectedWallets(nextConnectedWallets);
|
|
61
|
+
}), [connectedWalletsInfo, wallets]);
|
|
62
|
+
// Generate the connectedWallets list when connectedWalletsInfo (localStorage) or memoized wallet connector updates
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
updateConnectedWalletsList();
|
|
65
|
+
}, [updateConnectedWalletsList]);
|
|
24
66
|
const getNextIdAvailable = useCallback((currentWallets) => {
|
|
25
67
|
const existingIds = currentWallets.map(({ id }) => id);
|
|
26
68
|
const sortedIds = existingIds
|
|
27
|
-
.map((id) => Number(id.replace('connect-
|
|
69
|
+
.map((id) => Number(id.replace('connect-wallet-', '')))
|
|
28
70
|
.sort((a, b) => a - b);
|
|
29
71
|
for (let i = 0; i < sortedIds.length; i++) {
|
|
30
72
|
if (sortedIds[i] !== i) {
|
|
@@ -33,82 +75,44 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
33
75
|
}
|
|
34
76
|
return sortedIds.length;
|
|
35
77
|
}, []);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
78
|
+
const updateConnectedWalletById = useCallback((walletId, walletObject) => {
|
|
79
|
+
const clonedConnectedWalletsList = [...connectedWallets];
|
|
80
|
+
const connectedWalletIndex = clonedConnectedWalletsList.findIndex((connectedWallet) => connectedWallet.id === walletId);
|
|
81
|
+
if (connectedWalletIndex > -1) {
|
|
82
|
+
clonedConnectedWalletsList[connectedWalletIndex] = Object.assign(Object.assign({}, clonedConnectedWalletsList[connectedWalletIndex]), walletObject);
|
|
83
|
+
setConnectedWallets(clonedConnectedWalletsList);
|
|
41
84
|
}
|
|
42
|
-
|
|
43
|
-
address: connectedWallet.walletPublicKey,
|
|
44
|
-
chain: connectedWallet.chain,
|
|
45
|
-
connected: true,
|
|
46
|
-
connector: walletConnector,
|
|
47
|
-
id: connectedWallet.id,
|
|
48
|
-
network: connectedWallet.network,
|
|
49
|
-
};
|
|
50
|
-
return connectedWalletInfo;
|
|
51
|
-
})
|
|
52
|
-
.filter((wc) => wc !== null), [connectedWalletsInfo, wallets]);
|
|
53
|
-
const updateConnectedWalletById = useCallback((walletId, connectedWalletConnectorObject) => {
|
|
54
|
-
setConnectedWalletsInfo((currentWallets) => currentWallets.map((currentWallet) => {
|
|
55
|
-
if (currentWallet.id === walletId) {
|
|
56
|
-
return Object.assign(Object.assign({}, currentWallet), connectedWalletConnectorObject);
|
|
57
|
-
}
|
|
58
|
-
return currentWallet;
|
|
59
|
-
}));
|
|
60
|
-
}, [setConnectedWalletsInfo]);
|
|
85
|
+
}, [connectedWallets]);
|
|
61
86
|
const connectedWallet = connectedWallets[0] || null;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// an existing one in the array, we intend to replace the existing wallet with the new one.
|
|
72
|
-
if (existingWalletIndex !== -1) {
|
|
73
|
-
const updatedWallets = [...currentWallets];
|
|
74
|
-
updatedWallets[existingWalletIndex] = Object.assign(Object.assign({}, updatedWallets[existingWalletIndex]), { chain, provider: getWalletProvider(walletConnector), walletPublicKey: address });
|
|
75
|
-
return updatedWallets;
|
|
76
|
-
}
|
|
77
|
-
// otherwise, add new wallet to connectedWalletsInfo array
|
|
78
|
-
return [
|
|
79
|
-
...currentWallets,
|
|
80
|
-
{
|
|
81
|
-
chain,
|
|
82
|
-
id: `connect-only-wallet-${getNextIdAvailable(currentWallets)}`,
|
|
83
|
-
name: walletConnector.name,
|
|
84
|
-
network: walletConnectorNetwork,
|
|
85
|
-
provider: getWalletProvider(walletConnector),
|
|
86
|
-
walletPublicKey: address,
|
|
87
|
-
},
|
|
88
|
-
];
|
|
87
|
+
// Keeps connected wallet data inside localStorage
|
|
88
|
+
const applyConnectedWalletToStore = ({ walletId, walletAddress, walletConnectorKey, walletChain, provider, }) => {
|
|
89
|
+
const nextConnectedWalletsInfo = [...connectedWalletsInfo];
|
|
90
|
+
nextConnectedWalletsInfo.push({
|
|
91
|
+
id: walletId,
|
|
92
|
+
lastWalletAddress: walletAddress,
|
|
93
|
+
provider,
|
|
94
|
+
walletChain,
|
|
95
|
+
walletConnectorKey,
|
|
89
96
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const connectedAccounts = yield walletConnector.getConnectedAccounts();
|
|
98
|
-
const result = connectedAccounts.filter((account) => isSameAddress(account, address, chain));
|
|
99
|
-
const walletNetwork = yield walletConnector.getNetwork();
|
|
100
|
-
if (result.length > 0) {
|
|
101
|
-
walletConnector.connect();
|
|
102
|
-
setConnectedStates(walletConnector, address, chain, walletNetwork);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
removeConnectedWalletsInfo();
|
|
106
|
-
}
|
|
97
|
+
setConnectedWalletsInfo(nextConnectedWalletsInfo);
|
|
98
|
+
return Promise.resolve();
|
|
99
|
+
};
|
|
100
|
+
// Updates connected wallet (network and address) and verifies connected wallet connection
|
|
101
|
+
const refreshConnectedWallet = (walletId, walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
if (shouldManuallyReconnectOnRefresh(walletConnector)) {
|
|
103
|
+
yield walletConnector.connect();
|
|
107
104
|
}
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
const currentWalletConnectorAddress = yield walletConnector.fetchPublicAddress();
|
|
106
|
+
if (!currentWalletConnectorAddress) {
|
|
107
|
+
logger.error('Could not refresh the wallet. The wallet address is not available');
|
|
108
|
+
return;
|
|
110
109
|
}
|
|
111
|
-
|
|
110
|
+
const currentWalletConnectoNetwork = yield walletConnector.getNetwork();
|
|
111
|
+
updateConnectedWalletById(walletId, {
|
|
112
|
+
address: currentWalletConnectorAddress,
|
|
113
|
+
network: currentWalletConnectoNetwork,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
112
116
|
const shouldSkipCreatingVisit = useMemo(() => (authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly) ||
|
|
113
117
|
connectedWallet, [authMode, connectedWallet, enableVisitTrackingOnConnectOnly]);
|
|
114
118
|
const connectWallet = (walletConnector, fetchPublicAddressOpts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -118,29 +122,39 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
118
122
|
error.code = 'missing-public-address';
|
|
119
123
|
throw error;
|
|
120
124
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
const walletId = `connect-wallet-${getNextIdAvailable(connectedWalletsInfo)}`;
|
|
126
|
+
if (!primaryWalletId) {
|
|
127
|
+
setPrimaryWalletId(walletId);
|
|
128
|
+
}
|
|
129
|
+
const walletChain = walletConnector.connectedChain;
|
|
130
|
+
const isWalletStored = connectedWalletsInfo.some(({ walletConnectorKey: storedWalletConnectorKey }) => storedWalletConnectorKey === walletConnector.name);
|
|
131
|
+
if (isWalletStored) {
|
|
132
|
+
yield updateConnectedWalletsList();
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
applyConnectedWalletToStore({
|
|
136
|
+
provider: getWalletProvider(walletConnector),
|
|
137
|
+
walletAddress: publicWalletAddress,
|
|
138
|
+
walletChain,
|
|
139
|
+
walletConnectorKey: walletConnector.name,
|
|
140
|
+
walletId,
|
|
141
|
+
});
|
|
127
142
|
}
|
|
128
|
-
setConnectedStates(walletConnector, publicWalletAddress, chain, walletConnectorNetwork);
|
|
129
143
|
if (shouldSkipCreatingVisit) {
|
|
130
|
-
return publicWalletAddress;
|
|
144
|
+
return Promise.resolve(publicWalletAddress);
|
|
131
145
|
}
|
|
132
146
|
// send information to backend to kick off background jobs
|
|
133
147
|
// so verify/sign on the next step could go by more quickly
|
|
134
148
|
// this is async work, but DO NOT AWAIT
|
|
135
149
|
createVisit({
|
|
136
150
|
authMode,
|
|
137
|
-
chain,
|
|
151
|
+
chain: walletChain || '',
|
|
138
152
|
environmentId,
|
|
139
153
|
publicWalletAddress,
|
|
140
154
|
walletName: walletConnector.name,
|
|
141
155
|
walletProvider: getWalletProvider(walletConnector),
|
|
142
156
|
});
|
|
143
|
-
return publicWalletAddress;
|
|
157
|
+
return Promise.resolve(publicWalletAddress);
|
|
144
158
|
});
|
|
145
159
|
const unlinkConnectedWallet = (walletId) => {
|
|
146
160
|
const filteredWallets = connectedWalletsInfo.filter((wallet) => wallet.id !== walletId);
|
|
@@ -153,14 +167,13 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
153
167
|
const getConnectedWalletById = useCallback((walletId) => connectedWallets.find((wallet) => wallet.id === walletId), [connectedWallets]);
|
|
154
168
|
return {
|
|
155
169
|
connectWallet,
|
|
156
|
-
connectWalletByAddressAndChain,
|
|
157
170
|
connectedWallet,
|
|
158
171
|
connectedWallets,
|
|
159
172
|
connectedWalletsInfo,
|
|
160
173
|
getConnectedWalletById,
|
|
174
|
+
refreshConnectedWallet,
|
|
161
175
|
removeConnectedWalletsInfo,
|
|
162
176
|
unlinkConnectedWallet,
|
|
163
|
-
updateConnectedWalletById,
|
|
164
177
|
};
|
|
165
178
|
};
|
|
166
179
|
|
|
@@ -17,13 +17,17 @@ require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
17
17
|
require('ethers');
|
|
18
18
|
require('../../../shared/consts/index.cjs');
|
|
19
19
|
var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
20
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
20
21
|
|
|
21
22
|
const useConnectWithEmail = ({ emailWalletConnector, handleConnect, }) => {
|
|
22
23
|
const { error } = ErrorContext.useErrorContext();
|
|
23
24
|
const [loading, setLoading] = React.useState(false);
|
|
25
|
+
const { ongoingVerifications } = useInternalDynamicContext.useInternalDynamicContext();
|
|
24
26
|
const connectWithEmail = (email) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
25
27
|
if (!email || !emailWalletConnector || loading)
|
|
26
28
|
return;
|
|
29
|
+
// Indicate auth verification process start
|
|
30
|
+
ongoingVerifications.setAuthVerification(true);
|
|
27
31
|
setLoading(true);
|
|
28
32
|
emailWalletConnector.setEmail(email);
|
|
29
33
|
try {
|
|
@@ -31,6 +35,7 @@ const useConnectWithEmail = ({ emailWalletConnector, handleConnect, }) => {
|
|
|
31
35
|
}
|
|
32
36
|
catch (e) {
|
|
33
37
|
logger.logger.error(e);
|
|
38
|
+
ongoingVerifications.setAuthVerification(false);
|
|
34
39
|
setLoading(false);
|
|
35
40
|
}
|
|
36
41
|
});
|
|
@@ -13,13 +13,17 @@ import '../../../shared/utils/classes/storage/localStorage.js';
|
|
|
13
13
|
import 'ethers';
|
|
14
14
|
import '../../../shared/consts/index.js';
|
|
15
15
|
import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
|
|
16
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
16
17
|
|
|
17
18
|
const useConnectWithEmail = ({ emailWalletConnector, handleConnect, }) => {
|
|
18
19
|
const { error } = useErrorContext();
|
|
19
20
|
const [loading, setLoading] = useState(false);
|
|
21
|
+
const { ongoingVerifications } = useInternalDynamicContext();
|
|
20
22
|
const connectWithEmail = (email) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
23
|
if (!email || !emailWalletConnector || loading)
|
|
22
24
|
return;
|
|
25
|
+
// Indicate auth verification process start
|
|
26
|
+
ongoingVerifications.setAuthVerification(true);
|
|
23
27
|
setLoading(true);
|
|
24
28
|
emailWalletConnector.setEmail(email);
|
|
25
29
|
try {
|
|
@@ -27,6 +31,7 @@ const useConnectWithEmail = ({ emailWalletConnector, handleConnect, }) => {
|
|
|
27
31
|
}
|
|
28
32
|
catch (e) {
|
|
29
33
|
logger.error(e);
|
|
34
|
+
ongoingVerifications.setAuthVerification(false);
|
|
30
35
|
setLoading(false);
|
|
31
36
|
}
|
|
32
37
|
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
7
|
+
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
8
|
+
require('@dynamic-labs/sdk-api');
|
|
9
|
+
require('../../../shared/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
require('@dynamic-labs/utils');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
|
+
require('ethers');
|
|
18
|
+
require('../../../shared/consts/index.cjs');
|
|
19
|
+
require('@dynamic-labs/multi-wallet');
|
|
20
|
+
var isSupportedNetwork = require('../../functions/isSupportedNetwork/isSupportedNetwork.cjs');
|
|
21
|
+
var isProgrammableNetworkSwitchSupported = require('../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.cjs');
|
|
22
|
+
|
|
23
|
+
const useConnectedWalletsNetworkValidation = () => {
|
|
24
|
+
const { connectedWallets, selectedWalletConnector, setSelectedWalletConnector, setShowAuthFlow, showAuthFlow, walletsToConnectByChain, isBridgeFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
25
|
+
const { view, setView } = ViewContext.useViewContext();
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
if (!isBridgeFlow) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const connectedWalletsWithInvalidNetwork = connectedWallets.filter((connectedWallet) => {
|
|
31
|
+
const isChainInWalletsToConnect = walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.some((walletToConnectByChain) => walletToConnectByChain.chain === connectedWallet.chain);
|
|
32
|
+
const isSupported = isSupportedNetwork.isSupportedNetwork({
|
|
33
|
+
network: connectedWallet.network,
|
|
34
|
+
walletConnector: connectedWallet.connector,
|
|
35
|
+
});
|
|
36
|
+
return !isChainInWalletsToConnect && !isSupported;
|
|
37
|
+
});
|
|
38
|
+
if (connectedWalletsWithInvalidNetwork.length) {
|
|
39
|
+
// If we found wallets that require a change of network
|
|
40
|
+
// then, one by one, in the first one we require a change of network.
|
|
41
|
+
const [connectedWalletWithInvalidNetwork] = connectedWalletsWithInvalidNetwork;
|
|
42
|
+
// Keeps the first wallet connectedWallet in setSelectedWalletConnector
|
|
43
|
+
// This is required because NetworkNotSupported uses walletConnector to display wallet icon, address etc.
|
|
44
|
+
if (connectedWalletWithInvalidNetwork.connector.name !==
|
|
45
|
+
(selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name)) {
|
|
46
|
+
setSelectedWalletConnector(connectedWalletWithInvalidNetwork.connector);
|
|
47
|
+
}
|
|
48
|
+
const networkNotSupportedView = isProgrammableNetworkSwitchSupported.isProgrammableNetworkSwitchSupported(connectedWalletWithInvalidNetwork.connector)
|
|
49
|
+
? 'network-not-supported'
|
|
50
|
+
: 'network-not-supported-manual';
|
|
51
|
+
if (!showAuthFlow) {
|
|
52
|
+
setShowAuthFlow(true);
|
|
53
|
+
}
|
|
54
|
+
setView(networkNotSupportedView);
|
|
55
|
+
}
|
|
56
|
+
}, [
|
|
57
|
+
isBridgeFlow,
|
|
58
|
+
connectedWallets,
|
|
59
|
+
view,
|
|
60
|
+
selectedWalletConnector,
|
|
61
|
+
walletsToConnectByChain,
|
|
62
|
+
showAuthFlow,
|
|
63
|
+
setView,
|
|
64
|
+
setSelectedWalletConnector,
|
|
65
|
+
setShowAuthFlow,
|
|
66
|
+
]);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.useConnectedWalletsNetworkValidation = useConnectedWalletsNetworkValidation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useConnectedWalletsNetworkValidation: () => void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
3
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api';
|
|
5
|
+
import '../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '@dynamic-labs/utils';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
13
|
+
import 'ethers';
|
|
14
|
+
import '../../../shared/consts/index.js';
|
|
15
|
+
import '@dynamic-labs/multi-wallet';
|
|
16
|
+
import { isSupportedNetwork } from '../../functions/isSupportedNetwork/isSupportedNetwork.js';
|
|
17
|
+
import { isProgrammableNetworkSwitchSupported } from '../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.js';
|
|
18
|
+
|
|
19
|
+
const useConnectedWalletsNetworkValidation = () => {
|
|
20
|
+
const { connectedWallets, selectedWalletConnector, setSelectedWalletConnector, setShowAuthFlow, showAuthFlow, walletsToConnectByChain, isBridgeFlow, } = useInternalDynamicContext();
|
|
21
|
+
const { view, setView } = useViewContext();
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!isBridgeFlow) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const connectedWalletsWithInvalidNetwork = connectedWallets.filter((connectedWallet) => {
|
|
27
|
+
const isChainInWalletsToConnect = walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.some((walletToConnectByChain) => walletToConnectByChain.chain === connectedWallet.chain);
|
|
28
|
+
const isSupported = isSupportedNetwork({
|
|
29
|
+
network: connectedWallet.network,
|
|
30
|
+
walletConnector: connectedWallet.connector,
|
|
31
|
+
});
|
|
32
|
+
return !isChainInWalletsToConnect && !isSupported;
|
|
33
|
+
});
|
|
34
|
+
if (connectedWalletsWithInvalidNetwork.length) {
|
|
35
|
+
// If we found wallets that require a change of network
|
|
36
|
+
// then, one by one, in the first one we require a change of network.
|
|
37
|
+
const [connectedWalletWithInvalidNetwork] = connectedWalletsWithInvalidNetwork;
|
|
38
|
+
// Keeps the first wallet connectedWallet in setSelectedWalletConnector
|
|
39
|
+
// This is required because NetworkNotSupported uses walletConnector to display wallet icon, address etc.
|
|
40
|
+
if (connectedWalletWithInvalidNetwork.connector.name !==
|
|
41
|
+
(selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name)) {
|
|
42
|
+
setSelectedWalletConnector(connectedWalletWithInvalidNetwork.connector);
|
|
43
|
+
}
|
|
44
|
+
const networkNotSupportedView = isProgrammableNetworkSwitchSupported(connectedWalletWithInvalidNetwork.connector)
|
|
45
|
+
? 'network-not-supported'
|
|
46
|
+
: 'network-not-supported-manual';
|
|
47
|
+
if (!showAuthFlow) {
|
|
48
|
+
setShowAuthFlow(true);
|
|
49
|
+
}
|
|
50
|
+
setView(networkNotSupportedView);
|
|
51
|
+
}
|
|
52
|
+
}, [
|
|
53
|
+
isBridgeFlow,
|
|
54
|
+
connectedWallets,
|
|
55
|
+
view,
|
|
56
|
+
selectedWalletConnector,
|
|
57
|
+
walletsToConnectByChain,
|
|
58
|
+
showAuthFlow,
|
|
59
|
+
setView,
|
|
60
|
+
setSelectedWalletConnector,
|
|
61
|
+
setShowAuthFlow,
|
|
62
|
+
]);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { useConnectedWalletsNetworkValidation };
|
|
@@ -22,7 +22,7 @@ var validators = require('../../../context/DynamicContext/validators.cjs');
|
|
|
22
22
|
require('@dynamic-labs/multi-wallet');
|
|
23
23
|
var index = require('../../functions/getEnabledProviders/index.cjs');
|
|
24
24
|
|
|
25
|
-
const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, }) => {
|
|
25
|
+
const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dynamicContextProps, }) => {
|
|
26
26
|
const [lsSettings, setLsSettings, removeLsSettings] = useLocalStorage.useLocalStorage(localStorage.PROJECT_SETTINGS_STORAGE_KEY, undefined, validators.validateLocalStorageExpiry);
|
|
27
27
|
const [isLoading, setLoading] = React.useState(false);
|
|
28
28
|
const [retries, setRetries] = React.useState(0);
|
|
@@ -44,6 +44,7 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, })
|
|
|
44
44
|
environmentId &&
|
|
45
45
|
retries < maxRetries) {
|
|
46
46
|
setLoading(true);
|
|
47
|
+
api.sendDynamicProps(environmentId, dynamicContextProps);
|
|
47
48
|
api.fetchProjectSettings(environmentId)
|
|
48
49
|
.then((response) => {
|
|
49
50
|
if (!response)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { DynamicContextProps } from '../../../context/DynamicContext';
|
|
1
2
|
export type fetchProjectSettingsProps = {
|
|
2
3
|
authToken: string | undefined;
|
|
3
4
|
environmentId: string;
|
|
4
5
|
maxRetries?: number;
|
|
6
|
+
dynamicContextProps: Pick<DynamicContextProps, 'settings'>;
|
|
5
7
|
};
|
|
6
|
-
export declare const useFetchProjectSettings: ({ authToken, environmentId, maxRetries, }: fetchProjectSettingsProps) => {
|
|
8
|
+
export declare const useFetchProjectSettings: ({ authToken, environmentId, maxRetries, dynamicContextProps, }: fetchProjectSettingsProps) => {
|
|
7
9
|
isLoading: boolean;
|
|
8
10
|
projectSettings: import("@dynamic-labs/sdk-api").ProjectSettings | undefined;
|
|
9
11
|
removeLsSettings: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect, useMemo } from 'react';
|
|
2
2
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
3
|
-
import { fetchProjectSettings } from '../../../data/api.js';
|
|
3
|
+
import { sendDynamicProps, fetchProjectSettings } from '../../../data/api.js';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
@@ -18,7 +18,7 @@ import { validateLocalStorageExpiry } from '../../../context/DynamicContext/vali
|
|
|
18
18
|
import '@dynamic-labs/multi-wallet';
|
|
19
19
|
import { getEnabledProviders } from '../../functions/getEnabledProviders/index.js';
|
|
20
20
|
|
|
21
|
-
const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, }) => {
|
|
21
|
+
const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dynamicContextProps, }) => {
|
|
22
22
|
const [lsSettings, setLsSettings, removeLsSettings] = useLocalStorage(PROJECT_SETTINGS_STORAGE_KEY, undefined, validateLocalStorageExpiry);
|
|
23
23
|
const [isLoading, setLoading] = useState(false);
|
|
24
24
|
const [retries, setRetries] = useState(0);
|
|
@@ -40,6 +40,7 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, })
|
|
|
40
40
|
environmentId &&
|
|
41
41
|
retries < maxRetries) {
|
|
42
42
|
setLoading(true);
|
|
43
|
+
sendDynamicProps(environmentId, dynamicContextProps);
|
|
43
44
|
fetchProjectSettings(environmentId)
|
|
44
45
|
.then((response) => {
|
|
45
46
|
if (!response)
|
|
@@ -14,6 +14,11 @@ const useHandleWalletsToConnect = () => {
|
|
|
14
14
|
setShowAuthFlow(false);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
+
// Avoid showing wallet-list when wallet updates network to the correct one in run time (bridge mode)
|
|
18
|
+
if (walletsToConnectByChain.length === 0) {
|
|
19
|
+
setShowAuthFlow(false);
|
|
20
|
+
return goToInitialView();
|
|
21
|
+
}
|
|
17
22
|
const [firstWallet, ...restOfTheWallets] = walletsToConnectByChain;
|
|
18
23
|
if (firstWallet.numberOfWallets > 1) {
|
|
19
24
|
const updatedWallets = [
|
|
@@ -10,6 +10,11 @@ const useHandleWalletsToConnect = () => {
|
|
|
10
10
|
setShowAuthFlow(false);
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
+
// Avoid showing wallet-list when wallet updates network to the correct one in run time (bridge mode)
|
|
14
|
+
if (walletsToConnectByChain.length === 0) {
|
|
15
|
+
setShowAuthFlow(false);
|
|
16
|
+
return goToInitialView();
|
|
17
|
+
}
|
|
13
18
|
const [firstWallet, ...restOfTheWallets] = walletsToConnectByChain;
|
|
14
19
|
if (firstWallet.numberOfWallets > 1) {
|
|
15
20
|
const updatedWallets = [
|
|
@@ -11,6 +11,18 @@ var isEmailVerificationRequired = require('../../functions/authenication/isEmail
|
|
|
11
11
|
var EmailVerificationContext = require('../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
12
12
|
var useEmailVerificationRequest = require('../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs');
|
|
13
13
|
var useUpdateUserProfileByJWTCallback = require('../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
14
|
+
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
15
|
+
require('@dynamic-labs/iconic');
|
|
16
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
17
|
+
require('react/jsx-runtime');
|
|
18
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
19
|
+
require('../../../shared/logger.cjs');
|
|
20
|
+
require('@dynamic-labs/wallet-book');
|
|
21
|
+
require('@dynamic-labs/utils');
|
|
22
|
+
require('../../constants/colors.cjs');
|
|
23
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
24
|
+
require('ethers');
|
|
25
|
+
require('../../../shared/consts/index.cjs');
|
|
14
26
|
|
|
15
27
|
// User Fields Schema without captchaToken and policiesConsent properties
|
|
16
28
|
const userFieldsSchema = yup.object().shape({
|
|
@@ -33,11 +45,14 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
33
45
|
const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest.useEmailVerificationRequest();
|
|
34
46
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
35
47
|
const updateUser = React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a, _b;
|
|
48
|
+
var _a, _b, _c;
|
|
37
49
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
38
50
|
stripUnknown: validationSchemaStripUnknown,
|
|
39
51
|
});
|
|
40
52
|
const updateUserProfileResponse = yield api.updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
|
|
53
|
+
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
54
|
+
const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
|
|
55
|
+
const userProfileHasMissingFields = ((_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : []).length > 0;
|
|
41
56
|
const _isEmailVerificationRequired = isEmailVerificationRequired.isEmailVerificationRequired(updateUserProfileResponse);
|
|
42
57
|
if (!_isEmailVerificationRequired) {
|
|
43
58
|
// If email verification is not needed then we can update the user profile immediately.
|
|
@@ -45,11 +60,12 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
45
60
|
return {
|
|
46
61
|
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
47
62
|
updateUserProfileResponse,
|
|
63
|
+
userProfileHasMissingFields,
|
|
48
64
|
};
|
|
49
65
|
}
|
|
50
66
|
// We update EmailContext to use this information in the Email Verification view
|
|
51
|
-
setEmail((
|
|
52
|
-
setVerificationUUID((
|
|
67
|
+
setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
|
|
68
|
+
setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
|
|
53
69
|
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
54
70
|
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
55
71
|
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
@@ -60,6 +76,7 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
60
76
|
return {
|
|
61
77
|
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
62
78
|
updateUserProfileResponse,
|
|
79
|
+
userProfileHasMissingFields,
|
|
63
80
|
verifyEmailFn: scopedVerifyEmailFn,
|
|
64
81
|
};
|
|
65
82
|
}), [
|
|
@@ -6,10 +6,12 @@ export declare const useUserUpdateRequestInternal: ({ validationSchemaStripUnkno
|
|
|
6
6
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
7
7
|
isEmailVerificationRequired: false;
|
|
8
8
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
9
|
+
userProfileHasMissingFields: boolean;
|
|
9
10
|
verifyEmailFn?: undefined;
|
|
10
11
|
} | {
|
|
11
12
|
isEmailVerificationRequired: true;
|
|
12
13
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
14
|
+
userProfileHasMissingFields: boolean;
|
|
13
15
|
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
14
16
|
}>;
|
|
15
17
|
};
|
|
@@ -17,10 +19,12 @@ export declare const useUserUpdateRequest: () => {
|
|
|
17
19
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
18
20
|
isEmailVerificationRequired: false;
|
|
19
21
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
22
|
+
userProfileHasMissingFields: boolean;
|
|
20
23
|
verifyEmailFn?: undefined;
|
|
21
24
|
} | {
|
|
22
25
|
isEmailVerificationRequired: true;
|
|
23
26
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
27
|
+
userProfileHasMissingFields: boolean;
|
|
24
28
|
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
25
29
|
}>;
|
|
26
30
|
};
|