@dynamic-labs/sdk-react-core 4.19.6 → 4.19.7

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 (41) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.cjs +2 -1
  3. package/package.js +2 -1
  4. package/package.json +12 -11
  5. package/src/functions.d.ts +1 -0
  6. package/src/lib/client/client.cjs +19 -0
  7. package/src/lib/client/client.d.ts +8 -0
  8. package/src/lib/client/client.js +11 -0
  9. package/src/lib/client/extension/constants.cjs +12 -0
  10. package/src/lib/client/extension/constants.d.ts +5 -0
  11. package/src/lib/client/extension/constants.js +8 -0
  12. package/src/lib/client/extension/index.d.ts +1 -0
  13. package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/MockedFetchError.cjs +14 -0
  14. package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/MockedFetchError.d.ts +4 -0
  15. package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/MockedFetchError.js +10 -0
  16. package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/fetchOverride.cjs +29 -0
  17. package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/fetchOverride.d.ts +7 -0
  18. package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/fetchOverride.js +25 -0
  19. package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/index.d.ts +1 -0
  20. package/src/lib/client/extension/useInitializeSdkClient/index.d.ts +1 -0
  21. package/src/lib/client/extension/useInitializeSdkClient/useInitializeSdkClient.cjs +30 -0
  22. package/src/lib/client/extension/useInitializeSdkClient/useInitializeSdkClient.d.ts +2 -0
  23. package/src/lib/client/extension/useInitializeSdkClient/useInitializeSdkClient.js +26 -0
  24. package/src/lib/client/extension/utils/useClientState/index.d.ts +1 -0
  25. package/src/lib/client/extension/utils/useClientState/useClientState.d.ts +2 -0
  26. package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -0
  27. package/src/lib/context/DynamicContext/DynamicContext.js +3 -0
  28. package/src/lib/styles/index.shadow.cjs +1 -1
  29. package/src/lib/styles/index.shadow.js +1 -1
  30. package/src/lib/utils/functions/getSessionInformation/getSessionInformation.cjs +4 -1
  31. package/src/lib/utils/functions/getSessionInformation/getSessionInformation.js +4 -1
  32. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.cjs +9 -6
  33. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.d.ts +8 -0
  34. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.js +8 -7
  35. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +3 -2
  36. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +4 -3
  37. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +4 -1
  38. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +1 -0
  39. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +4 -1
  40. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +15 -88
  41. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +15 -88
