@dynamic-labs/sdk-react-core 1.0.2 → 1.0.4
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 +25 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +13 -13
- package/src/lib/components/Alert/Alert.types.d.ts +2 -1
- package/src/lib/components/Button/Button.cjs +2 -2
- package/src/lib/components/Button/Button.d.ts +2 -1
- package/src/lib/components/Button/Button.js +2 -2
- package/src/lib/components/CopyButton/CopyButton.d.ts +2 -1
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.cjs +2 -2
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.d.ts +3 -2
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.js +2 -2
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.d.ts +2 -1
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.cjs +2 -2
- package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +2 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.js +2 -2
- package/src/lib/components/Input/Input.types.d.ts +2 -1
- package/src/lib/components/ListTile/ListTile.cjs +1 -1
- package/src/lib/components/ListTile/ListTile.js +1 -1
- package/src/lib/components/ListTile/ListTile.types.d.ts +2 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +9 -5
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +1 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +9 -5
- package/src/lib/components/NeedHelpSection/NeedHelpSection.cjs +3 -3
- package/src/lib/components/NeedHelpSection/NeedHelpSection.js +3 -3
- package/src/lib/components/NetworkPicker/components/UnsupportedNetwork/UnsupportedNetwork.cjs +1 -1
- package/src/lib/components/NetworkPicker/components/UnsupportedNetwork/UnsupportedNetwork.js +1 -1
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +7 -6
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -1
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +7 -6
- package/src/lib/components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs +1 -1
- package/src/lib/components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js +1 -1
- package/src/lib/components/Search/Search.cjs +1 -1
- package/src/lib/components/Search/Search.d.ts +2 -1
- package/src/lib/components/Search/Search.js +1 -1
- package/src/lib/components/SecureTurnkeyWalletCard/SecureTurnkeyWalletCard.cjs +2 -2
- package/src/lib/components/SecureTurnkeyWalletCard/SecureTurnkeyWalletCard.js +2 -2
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +3 -3
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +3 -3
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +1 -1
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +1 -1
- package/src/lib/components/SendBalancePageLayout/components/TokenBalanceCard/TokenBalanceCard.cjs +1 -1
- package/src/lib/components/SendBalancePageLayout/components/TokenBalanceCard/TokenBalanceCard.js +1 -1
- package/src/lib/components/TextButton/TextButton.d.ts +2 -1
- package/src/lib/components/Tooltip/Tooltip.cjs +2 -2
- package/src/lib/components/Tooltip/Tooltip.d.ts +2 -1
- package/src/lib/components/Tooltip/Tooltip.js +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -3
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.d.ts +2 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -3
- package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.cjs +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.d.ts +2 -1
- package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.js +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +1 -1
- package/src/lib/components/Typography/Typography.types.d.ts +2 -1
- package/src/lib/components/UserProfile/UserProfile.cjs +2 -2
- package/src/lib/components/UserProfile/UserProfile.d.ts +1 -0
- package/src/lib/components/UserProfile/UserProfile.js +2 -2
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.cjs +2 -2
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.d.ts +3 -2
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.js +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -2
- package/src/lib/data/api.cjs +0 -13
- package/src/lib/data/api.d.ts +1 -2
- package/src/lib/data/api.js +1 -13
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +1 -1
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +1 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +2 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.d.ts +2 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +2 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.cjs +1 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.js +1 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/PasskeyInfoHelper/PasskeyInfoHelper.cjs +1 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/PasskeyInfoHelper/PasskeyInfoHelper.js +1 -1
- package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.cjs +2 -2
- package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.d.ts +2 -1
- package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.js +2 -2
- package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.cjs +2 -2
- package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.d.ts +2 -1
- package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.js +2 -2
- package/src/lib/locale/en/translation.cjs +124 -1
- package/src/lib/locale/en/translation.d.ts +124 -1
- package/src/lib/locale/en/translation.js +124 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +1 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +1 -1
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +2 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +2 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -1
- package/src/lib/shared/types/index.d.ts +3 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +16 -9
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +16 -9
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs +28 -1
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js +28 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -4
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -4
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +51 -7
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.d.ts +3 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +51 -7
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +3 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +3 -0
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/index.d.ts +1 -0
- package/src/lib/utils/hooks/{useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs → useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs} +53 -67
- package/src/lib/utils/hooks/{useFetchNetworkConfigurations/useFetchNetworkConfigurations.d.ts → useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts} +3 -2
- package/src/lib/utils/hooks/{useFetchNetworkConfigurations/useFetchNetworkConfigurations.js → useProcessNetworkConfigurations/useProcessNetworkConfigurations.js} +53 -67
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +20 -14
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +20 -14
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +26 -4
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +26 -4
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +1 -1
- package/src/lib/views/AccountExistsView/AccountExistsView.cjs +1 -1
- package/src/lib/views/AccountExistsView/AccountExistsView.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/BridgeWelcomeView/BridgeWelcomeView.cjs +1 -1
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.js +1 -1
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +3 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +3 -2
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +4 -4
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +4 -4
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +9 -8
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +9 -8
- package/src/lib/views/CollectUserDataView/useFields.cjs +11 -0
- package/src/lib/views/CollectUserDataView/useFields.d.ts +11 -0
- package/src/lib/views/CollectUserDataView/useFields.js +11 -0
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.cjs +3 -3
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.js +3 -3
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +1 -1
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +1 -1
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +2 -2
- package/src/lib/views/EmailUpdate/EmailUpdate.js +2 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +35 -24
- package/src/lib/views/EmailVerification/EmailVerification.js +35 -24
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +2 -3
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +2 -3
- package/src/lib/views/LoginView/sections/WalletSignInSection/ListItemButton/ListItemButton.cjs +2 -2
- package/src/lib/views/LoginView/sections/WalletSignInSection/ListItemButton/ListItemButton.d.ts +3 -2
- package/src/lib/views/LoginView/sections/WalletSignInSection/ListItemButton/ListItemButton.js +2 -2
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSignInSection.cjs +1 -1
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSignInSection.js +1 -1
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.cjs +1 -1
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.js +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +3 -3
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +3 -3
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +2 -2
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +2 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +3 -1
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +3 -1
- package/src/lib/views/NoAccess/NoAccess.cjs +1 -1
- package/src/lib/views/NoAccess/NoAccess.js +1 -1
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.cjs +6 -2
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.js +6 -2
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.cjs +10 -5
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.js +10 -5
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +3 -3
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +3 -3
- package/src/lib/views/PendingConnectView/PendingConnectView.cjs +7 -4
- package/src/lib/views/PendingConnectView/PendingConnectView.js +7 -4
- package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +8 -5
- package/src/lib/views/PendingSignatureView/PendingSignatureView.js +8 -5
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +11 -8
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +11 -8
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -1
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +2 -1
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -1
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -1
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +4 -3
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +4 -3
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +8 -6
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.d.ts +2 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +8 -6
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.cjs +1 -1
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.js +1 -1
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.cjs +1 -1
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.js +1 -1
- package/src/lib/views/WalletList/WalletList.cjs +6 -9
- package/src/lib/views/WalletList/WalletList.js +6 -9
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +3 -2
- package/src/lib/views/WalletLockedView/WalletLockedView.js +3 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +4 -3
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +4 -3
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -1
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -1
- package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/DynamicWidget.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +5 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +5 -3
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.d.ts +3 -2
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.js +2 -2
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.cjs +65 -21
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.js +66 -22
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/ManagePasskeysWidgetView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/ManagePasskeysWidgetView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js +1 -1
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/index.d.ts +0 -1
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/index.d.ts +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +0 -0
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var utils = require('@dynamic-labs/utils');
|
|
7
6
|
var validators = require('../../../context/DynamicContext/validators.cjs');
|
|
8
|
-
var api = require('../../../data/api.cjs');
|
|
9
7
|
require('@dynamic-labs/sdk-api');
|
|
10
8
|
require('../../../shared/logger.cjs');
|
|
11
9
|
require('@dynamic-labs/iconic');
|
|
@@ -18,12 +16,12 @@ require('../../constants/colors.cjs');
|
|
|
18
16
|
var localStorage$1 = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
17
|
require('viem');
|
|
20
18
|
var useLocalStorage = require('../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
19
|
+
require('@dynamic-labs/utils');
|
|
21
20
|
require('../../../shared/consts/index.cjs');
|
|
22
21
|
var usePrevious = require('../usePrevious/usePrevious.cjs');
|
|
23
22
|
var mergeCustomerEvmNetworksWithServerNetworks = require('./utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs');
|
|
24
23
|
|
|
25
|
-
const
|
|
26
|
-
const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, maxRetries = MAX_RETRIES, }) => {
|
|
24
|
+
const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, projectSettings, }) => {
|
|
27
25
|
var _a;
|
|
28
26
|
/**
|
|
29
27
|
* This is the version of the local storage object. If the version changes, the local storage object will be removed.
|
|
@@ -32,7 +30,6 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
32
30
|
const VERSION = 2;
|
|
33
31
|
const [lsNetworks, setLsNetworks, removeLsNetworks] = useLocalStorage.useLocalStorage(localStorage.NETWORKS_STORAGE_KEY, undefined, validators.validateLocalStorageExpiry);
|
|
34
32
|
const [loading, setLoading] = React.useState(false);
|
|
35
|
-
const [retries, setRetries] = React.useState(0);
|
|
36
33
|
const [completed, setCompleted] = React.useState(false);
|
|
37
34
|
const [lsNetworksExists, setlsNetworksExists] = React.useState(Boolean(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) && (lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.version) === VERSION);
|
|
38
35
|
// Stringify the objects for easy comparison
|
|
@@ -84,76 +81,65 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
84
81
|
handleRemoveLsNetworks,
|
|
85
82
|
]);
|
|
86
83
|
React.useEffect(() => {
|
|
87
|
-
|
|
84
|
+
var _a, _b, _c, _d;
|
|
85
|
+
if (!lsNetworksExists && !loading && (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks)) {
|
|
88
86
|
setLoading(true);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
environmentId,
|
|
136
|
-
expiry,
|
|
137
|
-
version: VERSION,
|
|
138
|
-
});
|
|
139
|
-
setlsNetworksExists(true);
|
|
140
|
-
})
|
|
141
|
-
.catch((e) => {
|
|
142
|
-
setRetries((currentRetries) => currentRetries + 1);
|
|
143
|
-
})
|
|
144
|
-
.finally(() => {
|
|
145
|
-
setLoading(false);
|
|
87
|
+
const { networks } = projectSettings;
|
|
88
|
+
const expiry = new Date().getTime() + 60000 * 5;
|
|
89
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
90
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
91
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
92
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
93
|
+
let mergedEvmNetworks;
|
|
94
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
95
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
96
|
+
chainId: parser(network.chainId),
|
|
97
|
+
iconUrls: network.iconUrls,
|
|
98
|
+
lcdUrl: network.lcdUrl,
|
|
99
|
+
name: network.name,
|
|
100
|
+
nativeCurrency: network.nativeCurrency,
|
|
101
|
+
networkId: parser(network.networkId),
|
|
102
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
103
|
+
rpcUrls: network.rpcUrls,
|
|
104
|
+
vanityName: network.vanityName,
|
|
105
|
+
});
|
|
106
|
+
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
107
|
+
const serverNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
108
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
109
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
110
|
+
if (!serverNetworks && (customerEvmNetworks === null || customerEvmNetworks === void 0 ? void 0 : customerEvmNetworks.length)) {
|
|
111
|
+
mergedEvmNetworks = customerEvmNetworks;
|
|
112
|
+
}
|
|
113
|
+
if (!customerEvmNetworks && (serverNetworks === null || serverNetworks === void 0 ? void 0 : serverNetworks.length)) {
|
|
114
|
+
mergedEvmNetworks = serverNetworks;
|
|
115
|
+
}
|
|
116
|
+
if (serverNetworks !== undefined &&
|
|
117
|
+
serverNetworks.length &&
|
|
118
|
+
customerEvmNetworks !== undefined &&
|
|
119
|
+
customerEvmNetworks.length) {
|
|
120
|
+
mergedEvmNetworks = mergeCustomerEvmNetworksWithServerNetworks.mergeCustomerEvmNetworksWithServerNetworks(customerEvmNetworks, serverNetworks);
|
|
121
|
+
}
|
|
122
|
+
setLsNetworks({
|
|
123
|
+
configurations: {
|
|
124
|
+
cosmos: cosmosNetworks,
|
|
125
|
+
evm: mergedEvmNetworks,
|
|
126
|
+
solana: solanaNetworks,
|
|
127
|
+
starknet: starknetNetworks,
|
|
128
|
+
},
|
|
129
|
+
environmentId,
|
|
130
|
+
expiry,
|
|
131
|
+
version: VERSION,
|
|
146
132
|
});
|
|
133
|
+
setlsNetworksExists(true);
|
|
134
|
+
setLoading(false);
|
|
147
135
|
}
|
|
148
136
|
}, [
|
|
149
|
-
authToken,
|
|
150
137
|
environmentId,
|
|
151
138
|
loading,
|
|
152
139
|
customerEvmNetworks,
|
|
153
140
|
lsNetworksExists,
|
|
154
|
-
maxRetries,
|
|
155
|
-
retries,
|
|
156
141
|
setLsNetworks,
|
|
142
|
+
projectSettings,
|
|
157
143
|
]);
|
|
158
144
|
return {
|
|
159
145
|
configurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations,
|
|
@@ -161,4 +147,4 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
161
147
|
};
|
|
162
148
|
};
|
|
163
149
|
|
|
164
|
-
exports.
|
|
150
|
+
exports.useProcessNetworkConfigurations = useProcessNetworkConfigurations;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
1
2
|
import { GenericNetwork } from '@dynamic-labs/types';
|
|
2
3
|
export type fetchNetworkConfigurationsProps = {
|
|
3
4
|
authToken: string | undefined;
|
|
4
5
|
environmentId: string;
|
|
5
6
|
evmNetworks?: GenericNetwork[];
|
|
6
|
-
|
|
7
|
+
projectSettings?: ProjectSettings;
|
|
7
8
|
};
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const useProcessNetworkConfigurations: ({ authToken, environmentId, evmNetworks: customerEvmNetworks, projectSettings, }: fetchNetworkConfigurationsProps) => {
|
|
9
10
|
configurations: import("@dynamic-labs/types").NetworkConfigurationMap | undefined;
|
|
10
11
|
handleRemoveLsNetworks: () => void;
|
|
11
12
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
3
2
|
import { validateLocalStorageExpiry } from '../../../context/DynamicContext/validators.js';
|
|
4
|
-
import { fetchNetworkSettings } from '../../../data/api.js';
|
|
5
3
|
import '@dynamic-labs/sdk-api';
|
|
6
4
|
import '../../../shared/logger.js';
|
|
7
5
|
import '@dynamic-labs/iconic';
|
|
@@ -14,12 +12,12 @@ import '../../constants/colors.js';
|
|
|
14
12
|
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
13
|
import 'viem';
|
|
16
14
|
import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
15
|
+
import '@dynamic-labs/utils';
|
|
17
16
|
import '../../../shared/consts/index.js';
|
|
18
17
|
import { usePrevious } from '../usePrevious/usePrevious.js';
|
|
19
18
|
import { mergeCustomerEvmNetworksWithServerNetworks } from './utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js';
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, maxRetries = MAX_RETRIES, }) => {
|
|
20
|
+
const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, projectSettings, }) => {
|
|
23
21
|
var _a;
|
|
24
22
|
/**
|
|
25
23
|
* This is the version of the local storage object. If the version changes, the local storage object will be removed.
|
|
@@ -28,7 +26,6 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
28
26
|
const VERSION = 2;
|
|
29
27
|
const [lsNetworks, setLsNetworks, removeLsNetworks] = useLocalStorage(NETWORKS_STORAGE_KEY, undefined, validateLocalStorageExpiry);
|
|
30
28
|
const [loading, setLoading] = useState(false);
|
|
31
|
-
const [retries, setRetries] = useState(0);
|
|
32
29
|
const [completed, setCompleted] = useState(false);
|
|
33
30
|
const [lsNetworksExists, setlsNetworksExists] = useState(Boolean(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) && (lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.version) === VERSION);
|
|
34
31
|
// Stringify the objects for easy comparison
|
|
@@ -80,76 +77,65 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
80
77
|
handleRemoveLsNetworks,
|
|
81
78
|
]);
|
|
82
79
|
useEffect(() => {
|
|
83
|
-
|
|
80
|
+
var _a, _b, _c, _d;
|
|
81
|
+
if (!lsNetworksExists && !loading && (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks)) {
|
|
84
82
|
setLoading(true);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
environmentId,
|
|
132
|
-
expiry,
|
|
133
|
-
version: VERSION,
|
|
134
|
-
});
|
|
135
|
-
setlsNetworksExists(true);
|
|
136
|
-
})
|
|
137
|
-
.catch((e) => {
|
|
138
|
-
setRetries((currentRetries) => currentRetries + 1);
|
|
139
|
-
})
|
|
140
|
-
.finally(() => {
|
|
141
|
-
setLoading(false);
|
|
83
|
+
const { networks } = projectSettings;
|
|
84
|
+
const expiry = new Date().getTime() + 60000 * 5;
|
|
85
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
86
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
87
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
88
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
89
|
+
let mergedEvmNetworks;
|
|
90
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
91
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
92
|
+
chainId: parser(network.chainId),
|
|
93
|
+
iconUrls: network.iconUrls,
|
|
94
|
+
lcdUrl: network.lcdUrl,
|
|
95
|
+
name: network.name,
|
|
96
|
+
nativeCurrency: network.nativeCurrency,
|
|
97
|
+
networkId: parser(network.networkId),
|
|
98
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
99
|
+
rpcUrls: network.rpcUrls,
|
|
100
|
+
vanityName: network.vanityName,
|
|
101
|
+
});
|
|
102
|
+
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
103
|
+
const serverNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
104
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
105
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
106
|
+
if (!serverNetworks && (customerEvmNetworks === null || customerEvmNetworks === void 0 ? void 0 : customerEvmNetworks.length)) {
|
|
107
|
+
mergedEvmNetworks = customerEvmNetworks;
|
|
108
|
+
}
|
|
109
|
+
if (!customerEvmNetworks && (serverNetworks === null || serverNetworks === void 0 ? void 0 : serverNetworks.length)) {
|
|
110
|
+
mergedEvmNetworks = serverNetworks;
|
|
111
|
+
}
|
|
112
|
+
if (serverNetworks !== undefined &&
|
|
113
|
+
serverNetworks.length &&
|
|
114
|
+
customerEvmNetworks !== undefined &&
|
|
115
|
+
customerEvmNetworks.length) {
|
|
116
|
+
mergedEvmNetworks = mergeCustomerEvmNetworksWithServerNetworks(customerEvmNetworks, serverNetworks);
|
|
117
|
+
}
|
|
118
|
+
setLsNetworks({
|
|
119
|
+
configurations: {
|
|
120
|
+
cosmos: cosmosNetworks,
|
|
121
|
+
evm: mergedEvmNetworks,
|
|
122
|
+
solana: solanaNetworks,
|
|
123
|
+
starknet: starknetNetworks,
|
|
124
|
+
},
|
|
125
|
+
environmentId,
|
|
126
|
+
expiry,
|
|
127
|
+
version: VERSION,
|
|
142
128
|
});
|
|
129
|
+
setlsNetworksExists(true);
|
|
130
|
+
setLoading(false);
|
|
143
131
|
}
|
|
144
132
|
}, [
|
|
145
|
-
authToken,
|
|
146
133
|
environmentId,
|
|
147
134
|
loading,
|
|
148
135
|
customerEvmNetworks,
|
|
149
136
|
lsNetworksExists,
|
|
150
|
-
maxRetries,
|
|
151
|
-
retries,
|
|
152
137
|
setLsNetworks,
|
|
138
|
+
projectSettings,
|
|
153
139
|
]);
|
|
154
140
|
return {
|
|
155
141
|
configurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations,
|
|
@@ -157,4 +143,4 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
157
143
|
};
|
|
158
144
|
};
|
|
159
145
|
|
|
160
|
-
export {
|
|
146
|
+
export { useProcessNetworkConfigurations };
|
|
@@ -27,7 +27,9 @@ require('@dynamic-labs/multi-wallet');
|
|
|
27
27
|
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
28
28
|
var getOauthLoginUrl = require('../../functions/getOauthLoginUrl/getOauthLoginUrl.cjs');
|
|
29
29
|
var getProviderByType = require('../../functions/getProviderByType/getProviderByType.cjs');
|
|
30
|
+
var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
30
31
|
var randomString = require('../../functions/randomString/randomString.cjs');
|
|
32
|
+
var index = require('../../functions/storeAuthToken/index.cjs');
|
|
31
33
|
var stringifyURIQuery = require('../../functions/stringifyURIQuery/stringifyURIQuery.cjs');
|
|
32
34
|
var useCreateUserProfileByJWTCallback = require('../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs');
|
|
33
35
|
var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
@@ -58,6 +60,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
58
60
|
const { createEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
|
|
59
61
|
const [isProcessing, setIsProcessing] = React.useState(false);
|
|
60
62
|
const [error, setError] = React.useState();
|
|
63
|
+
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
61
64
|
const providersWaitingOauthMessage = React.useRef({});
|
|
62
65
|
const authWindowInterval = React.useRef();
|
|
63
66
|
const shouldPool = React.useRef(false);
|
|
@@ -147,22 +150,25 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
152
|
setCallback('authSuccess');
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
if (isTurnkeyProviderEnabled &&
|
|
154
|
+
((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation)) {
|
|
155
|
+
try {
|
|
156
|
+
index.storeAuthToken(jwt);
|
|
157
|
+
// this function will check turnkey wallet enabled and create wallet if needed
|
|
158
|
+
// if not enabled, it will throw an error.
|
|
159
|
+
yield createEmbeddedWallet();
|
|
160
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
yield createUserProfileByJWT(jwt);
|
|
164
|
+
setShowAuthFlow(false);
|
|
165
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
166
|
+
}
|
|
154
167
|
return;
|
|
155
168
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
yield createEmbeddedWallet();
|
|
160
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
161
|
-
}
|
|
162
|
-
catch (e) {
|
|
163
|
-
setShowAuthFlow(false);
|
|
164
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
165
|
-
}
|
|
169
|
+
yield createUserProfileByJWT(jwt);
|
|
170
|
+
setShowAuthFlow(false);
|
|
171
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
166
172
|
}
|
|
167
173
|
catch (error) {
|
|
168
174
|
if (error instanceof utils.NoAccessError) {
|
|
@@ -23,7 +23,9 @@ import '@dynamic-labs/multi-wallet';
|
|
|
23
23
|
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
24
24
|
import { getOauthLoginUrl } from '../../functions/getOauthLoginUrl/getOauthLoginUrl.js';
|
|
25
25
|
import { getProviderByType } from '../../functions/getProviderByType/getProviderByType.js';
|
|
26
|
+
import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
26
27
|
import { randomString } from '../../functions/randomString/randomString.js';
|
|
28
|
+
import { storeAuthToken } from '../../functions/storeAuthToken/index.js';
|
|
27
29
|
import { stringifyURIQuery } from '../../functions/stringifyURIQuery/stringifyURIQuery.js';
|
|
28
30
|
import { useCreateUserProfileByJWTCallback } from '../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js';
|
|
29
31
|
import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
|
|
@@ -54,6 +56,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
54
56
|
const { createEmbeddedWallet } = useEmbeddedWallet();
|
|
55
57
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
56
58
|
const [error, setError] = useState();
|
|
59
|
+
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
57
60
|
const providersWaitingOauthMessage = useRef({});
|
|
58
61
|
const authWindowInterval = useRef();
|
|
59
62
|
const shouldPool = useRef(false);
|
|
@@ -143,22 +146,25 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
148
|
setCallback('authSuccess');
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
if (isTurnkeyProviderEnabled &&
|
|
150
|
+
((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation)) {
|
|
151
|
+
try {
|
|
152
|
+
storeAuthToken(jwt);
|
|
153
|
+
// this function will check turnkey wallet enabled and create wallet if needed
|
|
154
|
+
// if not enabled, it will throw an error.
|
|
155
|
+
yield createEmbeddedWallet();
|
|
156
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
yield createUserProfileByJWT(jwt);
|
|
160
|
+
setShowAuthFlow(false);
|
|
161
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
162
|
+
}
|
|
150
163
|
return;
|
|
151
164
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
yield createEmbeddedWallet();
|
|
156
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
157
|
-
}
|
|
158
|
-
catch (e) {
|
|
159
|
-
setShowAuthFlow(false);
|
|
160
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
161
|
-
}
|
|
165
|
+
yield createUserProfileByJWT(jwt);
|
|
166
|
+
setShowAuthFlow(false);
|
|
167
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
162
168
|
}
|
|
163
169
|
catch (error) {
|
|
164
170
|
if (error instanceof NoAccessError) {
|
|
@@ -25,6 +25,8 @@ require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
|
25
25
|
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
26
26
|
require('@dynamic-labs/multi-wallet');
|
|
27
27
|
require('@dynamic-labs/sdk-api');
|
|
28
|
+
var isTurnkeyEnabled = require('../../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
29
|
+
var index = require('../../../functions/storeAuthToken/index.cjs');
|
|
28
30
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
29
31
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
30
32
|
var useEmailVerificationRequest = require('../../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs');
|
|
@@ -54,13 +56,14 @@ const userFieldsSchema = yup.object().shape({
|
|
|
54
56
|
username: yup.string(),
|
|
55
57
|
});
|
|
56
58
|
const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
57
|
-
const { authToken, onboardingOnlyJwt, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
59
|
+
const { authToken, onboardingOnlyJwt, environmentId, projectSettings, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
60
|
+
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
58
61
|
const jwtToken = onboardingOnlyJwt || authToken;
|
|
59
62
|
const { setVerificationUUID, setEmail } = EmailVerificationContext.useEmailVerificationContext();
|
|
60
63
|
const { verifyEmail } = useEmailVerificationRequest.useEmailVerificationRequest();
|
|
61
64
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
62
65
|
return React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
var _a, _b, _c;
|
|
66
|
+
var _a, _b, _c, _d;
|
|
64
67
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
65
68
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
66
69
|
const { metadata } = userFields;
|
|
@@ -72,6 +75,25 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
72
75
|
const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
|
|
73
76
|
const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
|
|
74
77
|
const _isEmailVerificationRequired = isEmailVerificationRequired.isEmailVerificationRequired(updateUserProfileResponse);
|
|
78
|
+
// This is to handle properly the embedded wallet creation.
|
|
79
|
+
// In that case we shouldn't create a user. Only store the JWT in the localstorage
|
|
80
|
+
// The user will be created after generating the wallet.
|
|
81
|
+
// This should be called only when:
|
|
82
|
+
// Turnkey is enabled
|
|
83
|
+
// automaticEmbeddedWalletCreation is set to true
|
|
84
|
+
// there is no emailVerificationRequired -> it's already verified
|
|
85
|
+
// there is no primaryWallet -> it means that the user is already logged in
|
|
86
|
+
if (isTurnkeyProviderEnabled &&
|
|
87
|
+
((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
88
|
+
!_isEmailVerificationRequired &&
|
|
89
|
+
!primaryWallet) {
|
|
90
|
+
index.storeAuthToken(updateUserProfileResponse.jwt);
|
|
91
|
+
return {
|
|
92
|
+
isEmailVerificationRequired: false,
|
|
93
|
+
missingFields,
|
|
94
|
+
updateUserProfileResponse,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
75
97
|
if (!_isEmailVerificationRequired) {
|
|
76
98
|
// If email verification is not needed then we can update the user profile immediately.
|
|
77
99
|
yield updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
@@ -82,8 +104,8 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
82
104
|
};
|
|
83
105
|
}
|
|
84
106
|
// We update EmailContext to use this information in the Email Verification view
|
|
85
|
-
setEmail((
|
|
86
|
-
setVerificationUUID((
|
|
107
|
+
setEmail((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.email);
|
|
108
|
+
setVerificationUUID((_d = updateUserProfileResponse.emailVerification) === null || _d === void 0 ? void 0 : _d.verificationUUID);
|
|
87
109
|
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
88
110
|
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
89
111
|
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
@@ -21,6 +21,8 @@ import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
|
21
21
|
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
22
22
|
import '@dynamic-labs/multi-wallet';
|
|
23
23
|
import '@dynamic-labs/sdk-api';
|
|
24
|
+
import { isTurnkeyEnabled } from '../../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
25
|
+
import { storeAuthToken } from '../../../functions/storeAuthToken/index.js';
|
|
24
26
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
25
27
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
26
28
|
import { useEmailVerificationRequest } from '../../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js';
|
|
@@ -50,13 +52,14 @@ const userFieldsSchema = object().shape({
|
|
|
50
52
|
username: string(),
|
|
51
53
|
});
|
|
52
54
|
const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
53
|
-
const { authToken, onboardingOnlyJwt, environmentId } = useInternalDynamicContext();
|
|
55
|
+
const { authToken, onboardingOnlyJwt, environmentId, projectSettings, primaryWallet, } = useInternalDynamicContext();
|
|
56
|
+
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
54
57
|
const jwtToken = onboardingOnlyJwt || authToken;
|
|
55
58
|
const { setVerificationUUID, setEmail } = useEmailVerificationContext();
|
|
56
59
|
const { verifyEmail } = useEmailVerificationRequest();
|
|
57
60
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
58
61
|
return useCallback((userFields, userEnvironmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
var _a, _b, _c;
|
|
62
|
+
var _a, _b, _c, _d;
|
|
60
63
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
61
64
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
62
65
|
const { metadata } = userFields;
|
|
@@ -68,6 +71,25 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
68
71
|
const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
|
|
69
72
|
const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
|
|
70
73
|
const _isEmailVerificationRequired = isEmailVerificationRequired(updateUserProfileResponse);
|
|
74
|
+
// This is to handle properly the embedded wallet creation.
|
|
75
|
+
// In that case we shouldn't create a user. Only store the JWT in the localstorage
|
|
76
|
+
// The user will be created after generating the wallet.
|
|
77
|
+
// This should be called only when:
|
|
78
|
+
// Turnkey is enabled
|
|
79
|
+
// automaticEmbeddedWalletCreation is set to true
|
|
80
|
+
// there is no emailVerificationRequired -> it's already verified
|
|
81
|
+
// there is no primaryWallet -> it means that the user is already logged in
|
|
82
|
+
if (isTurnkeyProviderEnabled &&
|
|
83
|
+
((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
84
|
+
!_isEmailVerificationRequired &&
|
|
85
|
+
!primaryWallet) {
|
|
86
|
+
storeAuthToken(updateUserProfileResponse.jwt);
|
|
87
|
+
return {
|
|
88
|
+
isEmailVerificationRequired: false,
|
|
89
|
+
missingFields,
|
|
90
|
+
updateUserProfileResponse,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
71
93
|
if (!_isEmailVerificationRequired) {
|
|
72
94
|
// If email verification is not needed then we can update the user profile immediately.
|
|
73
95
|
yield updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
@@ -78,8 +100,8 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
78
100
|
};
|
|
79
101
|
}
|
|
80
102
|
// We update EmailContext to use this information in the Email Verification view
|
|
81
|
-
setEmail((
|
|
82
|
-
setVerificationUUID((
|
|
103
|
+
setEmail((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.email);
|
|
104
|
+
setVerificationUUID((_d = updateUserProfileResponse.emailVerification) === null || _d === void 0 ? void 0 : _d.verificationUUID);
|
|
83
105
|
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
84
106
|
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
85
107
|
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
@@ -38,7 +38,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
38
38
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
39
39
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
40
40
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
41
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
42
42
|
// If the user is not already logged it means that we only need to verify
|
|
43
43
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
44
44
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -80,7 +80,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
80
80
|
if (newSelectedCredentialWallet) {
|
|
81
81
|
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
82
82
|
if (verifyOnly ||
|
|
83
|
-
|
|
83
|
+
!primaryWallet ||
|
|
84
84
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
85
85
|
newSelectedCredentialWallet.walletName ===
|
|
86
86
|
(currentPrimaryWallet === null || currentPrimaryWallet === void 0 ? void 0 : currentPrimaryWallet.walletName)) ||
|