@dynamic-labs/sdk-react-core 4.50.4 → 4.51.0

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 (72) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +12 -12
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +1 -1
  7. package/src/index.js +1 -0
  8. package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.cjs +1 -1
  9. package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.js +1 -1
  10. package/src/lib/components/IconWithSpinner/IconWithSpinner.cjs +1 -1
  11. package/src/lib/components/IconWithSpinner/IconWithSpinner.js +1 -1
  12. package/src/lib/components/IconWithSpinner/Spinner/Spinner.cjs +1 -1
  13. package/src/lib/components/IconWithSpinner/Spinner/Spinner.js +1 -1
  14. package/src/lib/components/IconWithStatus/IconWithStatus.cjs +1 -1
  15. package/src/lib/components/IconWithStatus/IconWithStatus.js +1 -1
  16. package/src/lib/context/CaptchaContext/CaptchaContext.cjs +88 -1
  17. package/src/lib/context/CaptchaContext/CaptchaContext.js +88 -1
  18. package/src/lib/context/ConnectWithOtpContext/ConnectWithOtpProvider.cjs +1 -1
  19. package/src/lib/context/ConnectWithOtpContext/ConnectWithOtpProvider.js +1 -1
  20. package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
  21. package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
  22. package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.cjs +1 -1
  23. package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.js +1 -1
  24. package/src/lib/context/DynamicContext/hooks/useEmailLoginState/useEmailLoginState.cjs +1 -1
  25. package/src/lib/context/DynamicContext/hooks/useEmailLoginState/useEmailLoginState.js +1 -1
  26. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +19 -0
  27. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +20 -1
  28. package/src/lib/context/ReinitializeContext/ReinitializeContextProvider.cjs +1 -1
  29. package/src/lib/context/ReinitializeContext/ReinitializeContextProvider.js +1 -1
  30. package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.cjs +1 -1
  31. package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.js +1 -1
  32. package/src/lib/store/stateConfig.cjs +39 -35
  33. package/src/lib/store/stateConfig.js +39 -35
  34. package/src/lib/utils/functions/generateMessages/index.cjs +15 -1
  35. package/src/lib/utils/functions/generateMessages/index.js +15 -1
  36. package/src/lib/utils/functions/getEnabledEmbeddedWalletProviders/getEnabledEmbeddedWalletProviders.cjs +1 -1
  37. package/src/lib/utils/functions/getEnabledEmbeddedWalletProviders/getEnabledEmbeddedWalletProviders.js +1 -1
  38. package/src/lib/utils/functions/getUserIdentifier/getUserIdentifier.cjs +1 -1
  39. package/src/lib/utils/functions/getUserIdentifier/getUserIdentifier.js +1 -1
  40. package/src/lib/utils/functions/isAllowedToLinkWallet/isAllowedToLinkWallet.cjs +1 -1
  41. package/src/lib/utils/functions/isAllowedToLinkWallet/isAllowedToLinkWallet.js +1 -1
  42. package/src/lib/utils/functions/isPasskeyProviderEnabled/isPasskeyProviderEnabled.cjs +1 -1
  43. package/src/lib/utils/functions/isPasskeyProviderEnabled/isPasskeyProviderEnabled.js +1 -1
  44. package/src/lib/utils/functions/isPhoneNumberProviderEnabled/isPhoneNumberProviderEnabled.cjs +1 -1
  45. package/src/lib/utils/functions/isPhoneNumberProviderEnabled/isPhoneNumberProviderEnabled.js +1 -1
  46. package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.cjs +1 -32
  47. package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.js +1 -32
  48. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -1
  49. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -1
  50. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.cjs +1 -1
  51. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.js +1 -1
  52. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs +1 -1
  53. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/verifyMagicIsSetup/verifyMagicIsSetup.js +1 -1
  54. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/verifyZeroDevIsSetup/verifyZeroDevIsSetup.cjs +1 -1
  55. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/verifyZeroDevIsSetup/verifyZeroDevIsSetup.js +1 -1
  56. package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.cjs +1 -1
  57. package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.js +1 -1
  58. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +2 -1
  59. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +2 -1
  60. package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs +1 -1
  61. package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.js +1 -1
  62. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +38 -15
  63. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.d.ts +8 -2
  64. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +38 -15
  65. package/src/lib/views/LoginView/sections/SocialSignInSection/SocialSignInSection.cjs +1 -1
  66. package/src/lib/views/LoginView/sections/SocialSignInSection/SocialSignInSection.js +1 -1
  67. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +10 -2
  68. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +10 -2
  69. package/src/lib/widgets/DynamicWidget/components/WalletIconWithNetwork/WalletIconWithNetwork.cjs +1 -1
  70. package/src/lib/widgets/DynamicWidget/components/WalletIconWithNetwork/WalletIconWithNetwork.js +1 -1
  71. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.cjs +18 -18
  72. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.js +18 -18
@@ -115,7 +115,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
115
115
  const { pushView, clearStackAndPushInitialView, replaceView } = ViewContext.useViewContext();
116
116
  const { engageCaptcha, getCaptchaToken } = CaptchaContext.useCaptchaContext();