@@ -21,7 +21,10 @@ const getSessionInformationExpiration = (session) => {
21
21
  /** Returns the spending limit of the session in ETH */
22
22
  const getSessionInformationSpendingLimit = (session) => {
23
23
  const { limit } = session.session.feeLimit;
24
- const ethString = (Number(limit) / Math.pow(10, 18)).toFixed(6);
24
+ const formatter = new Intl.NumberFormat(undefined, {
25
+ maximumFractionDigits: 6,
26
+ });
27
+ const ethString = formatter.format(Number(limit) / Math.pow(10, 18));
25
28
  return `~${ethString} ETH`;
26
29
  };
27
30
  /** Exports the session information as a JSON string with a helper to process bigints */
@@ -17,7 +17,10 @@ const getSessionInformationExpiration = (session) => {
17
17
  /** Returns the spending limit of the session in ETH */
18
18
  const getSessionInformationSpendingLimit = (session) => {
19
19
  const { limit } = session.session.feeLimit;
20
- const ethString = (Number(limit) / Math.pow(10, 18)).toFixed(6);
20
+ const formatter = new Intl.NumberFormat(undefined, {
21
+ maximumFractionDigits: 6,
22
+ });
23
+ const ethString = formatter.format(Number(limit) / Math.pow(10, 18));
21
24
  return `~${ethString} ETH`;
22
25
  };
23
26
  /** Exports the session information as a JSON string with a helper to process bigints */
@@ -14,13 +14,16 @@ var loadingAndLifecycle = require('../../../../../store/state/loadingAndLifecycl
14
14
  */
15
15
  const UNSET_TIMEOUT = 5500;
16
16
  const unsetInitialWalletVerificationFlag = () => {
17
- const resolve = () => {
18
- loadingAndLifecycle.setIsInitialWalletVerificationInProgress(false);
17
+ loadingAndLifecycle.setIsInitialWalletVerificationInProgress(false);
18
+ };
19
+ const unsetInitialWalletVerificationFlagWithTimeout = () => {
20
+ const timeout = setTimeout(() => {
21
+ unsetInitialWalletVerificationFlag();
19
22
  clearTimeout(timeout);
20
- dynamicEvents.dynamicEvents.removeListener('walletAdded', resolve);
21
- };
22
- const timeout = setTimeout(resolve, UNSET_TIMEOUT);
23
- dynamicEvents.dynamicEvents.once('walletAdded', resolve);
23
+ dynamicEvents.dynamicEvents.removeListener('walletAdded', unsetInitialWalletVerificationFlag);
24
+ }, UNSET_TIMEOUT);
24
25
  };
25
26
 
27
+ exports.UNSET_TIMEOUT = UNSET_TIMEOUT;
26
28
  exports.unsetInitialWalletVerificationFlag = unsetInitialWalletVerificationFlag;
29
+ exports.unsetInitialWalletVerificationFlagWithTimeout = unsetInitialWalletVerificationFlagWithTimeout;
@@ -1 +1,9 @@
1
+ /**
2
+ * The max time the SDK will wait before unsetting the initial wallet verification flag.
3
+ * If the corresponding walletAdded event is triggered before this timeout, the flag will be unset immediately.
4
+ *
5
+ * See justification for this in comments where it is being called.
6
+ */
7
+ export declare const UNSET_TIMEOUT = 5500;
1
8
  export declare const unsetInitialWalletVerificationFlag: () => void;
9
+ export declare const unsetInitialWalletVerificationFlagWithTimeout: () => void;
@@ -10,13 +10,14 @@ import { setIsInitialWalletVerificationInProgress } from '../../../../../store/s
10
10
  */
11
11
  const UNSET_TIMEOUT = 5500;
12
12
  const unsetInitialWalletVerificationFlag = () => {
13
- const resolve = () => {
14
- setIsInitialWalletVerificationInProgress(false);
13
+ setIsInitialWalletVerificationInProgress(false);
14
+ };
15
+ const unsetInitialWalletVerificationFlagWithTimeout = () => {
16
+ const timeout = setTimeout(() => {
17
+ unsetInitialWalletVerificationFlag();
15
18
  clearTimeout(timeout);
16
- dynamicEvents.removeListener('walletAdded', resolve);
17
- };
18
- const timeout = setTimeout(resolve, UNSET_TIMEOUT);
19
- dynamicEvents.once('walletAdded', resolve);
19
+ dynamicEvents.removeListener('walletAdded', unsetInitialWalletVerificationFlag);
20
+ }, UNSET_TIMEOUT);
20
21
  };
21
22
 
22
- export { unsetInitialWalletVerificationFlag };
23
+ export { UNSET_TIMEOUT, unsetInitialWalletVerificationFlag, unsetInitialWalletVerificationFlagWithTimeout };
@@ -20,7 +20,7 @@ var localStorage = require('../../../constants/localStorage.cjs');
20
20
  require('../../../constants/colors.cjs');
21
21
  require('../../../constants/values.cjs');
22
22
  require('../../../../shared/consts/index.cjs');
23
- require('../../../../events/dynamicEvents.cjs');
23
+ var dynamicEvents = require('../../../../events/dynamicEvents.cjs');
24
24
  var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
25
25
  require('@dynamic-labs/multi-wallet');
26
26
  require('react-international-phone');
@@ -161,6 +161,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
161
161
  // Lock the variable that indicates that the login wallet verification is in progress
162
162
  // Read UserWalletsContext.tsx explanation for more context
163
163
  loadingAndLifecycle.setIsInitialWalletVerificationInProgress(true);
164
+ dynamicEvents.dynamicEvents.once('walletAdded', unsetInitialWalletVerificationFlag.unsetInitialWalletVerificationFlag);
164
165
  yield showPendingConnectView.showPendingConnectView(walletConnector, pushView);
165
166
  if (walletConnectorCore.isEmailWalletConnector(walletConnector)) {
166
167
  if (walletConnectorCore.isEmailOTPWalletConnector(walletConnector)) {
@@ -238,7 +239,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
238
239
  // 2. Add a useEffect somewhere that does primaryWallet.switchNetwork() and depends on primaryWallet
239
240
  // 3. The SDK will enter a broken state. Try signing a message with wagmi.
240
241
  // You can also add a "pause on exception" breakpoint in the debugger and see what happens during verification.
241
- unsetInitialWalletVerificationFlag.unsetInitialWalletVerificationFlag();
242
+ unsetInitialWalletVerificationFlag.unsetInitialWalletVerificationFlagWithTimeout();
242
243
  }
243
244
  });
244
245
  };
@@ -16,7 +16,7 @@ import { LAST_USED_WALLET } from '../../../constants/localStorage.js';
16
16
  import '../../../constants/colors.js';
17
17
  import '../../../constants/values.js';
18
18
  import '../../../../shared/consts/index.js';
19
- import '../../../../events/dynamicEvents.js';
19
+ import { dynamicEvents } from '../../../../events/dynamicEvents.js';
20
20
  import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
21
21
  import '@dynamic-labs/multi-wallet';
22
22
  import 'react-international-phone';
@@ -34,7 +34,7 @@ import { useHandleWalletsToConnect } from '../../useHandleWalletsToConnect/useHa
34
34
  import { useVerifyWallet } from '../../useVerifyWallet/useVerifyWallet.js';
35
35
  import { showPendingConnectView } from '../helpers/showPendingConnectView.js';
36
36
  import { isConnectOnly } from '../helpers/isConnectOnly.js';
37
- import { unsetInitialWalletVerificationFlag } from './unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.js';
37
+ import { unsetInitialWalletVerificationFlag, unsetInitialWalletVerificationFlagWithTimeout } from './unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.js';
38
38
  import '../../../../context/VerificationContext/VerificationContext.js';
39
39
  import 'react-dom';
40
40
  import '../../../functions/compareChains/compareChains.js';
@@ -157,6 +157,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
157
157
  // Lock the variable that indicates that the login wallet verification is in progress
158
158
  // Read UserWalletsContext.tsx explanation for more context
159
159
  setIsInitialWalletVerificationInProgress(true);
160
+ dynamicEvents.once('walletAdded', unsetInitialWalletVerificationFlag);
160
161
  yield showPendingConnectView(walletConnector, pushView);
161
162
  if (isEmailWalletConnector(walletConnector)) {
162
163
  if (isEmailOTPWalletConnector(walletConnector)) {
@@ -234,7 +235,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
234
235
  // 2. Add a useEffect somewhere that does primaryWallet.switchNetwork() and depends on primaryWallet
235
236
  // 3. The SDK will enter a broken state. Try signing a message with wagmi.
236
237
  // You can also add a "pause on exception" breakpoint in the debugger and see what happens during verification.
237
- unsetInitialWalletVerificationFlag();
238
+ unsetInitialWalletVerificationFlagWithTimeout();
238
239
  }
239
240
  });
