@dynamic-labs/sdk-react-core 4.48.2 → 4.50.1

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 (117) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +12 -12
  5. package/src/index.cjs +6 -4
  6. package/src/index.d.ts +1 -0
  7. package/src/index.js +3 -2
  8. package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
  9. package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
  10. package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +10 -0
  11. package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +10 -0
  12. package/src/lib/context/OnrampContext/OnrampContext.cjs +4 -2
  13. package/src/lib/context/OnrampContext/OnrampContext.d.ts +1 -0
  14. package/src/lib/context/OnrampContext/OnrampContext.js +4 -2
  15. package/src/lib/context/OnrampContext/types.d.ts +1 -0
  16. package/src/lib/context/OnrampContext/utils/getOnrampProviders.cjs +2 -1
  17. package/src/lib/context/OnrampContext/utils/getOnrampProviders.d.ts +1 -1
  18. package/src/lib/context/OnrampContext/utils/getOnrampProviders.js +2 -1
  19. package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.cjs +38 -6
  20. package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.d.ts +2 -2
  21. package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.js +39 -8
  22. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +108 -16
  23. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +108 -16
  24. package/src/lib/context/ViewContext/types/index.d.ts +1 -1
  25. package/src/lib/data/api/onramp/onramp.cjs +2 -1
  26. package/src/lib/data/api/onramp/onramp.d.ts +2 -1
  27. package/src/lib/data/api/onramp/onramp.js +2 -1
  28. package/src/lib/events/dynamicEvents.cjs +2 -0
  29. package/src/lib/events/dynamicEvents.d.ts +1 -1
  30. package/src/lib/events/dynamicEvents.js +2 -0
  31. package/src/lib/shared/assets/backup-waas.cjs +4 -4
  32. package/src/lib/shared/assets/backup-waas.js +4 -4
  33. package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +4 -0
  34. package/src/lib/styles/index.shadow.cjs +1 -1
  35. package/src/lib/styles/index.shadow.js +1 -1
  36. package/src/lib/utils/constants/authViewLayoutChecks.cjs +13 -0
  37. package/src/lib/utils/constants/authViewLayoutChecks.js +13 -0
  38. package/src/lib/utils/functions/generateMessages/index.cjs +11 -2
  39. package/src/lib/utils/functions/generateMessages/index.js +11 -2
  40. package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +27 -1
  41. package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +27 -1
  42. package/src/lib/utils/functions/index.d.ts +0 -1
  43. package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
  44. package/src/lib/utils/hooks/index.d.ts +2 -0
  45. package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.cjs +5 -1
  46. package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.js +5 -1
  47. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +35 -5
  48. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +1 -0
  49. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +35 -5
  50. package/src/lib/utils/hooks/useFunding/useFunding.d.ts +1 -0
  51. package/src/lib/utils/hooks/useOnramp/useOnramp.cjs +14 -29
  52. package/src/lib/utils/hooks/useOnramp/useOnramp.d.ts +14 -18
  53. package/src/lib/utils/hooks/useOnramp/useOnramp.js +14 -29
  54. package/src/lib/utils/hooks/usePhantomRedirectEvents/index.d.ts +1 -0
  55. package/src/lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.cjs +65 -0
  56. package/src/lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.d.ts +36 -0
  57. package/src/lib/utils/hooks/usePhantomRedirectEvents/usePhantomRedirectEvents.js +61 -0
  58. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +17 -14
  59. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +17 -14
  60. package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.cjs +106 -1
  61. package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.js +106 -1
  62. package/src/lib/utils/hooks/useSmartWallets/useSmartWallets.cjs +1 -1
  63. package/src/lib/utils/hooks/useSmartWallets/useSmartWallets.js +1 -1
  64. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +1 -1
  65. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +1 -1
  66. package/src/lib/utils/hooks/useWalletBackup/index.d.ts +1 -0
  67. package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.cjs +339 -0
  68. package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.d.ts +49 -0
  69. package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.js +332 -0
  70. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +2 -2
  71. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +2 -2
  72. package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +1 -0
  73. package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +1 -0
  74. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +13 -0
  75. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +14 -1
  76. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +9 -6
  77. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +9 -6
  78. package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.cjs +13 -0
  79. package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.js +14 -1
  80. package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -0
  81. package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -0
  82. package/src/lib/views/viewToComponentMap.cjs +15 -3
  83. package/src/lib/views/viewToComponentMap.d.ts +6 -0
  84. package/src/lib/views/viewToComponentMap.js +15 -3
  85. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.cjs +1 -1
  86. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.js +1 -1
  87. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +97 -3
  88. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +97 -3
  89. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +16 -14
  90. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +16 -14
  91. package/src/lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs +3 -1
  92. package/src/lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.d.ts +1 -0
  93. package/src/lib/widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js +3 -1
  94. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/BackupStepper.cjs +37 -0
  95. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/BackupStepper.d.ts +7 -0
  96. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/BackupStepper.js +33 -0
  97. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.cjs +49 -0
  98. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.d.ts +2 -0
  99. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.js +45 -0
  100. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.cjs +53 -0
  101. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.d.ts +2 -0
  102. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.js +49 -0
  103. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.cjs +9 -18
  104. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.js +10 -19
  105. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.cjs +52 -0
  106. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.d.ts +2 -0
  107. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.js +48 -0
  108. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.cjs +131 -0
  109. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.d.ts +5 -0
  110. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.js +127 -0
  111. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.cjs +45 -104
  112. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.js +47 -106
  113. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/index.d.ts +6 -1
  114. package/src/lib/utils/functions/downloadFile/downloadFile.cjs +0 -15
  115. package/src/lib/utils/functions/downloadFile/downloadFile.d.ts +0 -1
  116. package/src/lib/utils/functions/downloadFile/downloadFile.js +0 -11
  117. package/src/lib/utils/functions/downloadFile/index.d.ts +0 -1