117
117
  const { setErrorMessage, setError, setDefaultError } = ErrorContext.useErrorContext();
118
- const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, walletUiUtils, } = useInternalDynamicContext.useInternalDynamicContext();
118
+ const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, setShowAuthFlow, walletUiUtils, } = useInternalDynamicContext.useInternalDynamicContext();
119
119
  const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
120
120
  const verifyWallet = useVerifyWallet.useVerifyWallet({
121
121
  displaySiweStatement,
@@ -127,6 +127,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
127
127
  if (!walletConnectorCore.isEmailWalletConnector(walletConnector) ||
128
128
  walletConnectorCore.isBloctoConnector(walletConnector)) {
129
129
  replaceView('pending-signature');
130
+ setShowAuthFlow(true);
130
131
  }
131
132
  else {
132
133
  walletUiUtils.disabledConfirmationOnce();
@@ -111,7 +111,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
111
111
  const { pushView, clearStackAndPushInitialView, replaceView } = useViewContext();
112
112
  const { engageCaptcha, getCaptchaToken } = useCaptchaContext();
113
113
  const { setErrorMessage, setError, setDefaultError } = useErrorContext();
114
- const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, walletUiUtils, } = useInternalDynamicContext();
114
+ const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, setShowAuthFlow, walletUiUtils, } = useInternalDynamicContext();
115
115
  const { handleWalletsToConnect } = useHandleWalletsToConnect();
116
116
  const verifyWallet = useVerifyWallet({
117
117
  displaySiweStatement,
@@ -123,6 +123,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
123
123
  if (!isEmailWalletConnector(walletConnector) ||
124
124
  isBloctoConnector(walletConnector)) {
125
125
  replaceView('pending-signature');
126
+ setShowAuthFlow(true);
126
127
  }
127
128
  else {
128
129
  walletUiUtils.disabledConfirmationOnce();
@@ -11,13 +11,13 @@ require('@dynamic-labs/sdk-api-core');
11
11
  require('../../constants/values.cjs');
12
12
  require('@dynamic-labs/utils');
13
13
  require('@dynamic-labs/multi-wallet');
14
+ require('../../../shared/logger.cjs');
14
15
  require('react-international-phone');
15
16
  require('../../constants/colors.cjs');
16
17
  require('@dynamic-labs/iconic');
17
18
  require('@dynamic-labs/wallet-connector-core');
18
19
  require('react/jsx-runtime');
19
20
  require('../../../context/ViewContext/ViewContext.cjs');
20
- require('../../../shared/logger.cjs');
21
21
  require('../../../shared/consts/index.cjs');
22
22
  require('../../../store/state/nonce/nonce.cjs');
23
23
  var serializeWalletConnectors = require('../../functions/serializeWalletConnectors/serializeWalletConnectors.cjs');
@@ -7,13 +7,13 @@ import '@dynamic-labs/sdk-api-core';
7
7
  import '../../constants/values.js';
8
8
  import '@dynamic-labs/utils';
9
9
  import '@dynamic-labs/multi-wallet';
10
+ import '../../../shared/logger.js';
10
11
  import 'react-international-phone';
11
12
  import '../../constants/colors.js';
12
13
  import '@dynamic-labs/iconic';
13
14
  import '@dynamic-labs/wallet-connector-core';
14
15
  import 'react/jsx-runtime';
15
16
  import '../../../context/ViewContext/ViewContext.js';
16
- import '../../../shared/logger.js';
17
17
  import '../../../shared/consts/index.js';
18
18
  import '../../../store/state/nonce/nonce.js';
19
19
  import { serializeWalletConnectors } from '../../functions/serializeWalletConnectors/serializeWalletConnectors.js';
@@ -8,6 +8,7 @@ require('../../../../constants/values.cjs');
8
8
  require('@dynamic-labs/utils');
9
9
  require('../../../../../../../_virtual/_tslib.cjs');
10
10
  require('@dynamic-labs/multi-wallet');
11
+ require('../../../../../shared/logger.cjs');
11
12
  require('react-international-phone');
12
13
  require('../../../../constants/colors.cjs');
13
14
  require('@dynamic-labs/iconic');
@@ -15,7 +16,6 @@ require('@dynamic-labs/wallet-connector-core');
15
16
  require('react');
16
17
  require('react/jsx-runtime');
17
18
  require('../../../../../context/ViewContext/ViewContext.cjs');
18
- require('../../../../../shared/logger.cjs');
19
19
  require('@dynamic-labs/wallet-book');
20
20
  require('../../../../../shared/consts/index.cjs');
21
21
  require('../../../../../store/state/nonce/nonce.cjs');
@@ -4,6 +4,7 @@ import '../../../../constants/values.js';
4
4
  import '@dynamic-labs/utils';
5
5
  import '../../../../../../../_virtual/_tslib.js';
6
6
  import '@dynamic-labs/multi-wallet';
7
+ import '../../../../../shared/logger.js';
7
8
  import 'react-international-phone';
8
9
  import '../../../../constants/colors.js';
9
10
  import '@dynamic-labs/iconic';
@@ -11,7 +12,6 @@ import '@dynamic-labs/wallet-connector-core';
11
12
  import 'react';
12
13
  import 'react/jsx-runtime';
13
14
  import '../../../../../context/ViewContext/ViewContext.js';
14
- import '../../../../../shared/logger.js';
15
15
  import '@dynamic-labs/wallet-book';
16
16
  import '../../../../../shared/consts/index.js';
17
17
  import '../../../../../store/state/nonce/nonce.js';
@@ -8,6 +8,7 @@ require('../../../../constants/values.cjs');
8
8
  require('@dynamic-labs/utils');
9
9
  require('../../../../../../../_virtual/_tslib.cjs');
10
10
  require('@dynamic-labs/multi-wallet');
11
+ require('../../../../../shared/logger.cjs');
11
12
  require('react-international-phone');
12
13
  require('../../../../constants/colors.cjs');
13
14
  require('@dynamic-labs/iconic');
@@ -15,7 +16,6 @@ require('@dynamic-labs/wallet-connector-core');
15
16
  require('react');
16
17
  require('react/jsx-runtime');
17
18
  require('../../../../../context/ViewContext/ViewContext.cjs');
18
- require('../../../../../shared/logger.cjs');
19
19
  require('@dynamic-labs/wallet-book');
20
20
  require('../../../../../shared/consts/index.cjs');
21
21
  require('../../../../../store/state/nonce/nonce.cjs');
@@ -4,6 +4,7 @@ import '../../../../constants/values.js';
4
4
  import '@dynamic-labs/utils';
5
5
  import '../../../../../../../_virtual/_tslib.js';
6
6
  import '@dynamic-labs/multi-wallet';
7
+ import '../../../../../shared/logger.js';
7
8
  import 'react-international-phone';
8
9
  import '../../../../constants/colors.js';
9
10
  import '@dynamic-labs/iconic';
@@ -11,7 +12,6 @@ import '@dynamic-labs/wallet-connector-core';
11
12
  import 'react';
12
13
  import 'react/jsx-runtime';
13
14
  import '../../../../../context/ViewContext/ViewContext.js';
14
- import '../../../../../shared/logger.js';
15
15
  import '@dynamic-labs/wallet-book';
16
16
  import '../../../../../shared/consts/index.js';
17
17
  import '../../../../../store/state/nonce/nonce.js';
@@ -10,13 +10,13 @@ require('@dynamic-labs/sdk-api-core');
10
10
  require('../../constants/values.cjs');
11
11
  require('@dynamic-labs/utils');
12
12
  require('@dynamic-labs/multi-wallet');
13
+ require('../../../shared/logger.cjs');
13
14
  require('react-international-phone');
14
15
  require('../../constants/colors.cjs');
15
16
  require('@dynamic-labs/iconic');
16
17
  require('@dynamic-labs/wallet-connector-core');
17
18
  require('react/jsx-runtime');
18
19
  require('../../../context/ViewContext/ViewContext.cjs');
19
- require('../../../shared/logger.cjs');
20
20
  require('@dynamic-labs/wallet-book');
21
21
  require('../../../shared/consts/index.cjs');
22
22
  require('../../../store/state/nonce/nonce.cjs');
@@ -6,13 +6,13 @@ import '@dynamic-labs/sdk-api-core';
6
6
  import '../../constants/values.js';
7
7
  import '@dynamic-labs/utils';
8
8
  import '@dynamic-labs/multi-wallet';
9
+ import '../../../shared/logger.js';
9
10
  import 'react-international-phone';
10
11
  import '../../constants/colors.js';
11
12
  import '@dynamic-labs/iconic';
12
13
  import '@dynamic-labs/wallet-connector-core';
13
14
  import 'react/jsx-runtime';
14
15
  import '../../../context/ViewContext/ViewContext.js';
15
- import '../../../shared/logger.js';
16
16
  import '@dynamic-labs/wallet-book';
17
17
  import '../../../shared/consts/index.js';
18
18
  import '../../../store/state/nonce/nonce.js';
@@ -278,6 +278,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
278
278
  catch (error) {
279
279
  logger.logger.error('Social connection failed with unexpected error:', error);
280
280
  onFailed(provider, { error }, { raiseAuthFailure: authMode === 'signin' });
281
+ throw error;
281
282
  }
282
283
  }), [
283
284
  environmentId,
@@ -473,7 +474,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
473
474
  handleError(provider, error.code, error.message, {
474
475
  raiseAuthFailure: authMode === 'signin',
475
476
  });
476
- return;
477
+ throw error;
477
478
  }
478
479
  // Log message individually so the Expo console can display it (it fails to display objects)
479
480
  logger.logger.error('Social connection failed with unexpected error:', error.message, error);
@@ -274,6 +274,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
274
274
  catch (error) {
275
275
  logger.error('Social connection failed with unexpected error:', error);
276
276
  onFailed(provider, { error }, { raiseAuthFailure: authMode === 'signin' });
277
+ throw error;
277
278
  }
278
279
  }), [
279
280
  environmentId,
@@ -469,7 +470,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
469
470
  handleError(provider, error.code, error.message, {
470
471
  raiseAuthFailure: authMode === 'signin',
471
472
  });
472
- return;
473
+ throw error;
473
474
  }