240
241
  };
@@ -7,6 +7,7 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
8
  var sdkApiCore = require('@dynamic-labs/sdk-api-core');
9
9
  var utils = require('@dynamic-labs/utils');
10
+ var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
10
11
  require('../../constants/values.cjs');
11
12
  require('@dynamic-labs/multi-wallet');
12
13
  var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
@@ -36,7 +37,6 @@ require('../../../context/CaptchaContext/CaptchaContext.cjs');
36
37
  require('../../../context/ErrorContext/ErrorContext.cjs');
37
38
  require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
38
39
  require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
39
- require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
40
40
  require('../../../config/ApiEndpoint.cjs');
41
41
  require('../../../locale/locale.cjs');
42
42
  require('../../../store/state/authMode/authMode.cjs');
@@ -122,6 +122,7 @@ const useDynamicWaas = () => {
122
122
  const walletConnectorOptions = walletOptions.useWalletConnectorOptions();
123
123
  const refresh = useRefreshUser.useRefreshUser();
124
124
  const relayUrl = (_b = (_a = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
125
+ const userWallets = UserWalletsContext.useUserWallets();
125
126
  const embeddedWalletSettings = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.embeddedWallets;
126
127
  const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
127
128
  const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
@@ -225,9 +226,11 @@ const useDynamicWaas = () => {
225
226
  });
226
227
  yield refresh();
227
228
  });
229
+ const getWaasWallets = React.useCallback(() => userWallets.filter((w) => w.key === 'dynamicwaas'), [userWallets]);
228
230
  return {
229
231
  createWalletAccount,
230
232
  dynamicWaasIsEnabled,
233
+ getWaasWallets,
231
234
  getWalletConnector,
232
235
  importPrivateKey,
233
236
  shouldAutoCreateDynamicWaasWallet,
@@ -14,6 +14,7 @@ export declare const useDynamicWaas: () => {
14
14
  rawPublicKey: string | Uint8Array | undefined;
15
15
  } | undefined)[]>;
