@dynamic-labs/sdk-react-core 4.17.0 → 4.18.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 (65) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +12 -12
  5. package/src/lib/components/AppOriginTile/AppOriginTile.cjs +14 -14
  6. package/src/lib/components/AppOriginTile/AppOriginTile.d.ts +2 -2
  7. package/src/lib/components/AppOriginTile/AppOriginTile.js +16 -16
  8. package/src/lib/components/Chip/Chip.cjs +14 -0
  9. package/src/lib/components/Chip/Chip.js +10 -0
  10. package/src/lib/components/InlineSubmitButton/InlineSubmitButton.cjs +2 -2
  11. package/src/lib/components/InlineSubmitButton/InlineSubmitButton.js +2 -2
  12. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -1
  13. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +1 -2
  14. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -1
  15. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -1
  16. package/src/lib/context/ViewContext/ViewContext.cjs +7 -2
  17. package/src/lib/context/ViewContext/ViewContext.js +7 -2
  18. package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +8 -3
  19. package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +4 -2
  20. package/src/lib/data/api/embeddedWallets/embeddedWallets.js +8 -3
  21. package/src/lib/locale/en/translation.cjs +8 -4
  22. package/src/lib/locale/en/translation.d.ts +6 -2
  23. package/src/lib/locale/en/translation.js +8 -4
  24. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +8 -8
  25. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +9 -9
  26. package/src/lib/shared/utils/functions/getGlobalWalletContext/getGlobalWalletContext.cjs +15 -0
  27. package/src/lib/shared/utils/functions/getGlobalWalletContext/getGlobalWalletContext.d.ts +11 -0
  28. package/src/lib/shared/utils/functions/getGlobalWalletContext/getGlobalWalletContext.js +11 -0
  29. package/src/lib/shared/utils/functions/getGlobalWalletContext/index.d.ts +1 -0
  30. package/src/lib/shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs +2 -0
  31. package/src/lib/shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js +2 -0
  32. package/src/lib/styles/index.shadow.cjs +1 -1
  33. package/src/lib/styles/index.shadow.js +1 -1
  34. package/src/lib/utils/constants/localStorage.cjs +0 -2
  35. package/src/lib/utils/constants/localStorage.d.ts +0 -1
  36. package/src/lib/utils/constants/localStorage.js +1 -2
  37. package/src/lib/utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.cjs +33 -0
  38. package/src/lib/utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.d.ts +7 -0
  39. package/src/lib/utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.js +29 -0
  40. package/src/lib/utils/functions/getPrimaryTurnkeyWalletId/inedex.d.ts +1 -0
  41. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +1 -1
  42. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +1 -1
  43. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +1 -1
  44. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +1 -1
  45. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +6 -1
  46. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +6 -1
  47. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +8 -1
  48. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +8 -1
  49. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +1 -1
  50. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +1 -1
  51. package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.cjs +3 -0
  52. package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.js +3 -0
  53. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +7 -1
  54. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +7 -1
  55. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +1 -1
  56. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +1 -1
  57. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +4 -4
  58. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +4 -4
  59. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +17 -16
  60. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +18 -17
  61. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -1
  62. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -1
  63. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +2 -1
  64. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +2 -1
  65. package/src/lib/components/AppOriginTile/AppOriginTile.types.d.ts +0 -7
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../_virtual/_tslib.js';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
- import { useState, useMemo, useCallback, useEffect } from 'react';
4
+ import { useState, useMemo, useRef, useCallback, useEffect } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import bs58 from 'bs58';
7
7
  import { isAccountAbstractionConnector } from '@dynamic-labs/wallet-connector-core';
