@dynamic-labs/sdk-react-core 3.1.3 → 3.2.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 (45) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +10 -10
  5. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +11 -1
  6. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +12 -2
  7. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +15 -8
  8. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +15 -8
  9. package/src/lib/locale/en/translation.cjs +43 -24
  10. package/src/lib/locale/en/translation.d.ts +43 -24
  11. package/src/lib/locale/en/translation.js +43 -24
  12. package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +5 -5
  13. package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +5 -5
  14. package/src/lib/shared/assets/connected-apps.cjs +64 -0
  15. package/src/lib/shared/assets/connected-apps.js +40 -0
  16. package/src/lib/shared/assets/index.d.ts +1 -0
  17. package/src/lib/styles/index.shadow.cjs +1 -1
  18. package/src/lib/styles/index.shadow.js +1 -1
  19. package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.cjs +24 -0
  20. package/src/lib/utils/functions/getWalletConnectorForWallet/getWalletConnectorForWallet.js +20 -0
  21. package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +3 -0
  22. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +5 -3
  23. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +5 -3
  24. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +9 -0
  25. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +10 -1
  26. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -0
  27. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -0
  28. package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs +9 -2
  29. package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js +10 -3
  30. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +0 -14
  31. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +0 -14
  32. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/DynamicWidgetViews.cjs +4 -2
  33. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/DynamicWidgetViews.js +4 -2
  34. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +8 -1
  35. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +9 -2
  36. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.cjs +4 -1
  37. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +19 -14
  38. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.js +4 -1
  39. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.cjs +180 -0
  40. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.d.ts +12 -0
  41. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.js +175 -0
  42. package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +7 -9
  43. package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +7 -9
  44. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +17 -8
  45. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +17 -8
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletConnectorOptions = require('../../../store/state/walletConnectorOptions.cjs');
7
+
8
+ const getWalletConnectorForWallet = (wallet) => {
9
+ var _a, _b;
10
+ if (!wallet) {
11
+ return undefined;
12
+ }
13
+ const walletConnectorOptions$1 = walletConnectorOptions.getWalletConnectorOptions();
14
+ const { key: walletKey, chain } = wallet;
15
+ const walletConnector = (_a = walletConnectorOptions$1.find((wallet) => walletKey === wallet.key &&
16
+ wallet.walletConnector.connectedChain === chain)) === null || _a === void 0 ? void 0 : _a.walletConnector;
17
+ if (walletConnector) {
18
+ return walletConnector;
19
+ }
20
+ const fallbackConnector = (_b = walletConnectorOptions$1.find((wallet) => wallet.key === 'fallbackconnector')) === null || _b === void 0 ? void 0 : _b.walletConnector;
21
+ return fallbackConnector;
22
+ };
23
+
24
+ exports.getWalletConnectorForWallet = getWalletConnectorForWallet;
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ import { getWalletConnectorOptions } from '../../../store/state/walletConnectorOptions.js';
3
+
4
+ const getWalletConnectorForWallet = (wallet) => {
5
+ var _a, _b;
6
+ if (!wallet) {
7
+ return undefined;
8
+ }
9
+ const walletConnectorOptions = getWalletConnectorOptions();
10
+ const { key: walletKey, chain } = wallet;
11
+ const walletConnector = (_a = walletConnectorOptions.find((wallet) => walletKey === wallet.key &&
12
+ wallet.walletConnector.connectedChain === chain)) === null || _a === void 0 ? void 0 : _a.walletConnector;
13
+ if (walletConnector) {
14
+ return walletConnector;
15
+ }
16
+ const fallbackConnector = (_b = walletConnectorOptions.find((wallet) => wallet.key === 'fallbackconnector')) === null || _b === void 0 ? void 0 : _b.walletConnector;
17
+ return fallbackConnector;
18
+ };
19
+
20
+ export { getWalletConnectorForWallet };
@@ -1,4 +1,5 @@
1
1
  import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
2
+ import { SocialAuthMode } from '../../hooks/useSocialAuth';
2
3
  export declare const SOCIAL_STORAGE_KEY = "dynamic_social_storage";