16
16
  dynamicWaasIsEnabled: boolean;
17
+ getWaasWallets: () => import("@dynamic-labs/wallet-connector-core").Wallet<import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector>[];
17
18
  getWalletConnector: (chainName: string) => IDynamicWaasConnector | undefined;
18
19
  importPrivateKey: ({ chainName, privateKey, }: {
19
20
  chainName: string;
@@ -3,6 +3,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useCallback, useMemo } from 'react';
4
4
  import { EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
5
5
  import { DynamicError } from '@dynamic-labs/utils';
6
+ import { useUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
6
7
  import '../../constants/values.js';
7
8
  import '@dynamic-labs/multi-wallet';
8
9
  import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
@@ -32,7 +33,6 @@ import '../../../context/CaptchaContext/CaptchaContext.js';
32
33
  import '../../../context/ErrorContext/ErrorContext.js';
33
34
  import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
34
35
  import '../../../context/AccountExistsContext/AccountExistsContext.js';
35
- import '../../../context/UserWalletsContext/UserWalletsContext.js';
36
36
  import '../../../config/ApiEndpoint.js';
37
37
  import '../../../locale/locale.js';
38
38
  import '../../../store/state/authMode/authMode.js';
@@ -118,6 +118,7 @@ const useDynamicWaas = () => {
118
118
  const walletConnectorOptions = useWalletConnectorOptions();
119
119
  const refresh = useRefreshUser();
120
120
  const relayUrl = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
121
+ const userWallets = useUserWallets();
121
122
  const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
122
123
  const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
123
124
  const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
@@ -221,9 +222,11 @@ const useDynamicWaas = () => {
221
222
  });
222
223
  yield refresh();
223
224
  });
225
+ const getWaasWallets = useCallback(() => userWallets.filter((w) => w.key === 'dynamicwaas'), [userWallets]);
224
226
  return {
225
227
  createWalletAccount,
226
228
  dynamicWaasIsEnabled,
229
+ getWaasWallets,
227
230
  getWalletConnector,
228
231
  importPrivateKey,
229
232
  shouldAutoCreateDynamicWaasWallet,
@@ -120,16 +120,11 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
120
120
  var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
121
121
 
122
122
  const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) => {
123
- var _a, _b, _c, _d, _e;
123
+ var _a, _b, _c;
124
124
  const { primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
125
125
  const { handleAcknowledgeExportPrompt } = useSyncEmbeddedWalletFlow.useSyncEmbeddedWalletFlow();
126
126
  const { isTurnkeyWallet } = useIsTurnkeyWallet.useIsTurnkeyWallet();
127
- //should use useIsWaasWallet hook
128
127
  const isWaasWallet = 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'); });
129
- // Check if it's a Sui wallet
130
- const isSuiWallet = ((_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _a === void 0 ? void 0 : _a.connectedChain) === 'SUI';
131
- // Check if it's a SOL wallet
132
- const isSolWallet = ((_b = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _b === void 0 ? void 0 : _b.connectedChain) === 'SOL';
133
128
  const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
134
129
  const { pushView } = ViewContext.useViewContext();
135
130
  const { getEOAWallet, isSmartWallet } = useSmartWallets.useSmartWallets();
@@ -145,9 +140,9 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
145
140
  catch (error) {
146
141
  // waas wallet
147
142
  }
148
- const walletProperties = (_d = (_c = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _c === void 0 ? void 0 : _c.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _d === void 0 ? void 0 : _d.walletProperties;
143
+ const walletProperties = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _b === void 0 ? void 0 : _b.walletProperties;
149
144
  const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
150
- const wallet = (_e = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _e !== void 0 ? _e : primaryWallet;
145
+ const wallet = (_c = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _c !== void 0 ? _c : primaryWallet;
151
146
  const [showSkeleton, setShowSkeleton] = React.useState(false);
152
147
  // eslint-disable-next-line arrow-body-style
153
148
  React.useEffect(() => {
@@ -167,14 +162,14 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
167
162
  // eslint-disable-next-line react-hooks/exhaustive-deps
168
163
  }, []);
169
164
  const { isLoading: exportLoading } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
170
- var _f, _g;
165
+ var _d, _e;
171
166
  const iframeContainerElement = iframeContainerRef.current;
172
167
  if (!iframeContainerElement ||
173
- ((_f = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _f === void 0 ? void 0 : _f.length) > 0) {
168
+ ((_d = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _d === void 0 ? void 0 : _d.length) > 0) {
174
169
  return;
175
170
  }
176
171
  if (walletConnectorCore.isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
177
- yield ((_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.createOrRestoreSession());
172
+ yield ((_e = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _e === void 0 ? void 0 : _e.createOrRestoreSession());
178
173
  }
179
174
  if (isTurnkeyWallet) {
180
175
  return turnkeyExport.initExport({
@@ -186,7 +181,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
186
181
  return;
187
182
  }));
188
183
  const { mutate: handleExportWallet, isLoading, error, data, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
189
- var _h, _j, _k;
184
+ var _f, _g, _h;
190
185
  handleAcknowledgeExportPrompt();
191
186
  if (isTurnkeyWallet) {
192
187
  try {
@@ -197,11 +192,11 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
197
192
  wallet: wallet,
198
193
  });
199
194
  }
200
- catch (_l) {
195
+ catch (_j) {
201
196
  if (walletConnectorCore.isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector) &&
202
- ((_h = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _h === void 0 ? void 0 : _h.removeSessionKeys)) {
203
- yield ((_j = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _j === void 0 ? void 0 : _j.removeSessionKeys());
204
- yield ((_k = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _k === void 0 ? void 0 : _k.createOrRestoreSession({
197
+ ((_f = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _f === void 0 ? void 0 : _f.removeSessionKeys)) {
198
+ yield ((_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.removeSessionKeys());
199
+ yield ((_h = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _h === void 0 ? void 0 : _h.createOrRestoreSession({
205
200
  ignoreRestore: true,
206
201
  }));
207
202
  }
@@ -222,7 +217,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
222
217
  wallet: wallet,
223
218
  });
224
219
  }
225
- catch (_m) {
220
+ catch (_k) {
226
221
  return undefined;
227
222
  }
228
223
  }
@@ -259,44 +254,6 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
259
254
  setShowAuthFlow(false);
260
255
  setDynamicWidgetView('send-balance');
261
256
  }, className: 'embedded-reveal-view__zerodev-warning__link-button', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'primary', className: 'underline', copykey: 'dyn_embedded_reveal.aa_warning.button', children: t('dyn_embedded_reveal.aa_warning.button') }) })] })] })), jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__description', children: !(!isLoading && data && !error) && (jsxRuntime.jsx("div", { className: 'embedded-reveal-view__header', children: jsxRuntime.jsx("div", { className: 'embedded-reveal-view__header__hero', children: jsxRuntime.jsx(exportEmbeddedHero.ReactComponent, {}) }) })) })] }));
262
- React.useEffect(() => {
263
- var _a;
264
- if (((_a = iframeContainerRef === null || iframeContainerRef === void 0 ? void 0 : iframeContainerRef.current) === null || _a === void 0 ? void 0 : _a.children) && data) {
265
- // eslint-disable-next-line prefer-destructuring
266
- const iframeElement = iframeContainerRef.current.children[0];
267
- let height = '88px';
268
- let minHeight = '88px';
269
- // Determine height based on wallet type and other conditions
270
- if (!isTurnkeyHDWallet || exportPrivateKey) {
271
- if (isSolWallet) {
272
- height = '140px';
273
- minHeight = '140px';
274
- }
275
- else if (isSuiWallet) {
276
- height = '100px';
277
- minHeight = '100px';
278
- }
279
- else {
280
- height = '88px';
281
- minHeight = '88px';
282
- }
283
- }
284
- else {
285
- // Turnkey HD wallet case
286
- height = '120px';
287
- minHeight = '120px';
288
- }
289
- iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', `height: ${height}; min-height: ${minHeight}; width: 100%; border: none; background: transparent; overflow: hidden;`);
290
- }
291
- }, [
292
- iframeContainerRef,
293
- data,
294
- isTurnkeyHDWallet,
295
- isWaasWallet,
296
- exportPrivateKey,
297
- isSuiWallet,
298
- isSolWallet,
299
- ]);
300
257
  React.useEffect(() => {
301
258
  if (data) {
302
259
  // Show skeleton first
@@ -343,14 +300,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
343
300
  return `${baseClass} ${baseClass}--hidden`;
344
301
  }
345
302
  if (isWaasWallet) {
346
- const waasClass = `${baseClass} ${baseClass}--waas`;
347
- if (isSuiWallet) {
348
- return `${waasClass} ${baseClass}--sui`;
349
- }
350
- if (isSolWallet) {
351
- return `${waasClass} ${baseClass}--sol`;
352
- }
353
- return waasClass;
303
+ return `${baseClass} ${baseClass}--waas`;
354
304
  }
355
305
  return baseClass;
356
306
  };
@@ -362,29 +312,10 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
362
312
  if (showSkeleton) {
363
313
  return `${baseClass} ${baseClass}--invisible`;
364
314
  }
365
- if (isWaasWallet) {
366
- if (isSuiWallet) {
367
- return `${baseClass} ${baseClass}--sui`;
368
- }
369
- if (isSolWallet) {
370
- return `${baseClass} ${baseClass}--sol`;
371
- }
372
- }
373
315
  return baseClass;
374
316
  };
375
317
  const getSkeletonLines = () => {
376
- let lineCount = 4; // Default for 88px height
377
- if (isWaasWallet) {
378
- if (isSolWallet) {
379
- lineCount = 7; // For 140px height
380
- }
381
- else if (isSuiWallet) {
382
- lineCount = 5; // For 100px height
383
- }
384
- }
385
- else if (isTurnkeyHDWallet && !exportPrivateKey) {
386
- lineCount = 6; // For 120px height
387
- }
318
+ const lineCount = 5; // Updated for 110px height
388
319
  const lines = [];
389
320
  for (let i = 0; i < lineCount; i++) {
390
321
  const isLastLine = i === lineCount - 1;
@@ -398,11 +329,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
398
329
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: isPromptForExport ? null : closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsxRuntime.jsx("div", { className: 'embedded-reveal-view', children: jsxRuntime.jsxs("div", { className: getBodyClassName(), children: [(!isWaasWallet ||
399
330
  !hasInjectedCredential ||
400
331
  title !== credentialTitle) &&
401
- contentHeader, isTurnkeyWallet || isWaasWallet ? (jsxRuntime.jsxs("div", { className: getCredentialContainerClassName(), children: [jsxRuntime.jsx("div", { id: constants.iframeContainerId, className: getIframeContainerClassName(), ref: iframeContainerRef }), showSkeleton && data && (jsxRuntime.jsx("div", { className: `embedded-reveal-view__body__skeleton-container${isWaasWallet && isSuiWallet
402
- ? ' embedded-reveal-view__body__skeleton-container--sui'
403
- : isWaasWallet && isSolWallet
404
- ? ' embedded-reveal-view__body__skeleton-container--sol'
405
- : ''}`, children: getSkeletonLines() }))] })) : null, hasInjectedCredential ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
332
+ contentHeader, isTurnkeyWallet || isWaasWallet ? (jsxRuntime.jsxs("div", { className: getCredentialContainerClassName(), children: [jsxRuntime.jsx("div", { id: constants.iframeContainerId, className: getIframeContainerClassName(), ref: iframeContainerRef }), showSkeleton && data && (jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__skeleton-container', children: getSkeletonLines() }))] })) : null, hasInjectedCredential ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
406
333
  setShowAuthFlow(false);
407
334
  }, loading: isLoading, copykey: 'dyn_embedded_reveal.done_button_label', typographyProps: {
408
335
  color: 'inherit',
@@ -116,16 +116,11 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
116
116
  import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
117
117
 
118
118
  const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) => {
119
- var _a, _b, _c, _d, _e;
119
+ var _a, _b, _c;
120
120
  const { primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext();
121
121
  const { handleAcknowledgeExportPrompt } = useSyncEmbeddedWalletFlow();
122
122
  const { isTurnkeyWallet } = useIsTurnkeyWallet();
123
- //should use useIsWaasWallet hook
124
123
  const isWaasWallet = 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'); });
125
- // Check if it's a Sui wallet
126
- const isSuiWallet = ((_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _a === void 0 ? void 0 : _a.connectedChain) === 'SUI';
127
- // Check if it's a SOL wallet
128
- const isSolWallet = ((_b = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _b === void 0 ? void 0 : _b.connectedChain) === 'SOL';
129
124
  const { setDynamicWidgetView } = useWidgetContext();
130
125
  const { pushView } = useViewContext();
131
126
  const { getEOAWallet, isSmartWallet } = useSmartWallets();
@@ -141,9 +136,9 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
141
136
  catch (error) {
142
137
  // waas wallet
143
138
  }
144
- const walletProperties = (_d = (_c = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _c === void 0 ? void 0 : _c.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _d === void 0 ? void 0 : _d.walletProperties;
139
+ const walletProperties = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _b === void 0 ? void 0 : _b.walletProperties;
145
140
  const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
146
- const wallet = (_e = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _e !== void 0 ? _e : primaryWallet;
141
+ const wallet = (_c = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _c !== void 0 ? _c : primaryWallet;
147
142
  const [showSkeleton, setShowSkeleton] = useState(false);
148
143
  // eslint-disable-next-line arrow-body-style
149
144
  useEffect(() => {
@@ -163,14 +158,14 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
163
158
  // eslint-disable-next-line react-hooks/exhaustive-deps
164
159
  }, []);
165
160
  const { isLoading: exportLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
166
- var _f, _g;
161
+ var _d, _e;
167
162
  const iframeContainerElement = iframeContainerRef.current;
168
163
  if (!iframeContainerElement ||
169
- ((_f = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _f === void 0 ? void 0 : _f.length) > 0) {
164
+ ((_d = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _d === void 0 ? void 0 : _d.length) > 0) {
170
165
  return;
171
166
  }
172
167
  if (isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
173
- yield ((_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.createOrRestoreSession());
168
+ yield ((_e = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _e === void 0 ? void 0 : _e.createOrRestoreSession());
174
169
  }
175
170
  if (isTurnkeyWallet) {
176
171
  return initExport({
@@ -182,7 +177,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
182
177
  return;
183
178
  }));
184
179
  const { mutate: handleExportWallet, isLoading, error, data, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
185
- var _h, _j, _k;
180
+ var _f, _g, _h;
186
181
  handleAcknowledgeExportPrompt();
187
182
  if (isTurnkeyWallet) {
188
183
  try {
@@ -193,11 +188,11 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
193
188
  wallet: wallet,
194
189
  });
195
190
  }
196
- catch (_l) {
191
+ catch (_j) {
197
192
  if (isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector) &&
198
- ((_h = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _h === void 0 ? void 0 : _h.removeSessionKeys)) {
199
- yield ((_j = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _j === void 0 ? void 0 : _j.removeSessionKeys());
200
- yield ((_k = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _k === void 0 ? void 0 : _k.createOrRestoreSession({
193
+ ((_f = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _f === void 0 ? void 0 : _f.removeSessionKeys)) {
194
+ yield ((_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.removeSessionKeys());
195
+ yield ((_h = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _h === void 0 ? void 0 : _h.createOrRestoreSession({
201
196
  ignoreRestore: true,
202
197
  }));
203
198
  }
@@ -218,7 +213,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
218
213
  wallet: wallet,
219
214
  });
220
215
  }
221
- catch (_m) {
216
+ catch (_k) {
222
217
  return undefined;
223
218
  }
224
219
  }
@@ -255,44 +250,6 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
255
250
  setShowAuthFlow(false);
256
251
  setDynamicWidgetView('send-balance');
257
252
  }, className: 'embedded-reveal-view__zerodev-warning__link-button', children: jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'primary', className: 'underline', copykey: 'dyn_embedded_reveal.aa_warning.button', children: t('dyn_embedded_reveal.aa_warning.button') }) })] })] })), jsx("div", { className: 'embedded-reveal-view__body__description', children: !(!isLoading && data && !error) && (jsx("div", { className: 'embedded-reveal-view__header', children: jsx("div", { className: 'embedded-reveal-view__header__hero', children: jsx(SvgExportEmbeddedHero, {}) }) })) })] }));
258
- useEffect(() => {
259
- var _a;
260
- if (((_a = iframeContainerRef === null || iframeContainerRef === void 0 ? void 0 : iframeContainerRef.current) === null || _a === void 0 ? void 0 : _a.children) && data) {
261
- // eslint-disable-next-line prefer-destructuring
262
- const iframeElement = iframeContainerRef.current.children[0];
263
- let height = '88px';
264
- let minHeight = '88px';
265
- // Determine height based on wallet type and other conditions
266
- if (!isTurnkeyHDWallet || exportPrivateKey) {
267
- if (isSolWallet) {
268
- height = '140px';
269
- minHeight = '140px';
270
- }
271
- else if (isSuiWallet) {
272
- height = '100px';
273
- minHeight = '100px';
274
- }
275
- else {
276
- height = '88px';
277
- minHeight = '88px';
278
- }
279
- }
280
- else {
281
- // Turnkey HD wallet case
282
- height = '120px';
283
- minHeight = '120px';
284
- }
285
- iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', `height: ${height}; min-height: ${minHeight}; width: 100%; border: none; background: transparent; overflow: hidden;`);
286
- }
287
- }, [
288
- iframeContainerRef,
289
- data,
290
- isTurnkeyHDWallet,
291
- isWaasWallet,
292
- exportPrivateKey,
293
- isSuiWallet,
294
- isSolWallet,
295
- ]);
296
253
  useEffect(() => {
297
254
  if (data) {
298
255
  // Show skeleton first
@@ -339,14 +296,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
339
296
  return `${baseClass} ${baseClass}--hidden`;
340
297
  }
341
298
  if (isWaasWallet) {
342
- const waasClass = `${baseClass} ${baseClass}--waas`;
343
- if (isSuiWallet) {
344
- return `${waasClass} ${baseClass}--sui`;
345
- }
346
- if (isSolWallet) {
347
- return `${waasClass} ${baseClass}--sol`;
348
- }
349
- return waasClass;
299
+ return `${baseClass} ${baseClass}--waas`;
350
300
  }
351
301
  return baseClass;
352
302
  };
@@ -358,29 +308,10 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
358
308
  if (showSkeleton) {
359
309
  return `${baseClass} ${baseClass}--invisible`;
360
310
  }
361
- if (isWaasWallet) {
362
- if (isSuiWallet) {
363
- return `${baseClass} ${baseClass}--sui`;
364
- }
365
- if (isSolWallet) {
366
- return `${baseClass} ${baseClass}--sol`;
367
- }
368
- }
369
311
  return baseClass;
370
312
  };
371
313
  const getSkeletonLines = () => {
372
- let lineCount = 4; // Default for 88px height
373
- if (isWaasWallet) {
374
- if (isSolWallet) {
375
- lineCount = 7; // For 140px height
376
- }
377
- else if (isSuiWallet) {
378
- lineCount = 5; // For 100px height
379
- }
380
- }
381
- else if (isTurnkeyHDWallet && !exportPrivateKey) {
382
- lineCount = 6; // For 120px height
383
- }
314
+ const lineCount = 5; // Updated for 110px height
384
315
  const lines = [];
385
316
  for (let i = 0; i < lineCount; i++) {
386
317
  const isLastLine = i === lineCount - 1;
@@ -394,11 +325,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
394
325
  return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: isPromptForExport ? null : closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsx("div", { className: 'embedded-reveal-view', children: jsxs("div", { className: getBodyClassName(), children: [(!isWaasWallet ||
395
326
  !hasInjectedCredential ||
396
327
  title !== credentialTitle) &&
397
- contentHeader, isTurnkeyWallet || isWaasWallet ? (jsxs("div", { className: getCredentialContainerClassName(), children: [jsx("div", { id: iframeContainerId, className: getIframeContainerClassName(), ref: iframeContainerRef }), showSkeleton && data && (jsx("div", { className: `embedded-reveal-view__body__skeleton-container${isWaasWallet && isSuiWallet
398
- ? ' embedded-reveal-view__body__skeleton-container--sui'
399
- : isWaasWallet && isSolWallet
400
- ? ' embedded-reveal-view__body__skeleton-container--sol'
401
- : ''}`, children: getSkeletonLines() }))] })) : null, hasInjectedCredential ? (jsxs(Fragment, { children: [jsx(TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
328
+ contentHeader, isTurnkeyWallet || isWaasWallet ? (jsxs("div", { className: getCredentialContainerClassName(), children: [jsx("div", { id: iframeContainerId, className: getIframeContainerClassName(), ref: iframeContainerRef }), showSkeleton && data && (jsx("div", { className: 'embedded-reveal-view__body__skeleton-container', children: getSkeletonLines() }))] })) : null, hasInjectedCredential ? (jsxs(Fragment, { children: [jsx(TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
402
329
  setShowAuthFlow(false);
403
330
  }, loading: isLoading, copykey: 'dyn_embedded_reveal.done_button_label', typographyProps: {
404
331
  color: 'inherit',