@@ -0,0 +1,332 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
+ import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
4
+ import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
5
+ import '@dynamic-labs-sdk/client/core';
6
+ import '../../../client/client.js';
7
+ import '@dynamic-labs-sdk/client';
8
+ import '../../../config/ApiEndpoint.js';
9
+ import '@dynamic-labs/iconic';
10
+ import '@dynamic-labs/wallet-connector-core';
11
+ import 'react/jsx-runtime';
12
+ import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
13
+ import { logger } from '../../../shared/logger.js';
14
+ import '@dynamic-labs/wallet-book';
15
+ import '@dynamic-labs/utils';
16
+ import '../../constants/colors.js';
17
+ import { VerifiedCredentialNameToChainEnum } from '../../constants/values.js';
18
+ import '../../../shared/consts/index.js';
19
+ import { USER_NOT_LOGGED_IN } from '../../constants/errors.js';
20
+ import '@dynamic-labs/multi-wallet';
21
+ import 'react-international-phone';
22
+ import '../../../store/state/nonce/nonce.js';
23
+ import '@dynamic-labs/locale';
24
+ import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
25
+ import '../../../store/state/primaryWalletId/primaryWalletId.js';
26
+ import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
27
+ import '../../../events/dynamicEvents.js';
28
+ import { useUser } from '../../../client/extension/user/useUser/useUser.js';
29
+ import '../../../context/DynamicContext/DynamicContext.js';
30
+ import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
31
+ import '../../../context/CaptchaContext/CaptchaContext.js';
32
+ import '../../../context/ErrorContext/ErrorContext.js';
33
+ import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
34
+ import '../../../context/AccountExistsContext/AccountExistsContext.js';
35
+ import '../../../context/UserWalletsContext/UserWalletsContext.js';
36
+ import '../../../store/state/authMode/authMode.js';
37
+ import '../../../context/VerificationContext/VerificationContext.js';
38
+ import 'react-dom';
39
+ import '../../functions/compareChains/compareChains.js';
40
+ import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
41
+ import '../../../context/ThemeContext/ThemeContext.js';
42
+ import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
43
+ import 'bs58';
44
+ import { useSocialAccounts } from '../useSocialAccounts/useSocialAccounts.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/walletOptions/walletOptions.js';
52
+ import 'react-i18next';
53
+ import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
54
+ import '../../../components/Alert/Alert.js';
55
+ import '../../../context/WalletContext/WalletContext.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 '../useSubdomainCheck/useSubdomainCheck.js';
73
+ import '../../../context/WalletGroupContext/WalletGroupContext.js';
74
+ import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
75
+ import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
76
+ import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
77
+ import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
78
+ import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
79
+ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
80
+ import '@hcaptcha/react-hcaptcha';
81
+ import '../../../context/LoadingContext/LoadingContext.js';
82
+ import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
83
+ import '../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
84
+ import '../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
85
+ import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
86
+ import '../../../context/FooterAnimationContext/index.js';
87
+ import '@dynamic-labs/types';
88
+ import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
89
+ import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
90
+ import '../../../context/PasskeyContext/PasskeyContext.js';
91
+ import '../../../context/OnrampContext/OnrampContext.js';
92
+ import '../../../store/state/sendBalances.js';
93
+ import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
94
+ import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
95
+ import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
96
+ import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
97
+ import '../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
98
+ import '../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
99
+ import '../../../../index.js';
100
+ import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
101
+ import '../../../store/state/tokenBalances.js';
102
+ import '../../../store/state/multichainBalances.js';
103
+ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
104
+ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
105
+
106
+ const isWalletBackedUp = (cred) => {
107
+ var _a;
108
+ const keyShares = (_a = cred.walletProperties) === null || _a === void 0 ? void 0 : _a.keyShares;
109
+ if (!keyShares || !Array.isArray(keyShares))
110
+ return false;
111
+ return keyShares.some((keyShare) => keyShare &&
112
+ typeof keyShare === 'object' &&
113
+ 'backupLocation' in keyShare &&
114
+ keyShare.backupLocation === 'googleDrive');
115
+ };
116
+ const useWalletBackup = () => {
117
+ const { setShowAuthFlow } = useInternalDynamicContext();
118
+ const { pushView } = useViewContext();
119
+ const user = useUser();
120
+ const refresh = useRefreshUser();
121
+ const { getWaasWalletConnector, getWaasWalletsByCredentials } = useDynamicWaas();
122
+ const { linkSocialAccount, isLinked } = useSocialAccounts();
123
+ const isGoogleLinked = useMemo(() => isLinked(ProviderEnum.Google), [isLinked]);
124
+ const [backupState, setBackupState] = useState({
125
+ currentIndex: 0,
126
+ failedIndex: null,
127
+ hasError: false,
128
+ isComplete: false,
129
+ isProcessing: false,
130
+ totalWallets: 0,
131
+ });
132
+ const timeoutRef = useRef(null);
133
+ useEffect(() => () => {
134
+ if (timeoutRef.current) {
135
+ clearTimeout(timeoutRef.current);
136
+ }
137
+ }, []);
138
+ const getWalletsBackupStatus = useCallback(() => getWaasWalletsByCredentials().map((cred) => ({
139
+ address: cred.address,
140
+ chain: VerifiedCredentialNameToChainEnum[cred.chain],
141
+ status: isWalletBackedUp(cred) ? 'backed-up' : 'pending',
142
+ })), [getWaasWalletsByCredentials]);
143
+ const getWalletsToBackup = useCallback(() => getWalletsBackupStatus()
144
+ .filter((wallet) => wallet.status === 'pending')
145
+ .map(({ address, chain }) => ({ address, chain })), [getWalletsBackupStatus]);
146
+ const areAllWalletsBackedUp = useMemo(() => {
147
+ const statuses = getWalletsBackupStatus();
148
+ return (statuses.length > 0 && statuses.every((w) => w.status === 'backed-up'));
149
+ }, [getWalletsBackupStatus]);
150
+ const ensureGoogleLinked = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
151
+ var _a;
152
+ if (isGoogleLinked) {
153
+ return true;
154
+ }
155
+ try {
156
+ yield linkSocialAccount(ProviderEnum.Google, {
157
+ forcePopup: true,
158
+ showWidgetAfterConnection: false,
159
+ });
160
+ const updatedUser = yield refresh();
161
+ const isGoogleLinkedAfterRefresh = (_a = updatedUser === null || updatedUser === void 0 ? void 0 : updatedUser.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.some((cred) => cred.format === 'oauth' && cred.oauthProvider === ProviderEnum.Google);
162
+ return Boolean(isGoogleLinkedAfterRefresh);
163
+ }
164
+ catch (error) {
165
+ logger.warn('Error linking Google account for backup', { error });
166
+ return false;
167
+ }
168
+ }), [isGoogleLinked, linkSocialAccount, refresh]);
169
+ const backupWallet = useCallback((walletToBackup) => __awaiter(void 0, void 0, void 0, function* () {
170
+ try {
171
+ const waasConnector = getWaasWalletConnector(walletToBackup.chain);
172
+ if (!waasConnector) {
173
+ logger.warn('No WaaS connector found for wallet', {
174
+ address: walletToBackup.address,
175
+ });
176
+ return false;
177
+ }
178
+ yield waasConnector.backupKeySharesToGoogleDrive({
179
+ accountAddress: walletToBackup.address,
180
+ });
181
+ return true;
182
+ }
183
+ catch (error) {
184
+ logger.warn('Error backing up wallet', {
185
+ address: walletToBackup.address,
186
+ error,
187
+ });
188
+ return false;
189
+ }
190
+ }), [getWaasWalletConnector]);
191
+ const backupAllWallets = useCallback((wallets) => __awaiter(void 0, void 0, void 0, function* () {
192
+ const walletsToProcess = wallets !== null && wallets !== void 0 ? wallets : getWalletsToBackup();
193
+ for (const wallet of walletsToProcess) {
194
+ yield backupWallet(wallet);
195
+ }
196
+ yield refresh();
197
+ }), [getWalletsToBackup, backupWallet, refresh]);
198
+ const startBackup = useCallback((onComplete_1, ...args_1) => __awaiter(void 0, [onComplete_1, ...args_1], void 0, function* (onComplete, fromIndex = 0) {
199
+ if (timeoutRef.current) {
200
+ clearTimeout(timeoutRef.current);
201
+ timeoutRef.current = null;
202
+ }
203
+ const walletsToBackup = getWalletsToBackup();
204
+ if (walletsToBackup.length === 0) {
205
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
206
+ return;
207
+ }
208
+ setBackupState((prev) => (Object.assign(Object.assign({}, prev), { failedIndex: null, hasError: false, isProcessing: true, totalWallets: walletsToBackup.length })));
209
+ for (let i = fromIndex; i < walletsToBackup.length; i++) {
210
+ setBackupState((prev) => (Object.assign(Object.assign({}, prev), { currentIndex: i + 1 })));
211
+ const success = yield backupWallet(walletsToBackup[i]);
212
+ if (!success) {
213
+ setBackupState((prev) => (Object.assign(Object.assign({}, prev), { failedIndex: i, hasError: true, isProcessing: false })));
214
+ return;
215
+ }
216
+ }
217
+ yield refresh();
218
+ setBackupState((prev) => (Object.assign(Object.assign({}, prev), { isComplete: true, isProcessing: false })));
219
+ if (onComplete) {
220
+ timeoutRef.current = setTimeout(onComplete, 1000);
221
+ }
222
+ }), [getWalletsToBackup, backupWallet, refresh]);
223
+ const initBackupProcess = useCallback(() => {
224
+ if (!user) {
225
+ throw new Error(USER_NOT_LOGGED_IN);
226
+ }
227
+ setShowAuthFlow(true, {
228
+ ignoreIfIsEmbeddedWidget: false,
229
+ performMultiWalletChecks: false,
230
+ });
231
+ pushView('waas-backup-progress-view');
232
+ }, [setShowAuthFlow, pushView, user]);
233
+ return {
234
+ areAllWalletsBackedUp,
235
+ backupAllWallets,
236
+ backupState,
237
+ backupWallet,
238
+ ensureGoogleLinked,
239
+ getWalletsBackupStatus,
240
+ getWalletsToBackup,
241
+ initBackupProcess,
242
+ isGoogleLinked,
243
+ startBackup,
244
+ };
245
+ };
246
+ const useBackupWallets = (onComplete) => {
247
+ const { backupState, startBackup } = useWalletBackup();
248
+ const hasStartedRef = useRef(false);
249
+ const onCompleteRef = useRef(onComplete);
250
+ onCompleteRef.current = onComplete;
251
+ useEffect(() => {
252
+ if (hasStartedRef.current)
253
+ return;
254
+ hasStartedRef.current = true;
255
+ startBackup(() => onCompleteRef.current());
256
+ }, [startBackup]);
257
+ const retry = useCallback(() => {
258
+ var _a;
259
+ const fromIndex = (_a = backupState.failedIndex) !== null && _a !== void 0 ? _a : 0;
260
+ startBackup(() => onCompleteRef.current(), fromIndex);
261
+ }, [startBackup, backupState.failedIndex]);
262
+ return Object.assign(Object.assign({}, backupState), { retry });
263
+ };
264
+ const useDownloadKeyShares = (onComplete) => {
265
+ const { getWaasWalletConnector, getWaasWalletsByCredentials } = useDynamicWaas();
266
+ const [downloadState, setDownloadState] = useState({
267
+ currentIndex: 0,
268
+ failedIndex: null,
269
+ hasError: false,
270
+ isComplete: false,
271
+ isProcessing: false,
272
+ totalWallets: 0,
273
+ });
274
+ const hasStartedRef = useRef(false);
275
+ const onCompleteRef = useRef(onComplete);
276
+ onCompleteRef.current = onComplete;
277
+ const walletsToDownload = useMemo(() => getWaasWalletsByCredentials().map((cred) => ({
278
+ address: cred.address,
279
+ chain: VerifiedCredentialNameToChainEnum[cred.chain],
280
+ })), [getWaasWalletsByCredentials]);
281
+ const downloadKeyShare = useCallback((walletToDownload) => __awaiter(void 0, void 0, void 0, function* () {
282
+ try {
283
+ const waasConnector = getWaasWalletConnector(walletToDownload.chain);
284
+ if (!waasConnector) {
285
+ logger.warn('No WaaS connector found for wallet', {
286
+ address: walletToDownload.address,
287
+ });
288
+ return false;
289
+ }
290
+ yield waasConnector.exportClientKeyshares({
291
+ accountAddress: walletToDownload.address,
292
+ });
293
+ return true;
294
+ }
295
+ catch (error) {
296
+ logger.warn('Error downloading key share', {
297
+ address: walletToDownload.address,
298
+ error,
299
+ });
300
+ return false;
301
+ }
302
+ }), [getWaasWalletConnector]);
303
+ const startDownload = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (fromIndex = 0) {
304
+ if (hasStartedRef.current || walletsToDownload.length === 0)
305
+ return;
306
+ hasStartedRef.current = true;
307
+ setDownloadState((prev) => (Object.assign(Object.assign({}, prev), { currentIndex: fromIndex, failedIndex: null, hasError: false, isComplete: false, isProcessing: true, totalWallets: walletsToDownload.length })));
308
+ for (let i = fromIndex; i < walletsToDownload.length; i++) {
309
+ setDownloadState((prev) => (Object.assign(Object.assign({}, prev), { currentIndex: i + 1 })));
310
+ const success = yield downloadKeyShare(walletsToDownload[i]);
311
+ if (!success) {
312
+ setDownloadState((prev) => (Object.assign(Object.assign({}, prev), { failedIndex: i, hasError: true, isProcessing: false })));
313
+ hasStartedRef.current = false;
314
+ return;
315
+ }
316
+ }
317
+ setDownloadState((prev) => (Object.assign(Object.assign({}, prev), { isComplete: true, isProcessing: false })));
318
+ hasStartedRef.current = false;
319
+ if (onCompleteRef.current) {
320
+ const count = walletsToDownload.length;
321
+ setTimeout(() => { var _a; return (_a = onCompleteRef.current) === null || _a === void 0 ? void 0 : _a.call(onCompleteRef, count); }, 500);
322
+ }
323
+ }), [walletsToDownload, downloadKeyShare]);
324
+ const retry = useCallback(() => {
325
+ var _a;
326
+ const fromIndex = (_a = downloadState.failedIndex) !== null && _a !== void 0 ? _a : 0;
327
+ startDownload(fromIndex);
328
+ }, [startDownload, downloadState.failedIndex]);
329
+ return Object.assign(Object.assign({}, downloadState), { retry, startDownload: () => startDownload(0) });
330
+ };
331
+
332
+ export { isWalletBackedUp, useBackupWallets, useDownloadKeyShares, useWalletBackup };
@@ -80,6 +80,8 @@ require('qrcode');
80
80
  require('formik');