@@ -112,6 +112,7 @@ var SimulationStatus;
112
112
  const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation, onClickBack, walletConnector, onClickClose, title, displayPoweredByDynamicFooter = false, copykey, hideModal, currentToken, isNativeToken, transactionValue, isModal, sendBalanceTransaction, }) => {
113
113
  const { primaryWallet, environmentId } = useInternalDynamicContext();
114
114
  const [isGasSponsored, setIsGasSponsored] = useState(false);
115
+ const [isGasSponsoredLoading, setIsGasSponsoredLoading] = useState(false);
115
116
  const update = useForceUpdate();
116
117
  const { t } = useTranslation();
117
118
  const { currency } = useFetchCurrency(walletConnector);
@@ -127,13 +128,20 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
127
128
  status: SimulationStatus.LOADING,
128
129
  });
129
130
  const [recipient, setRecipient] = useState(undefined);
131
+ const isFetchingSimulationRef = useRef(false);
130
132
  const fetchSimulationResult = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
131
133
  var _a, _b, _c, _d, _e, _f, _g;
132
134
  if (simulationState.status !== SimulationStatus.LOADING) {
133
135
  return;
134
136
  }
137
+ if (isFetchingSimulationRef.current) {
138
+ // Already fetching, prevent duplicate call
139
+ return;
140
+ }
141
+ isFetchingSimulationRef.current = true;
135
142
  if (sendBalanceTransaction || hideModal) {
136
143
  setSimulationState({ status: SimulationStatus.SKIPPED });
144
+ isFetchingSimulationRef.current = false;
137
145
  return;
138
146
  }
139
147
  if (!primaryWallet || (!chainId && (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== 'SOL')) {
@@ -143,13 +151,16 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
143
151
  primaryWallet,
144
152
  });
145
153
  setSimulationState({ status: SimulationStatus.FAILED });
154
+ isFetchingSimulationRef.current = false;
146
155
  return;
147
156
  }
148
157
  try {
149
158
  let result;
150
159
  if (primaryWallet.connector.key === 'zerodev') {
151
160
  const connector = primaryWallet.connector;
152
- const { userOperation } = yield connector.getCurrentUserOperation(transaction);
161
+ const { userOperation, sponsored } = yield connector.getCurrentUserOperation(transaction);
162
+ setIsGasSponsored(sponsored);
163
+ setIsGasSponsoredLoading(false);
153
164
  if (userOperation) {
154
165
  const formattedUserOperation = yield connector.formatUserOperation(userOperation);
155
166
  // Set the gas fee on the transaction, only for zero dev
@@ -216,6 +227,9 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
216
227
  logger.error('[TransactionConfirmationView] Simulation failed:', error);
217
228
  setSimulationState({ status: SimulationStatus.FAILED });
218
229
  }
230
+ finally {
231
+ isFetchingSimulationRef.current = false;
232
+ }
219
233
  }), [
220
234
  sendBalanceTransaction,
221
235
  hideModal,
@@ -224,6 +238,8 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
224
238
  environmentId,
225
239
  transaction,
226
240
  walletConnector,
241
+ simulationState.status,
242
+ setSimulationState,
227
243
  ]);
228
244
  useEffect(() => {
229
245
  if (simulationState.status === SimulationStatus.SUCCESS ||
@@ -245,21 +261,6 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
245
261
  }
246
262
  transaction.fetchFee().finally(update);
247
263
  }, [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain, transaction, update]);
