@dynamic-labs/sdk-react-core 4.29.3 → 4.29.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +13 -13
  5. package/src/index.cjs +10 -2
  6. package/src/index.d.ts +2 -2
  7. package/src/index.js +4 -2
  8. package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
  9. package/src/lib/components/EmbeddedWalletExport/EmbeddedWalletExport.cjs +83 -0
  10. package/src/lib/components/EmbeddedWalletExport/EmbeddedWalletExport.d.ts +12 -0
  11. package/src/lib/components/EmbeddedWalletExport/EmbeddedWalletExport.js +79 -0
  12. package/src/lib/components/EmbeddedWalletExport/index.d.ts +2 -0
  13. package/src/lib/components/Input/Input.cjs +1 -1
  14. package/src/lib/components/Input/Input.js +1 -1
  15. package/src/lib/components/Textarea/Textarea.cjs +1 -1
  16. package/src/lib/components/Textarea/Textarea.js +1 -1
  17. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -2
  18. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -2
  19. package/src/lib/components/index.d.ts +1 -0
  20. package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.cjs +7 -7
  21. package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.js +7 -7
  22. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +7 -7
  23. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +7 -7
  24. package/src/lib/context/ViewContext/types/index.d.ts +1 -1
  25. package/src/lib/locale/en/translation.cjs +76 -0
  26. package/src/lib/locale/en/translation.d.ts +76 -0
  27. package/src/lib/locale/en/translation.js +76 -0
  28. package/src/lib/shared/assets/index.d.ts +1 -0
  29. package/src/lib/shared/assets/sparkles.cjs +54 -0
  30. package/src/lib/shared/assets/sparkles.js +30 -0
  31. package/src/lib/shared/assets/upgrade.cjs +93 -0
  32. package/src/lib/shared/assets/upgrade.js +69 -0
  33. package/src/lib/styles/index.shadow.cjs +1 -1
  34. package/src/lib/styles/index.shadow.js +1 -1
  35. package/src/lib/utils/constants/authViewLayoutChecks.cjs +4 -0
  36. package/src/lib/utils/constants/authViewLayoutChecks.js +4 -0
  37. package/src/lib/utils/functions/exportWalletCredential/exportWalletCredential.cjs +57 -0
  38. package/src/lib/utils/functions/exportWalletCredential/exportWalletCredential.d.ts +13 -0
  39. package/src/lib/utils/functions/exportWalletCredential/exportWalletCredential.js +53 -0
  40. package/src/lib/utils/functions/exportWalletCredential/index.d.ts +2 -0
  41. package/src/lib/utils/functions/findPrimaryWalletVCForUser/findPrimaryWalletVCForUser.cjs +57 -0
  42. package/src/lib/utils/functions/findPrimaryWalletVCForUser/findPrimaryWalletVCForUser.d.ts +11 -0
  43. package/src/lib/utils/functions/findPrimaryWalletVCForUser/findPrimaryWalletVCForUser.js +53 -0
  44. package/src/lib/utils/functions/findPrimaryWalletVCForUser/index.d.ts +1 -0
  45. package/src/lib/utils/functions/index.d.ts +1 -0
  46. package/src/lib/utils/hooks/index.d.ts +2 -0
  47. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +3 -3
  48. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +3 -3
  49. package/src/lib/utils/hooks/useDeletePasskey/index.d.ts +1 -0
  50. package/src/lib/utils/hooks/useDeletePasskey/useDeletePasskey.cjs +33 -0
  51. package/src/lib/utils/hooks/useDeletePasskey/useDeletePasskey.d.ts +22 -0
  52. package/src/lib/utils/hooks/useDeletePasskey/useDeletePasskey.js +29 -0
  53. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +23 -23
  54. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +5 -4
  55. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +24 -24
  56. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +25 -36
  57. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +26 -37
  58. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +2 -2
  59. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +2 -2
  60. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +4 -4
  61. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +4 -4
  62. package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.cjs +39 -19
  63. package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.js +39 -19
  64. package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.cjs +11 -5
  65. package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.js +11 -5
  66. package/src/lib/utils/hooks/useRefreshUserState/useRefreshUserState.cjs +2 -2
  67. package/src/lib/utils/hooks/useRefreshUserState/useRefreshUserState.js +2 -2
  68. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +1 -1
  69. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +1 -1
  70. package/src/lib/utils/hooks/useSmartWallets/useSmartWallets.cjs +1 -1
  71. package/src/lib/utils/hooks/useSmartWallets/useSmartWallets.js +1 -1
  72. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +1 -1
  73. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +1 -1
  74. package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +5 -4
  75. package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +5 -4
  76. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +3 -3
  77. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +3 -3
  78. package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.cjs +3 -3
  79. package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.js +3 -3
  80. package/src/lib/utils/hooks/useUpgradeToDynamicWaasFlow/index.d.ts +1 -0
  81. package/src/lib/utils/hooks/useUpgradeToDynamicWaasFlow/useUpgradeToDynamicWaasFlow.cjs +124 -0
  82. package/src/lib/utils/hooks/useUpgradeToDynamicWaasFlow/useUpgradeToDynamicWaasFlow.d.ts +7 -0
  83. package/src/lib/utils/hooks/useUpgradeToDynamicWaasFlow/useUpgradeToDynamicWaasFlow.js +120 -0
  84. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +3 -3
  85. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +3 -3
  86. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +6 -0
  87. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +6 -0
  88. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +6 -0
  89. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +6 -0
  90. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +44 -31
  91. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.d.ts +1 -1
  92. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +44 -31
  93. package/src/lib/views/AccountUpgradedView/AccountUpgradedView.cjs +124 -0
  94. package/src/lib/views/AccountUpgradedView/AccountUpgradedView.d.ts +2 -0
  95. package/src/lib/views/AccountUpgradedView/AccountUpgradedView.js +120 -0
  96. package/src/lib/views/AccountUpgradedView/index.d.ts +1 -0
  97. package/src/lib/views/EmailVerification/EmailVerification.cjs +3 -3
  98. package/src/lib/views/EmailVerification/EmailVerification.js +3 -3
  99. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +17 -139
  100. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +20 -142
  101. package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +15 -0
  102. package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.d.ts +2 -0
  103. package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +14 -1
  104. package/src/lib/views/WaasUpgradeView/WaasUpgradeView.cjs +159 -0
  105. package/src/lib/views/WaasUpgradeView/WaasUpgradeView.d.ts +5 -0
  106. package/src/lib/views/WaasUpgradeView/WaasUpgradeView.js +155 -0
  107. package/src/lib/views/WaasUpgradeView/index.d.ts +2 -0
  108. package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.cjs +203 -0
  109. package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.d.ts +9 -0
  110. package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.js +199 -0
  111. package/src/lib/views/WalletUpgradeFlowView/index.d.ts +1 -0
  112. package/src/lib/views/viewToComponentMap.cjs +6 -0
  113. package/src/lib/views/viewToComponentMap.d.ts +3 -0
  114. package/src/lib/views/viewToComponentMap.js +6 -0
  115. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +3 -3
  116. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +3 -3
  117. package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs +12 -1
  118. package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js +12 -1
  119. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs +10 -1
  120. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js +10 -1
