@dynamic-labs/sdk-react-core 1.1.0-alpha.7 → 1.1.0-alpha.9

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.
Files changed (159) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +12 -11
  5. package/src/index.cjs +4 -2
  6. package/src/index.js +2 -1
  7. package/src/lib/Main.cjs +4 -5
  8. package/src/lib/Main.js +4 -5
  9. package/src/lib/components/ChainCard/ChainCard.d.ts +2 -2
  10. package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.cjs +5 -1
  11. package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.js +5 -1
  12. package/src/lib/components/Toggle/Toggle.cjs +14 -0
  13. package/src/lib/components/Toggle/Toggle.d.ts +7 -0
  14. package/src/lib/components/Toggle/Toggle.js +10 -0
  15. package/src/lib/components/Toggle/index.d.ts +1 -0
  16. package/src/lib/context/DynamicContext/DynamicContext.cjs +42 -34
  17. package/src/lib/context/DynamicContext/DynamicContext.js +43 -35
  18. package/src/lib/context/DynamicContext/hooks/index.d.ts +1 -1
  19. package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/index.d.ts +1 -0
  20. package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.cjs +48 -0
  21. package/src/lib/context/DynamicContext/hooks/{useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.d.ts → useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.d.ts} +4 -7
  22. package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.js +44 -0
  23. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/index.d.ts +1 -0
  24. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +59 -0
  25. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.d.ts +37 -0
  26. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +55 -0
  27. package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +1 -0
  28. package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +1 -0
  29. package/src/lib/context/DynamicContext/types/index.d.ts +11 -7
  30. package/src/lib/context/DynamicContext/useDynamicContext.cjs +8 -2
  31. package/src/lib/context/DynamicContext/useDynamicContext.d.ts +4 -1
  32. package/src/lib/context/DynamicContext/useDynamicContext.js +8 -2
  33. package/src/lib/context/FundingContext/FundingContext.cjs +4 -1
  34. package/src/lib/context/FundingContext/FundingContext.js +4 -1
  35. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -1
  36. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -1
  37. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  38. package/src/lib/events/dynamicEvents.d.ts +3 -0
  39. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.cjs +2 -2
  40. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.js +2 -2
  41. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.cjs +5 -5
  42. package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.js +5 -5
  43. package/src/lib/locale/en/translation.cjs +18 -2
  44. package/src/lib/locale/en/translation.d.ts +17 -1
  45. package/src/lib/locale/en/translation.js +18 -2
  46. package/src/lib/shared/assets/alt-key.cjs +54 -0
  47. package/src/lib/shared/assets/alt-key.js +30 -0
  48. package/src/lib/shared/assets/index.d.ts +1 -0
  49. package/src/lib/shared/types/index.d.ts +3 -0
  50. package/src/lib/styles/index.shadow.cjs +1 -1
  51. package/src/lib/styles/index.shadow.js +1 -1
  52. package/src/lib/utils/functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.cjs +2 -4
  53. package/src/lib/utils/functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.js +2 -4
  54. package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.cjs +13 -2
  55. package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.js +13 -2
  56. package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +3 -3
  57. package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +4 -4
  58. package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +1 -1
  59. package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +1 -1
  60. package/src/lib/utils/hooks/index.d.ts +1 -0
  61. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +3 -2
  62. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +6 -1
  63. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +3 -2
  64. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
  65. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
  66. package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.cjs +3 -3
  67. package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.js +3 -3
  68. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +1 -1
  69. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +2 -2
  70. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +1 -1
  71. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +2 -2
  72. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +2 -2
  73. package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +23 -13
  74. package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.d.ts +1 -1
  75. package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +23 -13
  76. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +9 -6
  77. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +9 -6
  78. package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +5 -3
  79. package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +5 -3
  80. package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +6 -8
  81. package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +6 -8
  82. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -1
  83. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -1
  84. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs +8 -5
  85. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js +8 -5
  86. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
  87. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
  88. package/src/lib/utils/hooks/useWalletConnectorNetwork/index.d.ts +1 -0
  89. package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs +42 -0
  90. package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.d.ts +18 -0
  91. package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js +38 -0
  92. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +2 -2
  93. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +2 -2
  94. package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.cjs +5 -2
  95. package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.js +5 -2
  96. package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs +1 -1
  97. package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js +1 -1
  98. package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +1 -1
  99. package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +1 -1
  100. package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.cjs +1 -1
  101. package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.js +1 -1
  102. package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
  103. package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
  104. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +20 -18
  105. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +20 -18
  106. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +55 -30
  107. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +7 -1
  108. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +55 -31
  109. package/src/lib/views/LoginView/LoginView.cjs +60 -7
  110. package/src/lib/views/LoginView/LoginView.js +60 -7
  111. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -1
  112. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -1
  113. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +3 -4
  114. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +3 -4
  115. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +3 -6
  116. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +3 -6
  117. package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.cjs +1 -1
  118. package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.js +1 -1
  119. package/src/lib/views/QrCodeView/QRCode.cjs +2 -3
  120. package/src/lib/views/QrCodeView/QRCode.js +2 -3
  121. package/src/lib/views/WalletGroupView/WalletGroupView.cjs +72 -1
  122. package/src/lib/views/WalletGroupView/WalletGroupView.js +73 -2
  123. package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.cjs +74 -0
  124. package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.d.ts +7 -0
  125. package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.js +70 -0
  126. package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/index.d.ts +1 -0
  127. package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +2 -4
  128. package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.d.ts +2 -1
  129. package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +2 -4
  130. package/src/lib/views/WalletUsedView/WalletUsedView.cjs +5 -5
  131. package/src/lib/views/WalletUsedView/WalletUsedView.js +5 -5
  132. package/src/lib/views/viewToComponentMap.cjs +1 -0
  133. package/src/lib/views/viewToComponentMap.js +1 -0
  134. package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.cjs +6 -3
  135. package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.js +6 -3
  136. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.cjs +76 -0
  137. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.d.ts +9 -0
  138. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.js +72 -0
  139. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/index.d.ts +1 -0
  140. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.cjs +67 -0
  141. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.d.ts +9 -0
  142. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.js +63 -0
  143. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/index.d.ts +1 -0
  144. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +9 -8
  145. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +9 -8
  146. package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.cjs +66 -21
  147. package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.d.ts +1 -1
  148. package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.js +67 -22
  149. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +2 -2
  150. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +2 -2
  151. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +7 -3
  152. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +7 -3
  153. package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +8 -6
  154. package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +8 -6
  155. package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +2 -2
  156. package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +2 -2
  157. package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/index.d.ts +0 -1
  158. package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs +0 -33
  159. package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js +0 -29