3
4
  export type SocialStorageItem = {
4
5
  provider: ProviderEnum;
@@ -10,6 +11,8 @@ export type SocialStorageItem = {
10
11
  captchaToken?: string;
11
12
  /** Oauth code from redirect from oauth provider, this will be provided on response from redirect endpoint **/
12
13
  code?: string;
14
+ /** Social auth mode, either sign-in or link */
15
+ mode: SocialAuthMode;
13
16
  };
14
17
  export type SocialStorage = Partial<Record<ProviderEnum, SocialStorageItem>>;
15
18
  export declare const searchSocialStorageByState: (targetState: string) => SocialStorageItem | undefined;
@@ -30,6 +30,7 @@ var session = require('../../../data/api/session/session.cjs');
30
30
  require('../../../locale/locale.cjs');
31
31
  var getWalletProvider = require('../../functions/getWalletProvider/getWalletProvider.cjs');
32
32
  var isConnectOnly = require('../authenticationHooks/helpers/isConnectOnly.cjs');
33
+ var getWalletConnectorForWallet = require('../../functions/getWalletConnectorForWallet/getWalletConnectorForWallet.cjs');
33
34
  var updateUserWalletsFromConnectedWallets = require('./updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.cjs');
34
35
 
35
36
  const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, handleConnectedWallet, setShowAuthFlow, isBridgeFlow, user, }) => {
@@ -136,10 +137,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
136
137
  var _a;
137
138
  const clonedConnectedWalletsList = [...connectedWallets];
138
139
  const connectedWalletIndex = clonedConnectedWalletsList.findIndex((connectedWallet) => connectedWallet.id === walletId);
139
- if (connectedWalletIndex > -1) {
140
- clonedConnectedWalletsList[connectedWalletIndex].address =
141
- (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address;
140
+ if (connectedWalletIndex < 0) {
141
+ return;
142
142
  }
143
+ clonedConnectedWalletsList[connectedWalletIndex] =
144
+ clonedConnectedWalletsList[connectedWalletIndex].connector.createWallet(Object.assign(Object.assign({}, clonedConnectedWalletsList[connectedWalletIndex]), { address: (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address, connector: getWalletConnectorForWallet.getWalletConnectorForWallet(clonedConnectedWalletsList[connectedWalletIndex]) }));
143
145
  setConnectedWallets(clonedConnectedWalletsList);
144
146
  }, [connectedWallets, setConnectedWallets]);
145
147
  // Keeps connected wallet data inside localStorage
@@ -26,6 +26,7 @@ import { createVisit } from '../../../data/api/session/session.js';
26
26
  import '../../../locale/locale.js';
27
27
  import { getWalletProvider } from '../../functions/getWalletProvider/getWalletProvider.js';
28
28
  import { isConnectOnly } from '../authenticationHooks/helpers/isConnectOnly.js';
29
+ import { getWalletConnectorForWallet } from '../../functions/getWalletConnectorForWallet/getWalletConnectorForWallet.js';
29
30
  import { updateUserWalletsFromConnectedWallets } from './updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.js';
30
31
 
31
32
  const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, handleConnectedWallet, setShowAuthFlow, isBridgeFlow, user, }) => {
@@ -132,10 +133,11 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
132
133
  var _a;
133
134
  const clonedConnectedWalletsList = [...connectedWallets];
134
135
  const connectedWalletIndex = clonedConnectedWalletsList.findIndex((connectedWallet) => connectedWallet.id === walletId);
135
- if (connectedWalletIndex > -1) {
136
- clonedConnectedWalletsList[connectedWalletIndex].address =
137
- (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address;
136
+ if (connectedWalletIndex < 0) {
137
+ return;
138
138
  }
139
+ clonedConnectedWalletsList[connectedWalletIndex] =
140
+ clonedConnectedWalletsList[connectedWalletIndex].connector.createWallet(Object.assign(Object.assign({}, clonedConnectedWalletsList[connectedWalletIndex]), { address: (_a = walletObject.address) !== null && _a !== void 0 ? _a : clonedConnectedWalletsList[connectedWalletIndex].address, connector: getWalletConnectorForWallet(clonedConnectedWalletsList[connectedWalletIndex]) }));
139
141
  setConnectedWallets(clonedConnectedWalletsList);
140
142
  }, [connectedWallets, setConnectedWallets]);
141
143
  // Keeps connected wallet data inside localStorage
@@ -19,6 +19,7 @@ require('../../constants/values.cjs');
19
19
  require('../../../store/state/loadingAndLifecycle.cjs');
20
20
  require('../../../shared/consts/index.cjs');
21
21
  require('../../../events/dynamicEvents.cjs');
22
+ var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWalletConnectorEvent.cjs');
22
23
  require('../../../context/CaptchaContext/CaptchaContext.cjs');
23
24
  require('../../../context/ErrorContext/ErrorContext.cjs');
24
25
  require('@dynamic-labs/multi-wallet');
@@ -140,6 +141,14 @@ const useConnectedWalletsNetworkValidation = () => {
140
141
  setShowAuthFlow,
141
142
  setView,
142
143
  ]);