81
81
  require('../useSubdomainCheck/useSubdomainCheck.cjs');
82
82
  require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
83
+ var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
84
+ var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
83
85
  require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
84
86
  require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
85
87
  require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
@@ -93,8 +95,6 @@ require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cj
93
95
  require('../../../context/PasskeyContext/PasskeyContext.cjs');
94
96
  require('../../../context/OnrampContext/OnrampContext.cjs');
95
97
  var waas = require('../../../data/api/waas/waas.cjs');
96
- var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
97
- var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
98
98
  require('../../../store/state/sendBalances.cjs');
99
99
  require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
100
100
  require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
@@ -76,6 +76,8 @@ import 'qrcode';
76
76
  import 'formik';
77
77
  import '../useSubdomainCheck/useSubdomainCheck.js';
78
78
  import '../../../context/WalletGroupContext/WalletGroupContext.js';
79
+ import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
80
+ import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
79
81
  import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
80
82
  import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
81
83
  import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
@@ -89,8 +91,6 @@ import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js'
89
91
  import '../../../context/PasskeyContext/PasskeyContext.js';
90
92
  import '../../../context/OnrampContext/OnrampContext.js';
91
93
  import { updateWaasWalletSettings } from '../../../data/api/waas/waas.js';
92
- import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
93
- import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
94
94
  import '../../../store/state/sendBalances.js';