@@ -1,6 +1,6 @@
1
1
  import { __awaiter } from '../../../../_virtual/_tslib.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { createContext, useState, useEffect, useCallback, useRef, useMemo } from 'react';
3
+ import { createContext, useState, useRef, useEffect, useCallback, useMemo } from 'react';
4
4
  import { I18nextProvider } from 'react-i18next';
5
5
  import { ICONIC_SPRITE_URL } from '@dynamic-labs/iconic';
6
6
  import { MissingEnvironmentIdError } from '@dynamic-labs/utils';
@@ -30,7 +30,6 @@ import { AccountExistsContextProvider } from '../AccountExistsContext/AccountExi
30
30
  import { revokeSession, sendDynamicProps } from '../../data/api.js';
31
31
  import { EmailVerificationContextProvider } from '../EmailVerificationContext/EmailVerificationContext.js';
32
32
  import 'react-dom';
33
- import { isSameWalletName } from '../../utils/functions/isSameWalletName/isSameWalletName.js';
34
33
  import { useFetchNonce } from '../../utils/hooks/useFetchNonce/useFetchNonce.js';
35
34
  import { useFetchProjectSettings } from '../../utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js';
36
35
  import { ThemeContextProvider } from '../ThemeContext/ThemeContext.js';
@@ -68,10 +67,10 @@ import { useMultiWalletWidgetState } from '../../utils/hooks/multiWallet/useMult
68
67
  import { useMultiWallet } from '../../utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js';
69
68
  import { useClearWalletConnectSessions } from '../../utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.js';
70
69
  import { useConnectWallet } from '../../utils/hooks/useConnectWallet/useConnectWallet.js';
71
- import { useProcessNetworkConfigurations } from '../../utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js';
72
70
  import { useFetchWalletsForChainsMap } from '../../utils/hooks/useFetchWalletsForChainsMap/useFetchWalletsForChainsMap.js';
73
71
  import { useHandleUnlinkWallet } from '../../utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js';
74
72
  import { usePrimaryWalletId } from '../../utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js';
73
+ import { useProcessNetworkConfigurations } from '../../utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js';
75
74
  import { useRpcProviders } from '../../utils/hooks/useRpcProviders/useRpcProviders.js';
76
75
  import { useWalletEventListeners } from '../../utils/hooks/useWalletEventListeners/useWalletEventListeners.js';
77
76
  import { DynamicBridgeWidgetContextProvider } from '../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
@@ -90,23 +89,24 @@ import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/P
90
89
  import '../../views/WalletList/WalletList.js';
91
90
  import '../../views/viewToComponentMap.js';
92
91
  import { FundingWidget } from '../../widgets/FundingWidget/FundingWidget.js';
92
+ import { ConnectWithEmailOtpProvider } from '../ConnectWithEmailOtpContext/ConnectWithEmailOtpProvider.js';
93
+ import '../ConnectWithEmailOtpContext/connectWithEmailOtpContext.js';
93
94
  import { FundingContextProvider } from '../FundingContext/FundingContext.js';
94
95
  import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceContext.js';
95
96
  import { UseNetworkValidation } from '../UseNetworkValidation/UseNetworkValidation.js';
96
97
  import { UserWalletsProvider } from '../UserWalletsContext/UserWalletsContext.js';
97
98
  import { WalletContextProvider } from '../WalletContext/WalletContext.js';
98
- import { ConnectWithEmailOtpProvider } from '../ConnectWithEmailOtpContext/ConnectWithEmailOtpProvider.js';
99
- import '../ConnectWithEmailOtpContext/connectWithEmailOtpContext.js';
100
99
  import { handleDisconnectWallet } from './handleDisconnectWallet/handleDisconnectWallet.js';
101
100
  import { initExpirationTime, getInitialView } from './helpers.js';
102
101
  import { useDisplayOrderState } from './hooks/useDisplayOrderState/useDisplayOrderState.js';
103
102
  import { useEmailLoginState } from './hooks/useEmailLoginState/useEmailLoginState.js';
104
103
  import { useNameService } from './hooks/useNameService/useNameService.js';
105
104
  import { useSelectedWalletConnector } from './hooks/useSelectedWalletConnector/useSelectedWalletConnector.js';
106
- import { useSetShowAuthFlowWithInit } from './hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js';
105
+ import { useShowAuthFlow } from './hooks/useShowAuthFlow/useShowAuthFlow.js';
107
106
  import { useShowPasskeyCreateSuccess } from './hooks/useShowPasskeyCreateSuccess/useShowPasskeyCreateSuccess.js';
108
107
  import { useTieCallbacksToEvents } from './hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js';
109
108
  import { useVerificationInProgress } from './hooks/useVerificationInProgress/useVerificationInProgress.js';
