@dynamic-labs/sdk-react-core 2.0.0-alpha.6 → 2.0.0-alpha.8
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 +21 -0
- package/package.cjs +4 -4
- package/package.js +4 -4
- package/package.json +16 -16
- package/src/index.cjs +3 -7
- package/src/index.d.ts +1 -2
- package/src/index.js +2 -2
- package/src/lib/components/Alert/Alert.cjs +1 -0
- package/src/lib/components/Alert/Alert.js +1 -0
- package/src/lib/components/Alert/Alert.types.d.ts +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.cjs +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.js +1 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.cjs +4 -2
- package/src/lib/components/NetworkPicker/NetworkPicker.js +4 -2
- package/src/lib/components/ShadowDOM/ShadowDOM.cjs +2 -0
- package/src/lib/components/ShadowDOM/ShadowDOM.js +2 -1
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.cjs +26 -10
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.js +27 -11
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +16 -17
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +3 -4
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -18
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +10 -0
- package/src/lib/context/DynamicContext/helpers/helpers.d.ts +5 -0
- package/src/lib/context/DynamicContext/helpers/helpers.js +10 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +1 -1
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.d.ts +8 -7
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +1 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +14 -2
- package/src/lib/context/ErrorContext/ErrorContext.cjs +4 -0
- package/src/lib/context/ErrorContext/ErrorContext.d.ts +1 -0
- package/src/lib/context/ErrorContext/ErrorContext.js +4 -0
- package/src/lib/context/FundingContext/FundingContext.cjs +3 -1
- package/src/lib/context/FundingContext/FundingContext.js +3 -1
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +1 -0
- package/src/lib/context/PasskeyContext/PasskeyContext.js +1 -0
- package/src/lib/context/ViewContext/ViewContext.cjs +7 -0
- package/src/lib/context/ViewContext/ViewContext.js +7 -0
- package/src/lib/context/ViewContext/types/index.d.ts +5 -3
- package/src/lib/locale/en/translation.cjs +30 -16
- package/src/lib/locale/en/translation.d.ts +22 -8
- package/src/lib/locale/en/translation.js +30 -16
- package/src/lib/shared/types/localStorage.d.ts +1 -1
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +10 -28
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.d.ts +1 -5
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.js +10 -28
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/mergeNetworks/index.d.ts +1 -0
- package/src/lib/utils/functions/mergeNetworks/mergeNetworks.cjs +26 -0
- package/src/lib/utils/functions/mergeNetworks/mergeNetworks.d.ts +13 -0
- package/src/lib/utils/functions/mergeNetworks/mergeNetworks.js +22 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +4 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +4 -2
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +3 -13
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +3 -13
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -1
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +1 -0
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +1 -0
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +33 -8
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +33 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +27 -5
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +27 -5
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +7 -6
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.d.ts +1 -1
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +7 -6
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +2 -6
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +2 -6
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs +20 -54
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts +5 -3
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js +20 -54
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +38 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.d.ts +2 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +34 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +8 -11
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +8 -11
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +1 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +1 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.cjs +4 -7
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.js +4 -7
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +1 -1
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +1 -1
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +1 -1
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.cjs +1 -1
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.js +1 -1
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -8
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -8
- package/src/lib/views/{CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.cjs → CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs} +5 -4
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.d.ts +13 -0
- package/src/lib/views/{CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.js → CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js} +5 -4
- package/src/lib/views/CollectUserDataViewNoWallet/index.d.ts +1 -0
- package/src/lib/views/CreatePasswordView/CreatePasswordStep/CreatePasswordStep.cjs +17 -2
- package/src/lib/views/CreatePasswordView/CreatePasswordStep/CreatePasswordStep.js +17 -2
- package/src/lib/views/CreatePasswordView/CreatePasswordView.cjs +12 -13
- package/src/lib/views/CreatePasswordView/CreatePasswordView.d.ts +2 -0
- package/src/lib/views/CreatePasswordView/CreatePasswordView.js +12 -13
- 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 +10 -17
- package/src/lib/views/EmailVerification/EmailVerification.js +10 -17
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +40 -13
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.d.ts +2 -3
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +40 -13
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +1 -1
- package/src/lib/views/EnterPasswordView/EnterPasswordView.cjs +8 -1
- package/src/lib/views/EnterPasswordView/EnterPasswordView.js +8 -1
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs +1 -0
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js +1 -0
- package/src/lib/views/LoginView/useLoginView/useLoginView.cjs +11 -5
- package/src/lib/views/LoginView/useLoginView/useLoginView.js +11 -5
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -0
- package/src/lib/views/Passkey/EmbeddedAuthChoice/EmbeddedAuthChoice.d.ts +2 -3
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.d.ts +2 -3
- package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.d.ts +2 -3
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.cjs +1 -0
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.js +1 -0
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +31 -7
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +31 -7
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -0
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -0
- package/src/lib/views/viewToComponentMap.cjs +4 -4
- package/src/lib/views/viewToComponentMap.d.ts +60 -2
- package/src/lib/views/viewToComponentMap.js +4 -4
- 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/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +6 -4
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +6 -4
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +5 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs +2 -14
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js +2 -14
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.cjs +3 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.js +4 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +2 -14
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +2 -14
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +18 -9
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +18 -9
- package/src/lib/utils/functions/isSameWalletName/index.d.ts +0 -1
- package/src/lib/utils/functions/isSameWalletName/isSameWalletName.cjs +0 -9
- package/src/lib/utils/functions/isSameWalletName/isSameWalletName.d.ts +0 -1
- package/src/lib/utils/functions/isSameWalletName/isSameWalletName.js +0 -5
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +0 -16
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +0 -2
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +0 -12
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.d.ts +0 -2
- package/src/lib/views/CollectUserDataViewLoginWithEmail/index.d.ts +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GenericNetwork } from '@dynamic-labs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Will merge the networks in the first param to the networks in the second param.
|
|
4
|
+
* The firs param's networks will have priority in case of conflicts.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const DynamicSettings = {
|
|
8
|
+
* overrides: {
|
|
9
|
+
* evmNetworks: (networks) => mergeNetworks(myEvmNetworks, networks),
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
export declare const mergeNetworks: (priorityNetworks: GenericNetwork[], secondaryNetworks: GenericNetwork[]) => GenericNetwork[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Will merge the networks in the first param to the networks in the second param.
|
|
3
|
+
* The firs param's networks will have priority in case of conflicts.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const DynamicSettings = {
|
|
7
|
+
* overrides: {
|
|
8
|
+
* evmNetworks: (networks) => mergeNetworks(myEvmNetworks, networks),
|
|
9
|
+
* }
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
const mergeNetworks = (priorityNetworks, secondaryNetworks) => {
|
|
13
|
+
const networks = [...priorityNetworks];
|
|
14
|
+
secondaryNetworks.forEach((network) => {
|
|
15
|
+
const hasNetwork = networks.some((item) => item.chainId === network.chainId);
|
|
16
|
+
if (!hasNetwork)
|
|
17
|
+
networks.push(network);
|
|
18
|
+
});
|
|
19
|
+
return networks;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { mergeNetworks };
|
|
@@ -84,7 +84,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
84
84
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
85
85
|
const { engageCaptcha, getCaptchaToken } = CaptchaContext.useCaptchaContext();
|
|
86
86
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
87
|
-
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils,
|
|
87
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, user, walletUiUtils, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
88
88
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
89
89
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
90
90
|
consumeNonce,
|
|
@@ -147,7 +147,9 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
147
147
|
network: walletNetwork,
|
|
148
148
|
walletConnector,
|
|
149
149
|
});
|
|
150
|
-
|
|
150
|
+
const isNetworkValidationEnabledForSignIn = networkValidationMode === 'always' ||
|
|
151
|
+
networkValidationMode === 'sign-in';
|
|
152
|
+
if (!usesSupportedNetwork && isNetworkValidationEnabledForSignIn) {
|
|
151
153
|
if (!isProgrammableNetworkSwitchSupported.isProgrammableNetworkSwitchSupported(walletConnector)) {
|
|
152
154
|
return setView('network-not-supported-manual');
|
|
153
155
|
}
|
|
@@ -80,7 +80,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
80
80
|
const { setView, goToInitialView } = useViewContext();
|
|
81
81
|
const { engageCaptcha, getCaptchaToken } = useCaptchaContext();
|
|
82
82
|
const { setErrorMessage } = useErrorContext();
|
|
83
|
-
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils,
|
|
83
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, user, walletUiUtils, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
84
84
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
85
85
|
const verifyWallet = useVerifyWallet({
|
|
86
86
|
consumeNonce,
|
|
@@ -143,7 +143,9 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
143
143
|
network: walletNetwork,
|
|
144
144
|
walletConnector,
|
|
145
145
|
});
|
|
146
|
-
|
|
146
|
+
const isNetworkValidationEnabledForSignIn = networkValidationMode === 'always' ||
|
|
147
|
+
networkValidationMode === 'sign-in';
|
|
148
|
+
if (!usesSupportedNetwork && isNetworkValidationEnabledForSignIn) {
|
|
147
149
|
if (!isProgrammableNetworkSwitchSupported(walletConnector)) {
|
|
148
150
|
return setView('network-not-supported-manual');
|
|
149
151
|
}
|
|
@@ -63,6 +63,7 @@ require('../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Se
|
|
|
63
63
|
require('i18next');
|
|
64
64
|
require('@hcaptcha/react-hcaptcha');
|
|
65
65
|
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
66
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
66
67
|
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
67
68
|
require('../../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs');
|
|
68
69
|
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
@@ -59,6 +59,7 @@ import '../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Sec
|
|
|
59
59
|
import 'i18next';
|
|
60
60
|
import '@hcaptcha/react-hcaptcha';
|
|
61
61
|
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
62
|
+
import '../../../../config/ApiEndpoint.js';
|
|
62
63
|
import '../../../../context/FooterAnimationContext/index.js';
|
|
63
64
|
import '../../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js';
|
|
64
65
|
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -46,3 +46,4 @@ export { useEmbeddedWalletAuthenticator } from './useEmbeddedWalletAuthenticator
|
|
|
46
46
|
export { useViewSettings } from './useViewSettings';
|
|
47
47
|
export { useSendBalance } from './useSendBalance';
|
|
48
48
|
export { useEmbeddedWalletPassword } from './useEmbeddedWalletPassword';
|
|
49
|
+
export { useSetWalletConnectorFetchers } from './useSetWalletConnectorFetchers';
|
|
@@ -2,37 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React = require('react');
|
|
6
5
|
require('@dynamic-labs/sdk-api');
|
|
7
6
|
require('../../../../shared/logger.cjs');
|
|
8
7
|
require('@dynamic-labs/iconic');
|
|
9
8
|
require('@dynamic-labs/wallet-connector-core');
|
|
10
9
|
require('react/jsx-runtime');
|
|
11
10
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
11
|
+
require('react');
|
|
12
12
|
require('@dynamic-labs/wallet-book');
|
|
13
13
|
var localStorage = require('../../../constants/localStorage.cjs');
|
|
14
14
|
require('../../../constants/colors.cjs');
|
|
15
15
|
require('../../../constants/values.cjs');
|
|
16
|
-
|
|
16
|
+
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
17
|
require('viem');
|
|
18
18
|
var useLocalStorage = require('../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
19
19
|
require('@dynamic-labs/utils');
|
|
20
20
|
require('../../../../shared/consts/index.cjs');
|
|
21
21
|
|
|
22
|
-
const useMultiWallet = ({
|
|
22
|
+
const useMultiWallet = ({ isBridgeFlow, multiWalletSettings, }) => {
|
|
23
23
|
var _a;
|
|
24
24
|
const isMultiWalletEnabled = (_a = (multiWalletSettings || isBridgeFlow)) !== null && _a !== void 0 ? _a : false;
|
|
25
25
|
const [multiWallet, setMultiWallet] = useLocalStorage.useLocalStorage(localStorage.IS_MULTI_WALLET_ENABLED, isMultiWalletEnabled);
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
// don't overwrite toolkit stored value after the refresh
|
|
28
|
-
if (toolkitEnabled &&
|
|
29
|
-
localStorage$1.LocalStorage.getFromLS(localStorage.IS_MULTI_WALLET_ENABLED) !== undefined) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (multiWalletSettings) {
|
|
33
|
-
setMultiWallet(multiWalletSettings);
|
|
34
|
-
}
|
|
35
|
-
}, [multiWalletSettings]);
|
|
36
26
|
return { multiWallet, setMultiWallet };
|
|
37
27
|
};
|
|
38
28
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export type UseMultiWalletProps = {
|
|
2
|
-
toolkitEnabled: boolean;
|
|
3
2
|
isBridgeFlow?: boolean;
|
|
4
3
|
multiWalletSettings?: boolean;
|
|
5
4
|
};
|
|
6
|
-
export declare const useMultiWallet: ({
|
|
5
|
+
export declare const useMultiWallet: ({ isBridgeFlow, multiWalletSettings, }: UseMultiWalletProps) => {
|
|
7
6
|
multiWallet: boolean;
|
|
8
7
|
setMultiWallet: (value: boolean | ((val: boolean) => boolean)) => void;
|
|
9
8
|
};
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
1
|
import '@dynamic-labs/sdk-api';
|
|
3
2
|
import '../../../../shared/logger.js';
|
|
4
3
|
import '@dynamic-labs/iconic';
|
|
5
4
|
import '@dynamic-labs/wallet-connector-core';
|
|
6
5
|
import 'react/jsx-runtime';
|
|
7
6
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
7
|
+
import 'react';
|
|
8
8
|
import '@dynamic-labs/wallet-book';
|
|
9
9
|
import { IS_MULTI_WALLET_ENABLED } from '../../../constants/localStorage.js';
|
|
10
10
|
import '../../../constants/colors.js';
|
|
11
11
|
import '../../../constants/values.js';
|
|
12
|
-
import
|
|
12
|
+
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
13
13
|
import 'viem';
|
|
14
14
|
import { useLocalStorage } from '../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
15
15
|
import '@dynamic-labs/utils';
|
|
16
16
|
import '../../../../shared/consts/index.js';
|
|
17
17
|
|
|
18
|
-
const useMultiWallet = ({
|
|
18
|
+
const useMultiWallet = ({ isBridgeFlow, multiWalletSettings, }) => {
|
|
19
19
|
var _a;
|
|
20
20
|
const isMultiWalletEnabled = (_a = (multiWalletSettings || isBridgeFlow)) !== null && _a !== void 0 ? _a : false;
|
|
21
21
|
const [multiWallet, setMultiWallet] = useLocalStorage(IS_MULTI_WALLET_ENABLED, isMultiWalletEnabled);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
// don't overwrite toolkit stored value after the refresh
|
|
24
|
-
if (toolkitEnabled &&
|
|
25
|
-
LocalStorage.getFromLS(IS_MULTI_WALLET_ENABLED) !== undefined) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (multiWalletSettings) {
|
|
29
|
-
setMultiWallet(multiWalletSettings);
|
|
30
|
-
}
|
|
31
|
-
}, [multiWalletSettings]);
|
|
32
22
|
return { multiWallet, setMultiWallet };
|
|
33
23
|
};
|
|
34
24
|
|
|
@@ -116,7 +116,7 @@ const useAuthLayoutChecks = () => {
|
|
|
116
116
|
view.type !== 'passkey-new-domain-detected' &&
|
|
117
117
|
view.type !== 'social-redirect-view' &&
|
|
118
118
|
view.type !== 'update-email' &&
|
|
119
|
-
view.type !== 'collect-user-data-login-
|
|
119
|
+
view.type !== 'collect-user-data-login-no-wallet' &&
|
|
120
120
|
view.type !== 'passkey-recovery-bundle' &&
|
|
121
121
|
view.type !== 'passkey-recovery-start' &&
|
|
122
122
|
view.type !== 'embedded-reveal-view' &&
|
|
@@ -112,7 +112,7 @@ const useAuthLayoutChecks = () => {
|
|
|
112
112
|
view.type !== 'passkey-new-domain-detected' &&
|
|
113
113
|
view.type !== 'social-redirect-view' &&
|
|
114
114
|
view.type !== 'update-email' &&
|
|
115
|
-
view.type !== 'collect-user-data-login-
|
|
115
|
+
view.type !== 'collect-user-data-login-no-wallet' &&
|
|
116
116
|
view.type !== 'passkey-recovery-bundle' &&
|
|
117
117
|
view.type !== 'passkey-recovery-start' &&
|
|
118
118
|
view.type !== 'embedded-reveal-view' &&
|
|
@@ -66,6 +66,7 @@ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Secon
|
|
|
66
66
|
require('i18next');
|
|
67
67
|
require('@hcaptcha/react-hcaptcha');
|
|
68
68
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
69
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
69
70
|
require('../../../context/FooterAnimationContext/index.cjs');
|
|
70
71
|
require('../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs');
|
|
71
72
|
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
@@ -62,6 +62,7 @@ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Second
|
|
|
62
62
|
import 'i18next';
|
|
63
63
|
import '@hcaptcha/react-hcaptcha';
|
|
64
64
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
65
|
+
import '../../../config/ApiEndpoint.js';
|
|
65
66
|
import '../../../context/FooterAnimationContext/index.js';
|
|
66
67
|
import '../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js';
|
|
67
68
|
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
8
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
8
9
|
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
9
10
|
require('@dynamic-labs/iconic');
|
|
10
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
11
11
|
require('react/jsx-runtime');
|
|
12
12
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
13
13
|
require('../../../shared/logger.cjs');
|
|
@@ -27,6 +27,7 @@ var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
|
27
27
|
require('react-international-phone');
|
|
28
28
|
var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
29
29
|
require('viem/chains');
|
|
30
|
+
var isCoinbaseWaasEnabled = require('../../functions/isCoinbaseWaasEnabled/isCoinbaseWaasEnabled.cjs');
|
|
30
31
|
require('../../../config/ApiEndpoint.cjs');
|
|
31
32
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
32
33
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -34,6 +35,7 @@ require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
|
34
35
|
require('react-dom');
|
|
35
36
|
var useEmbeddedWallet = require('../useEmbeddedWallet/useEmbeddedWallet.cjs');
|
|
36
37
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
38
|
+
var useIsTurnkeyWallet = require('../useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
37
39
|
require('@dynamic-labs/types');
|
|
38
40
|
require('yup');
|
|
39
41
|
require('react-i18next');
|
|
@@ -79,15 +81,12 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
79
81
|
|
|
80
82
|
// Hook exposed to customers and used internally to trigger embedded reveal
|
|
81
83
|
const useEmbeddedReveal = () => {
|
|
82
|
-
const { projectSettings, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
84
|
+
const { primaryWallet, projectSettings, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
83
85
|
const { userHasEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
|
|
84
86
|
const { setView } = ViewContext.useViewContext();
|
|
85
|
-
const
|
|
87
|
+
const { isTurnkeyWallet } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
88
|
+
const turnkeyChecks = ({ jwt, recoveryPhrase, }) => {
|
|
86
89
|
var _a, _b;
|
|
87
|
-
const jwt = getAuthToken.getAuthToken();
|
|
88
|
-
if (!jwt) {
|
|
89
|
-
throw new Error('User is not logged in');
|
|
90
|
-
}
|
|
91
90
|
if (!isTurnkeyEnabled.isTurnkeyEnabled(projectSettings)) {
|
|
92
91
|
throw new Error('Passkey embedded wallet is not enabled. Go to the dashboard and make sure to have both Turnkey/Passkey Embedded wallets and at least one EVM network enabled. Also, check if EthereumWalletConnectors is in the DynamicContextProvider > settings > walletConnectors.');
|
|
93
92
|
}
|
|
@@ -100,6 +99,32 @@ const useEmbeddedReveal = () => {
|
|
|
100
99
|
if (recoveryPhrase && !turnkeyHDWalletId) {
|
|
101
100
|
throw new Error('Wallet is non-HD and does not have a recovery phrase');
|
|
102
101
|
}
|
|
102
|
+
};
|
|
103
|
+
const coinbaseMpcChecks = ({ jwt }) => {
|
|
104
|
+
if (!isCoinbaseWaasEnabled.isCoinbaseWaasEnabled(projectSettings)) {
|
|
105
|
+
throw new Error('Coinbase MPC is not enabled. Go to the dashboard and make sure to have Coinbase WaaS and at least one EVM network enabled. Also, make sure you are passing `EthereumWalletConnectors` to the `walletConnectors` prop in `DynamicContextProvider` `settings`.');
|
|
106
|
+
}
|
|
107
|
+
if (!userHasEmbeddedWallet()) {
|
|
108
|
+
throw new Error('Coinbase MPC wallet not found');
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const initExportProcess = React.useCallback((recoveryPhrase = false) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
+
if (!primaryWallet) {
|
|
113
|
+
throw new Error('No primary wallet');
|
|
114
|
+
}
|
|
115
|
+
const jwt = getAuthToken.getAuthToken();
|
|
116
|
+
if (!jwt) {
|
|
117
|
+
throw new Error('User is not logged in');
|
|
118
|
+
}
|
|
119
|
+
if (isTurnkeyWallet) {
|
|
120
|
+
turnkeyChecks({ jwt, recoveryPhrase });
|
|
121
|
+
}
|
|
122
|
+
if (walletConnectorCore.isCoinbaseMpcWalletConnector(primaryWallet.connector)) {
|
|
123
|
+
coinbaseMpcChecks({ jwt });
|
|
124
|
+
}
|
|
125
|
+
if (!userHasEmbeddedWallet()) {
|
|
126
|
+
throw new Error('Passkey embedded wallet not found');
|
|
127
|
+
}
|
|
103
128
|
setShowAuthFlow(true, {
|
|
104
129
|
ignoreIfIsEmbeddedWidget: false,
|
|
105
130
|
performMultiWalletChecks: false,
|
|
@@ -109,7 +134,7 @@ const useEmbeddedReveal = () => {
|
|
|
109
134
|
dynamicEvents.dynamicEvents.once('embeddedWalletRevealCompleted', (wallet) => resolve(wallet));
|
|
110
135
|
dynamicEvents.dynamicEvents.once('embeddedWalletRevealFailed', (error) => reject(error));
|
|
111
136
|
});
|
|
112
|
-
}), [
|
|
137
|
+
}), [primaryWallet, isTurnkeyWallet, setShowAuthFlow, setView]);
|
|
113
138
|
return {
|
|
114
139
|
initExportProcess,
|
|
115
140
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
+
import { isCoinbaseMpcWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
4
5
|
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
5
6
|
import '@dynamic-labs/iconic';
|
|
6
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import 'react/jsx-runtime';
|
|
8
8
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
9
9
|
import '../../../shared/logger.js';
|
|
@@ -23,6 +23,7 @@ import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
|
23
23
|
import 'react-international-phone';
|
|
24
24
|
import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
25
25
|
import 'viem/chains';
|
|
26
|
+
import { isCoinbaseWaasEnabled } from '../../functions/isCoinbaseWaasEnabled/isCoinbaseWaasEnabled.js';
|
|
26
27
|
import '../../../config/ApiEndpoint.js';
|
|
27
28
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
28
29
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -30,6 +31,7 @@ import '../../../context/VerificationContext/VerificationContext.js';
|
|
|
30
31
|
import 'react-dom';
|
|
31
32
|
import { useEmbeddedWallet } from '../useEmbeddedWallet/useEmbeddedWallet.js';
|
|
32
33
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
34
|
+
import { useIsTurnkeyWallet } from '../useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
33
35
|
import '@dynamic-labs/types';
|
|
34
36
|
import 'yup';
|
|
35
37
|
import 'react-i18next';
|
|
@@ -75,15 +77,12 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
75
77
|
|
|
76
78
|
// Hook exposed to customers and used internally to trigger embedded reveal
|
|
77
79
|
const useEmbeddedReveal = () => {
|
|
78
|
-
const { projectSettings, setShowAuthFlow } = useInternalDynamicContext();
|
|
80
|
+
const { primaryWallet, projectSettings, setShowAuthFlow } = useInternalDynamicContext();
|
|
79
81
|
const { userHasEmbeddedWallet } = useEmbeddedWallet();
|
|
80
82
|
const { setView } = useViewContext();
|
|
81
|
-
const
|
|
83
|
+
const { isTurnkeyWallet } = useIsTurnkeyWallet();
|
|
84
|
+
const turnkeyChecks = ({ jwt, recoveryPhrase, }) => {
|
|
82
85
|
var _a, _b;
|
|
83
|
-
const jwt = getAuthToken();
|
|
84
|
-
if (!jwt) {
|
|
85
|
-
throw new Error('User is not logged in');
|
|
86
|
-
}
|
|
87
86
|
if (!isTurnkeyEnabled(projectSettings)) {
|
|
88
87
|
throw new Error('Passkey embedded wallet is not enabled. Go to the dashboard and make sure to have both Turnkey/Passkey Embedded wallets and at least one EVM network enabled. Also, check if EthereumWalletConnectors is in the DynamicContextProvider > settings > walletConnectors.');
|
|
89
88
|
}
|
|
@@ -96,6 +95,32 @@ const useEmbeddedReveal = () => {
|
|
|
96
95
|
if (recoveryPhrase && !turnkeyHDWalletId) {
|
|
97
96
|
throw new Error('Wallet is non-HD and does not have a recovery phrase');
|
|
98
97
|
}
|
|
98
|
+
};
|
|
99
|
+
const coinbaseMpcChecks = ({ jwt }) => {
|
|
100
|
+
if (!isCoinbaseWaasEnabled(projectSettings)) {
|
|
101
|
+
throw new Error('Coinbase MPC is not enabled. Go to the dashboard and make sure to have Coinbase WaaS and at least one EVM network enabled. Also, make sure you are passing `EthereumWalletConnectors` to the `walletConnectors` prop in `DynamicContextProvider` `settings`.');
|
|
102
|
+
}
|
|
103
|
+
if (!userHasEmbeddedWallet()) {
|
|
104
|
+
throw new Error('Coinbase MPC wallet not found');
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const initExportProcess = useCallback((recoveryPhrase = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
if (!primaryWallet) {
|
|
109
|
+
throw new Error('No primary wallet');
|
|
110
|
+
}
|
|
111
|
+
const jwt = getAuthToken();
|
|
112
|
+
if (!jwt) {
|
|
113
|
+
throw new Error('User is not logged in');
|
|
114
|
+
}
|
|
115
|
+
if (isTurnkeyWallet) {
|
|
116
|
+
turnkeyChecks({ jwt, recoveryPhrase });
|
|
117
|
+
}
|
|
118
|
+
if (isCoinbaseMpcWalletConnector(primaryWallet.connector)) {
|
|
119
|
+
coinbaseMpcChecks({ jwt });
|
|
120
|
+
}
|
|
121
|
+
if (!userHasEmbeddedWallet()) {
|
|
122
|
+
throw new Error('Passkey embedded wallet not found');
|
|
123
|
+
}
|
|
99
124
|
setShowAuthFlow(true, {
|
|
100
125
|
ignoreIfIsEmbeddedWidget: false,
|
|
101
126
|
performMultiWalletChecks: false,
|
|
@@ -105,7 +130,7 @@ const useEmbeddedReveal = () => {
|
|
|
105
130
|
dynamicEvents.once('embeddedWalletRevealCompleted', (wallet) => resolve(wallet));
|
|
106
131
|
dynamicEvents.once('embeddedWalletRevealFailed', (error) => reject(error));
|
|
107
132
|
});
|
|
108
|
-
}), [
|
|
133
|
+
}), [primaryWallet, isTurnkeyWallet, setShowAuthFlow, setView]);
|
|
109
134
|
return {
|
|
110
135
|
initExportProcess,
|
|
111
136
|
};
|
|
@@ -72,6 +72,7 @@ require('../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Se
|
|
|
72
72
|
require('i18next');
|
|
73
73
|
require('@hcaptcha/react-hcaptcha');
|
|
74
74
|
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
75
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
75
76
|
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
76
77
|
require('../../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.cjs');
|
|
77
78
|
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
@@ -68,6 +68,7 @@ import '../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/Sec
|
|
|
68
68
|
import 'i18next';
|
|
69
69
|
import '@hcaptcha/react-hcaptcha';
|
|
70
70
|
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
71
|
+
import '../../../../config/ApiEndpoint.js';
|
|
71
72
|
import '../../../../context/FooterAnimationContext/index.js';
|
|
72
73
|
import '../../../../views/LoginView/sections/PhoneNumberSignInSection/usePhoneInputLogic/usePhoneInputLogic.js';
|
|
73
74
|
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var sdkApi = require('@dynamic-labs/sdk-api');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
9
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
9
10
|
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
10
11
|
require('@dynamic-labs/iconic');
|
|
11
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
12
12
|
require('react/jsx-runtime');
|
|
13
13
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
14
|
require('../../../shared/logger.cjs');
|
|
@@ -26,9 +26,12 @@ var findEmbeddedWalletFromVerifiedCredentials = require('../../functions/findEmb
|
|
|
26
26
|
require('@dynamic-labs/multi-wallet');
|
|
27
27
|
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
28
28
|
require('react-international-phone');
|
|
29
|
+
var getUserWalletsFromVerifiedCredentials = require('../../functions/getUserWalletsFromVerifiedCredentials/getUserWalletsFromVerifiedCredentials.cjs');
|
|
29
30
|
var isEmbeddedWalletPresent = require('../../functions/isEmbeddedWalletPresent/isEmbeddedWalletPresent.cjs');
|
|
30
31
|
var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
31
32
|
require('viem/chains');
|
|
33
|
+
var findCoinbaseMPCWallet = require('../../functions/findCoinbaseMPCWallet/findCoinbaseMPCWallet.cjs');
|
|
34
|
+
var requiresPasswordForEmbeddedWallet = require('../../functions/requiresPasswordForEmbeddedWallet/requiresPasswordForEmbeddedWallet.cjs');
|
|
32
35
|
var requiresPasswordForEmbeddedWalletOnSignup = require('../../functions/requiresPasswordForEmbeddedWalletOnSignup/requiresPasswordForEmbeddedWalletOnSignup.cjs');
|
|
33
36
|
var isCoinbaseWaasEnabled = require('../../functions/isCoinbaseWaasEnabled/isCoinbaseWaasEnabled.cjs');
|
|
34
37
|
require('../../../config/ApiEndpoint.cjs');
|
|
@@ -85,7 +88,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
85
88
|
|
|
86
89
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
87
90
|
const useEmbeddedWallet = () => {
|
|
88
|
-
const { projectSettings, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
|
|
91
|
+
const { projectSettings, onboardingOnlyJwt, setPrimaryWalletId, primaryWallet, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
89
92
|
const { createPassword: internalCreatePassword } = useEmbeddedWalletPassword.useEmbeddedWalletPassword();
|
|
90
93
|
const { createCoinbaseMPCWallet } = useCoinbaseMPC.useCoinbaseMPC();
|
|
91
94
|
const { createTurnkeyWallet } = useTurnkey.useTurnkey();
|
|
@@ -100,21 +103,37 @@ const useEmbeddedWallet = () => {
|
|
|
100
103
|
};
|
|
101
104
|
const createPassword = React.useCallback((showIntro) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return internalCreatePassword(showIntro); }), [internalCreatePassword]);
|
|
102
105
|
const createEmbeddedWallet = React.useCallback((chain = sdkApi.ChainEnum.Evm) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
-
var _a;
|
|
106
|
+
var _a, _b, _c;
|
|
104
107
|
const jwt = (_a = getAuthToken.getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
105
108
|
const decodedJwt = decodeJwt.decodeJwt(jwt);
|
|
106
109
|
if (!jwt || !decodedJwt) {
|
|
107
110
|
throw new Error('User is not logged in');
|
|
108
111
|
}
|
|
112
|
+
const userWaletsCredentials = getUserWalletsFromVerifiedCredentials.getUserWalletsFromVerifiedCredentials(jwt);
|
|
113
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
114
|
+
// if user has a wallet and it's not embedded, set it as primary and return,
|
|
115
|
+
if ((userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) && !embeddedWalletVerifiedCredential) {
|
|
116
|
+
if (!primaryWallet) {
|
|
117
|
+
// user logged in through an email linked to a third party wallet
|
|
118
|
+
// at this point primary wallet is still undefined and we need to set it
|
|
119
|
+
setPrimaryWalletId(userWaletsCredentials[0].id);
|
|
120
|
+
}
|
|
121
|
+
throw new Error('Primary wallet is not an embedded wallet');
|
|
122
|
+
}
|
|
109
123
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
110
124
|
const isCoinbaseWaaSProviderEnabled = isCoinbaseWaasEnabled.isCoinbaseWaasEnabled(projectSettings);
|
|
111
125
|
if (!isTurnkeyProviderEnabled && !isCoinbaseWaaSProviderEnabled) {
|
|
112
126
|
throw new Error('No embedded wallet is enabled. Go to the dashboard and make sure to have both Embedded wallets and at least one EVM network enabled. Also, check if EthereumWalletConnectors is in the DynamicContextProvider > settings > walletConnectors.');
|
|
113
127
|
}
|
|
114
|
-
const hasEmbeddedWallet = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
115
128
|
setIsLoadingEmbeddedWallet(true);
|
|
129
|
+
// since we can dynamically change the settings from demov2, we need to set
|
|
130
|
+
// requires password prop here in case the connector has already been initialized with a different value
|
|
131
|
+
const connector = (_b = findCoinbaseMPCWallet.findCoinbaseMPCWallet(walletConnectorOptions)) === null || _b === void 0 ? void 0 : _b.walletConnector;
|
|
132
|
+
if (walletConnectorCore.isCoinbaseMpcWalletConnector(connector)) {
|
|
133
|
+
connector.setRequiredPassword((_c = requiresPasswordForEmbeddedWallet.requiresPasswordForEmbeddedWallet(projectSettings)) !== null && _c !== void 0 ? _c : false);
|
|
134
|
+
}
|
|
116
135
|
let password;
|
|
117
|
-
if (!
|
|
136
|
+
if (!embeddedWalletVerifiedCredential &&
|
|
118
137
|
requiresPasswordForEmbeddedWalletOnSignup.requiresPasswordForEmbeddedWalletOnSignup(projectSettings)) {
|
|
119
138
|
password = yield internalCreatePassword(false, true);
|
|
120
139
|
}
|
|
@@ -134,8 +153,11 @@ const useEmbeddedWallet = () => {
|
|
|
134
153
|
createTurnkeyWallet,
|
|
135
154
|
internalCreatePassword,
|
|
136
155
|
onboardingOnlyJwt,
|
|
156
|
+
primaryWallet,
|
|
137
157
|
projectSettings,
|
|
138
158
|
setIsLoadingEmbeddedWallet,
|
|
159
|
+
setPrimaryWalletId,
|
|
160
|
+
walletConnectorOptions,
|
|
139
161
|
]);
|
|
140
162
|
return {
|
|
141
163
|
createEmbeddedWallet,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { ChainEnum } from '@dynamic-labs/sdk-api';
|
|
4
|
+
import { isCoinbaseMpcWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
5
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
5
6
|
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
6
7
|
import '@dynamic-labs/iconic';
|
|
7
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
8
8
|
import 'react/jsx-runtime';
|
|
9
9
|
import '../../../context/ViewContext/ViewContext.js';
|
|
10
10
|
import '../../../shared/logger.js';
|
|
@@ -22,9 +22,12 @@ import { findEmbeddedWalletFromVerifiedCredentials } from '../../functions/findE
|
|
|
22
22
|
import '@dynamic-labs/multi-wallet';
|
|
23
23
|
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
24
24
|
import 'react-international-phone';
|
|
25
|
+
import { getUserWalletsFromVerifiedCredentials } from '../../functions/getUserWalletsFromVerifiedCredentials/getUserWalletsFromVerifiedCredentials.js';
|
|
25
26
|
import { isEmbeddedWalletPresent } from '../../functions/isEmbeddedWalletPresent/isEmbeddedWalletPresent.js';
|
|
26
27
|
import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
27
28
|
import 'viem/chains';
|
|
29
|
+
import { findCoinbaseMPCWallet } from '../../functions/findCoinbaseMPCWallet/findCoinbaseMPCWallet.js';
|
|
30
|
+
import { requiresPasswordForEmbeddedWallet } from '../../functions/requiresPasswordForEmbeddedWallet/requiresPasswordForEmbeddedWallet.js';
|
|
28
31
|
import { requiresPasswordForEmbeddedWalletOnSignup } from '../../functions/requiresPasswordForEmbeddedWalletOnSignup/requiresPasswordForEmbeddedWalletOnSignup.js';
|
|
29
32
|
import { isCoinbaseWaasEnabled } from '../../functions/isCoinbaseWaasEnabled/isCoinbaseWaasEnabled.js';
|
|
30
33
|
import '../../../config/ApiEndpoint.js';
|
|
@@ -81,7 +84,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
81
84
|
|
|
82
85
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
83
86
|
const useEmbeddedWallet = () => {
|
|
84
|
-
const { projectSettings, onboardingOnlyJwt } = useInternalDynamicContext();
|
|
87
|
+
const { projectSettings, onboardingOnlyJwt, setPrimaryWalletId, primaryWallet, walletConnectorOptions, } = useInternalDynamicContext();
|
|
85
88
|
const { createPassword: internalCreatePassword } = useEmbeddedWalletPassword();
|
|
86
89
|
const { createCoinbaseMPCWallet } = useCoinbaseMPC();
|
|
87
90
|
const { createTurnkeyWallet } = useTurnkey();
|
|
@@ -96,21 +99,37 @@ const useEmbeddedWallet = () => {
|
|
|
96
99
|
};
|
|
97
100
|
const createPassword = useCallback((showIntro) => __awaiter(void 0, void 0, void 0, function* () { return internalCreatePassword(showIntro); }), [internalCreatePassword]);
|
|
98
101
|
const createEmbeddedWallet = useCallback((chain = ChainEnum.Evm) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
var _a;
|
|
102
|
+
var _a, _b, _c;
|
|
100
103
|
const jwt = (_a = getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
101
104
|
const decodedJwt = decodeJwt(jwt);
|
|
102
105
|
if (!jwt || !decodedJwt) {
|
|
103
106
|
throw new Error('User is not logged in');
|
|
104
107
|
}
|
|
108
|
+
const userWaletsCredentials = getUserWalletsFromVerifiedCredentials(jwt);
|
|
109
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
110
|
+
// if user has a wallet and it's not embedded, set it as primary and return,
|
|
111
|
+
if ((userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) && !embeddedWalletVerifiedCredential) {
|
|
112
|
+
if (!primaryWallet) {
|
|
113
|
+
// user logged in through an email linked to a third party wallet
|
|
114
|
+
// at this point primary wallet is still undefined and we need to set it
|
|
115
|
+
setPrimaryWalletId(userWaletsCredentials[0].id);
|
|
116
|
+
}
|
|
117
|
+
throw new Error('Primary wallet is not an embedded wallet');
|
|
118
|
+
}
|
|
105
119
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
106
120
|
const isCoinbaseWaaSProviderEnabled = isCoinbaseWaasEnabled(projectSettings);
|
|
107
121
|
if (!isTurnkeyProviderEnabled && !isCoinbaseWaaSProviderEnabled) {
|
|
108
122
|
throw new Error('No embedded wallet is enabled. Go to the dashboard and make sure to have both Embedded wallets and at least one EVM network enabled. Also, check if EthereumWalletConnectors is in the DynamicContextProvider > settings > walletConnectors.');
|
|
109
123
|
}
|
|
110
|
-
const hasEmbeddedWallet = findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
111
124
|
setIsLoadingEmbeddedWallet(true);
|
|
125
|
+
// since we can dynamically change the settings from demov2, we need to set
|
|
126
|
+
// requires password prop here in case the connector has already been initialized with a different value
|
|
127
|
+
const connector = (_b = findCoinbaseMPCWallet(walletConnectorOptions)) === null || _b === void 0 ? void 0 : _b.walletConnector;
|
|
128
|
+
if (isCoinbaseMpcWalletConnector(connector)) {
|
|
129
|
+
connector.setRequiredPassword((_c = requiresPasswordForEmbeddedWallet(projectSettings)) !== null && _c !== void 0 ? _c : false);
|
|
130
|
+
}
|
|
112
131
|
let password;
|
|
113
|
-
if (!
|
|
132
|
+
if (!embeddedWalletVerifiedCredential &&
|
|
114
133
|
requiresPasswordForEmbeddedWalletOnSignup(projectSettings)) {
|
|
115
134
|
password = yield internalCreatePassword(false, true);
|
|
116
135
|
}
|
|
@@ -130,8 +149,11 @@ const useEmbeddedWallet = () => {
|
|
|
130
149
|
createTurnkeyWallet,
|
|
131
150
|
internalCreatePassword,
|
|
132
151
|
onboardingOnlyJwt,
|
|
152
|
+
primaryWallet,
|
|
133
153
|
projectSettings,
|
|
134
154
|
setIsLoadingEmbeddedWallet,
|
|
155
|
+
setPrimaryWalletId,
|
|
156
|
+
walletConnectorOptions,
|
|
135
157
|
]);
|
|
136
158
|
return {
|
|
137
159
|
createEmbeddedWallet,
|