474
475
  // Log message individually so the Expo console can display it (it fails to display objects)
475
476
  logger.error('Social connection failed with unexpected error:', error.message, error);
@@ -8,6 +8,7 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
8
8
  require('../../constants/values.cjs');
9
9
  require('@dynamic-labs/utils');
10
10
  require('@dynamic-labs/multi-wallet');
11
+ var logger = require('../../../shared/logger.cjs');
11
12
  require('react-international-phone');
12
13
  require('../../constants/colors.cjs');
13
14
  require('@dynamic-labs/iconic');
@@ -15,7 +16,6 @@ require('@dynamic-labs/wallet-connector-core');
15
16
  require('react');
16
17
  require('react/jsx-runtime');
17
18
  require('../../../context/ViewContext/ViewContext.cjs');
18
- var logger = require('../../../shared/logger.cjs');
19
19
  require('@dynamic-labs/wallet-book');
20
20
  require('../../../shared/consts/index.cjs');
21
21
  require('../../../store/state/nonce/nonce.cjs');
@@ -4,6 +4,7 @@ import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
4
4
  import '../../constants/values.js';
5
5
  import '@dynamic-labs/utils';
6
6
  import '@dynamic-labs/multi-wallet';
7
+ import { logger } from '../../../shared/logger.js';
7
8
  import 'react-international-phone';