109
+ import { useSetShowLinkNewWalletModal } from './hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.js';
110
110
  import { useCustomerCallbacks } from './useCustomerCallbacks/useCustomerCallbacks.js';
111
111
  import { useCustomerAuthFlowCallbacks } from './useCustomerCallbacks/useCustomerAuthFlowCallbacks.js';
112
112
  import { validateAuthUser } from './validators.js';
@@ -116,7 +116,7 @@ const EMPTY_INITIAL_USER = undefined;
116
116
  const DynamicContext = createContext(undefined);
117
117
  /** The context provider itself we only use internally */
118
118
  const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) => {
119
- var _a, _b, _c, _d, _e, _f, _g, _h;
119
+ var _a, _b, _c, _d, _e, _f;
120
120
  const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, enableForcedNetworkValidation: enableForcedNetworkValidationProp = false, deepLinkPreference = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = true, walletConnectPreferredChains, walletConnectorExtensions, } = settings;
121
121
  let enableForcedNetworkValidation = enableForcedNetworkValidationProp;
122
122
  if (bridgeChains) {
@@ -125,7 +125,8 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
125
125
  // Ties all client callbacks to dynamic's events, such that
126
126
  // when our events are triggered, so are the client callbacks
127
127
  useTieCallbacksToEvents(eventsCallbacks);
128
- let { walletConnectV1Bridge, appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', } = settings;
128
+ let { appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', } = settings;
129
+ const { walletConnectV1Bridge } = settings;
129
130
  if (!environmentId) {
130
131
  throw new MissingEnvironmentIdError();
131
132
  }
@@ -140,7 +141,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
140
141
  const isAuthenticated = Boolean(getAuthToken());
141
142
  const isBridgeFlow = Boolean(bridgeChains);
142
143
  const [onboardingOnlyJwt, setOnboardingOnlyJwt] = useState(undefined);
143
- const [showAuthFlow, setShowAuthFlow] = useState(false);
144
144
  // state to track the full connectivity status of the individual's wallets.
145
145
  // Set to true once the predetermined number of wallets is connected.
146
146
  const [isFullyConnected, setIsFullyConnected, removeIsFullyConnected] = useLocalStorage(IS_FULLY_CONNECTED, false);
@@ -160,15 +160,11 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
160
160
  dynamicContextProps: { settings },
161
161
  environmentId,
162
162
  });
163
- const { multiWallet, setMultiWallet } = useMultiWallet(toolkitEnabled || false, (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.multiWallet);
164
- // for demo proposes when running single wallet
165
- // it should not use bridge even having walletConnectV1Bridge set on settings
166
- // but v2 if enabled
167
- if (toolkitEnabled &&
168
- ((_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.walletConnect) === null || _d === void 0 ? void 0 : _d.v2Enabled) &&
169
- !multiWallet) {
170
- walletConnectV1Bridge = undefined;
171
- }
163
+ const { multiWallet, setMultiWallet } = useMultiWallet({
164
+ isBridgeFlow,
165
+ multiWalletSettings: (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.multiWallet,
166
+ toolkitEnabled: toolkitEnabled || false,
167
+ });
172
168
  // ensures that when user comes back to site and primary wallet is out of sync, we don't show widget popup
173
169
  const [showWidgetStatePopup, setShowWidgetStatePopup] = useState(!multiWallet);
174
170
  // Used inside useVerifyOnAwaitingSignature. Is legacy and should be removed asap
@@ -208,6 +204,14 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
208
204
  });
209
205
  const [authMode, setAuthMode] = useLocalStorage(AUTH_MODE, initialAuthenticationMode);
210
206
  const { clearPrimaryWalletId, primaryWalletId, setPrimaryWalletId } = usePrimaryWalletId();
207
+ const isUserAuthenticated = Boolean(authMode === 'connect-and-sign' ? user : isFullyConnected);
208
+ const isRenderingEmbeddedAuthFlow = useRef(false);
209
+ const [showAuthFlow, setShowAuthFlow] = useShowAuthFlow({
210
+ isAuthenticated: isUserAuthenticated,
211
+ isMultiWalletEnabled: multiWallet,
212
+ isRenderingEmbeddedAuthFlow,
213
+ walletConnectorOptions,
214
+ });
211
215
  const { connectWallet, removeConnectedWalletsInfo, connectedWalletsInfo, getConnectedWalletById, connectedWallets, disconnectWallet, refreshConnectedWallet, } = useConnectWallet({
212
216
  authMode,
213
217
  clearPrimaryWalletId,
@@ -239,12 +243,12 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
239
243
  removeUser();
240
244
  }, [removeUser]);
241
245
  // until user completes onboarding, jwt is only stored in onboardingOnlyJwt
242
- const authToken = (_e = getAuthToken()) !== null && _e !== void 0 ? _e : onboardingOnlyJwt;
246
+ const authToken = (_c = getAuthToken()) !== null && _c !== void 0 ? _c : onboardingOnlyJwt;
243
247
  useSetWalletConnectorVerifiedCredentials(authToken, walletConnectorOptions);
244
248
  const { didConnectedStateLoad, primaryWallet, showQrcodeModal, secondaryWallets, setPrimaryWallet, setShowQrcodeModal, wallets: linkedOrConnectedWallets, } = useWalletConnectors({
245
249
  authMode,
246
250
  authToken: getAuthToken() || onboardingOnlyJwt,
247
- canHaveMultipleWalletsConnected: multiWallet || isBridgeFlow,
251
+ canHaveMultipleWalletsConnected: multiWallet,
248
252
  connectedWallets,
249
253
  multiWalletWidgetState,
250
254
  onboardingOnlyJwt,
@@ -266,13 +270,10 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
266
270
  user,
267
271
  walletBook,
268
272
  });
269
- const isRenderingEmbeddedAuthFlow = useRef(false);
270
- const setShowAuthFlowWithInit = useSetShowAuthFlowWithInit({
273
+ const setShowLinkNewWalletModal = useSetShowLinkNewWalletModal({
274
+ isAuthenticated: isUserAuthenticated,
271
275
  isMultiWalletEnabled: multiWallet,
272
- isRenderingEmbeddedAuthFlow,
273
276
  setShowAuthFlow,
274
- user,
275
- walletConnectorOptions,
276
277
  });
277
278
  const { getNameService, removeConnectedNameService } = useNameService({
278
279
  authToken,
@@ -285,7 +286,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
285
286
  clearOphanedWalletConnectSessions,
286
287
  ]);
287
288
  const handleLogOut = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
288
- var _j, _k;
289
+ var _g, _h;
289
290
  setSdkHasLoaded(false);
290
291
  clearAllWalletConnectSessions();
291
292
  setBridgeChainsToConnect(bridgeChains);
@@ -311,7 +312,12 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
311
312
  setIsVerificationInProgress(false);
312
313
  setLegacyIsVerifying(false);
313
314
  setAuthMode(initialAuthenticationMode);
314
- setShowAuthFlow(false);
315
+ setShowAuthFlow(false, {
316
+ emitCancelAuth: false,
317
+ ignoreIfIsEmbeddedWidget: false,
318
+ initializeWalletConnect: false,
319
+ performMultiWalletChecks: false,
320
+ });
315
321
  setMultiWalletWidgetState('idle');
316
322
  removeAuthTokenAndUser();
317
323
  removeLsSettings();
@@ -322,12 +328,12 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
322
328
  clearPrimaryWalletId();
323
329
  removeConnectedNameService();
324
330
  for (const connectedWallet of connectedWallets) {
325
- (_j = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onDisconnect) === null || _j === void 0 ? void 0 : _j.call(eventsCallbacks, {
331
+ (_g = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onDisconnect) === null || _g === void 0 ? void 0 : _g.call(eventsCallbacks, {
326
332
  wallet: connectedWallet,
327
333
  walletConnector: connectedWallet === null || connectedWallet === void 0 ? void 0 : connectedWallet.connector,
328
334
  });
329
335
  }
330
- (_k = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLogout) === null || _k === void 0 ? void 0 : _k.call(eventsCallbacks, user);
336
+ (_h = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLogout) === null || _h === void 0 ? void 0 : _h.call(eventsCallbacks, user);
331
337
  dynamicEvents.emit('logout');
332
338
  }), [
333
339
  setSdkHasLoaded,
@@ -339,6 +345,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
339
345
  setIsVerificationInProgress,
340
346
  setAuthMode,
341
347
  initialAuthenticationMode,
348
+ setShowAuthFlow,
342
349
  setMultiWalletWidgetState,
343
350
  removeAuthTokenAndUser,
344
351
  removeLsSettings,
@@ -356,7 +363,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
356
363
  let wcVersion;
357
364
  if (projectSettings) {
358
365
  wcVersion =
359
- ((_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.walletConnect) === null || _g === void 0 ? void 0 : _g.v2Enabled) && !walletConnectV1Bridge
366
+ ((_e = (_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.walletConnect) === null || _e === void 0 ? void 0 : _e.v2Enabled) && !walletConnectV1Bridge
360
367
  ? 2
361
368
  : 1;
362
369
  }
@@ -444,7 +451,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
444
451
  }
445
452
  if (selectedWalletConnector &&
446
453
  (!primaryWallet ||
447
- !isSameWalletName(primaryWallet.connector.name, selectedWalletConnector.name))) {
454
+ primaryWallet.connector.key !== selectedWalletConnector.key)) {
448
455
  yield (selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.endSession());
449
456
  }
450
457
  }), [
@@ -495,7 +502,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
495
502
  handleLogOut,
496
503
  handleUnlinkWallet: authMode === 'connect-only' ? disconnectWallet : handleUnlinkWallet,
497
504
  i18nSDKInstance,
498
- internalSetShowAuthFlow: setShowAuthFlow,
499
505
  isAuthenticated,
500
506
  isBridgeFlow,
501
507
  isFullyConnected,
@@ -551,9 +557,10 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
551
557
  setSdkHasLoaded,
552
558
  setSelectedWalletConnectorKey,
553
559
  setSelectedWalletWithAction,
554
- setShowAuthFlow: setShowAuthFlowWithInit,
560
+ setShowAuthFlow,
555
561
  setShowBridgeWidget,
556
562
  setShowDynamicUserProfile,
563
+ setShowLinkNewWalletModal,
557
564
  setShowPasskeyCreatedSuccess,
558
565
  setShowQrcodeModal,
559
566
  setShowWidgetStatePopup,
@@ -659,7 +666,8 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
659
666
  setPrimaryWalletId,
660
667
  setSdkHasLoaded,
661
668
  setSelectedWalletConnectorKey,
662
- setShowAuthFlowWithInit,
669
+ setShowAuthFlow,
670
+ setShowLinkNewWalletModal,
663
671
  setShowPasskeyCreatedSuccess,
664
672
  setShowQrcodeModal,
665
673
  setUser,
@@ -720,7 +728,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
720
728
  setShowDynamicUserProfile(true);
721
729
  }
722
730
  }, [multiWallet, multiWalletWidgetState, showDynamicUserProfile, user]);
