@dynamic-labs/sdk-react-core 1.1.0-alpha.24 → 1.1.0-alpha.26
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 +27 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +12 -12
- package/src/index.cjs +4 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -0
- package/src/lib/components/Icon/Icon.cjs +1 -0
- package/src/lib/components/Icon/Icon.js +1 -0
- package/src/lib/components/Icon/Icon.types.d.ts +1 -1
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +1 -1
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +1 -1
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +13 -60
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +13 -60
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.cjs +97 -0
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.d.ts +9 -0
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.js +93 -0
- package/src/lib/components/RetrySendVerificationCodeSection/index.d.ts +1 -0
- package/src/lib/components/SocialSignIn/SocialSignIn.cjs +2 -2
- package/src/lib/components/SocialSignIn/SocialSignIn.js +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -3
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -3
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +1 -0
- package/src/lib/context/DynamicContext/helpers/helpers.js +1 -0
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.js +1 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +3 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +2 -4
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +4 -50
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +1 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +4 -50
- package/src/lib/events/dynamicEvents.d.ts +2 -0
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +1 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +1 -2
- package/src/lib/shared/utils/functions/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/providerLabel/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.cjs +15 -0
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.d.ts +2 -0
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.js +11 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs +1 -0
- package/src/lib/utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js +1 -0
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.cjs +4 -0
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.js +4 -0
- package/src/lib/utils/functions/getReferencedAccount/getReferencedAccount.cjs +1 -0
- package/src/lib/utils/functions/getReferencedAccount/getReferencedAccount.js +1 -0
- package/src/lib/utils/functions/getUserWalletsFromVerifiedCredentials/getUserWalletsFromVerifiedCredentials.cjs +1 -0
- package/src/lib/utils/functions/getUserWalletsFromVerifiedCredentials/getUserWalletsFromVerifiedCredentials.js +1 -0
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +1 -1
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +1 -1
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -6
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -6
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +4 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +4 -5
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +38 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +16 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +39 -6
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs +1 -1
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/index.d.ts +1 -0
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.cjs +21 -0
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.d.ts +4 -0
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.js +17 -0
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.cjs +3 -2
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.js +3 -2
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.cjs +1 -0
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.js +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.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/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +1 -1
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -14
- package/src/lib/views/EmailVerification/EmailVerification.js +6 -14
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +1 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +1 -0
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +1 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -1
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +1 -1
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.cjs +1 -1
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.js +1 -1
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs +1 -1
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js +1 -1
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +1 -1
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +1 -1
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +1 -2
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +6 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +6 -1
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +1 -1
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -1
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +1 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +0 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +0 -49
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +0 -18
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +0 -44
package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import '../../events/dynamicEvents.js';
|
|
5
|
+
import '../../../../_virtual/_tslib.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../../context/DynamicContext/DynamicContext.js';
|
|
8
|
+
import '@dynamic-labs/sdk-api';
|
|
9
|
+
import '../../shared/logger.js';
|
|
10
|
+
import '@dynamic-labs/iconic';
|
|
11
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
12
|
+
import '../../context/ViewContext/ViewContext.js';
|
|
13
|
+
import { ReactComponent as SvgCheckCircle } from '../../shared/assets/check-circle.js';
|
|
14
|
+
import '@dynamic-labs/wallet-book';
|
|
15
|
+
import '../../utils/constants/colors.js';
|
|
16
|
+
import '../../utils/constants/values.js';
|
|
17
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
18
|
+
import 'viem';
|
|
19
|
+
import '../../shared/consts/index.js';
|
|
20
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
21
|
+
import '../../context/ErrorContext/ErrorContext.js';
|
|
22
|
+
import '@dynamic-labs/multi-wallet';
|
|
23
|
+
import 'viem/chains';
|
|
24
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
25
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
26
|
+
import '../../config/ApiEndpoint.js';
|
|
27
|
+
import '../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
28
|
+
import 'react-dom';
|
|
29
|
+
import { useCountdown } from '../../utils/hooks/useCountdown/useCountdown.js';
|
|
30
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
31
|
+
import { useMutation } from '../../utils/hooks/useMutation/useMutation.js';
|
|
32
|
+
import '@dynamic-labs/types';
|
|
33
|
+
import 'yup';
|
|
34
|
+
import '../../context/MockContext/MockContext.js';
|
|
35
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
36
|
+
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
37
|
+
import '@dynamic-labs/rpc-providers';
|
|
38
|
+
import '../../context/UserWalletsContext/UserWalletsContext.js';
|
|
39
|
+
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
40
|
+
import '../Alert/Alert.js';
|
|
41
|
+
import { Typography } from '../Typography/Typography.js';
|
|
42
|
+
import { TextButton } from '../TextButton/TextButton.js';
|
|
43
|
+
import '../ShadowDOM/ShadowDOM.js';
|
|
44
|
+
import { Icon } from '../Icon/Icon.js';
|
|
45
|
+
import '../IconButton/IconButton.js';
|
|
46
|
+
import '../InlineWidget/InlineWidget.js';
|
|
47
|
+
import '../MenuList/Dropdown/Dropdown.js';
|
|
48
|
+
import '../Transition/ZoomTransition/ZoomTransition.js';
|
|
49
|
+
import '../Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
50
|
+
import '../Transition/OpacityTransition/OpacityTransition.js';
|
|
51
|
+
import '../Popper/Popper/Popper.js';
|
|
52
|
+
import '../Popper/PopperContext/PopperContext.js';
|
|
53
|
+
import 'react-focus-lock';
|
|
54
|
+
import 'formik';
|
|
55
|
+
import 'i18next';
|
|
56
|
+
import '../OverlayCard/OverlayCard.context.js';
|
|
57
|
+
import '../PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
58
|
+
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
59
|
+
import '../../views/WalletList/WalletList.js';
|
|
60
|
+
import 'qrcode';
|
|
61
|
+
import '@hcaptcha/react-hcaptcha';
|
|
62
|
+
import '../../context/LoadingContext/LoadingContext.js';
|
|
63
|
+
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
64
|
+
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
65
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
66
|
+
import '../../context/FooterAnimationContext/index.js';
|
|
67
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
68
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
69
|
+
import '../UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
70
|
+
import '@dynamic-labs/viem-utils';
|
|
71
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
72
|
+
|
|
73
|
+
const RetrySendVerificationCodeSection = ({ retryHandler, secondsToRetry = 15, disabled = false, className }) => {
|
|
74
|
+
const { t } = useTranslation();
|
|
75
|
+
const [retried, setRetried] = useState(false);
|
|
76
|
+
const { remainingSeconds, startCountdown } = useCountdown({
|
|
77
|
+
callback: () => setRetried(false),
|
|
78
|
+
seconds: secondsToRetry,
|
|
79
|
+
});
|
|
80
|
+
const { isLoading, mutate: retry } = useMutation(retryHandler, {
|
|
81
|
+
onSuccess: () => {
|
|
82
|
+
setRetried(true);
|
|
83
|
+
startCountdown();
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
const containerClassName = classNames('retry-send-verification-code-section', className);
|
|
87
|
+
if (retried) {
|
|
88
|
+
return (jsxs("div", { className: containerClassName, children: [jsx(Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_email_verification.resend_code_in', children: t('dyn_email_verification.resend_code_in', { remainingSeconds }) }), jsxs("span", { className: 'retry-send-verification-code-section__confirmation', children: [jsx(Icon, { color: 'success-1', children: jsx(SvgCheckCircle, {}) }), jsx(Typography, { variant: 'body_small', weight: 'medium', color: 'primary', copykey: 'dyn_email_verification.code_sent', children: t('dyn_email_verification.code_sent') })] })] }));
|
|
89
|
+
}
|
|
90
|
+
return (jsxs("div", { className: containerClassName, children: [jsx(Typography, { variant: 'body_small', weight: 'medium', color: 'secondary', copykey: 'dyn_email_verification.code_not_received', children: t('dyn_email_verification.code_not_received') }), jsx(TextButton, { className: 'email-verification__text-button', disabled: isLoading || disabled, onClick: () => retry(), copykey: 'dyn_email_verification.resend_code', children: t('dyn_email_verification.resend_code') })] }));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { RetrySendVerificationCodeSection };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RetrySendVerificationCodeSection } from './RetrySendVerificationCodeSection';
|
|
@@ -16,9 +16,9 @@ require('../../utils/constants/colors.cjs');
|
|
|
16
16
|
require('../../utils/constants/values.cjs');
|
|
17
17
|
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
18
|
require('viem');
|
|
19
|
+
var providerLabel = require('../../shared/utils/functions/providerLabel/providerLabel.cjs');
|
|
19
20
|
require('@dynamic-labs/utils');
|
|
20
21
|
require('../../shared/consts/index.cjs');
|
|
21
|
-
var capitalize = require('../../shared/utils/functions/capitalize/capitalize.cjs');
|
|
22
22
|
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
23
23
|
require('../../events/dynamicEvents.cjs');
|
|
24
24
|
require('../../../../_virtual/_tslib.cjs');
|
|
@@ -117,7 +117,7 @@ const SocialSignIn = ({ providers, onSelectProvider, isLoading, selectedProvider
|
|
|
117
117
|
'social-sign-in--tile__full-width': fullWidth,
|
|
118
118
|
}), children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon:
|
|
119
119
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
120
|
-
jsxRuntime.jsx(iconic.SocialIcon, { name: getProviderAsString(provider), variant: iconThemeVariant }), isSpinning: selectedProvider === provider, iconSize: 32 }), !insideCard && fullWidth && (jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', children: ["Continue with ",
|
|
120
|
+
jsxRuntime.jsx(iconic.SocialIcon, { name: getProviderAsString(provider), variant: iconThemeVariant }), isSpinning: selectedProvider === provider, iconSize: 32 }), !insideCard && fullWidth && (jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', children: ["Continue with ", providerLabel.providerLabel(provider)] }))] }, getProviderAsString(provider)));
|
|
121
121
|
if (!providers.length) {
|
|
122
122
|
logger.logger.error('Failed to render SocialSignInSection - no social providers enabled');
|
|
123
123
|
return null;
|
|
@@ -12,9 +12,9 @@ import '../../utils/constants/colors.js';
|
|
|
12
12
|
import '../../utils/constants/values.js';
|
|
13
13
|
import '../../shared/utils/classes/storage/localStorage.js';
|
|
14
14
|
import 'viem';
|
|
15
|
+
import { providerLabel } from '../../shared/utils/functions/providerLabel/providerLabel.js';
|
|
15
16
|
import '@dynamic-labs/utils';
|
|
16
17
|
import '../../shared/consts/index.js';
|
|
17
|
-
import { capitalize } from '../../shared/utils/functions/capitalize/capitalize.js';
|
|
18
18
|
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
19
19
|
import '../../events/dynamicEvents.js';
|
|
20
20
|
import '../../../../_virtual/_tslib.js';
|
|
@@ -113,7 +113,7 @@ const SocialSignIn = ({ providers, onSelectProvider, isLoading, selectedProvider
|
|
|
113
113
|
'social-sign-in--tile__full-width': fullWidth,
|
|
114
114
|
}), children: [jsx(IconWithSpinner, { Icon:
|
|
115
115
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
116
|
-
jsx(SocialIcon, { name: getProviderAsString(provider), variant: iconThemeVariant }), isSpinning: selectedProvider === provider, iconSize: 32 }), !insideCard && fullWidth && (jsxs(Typography, { variant: 'button_primary', children: ["Continue with ",
|
|
116
|
+
jsx(SocialIcon, { name: getProviderAsString(provider), variant: iconThemeVariant }), isSpinning: selectedProvider === provider, iconSize: 32 }), !insideCard && fullWidth && (jsxs(Typography, { variant: 'button_primary', children: ["Continue with ", providerLabel(provider)] }))] }, getProviderAsString(provider)));
|
|
117
117
|
if (!providers.length) {
|
|
118
118
|
logger.error('Failed to render SocialSignInSection - no social providers enabled');
|
|
119
119
|
return null;
|
|
@@ -20,6 +20,7 @@ require('../../utils/constants/colors.cjs');
|
|
|
20
20
|
var values = require('../../utils/constants/values.cjs');
|
|
21
21
|
var localStorage = require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
22
22
|
require('viem');
|
|
23
|
+
require('@dynamic-labs/sdk-api');
|
|
23
24
|
var useGlobalLoading = require('../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs');
|
|
24
25
|
var useLocalStorage = require('../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
25
26
|
require('../../shared/consts/index.cjs');
|
|
@@ -27,7 +28,6 @@ var CaptchaContext = require('../CaptchaContext/CaptchaContext.cjs');
|
|
|
27
28
|
var ErrorContext = require('../ErrorContext/ErrorContext.cjs');
|
|
28
29
|
require('@dynamic-labs/multi-wallet');
|
|
29
30
|
var getAuthToken = require('../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
30
|
-
require('@dynamic-labs/sdk-api');
|
|
31
31
|
require('viem/chains');
|
|
32
32
|
var AccessDeniedContext = require('../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
33
33
|
var AccountExistsContext = require('../AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -233,8 +233,10 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
233
233
|
}),
|
|
234
234
|
primaryWalletId,
|
|
235
235
|
removeIsFullyConnected,
|
|
236
|
+
setIsVerificationInProgress,
|
|
236
237
|
setPrimaryWalletId,
|
|
237
238
|
setShowAuthFlow,
|
|
239
|
+
user,
|
|
238
240
|
walletConnectorOptions,
|
|
239
241
|
});
|
|
240
242
|
// Ties all client callbacks to dynamic's events, such that
|
|
@@ -369,10 +371,8 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
369
371
|
helpers.initExpirationTime(handleLogOut);
|
|
370
372
|
}, [handleLogOut]);
|
|
371
373
|
const { setCallback } = useCustomerCallbacks.useCustomerCallbacks({
|
|
372
|
-
authMode,
|
|
373
374
|
callbacks: {
|
|
374
375
|
onAuthSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onAuthSuccess,
|
|
375
|
-
onConnect: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onConnect,
|
|
376
376
|
onEmbeddedWalletCreated: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmbeddedWalletCreated,
|
|
377
377
|
onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
|
|
378
378
|
onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
|
|
@@ -16,6 +16,7 @@ import '../../utils/constants/colors.js';
|
|
|
16
16
|
import { DEFAULT_NUMBER_OF_WALLETS_TO_SHOW } from '../../utils/constants/values.js';
|
|
17
17
|
import { LocalStorage } from '../../shared/utils/classes/storage/localStorage.js';
|
|
18
18
|
import 'viem';
|
|
19
|
+
import '@dynamic-labs/sdk-api';
|
|
19
20
|
import { useGlobalLoading } from '../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.js';
|
|
20
21
|
import { useLocalStorage } from '../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
21
22
|
import '../../shared/consts/index.js';
|
|
@@ -23,7 +24,6 @@ import { CaptchaContextProvider } from '../CaptchaContext/CaptchaContext.js';
|
|
|
23
24
|
import { ErrorContextProvider } from '../ErrorContext/ErrorContext.js';
|
|
24
25
|
import '@dynamic-labs/multi-wallet';
|
|
25
26
|
import { getAuthToken } from '../../utils/functions/getAuthToken/getAuthToken.js';
|
|
26
|
-
import '@dynamic-labs/sdk-api';
|
|
27
27
|
import 'viem/chains';
|
|
28
28
|
import { AccessDeniedContextProvider } from '../AccessDeniedContext/AccessDeniedContext.js';
|
|
29
29
|
import { AccountExistsContextProvider } from '../AccountExistsContext/AccountExistsContext.js';
|
|
@@ -229,8 +229,10 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
229
229
|
}),
|
|
230
230
|
primaryWalletId,
|
|
231
231
|
removeIsFullyConnected,
|
|
232
|
+
setIsVerificationInProgress,
|
|
232
233
|
setPrimaryWalletId,
|
|
233
234
|
setShowAuthFlow,
|
|
235
|
+
user,
|
|
234
236
|
walletConnectorOptions,
|
|
235
237
|
});
|
|
236
238
|
// Ties all client callbacks to dynamic's events, such that
|
|
@@ -365,10 +367,8 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
365
367
|
initExpirationTime(handleLogOut);
|
|
366
368
|
}, [handleLogOut]);
|
|
367
369
|
const { setCallback } = useCustomerCallbacks({
|
|
368
|
-
authMode,
|
|
369
370
|
callbacks: {
|
|
370
371
|
onAuthSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onAuthSuccess,
|
|
371
|
-
onConnect: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onConnect,
|
|
372
372
|
onEmbeddedWalletCreated: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmbeddedWalletCreated,
|
|
373
373
|
onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
|
|
374
374
|
onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
|
|
@@ -15,6 +15,7 @@ require('../../../utils/constants/colors.cjs');
|
|
|
15
15
|
require('../../../utils/constants/values.cjs');
|
|
16
16
|
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
17
|
require('viem');
|
|
18
|
+
require('@dynamic-labs/sdk-api');
|
|
18
19
|
require('@dynamic-labs/utils');
|
|
19
20
|
var getAuthToken = require('../../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
20
21
|
|
|
@@ -11,6 +11,7 @@ import '../../../utils/constants/colors.js';
|
|
|
11
11
|
import '../../../utils/constants/values.js';
|
|
12
12
|
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
13
13
|
import 'viem';
|
|
14
|
+
import '@dynamic-labs/sdk-api';
|
|
14
15
|
import '@dynamic-labs/utils';
|
|
15
16
|
import { getAuthToken } from '../../../utils/functions/getAuthToken/getAuthToken.js';
|
|
16
17
|
|
|
@@ -16,6 +16,7 @@ require('../../../../utils/constants/colors.cjs');
|
|
|
16
16
|
require('../../../../utils/constants/values.cjs');
|
|
17
17
|
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
18
|
require('viem');
|
|
19
|
+
require('@dynamic-labs/sdk-api');
|
|
19
20
|
var useLocalStorage = require('../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
20
21
|
require('@dynamic-labs/utils');
|
|
21
22
|
require('../../../../shared/consts/index.cjs');
|
|
@@ -12,6 +12,7 @@ import '../../../../utils/constants/colors.js';
|
|
|
12
12
|
import '../../../../utils/constants/values.js';
|
|
13
13
|
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
14
14
|
import 'viem';
|
|
15
|
+
import '@dynamic-labs/sdk-api';
|
|
15
16
|
import { useLocalStorage } from '../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
16
17
|
import '@dynamic-labs/utils';
|
|
17
18
|
import '../../../../shared/consts/index.js';
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs
CHANGED
|
@@ -86,6 +86,10 @@ const useTieCallbacksToEvents = ({ clientCallbacks, connectedWallets, user, }) =
|
|
|
86
86
|
var _a;
|
|
87
87
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFlowClose) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks);
|
|
88
88
|
});
|
|
89
|
+
useDynamicEvents.useInternalDynamicEvents('walletConnected', (wallet) => {
|
|
90
|
+
var _a;
|
|
91
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onConnect) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, { wallet, walletConnector: wallet.connector });
|
|
92
|
+
});
|
|
89
93
|
useDynamicEvents.useInternalDynamicEvents('logout', () => {
|
|
90
94
|
var _a;
|
|
91
95
|
if (clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onDisconnect)
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js
CHANGED
|
@@ -82,6 +82,10 @@ const useTieCallbacksToEvents = ({ clientCallbacks, connectedWallets, user, }) =
|
|
|
82
82
|
var _a;
|
|
83
83
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFlowClose) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks);
|
|
84
84
|
});
|
|
85
|
+
useInternalDynamicEvents('walletConnected', (wallet) => {
|
|
86
|
+
var _a;
|
|
87
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onConnect) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, { wallet, walletConnector: wallet.connector });
|
|
88
|
+
});
|
|
85
89
|
useInternalDynamicEvents('logout', () => {
|
|
86
90
|
var _a;
|
|
87
91
|
if (clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onDisconnect)
|
|
@@ -2,13 +2,14 @@ import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
|
2
2
|
import { DynamicJwt, NameServiceData, ProjectSettings, SdkView } from '@dynamic-labs/sdk-api';
|
|
3
3
|
import { NetworkConfigurationMap, SocialProviderFilter, WalletUiUtils } from '@dynamic-labs/types';
|
|
4
4
|
import { Chain, FetchPublicAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { PasskeySuccessEnum } from '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner';
|
|
5
6
|
import { AccessDeniedCustomButton, AccountSwitchState, AuthModeType, AwaitingSignatureState, ChainToWalletMap, DynamicEventsCallbacks, DynamicRPCProviders, MultiWalletWidgetState, UserProfile, Wallet, WalletOption, WalletWithAction } from '../../../shared';
|
|
6
7
|
import { SocialNetworkIconType } from '../../../utils/functions/getSocialNetworkIcon';
|
|
7
8
|
import { MultiWalletWidgetStateSetter } from '../../../utils/hooks/multiWallet';
|
|
9
|
+
import { ConnectWalletOptions } from '../../../utils/hooks/useConnectWallet/useConnectWallet';
|
|
8
10
|
import { ThemeData, ThemeSetting } from '../../ThemeContext';
|
|
9
11
|
import { DisplayOrder, SetDisplayOrderPriority, SetShowAuthFlow } from '../hooks';
|
|
10
12
|
import { SetCallbackType } from '../useCustomerCallbacks';
|
|
11
|
-
import { PasskeySuccessEnum } from '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner';
|
|
12
13
|
export type ChainsToConnect = {
|
|
13
14
|
chain: Chain;
|
|
14
15
|
chainId?: number;
|
|
@@ -33,7 +34,7 @@ export interface IDynamicContext {
|
|
|
33
34
|
authorizationViewDisplayOrder: DisplayOrder;
|
|
34
35
|
awaitingSignatureState: AwaitingSignatureState;
|
|
35
36
|
clearStatesOnBackClick: () => void;
|
|
36
|
-
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts,
|
|
37
|
+
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts, options?: ConnectWalletOptions) => Promise<ConnectWalletResult | undefined>;
|
|
37
38
|
connectedWallets: Wallet[];
|
|
38
39
|
linkedWallets: Wallet[];
|
|
39
40
|
locale: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api';
|
|
2
|
-
import {
|
|
2
|
+
import { OnAuthSuccess, OnEmbeddedWalletCreated, OnLinkSuccess, OnUserProfileUpdate, UserProfile, Wallet } from '../../../shared/types';
|
|
3
3
|
import { IDynamicContext } from '../types';
|
|
4
|
-
export type Callback = 'authSuccess' | 'linkSuccess' | 'userProfileUpdate' | '
|
|
4
|
+
export type Callback = 'authSuccess' | 'linkSuccess' | 'userProfileUpdate' | 'embeddedWalletCreated';
|
|
5
5
|
export type CallbackParams = {
|
|
6
6
|
/** For embedded wallet events */
|
|
7
7
|
email?: string;
|
|
@@ -10,10 +10,8 @@ export type CallbackParams = {
|
|
|
10
10
|
walletId?: string;
|
|
11
11
|
};
|
|
12
12
|
export type UseCustomerCallbacksArgs = {
|
|
13
|
-
authMode: AuthModeType;
|
|
14
13
|
callbacks: {
|
|
15
14
|
onAuthSuccess?: OnAuthSuccess;
|
|
16
|
-
onConnect?: onConnect;
|
|
17
15
|
onLinkSuccess?: OnLinkSuccess;
|
|
18
16
|
onUserProfileUpdate?: OnUserProfileUpdate;
|
|
19
17
|
onEmbeddedWalletCreated?: OnEmbeddedWalletCreated;
|
|
@@ -20,9 +20,8 @@ require('../../../../../_virtual/_tslib.cjs');
|
|
|
20
20
|
require('@dynamic-labs/multi-wallet');
|
|
21
21
|
var getAuthToken = require('../../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
22
22
|
require('viem/chains');
|
|
23
|
-
var isConnectOnly = require('../../../utils/hooks/authenticationHooks/helpers/isConnectOnly.cjs');
|
|
24
23
|
|
|
25
|
-
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate,
|
|
24
|
+
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onEmbeddedWalletCreated, }, handleLogOut, primaryWallet, secondaryWallets, user, isAuthenticated, setIsVerificationInProgress, }) => {
|
|
26
25
|
const [callbackQueue, setCallbackQueue] = React.useState([]);
|
|
27
26
|
/** Gets the wallet from its id */
|
|
28
27
|
const getWallet = React.useCallback((id) => {
|
|
@@ -31,39 +30,6 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
31
30
|
? (_a = [primaryWallet, ...secondaryWallets].find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.id) === id)) !== null && _a !== void 0 ? _a : undefined
|
|
32
31
|
: undefined;
|
|
33
32
|
}, [primaryWallet, secondaryWallets]);
|
|
34
|
-
const isConnectOnlyAndCallbackIsConnectSuccess = React.useCallback((next) => isConnectOnly.isConnectOnly(user, authMode) &&
|
|
35
|
-
Boolean(primaryWallet) &&
|
|
36
|
-
next === 'connectSuccess', [authMode, user, primaryWallet]);
|
|
37
|
-
const handleConnectOnlyAndCallbackIsConnectSuccess = React.useCallback(() => {
|
|
38
|
-
const [{ callback: peek, params }] = callbackQueue;
|
|
39
|
-
// we need to handle connect-only different way
|
|
40
|
-
// for connect-only we don't have user object or JWT (needed in connect-and-sign)
|
|
41
|
-
// so we need to handle connect-only before the early returns
|
|
42
|
-
if (isConnectOnlyAndCallbackIsConnectSuccess(peek)) {
|
|
43
|
-
const updatedQueue = [...callbackQueue];
|
|
44
|
-
updatedQueue.shift();
|
|
45
|
-
setCallbackQueue(updatedQueue);
|
|
46
|
-
try {
|
|
47
|
-
setIsVerificationInProgress(false);
|
|
48
|
-
const wallet = getWallet(params === null || params === void 0 ? void 0 : params.walletId);
|
|
49
|
-
onConnect === null || onConnect === void 0 ? void 0 : onConnect({
|
|
50
|
-
wallet,
|
|
51
|
-
walletConnector: wallet === null || wallet === void 0 ? void 0 : wallet.connector,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
logger.logger.error('Error calling onConnect: ', e);
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
}, [
|
|
61
|
-
callbackQueue,
|
|
62
|
-
getWallet,
|
|
63
|
-
isConnectOnlyAndCallbackIsConnectSuccess,
|
|
64
|
-
onConnect,
|
|
65
|
-
setIsVerificationInProgress,
|
|
66
|
-
]);
|
|
67
33
|
const handleNextCallback = React.useCallback((next, authToken, user) => {
|
|
68
34
|
var _a, _b;
|
|
69
35
|
switch (next === null || next === void 0 ? void 0 : next.callback) {
|
|
@@ -129,32 +95,20 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
129
95
|
setIsVerificationInProgress,
|
|
130
96
|
]);
|
|
131
97
|
React.useEffect(() => {
|
|
132
|
-
if (!callbackQueue.length)
|
|
133
|
-
return;
|
|
134
|
-
if (!handleConnectOnlyAndCallbackIsConnectSuccess())
|
|
135
|
-
return;
|
|
136
|
-
if (!user)
|
|
98
|
+
if (!callbackQueue.length || !user)
|
|
137
99
|
return;
|
|
138
100
|
const authToken = getAuthToken.getAuthToken();
|
|
139
|
-
if (!authToken)
|
|
140
|
-
return;
|
|
141
101
|
// checks if user logged in with a wallet, so we need to wait
|
|
142
102
|
// for the primary wallet state to be set
|
|
143
103
|
// if user logged in with email without embedded wallet, then
|
|
144
104
|
// there is no wallet so we can go ahead and run the callback
|
|
145
|
-
if (user.isAuthenticatedWithAWallet && !primaryWallet) {
|
|
105
|
+
if (!authToken || (user.isAuthenticatedWithAWallet && !primaryWallet)) {
|
|
146
106
|
return;
|
|
147
107
|
}
|
|
148
108
|
const updatedQueue = [...callbackQueue];
|
|
149
109
|
handleNextCallback(updatedQueue.shift(), authToken, user);
|
|
150
110
|
setCallbackQueue(updatedQueue);
|
|
151
|
-
}, [
|
|
152
|
-
callbackQueue,
|
|
153
|
-
handleConnectOnlyAndCallbackIsConnectSuccess,
|
|
154
|
-
handleNextCallback,
|
|
155
|
-
primaryWallet,
|
|
156
|
-
user,
|
|
157
|
-
]);
|
|
111
|
+
}, [callbackQueue, handleNextCallback, primaryWallet, user]);
|
|
158
112
|
const setCallback = (callback, params) => {
|
|
159
113
|
setCallbackQueue((prev) => [...prev, { callback, params }]);
|
|
160
114
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SetCallbackType, UseCustomerCallbacksArgs } from './types';
|
|
2
|
-
export declare const useCustomerCallbacks: ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate,
|
|
2
|
+
export declare const useCustomerCallbacks: ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onEmbeddedWalletCreated, }, handleLogOut, primaryWallet, secondaryWallets, user, isAuthenticated, setIsVerificationInProgress, }: UseCustomerCallbacksArgs) => {
|
|
3
3
|
setCallback: SetCallbackType;
|
|
4
4
|
};
|
|
@@ -16,9 +16,8 @@ import '../../../../../_virtual/_tslib.js';
|
|
|
16
16
|
import '@dynamic-labs/multi-wallet';
|
|
17
17
|
import { getAuthToken } from '../../../utils/functions/getAuthToken/getAuthToken.js';
|
|
18
18
|
import 'viem/chains';
|
|
19
|
-
import { isConnectOnly } from '../../../utils/hooks/authenticationHooks/helpers/isConnectOnly.js';
|
|
20
19
|
|
|
21
|
-
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate,
|
|
20
|
+
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onEmbeddedWalletCreated, }, handleLogOut, primaryWallet, secondaryWallets, user, isAuthenticated, setIsVerificationInProgress, }) => {
|
|
22
21
|
const [callbackQueue, setCallbackQueue] = useState([]);
|
|
23
22
|
/** Gets the wallet from its id */
|
|
24
23
|
const getWallet = useCallback((id) => {
|
|
@@ -27,39 +26,6 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
27
26
|
? (_a = [primaryWallet, ...secondaryWallets].find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.id) === id)) !== null && _a !== void 0 ? _a : undefined
|
|
28
27
|
: undefined;
|
|
29
28
|
}, [primaryWallet, secondaryWallets]);
|
|
30
|
-
const isConnectOnlyAndCallbackIsConnectSuccess = useCallback((next) => isConnectOnly(user, authMode) &&
|
|
31
|
-
Boolean(primaryWallet) &&
|
|
32
|
-
next === 'connectSuccess', [authMode, user, primaryWallet]);
|
|
33
|
-
const handleConnectOnlyAndCallbackIsConnectSuccess = useCallback(() => {
|
|
34
|
-
const [{ callback: peek, params }] = callbackQueue;
|
|
35
|
-
// we need to handle connect-only different way
|
|
36
|
-
// for connect-only we don't have user object or JWT (needed in connect-and-sign)
|
|
37
|
-
// so we need to handle connect-only before the early returns
|
|
38
|
-
if (isConnectOnlyAndCallbackIsConnectSuccess(peek)) {
|
|
39
|
-
const updatedQueue = [...callbackQueue];
|
|
40
|
-
updatedQueue.shift();
|
|
41
|
-
setCallbackQueue(updatedQueue);
|
|
42
|
-
try {
|
|
43
|
-
setIsVerificationInProgress(false);
|
|
44
|
-
const wallet = getWallet(params === null || params === void 0 ? void 0 : params.walletId);
|
|
45
|
-
onConnect === null || onConnect === void 0 ? void 0 : onConnect({
|
|
46
|
-
wallet,
|
|
47
|
-
walletConnector: wallet === null || wallet === void 0 ? void 0 : wallet.connector,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
logger.error('Error calling onConnect: ', e);
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}, [
|
|
57
|
-
callbackQueue,
|
|
58
|
-
getWallet,
|
|
59
|
-
isConnectOnlyAndCallbackIsConnectSuccess,
|
|
60
|
-
onConnect,
|
|
61
|
-
setIsVerificationInProgress,
|
|
62
|
-
]);
|
|
63
29
|
const handleNextCallback = useCallback((next, authToken, user) => {
|
|
64
30
|
var _a, _b;
|
|
65
31
|
switch (next === null || next === void 0 ? void 0 : next.callback) {
|
|
@@ -125,32 +91,20 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
125
91
|
setIsVerificationInProgress,
|
|
126
92
|
]);
|
|
127
93
|
useEffect(() => {
|
|
128
|
-
if (!callbackQueue.length)
|
|
129
|
-
return;
|
|
130
|
-
if (!handleConnectOnlyAndCallbackIsConnectSuccess())
|
|
131
|
-
return;
|
|
132
|
-
if (!user)
|
|
94
|
+
if (!callbackQueue.length || !user)
|
|
133
95
|
return;
|
|
134
96
|
const authToken = getAuthToken();
|
|
135
|
-
if (!authToken)
|
|
136
|
-
return;
|
|
137
97
|
// checks if user logged in with a wallet, so we need to wait
|
|
138
98
|
// for the primary wallet state to be set
|
|
139
99
|
// if user logged in with email without embedded wallet, then
|
|
140
100
|
// there is no wallet so we can go ahead and run the callback
|
|
141
|
-
if (user.isAuthenticatedWithAWallet && !primaryWallet) {
|
|
101
|
+
if (!authToken || (user.isAuthenticatedWithAWallet && !primaryWallet)) {
|
|
142
102
|
return;
|
|
143
103
|
}
|
|
144
104
|
const updatedQueue = [...callbackQueue];
|
|
145
105
|
handleNextCallback(updatedQueue.shift(), authToken, user);
|
|
146
106
|
setCallbackQueue(updatedQueue);
|
|
147
|
-
}, [
|
|
148
|
-
callbackQueue,
|
|
149
|
-
handleConnectOnlyAndCallbackIsConnectSuccess,
|
|
150
|
-
handleNextCallback,
|
|
151
|
-
primaryWallet,
|
|
152
|
-
user,
|
|
153
|
-
]);
|
|
107
|
+
}, [callbackQueue, handleNextCallback, primaryWallet, user]);
|
|
154
108
|
const setCallback = (callback, params) => {
|
|
155
109
|
setCallbackQueue((prev) => [...prev, { callback, params }]);
|
|
156
110
|
};
|
|
@@ -15,6 +15,8 @@ export type DynamicEvents = {
|
|
|
15
15
|
embeddedWalletRevealCompleted: (wallet: Wallet) => void;
|
|
16
16
|
embeddedWalletRevealFailed: (error: unknown) => void;
|
|
17
17
|
logout: () => void;
|
|
18
|
+
/** Triggered when a new wallet is connected in connect-only mode */
|
|
19
|
+
walletConnected: (wallet: Wallet) => void;
|
|
18
20
|
/** This event is used to trigger logout to be called, DO NOT listen to it. Listen to "logout" instead */
|
|
19
21
|
triggerLogout: () => void;
|
|
20
22
|
};
|
|
@@ -24,7 +24,6 @@ require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
|
24
24
|
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
26
26
|
var isMagicConnector = require('../../utils/functions/isMagicConnector/isMagicConnector.cjs');
|
|
27
|
-
var sendTransactionWithAutoNonce = require('../../utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs');
|
|
28
27
|
require('viem/chains');
|
|
29
28
|
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
30
29
|
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -96,7 +95,7 @@ const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionR
|
|
|
96
95
|
}, [onTransactionResponseSuccess, onReject]);
|
|
97
96
|
return (jsxRuntime.jsx(Portal.Portal, { handleClose: closeModal, isShown: show, zIndex: index.authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-transaction', transitionEvents: {
|
|
98
97
|
onUnmount: handleOnModalUnmount,
|
|
99
|
-
}, children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { provider: provider, transaction: transactionWithGasPrice, title: title, copykey: copykey, mutation: () =>
|
|
98
|
+
}, children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { provider: provider, transaction: transactionWithGasPrice, title: title, copykey: copykey, mutation: () => handler(transactionWithGasPrice), onClickClose: closeModal, onError: (error) => (errorRef.current = error), displayPoweredByDynamicFooter: true, onSuccess: (transactionResponse) => {
|
|
100
99
|
errorRef.current = null;
|
|
101
100
|
transactionResponseRef.current = transactionResponse;
|
|
102
101
|
closeModal();
|
|
@@ -20,7 +20,6 @@ import '../../context/CaptchaContext/CaptchaContext.js';
|
|
|
20
20
|
import '../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import '@dynamic-labs/multi-wallet';
|
|
22
22
|
import { isMagicConnector } from '../../utils/functions/isMagicConnector/isMagicConnector.js';
|
|
23
|
-
import { sendTransactionWithAutoNonce } from '../../utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js';
|
|
24
23
|
import 'viem/chains';
|
|
25
24
|
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
26
25
|
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -92,7 +91,7 @@ const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionR
|
|
|
92
91
|
}, [onTransactionResponseSuccess, onReject]);
|
|
93
92
|
return (jsx(Portal, { handleClose: closeModal, isShown: show, zIndex: authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-transaction', transitionEvents: {
|
|
94
93
|
onUnmount: handleOnModalUnmount,
|
|
95
|
-
}, children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(TransactionConfirmationView, { provider: provider, transaction: transactionWithGasPrice, title: title, copykey: copykey, mutation: () =>
|
|
94
|
+
}, children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(TransactionConfirmationView, { provider: provider, transaction: transactionWithGasPrice, title: title, copykey: copykey, mutation: () => handler(transactionWithGasPrice), onClickClose: closeModal, onError: (error) => (errorRef.current = error), displayPoweredByDynamicFooter: true, onSuccess: (transactionResponse) => {
|
|
96
95
|
errorRef.current = null;
|
|
97
96
|
transactionResponseRef.current = transactionResponse;
|
|
98
97
|
closeModal();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { providerLabel } from './providerLabel';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var sdkApi = require('@dynamic-labs/sdk-api');
|
|
6
|
+
var capitalize = require('../capitalize/capitalize.cjs');
|
|
7
|
+
|
|
8
|
+
const providerLabel = (provider) => {
|
|
9
|
+
if (provider === sdkApi.SocialSignInProviderEnum.Coinbasesocial) {
|
|
10
|
+
return 'Coinbase';
|
|
11
|
+
}
|
|
12
|
+
return capitalize.capitalize(provider);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.providerLabel = providerLabel;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SocialSignInProviderEnum } from '@dynamic-labs/sdk-api';
|
|
2
|
+
import { capitalize } from '../capitalize/capitalize.js';
|
|
3
|
+
|
|
4
|
+
const providerLabel = (provider) => {
|
|
5
|
+
if (provider === SocialSignInProviderEnum.Coinbasesocial) {
|
|
6
|
+
return 'Coinbase';
|
|
7
|
+
}
|
|
8
|
+
return capitalize(provider);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { providerLabel };
|