8
9
  import '../../constants/colors.js';
9
10
  import '@dynamic-labs/iconic';
@@ -11,7 +12,6 @@ import '@dynamic-labs/wallet-connector-core';
11
12
  import 'react';
12
13
  import 'react/jsx-runtime';
13
14
  import '../../../context/ViewContext/ViewContext.js';
14
- import { logger } from '../../../shared/logger.js';
15
15
  import '@dynamic-labs/wallet-book';
16
16
  import '../../../shared/consts/index.js';
17
17
  import '../../../store/state/nonce/nonce.js';
@@ -115,11 +115,12 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
115
115
  * Otherwise, returns all pending wallets from getWalletsDelegatedStatus.
116
116
  */
117
117
  const getWalletsToDelegate = (wallets, getWalletsDelegatedStatus) => {
118
+ const walletsWithDelegationStatus = getWalletsDelegatedStatus().filter((wallet) => wallet.status === 'pending');
118
119
  if (wallets && wallets.length > 0) {
119
- // Convert Wallet[] to WalletWithStatus[] with pending status
120
- return wallets.map((wallet) => (Object.assign(Object.assign({}, wallet), { status: 'pending' })));
120
+ return walletsWithDelegationStatus.filter((wallet) => wallets.some((w) => w.accountAddress === wallet.address &&
121
+ w.chainName === wallet.chain));
121
122
  }
122
- return getWalletsDelegatedStatus().filter((wallet) => wallet.status === 'pending');
123
+ return walletsWithDelegationStatus;
123
124
  };
124
125
  // Hook to trigger wallet delegation modal
125
126
  const useWalletDelegation = () => {
@@ -222,23 +223,45 @@ const useWalletDelegation = () => {
222
223
  .filter((wallet) => wallet !== null);
223
224
  }, [user === null || user === void 0 ? void 0 : user.verifiedCredentials, userWallets]);