95
95
  import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
96
96
  import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
@@ -141,6 +141,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
141
141
  // Check method handleUserResponse in file useResponseHandlers, case 'signMessage'.
142
142
  if (walletConnector.key === 'phantom') {
143
143
  const currentState = utils.StorageService.getItem(localStorage.PHANTOM_SIGNATURE_STATE);
144
+ logger.logger.logVerboseTroubleshootingMessage('[useHandleWalletItem] Setting PHANTOM_SIGNATURE_STATE to awaiting_verification', { currentState });
144
145
  utils.StorageService.setItem(localStorage.PHANTOM_SIGNATURE_STATE, {
145
146
  loseOriginalAccountOnTransfer: (_a = currentState === null || currentState === void 0 ? void 0 : currentState.loseOriginalAccountOnTransfer) !== null && _a !== void 0 ? _a : false,
146
147
  submittedAtTimestamp: new Date().toString(),
@@ -137,6 +137,7 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
137
137
  // Check method handleUserResponse in file useResponseHandlers, case 'signMessage'.
138
138
  if (walletConnector.key === 'phantom') {
139
139
  const currentState = StorageService.getItem(PHANTOM_SIGNATURE_STATE);
140
+ logger.logVerboseTroubleshootingMessage('[useHandleWalletItem] Setting PHANTOM_SIGNATURE_STATE to awaiting_verification', { currentState });
140
141
  StorageService.setItem(PHANTOM_SIGNATURE_STATE, {
141
142
  loseOriginalAccountOnTransfer: (_a = currentState === null || currentState === void 0 ? void 0 : currentState.loseOriginalAccountOnTransfer) !== null && _a !== void 0 ? _a : false,
142
143
  submittedAtTimestamp: new Date().toString(),
@@ -200,6 +200,19 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
200
200
  }, [error, pushView, user]);
201
201
  const { t } = reactI18next.useTranslation();
202
202
  const hasInjectedCredential = !isLoading && data && !error;
203
+ // Track successful reveal for emitting event on unmount
204
+ const revealedWalletRef = React.useRef(null);
205
+ React.useEffect(() => {
206
+ if (hasInjectedCredential && wallet) {
207
+ revealedWalletRef.current = wallet;
208
+ }
209
+ }, [hasInjectedCredential, wallet]);
210
+ // Emit success event when user exits the screen after successful reveal
211
+ React.useEffect(() => () => {
212
+ if (revealedWalletRef.current) {
213
+ dynamicEvents.dynamicEvents.emit('embeddedWalletRevealCompleted', revealedWalletRef.current);
214
+ }
215
+ }, []);
203
216
  const credentialTitle = !isTurnkeyHDWallet || exportPrivateKey
204
217
  ? t('dyn_embedded_reveal.private_key_title')
205
218
  : t('dyn_embedded_reveal.recovery_phrase_title');
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { useState, useEffect, useMemo } from 'react';
3
+ import { useState, useEffect, useMemo, useRef } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { DynamicError, AccessBlockedError } from '@dynamic-labs/utils';
6
6
  import { Badge } from '../../../components/Badge/Badge.js';
@@ -196,6 +196,19 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
196
196
  }, [error, pushView, user]);
197
197
  const { t } = useTranslation();
198
198
  const hasInjectedCredential = !isLoading && data && !error;
199
+ // Track successful reveal for emitting event on unmount
200
+ const revealedWalletRef = useRef(null);
201
+ useEffect(() => {
202
+ if (hasInjectedCredential && wallet) {
203
+ revealedWalletRef.current = wallet;
204
+ }
205
+ }, [hasInjectedCredential, wallet]);
206
+ // Emit success event when user exits the screen after successful reveal
207
+ useEffect(() => () => {
208
+ if (revealedWalletRef.current) {
209
+ dynamicEvents.emit('embeddedWalletRevealCompleted', revealedWalletRef.current);
210
+ }
211
+ }, []);
199
212
  const credentialTitle = !isTurnkeyHDWallet || exportPrivateKey
200
213
  ? t('dyn_embedded_reveal.private_key_title')
201
214
  : t('dyn_embedded_reveal.recovery_phrase_title');
@@ -7,7 +7,7 @@ var _tslib = require('../../../../_virtual/_tslib.cjs');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
  var React = require('react');
9
9
  var reactI18next = require('react-i18next');
10
- require('@dynamic-labs/utils');
10
+ var utils = require('@dynamic-labs/utils');
11
11
  require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
12
12
  var copy = require('../../shared/assets/copy.cjs');
13
13
  var download = require('../../shared/assets/download.cjs');
@@ -32,7 +32,6 @@ require('../../context/ErrorContext/ErrorContext.cjs');
32
32
  require('@dynamic-labs/multi-wallet');
33
33
  require('react-international-phone');
34
34
  require('../../store/state/nonce/nonce.cjs');
35
- var downloadFile = require('../../utils/functions/downloadFile/downloadFile.cjs');
36
35
  require('@dynamic-labs-sdk/client/core');
37
36
  require('../../client/client.cjs');
38
37
  require('@dynamic-labs-sdk/client');
@@ -124,12 +123,16 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
124
123
  setShowAuthFlow(false);
125
124
  yield completeAcknowledgement();
126
125
  });
