@dynamic-labs/sdk-react-core 4.9.2-preview.0 → 4.9.3
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 +28 -1
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -2
- package/src/index.js +2 -2
- package/src/lib/components/Portal/ModalComponent/ModalComponent.cjs +32 -0
- package/src/lib/components/Portal/ModalComponent/ModalComponent.d.ts +9 -0
- package/src/lib/components/Portal/ModalComponent/ModalComponent.js +24 -0
- package/src/lib/components/Portal/ModalComponent/index.d.ts +1 -0
- package/src/lib/components/Portal/Portal.cjs +3 -119
- package/src/lib/components/Portal/Portal.d.ts +3 -8
- package/src/lib/components/Portal/Portal.js +3 -115
- package/src/lib/components/TosAndPp/TosAndPp.cjs +3 -1
- package/src/lib/components/TosAndPp/TosAndPp.js +3 -1
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.cjs +1 -1
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.js +1 -1
- package/src/lib/components/TransactionCard/TransactionCard.cjs +1 -1
- package/src/lib/components/TransactionCard/TransactionCard.js +1 -1
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.cjs +10 -2
- package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.js +10 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +13 -9
- package/src/lib/context/DynamicContext/DynamicContext.js +15 -11
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +0 -12
- package/src/lib/context/DynamicContext/helpers/helpers.d.ts +1 -9
- package/src/lib/context/DynamicContext/helpers/helpers.js +1 -12
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.cjs +18 -0
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.d.ts +10 -0
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.js +14 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +1 -1
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +6 -2
- package/src/lib/context/ErrorContext/hooks/useErrorText/useErrorText.cjs +1 -0
- package/src/lib/context/ErrorContext/hooks/useErrorText/useErrorText.js +1 -0
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +1 -0
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -0
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
- package/src/lib/context/ViewContext/ViewContext.cjs +1 -1
- package/src/lib/context/ViewContext/ViewContext.js +1 -1
- package/src/lib/locale/en/translation.cjs +3 -2
- package/src/lib/locale/en/translation.d.ts +2 -1
- package/src/lib/locale/en/translation.js +3 -2
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/authViewLayoutChecks.cjs +135 -0
- package/src/lib/utils/constants/authViewLayoutChecks.d.ts +21 -0
- package/src/lib/utils/constants/authViewLayoutChecks.js +123 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.cjs +36 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.d.ts +11 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.js +32 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +20 -93
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +19 -92
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +7 -4
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +5 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +7 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +8 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +8 -8
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +2 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +2 -1
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +3 -2
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +3 -2
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs +1 -3
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.d.ts +1 -2
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js +1 -3
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.cjs +3 -5
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.d.ts +1 -2
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.js +3 -5
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +37 -0
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.d.ts +9 -0
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +33 -0
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/index.d.ts +1 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +2 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +2 -0
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +4 -1
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +4 -1
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +1 -4
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +1 -4
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +4 -10
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +4 -10
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +7 -5
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +7 -5
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +164 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.d.ts +3 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +160 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +11 -50
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +11 -50
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.d.ts +2 -1
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +2 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +4 -4
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +4 -4
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.js +1 -1
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.cjs +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.js +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/index.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.cjs +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.js +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/index.d.ts +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { getUser } from '../../../../store/state/user/user.js';
|
|
4
|
+
import '@dynamic-labs/utils';
|
|
5
|
+
import '../../../constants/values.js';
|
|
6
|
+
import '@dynamic-labs/sdk-api-core';
|
|
7
|
+
import '../../../../store/state/projectSettings/projectSettings.js';
|
|
8
|
+
import { getPrimaryWalletId } from '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
9
|
+
import { getConnectedWalletsInfo } from '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Detects mismatch between wallet info.
|
|
13
|
+
* If there is primary wallet id, but no user or connected wallets info,
|
|
14
|
+
* it means it's in a bad state and we should log out.
|
|
15
|
+
*/
|
|
16
|
+
const handleWalletInfoOutOfSync = (_a) => __awaiter(void 0, [_a], void 0, function* ({ logout, }) {
|
|
17
|
+
const primaryWalletId = getPrimaryWalletId();
|
|
18
|
+
if (!primaryWalletId) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const user = getUser();
|
|
22
|
+
const connectedWallets = getConnectedWalletsInfo();
|
|
23
|
+
if (user || connectedWallets.length > 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
yield logout('wallet info is out of sync', {
|
|
27
|
+
connectedWallets,
|
|
28
|
+
primaryWalletId,
|
|
29
|
+
user,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { handleWalletInfoOutOfSync };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './handleWalletInfoOutOfSync';
|
|
@@ -11,6 +11,7 @@ var useDynamicEvents = require('../events/useDynamicEvents/useDynamicEvents.cjs'
|
|
|
11
11
|
var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
12
12
|
var handleStoreAndEnvironmentMismatch = require('./handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs');
|
|
13
13
|
var handleUserDataOutOfSync = require('./handleUserDataOutOfSync/handleUserDataOutOfSync.cjs');
|
|
14
|
+
var handleWalletInfoOutOfSync = require('./handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs');
|
|
14
15
|
|
|
15
16
|
const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
16
17
|
const didRunRef = React.useRef(false);
|
|
@@ -30,6 +31,7 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
30
31
|
yield Promise.all([
|
|
31
32
|
handleStoreAndEnvironmentMismatch.handleStoreAndEnvironmentMismatch(params),
|
|
32
33
|
handleUserDataOutOfSync.handleUserDataOutOfSync(params),
|
|
34
|
+
handleWalletInfoOutOfSync.handleWalletInfoOutOfSync(params),
|
|
33
35
|
]);
|
|
34
36
|
// Regardless of whether we logged out or not, session validation is now complete
|
|
35
37
|
loadingAndLifecycle.setLoadingAndLifecycle({ sessionValidation: true });
|
|
@@ -7,6 +7,7 @@ import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicE
|
|
|
7
7
|
import { useProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
|
|
8
8
|
import { handleStoreAndEnvironmentMismatch } from './handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js';
|
|
9
9
|
import { handleUserDataOutOfSync } from './handleUserDataOutOfSync/handleUserDataOutOfSync.js';
|
|
10
|
+
import { handleWalletInfoOutOfSync } from './handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js';
|
|
10
11
|
|
|
11
12
|
const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
12
13
|
const didRunRef = useRef(false);
|
|
@@ -26,6 +27,7 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
26
27
|
yield Promise.all([
|
|
27
28
|
handleStoreAndEnvironmentMismatch(params),
|
|
28
29
|
handleUserDataOutOfSync(params),
|
|
30
|
+
handleWalletInfoOutOfSync(params),
|
|
29
31
|
]);
|
|
30
32
|
// Regardless of whether we logged out or not, session validation is now complete
|
|
31
33
|
setLoadingAndLifecycle({ sessionValidation: true });
|
|
@@ -71,8 +71,8 @@ require('../../store/state/loadingAndLifecycle.cjs');
|
|
|
71
71
|
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
72
72
|
require('../../store/state/walletOptions/walletOptions.cjs');
|
|
73
73
|
var Typography = require('../../components/Typography/Typography.cjs');
|
|
74
|
-
var useIsTurnkeyWallet = require('../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
75
74
|
require('../../context/FooterAnimationContext/index.cjs');
|
|
75
|
+
var useIsTurnkeyWallet = require('../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
76
76
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
77
77
|
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
78
78
|
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
@@ -67,8 +67,8 @@ import '../../store/state/loadingAndLifecycle.js';
|
|
|
67
67
|
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
68
68
|
import '../../store/state/walletOptions/walletOptions.js';
|
|
69
69
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
70
|
-
import { useIsTurnkeyWallet } from '../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
71
70
|
import '../../context/FooterAnimationContext/index.js';
|
|
71
|
+
import { useIsTurnkeyWallet } from '../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
72
72
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
73
73
|
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
74
74
|
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
@@ -113,7 +113,10 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, }) => {
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
if (isInitialSetup) {
|
|
116
|
-
pushView('mfa-secure-device', {
|
|
116
|
+
pushView('mfa-secure-device', {
|
|
117
|
+
isInitialSetup: true,
|
|
118
|
+
type: option.type,
|
|
119
|
+
});
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
119
122
|
pushView('mfa-verification', {
|
|
@@ -109,7 +109,10 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, }) => {
|
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
if (isInitialSetup) {
|
|
112
|
-
pushView('mfa-secure-device', {
|
|
112
|
+
pushView('mfa-secure-device', {
|
|
113
|
+
isInitialSetup: true,
|
|
114
|
+
type: option.type,
|
|
115
|
+
});
|
|
113
116
|
return;
|
|
114
117
|
}
|
|
115
118
|
pushView('mfa-verification', {
|
|
@@ -117,13 +117,10 @@ const MfaSecureDeviceView = ({ type, isInitialSetup = false, }) => {
|
|
|
117
117
|
});
|
|
118
118
|
};
|
|
119
119
|
const onHelpClick = ({ secret, uri }) => {
|
|
120
|
-
const onMfaSecureDeviceHelpBackClick = () => {
|
|
121
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
122
|
-
};
|
|
123
120
|
pushView('mfa-secure-device-help', {
|
|
124
121
|
secret,
|
|
125
122
|
uri,
|
|
126
|
-
}
|
|
123
|
+
});
|
|
127
124
|
};
|
|
128
125
|
return (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsxRuntime.jsx(spinner.Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsxRuntime.jsx(QRCode.QRCode, { Icon: jsxRuntime.jsx(passwordHero.ReactComponent, {}), value: data.uri, logoSize: 50 }), jsxRuntime.jsx("div", { className: 'button-container', children: jsxRuntime.jsx("button", { onClick: () => onHelpClick({ secret: data.secret, uri: data.uri }), children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'medium', color: 'secondary', children: t('dyn_mfa.secure_device_view.helper.button') }) }) })] })), jsxRuntime.jsx(TypographyButton.TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') }), jsxRuntime.jsx(TextButton.TextButton, { className: 'mfa-secure-device-view__logout-button', onClick: handleLogOut, copykey: 'dyn_mfa.choose_device_view.logout', children: t('dyn_mfa.secure_device_view.logout') })] }));
|
|
129
126
|
};
|
|
@@ -113,13 +113,10 @@ const MfaSecureDeviceView = ({ type, isInitialSetup = false, }) => {
|
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
115
|
const onHelpClick = ({ secret, uri }) => {
|
|
116
|
-
const onMfaSecureDeviceHelpBackClick = () => {
|
|
117
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
118
|
-
};
|
|
119
116
|
pushView('mfa-secure-device-help', {
|
|
120
117
|
secret,
|
|
121
118
|
uri,
|
|
122
|
-
}
|
|
119
|
+
});
|
|
123
120
|
};
|
|
124
121
|
return (jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsx(Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsx(Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsx(QRCode, { Icon: jsx(SvgPasswordHero, {}), value: data.uri, logoSize: 50 }), jsx("div", { className: 'button-container', children: jsx("button", { onClick: () => onHelpClick({ secret: data.secret, uri: data.uri }), children: jsx(Typography, { variant: 'body_small', weight: 'medium', color: 'secondary', children: t('dyn_mfa.secure_device_view.helper.button') }) }) })] })), jsx(TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') }), jsx(TextButton, { className: 'mfa-secure-device-view__logout-button', onClick: handleLogOut, copykey: 'dyn_mfa.choose_device_view.logout', children: t('dyn_mfa.secure_device_view.logout') })] }));
|
|
125
122
|
};
|
|
@@ -101,7 +101,7 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
101
101
|
|
|
102
102
|
const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = false, deviceId, }) => {
|
|
103
103
|
const { t } = reactI18next.useTranslation();
|
|
104
|
-
const { pushView } = ViewContext.useViewContext();
|
|
104
|
+
const { clearStackAndPush, pushView, goBack, canGoBack } = ViewContext.useViewContext();
|
|
105
105
|
const { authDevice } = useMfa.useMfa();
|
|
106
106
|
const [code, setCode] = React.useState('');
|
|
107
107
|
const [error, setError] = React.useState();
|
|
@@ -123,7 +123,7 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
123
123
|
const user$1 = user.getUser();
|
|
124
124
|
if ((user$1 === null || user$1 === void 0 ? void 0 : user$1.mfaBackupCodeAcknowledgement) !==
|
|
125
125
|
sdkApiCore.MfaBackupCodeAcknowledgement.Complete) {
|
|
126
|
-
|
|
126
|
+
clearStackAndPush('mfa-display-backup-codes');
|
|
127
127
|
}
|
|
128
128
|
}),
|
|
129
129
|
});
|
|
@@ -134,14 +134,8 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
134
134
|
const onSubmit = (code) => {
|
|
135
135
|
setCode(code);
|
|
136
136
|
};
|
|
137
|
-
const onClickBack =
|
|
138
|
-
|
|
139
|
-
pushView('mfa-choose-device', { isInitialSetup });
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
143
|
-
};
|
|
144
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { MainIcon: passwordHero.ReactComponent, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: showBackButton ? onClickBack : undefined, disabled: isRateLimited }), !isInitialSetup && (jsxRuntime.jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsxRuntime.jsx(TextButton.TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
137
|
+
const onClickBack = canGoBack && showBackButton ? goBack : undefined;
|
|
138
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { MainIcon: passwordHero.ReactComponent, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: onClickBack, disabled: isRateLimited }), !isInitialSetup && (jsxRuntime.jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsxRuntime.jsx(TextButton.TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
145
139
|
};
|
|
146
140
|
|
|
147
141
|
exports.MfaVerificationView = MfaVerificationView;
|
|
@@ -97,7 +97,7 @@ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
97
97
|
|
|
98
98
|
const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = false, deviceId, }) => {
|
|
99
99
|
const { t } = useTranslation();
|
|
100
|
-
const { pushView } = useViewContext();
|
|
100
|
+
const { clearStackAndPush, pushView, goBack, canGoBack } = useViewContext();
|
|
101
101
|
const { authDevice } = useMfa();
|
|
102
102
|
const [code, setCode] = useState('');
|
|
103
103
|
const [error, setError] = useState();
|
|
@@ -119,7 +119,7 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
119
119
|
const user = getUser();
|
|
120
120
|
if ((user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) !==
|
|
121
121
|
MfaBackupCodeAcknowledgement.Complete) {
|
|
122
|
-
|
|
122
|
+
clearStackAndPush('mfa-display-backup-codes');
|
|
123
123
|
}
|
|
124
124
|
}),
|
|
125
125
|
});
|
|
@@ -130,14 +130,8 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
130
130
|
const onSubmit = (code) => {
|
|
131
131
|
setCode(code);
|
|
132
132
|
};
|
|
133
|
-
const onClickBack =
|
|
134
|
-
|
|
135
|
-
pushView('mfa-choose-device', { isInitialSetup });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
139
|
-
};
|
|
140
|
-
return (jsxs(Fragment, { children: [jsx(OTPVerificationView, { MainIcon: SvgPasswordHero, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: showBackButton ? onClickBack : undefined, disabled: isRateLimited }), !isInitialSetup && (jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsx(TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
133
|
+
const onClickBack = canGoBack && showBackButton ? goBack : undefined;
|
|
134
|
+
return (jsxs(Fragment, { children: [jsx(OTPVerificationView, { MainIcon: SvgPasswordHero, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: onClickBack, disabled: isRateLimited }), !isInitialSetup && (jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsx(TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
141
135
|
};
|
|
142
136
|
|
|
143
137
|
export { MfaVerificationView };
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs
CHANGED
|
@@ -102,12 +102,14 @@ var SandboxIndicatorWrapper = require('../../../components/SandboxIndicatorWrapp
|
|
|
102
102
|
|
|
103
103
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
104
104
|
const hide = useIsLoggedIn.useIsLoggedIn();
|
|
105
|
-
const { projectSettings,
|
|
106
|
-
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
105
|
+
const { projectSettings, setIsRenderingEmbeddedAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
107
106
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
108
|
-
React.useEffect(() =>
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
setIsRenderingEmbeddedAuthFlow(!hide);
|
|
109
|
+
return () => {
|
|
110
|
+
setIsRenderingEmbeddedAuthFlow(false);
|
|
111
|
+
};
|
|
112
|
+
}, [setIsRenderingEmbeddedAuthFlow, hide]);
|
|
111
113
|
if (hide)
|
|
112
114
|
return null;
|
|
113
115
|
const content = (jsxRuntime.jsx(DynamicAuthLayout.DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsxRuntime.jsx(RenderView.RenderView, {}) }));
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js
CHANGED
|
@@ -98,12 +98,14 @@ import { SandboxIndicatorWrapper } from '../../../components/SandboxIndicatorWra
|
|
|
98
98
|
|
|
99
99
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
100
100
|
const hide = useIsLoggedIn();
|
|
101
|
-
const { projectSettings,
|
|
102
|
-
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
101
|
+
const { projectSettings, setIsRenderingEmbeddedAuthFlow } = useInternalDynamicContext();
|
|
103
102
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
104
|
-
useEffect(() =>
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
setIsRenderingEmbeddedAuthFlow(!hide);
|
|
105
|
+
return () => {
|
|
106
|
+
setIsRenderingEmbeddedAuthFlow(false);
|
|
107
|
+
};
|
|
108
|
+
}, [setIsRenderingEmbeddedAuthFlow, hide]);
|
|
107
109
|
if (hide)
|
|
108
110
|
return null;
|
|
109
111
|
const content = (jsx(DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsx(RenderView, {}) }));
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var reactI18next = require('react-i18next');
|
|
9
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
10
|
+
require('@dynamic-labs/sdk-api-core');
|
|
11
|
+
require('../../../../shared/logger.cjs');
|
|
12
|
+
require('@dynamic-labs/iconic');
|
|
13
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
14
|
+
var chevronDown = require('../../../../shared/assets/chevron-down.cjs');
|
|
15
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
16
|
+
require('@dynamic-labs/wallet-book');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('../../../../utils/constants/colors.cjs');
|
|
19
|
+
require('../../../../utils/constants/values.cjs');
|
|
20
|
+
require('../../../../shared/consts/index.cjs');
|
|
21
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
22
|
+
require('../../../../../../_virtual/_tslib.cjs');
|
|
23
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
|
+
require('@dynamic-labs/multi-wallet');
|
|
26
|
+
require('react-international-phone');
|
|
27
|
+
require('../../../../store/state/nonce/nonce.cjs');
|
|
28
|
+
var projectSettings = require('../../../../store/state/projectSettings/projectSettings.cjs');
|
|
29
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
30
|
+
require('../../../../store/state/user/user.cjs');
|
|
31
|
+
require('../../../../locale/locale.cjs');
|
|
32
|
+
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
33
|
+
require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
34
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
35
|
+
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
36
|
+
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
37
|
+
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
38
|
+
require('../../../../context/VerificationContext/VerificationContext.cjs');
|
|
39
|
+
require('react-dom');
|
|
40
|
+
require('../../../../utils/functions/compareChains/compareChains.cjs');
|
|
41
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
42
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
43
|
+
require('bs58');
|
|
44
|
+
require('@dynamic-labs/types');
|
|
45
|
+
require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
46
|
+
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
47
|
+
require('../../../../context/WalletContext/WalletContext.cjs');
|
|
48
|
+
require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
49
|
+
require('yup');
|
|
50
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
51
|
+
require('../../../../views/CollectUserDataView/useFields.cjs');
|
|
52
|
+
require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
53
|
+
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
54
|
+
require('@dynamic-labs/rpc-providers');
|
|
55
|
+
require('../../../../store/state/loadingAndLifecycle.cjs');
|
|
56
|
+
require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
57
|
+
var AccordionItem = require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
58
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
59
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
60
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
61
|
+
require('../../../../components/IconButton/IconButton.cjs');
|
|
62
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
63
|
+
require('../../../../components/Input/Input.cjs');
|
|
64
|
+
require('../../../../components/IsBrowser/IsBrowser.cjs');
|
|
65
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
66
|
+
require('../../../../components/OverlayCard/OverlayCard.cjs');
|
|
67
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
68
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
69
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
70
|
+
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
71
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
72
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
73
|
+
require('react-focus-lock');
|
|
74
|
+
require('qrcode');
|
|
75
|
+
require('formik');
|
|
76
|
+
require('../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
77
|
+
var Skeleton = require('../../../../components/Skeleton/Skeleton.cjs');
|
|
78
|
+
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
79
|
+
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
80
|
+
require('../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
81
|
+
require('../../../../context/ConnectWithOtpContext/constants.cjs');
|
|
82
|
+
require('../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
83
|
+
var Balance = require('../Balance/Balance.cjs');
|
|
84
|
+
require('@hcaptcha/react-hcaptcha');
|
|
85
|
+
require('../../context/DynamicWidgetContext.cjs');
|
|
86
|
+
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
87
|
+
require('../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
88
|
+
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
89
|
+
require('../../../../store/state/sendBalances.cjs');
|
|
90
|
+
require('../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
91
|
+
require('../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
92
|
+
require('../DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
93
|
+
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
94
|
+
require('../../views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
95
|
+
require('../../../../context/OnrampContext/OnrampContext.cjs');
|
|
96
|
+
require('../../views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
97
|
+
require('../../../../../index.cjs');
|
|
98
|
+
var useTokenBalances = require('../../../../utils/hooks/useTokenBalances/useTokenBalances.cjs');
|
|
99
|
+
require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
100
|
+
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
101
|
+
var isMultiAssetSupportedNetwork = require('../../../../utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.cjs');
|
|
102
|
+
var TokenBalanceList = require('./TokenBalanceList/TokenBalanceList.cjs');
|
|
103
|
+
|
|
104
|
+
/** Component to display token balances for the primary wallet */
|
|
105
|
+
const ActiveWalletBalance = () => {
|
|
106
|
+
var _a;
|
|
107
|
+
const { t } = reactI18next.useTranslation();
|
|
108
|
+
/** Controls for the multi asset balance accordion */
|
|
109
|
+
const [balanceIsExpanded, setBalanceIsExpanded] = React.useState(false);
|
|
110
|
+
/** Controls for the shadow on scroll of the multi asset balance section */
|
|
111
|
+
const [hasShadow, setHasShadow] = React.useState(false);
|
|
112
|
+
const contentRef = React.useRef(null);
|
|
113
|
+
const { primaryWallet, network, authMode, showFiat, multiAsset } = useInternalDynamicContext.useInternalDynamicContext();
|
|
114
|
+
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
115
|
+
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, } = useTokenBalances.useTokenBalances({
|
|
116
|
+
chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
|
|
117
|
+
includeFiat: showFiat,
|
|
118
|
+
includeNativeBalance: true,
|
|
119
|
+
});
|
|
120
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
121
|
+
const filteredTokenBalances = React.useMemo(() => {
|
|
122
|
+
const balances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [];
|
|
123
|
+
balances.sort((a, b) => ((b === null || b === void 0 ? void 0 : b.marketValue) || 0) - ((a === null || a === void 0 ? void 0 : a.marketValue) || 0));
|
|
124
|
+
return balances;
|
|
125
|
+
}, [tokenBalances]);
|
|
126
|
+
const totalValue = React.useMemo(() => filteredTokenBalances.reduce((acc, token) => acc + ((token === null || token === void 0 ? void 0 : token.marketValue) || 0), 0), [filteredTokenBalances]);
|
|
127
|
+
const enableMultiAsset = (authMode === 'connect-and-sign' ||
|
|
128
|
+
(authMode === 'connect-only' &&
|
|
129
|
+
((_a = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.featureFlags) === null || _a === void 0 ? void 0 : _a.connectOnlyMultiAsset))) &&
|
|
130
|
+
multiAsset;
|
|
131
|
+
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork.isMultiAssetSupportedNetwork(filteredTokenBalances, primaryConnector, network);
|
|
132
|
+
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
133
|
+
const showMultiAsset = !isTooManyRequests && isNetworkMultiAssetSupported && enableMultiAsset;
|
|
134
|
+
const currencyFormatter = new Intl.NumberFormat('en-US', {
|
|
135
|
+
currency: 'USD',
|
|
136
|
+
style: 'currency',
|
|
137
|
+
});
|
|
138
|
+
const handleScroll = () => {
|
|
139
|
+
if (contentRef.current) {
|
|
140
|
+
setHasShadow(contentRef.current.scrollTop > 0);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const primaryWalletNativeBalance = () => {
|
|
144
|
+
if (!primaryWallet || isLoadingTokenBalances) {
|
|
145
|
+
return jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-container__skeleton' });
|
|
146
|
+
}
|
|
147
|
+
return showFiat ? (jsxRuntime.jsx(Typography.Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
148
|
+
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
149
|
+
: '<$0.01' })) : (jsxRuntime.jsx(Balance.Balance, { className: 'balance-header__balance', wallet: primaryWallet, network: network, variant: 'numbers_display' }));
|
|
150
|
+
};
|
|
151
|
+
const balanceHeaderTitle = () => (jsxRuntime.jsxs("div", { className: 'balance-header__title', children: [jsxRuntime.jsx(Typography.Typography, { color: 'secondary', variant: 'body_normal', children: t('dyn_active_wallet_info.balance') }), jsxRuntime.jsx("div", { className: 'balance-header__balance', children: primaryWalletNativeBalance() })] }));
|
|
152
|
+
const toggleBalanceAccordion = React.useCallback(() => {
|
|
153
|
+
if (!isLoadingTokenBalances) {
|
|
154
|
+
setBalanceIsExpanded(!balanceIsExpanded);
|
|
155
|
+
}
|
|
156
|
+
}, [isLoadingTokenBalances, balanceIsExpanded]);
|
|
157
|
+
if (!showMultiAsset) {
|
|
158
|
+
return jsxRuntime.jsx("div", { className: 'balance-container', children: balanceHeaderTitle() });
|
|
159
|
+
}
|
|
160
|
+
return (jsxRuntime.jsx("div", { className: 'balance-container', children: jsxRuntime.jsxs("div", { className: 'multi-asset-balance-container', children: [jsxRuntime.jsx("div", { className: `${hasShadow ? 'shadow' : ''}`, children: jsxRuntime.jsxs("button", { onClick: toggleBalanceAccordion, className: 'balance-header', "data-testid": 'balance-header', children: [balanceHeaderTitle(), !isLoadingTokenBalances && (jsxRuntime.jsx("div", { className: balanceIsExpanded ? 'balance-header__chevron' : '', children: jsxRuntime.jsx(chevronDown.ReactComponent, {}) }))] }) }), jsxRuntime.jsx(AccordionItem.AccordionItem, { isOpen: balanceIsExpanded, className: `multi-asset-balance-container__accordion ${'multi-asset-balance-container__accordion' +
|
|
161
|
+
(balanceIsExpanded ? '--expanded' : '--collapsed')}`, handleScroll: handleScroll, ref: contentRef, dataTestId: 'multi-asset-balance-accordion', children: jsxRuntime.jsx(TokenBalanceList.TokenBalanceList, { tokenBalances: filteredTokenBalances }) })] }) }));
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
exports.ActiveWalletBalance = ActiveWalletBalance;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useRef, useMemo, useCallback } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
6
|
+
import '@dynamic-labs/sdk-api-core';
|
|
7
|
+
import '../../../../shared/logger.js';
|
|
8
|
+
import '@dynamic-labs/iconic';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import { ReactComponent as SvgChevronDown } from '../../../../shared/assets/chevron-down.js';
|
|
11
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../../../utils/constants/colors.js';
|
|
15
|
+
import '../../../../utils/constants/values.js';
|
|
16
|
+
import '../../../../shared/consts/index.js';
|
|
17
|
+
import '../../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../../../../_virtual/_tslib.js';
|
|
19
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
21
|
+
import '@dynamic-labs/multi-wallet';
|
|
22
|
+
import 'react-international-phone';
|
|
23
|
+
import '../../../../store/state/nonce/nonce.js';
|
|
24
|
+
import { useProjectSettings } from '../../../../store/state/projectSettings/projectSettings.js';
|
|
25
|
+
import '../../../../config/ApiEndpoint.js';
|
|
26
|
+
import '../../../../store/state/user/user.js';
|
|
27
|
+
import '../../../../locale/locale.js';
|
|
28
|
+
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
29
|
+
import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
30
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
|
+
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
|
+
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
33
|
+
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
34
|
+
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
35
|
+
import 'react-dom';
|
|
36
|
+
import '../../../../utils/functions/compareChains/compareChains.js';
|
|
37
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
38
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
39
|
+
import 'bs58';
|
|
40
|
+
import '@dynamic-labs/types';
|
|
41
|
+
import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
42
|
+
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
43
|
+
import '../../../../context/WalletContext/WalletContext.js';
|
|
44
|
+
import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
45
|
+
import 'yup';
|
|
46
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
47
|
+
import '../../../../views/CollectUserDataView/useFields.js';
|
|
48
|
+
import '../../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
49
|
+
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
50
|
+
import '@dynamic-labs/rpc-providers';
|
|
51
|
+
import '../../../../store/state/loadingAndLifecycle.js';
|
|
52
|
+
import '../../../../store/state/walletOptions/walletOptions.js';
|
|
53
|
+
import { AccordionItem } from '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
54
|
+
import '../../../../components/Alert/Alert.js';
|
|
55
|
+
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
56
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
57
|
+
import '../../../../components/IconButton/IconButton.js';
|
|
58
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
59
|
+
import '../../../../components/Input/Input.js';
|
|
60
|
+
import '../../../../components/IsBrowser/IsBrowser.js';
|
|
61
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
62
|
+
import '../../../../components/OverlayCard/OverlayCard.js';
|
|
63
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
64
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
65
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
66
|
+
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
67
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
68
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
69
|
+
import 'react-focus-lock';
|
|
70
|
+
import 'qrcode';
|
|
71
|
+
import 'formik';
|
|
72
|
+
import '../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
73
|
+
import { Skeleton } from '../../../../components/Skeleton/Skeleton.js';
|
|
74
|
+
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
75
|
+
import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
76
|
+
import '../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
77
|
+
import '../../../../context/ConnectWithOtpContext/constants.js';
|
|
78
|
+
import '../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
79
|
+
import { Balance } from '../Balance/Balance.js';
|
|
80
|
+
import '@hcaptcha/react-hcaptcha';
|
|
81
|
+
import '../../context/DynamicWidgetContext.js';
|
|
82
|
+
import '../../../../context/FooterAnimationContext/index.js';
|
|
83
|
+
import '../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
84
|
+
import '../../../../context/PasskeyContext/PasskeyContext.js';
|
|
85
|
+
import '../../../../store/state/sendBalances.js';
|
|
86
|
+
import '../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
87
|
+
import '../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
88
|
+
import '../DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
89
|
+
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
90
|
+
import '../../views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
91
|
+
import '../../../../context/OnrampContext/OnrampContext.js';
|
|
92
|
+
import '../../views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
93
|
+
import '../../../../../index.js';
|
|
94
|
+
import { useTokenBalances } from '../../../../utils/hooks/useTokenBalances/useTokenBalances.js';
|
|
95
|
+
import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
96
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
97
|
+
import { isMultiAssetSupportedNetwork } from '../../../../utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.js';
|
|
98
|
+
import { TokenBalanceList } from './TokenBalanceList/TokenBalanceList.js';
|
|
99
|
+
|
|
100
|
+
/** Component to display token balances for the primary wallet */
|
|
101
|
+
const ActiveWalletBalance = () => {
|
|
102
|
+
var _a;
|
|
103
|
+
const { t } = useTranslation();
|
|
104
|
+
/** Controls for the multi asset balance accordion */
|
|
105
|
+
const [balanceIsExpanded, setBalanceIsExpanded] = useState(false);
|
|
106
|
+
/** Controls for the shadow on scroll of the multi asset balance section */
|
|
107
|
+
const [hasShadow, setHasShadow] = useState(false);
|
|
108
|
+
const contentRef = useRef(null);
|
|
109
|
+
const { primaryWallet, network, authMode, showFiat, multiAsset } = useInternalDynamicContext();
|
|
110
|
+
const projectSettings = useProjectSettings();
|
|
111
|
+
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, } = useTokenBalances({
|
|
112
|
+
chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
|
|
113
|
+
includeFiat: showFiat,
|
|
114
|
+
includeNativeBalance: true,
|
|
115
|
+
});
|
|
116
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
117
|
+
const filteredTokenBalances = useMemo(() => {
|
|
118
|
+
const balances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [];
|
|
119
|
+
balances.sort((a, b) => ((b === null || b === void 0 ? void 0 : b.marketValue) || 0) - ((a === null || a === void 0 ? void 0 : a.marketValue) || 0));
|
|
120
|
+
return balances;
|
|
121
|
+
}, [tokenBalances]);
|
|
122
|
+
const totalValue = useMemo(() => filteredTokenBalances.reduce((acc, token) => acc + ((token === null || token === void 0 ? void 0 : token.marketValue) || 0), 0), [filteredTokenBalances]);
|
|
123
|
+
const enableMultiAsset = (authMode === 'connect-and-sign' ||
|
|
124
|
+
(authMode === 'connect-only' &&
|
|
125
|
+
((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _a === void 0 ? void 0 : _a.connectOnlyMultiAsset))) &&
|
|
126
|
+
multiAsset;
|
|
127
|
+
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork(filteredTokenBalances, primaryConnector, network);
|
|
128
|
+
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
129
|
+
const showMultiAsset = !isTooManyRequests && isNetworkMultiAssetSupported && enableMultiAsset;
|
|
130
|
+
const currencyFormatter = new Intl.NumberFormat('en-US', {
|
|
131
|
+
currency: 'USD',
|
|
132
|
+
style: 'currency',
|
|
133
|
+
});
|
|
134
|
+
const handleScroll = () => {
|
|
135
|
+
if (contentRef.current) {
|
|
136
|
+
setHasShadow(contentRef.current.scrollTop > 0);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const primaryWalletNativeBalance = () => {
|
|
140
|
+
if (!primaryWallet || isLoadingTokenBalances) {
|
|
141
|
+
return jsx(Skeleton, { className: 'balance-container__skeleton' });
|
|
142
|
+
}
|
|
143
|
+
return showFiat ? (jsx(Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
144
|
+
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
145
|
+
: '<$0.01' })) : (jsx(Balance, { className: 'balance-header__balance', wallet: primaryWallet, network: network, variant: 'numbers_display' }));
|
|
146
|
+
};
|
|
147
|
+
const balanceHeaderTitle = () => (jsxs("div", { className: 'balance-header__title', children: [jsx(Typography, { color: 'secondary', variant: 'body_normal', children: t('dyn_active_wallet_info.balance') }), jsx("div", { className: 'balance-header__balance', children: primaryWalletNativeBalance() })] }));
|
|
148
|
+
const toggleBalanceAccordion = useCallback(() => {
|
|
149
|
+
if (!isLoadingTokenBalances) {
|
|
150
|
+
setBalanceIsExpanded(!balanceIsExpanded);
|
|
151
|
+
}
|
|
152
|
+
}, [isLoadingTokenBalances, balanceIsExpanded]);
|
|
153
|
+
if (!showMultiAsset) {
|
|
154
|
+
return jsx("div", { className: 'balance-container', children: balanceHeaderTitle() });
|
|
155
|
+
}
|
|
156
|
+
return (jsx("div", { className: 'balance-container', children: jsxs("div", { className: 'multi-asset-balance-container', children: [jsx("div", { className: `${hasShadow ? 'shadow' : ''}`, children: jsxs("button", { onClick: toggleBalanceAccordion, className: 'balance-header', "data-testid": 'balance-header', children: [balanceHeaderTitle(), !isLoadingTokenBalances && (jsx("div", { className: balanceIsExpanded ? 'balance-header__chevron' : '', children: jsx(SvgChevronDown, {}) }))] }) }), jsx(AccordionItem, { isOpen: balanceIsExpanded, className: `multi-asset-balance-container__accordion ${'multi-asset-balance-container__accordion' +
|
|
157
|
+
(balanceIsExpanded ? '--expanded' : '--collapsed')}`, handleScroll: handleScroll, ref: contentRef, dataTestId: 'multi-asset-balance-accordion', children: jsx(TokenBalanceList, { tokenBalances: filteredTokenBalances }) })] }) }));
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export { ActiveWalletBalance };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ActiveWalletBalance } from './ActiveWalletBalance';
|