224
225
  const delegateKeyShares = React.useCallback((wallets) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
225
- // If wallets provided, use them directly; otherwise get pending wallets
226
- const walletsToDelegate = wallets && wallets.length > 0
227
- ? wallets
228
- : getWalletsToDelegate(undefined, getWalletsDelegatedStatus).map((wallet) => ({
229
- accountAddress: wallet.address,
230
- chainName: wallet.chain,
231
- }));
226
+ if (!delegatedAccessEnabled) {
227
+ throw new Error('Wallet delegation is not enabled for this project environment. Please check the project settings.');
228
+ }
229
+ // If wallets provided, only eligible wallets are returned; otherwise get pending wallets
230
+ const walletsToDelegate = getWalletsToDelegate(wallets, getWalletsDelegatedStatus).map((wallet) => ({
231
+ accountAddress: wallet.address,
232
+ chainName: wallet.chain,
233
+ }));
234
+ if (walletsToDelegate.length === 0) {
235
+ throw new Error('No eligible wallets to delegate, only Dynamic WaaS wallets are eligible for delegation');
236
+ }
232
237
  for (const wallet of walletsToDelegate) {
233
238
  const walletConnector = getWaasWalletConnector(wallet.chainName);
234
- if (!walletConnector)
239
+ if (!walletConnector) {
240
+ logger.logger.warn('Wallet connector not found, skipping delegate', {
241
+ accountAddress: wallet.accountAddress,
242
+ chainName: wallet.chainName,
243
+ });
235
244
  continue;
236
- yield walletConnector.delegateKeyShares({
237
- accountAddress: wallet.accountAddress,
238
- });
245
+ }
246
+ try {
247
+ yield walletConnector.delegateKeyShares({
248
+ accountAddress: wallet.accountAddress,
249
+ });
250
+ }
251
+ catch (error) {
252
+ logger.logger.error('Failed to delegate key shares:', {
253
+ error,
254
+ wallet,
255
+ });
256
+ }
239
257
  }
240
258
  yield refresh();
241
- }), [getWaasWalletConnector, refresh, getWalletsDelegatedStatus]);
259
+ }), [
260
+ getWaasWalletConnector,
261
+ refresh,
262
+ getWalletsDelegatedStatus,
263
+ delegatedAccessEnabled,
264
+ ]);
242
265
  const revokeDelegation = React.useCallback((wallets) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
243
266
  // Get current wallet statuses to check which ones are actually delegated
244
267
  const walletsWithStatus = getWalletsDelegatedStatus();
@@ -10,7 +10,10 @@ export type WalletWithStatus = Wallet & {
10
10
  * If wallets are provided and not empty, converts them to WalletWithStatus[] with pending status.
11
11
  * Otherwise, returns all pending wallets from getWalletsDelegatedStatus.
12
12
  */
13
- export declare const getWalletsToDelegate: (wallets: Wallet[] | undefined, getWalletsDelegatedStatus: () => WalletWithStatus[]) => WalletWithStatus[];
13
+ export declare const getWalletsToDelegate: (wallets: {
14
+ chainName: ChainEnum;
15
+ accountAddress: string;
16
+ }[] | undefined, getWalletsDelegatedStatus: () => WalletWithStatus[]) => WalletWithStatus[];
14
17
  export declare const useWalletDelegation: () => {
15
18
  readonly clearDelegationSessionState: () => void;
16
19
  readonly delegateKeyShares: (wallets?: {
@@ -21,7 +24,10 @@ export declare const useWalletDelegation: () => {
21
24
  readonly denyWalletDelegation: (walletId: string) => Promise<void>;
22
25
  readonly dismissDelegationPrompt: (walletId?: string) => void;
23
26
  readonly getWalletsDelegatedStatus: () => WalletWithStatus[];
24
- readonly getWalletsToDelegate: (wallets: Wallet[] | undefined, getWalletsDelegatedStatus: () => WalletWithStatus[]) => WalletWithStatus[];
27
+ readonly getWalletsToDelegate: (wallets: {
28
+ chainName: ChainEnum;
29
+ accountAddress: string;
30
+ }[] | undefined, getWalletsDelegatedStatus: () => WalletWithStatus[]) => WalletWithStatus[];
25
31
  readonly initDelegationProcess: (options?: {
26
32
  wallets?: Wallet[];
27
33
  }) => Promise<void>;
@@ -111,11 +111,12 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
111
111
  * Otherwise, returns all pending wallets from getWalletsDelegatedStatus.
112
112
  */
113
113
  const getWalletsToDelegate = (wallets, getWalletsDelegatedStatus) => {
114
+ const walletsWithDelegationStatus = getWalletsDelegatedStatus().filter((wallet) => wallet.status === 'pending');
114
115
  if (wallets && wallets.length > 0) {
115
- // Convert Wallet[] to WalletWithStatus[] with pending status
116
- return wallets.map((wallet) => (Object.assign(Object.assign({}, wallet), { status: 'pending' })));
116
+ return walletsWithDelegationStatus.filter((wallet) => wallets.some((w) => w.accountAddress === wallet.address &&
117
+ w.chainName === wallet.chain));
117
118
  }
118
- return getWalletsDelegatedStatus().filter((wallet) => wallet.status === 'pending');
119
+ return walletsWithDelegationStatus;
119
120
  };
120
121
  // Hook to trigger wallet delegation modal
121
122
  const useWalletDelegation = () => {
@@ -218,23 +219,45 @@ const useWalletDelegation = () => {
218
219
  .filter((wallet) => wallet !== null);
219
220
  }, [user === null || user === void 0 ? void 0 : user.verifiedCredentials, userWallets]);
220
221
  const delegateKeyShares = useCallback((wallets) => __awaiter(void 0, void 0, void 0, function* () {
221
- // If wallets provided, use them directly; otherwise get pending wallets
222
- const walletsToDelegate = wallets && wallets.length > 0
223
- ? wallets
224
- : getWalletsToDelegate(undefined, getWalletsDelegatedStatus).map((wallet) => ({
225
- accountAddress: wallet.address,
226
- chainName: wallet.chain,
227
- }));
222
+ if (!delegatedAccessEnabled) {
223
+ throw new Error('Wallet delegation is not enabled for this project environment. Please check the project settings.');
224
+ }
225
+ // If wallets provided, only eligible wallets are returned; otherwise get pending wallets
226
+ const walletsToDelegate = getWalletsToDelegate(wallets, getWalletsDelegatedStatus).map((wallet) => ({
227
+ accountAddress: wallet.address,
228
+ chainName: wallet.chain,
229
+ }));
230
+ if (walletsToDelegate.length === 0) {
231
+ throw new Error('No eligible wallets to delegate, only Dynamic WaaS wallets are eligible for delegation');
232
+ }
228
233
  for (const wallet of walletsToDelegate) {
229
234
  const walletConnector = getWaasWalletConnector(wallet.chainName);
230
- if (!walletConnector)
235
+ if (!walletConnector) {
236
+ logger.warn('Wallet connector not found, skipping delegate', {
237
+ accountAddress: wallet.accountAddress,
238
+ chainName: wallet.chainName,
239
+ });
231
240
  continue;
232
- yield walletConnector.delegateKeyShares({
233
- accountAddress: wallet.accountAddress,
234
- });
241
+ }
242
+ try {
243
+ yield walletConnector.delegateKeyShares({
244
+ accountAddress: wallet.accountAddress,
245
+ });
246
+ }
247
+ catch (error) {
248
+ logger.error('Failed to delegate key shares:', {
249
+ error,
250
+ wallet,
251
+ });
252
+ }
235
253
  }
236
254
  yield refresh();
237
- }), [getWaasWalletConnector, refresh, getWalletsDelegatedStatus]);
255
+ }), [
256
+ getWaasWalletConnector,
257
+ refresh,
258
+ getWalletsDelegatedStatus,
259
+ delegatedAccessEnabled,
260
+ ]);
238
261
  const revokeDelegation = useCallback((wallets) => __awaiter(void 0, void 0, void 0, function* () {
239
262
  // Get current wallet statuses to check which ones are actually delegated
240
263
  const walletsWithStatus = getWalletsDelegatedStatus();
@@ -9,13 +9,13 @@ require('../../../../utils/constants/values.cjs');
9
9
  require('@dynamic-labs/utils');
10
10
  require('../../../../../../_virtual/_tslib.cjs');
11
11
  require('@dynamic-labs/multi-wallet');
12
+ var logger = require('../../../../shared/logger.cjs');
12
13
  require('react-international-phone');
13
14
  require('../../../../utils/constants/colors.cjs');
14
15
  require('@dynamic-labs/iconic');
15
16
  require('@dynamic-labs/wallet-connector-core');
16
17
  require('react');
17
18
  require('../../../../context/ViewContext/ViewContext.cjs');
18
- var logger = require('../../../../shared/logger.cjs');
19
19
  require('@dynamic-labs/wallet-book');
20
20
  require('../../../../shared/consts/index.cjs');
21
21
  var getSocialSignInProviderFromString = require('../../../../utils/functions/getSocialSignInProviderFromString/getSocialSignInProviderFromString.cjs');
@@ -5,13 +5,13 @@ import '../../../../utils/constants/values.js';
5
5
  import '@dynamic-labs/utils';
6
6
  import '../../../../../../_virtual/_tslib.js';
7
7
  import '@dynamic-labs/multi-wallet';
8
+ import { logger } from '../../../../shared/logger.js';
8
9
  import 'react-international-phone';
9
10
  import '../../../../utils/constants/colors.js';
10
11
  import '@dynamic-labs/iconic';
11
12
  import '@dynamic-labs/wallet-connector-core';
12
13
  import 'react';
13
14
  import '../../../../context/ViewContext/ViewContext.js';
14
- import { logger } from '../../../../shared/logger.js';
15
15
  import '@dynamic-labs/wallet-book';
16
16
  import '../../../../shared/consts/index.js';
17
17
  import { getSocialSignInProviderFromString } from '../../../../utils/functions/getSocialSignInProviderFromString/getSocialSignInProviderFromString.js';
@@ -48,7 +48,15 @@ const WalletDelegationView = ({ wallets, }) => {
48
48
  const [agreementChecked, setAgreementChecked] = React.useState(false);
49
49
  const [selectionInitialized, setSelectionInitialized] = React.useState(false);
50
50
  // Get waas wallets that are not yet delegated or use provided wallets override
51
- const waasWallets = React.useMemo(() => getWalletsToDelegate(wallets, getWalletsDelegatedStatus), [wallets, getWalletsDelegatedStatus]);
51
+ const waasWallets = React.useMemo(() => {
52
+ const walletsToDelegate = wallets
53
+ ? wallets.map((wallet) => ({
54
+ accountAddress: wallet.address,
55
+ chainName: wallet.chain,
56
+ }))
57
+ : undefined;
58
+ return getWalletsToDelegate(walletsToDelegate, getWalletsDelegatedStatus);
59
+ }, [wallets, getWalletsDelegatedStatus, getWalletsToDelegate]);
52
60
  // Auto-select wallets only on initial load
53
61
  React.useEffect(() => {
54
62
  if (selectionInitialized)
@@ -175,7 +183,7 @@ const WalletDelegationView = ({ wallets, }) => {
175
183
  // Single wallet view
176
184
  const displaySingleWallet = () => {
177
185
  const [wallet] = waasWallets;
178
- if (!wallet)
186
+ if (!wallet || !wallet.address)
179
187
  return null;
180
188
  return (jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-card-container', children: [jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-card', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', color: 'primary', children: t('dyn_wallet_delegation.my_wallet') }), jsxRuntime.jsxs("div", { className: 'embedded-delegated-view__wallet-address', children: [jsxRuntime.jsx("div", { className: 'embedded-delegated-view__wallet-address-dot' }), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_small', color: 'secondary', children: [wallet.address.slice(0, 6), "...", wallet.address.slice(-4)] })] })] }), jsxRuntime.jsx(AgreementSection.AgreementSection, { checked: agreementChecked, onToggle: () => setAgreementChecked(!agreementChecked), text: t('dyn_wallet_delegation.agreement_text') })] }));