@@ -0,0 +1,155 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { useState } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import '@dynamic-labs/utils';
7
+ import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
8
+ import '@dynamic-labs/iconic';
9
+ import { useViewContext } from '../../context/ViewContext/ViewContext.js';
10
+ import { ReactComponent as SvgUpgrade } from '../../shared/assets/upgrade.js';
11
+ import '@dynamic-labs/sdk-api-core';
12
+ import '../../shared/logger.js';
13
+ import '@dynamic-labs/wallet-connector-core';
14
+ import '@dynamic-labs/wallet-book';
15
+ import '../../utils/constants/colors.js';
16
+ import '../../utils/constants/values.js';
17
+ import '../../shared/consts/index.js';
18
+ import '../../components/Alert/Alert.js';
19
+ import '../../events/dynamicEvents.js';
20
+ import { useDynamicContext } from '../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
21
+ import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
22
+ import '../../context/CaptchaContext/CaptchaContext.js';
23
+ import '../../context/ErrorContext/ErrorContext.js';
24
+ import '@dynamic-labs/multi-wallet';
25
+ import 'react-international-phone';
26
+ import '../../store/state/nonce/nonce.js';
27
+ import '@dynamic-labs-sdk/client/core';
28
+ import '../../client/client.js';
29
+ import '@dynamic-labs-sdk/client';
30
+ import '../../config/ApiEndpoint.js';
31
+ import '../../store/state/projectSettings/projectSettings.js';
32
+ import '../../locale/locale.js';
33
+ import '../../store/state/dynamicContextProps/dynamicContextProps.js';
34
+ import '../../store/state/primaryWalletId/primaryWalletId.js';
35
+ import '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
36
+ import '../../context/AccessDeniedContext/AccessDeniedContext.js';
37
+ import '../../context/AccountExistsContext/AccountExistsContext.js';
38
+ import '../../context/UserWalletsContext/UserWalletsContext.js';
39
+ import '../../store/state/authMode/authMode.js';
40
+ import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
41
+ import '../../context/VerificationContext/VerificationContext.js';
42
+ import 'react-dom';
43
+ import '../../utils/functions/compareChains/compareChains.js';
44
+ import '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
45
+ import '../../context/ThemeContext/ThemeContext.js';
46
+ import { useSmartWallets } from '../../utils/hooks/useSmartWallets/useSmartWallets.js';
47
+ import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
48
+ import 'bs58';
49
+ import '@dynamic-labs/types';
50
+ import '../../context/SocialRedirectContext/SocialRedirectContext.js';
51
+ import '../../context/LoadingContext/LoadingContext.js';
52
+ import '../../context/WalletContext/WalletContext.js';
53
+ import '../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
54
+ import 'yup';
55
+ import '../../context/MockContext/MockContext.js';
56
+ import '../CollectUserDataView/useFields.js';
57
+ import '../../context/FieldsStateContext/FieldsStateContext.js';
58
+ import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
59
+ import '@dynamic-labs/rpc-providers';
60
+ import '../../store/state/walletOptions/walletOptions.js';
61
+ import { Typography } from '../../components/Typography/Typography.js';
62
+ import '../../context/FooterAnimationContext/index.js';
63
+ import '../../components/ShadowDOM/ShadowDOM.js';
64
+ import '../../components/Transition/ZoomTransition/ZoomTransition.js';
65
+ import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
66
+ import '../../components/Transition/OpacityTransition/OpacityTransition.js';
67
+ import '../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
68
+ import '../../context/WalletGroupContext/WalletGroupContext.js';
69
+ import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
70
+ import 'react-focus-lock';
71
+ import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
72
+ import '../../components/IconButton/IconButton.js';
73
+ import '../../components/MenuList/Dropdown/Dropdown.js';
74
+ import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
75
+ import 'formik';
76
+ import '../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
77
+ import { ModalHeader } from '../../components/ModalHeader/ModalHeader.js';
78
+ import '../../store/state/sendBalances.js';
79
+ import '../../components/Input/Input.js';
80
+ import '../../components/OverlayCard/OverlayCard.js';
81
+ import '../TransactionConfirmationView/TransactionConfirmationView.js';
82
+ import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
83
+ import '../../context/PasskeyContext/PasskeyContext.js';
84
+ import '../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
85
+ import '../../context/OnrampContext/OnrampContext.js';
86
+ import '../../../index.js';
87
+ import '../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
88
+ import 'qrcode';
89
+ import '../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
90
+ import '../../context/IpConfigurationContext/IpConfigurationContext.js';
91
+ import '../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
92
+ import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
93
+ import '@hcaptcha/react-hcaptcha';
94
+ import '../ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
95
+ import '../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
96
+ import '../MfaChooseDeviceView/getMfaOptions/getMfaOptions.js';
97
+ import '../../store/state/connectorsInitializing/connectorsInitializing.js';
98
+ import '../../store/state/tokenBalances.js';
99
+ import '../../store/state/multichainBalances.js';
100
+ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
101
+ import '../../components/InlineWidget/InlineWidget.js';
102
+ import '../../components/IsBrowser/IsBrowser.js';
103
+ import '../../components/Popper/Popper/Popper.js';
104
+ import '../../components/Popper/PopperContext/PopperContext.js';
105
+
106
+ // TODO(zfaizal2): Add this back as a param in a future PR
107
+ const enableNewWalletCreation = false;
108
+ const WaasUpgradeView = ({ onUpgrade }) => {
109
+ const { pushView } = useViewContext();
110
+ const { primaryWallet, secondaryWallets } = useInternalDynamicContext();
111
+ const { getEOAWallet } = useSmartWallets();
112
+ const userWallets = [primaryWallet, ...secondaryWallets].reduce((acc, wallet) => {
113
+ if (!wallet)
114
+ return acc;
115
+ // Check if the wallet itself is a Turnkey wallet
116
+ if (wallet.connector.key.startsWith('turnkey')) {
117
+ acc.push(wallet);
118
+ }
119
+ // Check if it's a smart contract wallet with a Turnkey EOA signer
120
+ const eoaWallet = getEOAWallet(wallet);
121
+ if (eoaWallet && eoaWallet.connector.key.startsWith('turnkey')) {
122
+ // Check if EOA wallet is already in the accumulator to avoid duplicates
123
+ const isAlreadyIncluded = acc.some((existingWallet) => existingWallet.id === eoaWallet.id);
124
+ if (!isAlreadyIncluded) {
125
+ acc.push(eoaWallet);
126
+ }
127
+ }
128
+ return acc;
129
+ }, []);
130
+ const { t } = useTranslation();
131
+ const { setShowAuthFlow } = useDynamicContext();
132
+ const [selectedWallets] = useState(userWallets.map((w) => { var _a; return (_a = w === null || w === void 0 ? void 0 : w.id) !== null && _a !== void 0 ? _a : ''; }));
133
+ const [upgradeOption, setUpgradeOption] = useState('keep');
134
+ const handleUpgrade = () => __awaiter(void 0, void 0, void 0, function* () {
135
+ if (selectedWallets.length === 0)
136
+ return;
137
+ if (upgradeOption === 'keep') {
138
+ const walletsToUpgrade = selectedWallets
139
+ .map((walletId) => userWallets.find((w) => (w === null || w === void 0 ? void 0 : w.id) === walletId))
140
+ .filter((w) => w !== undefined && w !== null);
141
+ pushView('wallet-upgrade-flow-view', {
142
+ method: 'existing',
143
+ wallets: walletsToUpgrade,
144
+ });
145
+ }
146
+ onUpgrade === null || onUpgrade === void 0 ? void 0 : onUpgrade(selectedWallets, upgradeOption);
147
+ });
148
+ return (jsxs("div", { className: 'waas-upgrade-view', children: [jsx(ModalHeader, { children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', children: t('dyn_upgrade_wallet.title') }) }), jsxs("div", { className: 'waas-upgrade-view__content', children: [jsx("div", { className: 'waas-upgrade-view__illustration', children: jsx(SvgUpgrade, {}) }), jsx(Typography, { as: 'p', variant: 'body_normal', className: 'waas-upgrade-view__new-version-message', children: t('dyn_upgrade_wallet.description') }), jsxs("div", { className: 'waas-upgrade-view__wallets-section', children: [jsx("div", { className: 'waas-upgrade-view__section-header', children: jsx(Typography, { color: 'primary', children: t('dyn_upgrade_wallet.eligible_wallets') }) }), jsx("div", { className: 'waas-upgrade-view__wallets-list', children: userWallets.map((wallet) => (jsx("div", { className: 'waas-upgrade-view__wallet-item', children: jsx("div", { className: 'waas-upgrade-view__wallet-info', children: jsxs("div", { className: 'waas-upgrade-view__wallet-details', children: [jsx(Typography, { color: 'primary', children: wallet.chain }), jsxs(Typography, { color: 'primary', children: [wallet.address.slice(0, 6), "...", wallet.address.slice(-4)] })] }) }) }, wallet.id))) })] }), enableNewWalletCreation , jsxs("div", { className: 'waas-upgrade-view__actions', children: [jsx(TypographyButton, { buttonVariant: 'brand-primary', onClick: handleUpgrade, disabled: selectedWallets.length === 0, copykey: 'dyn_upgrade_wallet.upgrade', typographyProps: {
149
+ color: 'inherit',
150
+ }, children: t('dyn_upgrade_wallet.upgrade') }), jsx(TypographyButton, { buttonVariant: 'tertiary', onClick: () => {
151
+ setShowAuthFlow(false);
152
+ }, children: t('dyn_upgrade_wallet.not_now') })] })] })] }));
153
+ };
154
+
155
+ export { WaasUpgradeView };
@@ -0,0 +1,2 @@
1
+ export { WaasUpgradeView } from './WaasUpgradeView';
2
+ export type { WaasUpgradeViewProps } from './WaasUpgradeView';
@@ -0,0 +1,203 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var React = require('react');
9
+ var reactI18next = require('react-i18next');
10
+ var utils = require('@dynamic-labs/utils');
11
+ require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
12
+ require('@dynamic-labs/iconic');
13
+ var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
14
+ require('@dynamic-labs/sdk-api-core');
15
+ var logger = require('../../shared/logger.cjs');
16
+ require('@dynamic-labs/wallet-connector-core');
17
+ require('@dynamic-labs/wallet-book');
18
+ require('../../utils/constants/colors.cjs');
19
+ require('../../utils/constants/values.cjs');
20
+ require('../../shared/consts/index.cjs');
21
+ require('../../components/Alert/Alert.cjs');
22
+ var dynamicEvents = require('../../events/dynamicEvents.cjs');
23
+ require('../../context/DynamicContext/DynamicContext.cjs');
24
+ require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
25
+ require('../../store/state/authMode/authMode.cjs');
26
+ var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
27
+ require('../../context/CaptchaContext/CaptchaContext.cjs');
28
+ require('../../context/ErrorContext/ErrorContext.cjs');
29
+ require('@dynamic-labs/multi-wallet');
30
+ require('react-international-phone');
31
+ require('../../store/state/nonce/nonce.cjs');
32
+ require('@dynamic-labs-sdk/client/core');
33
+ require('../../client/client.cjs');
34
+ require('@dynamic-labs-sdk/client');
35
+ require('../../config/ApiEndpoint.cjs');
36
+ require('../../store/state/projectSettings/projectSettings.cjs');
37
+ require('../../locale/locale.cjs');
38
+ require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
39
+ require('../../store/state/primaryWalletId/primaryWalletId.cjs');
40
+ require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
41
+ var exportWalletCredential = require('../../utils/functions/exportWalletCredential/exportWalletCredential.cjs');
42
+ require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
43
+ require('../../context/AccountExistsContext/AccountExistsContext.cjs');
44
+ require('../../context/UserWalletsContext/UserWalletsContext.cjs');
45
+ require('../../context/VerificationContext/VerificationContext.cjs');
46
+ require('react-dom');
47
+ require('../../utils/functions/compareChains/compareChains.cjs');
48
+ require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
49
+ require('../../context/ThemeContext/ThemeContext.cjs');
50
+ require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
51
+ var useMutation = require('../../utils/hooks/useMutation/useMutation.cjs');
52
+ require('bs58');
53
+ require('@dynamic-labs/types');
54
+ require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
55
+ require('../../context/LoadingContext/LoadingContext.cjs');
56
+ require('../../context/WalletContext/WalletContext.cjs');
57
+ require('../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
58
+ require('yup');
59
+ require('../../context/MockContext/MockContext.cjs');
60
+ require('../CollectUserDataView/useFields.cjs');
61
+ require('../../context/FieldsStateContext/FieldsStateContext.cjs');
62
+ require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
63
+ require('@dynamic-labs/rpc-providers');
64
+ require('../../store/state/walletOptions/walletOptions.cjs');
65
+ var Typography = require('../../components/Typography/Typography.cjs');
66
+ require('../../context/FooterAnimationContext/index.cjs');
67
+ require('../../components/ShadowDOM/ShadowDOM.cjs');
68
+ require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
69
+ require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
70
+ require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
71
+ require('../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
72
+ require('../../context/WalletGroupContext/WalletGroupContext.cjs');
73
+ require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
74
+ require('react-focus-lock');
75
+ require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
76
+ require('../../components/IconButton/IconButton.cjs');
77
+ require('../../components/MenuList/Dropdown/Dropdown.cjs');
78
+ var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
79
+ var TypographyButton = require('../../components/TypographyButton/TypographyButton.cjs');
80
+ require('formik');
81
+ require('../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
82
+ var ModalHeader = require('../../components/ModalHeader/ModalHeader.cjs');
83
+ require('../../store/state/sendBalances.cjs');
84
+ require('../../components/Input/Input.cjs');
85
+ require('../../components/OverlayCard/OverlayCard.cjs');
86
+ require('../TransactionConfirmationView/TransactionConfirmationView.cjs');
87
+ require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
88
+ require('../../context/PasskeyContext/PasskeyContext.cjs');
89
+ require('../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs');
90
+ require('../../context/OnrampContext/OnrampContext.cjs');
91
+ require('../../../index.cjs');
92
+ require('../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
93
+ require('qrcode');
94
+ require('../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
95
+ var Textarea = require('../../components/Textarea/Textarea.cjs');
96
+ require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
97
+ require('../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
98
+ require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
99
+ require('@hcaptcha/react-hcaptcha');
100
+ require('../ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
101
+ require('../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
102
+ require('../MfaChooseDeviceView/getMfaOptions/getMfaOptions.cjs');
103
+ var useDynamicWaas = require('../../utils/hooks/useDynamicWaas/useDynamicWaas.cjs');
104
+ require('../../store/state/connectorsInitializing/connectorsInitializing.cjs');
105
+ require('../../store/state/tokenBalances.cjs');
106
+ require('../../store/state/multichainBalances.cjs');
107
+ var useRefreshUser = require('../../utils/hooks/useRefreshUser/useRefreshUser.cjs');
108
+ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
109
+ var EmbeddedWalletExport = require('../../components/EmbeddedWalletExport/EmbeddedWalletExport.cjs');
110
+ require('../../components/InlineWidget/InlineWidget.cjs');
111
+ require('../../components/IsBrowser/IsBrowser.cjs');
112
+ require('../../components/Popper/Popper/Popper.cjs');
113
+ require('../../components/Popper/PopperContext/PopperContext.cjs');
114
+
115
+ const WalletUpgradeFlowView = ({ wallets, method, onComplete, onCancel, }) => {
116
+ var _a;
117
+ const { setShowAuthFlow, user, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
118
+ const { upgradeToDynamicWaas } = useDynamicWaas.useDynamicWaas();
119
+ const { t } = reactI18next.useTranslation();
120
+ const { pushView } = ViewContext.useViewContext();
121
+ const [currentWalletIndex, setCurrentWalletIndex] = React.useState(0);
122
+ const [privateKeyInput, setPrivateKeyInput] = React.useState('');
123
+ const [iframeContainerRef, setIframeContainerRef] = React.useState(null);
124
+ const isLastWallet = currentWalletIndex === wallets.length - 1;
125
+ const completedSteps = currentWalletIndex;
126
+ const totalSteps = wallets.length;
127
+ const refresh = useRefreshUser.useRefreshUser();
128
+ // Check if current wallet is a WaaS wallet based on its properties
129
+ const isWaasWallet = Boolean(user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((vc) => { var _a; return (_a = vc.walletName) === null || _a === void 0 ? void 0 : _a.startsWith('dynamicwaas'); }));
130
+ const onExportReady = (isReady, wallet) => {
131
+ if (isReady) {
132
+ handleExportWallet(wallet);
133
+ }
134
+ };
135
+ const { mutate: handleExportWallet, data: exportData, error: exportError, } = useMutation.useMutation((wallet) => exportWalletCredential.exportWalletCredential({
136
+ environmentId,
137
+ exportPrivateKey: true,
138
+ handleAcknowledgeExportPrompt: () => { },
139
+ iframeContainerRef: iframeContainerRef,
140
+ isTurnkeyWallet: true,
141
+ isWaasWallet,
142
+ user,
143
+ wallet,
144
+ }), {
145
+ onFailure: (err) => {
146
+ logger.logger.error('Failed to export wallet in upgrade flow', err);
147
+ dynamicEvents.dynamicEvents.emit('embeddedWalletRevealFailed', err);
148
+ },
149
+ });
150
+ const { mutate: handleUpgradeWallet, isLoading: isUpgrading, error: upgradeError, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
151
+ if (!privateKeyInput.trim()) {
152
+ throw new utils.DynamicError('Private key is required');
153
+ }
154
+ yield upgradeToDynamicWaas({
155
+ privateKey: privateKeyInput.trim(),
156
+ wallet: wallets[currentWalletIndex],
157
+ });
158
+ setIframeContainerRef(null);
159
+ setPrivateKeyInput('');
160
+ refresh();
161
+ if (isLastWallet) {
162
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
163
+ pushView('account-upgraded');
164
+ }
165
+ else {
166
+ setCurrentWalletIndex((prev) => prev + 1);
167
+ }
168
+ }), {
169
+ onFailure: () => {
170
+ logger.logger.error('Failed to upgrade wallet in upgrade flow');
171
+ },
172
+ });
173
+ const handleClose = () => {
174
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
175
+ setShowAuthFlow(false);
176
+ };
177
+ const getStepTitle = (stepIndex) => {
178
+ var _a;
179
+ const walletName = ((_a = wallets[stepIndex]) === null || _a === void 0 ? void 0 : _a.chain) || 'Wallet';
180
+ return t('dyn_wallet_upgrade_flow.step_wallet_upgrade', { walletName });
181
+ };
182
+ if (!wallets[currentWalletIndex]) {
183
+ return null;
184
+ }
185
+ if (method === 'new') {
186
+ // For 'new' method, we would implement fresh wallet creation
187
+ // This is a placeholder for now
188
+ return (jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', children: t('dyn_wallet_upgrade_flow.new_wallet_title') }) }), jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__content', children: jsxRuntime.jsx(Typography.Typography, { children: t('dyn_wallet_upgrade_flow.new_wallet_coming_soon') }) })] }));
189
+ }
190
+ return (jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { children: totalSteps > 1 && (jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__header', children: jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__steps', children: Array.from({ length: totalSteps }, (_, index) => (jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view__step-container', children: [jsxRuntime.jsxs("div", { className: `wallet-upgrade-flow-view__step ${index < completedSteps
191
+ ? 'wallet-upgrade-flow-view__step--completed'
192
+ : ''} ${index === currentWalletIndex
193
+ ? 'wallet-upgrade-flow-view__step--current'
194
+ : ''}`, children: [jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__step-indicator', children: index < completedSteps ? (jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__step-check', children: "\u2713" })) : (jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__step-number', children: index + 1 })) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: index <= currentWalletIndex ? 'primary' : 'secondary', className: 'wallet-upgrade-flow-view__step-title', children: getStepTitle(index) })] }), index < totalSteps - 1 && (jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__step-separator' }))] }, index))) }) })) }), jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view__content', children: [exportError && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { className: 'wallet-upgrade-flow-view__error', children: exportError instanceof Error
195
+ ? exportError.message
196
+ : t('dyn_wallet_upgrade_flow.export_failed') })), upgradeError && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { className: 'wallet-upgrade-flow-view__error', children: upgradeError instanceof Error
197
+ ? upgradeError.message
198
+ : t('dyn_wallet_upgrade_flow.upgrade_failed') })), jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view__title-section', children: [jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', children: t('dyn_wallet_upgrade_flow.title') }), jsxRuntime.jsx(Typography.Typography, { color: 'secondary', className: 'wallet-upgrade-flow-view__subtitle', children: t('dyn_wallet_upgrade_flow.copy_private_key_subtitle') })] }), jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view__export-section', children: [jsxRuntime.jsx(Typography.Typography, { color: 'primary', variant: 'body_normal', weight: 'bold', className: 'wallet-upgrade-flow-view__section-title', children: t('dyn_wallet_upgrade_flow.copy_private_key_title') }), jsxRuntime.jsx(EmbeddedWalletExport.EmbeddedWalletExport, { wallet: wallets[currentWalletIndex], isTurnkeyWallet: true, isWaasWallet: isWaasWallet, data: exportData, onIframeContainerRef: setIframeContainerRef, onExportReady: onExportReady }, `wallet-export-${currentWalletIndex}-${(_a = wallets[currentWalletIndex]) === null || _a === void 0 ? void 0 : _a.id}`)] }), jsxRuntime.jsx("div", { className: 'wallet-upgrade-flow-view__input-section', children: jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view__input-container', children: [jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'primary', copykey: 'dyn_embedded_reveal.step_2_title', children: [jsxRuntime.jsx("span", { className: 'wallet-upgrade-flow__step-description', children: t('dyn_wallet_upgrade_flow.step_2_upgrade_description') }), ' '] }), jsxRuntime.jsx(Textarea.Textarea, { id: 'paste-private-key-input', value: privateKeyInput, onChange: (e) => setPrivateKeyInput(e.target.value), variant: 'regular', className: 'wallet-upgrade-flow__paste-input', label: '' })] }) })] }), jsxRuntime.jsxs("div", { className: 'wallet-upgrade-flow-view__actions', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'brand-primary', onClick: () => handleUpgradeWallet(), disabled: !privateKeyInput.trim() || isUpgrading, loading: isUpgrading, copykey: 'dyn_wallet_upgrade_flow.upgrade_button', typographyProps: {
199
+ color: 'inherit',
200
+ }, expanded: true, children: t('dyn_wallet_upgrade_flow.upgrade_wallet') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'tertiary', onClick: handleClose, disabled: isUpgrading, children: t('dyn_wallet_upgrade_flow.cancel') })] })] }));
201
+ };
202
+
203
+ exports.WalletUpgradeFlowView = WalletUpgradeFlowView;
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { Wallet, WalletConnectorCore } from '@dynamic-labs/wallet-connector-core';
3
+ export interface WalletUpgradeFlowViewProps {
4
+ wallets: Wallet<WalletConnectorCore.WalletConnector>[];
5
+ method: 'new' | 'existing';
6
+ onComplete?: () => void;
7
+ onCancel?: () => void;
8
+ }
9
+ export declare const WalletUpgradeFlowView: FC<WalletUpgradeFlowViewProps>;
@@ -0,0 +1,199 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { useState } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { DynamicError } from '@dynamic-labs/utils';
7
+ import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
8
+ import '@dynamic-labs/iconic';
9
+ import { useViewContext } from '../../context/ViewContext/ViewContext.js';
10
+ import '@dynamic-labs/sdk-api-core';
11
+ import { logger } from '../../shared/logger.js';
12
+ import '@dynamic-labs/wallet-connector-core';
13
+ import '@dynamic-labs/wallet-book';
14
+ import '../../utils/constants/colors.js';
15
+ import '../../utils/constants/values.js';
16
+ import '../../shared/consts/index.js';
17
+ import '../../components/Alert/Alert.js';
18
+ import { dynamicEvents } from '../../events/dynamicEvents.js';
19
+ import '../../context/DynamicContext/DynamicContext.js';
20
+ import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
21
+ import '../../store/state/authMode/authMode.js';
22
+ import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
23
+ import '../../context/CaptchaContext/CaptchaContext.js';
24
+ import '../../context/ErrorContext/ErrorContext.js';
25
+ import '@dynamic-labs/multi-wallet';
26
+ import 'react-international-phone';
27
+ import '../../store/state/nonce/nonce.js';
28
+ import '@dynamic-labs-sdk/client/core';
29
+ import '../../client/client.js';
30
+ import '@dynamic-labs-sdk/client';
31
+ import '../../config/ApiEndpoint.js';
32
+ import '../../store/state/projectSettings/projectSettings.js';
33
+ import '../../locale/locale.js';
34
+ import '../../store/state/dynamicContextProps/dynamicContextProps.js';
35
+ import '../../store/state/primaryWalletId/primaryWalletId.js';
36
+ import '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
37
+ import { exportWalletCredential } from '../../utils/functions/exportWalletCredential/exportWalletCredential.js';
38
+ import '../../context/AccessDeniedContext/AccessDeniedContext.js';
39
+ import '../../context/AccountExistsContext/AccountExistsContext.js';
40
+ import '../../context/UserWalletsContext/UserWalletsContext.js';
41
+ import '../../context/VerificationContext/VerificationContext.js';
42
+ import 'react-dom';
43
+ import '../../utils/functions/compareChains/compareChains.js';
44
+ import '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
45
+ import '../../context/ThemeContext/ThemeContext.js';
46
+ import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
47
+ import { useMutation } from '../../utils/hooks/useMutation/useMutation.js';
48
+ import 'bs58';
49
+ import '@dynamic-labs/types';
50
+ import '../../context/SocialRedirectContext/SocialRedirectContext.js';
51
+ import '../../context/LoadingContext/LoadingContext.js';
52
+ import '../../context/WalletContext/WalletContext.js';
53
+ import '../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
54
+ import 'yup';
55
+ import '../../context/MockContext/MockContext.js';
56
+ import '../CollectUserDataView/useFields.js';
57
+ import '../../context/FieldsStateContext/FieldsStateContext.js';
58
+ import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
59
+ import '@dynamic-labs/rpc-providers';
60
+ import '../../store/state/walletOptions/walletOptions.js';
61
+ import { Typography } from '../../components/Typography/Typography.js';
62
+ import '../../context/FooterAnimationContext/index.js';
63
+ import '../../components/ShadowDOM/ShadowDOM.js';
64
+ import '../../components/Transition/ZoomTransition/ZoomTransition.js';
65
+ import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
66
+ import '../../components/Transition/OpacityTransition/OpacityTransition.js';
67
+ import '../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
68
+ import '../../context/WalletGroupContext/WalletGroupContext.js';
69
+ import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
70
+ import 'react-focus-lock';
71
+ import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
72
+ import '../../components/IconButton/IconButton.js';
73
+ import '../../components/MenuList/Dropdown/Dropdown.js';
74
+ import { ErrorContainer } from '../../components/ErrorContainer/ErrorContainer.js';
75
+ import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
76
+ import 'formik';
77
+ import '../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
78
+ import { ModalHeader } from '../../components/ModalHeader/ModalHeader.js';
79
+ import '../../store/state/sendBalances.js';
80
+ import '../../components/Input/Input.js';
81
+ import '../../components/OverlayCard/OverlayCard.js';
82
+ import '../TransactionConfirmationView/TransactionConfirmationView.js';
83
+ import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
84
+ import '../../context/PasskeyContext/PasskeyContext.js';
85
+ import '../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
86
+ import '../../context/OnrampContext/OnrampContext.js';
87
+ import '../../../index.js';
88
+ import '../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
89
+ import 'qrcode';
90
+ import '../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
91
+ import { Textarea } from '../../components/Textarea/Textarea.js';
92
+ import '../../context/IpConfigurationContext/IpConfigurationContext.js';
93
+ import '../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
94
+ import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
95
+ import '@hcaptcha/react-hcaptcha';
96
+ import '../ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
97
+ import '../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
98
+ import '../MfaChooseDeviceView/getMfaOptions/getMfaOptions.js';
99
+ import { useDynamicWaas } from '../../utils/hooks/useDynamicWaas/useDynamicWaas.js';
100
+ import '../../store/state/connectorsInitializing/connectorsInitializing.js';
101
+ import '../../store/state/tokenBalances.js';
102
+ import '../../store/state/multichainBalances.js';
103
+ import { useRefreshUser } from '../../utils/hooks/useRefreshUser/useRefreshUser.js';
104
+ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
105
+ import { EmbeddedWalletExport } from '../../components/EmbeddedWalletExport/EmbeddedWalletExport.js';
106
+ import '../../components/InlineWidget/InlineWidget.js';
107
+ import '../../components/IsBrowser/IsBrowser.js';
108
+ import '../../components/Popper/Popper/Popper.js';
109
+ import '../../components/Popper/PopperContext/PopperContext.js';
110
+
111
+ const WalletUpgradeFlowView = ({ wallets, method, onComplete, onCancel, }) => {
112
+ var _a;
113
+ const { setShowAuthFlow, user, environmentId } = useInternalDynamicContext();
114
+ const { upgradeToDynamicWaas } = useDynamicWaas();
115
+ const { t } = useTranslation();
116
+ const { pushView } = useViewContext();
117
+ const [currentWalletIndex, setCurrentWalletIndex] = useState(0);
118
+ const [privateKeyInput, setPrivateKeyInput] = useState('');
119
+ const [iframeContainerRef, setIframeContainerRef] = useState(null);
120
+ const isLastWallet = currentWalletIndex === wallets.length - 1;
121
+ const completedSteps = currentWalletIndex;
122
+ const totalSteps = wallets.length;
123
+ const refresh = useRefreshUser();
124
+ // Check if current wallet is a WaaS wallet based on its properties
125
+ const isWaasWallet = Boolean(user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((vc) => { var _a; return (_a = vc.walletName) === null || _a === void 0 ? void 0 : _a.startsWith('dynamicwaas'); }));
126
+ const onExportReady = (isReady, wallet) => {
127
+ if (isReady) {
128
+ handleExportWallet(wallet);
129
+ }
130
+ };
131
+ const { mutate: handleExportWallet, data: exportData, error: exportError, } = useMutation((wallet) => exportWalletCredential({
132
+ environmentId,
133
+ exportPrivateKey: true,
134
+ handleAcknowledgeExportPrompt: () => { },
135
+ iframeContainerRef: iframeContainerRef,
136
+ isTurnkeyWallet: true,
137
+ isWaasWallet,
138
+ user,
139
+ wallet,
140
+ }), {
141
+ onFailure: (err) => {
142
+ logger.error('Failed to export wallet in upgrade flow', err);
143
+ dynamicEvents.emit('embeddedWalletRevealFailed', err);
144
+ },
145
+ });
146
+ const { mutate: handleUpgradeWallet, isLoading: isUpgrading, error: upgradeError, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
147
+ if (!privateKeyInput.trim()) {
148
+ throw new DynamicError('Private key is required');
149
+ }
150
+ yield upgradeToDynamicWaas({
151
+ privateKey: privateKeyInput.trim(),
152
+ wallet: wallets[currentWalletIndex],
153
+ });
154
+ setIframeContainerRef(null);
155
+ setPrivateKeyInput('');
156
+ refresh();
157
+ if (isLastWallet) {
158
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
159
+ pushView('account-upgraded');
160
+ }
161
+ else {
162
+ setCurrentWalletIndex((prev) => prev + 1);
163
+ }
164
+ }), {
165
+ onFailure: () => {
166
+ logger.error('Failed to upgrade wallet in upgrade flow');
167
+ },
168
+ });
169
+ const handleClose = () => {
170
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel();
171
+ setShowAuthFlow(false);
172
+ };
173
+ const getStepTitle = (stepIndex) => {
174
+ var _a;
175
+ const walletName = ((_a = wallets[stepIndex]) === null || _a === void 0 ? void 0 : _a.chain) || 'Wallet';
176
+ return t('dyn_wallet_upgrade_flow.step_wallet_upgrade', { walletName });
177
+ };
178
+ if (!wallets[currentWalletIndex]) {
179
+ return null;
180
+ }
181
+ if (method === 'new') {
182
+ // For 'new' method, we would implement fresh wallet creation
183
+ // This is a placeholder for now
184
+ return (jsxs("div", { className: 'wallet-upgrade-flow-view', children: [jsx(ModalHeader, { children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', children: t('dyn_wallet_upgrade_flow.new_wallet_title') }) }), jsx("div", { className: 'wallet-upgrade-flow-view__content', children: jsx(Typography, { children: t('dyn_wallet_upgrade_flow.new_wallet_coming_soon') }) })] }));
185
+ }
186
+ return (jsxs("div", { className: 'wallet-upgrade-flow-view', children: [jsx(ModalHeader, { children: totalSteps > 1 && (jsx("div", { className: 'wallet-upgrade-flow-view__header', children: jsx("div", { className: 'wallet-upgrade-flow-view__steps', children: Array.from({ length: totalSteps }, (_, index) => (jsxs("div", { className: 'wallet-upgrade-flow-view__step-container', children: [jsxs("div", { className: `wallet-upgrade-flow-view__step ${index < completedSteps
187
+ ? 'wallet-upgrade-flow-view__step--completed'
188
+ : ''} ${index === currentWalletIndex
189
+ ? 'wallet-upgrade-flow-view__step--current'
190
+ : ''}`, children: [jsx("div", { className: 'wallet-upgrade-flow-view__step-indicator', children: index < completedSteps ? (jsx("div", { className: 'wallet-upgrade-flow-view__step-check', children: "\u2713" })) : (jsx("div", { className: 'wallet-upgrade-flow-view__step-number', children: index + 1 })) }), jsx(Typography, { variant: 'body_small', color: index <= currentWalletIndex ? 'primary' : 'secondary', className: 'wallet-upgrade-flow-view__step-title', children: getStepTitle(index) })] }), index < totalSteps - 1 && (jsx("div", { className: 'wallet-upgrade-flow-view__step-separator' }))] }, index))) }) })) }), jsxs("div", { className: 'wallet-upgrade-flow-view__content', children: [exportError && (jsx(ErrorContainer, { className: 'wallet-upgrade-flow-view__error', children: exportError instanceof Error
191
+ ? exportError.message
192
+ : t('dyn_wallet_upgrade_flow.export_failed') })), upgradeError && (jsx(ErrorContainer, { className: 'wallet-upgrade-flow-view__error', children: upgradeError instanceof Error
193
+ ? upgradeError.message
194
+ : t('dyn_wallet_upgrade_flow.upgrade_failed') })), jsxs("div", { className: 'wallet-upgrade-flow-view__title-section', children: [jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', children: t('dyn_wallet_upgrade_flow.title') }), jsx(Typography, { color: 'secondary', className: 'wallet-upgrade-flow-view__subtitle', children: t('dyn_wallet_upgrade_flow.copy_private_key_subtitle') })] }), jsxs("div", { className: 'wallet-upgrade-flow-view__export-section', children: [jsx(Typography, { color: 'primary', variant: 'body_normal', weight: 'bold', className: 'wallet-upgrade-flow-view__section-title', children: t('dyn_wallet_upgrade_flow.copy_private_key_title') }), jsx(EmbeddedWalletExport, { wallet: wallets[currentWalletIndex], isTurnkeyWallet: true, isWaasWallet: isWaasWallet, data: exportData, onIframeContainerRef: setIframeContainerRef, onExportReady: onExportReady }, `wallet-export-${currentWalletIndex}-${(_a = wallets[currentWalletIndex]) === null || _a === void 0 ? void 0 : _a.id}`)] }), jsx("div", { className: 'wallet-upgrade-flow-view__input-section', children: jsxs("div", { className: 'wallet-upgrade-flow-view__input-container', children: [jsxs(Typography, { variant: 'body_normal', weight: 'bold', color: 'primary', copykey: 'dyn_embedded_reveal.step_2_title', children: [jsx("span", { className: 'wallet-upgrade-flow__step-description', children: t('dyn_wallet_upgrade_flow.step_2_upgrade_description') }), ' '] }), jsx(Textarea, { id: 'paste-private-key-input', value: privateKeyInput, onChange: (e) => setPrivateKeyInput(e.target.value), variant: 'regular', className: 'wallet-upgrade-flow__paste-input', label: '' })] }) })] }), jsxs("div", { className: 'wallet-upgrade-flow-view__actions', children: [jsx(TypographyButton, { buttonVariant: 'brand-primary', onClick: () => handleUpgradeWallet(), disabled: !privateKeyInput.trim() || isUpgrading, loading: isUpgrading, copykey: 'dyn_wallet_upgrade_flow.upgrade_button', typographyProps: {
195
+ color: 'inherit',
196
+ }, expanded: true, children: t('dyn_wallet_upgrade_flow.upgrade_wallet') }), jsx(TypographyButton, { buttonVariant: 'tertiary', onClick: handleClose, disabled: isUpgrading, children: t('dyn_wallet_upgrade_flow.cancel') })] })] }));
197
+ };
198
+
199
+ export { WalletUpgradeFlowView };
@@ -0,0 +1 @@
1
+ export { WalletUpgradeFlowView, type WalletUpgradeFlowViewProps, } from './WalletUpgradeFlowView';
@@ -150,7 +150,10 @@ var WalletListForDefaultConnection = require('./WalletList/WalletListForDefaultC
150
150
  var WalletLockedView = require('./WalletLockedView/WalletLockedView.cjs');
151
151
  var WalletRedirectView = require('./WalletRedirectView/WalletRedirectView.cjs');
152
152
  var WalletSignSpinnerView = require('./WalletSignSpinnerView/WalletSignSpinnerView.cjs');
153
+ var WalletUpgradeFlowView = require('./WalletUpgradeFlowView/WalletUpgradeFlowView.cjs');
153
154
  var WalletUsedView = require('./WalletUsedView/WalletUsedView.cjs');
155
+ var WaasUpgradeView = require('./WaasUpgradeView/WaasUpgradeView.cjs');
156
+ var AccountUpgradedView = require('./AccountUpgradedView/AccountUpgradedView.cjs');
154
157
  require('../store/state/connectorsInitializing/connectorsInitializing.cjs');
155
158
  require('../store/state/tokenBalances.cjs');
156
159
  require('../store/state/multichainBalances.cjs');
@@ -164,6 +167,7 @@ var PasskeyNewDomainDetectedView = require('./Passkey/PasskeyNewDomainDetectedVi
164
167
  const viewToComponentMap = {
165
168
  'access-blocked': AccessBlockedView.AccessBlockedView,
166
169
  'account-exists': AccountExistsView.AccountExistsView,
170
+ 'account-upgraded': AccountUpgradedView.AccountUpgradedView,
167
171
  'backup-unsuccessful': BackupUnsuccessfulView.BackupUnsuccessfulView,
168
172
  'bridge-next-wallet-connection': BridgeNextWalletConnectionView.BridgeNextWalletConnectionView,
169
173
  'bridge-summary': BridgeSummaryView.BridgeSummaryView,
@@ -230,6 +234,7 @@ const viewToComponentMap = {
230
234
  'user-delete-account': UserDeleteAccountView.UserDeleteAccountView,
231
235
  'verify-email': EmailVerification.EmailVerification,
232
236
  'verify-sms': SmsVerification.SmsVerification,
237
+ 'waas-upgrade-view': WaasUpgradeView.WaasUpgradeView,
233
238
  'wait-for-email-confirmation-view': EmailConfirmationWaitingView.EmailConfirmationWaitingView,
234
239
  'wallet-cannot-be-transferred': WalletCannotBeTransferredView.WalletCannotBeTransferredView,
235
240
  'wallet-connect-mobile-wallets-list': () => (jsxRuntime.jsx(WalletListForDefaultConnection.WalletListForDefaultConnection, { isWalletConnectList: true })),
@@ -238,6 +243,7 @@ const viewToComponentMap = {
238
243
  'wallet-locked-view': WalletLockedView.WalletLockedView,
239
244
  'wallet-redirect-view': WalletRedirectView.WalletRedirectView,
240
245
  'wallet-sign': WalletSignSpinnerView.WalletSignSpinnerView,
246
+ 'wallet-upgrade-flow-view': WalletUpgradeFlowView.WalletUpgradeFlowView,
241
247
  'wallet-used': WalletUsedView.WalletUsedView,
242
248
  };
243
249