723
- return (jsx(I18nextProvider, { i18n: i18nSDKInstance, children: jsx(DynamicContext.Provider, { value: value, children: jsx(WalletBookContextProvider, { walletBook: walletBook, children: jsx(ThemeContextProvider, { customerTheme: parseTheme(theme, ((_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _h === void 0 ? void 0 : _h.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design, children: jsx(LoadingContextProvider, { children: jsx(ErrorContextProvider, { children: jsxs(ViewContextProvider, { initialView: getInitialView({
731
+ return (jsx(I18nextProvider, { i18n: i18nSDKInstance, children: jsx(DynamicContext.Provider, { value: value, children: jsx(WalletBookContextProvider, { walletBook: walletBook, children: jsx(ThemeContextProvider, { customerTheme: parseTheme(theme, ((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _f === void 0 ? void 0 : _f.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design, children: jsx(LoadingContextProvider, { children: jsx(ErrorContextProvider, { children: jsxs(ViewContextProvider, { initialView: getInitialView({
724
732
  connectedWallets,
725
733
  isAuthenticated,
726
734
  isBridgeFlow,
@@ -2,7 +2,7 @@ export * from './useDisplayOrderState';
2
2
  export * from './useEmailLoginState';
3
3
  export * from './useNameService';
4
4
  export * from './useSelectedWalletConnector';
5
- export * from './useSetShowAuthFlowWithInit';
5
+ export * from './useShowAuthFlow';
6
6
  export * from './useShowPasskeyCreateSuccess';
7
7
  export * from './useTieCallbacksToEvents';
8
8
  export * from './useVerificationInProgress';
@@ -0,0 +1 @@
1
+ export * from './useSetShowLinkNewWalletModal';
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ require('@dynamic-labs/sdk-api');
7
+ var logger = require('../../../../shared/logger.cjs');
8
+ require('@dynamic-labs/iconic');
9
+ require('@dynamic-labs/wallet-connector-core');
10
+ require('react/jsx-runtime');
11
+ require('../../../ViewContext/ViewContext.cjs');
12
+ require('@dynamic-labs/wallet-book');
13
+ require('../../../../utils/constants/colors.cjs');
14
+ require('../../../../shared/utils/classes/storage/localStorage.cjs');
15
+ require('viem');
16
+ require('@dynamic-labs/utils');
17
+ require('../../../../shared/consts/index.cjs');
18
+
19
+ /**
20
+ * this hook wraps `setShowAuthFlow`. WalletConnect requires initialization
21
+ * before we can connect a wallet. The goal here is that when a user clicks
22
+ * on the "Connect your wallet" button, the SDK starts initializing WalletConnect
23
+ * and will prime it for connection. This way, when the user clicks on the
24
+ * "Connect" button in the WalletConnect modal, there is a uri ready to go
25
+ * to immediately trigger the deep link on mobile
26
+ */
27
+ const useSetShowLinkNewWalletModal = ({ setShowAuthFlow, isMultiWalletEnabled, isAuthenticated, }) => {
28
+ const setSetShowLinkNewWalletModalWithInit = React.useCallback((value) => {
29
+ if (value) {
30
+ // Do not change state if the user is already signed in and multi-wallet is not enabled
31
+ if (!isAuthenticated)
32
+ return;
33
+ if (!isMultiWalletEnabled) {
34
+ logger.logger.warn('setShowLinkNewWalletModal was called while the user was not logged in. This results in a no-op. To log the user in, use setShowAuthFlow. For more information, see: https://docs.dynamic.xyz/react-sdk/hooks/usedynamiccontext');
35
+ return;
36
+ }
37
+ }
38
+ setShowAuthFlow(value, {
39
+ emitCancelAuth: true,
40
+ ignoreIfIsEmbeddedWidget: true,
41
+ initializeWalletConnect: true,
42
+ performMultiWalletChecks: false,
43
+ });
44
+ }, [setShowAuthFlow, isAuthenticated, isMultiWalletEnabled]);
45
+ return setSetShowLinkNewWalletModalWithInit;
46
+ };
47
+
48
+ exports.useSetShowLinkNewWalletModal = useSetShowLinkNewWalletModal;
@@ -1,6 +1,5 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- import { UserProfile, WalletOption } from '../../../../shared';
3
- import { IDynamicContext } from '../../types';
2
+ import { SetShowAuthFlow } from '../useShowAuthFlow';
4
3
  /**
5
4
  * this hook wraps `setShowAuthFlow`. WalletConnect requires initialization
6
5
  * before we can connect a wallet. The goal here is that when a user clicks
@@ -9,10 +8,8 @@ import { IDynamicContext } from '../../types';
9
8
  * "Connect" button in the WalletConnect modal, there is a uri ready to go
10
9
  * to immediately trigger the deep link on mobile
11
10
  */
12
- export declare const useSetShowAuthFlowWithInit: ({ setShowAuthFlow, walletConnectorOptions, user, isMultiWalletEnabled, isRenderingEmbeddedAuthFlow, }: {
13
- setShowAuthFlow: Dispatch<SetStateAction<boolean>>;
14
- isRenderingEmbeddedAuthFlow: IDynamicContext['isRenderingEmbeddedAuthFlow'];
15
- walletConnectorOptions: WalletOption[];
16
- user?: UserProfile | undefined;
11
+ export declare const useSetShowLinkNewWalletModal: ({ setShowAuthFlow, isMultiWalletEnabled, isAuthenticated, }: {
12
+ setShowAuthFlow: SetShowAuthFlow;
17
13
  isMultiWalletEnabled?: boolean | undefined;
14
+ isAuthenticated: boolean;
18
15
  }) => Dispatch<SetStateAction<boolean>>;
@@ -0,0 +1,44 @@
1
+ import { useCallback } from 'react';
2
+ import '@dynamic-labs/sdk-api';
3
+ import { logger } from '../../../../shared/logger.js';
4
+ import '@dynamic-labs/iconic';
5
+ import '@dynamic-labs/wallet-connector-core';
6
+ import 'react/jsx-runtime';
7
+ import '../../../ViewContext/ViewContext.js';
8
+ import '@dynamic-labs/wallet-book';
9
+ import '../../../../utils/constants/colors.js';
10
+ import '../../../../shared/utils/classes/storage/localStorage.js';
11
+ import 'viem';
12
+ import '@dynamic-labs/utils';
13
+ import '../../../../shared/consts/index.js';
14
+
15
+ /**
16
+ * this hook wraps `setShowAuthFlow`. WalletConnect requires initialization
17
+ * before we can connect a wallet. The goal here is that when a user clicks
18
+ * on the "Connect your wallet" button, the SDK starts initializing WalletConnect
19
+ * and will prime it for connection. This way, when the user clicks on the
20
+ * "Connect" button in the WalletConnect modal, there is a uri ready to go
21
+ * to immediately trigger the deep link on mobile
22
+ */
23
+ const useSetShowLinkNewWalletModal = ({ setShowAuthFlow, isMultiWalletEnabled, isAuthenticated, }) => {
24
+ const setSetShowLinkNewWalletModalWithInit = useCallback((value) => {
25
+ if (value) {
26
+ // Do not change state if the user is already signed in and multi-wallet is not enabled
27
+ if (!isAuthenticated)
28
+ return;
29
+ if (!isMultiWalletEnabled) {
30
+ logger.warn('setShowLinkNewWalletModal was called while the user was not logged in. This results in a no-op. To log the user in, use setShowAuthFlow. For more information, see: https://docs.dynamic.xyz/react-sdk/hooks/usedynamiccontext');
31
+ return;
32
+ }
33
+ }
34
+ setShowAuthFlow(value, {
35
+ emitCancelAuth: true,
36
+ ignoreIfIsEmbeddedWidget: true,
37
+ initializeWalletConnect: true,
38
+ performMultiWalletChecks: false,
39
+ });
40
+ }, [setShowAuthFlow, isAuthenticated, isMultiWalletEnabled]);
41
+ return setSetShowLinkNewWalletModalWithInit;
42
+ };
43
+
44
+ export { useSetShowLinkNewWalletModal };
@@ -0,0 +1 @@
1
+ export * from './useShowAuthFlow';
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var dynamicEvents = require('../../../../events/dynamicEvents.cjs');
7
+ require('@dynamic-labs/sdk-api');
8
+ var logger = require('../../../../shared/logger.cjs');
9
+ require('@dynamic-labs/iconic');
10
+ require('@dynamic-labs/wallet-connector-core');
11
+ require('react/jsx-runtime');
12
+ require('../../../ViewContext/ViewContext.cjs');
13
+ require('@dynamic-labs/wallet-book');
14
+ require('../../../../utils/constants/colors.cjs');
15
+ require('../../../../shared/utils/classes/storage/localStorage.cjs');
16
+ require('viem');
17
+ require('@dynamic-labs/utils');
18
+ require('../../../../shared/consts/index.cjs');
19
+
20
+ /**
21
+ * There are a multitude of scenarios where we want to ignore or insert functionality to calls
22
+ * to setShowAuthFlow. This hook wraps it with an options parameter to allow encapsulating these
23
+ * different scenarios and makes it especially easy to customize exactly which version of this method
24
+ * is being passed to useDynamicContext.
25
+ */
26
+ const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMultiWalletEnabled, walletConnectorOptions, }) => {
27
+ const [showAuthFlow, _setShowAuthFlow] = React.useState(false);
28
+ const setShowAuthFlow = React.useCallback((value, options = {}) => {
29
+ var _a;
30
+ const { emitCancelAuth, ignoreIfIsEmbeddedWidget, initializeWalletConnect, performMultiWalletChecks, } = Object.assign({ emitCancelAuth: false, ignoreIfIsEmbeddedWidget: true, initializeWalletConnect: true, performMultiWalletChecks: false }, options);
31
+ if (value) {
32
+ if (ignoreIfIsEmbeddedWidget && isRenderingEmbeddedAuthFlow.current)
33
+ return;
34
+ if (performMultiWalletChecks && isAuthenticated) {
35
+ if (!isMultiWalletEnabled) {
36
+ logger.logger.warn('setShowAuthFlow was called while the user is logged in, but Dynamic is not configured with multi-wallet enabled. This results in a no-op.');
37
+ return;
38
+ }
39
+ logger.logger.warn('Using setShowAuthFlow to render the wallet list when the user is logged in is deprecated. Use setShowLinkNewWalletModal instead. For more information, see: https://docs.dynamic.xyz/react-sdk/hooks/usedynamiccontext');
40
+ }
41
+ if (initializeWalletConnect) {
42
+ (_a = walletConnectorOptions
43
+ .find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
44
+ }
45
+ }
46
+ else if (emitCancelAuth && showAuthFlow)
47
+ dynamicEvents.dynamicEvents.emit('authFlowCancelled');
48
+ _setShowAuthFlow(value);
49
+ }, [
50
+ isAuthenticated,
51
+ isMultiWalletEnabled,
52
+ isRenderingEmbeddedAuthFlow,
53
+ showAuthFlow,
54
+ walletConnectorOptions,
55
+ ]);
56
+ return [showAuthFlow, setShowAuthFlow];
57
+ };
58
+
59
+ exports.useShowAuthFlow = useShowAuthFlow;
@@ -0,0 +1,37 @@
1
+ import { SetStateAction } from 'react';
2
+ import { WalletOption } from '../../../../shared';
3
+ import { IDynamicContext } from '../../types';
4
+ export type SetShowAuthFlowOptions = {
5
+ /**
6
+ * WalletConnect requires initialization before we can connect a wallet.
7
+ * The goal here is that when the auth flow opens, the
8
+ * SDK starts initializing WalletConnect and will prime it for connection.
9
+ * This way, when the user clicks on the "Connect" button in the WalletConnect modal,
10
+ * there is a uri ready to go to immediately trigger the deep link on mobile
11
+ */
12
+ initializeWalletConnect?: boolean;
13
+ /** Makes this call be ignored if setting to true when there is an embedded widget on screen */
14
+ ignoreIfIsEmbeddedWidget?: boolean;
15
+ /**
16
+ * When setting to true while logged in:
17
+ * 1. If multi wallet is false, ignores the call — handy to prevent users from
18
+ * getting to the link new wallet screen without multi wallet
19
+ * 2. If multi wallet is true, logs a warning to use setShowLinkNewWalletModal instead
20
+ */
21
+ performMultiWalletChecks?: boolean;
22
+ /** When setting to false, emits authFlowCancelled event and callback */
23
+ emitCancelAuth?: boolean;
24
+ };
25
+ export type SetShowAuthFlow = (value: SetStateAction<boolean>, options?: SetShowAuthFlowOptions) => void;
26
+ /**
27
+ * There are a multitude of scenarios where we want to ignore or insert functionality to calls
28
+ * to setShowAuthFlow. This hook wraps it with an options parameter to allow encapsulating these
29
+ * different scenarios and makes it especially easy to customize exactly which version of this method
30
+ * is being passed to useDynamicContext.
31
+ */
32
+ export declare const useShowAuthFlow: ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMultiWalletEnabled, walletConnectorOptions, }: {
33
+ isMultiWalletEnabled: boolean;
34
+ isRenderingEmbeddedAuthFlow: IDynamicContext['isRenderingEmbeddedAuthFlow'];
35
+ walletConnectorOptions: WalletOption[];
36
+ isAuthenticated: boolean;
37
+ }) => [boolean, SetShowAuthFlow];
@@ -0,0 +1,55 @@
1
+ import { useState, useCallback } from 'react';
2
+ import { dynamicEvents } from '../../../../events/dynamicEvents.js';
3
+ import '@dynamic-labs/sdk-api';
4
+ import { logger } from '../../../../shared/logger.js';
5
+ import '@dynamic-labs/iconic';
6
+ import '@dynamic-labs/wallet-connector-core';
7
+ import 'react/jsx-runtime';
8
+ import '../../../ViewContext/ViewContext.js';
9
+ import '@dynamic-labs/wallet-book';
10
+ import '../../../../utils/constants/colors.js';
11
+ import '../../../../shared/utils/classes/storage/localStorage.js';
12
+ import 'viem';
13
+ import '@dynamic-labs/utils';
14
+ import '../../../../shared/consts/index.js';
15
+
16
+ /**
17
+ * There are a multitude of scenarios where we want to ignore or insert functionality to calls
18
+ * to setShowAuthFlow. This hook wraps it with an options parameter to allow encapsulating these
19
+ * different scenarios and makes it especially easy to customize exactly which version of this method
20
+ * is being passed to useDynamicContext.
21
+ */
22
+ const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMultiWalletEnabled, walletConnectorOptions, }) => {
23
+ const [showAuthFlow, _setShowAuthFlow] = useState(false);
24
+ const setShowAuthFlow = useCallback((value, options = {}) => {
25
+ var _a;
26
+ const { emitCancelAuth, ignoreIfIsEmbeddedWidget, initializeWalletConnect, performMultiWalletChecks, } = Object.assign({ emitCancelAuth: false, ignoreIfIsEmbeddedWidget: true, initializeWalletConnect: true, performMultiWalletChecks: false }, options);
27
+ if (value) {
28
+ if (ignoreIfIsEmbeddedWidget && isRenderingEmbeddedAuthFlow.current)
29
+ return;
30
+ if (performMultiWalletChecks && isAuthenticated) {
31
+ if (!isMultiWalletEnabled) {
32
+ logger.warn('setShowAuthFlow was called while the user is logged in, but Dynamic is not configured with multi-wallet enabled. This results in a no-op.');
33
+ return;
34
+ }
35
+ logger.warn('Using setShowAuthFlow to render the wallet list when the user is logged in is deprecated. Use setShowLinkNewWalletModal instead. For more information, see: https://docs.dynamic.xyz/react-sdk/hooks/usedynamiccontext');
36
+ }
37
+ if (initializeWalletConnect) {
38
+ (_a = walletConnectorOptions
39
+ .find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
40
+ }
41
+ }
42
+ else if (emitCancelAuth && showAuthFlow)
43
+ dynamicEvents.emit('authFlowCancelled');
44
+ _setShowAuthFlow(value);
45
+ }, [
46
+ isAuthenticated,
47
+ isMultiWalletEnabled,
48
+ isRenderingEmbeddedAuthFlow,
49
+ showAuthFlow,
50
+ walletConnectorOptions,
51
+ ]);
52
+ return [showAuthFlow, setShowAuthFlow];
53
+ };
54
+
55
+ export { useShowAuthFlow };
@@ -70,6 +70,7 @@ const useTieCallbacksToEvents = (clientCallbacks) => {
70
70
  else
71
71
  (_b = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmailVerificationFailure) === null || _b === void 0 ? void 0 : _b.call(clientCallbacks, email);
72
72
  });
73
+ useDynamicEvents.useInternalDynamicEvents('authFlowCancelled', () => { var _a; return (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFlowCancel) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks); });
73
74
  };
74
75
 
75
76
  exports.useTieCallbacksToEvents = useTieCallbacksToEvents;
@@ -66,6 +66,7 @@ const useTieCallbacksToEvents = (clientCallbacks) => {
66
66
  else
67
67
  (_b = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onEmailVerificationFailure) === null || _b === void 0 ? void 0 : _b.call(clientCallbacks, email);
68
68
  });
69
+ useInternalDynamicEvents('authFlowCancelled', () => { var _a; return (_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFlowCancel) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks); });
69
70
  };
70
71
 
71
72
  export { useTieCallbacksToEvents };
@@ -6,7 +6,7 @@ import { AccessDeniedCustomButton, AccountSwitchState, AuthModeType, AwaitingSig
6
6
  import { SocialNetworkIconType } from '../../../utils/functions/getSocialNetworkIcon';
7
7
  import { MultiWalletWidgetStateSetter } from '../../../utils/hooks/multiWallet';
8
8
  import { ThemeData, ThemeSetting } from '../../ThemeContext';
9
- import { DisplayOrder, SetDisplayOrderPriority } from '../hooks';
9
+ import { DisplayOrder, SetDisplayOrderPriority, SetShowAuthFlow } from '../hooks';
10
10
  import { SetCallbackType } from '../useCustomerCallbacks';
11
11
  export type ChainsToConnect = {
12
12
  chain: Chain;
@@ -101,9 +101,8 @@ export interface IDynamicContext {
101
101
  setQrcodeUri: Dispatch<SetStateAction<string>>;
102
102
  setSelectedWalletConnectorKey: (key: string | null) => void;
103
103
  setSelectedWalletWithAction: (walletWithAction: WalletWithAction | null) => void;
104
- setShowAuthFlow: Dispatch<SetStateAction<boolean>>;
105
- /** The unwrapped version of setShowAuthFlow. See useSetShowAuthFlowWithInit.ts for context */
106
- internalSetShowAuthFlow: Dispatch<SetStateAction<boolean>>;
104
+ setShowAuthFlow: SetShowAuthFlow;
105
+ setShowLinkNewWalletModal: Dispatch<SetStateAction<boolean>>;
107
106
  setShowDynamicUserProfile: Dispatch<SetStateAction<boolean>>;
108
107
  setShowPasskeyCreatedSuccess: VoidFunction;
109
108
  setShowQrcodeModal: Dispatch<SetStateAction<boolean>>;
@@ -140,18 +139,23 @@ export interface IDynamicContext {
140
139
  walletConnectorOptions: WalletOption[];
141
140
  walletsFilter?: (options: WalletOption[]) => WalletOption[];
142
141
  removeConnectedWalletsInfo: () => void;
143
- /** Whether any verifications are ongoing for the current user (ex. connect, sign and email login verifications) */
142
+ /** Whether any verifications are ongoing for the current user (ex. connect, sign and email login verifications
143
+ * @deprecated Listen to our callbacks instead: https://docs.dynamic.xyz/react-sdk/callbacks/callbacks-introduction
144
+ */
144
145
  isVerificationInProgress: boolean;
145
146
  /** State setter for isVerificationInProgress
146
147
  * @param checkWasSetOnDisable when true, if newValue is false, logs a message if the flag wasn't set to true before
148
+ * @deprecated This will be dropped in v2
147
149
  */
148
150
  setIsVerificationInProgress: (newValue: boolean, checkWasSetOnDisable?: boolean) => void;
149
151
  /** Legacy boolean flag used in useVerifyOnAwaitingSignature. Used to be called "isVerifying".
150
152
  * Was meant to prevent an effect from accidentally triggering again when it shouldn't.
151
- * Should be removed asap.
153
+ * @deprecated Should be removed asap.
152
154
  */
153
155
  legacyIsVerifying: boolean;
154
- /** Legacy setter for legacyIsVerifying */
156
+ /** Legacy setter for legacyIsVerifying
157
+ * @deprecated Should be removed asap.
158
+ */
155
159
  setLegacyIsVerifying: Dispatch<SetStateAction<boolean>>;
156
160
  /** Whether there is an instance of DynamicEmbeddedAuthFlow being rendered */
157
161
  isRenderingEmbeddedAuthFlow: MutableRefObject<boolean>;
@@ -11,7 +11,7 @@ const useDynamicContext = () => {
11
11
  if (context === undefined) {
12
12
  throw new Error('useDynamicContext must be used within a DynamicContextProvider');
13
13
  }
14
- const { accountSwitchState, authMode, authToken, awaitingSignatureState, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, isVerificationInProgress, loadingNetwork, locale, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, walletConnectorOptions, bridgeChains, bridgeChainsToConnect, primaryWallet, setShowBridgeWidget, sendWagmiSettings, showDynamicUserProfile, } = context;
14
+ const { accountSwitchState, authMode, authToken, awaitingSignatureState, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, isVerificationInProgress, loadingNetwork, locale, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, walletConnectorOptions, bridgeChains, bridgeChainsToConnect, primaryWallet, setShowBridgeWidget, sendWagmiSettings, showDynamicUserProfile, setShowLinkNewWalletModal, } = context;
15
15
  return {
16
16
  accountSwitchState,
17
17
  authMode,
@@ -40,9 +40,15 @@ const useDynamicContext = () => {
40
40
  setMultiWalletWidgetState,
41
41
  setNetwork,
42
42
  setPrimaryWallet,
43
- setShowAuthFlow,
43
+ setShowAuthFlow: (value) => setShowAuthFlow(value, {
44
+ emitCancelAuth: true,
45
+ ignoreIfIsEmbeddedWidget: true,
46
+ initializeWalletConnect: true,
47
+ performMultiWalletChecks: true,
48
+ }),
44
49
  setShowBridgeWidget,
45
50
  setShowDynamicUserProfile,
51
+ setShowLinkNewWalletModal,
46
52
  setShowQrcodeModal,
47
53
  shadowDOMEnabled,
48
54
  showAuthFlow,