181
189
  };
@@ -44,7 +44,15 @@ const WalletDelegationView = ({ wallets, }) => {
44
44
  const [agreementChecked, setAgreementChecked] = useState(false);
45
45
  const [selectionInitialized, setSelectionInitialized] = useState(false);
46
46
  // Get waas wallets that are not yet delegated or use provided wallets override
47
- const waasWallets = useMemo(() => getWalletsToDelegate(wallets, getWalletsDelegatedStatus), [wallets, getWalletsDelegatedStatus]);
47
+ const waasWallets = useMemo(() => {
48
+ const walletsToDelegate = wallets
49
+ ? wallets.map((wallet) => ({
50
+ accountAddress: wallet.address,
51
+ chainName: wallet.chain,
52
+ }))
53
+ : undefined;
54
+ return getWalletsToDelegate(walletsToDelegate, getWalletsDelegatedStatus);
55
+ }, [wallets, getWalletsDelegatedStatus, getWalletsToDelegate]);
48
56
  // Auto-select wallets only on initial load
49
57
  useEffect(() => {
50
58
  if (selectionInitialized)
@@ -171,7 +179,7 @@ const WalletDelegationView = ({ wallets, }) => {
171
179
  // Single wallet view
172
180
  const displaySingleWallet = () => {
173
181
  const [wallet] = waasWallets;
174
- if (!wallet)
182
+ if (!wallet || !wallet.address)
175
183
  return null;
176
184
  return (jsxs("div", { className: 'embedded-delegated-view__wallet-card-container', children: [jsxs("div", { className: 'embedded-delegated-view__wallet-card', children: [jsx(Typography, { variant: 'body_normal', weight: 'medium', color: 'primary', children: t('dyn_wallet_delegation.my_wallet') }), jsxs("div", { className: 'embedded-delegated-view__wallet-address', children: [jsx("div", { className: 'embedded-delegated-view__wallet-address-dot' }), jsxs(Typography, { variant: 'body_small', color: 'secondary', children: [wallet.address.slice(0, 6), "...", wallet.address.slice(-4)] })] })] }), jsx(AgreementSection, { checked: agreementChecked, onToggle: () => setAgreementChecked(!agreementChecked), text: t('dyn_wallet_delegation.agreement_text') })] }));
177
185
  };
@@ -10,11 +10,11 @@ require('../../../../utils/constants/values.cjs');
10
10
  require('@dynamic-labs/utils');
11
11
  require('../../../../../../_virtual/_tslib.cjs');
12
12
  require('@dynamic-labs/multi-wallet');
13
+ require('../../../../shared/logger.cjs');
13
14
  require('react-international-phone');
14
15
  require('../../../../utils/constants/colors.cjs');
15
16
  var getChainIcon = require('../../../../shared/utils/functions/chain/getChainIcon.cjs');
16
17
  require('@dynamic-labs/wallet-connector-core');
17
- require('../../../../shared/logger.cjs');
18
18
  require('react');
19
19
  require('@dynamic-labs/iconic');
20
20
  require('../../../../context/ViewContext/ViewContext.cjs');
@@ -6,11 +6,11 @@ import '../../../../utils/constants/values.js';
6
6
  import '@dynamic-labs/utils';
7
7
  import '../../../../../../_virtual/_tslib.js';
8
8
  import '@dynamic-labs/multi-wallet';
9
+ import '../../../../shared/logger.js';
9
10
  import 'react-international-phone';
10
11
  import '../../../../utils/constants/colors.js';
11
12
  import { getChainIcon } from '../../../../shared/utils/functions/chain/getChainIcon.js';
12
13
  import '@dynamic-labs/wallet-connector-core';
13
- import '../../../../shared/logger.js';
14
14
  import 'react';
15
15
  import '@dynamic-labs/iconic';
16
16
  import '../../../../context/ViewContext/ViewContext.js';
@@ -173,27 +173,27 @@ const WalletsDelegatedSettingsView = ({ name }) => {
173
173
  const handleDelegate = createHandleDelegate(delegateKeyShares);
174
174
  const handleWalletStatusChange = createHandleWalletStatusChange(handleRevoke, handleDelegate);
175
175
  const handleRevokeAll = createHandleRevokeAll(handleRevoke, walletsWithStatus);
176
- return (jsxRuntime.jsxs("div", { className: 'wallets-delegated-settings-view', children: [jsxRuntime.jsxs("div", { className: 'header', children: [jsxRuntime.jsx(IconButton.IconButton, { onClick: () => setDynamicWidgetView('settings'), "data-testid": 'back-button', className: 'back-button', type: 'button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', className: 'title', copykey: 'wallets_delegated.title', children: t('wallets_delegated.title') })] }), walletsWithStatus.length > 0 && (jsxRuntime.jsx("ul", { className: 'delegated-wallets-list', children: walletsWithStatus.map((wallet) => {
177
- var _a, _b;
178
- return (jsxRuntime.jsxs("li", { className: 'delegated-wallets-item', children: [jsxRuntime.jsx("div", { className: 'wallet-icon', children: jsxRuntime.jsx(WalletIconWithNetwork.WalletIconWithNetwork, { walletKey: wallet.key, Icon: null, iconUrl: (_b = (_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.icon, chainName: wallet.chain, iconSize: 24, showNetwork: true }) }), jsxRuntime.jsxs("div", { className: 'wallet-info', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', weight: 'medium', children: shortenWalletAddress.shortenWalletAddress(wallet.address) }), jsxRuntime.jsx("div", { className: wallet.status === 'delegated'
179
- ? 'status-badge'
180
- : 'status-badge status-badge--disconnected', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: wallet.status === 'delegated' ? 'primary' : 'secondary', children: wallet.status === 'delegated'
181
- ? t('connected', 'Connected')
182
- : t('disconnected', 'Disconnected') }) })] }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
183
- yield handleWalletStatusChange(wallet);
184
- }), buttonPadding: 'small', className: 'revoke-button', typographyProps: {
185
- color: 'primary',
186
- variant: 'body_small',
187
- weight: 'medium',
188
- }, children: wallet.status === 'delegated'
189
- ? t('revoke', 'Revoke')
190
- : t('delegate', 'Delegate') })] }, wallet.id));
191
- }) })), walletsWithStatus.filter((w) => w.status === 'delegated').length > 0 && (jsxRuntime.jsx("div", { className: 'revoke-all-section', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
176
+ return (jsxRuntime.jsxs("div", { className: 'wallets-delegated-settings-view', "data-testid": 'wallets-delegated-settings-view', children: [' ', jsxRuntime.jsxs("div", { className: 'header', "data-testid": 'delegated-header', children: [jsxRuntime.jsx(IconButton.IconButton, { onClick: () => setDynamicWidgetView('settings'), "data-testid": 'back-button', className: 'back-button', type: 'button', children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', className: 'title', copykey: 'wallets_delegated.title', "data-testid": 'delegated-title', children: t('wallets_delegated.title') })] }), walletsWithStatus.length > 0 && (jsxRuntime.jsxs("ul", { className: 'delegated-wallets-list', "data-testid": 'delegated-wallets-list', children: [' ', walletsWithStatus.map((wallet, index) => {
177
+ var _a, _b;
178
+ return (jsxRuntime.jsxs("li", { className: 'delegated-wallets-item', "data-testid": `delegated-wallet-item-${index}`, children: [' ', jsxRuntime.jsx("div", { className: 'wallet-icon', children: jsxRuntime.jsx(WalletIconWithNetwork.WalletIconWithNetwork, { walletKey: wallet.key, Icon: null, iconUrl: (_b = (_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.icon, chainName: wallet.chain, iconSize: 24, showNetwork: true }) }), jsxRuntime.jsxs("div", { className: 'wallet-info', "data-testid": `wallet-info-${index}`, children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', weight: 'medium', children: shortenWalletAddress.shortenWalletAddress(wallet.address) }), jsxRuntime.jsx("div", { className: wallet.status === 'delegated'
179
+ ? 'status-badge'
180
+ : 'status-badge status-badge--disconnected', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: wallet.status === 'delegated' ? 'primary' : 'secondary', children: wallet.status === 'delegated'
181
+ ? t('connected', 'Connected')
182
+ : t('disconnected', 'Disconnected') }) })] }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
183
+ yield handleWalletStatusChange(wallet);
184
+ }), buttonPadding: 'small', className: 'revoke-button', typographyProps: {
185
+ color: 'primary',
186
+ variant: 'body_small',
187
+ weight: 'medium',
188
+ }, children: wallet.status === 'delegated'
189
+ ? t('revoke', 'Revoke')
190
+ : t('delegate', 'Delegate') })] }, wallet.id));
191
+ })] })), walletsWithStatus.filter((w) => w.status === 'delegated').length > 0 && (jsxRuntime.jsx("div", { className: 'revoke-all-section', "data-testid": 'revoke-all-section', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
192
192
  yield handleRevokeAll();
193
- }), buttonVariant: 'tertiary', buttonPadding: 'none', className: 'revoke-all-button', typographyProps: {
193
+ }), buttonVariant: 'tertiary', buttonPadding: 'none', className: 'revoke-all-button', "data-testid": 'revoke-all-button', typographyProps: {
194
194
  variant: 'body_normal',
195
195
  weight: 'medium',
196
- }, children: t('revoke_all_wallet_access', 'Revoke all wallet access') }) })), showSuccessMessage && (jsxRuntime.jsxs("div", { className: 'success-message', children: [jsxRuntime.jsx(check.ReactComponent, {}), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'primary', copykey: 'global_wallet.wallets_delegated.success', children: t('global_wallet.wallets_delegated.success', { name }) })] }))] }));
196
+ }, children: t('revoke_all_wallet_access', 'Revoke all wallet access') }) })), showSuccessMessage && (jsxRuntime.jsxs("div", { className: 'success-message', "data-testid": 'success-message', children: [jsxRuntime.jsx(check.ReactComponent, { "data-testid": 'success-icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'primary', copykey: 'global_wallet.wallets_delegated.success', "data-testid": 'success-text', children: t('global_wallet.wallets_delegated.success', { name }) })] }))] }));
197
197
  };
198
198
 
199
199
  exports.WalletsDelegatedSettingsView = WalletsDelegatedSettingsView;