248
- const { isLoading: isGasSponsoredLoading } = usePromise(() => {
249
- if (!isAccountAbstractionConnector(walletConnector)) {
250
- return false;
251
- }
252
- return walletConnector.canSponsorTransactionGas(transaction);
253
- }, {
254
- initialData: false,
255
- onReject: logger.error,
256
- onResolve: (isGasSponsored) => {
257
- setIsGasSponsored(isGasSponsored);
258
- if (!isGasSponsored && isAccountAbstractionConnector(walletConnector)) {
259
- walletConnector.disableGasSponsorshipOnce();
260
- }
261
- },
262
- });
263
264
  useEffect(() => {
264
265
  var _a;
265
266
  // solana gas sponsorship check
@@ -41,13 +41,13 @@ require('../../../../context/VerificationContext/VerificationContext.cjs');
41
41
  require('react-dom');
42
42
  require('../../../../utils/functions/compareChains/compareChains.cjs');
43
43
  require('../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
44
+ require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
44
45
  require('../../../../context/ThemeContext/ThemeContext.cjs');
45
46
  require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
46
47
  var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
47
48
  require('bs58');
48
49
  require('@dynamic-labs/types');
49
50
  require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
50
- require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
51
51
  require('../../../../context/LoadingContext/LoadingContext.cjs');
52
52
  require('../../../../context/WalletContext/WalletContext.cjs');
53
53
  require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
@@ -37,13 +37,13 @@ import '../../../../context/VerificationContext/VerificationContext.js';
37
37
  import 'react-dom';
38
38
  import '../../../../utils/functions/compareChains/compareChains.js';
39
39
  import '../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
40
+ import '../../../../store/state/primaryWalletId/primaryWalletId.js';
40
41
  import '../../../../context/ThemeContext/ThemeContext.js';
41
42
  import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
42
43
  import { useMutation } from '../../../../utils/hooks/useMutation/useMutation.js';
43
44
  import 'bs58';
44
45
  import '@dynamic-labs/types';
45
46
  import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
46
- import '../../../../store/state/primaryWalletId/primaryWalletId.js';
47
47
  import '../../../../context/LoadingContext/LoadingContext.js';
48
48
  import '../../../../context/WalletContext/WalletContext.js';
49
49
  import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
@@ -131,7 +131,8 @@ const AccountAndSecuritySettingsView = () => {
131
131
  const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
132
132
  const [isLoading, setIsLoading] = React.useState(false);
133
133
  const { getEOAWallet } = useSmartWallets.useSmartWallets();
134
- const turnkeyWalletProperties = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
134
+ const turnkeyWalletProperties = (_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')) &&
135
+ ((primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id) ? id === (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id) : true))) === null || _b === void 0 ? void 0 : _b.walletProperties;
135
136
  const isTurnkeyHDWallet = turnkeyWalletProperties === null || turnkeyWalletProperties === void 0 ? void 0 : turnkeyWalletProperties.turnkeyHDWalletId;
136
137
  const isPasskeyEnabled = Boolean((_f = (_e = (_d = (_c = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _c === void 0 ? void 0 : _c.embeddedWallets) === null || _d === void 0 ? void 0 : _d.supportedSecurityMethods) === null || _e === void 0 ? void 0 : _e.passkey) === null || _f === void 0 ? void 0 : _f.isEnabled);
137
138
  const isTurnkeyWalletWithAuthenticator = isTurnkeyWallet && !isTurnkeyWalletWithoutAuthenticator;
@@ -127,7 +127,8 @@ const AccountAndSecuritySettingsView = () => {
127
127
  const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
128
128
  const [isLoading, setIsLoading] = useState(false);
129
129
  const { getEOAWallet } = useSmartWallets();
130
- const turnkeyWalletProperties = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
130
+ const turnkeyWalletProperties = (_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')) &&
131
+ ((primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id) ? id === (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id) : true))) === null || _b === void 0 ? void 0 : _b.walletProperties;
131
132
  const isTurnkeyHDWallet = turnkeyWalletProperties === null || turnkeyWalletProperties === void 0 ? void 0 : turnkeyWalletProperties.turnkeyHDWalletId;
132
133
  const isPasskeyEnabled = Boolean((_f = (_e = (_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.embeddedWallets) === null || _d === void 0 ? void 0 : _d.supportedSecurityMethods) === null || _e === void 0 ? void 0 : _e.passkey) === null || _f === void 0 ? void 0 : _f.isEnabled);
133
134
  const isTurnkeyWalletWithAuthenticator = isTurnkeyWallet && !isTurnkeyWalletWithoutAuthenticator;
@@ -1,7 +0,0 @@
1
- import { FC } from 'react';
2
- export type AppOriginTileProps = {
3
- appLogoUrl?: string;
4
- appName?: string;
5
- appOrigin?: string;
6
- };
7
- export type AppOriginTileComponent = FC<AppOriginTileProps>;