144
+ const uniqueConnectors = React.useMemo(() => {
145
+ const connectors = connectedWallets.map(({ connector }) => connector);
146
+ const allWalletConnectors = new Set([...connectors].filter((connector) => Boolean(connector)));
147
+ return Array.from(allWalletConnectors);
148
+ }, [connectedWallets]);
149
+ useWalletConnectorEvent.useWalletConnectorEvent(uniqueConnectors, 'chainChange', ({ chain }) => {
150
+ validateNetwork();
151
+ });
143
152
  React.useEffect(() => {
144
153
  /**
145
154
  * This check was added to prevent the "wrong network" modal from appearing
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
- import { useCallback, useEffect } from 'react';
3
+ import { useCallback, useMemo, useEffect } from 'react';
4
4
  import '../../../context/DynamicContext/DynamicContext.js';
5
5
  import '@dynamic-labs/sdk-api-core';
6
6
  import '../../../shared/logger.js';
@@ -15,6 +15,7 @@ import '../../constants/values.js';
15
15
  import '../../../store/state/loadingAndLifecycle.js';
16
16
  import '../../../shared/consts/index.js';
17
17
  import '../../../events/dynamicEvents.js';
18
+ import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWalletConnectorEvent.js';
18
19
  import '../../../context/CaptchaContext/CaptchaContext.js';
19
20
  import '../../../context/ErrorContext/ErrorContext.js';
20
21
  import '@dynamic-labs/multi-wallet';
@@ -136,6 +137,14 @@ const useConnectedWalletsNetworkValidation = () => {
136
137
  setShowAuthFlow,
137
138
  setView,
138
139
  ]);
140
+ const uniqueConnectors = useMemo(() => {
141
+ const connectors = connectedWallets.map(({ connector }) => connector);
142
+ const allWalletConnectors = new Set([...connectors].filter((connector) => Boolean(connector)));
143
+ return Array.from(allWalletConnectors);
144
+ }, [connectedWallets]);
145
+ useWalletConnectorEvent(uniqueConnectors, 'chainChange', ({ chain }) => {
146
+ validateNetwork();
147
+ });
139
148
  useEffect(() => {
140
149
  /**
141
150
  * This check was added to prevent the "wrong network" modal from appearing
@@ -369,6 +369,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
369
369
  socialStorage.setSocialStorageFor(provider, {
370
370
  captchaToken,
371
371
  codeVerifier: usingPkce ? verifier : undefined,
372
+ mode: authMode,
372
373
  state,
373
374
  });
374
375
  const loginUrlString = getOauthLoginUrl.getOauthLoginUrl((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
@@ -365,6 +365,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
365
365
  setSocialStorageFor(provider, {
366
366
  captchaToken,
367
367
  codeVerifier: usingPkce ? verifier : undefined,
368
+ mode: authMode,
368
369
  state,
369
370
  });
370
371
  const loginUrlString = getOauthLoginUrl((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
@@ -4,6 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
8
  var findWalletOptionFor = require('../../../../functions/findWalletOptionFor/findWalletOptionFor.cjs');
8
9
  var shouldManuallyReconnectOnRefresh = require('../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
9
10
  var convertLegacyPhantomLedgerConnector = require('../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.cjs');
@@ -17,7 +18,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
17
18
  return user.verifiedCredentials
18
19
  .map(convertLegacyPhantomLedger)
19
20
  .map((account) => {
20
- var _a;
21
+ var _a, _b;
21
22
  const wallet = findWalletOptionFor.findWalletOptionFor(account, walletConnectorOptions);
22
23
  // this probably shouldn't happen. this would mean that the user has an account linked
23
24
  // with wallet W, but the customer has toggled off wallet W or the chain that
@@ -29,6 +30,12 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
29
30
  shouldManuallyReconnectOnRefresh.shouldManuallyReconnectOnRefresh(wallet.walletConnector)) {
30
31
  wallet.walletConnector.connect();
31
32
  }
33
+ // only checking for ledger hardware wallets since we only specify ledger as a hardware wallet
34
+ if (((_a = account.walletProperties) === null || _a === void 0 ? void 0 : _a.hardwareWallet) ===
35
+ sdkApiCore.HardwareWalletEnum.Ledger &&
36
+ walletConnectorCore.isHardwareWalletConnector(wallet.walletConnector)) {
37
+ wallet.walletConnector.isHardwareWalletEnabled = true;
38
+ }
32
39
  // this account is the owner of a smart wallet, and should not be surfaced
33
40
  if (smartWallet.isOwnerOfASmartWallet(account, user.verifiedCredentials)) {
34
41
  return null;
@@ -48,7 +55,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
48
55
  connector: wallet.walletConnector,
49
56
  id: account.id,
50
57
  isAuthenticated: true,
51
- key: (_a = account.walletName) !== null && _a !== void 0 ? _a : wallet.walletConnector.key,
58
+ key: (_b = account.walletName) !== null && _b !== void 0 ? _b : wallet.walletConnector.key,
52
59
  });
53
60
  }
54
61
  return null;
@@ -1,5 +1,6 @@
1
1
  'use client'
2
- import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
2
+ import { HardwareWalletEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
3
+ import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
3
4
  import { findWalletOptionFor } from '../../../../functions/findWalletOptionFor/findWalletOptionFor.js';
4
5
  import { shouldManuallyReconnectOnRefresh } from '../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
5
6
  import { convertLegacyPhantomLedgerConnector } from '../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.js';
@@ -13,7 +14,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
13
14
  return user.verifiedCredentials
14
15
  .map(convertLegacyPhantomLedger)
15
16
  .map((account) => {
16
- var _a;
17
+ var _a, _b;
17
18
  const wallet = findWalletOptionFor(account, walletConnectorOptions);
18
19
  // this probably shouldn't happen. this would mean that the user has an account linked
19
20
  // with wallet W, but the customer has toggled off wallet W or the chain that
@@ -25,6 +26,12 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
25
26
  shouldManuallyReconnectOnRefresh(wallet.walletConnector)) {
26
27
  wallet.walletConnector.connect();
27
28
  }
29
+ // only checking for ledger hardware wallets since we only specify ledger as a hardware wallet
30
+ if (((_a = account.walletProperties) === null || _a === void 0 ? void 0 : _a.hardwareWallet) ===
31
+ HardwareWalletEnum.Ledger &&
32
+ isHardwareWalletConnector(wallet.walletConnector)) {
33
+ wallet.walletConnector.isHardwareWalletEnabled = true;
34
+ }
28
35
  // this account is the owner of a smart wallet, and should not be surfaced
29
36
  if (isOwnerOfASmartWallet(account, user.verifiedCredentials)) {
30
37
  return null;
@@ -44,7 +51,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
44
51
  connector: wallet.walletConnector,
45
52
  id: account.id,
46
53
  isAuthenticated: true,
47
- key: (_a = account.walletName) !== null && _a !== void 0 ? _a : wallet.walletConnector.key,
54
+ key: (_b = account.walletName) !== null && _b !== void 0 ? _b : wallet.walletConnector.key,
48
55
  });
49
56
  }
50
57
  return null;
@@ -22,13 +22,6 @@ var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWall
22
22
  var dynamicEvents = require('../../../events/dynamicEvents.cjs');
23
23
 
24
24
  const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, detectNewWalletsForLinking, }) => {
25
- useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', ({ chain }) => {
26
- logger.logger.debug('primary wallet chain change', { chain });
27
- if (!primaryWallet) {
28
- return;
29
- }
30
- refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
31
- });
32
25
  const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
33
26
  logger.logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
34
27
  isPrimaryWallet,
@@ -149,13 +142,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
149
142
  handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
150
143
  }
151
144
  }));
152
- useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', (_, changedConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
153
- logger.logger.debug('secondary wallet chain change');
154
- // Get all wallets with this connector
155
- const affectedWallets = secondaryWallets.filter(({ connector }) => connector.key === changedConnector.key);
156
- for (const wallet of affectedWallets)
157
- refreshConnectedWallet(wallet.id, wallet.connector);
158
- }));
159
145
  useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
160
146
  logger.logger.debug('primary wallet disconnect');
161
147
  if (authMode === 'connect-only') {
@@ -18,13 +18,6 @@ import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWa
18
18
  import { dynamicEvents } from '../../../events/dynamicEvents.js';
19
19
 
20
20
  const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, detectNewWalletsForLinking, }) => {
21
- useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', ({ chain }) => {
22
- logger.debug('primary wallet chain change', { chain });
23
- if (!primaryWallet) {
24
- return;
25
- }
26
- refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
27
- });
28
21
  const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
29
22
  logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
30
23
  isPrimaryWallet,
@@ -145,13 +138,6 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
145
138
  handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
146
139
  }
147
140
  }));
148
- useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', (_, changedConnector) => __awaiter(void 0, void 0, void 0, function* () {
149
- logger.debug('secondary wallet chain change');
150
- // Get all wallets with this connector
151
- const affectedWallets = secondaryWallets.filter(({ connector }) => connector.key === changedConnector.key);
152
- for (const wallet of affectedWallets)
153
- refreshConnectedWallet(wallet.id, wallet.connector);
154
- }));
155
141
  useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
156
142
  logger.debug('primary wallet disconnect');
157
143
  if (authMode === 'connect-only') {
@@ -13,8 +13,10 @@ var ManagePasskeysWidgetView = require('../../views/ManagePasskeysWidgetView/Man
13
13
  var SettingsView = require('../../views/SettingsView/SettingsView.cjs');
14
14
  var ManageMfaWidgetView = require('../../views/ManageMfaWidgetView/ManageMfaWidgetView.cjs');
15
15
  var GlobalWalletView = require('../../views/GlobalWalletView/GlobalWalletView.cjs');
16
+ var ConnectedAppsView = require('../../views/ConnectedAppsView/ConnectedAppsView.cjs');
16
17
 
17
18
  const mapViewToComponent = {
19
+ 'connected-apps': ConnectedAppsView.ConnectedAppsView,
18
20
  'edit-profile': EditProfileView.EditProfileView,
19
21
  'global-wallet': GlobalWalletView.GlobalWalletView,
20
22
  'manage-mfa': ManageMfaWidgetView.ManageMfaWidgetView,
@@ -25,9 +27,9 @@ const mapViewToComponent = {
25
27
  wallets: WalletsView.WalletsView,
26
28
  };
27
29
  const DynamicWidgetViews = () => {
28
- const { dynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
30
+ const { dynamicWidgetView, viewProps } = DynamicWidgetContext.useWidgetContext();
29
31
  const ViewComponent = mapViewToComponent[dynamicWidgetView] || mapViewToComponent.wallets;
30
- return jsxRuntime.jsx(ViewComponent, {});
32
+ return jsxRuntime.jsx(ViewComponent, Object.assign({}, viewProps));
31
33
  };
32
34
 
33
35
  exports.DynamicWidgetViews = DynamicWidgetViews;
@@ -9,8 +9,10 @@ import { ManagePasskeysWidgetView } from '../../views/ManagePasskeysWidgetView/M
9
9
  import { SettingsView } from '../../views/SettingsView/SettingsView.js';
10
10
  import { ManageMfaWidgetView } from '../../views/ManageMfaWidgetView/ManageMfaWidgetView.js';
11
11
  import { GlobalWalletView } from '../../views/GlobalWalletView/GlobalWalletView.js';
12
+ import { ConnectedAppsView } from '../../views/ConnectedAppsView/ConnectedAppsView.js';
12
13
 
13
14
  const mapViewToComponent = {
15
+ 'connected-apps': ConnectedAppsView,
14
16
  'edit-profile': EditProfileView,
15
17
  'global-wallet': GlobalWalletView,
16
18
  'manage-mfa': ManageMfaWidgetView,
@@ -21,9 +23,9 @@ const mapViewToComponent = {
21
23
  wallets: WalletsView,
22
24
  };
23
25
  const DynamicWidgetViews = () => {
24
- const { dynamicWidgetView } = useWidgetContext();
26
+ const { dynamicWidgetView, viewProps } = useWidgetContext();
25
27
  const ViewComponent = mapViewToComponent[dynamicWidgetView] || mapViewToComponent.wallets;
26
- return jsx(ViewComponent, {});
28
+ return jsx(ViewComponent, Object.assign({}, viewProps));
27
29
  };
28
30
 
29
31
  export { DynamicWidgetViews, mapViewToComponent };
@@ -100,7 +100,12 @@ const DynamicWidgetContextProvider = ({ children, }) => {
100
100
  const availableWalletsContainerRef = React.useRef(null);
101
101
  const { setShowDynamicUserProfile, showDynamicUserProfile, multiWallet } = useInternalDynamicContext.useInternalDynamicContext();
102
102
  const isKYCEnabled = useKYCFlag.useKYCFlag();
103
- const { view: dynamicWidgetView, setView: setDynamicWidgetView, goToInitialView: goToInitialDynamicWidgetView, } = useViewController.useViewController(isKYCEnabled && !multiWallet ? 'profile' : 'wallets');
103
+ const { view: dynamicWidgetView, setView, goToInitialView: goToInitialDynamicWidgetView, } = useViewController.useViewController(isKYCEnabled && !multiWallet ? 'profile' : 'wallets');
104
+ const [viewProps, setViewProps] = React.useState({});
105
+ const setDynamicWidgetView = React.useCallback((view, props) => {
106
+ setView(view);
107
+ setViewProps(props || {});
108
+ }, [setView]);
104
109
  const goToProfileView = React.useCallback(() => {
105
110
  if (isKYCEnabled)
106
111
  return setDynamicWidgetView('profile');
@@ -132,6 +137,7 @@ const DynamicWidgetContextProvider = ({ children, }) => {
132
137
  overridenWidgetView,
133
138
  setDynamicWidgetView,
134
139
  setIsOpen: setShowDynamicUserProfile,
140
+ viewProps,
135
141
  widgetRef,
136
142
  }), [
137
143
  dynamicWidgetView,
@@ -141,6 +147,7 @@ const DynamicWidgetContextProvider = ({ children, }) => {
141
147
  setDynamicWidgetView,
142
148
  setShowDynamicUserProfile,
143
149
  overridenWidgetView,
150
+ viewProps,
144
151
  ]);
145
152
  return (jsxRuntime.jsx(DynamicWidgetContext.Provider, { value: value, children: children }));
146
153
  };
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { createContext, useRef, useCallback, useMemo, useContext } from 'react';
3
+ import { createContext, useRef, useState, useCallback, useMemo, useContext } from 'react';
4
4
  import '../../../context/DynamicContext/DynamicContext.js';
5
5
  import '@dynamic-labs/sdk-api-core';
6
6
  import '../../../shared/logger.js';
@@ -96,7 +96,12 @@ const DynamicWidgetContextProvider = ({ children, }) => {
96
96
  const availableWalletsContainerRef = useRef(null);
97
97
  const { setShowDynamicUserProfile, showDynamicUserProfile, multiWallet } = useInternalDynamicContext();
98
98
  const isKYCEnabled = useKYCFlag();
99
- const { view: dynamicWidgetView, setView: setDynamicWidgetView, goToInitialView: goToInitialDynamicWidgetView, } = useViewController(isKYCEnabled && !multiWallet ? 'profile' : 'wallets');
99
+ const { view: dynamicWidgetView, setView, goToInitialView: goToInitialDynamicWidgetView, } = useViewController(isKYCEnabled && !multiWallet ? 'profile' : 'wallets');
100
+ const [viewProps, setViewProps] = useState({});
101
+ const setDynamicWidgetView = useCallback((view, props) => {
102
+ setView(view);
103
+ setViewProps(props || {});
104
+ }, [setView]);
100
105
  const goToProfileView = useCallback(() => {
101
106
  if (isKYCEnabled)
102
107
  return setDynamicWidgetView('profile');
@@ -128,6 +133,7 @@ const DynamicWidgetContextProvider = ({ children, }) => {
128
133
  overridenWidgetView,
129
134
  setDynamicWidgetView,
130
135
  setIsOpen: setShowDynamicUserProfile,
136
+ viewProps,
131
137
  widgetRef,
132
138
  }), [
133
139
  dynamicWidgetView,
@@ -137,6 +143,7 @@ const DynamicWidgetContextProvider = ({ children, }) => {
137
143
  setDynamicWidgetView,
138
144
  setShowDynamicUserProfile,
139
145
  overridenWidgetView,
146
+ viewProps,
140
147
  ]);
141
148
  return (jsx(DynamicWidgetContext.Provider, { value: value, children: children }));
142
149
  };
@@ -4,7 +4,10 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  const DynamicSettingsViews = ['settings'];
7
- const DynamicGlobalWalletViews = ['global-wallet'];
7
+ const DynamicGlobalWalletViews = [
8
+ 'global-wallet',
9
+ 'connected-apps',
10
+ ];
8
11
  const DynamicPasskeyWidgetViews = ['manage-passkeys'];
9
12
  const DynamicMfaWidgetViews = ['manage-mfa'];
10
13
  const DynamicTransactionsWidgetViews = ['send-balance'];
@@ -1,19 +1,8 @@
1
1
  import { Dispatch, RefObject, SetStateAction } from 'react';
2
- export interface WidgetContextProps {
3
- availableWalletsContainerRef: RefObject<HTMLDivElement>;
4
- dynamicWidgetView: DynamicWidgetViews;
5
- goToProfileView: () => void;
6
- goToInitialDynamicWidgetView: () => void;
7
- inlineControlsRef: RefObject<HTMLDivElement>;
8
- isOpen: boolean;
9
- setDynamicWidgetView: Dispatch<SetStateAction<DynamicWidgetViews>>;
10
- setIsOpen: Dispatch<SetStateAction<boolean>>;
11
- widgetRef: RefObject<HTMLDivElement>;
12
- overridenWidgetView: DynamicWidgetViews;
13
- }
2
+ import { ConnectedAppsViewProps } from '../views/ConnectedAppsView/ConnectedAppsView';
14
3
  export declare const DynamicSettingsViews: readonly ["settings"];
15
4
  export type DynamicSettingsType = typeof DynamicSettingsViews[number];
16
- export declare const DynamicGlobalWalletViews: readonly ["global-wallet"];
5
+ export declare const DynamicGlobalWalletViews: readonly ["global-wallet", "connected-apps"];
17
6
  export type DynamicGlobalWalletType = typeof DynamicGlobalWalletViews[number];
18
7
  export declare const DynamicPasskeyWidgetViews: readonly ["manage-passkeys"];
19
8
  export declare const DynamicMfaWidgetViews: readonly ["manage-mfa"];
@@ -21,4 +10,20 @@ export type DynamicPasskeyWidgetViewsType = typeof DynamicPasskeyWidgetViews[num
21
10
  export type DynamicMfaWidgetViewsType = typeof DynamicMfaWidgetViews[number];
22
11
  export declare const DynamicTransactionsWidgetViews: readonly ["send-balance"];
23
12
  export type DynamicTransactionsWidgetViewsType = typeof DynamicTransactionsWidgetViews[number];
24
- export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType;
13
+ export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType | 'connected-apps';
14
+ export type ViewProps = {
15
+ 'connected-apps': ConnectedAppsViewProps;
16
+ };
17
+ export type WidgetContextProps = {
18
+ availableWalletsContainerRef: RefObject<HTMLDivElement>;
19
+ dynamicWidgetView: DynamicWidgetViews;
20
+ goToInitialDynamicWidgetView: () => void;
21
+ goToProfileView: () => void;
22
+ inlineControlsRef: RefObject<HTMLDivElement>;
23
+ isOpen: boolean;
24
+ overridenWidgetView: DynamicWidgetViews;
25
+ setDynamicWidgetView: <T extends DynamicWidgetViews>(view: T, props?: T extends keyof ViewProps ? ViewProps[T] : never) => void;
26
+ setIsOpen: Dispatch<SetStateAction<boolean>>;
27
+ widgetRef: RefObject<HTMLDivElement>;
28
+ viewProps: Record<string, unknown>;
29
+ };
@@ -1,6 +1,9 @@
1
1
  'use client'
2
2
  const DynamicSettingsViews = ['settings'];
3
- const DynamicGlobalWalletViews = ['global-wallet'];
3
+ const DynamicGlobalWalletViews = [
4
+ 'global-wallet',
5
+ 'connected-apps',
6
+ ];
4
7
  const DynamicPasskeyWidgetViews = ['manage-passkeys'];
5
8
  const DynamicMfaWidgetViews = ['manage-mfa'];
6
9
  const DynamicTransactionsWidgetViews = ['send-balance'];