126
+ const handleDownload = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
127
+ e.preventDefault();
128
+ const file = new Blob([codesAsString], {
129
+ type: 'text/plain',
130
+ });
131
+ yield utils.PlatformService.downloadFile('mfa-backup-codes.txt', file);
132
+ });
127
133
  return (jsxRuntime.jsxs("div", { className: 'mfa-display-backup-codes-view__body', "data-testid": 'mfa-display-backup-codes-view', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mfa-display-backup-codes-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_mfa.display_backup_codes_view.body', children: t('dyn_mfa.display_backup_codes_view.body') }), jsxRuntime.jsx(Alert.Alert, { variant: 'warning', copykey: 'dyn_mfa.display_backup_codes_view.warning', className: 'mfa-display-backup-codes-view__warning', children: t('dyn_mfa.display_backup_codes_view.warning') }), isLoading ? (jsxRuntime.jsx(spinner.Spinner, { className: 'mfa-display-backup-codes-view__loading-spinner' })) : (jsxRuntime.jsxs("div", { className: 'mfa-display-backup-codes-view__codes', children: [codes === null || codes === void 0 ? void 0 : codes.map((code, index) => (jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'mfa-display-backup-codes-view__code', children: code }, index))), jsxRuntime.jsxs("div", { className: 'mfa-display-backup-codes-view__actions', children: [jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'button', textToCopy: codesAsString, copykey: 'dyn_mfa.display_backup_codes_view.copy_all', startSlot:
128
134
  // eslint-disable-next-line react/jsx-wrap-multilines
129
- jsxRuntime.jsx(Icon.Icon, { size: 'mini', color: 'text-tertiary', children: jsxRuntime.jsx(copy.ReactComponent, {}) }), children: t('dyn_mfa.display_backup_codes_view.copy_all') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'download-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: (e) => {
130
- e.preventDefault();
131
- downloadFile.downloadFile('mfa-backup-codes.txt', codesAsString);
132
- }, startSlot: jsxRuntime.jsx(download.ReactComponent, {}), expanded: true, copykey: 'dyn_mfa.display_backup_codes_view.download', children: t('dyn_mfa.display_backup_codes_view.download') })] })] })), jsxRuntime.jsxs("div", { className: 'mfa-display-backup-codes-view__complete', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonClassName: 'mfa-display-backup-codes-view__acknowledgement', dataTestId: 'ack-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: () => setAcknowledgement(!acknowledgement), startSlot:
135
+ jsxRuntime.jsx(Icon.Icon, { size: 'mini', color: 'text-tertiary', children: jsxRuntime.jsx(copy.ReactComponent, {}) }), children: t('dyn_mfa.display_backup_codes_view.copy_all') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'download-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: handleDownload, startSlot: jsxRuntime.jsx(download.ReactComponent, {}), expanded: true, copykey: 'dyn_mfa.display_backup_codes_view.download', children: t('dyn_mfa.display_backup_codes_view.download') })] })] })), jsxRuntime.jsxs("div", { className: 'mfa-display-backup-codes-view__complete', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonClassName: 'mfa-display-backup-codes-view__acknowledgement', dataTestId: 'ack-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: () => setAcknowledgement(!acknowledgement), startSlot:
133
136
  // eslint-disable-next-line react/jsx-wrap-multilines
134
137
  jsxRuntime.jsx(Checkbox.Checkbox, { checked: acknowledgement, onChange: () => {
135
138
  setAcknowledgement(!acknowledgement);
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
- import '@dynamic-labs/utils';
6
+ import { PlatformService } from '@dynamic-labs/utils';
7
7
  import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
8
8
  import { ReactComponent as SvgCopy } from '../../shared/assets/copy.js';
9
9
  import { ReactComponent as SvgDownload } from '../../shared/assets/download.js';
@@ -28,7 +28,6 @@ import '../../context/ErrorContext/ErrorContext.js';
28
28
  import '@dynamic-labs/multi-wallet';
29
29
  import 'react-international-phone';
30
30
  import '../../store/state/nonce/nonce.js';
31
- import { downloadFile } from '../../utils/functions/downloadFile/downloadFile.js';
32
31
  import '@dynamic-labs-sdk/client/core';
33
32
  import '../../client/client.js';
34
33
  import '@dynamic-labs-sdk/client';
@@ -120,12 +119,16 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
120
119
  setShowAuthFlow(false);
121
120
  yield completeAcknowledgement();
122
121
  });
122
+ const handleDownload = (e) => __awaiter(void 0, void 0, void 0, function* () {
123
+ e.preventDefault();
124
+ const file = new Blob([codesAsString], {
125
+ type: 'text/plain',
126
+ });
127
+ yield PlatformService.downloadFile('mfa-backup-codes.txt', file);
128
+ });
123
129
  return (jsxs("div", { className: 'mfa-display-backup-codes-view__body', "data-testid": 'mfa-display-backup-codes-view', children: [jsx(Typography, { className: 'mfa-display-backup-codes-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_mfa.display_backup_codes_view.body', children: t('dyn_mfa.display_backup_codes_view.body') }), jsx(Alert, { variant: 'warning', copykey: 'dyn_mfa.display_backup_codes_view.warning', className: 'mfa-display-backup-codes-view__warning', children: t('dyn_mfa.display_backup_codes_view.warning') }), isLoading ? (jsx(Spinner, { className: 'mfa-display-backup-codes-view__loading-spinner' })) : (jsxs("div", { className: 'mfa-display-backup-codes-view__codes', children: [codes === null || codes === void 0 ? void 0 : codes.map((code, index) => (jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'mfa-display-backup-codes-view__code', children: code }, index))), jsxs("div", { className: 'mfa-display-backup-codes-view__actions', children: [jsx(CopyButton, { variant: 'button', textToCopy: codesAsString, copykey: 'dyn_mfa.display_backup_codes_view.copy_all', startSlot:
124
130
  // eslint-disable-next-line react/jsx-wrap-multilines
125
- jsx(Icon, { size: 'mini', color: 'text-tertiary', children: jsx(SvgCopy, {}) }), children: t('dyn_mfa.display_backup_codes_view.copy_all') }), jsx(TypographyButton, { dataTestId: 'download-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: (e) => {
126
- e.preventDefault();
127
- downloadFile('mfa-backup-codes.txt', codesAsString);
128
- }, startSlot: jsx(SvgDownload, {}), expanded: true, copykey: 'dyn_mfa.display_backup_codes_view.download', children: t('dyn_mfa.display_backup_codes_view.download') })] })] })), jsxs("div", { className: 'mfa-display-backup-codes-view__complete', children: [jsx(TypographyButton, { buttonClassName: 'mfa-display-backup-codes-view__acknowledgement', dataTestId: 'ack-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: () => setAcknowledgement(!acknowledgement), startSlot:
131
+ jsx(Icon, { size: 'mini', color: 'text-tertiary', children: jsx(SvgCopy, {}) }), children: t('dyn_mfa.display_backup_codes_view.copy_all') }), jsx(TypographyButton, { dataTestId: 'download-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: handleDownload, startSlot: jsx(SvgDownload, {}), expanded: true, copykey: 'dyn_mfa.display_backup_codes_view.download', children: t('dyn_mfa.display_backup_codes_view.download') })] })] })), jsxs("div", { className: 'mfa-display-backup-codes-view__complete', children: [jsx(TypographyButton, { buttonClassName: 'mfa-display-backup-codes-view__acknowledgement', dataTestId: 'ack-button', buttonPadding: 'small', buttonVariant: 'primary', onClick: () => setAcknowledgement(!acknowledgement), startSlot:
129
132
  // eslint-disable-next-line react/jsx-wrap-multilines
130
133
  jsx(Checkbox, { checked: acknowledgement, onChange: () => {
131
134
  setAcknowledgement(!acknowledgement);
@@ -147,6 +147,19 @@ const WalletUpgradeFlowView = ({ wallets, method, onComplete, onCancel, }) => {
147
147
  dynamicEvents.dynamicEvents.emit('embeddedWalletRevealFailed', err);
148
148
  },
149
149
  });
150
+ // Track successful export for emitting event on unmount
151
+ const revealedWalletRef = React.useRef(null);
152
+ React.useEffect(() => {
153
+ if (exportData && wallets[currentWalletIndex]) {
154
+ revealedWalletRef.current = wallets[currentWalletIndex];
155
+ }
156
+ }, [exportData, wallets, currentWalletIndex]);
157
+ // Emit success event when user exits the screen after successful reveal
158
+ React.useEffect(() => () => {
159
+ if (revealedWalletRef.current) {
160
+ dynamicEvents.dynamicEvents.emit('embeddedWalletRevealCompleted', revealedWalletRef.current);
161
+ }
162
+ }, []);
150
163
  const { mutate: handleUpgradeWallet, isLoading: isUpgrading, error: upgradeError, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
151
164
  if (!privateKeyInput.trim()) {
152
165
  throw new utils.DynamicError('Private key is required');
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../_virtual/_tslib.js';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
- import { useState } from 'react';
4
+ import { useState, useRef, useEffect } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { DynamicError } from '@dynamic-labs/utils';
7
7
  import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
@@ -143,6 +143,19 @@ const WalletUpgradeFlowView = ({ wallets, method, onComplete, onCancel, }) => {
143
143
  dynamicEvents.emit('embeddedWalletRevealFailed', err);
144
144
  },
145
145
  });
146
+ // Track successful export for emitting event on unmount
147
+ const revealedWalletRef = useRef(null);
148
+ useEffect(() => {
149
+ if (exportData && wallets[currentWalletIndex]) {
150
+ revealedWalletRef.current = wallets[currentWalletIndex];
151
+ }
152
+ }, [exportData, wallets, currentWalletIndex]);
153
+ // Emit success event when user exits the screen after successful reveal
154
+ useEffect(() => () => {
155
+ if (revealedWalletRef.current) {
156
+ dynamicEvents.emit('embeddedWalletRevealCompleted', revealedWalletRef.current);
157
+ }
158
+ }, []);
146
159
  const { mutate: handleUpgradeWallet, isLoading: isUpgrading, error: upgradeError, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
147
160
  if (!privateKeyInput.trim()) {
148
161
  throw new DynamicError('Private key is required');
@@ -145,6 +145,7 @@ const WalletUsedView = () => {
145
145
  // is a signature, authentication or transfer.
146
146
  // Check method handleUserResponse in file useResponseHandlers, case 'signMessage'.
147
147
  if (walletConnector.key === 'phantom' && utils.isMobile()) {
148
+ logger.logger.logVerboseTroubleshootingMessage('[WalletUsedView handleWalletTransfer] Setting PHANTOM_SIGNATURE_STATE to awaiting_transfer', { isChecked });
148
149
  utils.StorageService.setItem(localStorage.PHANTOM_SIGNATURE_STATE, {
149
150
  loseOriginalAccountOnTransfer: isChecked,
150
151
  submittedAtTimestamp: new Date().toString(),
@@ -141,6 +141,7 @@ const WalletUsedView = () => {
141
141
  // is a signature, authentication or transfer.
142
142
  // Check method handleUserResponse in file useResponseHandlers, case 'signMessage'.
143
143
  if (walletConnector.key === 'phantom' && isMobile()) {
144
+ logger.logVerboseTroubleshootingMessage('[WalletUsedView handleWalletTransfer] Setting PHANTOM_SIGNATURE_STATE to awaiting_transfer', { isChecked });
144
145
  StorageService.setItem(PHANTOM_SIGNATURE_STATE, {
145
146
  loseOriginalAccountOnTransfer: isChecked,
146
147
  submittedAtTimestamp: new Date().toString(),
@@ -4,6 +4,15 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ require('react');
8
+ require('@dynamic-labs/iconic');
9
+ require('../context/ViewContext/ViewContext.cjs');
10
+ var WaasBackupCloudProviderView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.cjs');
11
+ var WaasBackupDownloadView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.cjs');
12
+ var WaasBackupInfoView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.cjs');
13
+ var WaasBackupProgressView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.cjs');
14
+ var WaasBackupSuccessView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.cjs');
15
+ var WaasBackupView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.cjs');
7
16
  var AccessBlockedView = require('./AccessBlockedView/AccessBlockedView.cjs');
8
17
  var AccountExistsView = require('./AccountExistsView/AccountExistsView.cjs');
9
18
  var AccountUpgradedView = require('./AccountUpgradedView/AccountUpgradedView.cjs');
@@ -53,9 +62,6 @@ var EmbeddedAuthChoice = require('./Passkey/EmbeddedAuthChoice/EmbeddedAuthChoic
53
62
  require('react-i18next');
54
63
  require('@dynamic-labs/utils');
55
64
  require('../components/Accordion/components/AccordionItem/AccordionItem.cjs');
56
- require('react');
57
- require('@dynamic-labs/iconic');
58
- require('../context/ViewContext/ViewContext.cjs');
59
65
  require('../../../_virtual/_tslib.cjs');
60
66
  require('@dynamic-labs/wallet-connector-core');
61
67
  require('../shared/logger.cjs');
@@ -237,6 +243,12 @@ const viewToComponentMap = {
237
243
  'user-delete-account': UserDeleteAccountView.UserDeleteAccountView,
238
244
  'verify-email': EmailVerification.EmailVerification,
239
245
  'verify-sms': SmsVerification.SmsVerification,
246
+ 'waas-backup-cloud-provider-view': WaasBackupCloudProviderView.WaasBackupCloudProviderView,
247
+ 'waas-backup-download-view': WaasBackupDownloadView.WaasBackupDownloadView,
248
+ 'waas-backup-info-view': WaasBackupInfoView.WaasBackupInfoView,
249
+ 'waas-backup-progress-view': WaasBackupProgressView.WaasBackupProgressView,
250
+ 'waas-backup-success-view': WaasBackupSuccessView.WaasBackupSuccessView,
251
+ 'waas-backup-view': WaasBackupView.WaasBackupView,
240
252
  'waas-upgrade-view': WaasUpgradeView.WaasUpgradeView,
241
253
  'wait-for-email-confirmation-view': EmailConfirmationWaitingView.EmailConfirmationWaitingView,
242
254
  'wallet-cannot-be-transferred': WalletCannotBeTransferredView.WalletCannotBeTransferredView,