@dynamic-labs/sdk-react-core 4.8.2 → 4.8.3

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 (39) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  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/components/SyncAuthFlow/SyncAuthFlow.cjs +2 -0
  9. package/src/lib/components/SyncAuthFlow/SyncAuthFlow.js +2 -0
  10. package/src/lib/locale/en/translation.cjs +2 -1
  11. package/src/lib/locale/en/translation.d.ts +2 -1
  12. package/src/lib/locale/en/translation.js +2 -1
  13. package/src/lib/store/state/dynamicContextProps/dynamicContextProps.cjs +2 -0
  14. package/src/lib/store/state/dynamicContextProps/dynamicContextProps.d.ts +2 -0
  15. package/src/lib/store/state/dynamicContextProps/dynamicContextProps.js +2 -1
  16. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.cjs +2 -2
  17. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.js +2 -2
  18. package/src/lib/utils/hooks/index.d.ts +2 -0
  19. package/src/lib/utils/hooks/useDynamicWaas/constants.cjs +10 -0
  20. package/src/lib/utils/hooks/useDynamicWaas/constants.d.ts +2 -0
  21. package/src/lib/utils/hooks/useDynamicWaas/constants.js +5 -0
  22. package/src/lib/utils/hooks/useDynamicWaas/index.d.ts +1 -0
  23. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +220 -0
  24. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +21 -0
  25. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +215 -0
  26. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +9 -5
  27. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +10 -6
  28. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +14 -1
  29. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +15 -2
  30. package/src/lib/utils/hooks/useSyncDynamicWaas/index.d.ts +1 -0
  31. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +145 -0
  32. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.d.ts +1 -0
  33. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +141 -0
  34. package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.cjs +6 -3
  35. package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.js +6 -3
  36. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +1 -1
  37. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +1 -1
  38. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +1 -1
  39. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
 
2
+ ### [4.8.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.2...v4.8.3) (2025-03-04)
3
+
4
+
2
5
  ### [4.8.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.1...v4.8.2) (2025-03-01)
3
6
 
4
7
 
package/package.cjs CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.8.2";
6
+ var version = "4.8.3";
7
7
  var dependencies = {
8
- "@dynamic-labs/sdk-api-core": "0.0.633",
8
+ "@dynamic-labs/sdk-api-core": "0.0.638",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
10
10
  "@thumbmarkjs/thumbmarkjs": "0.16.0",
11
11
  "country-list": "2.3.0",
package/package.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client'
2
- var version = "4.8.2";
2
+ var version = "4.8.3";
3
3
  var dependencies = {
4
- "@dynamic-labs/sdk-api-core": "0.0.633",
4
+ "@dynamic-labs/sdk-api-core": "0.0.638",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
6
6
  "@thumbmarkjs/thumbmarkjs": "0.16.0",
7
7
  "country-list": "2.3.0",
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.8.2",
3
+ "version": "4.8.3",
4
4
  "dependencies": {
5
- "@dynamic-labs/sdk-api-core": "0.0.633",
5
+ "@dynamic-labs/sdk-api-core": "0.0.638",
6
6
  "@hcaptcha/react-hcaptcha": "1.4.4",
7
7
  "@thumbmarkjs/thumbmarkjs": "0.16.0",
8
8
  "country-list": "2.3.0",
@@ -14,16 +14,16 @@
14
14
  "yup": "0.32.11",
15
15
  "react-international-phone": "4.2.5",
16
16
  "bs58": "5.0.0",
17
- "@dynamic-labs/assert-package-version": "4.8.2",
18
- "@dynamic-labs/iconic": "4.8.2",
19
- "@dynamic-labs/logger": "4.8.2",
20
- "@dynamic-labs/multi-wallet": "4.8.2",
21
- "@dynamic-labs/rpc-providers": "4.8.2",
22
- "@dynamic-labs/store": "4.8.2",
23
- "@dynamic-labs/types": "4.8.2",
24
- "@dynamic-labs/utils": "4.8.2",
25
- "@dynamic-labs/wallet-book": "4.8.2",
26
- "@dynamic-labs/wallet-connector-core": "4.8.2",
17
+ "@dynamic-labs/assert-package-version": "4.8.3",
18
+ "@dynamic-labs/iconic": "4.8.3",
19
+ "@dynamic-labs/logger": "4.8.3",
20
+ "@dynamic-labs/multi-wallet": "4.8.3",
21
+ "@dynamic-labs/rpc-providers": "4.8.3",
22
+ "@dynamic-labs/store": "4.8.3",
23
+ "@dynamic-labs/types": "4.8.3",
24
+ "@dynamic-labs/utils": "4.8.3",
25
+ "@dynamic-labs/wallet-book": "4.8.3",
26
+ "@dynamic-labs/wallet-connector-core": "4.8.3",
27
27
  "eventemitter3": "5.0.1"
28
28
  },
29
29
  "devDependencies": {
package/src/index.cjs CHANGED
@@ -142,6 +142,7 @@ var WalletList = require('./lib/views/WalletList/WalletList.cjs');
142
142
  var FarcasterConnectView = require('./lib/views/FarcasterConnectView/FarcasterConnectView.cjs');
143
143
  var NetworkNotSupportedSwitchManual = require('./lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs');
144
144
  var viewToComponentMap = require('./lib/views/viewToComponentMap.cjs');
145
+ var useDynamicWaas = require('./lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs');
145
146
  var useDynamicModals = require('./lib/utils/hooks/useDynamicModals/useDynamicModals.cjs');
146
147
  var useMfa = require('./lib/utils/hooks/useMfa/useMfa.cjs');
147
148
  var useTokenBalances = require('./lib/utils/hooks/useTokenBalances/useTokenBalances.cjs');
@@ -268,6 +269,7 @@ exports.WalletList = WalletList.WalletList;
268
269
  exports.FarcasterConnectView = FarcasterConnectView.FarcasterConnectView;
269
270
  exports.NetworkNotSupportedSwitchManual = NetworkNotSupportedSwitchManual.NetworkNotSupportedSwitchManual;
270
271
  exports.viewToComponentMap = viewToComponentMap.viewToComponentMap;
272
+ exports.useDynamicWaas = useDynamicWaas.useDynamicWaas;
271
273
  exports.useDynamicModals = useDynamicModals.useDynamicModals;
272
274
  exports.useMfa = useMfa.useMfa;
273
275
  exports.useTokenBalances = useTokenBalances.useTokenBalances;
package/src/index.d.ts CHANGED
@@ -114,7 +114,7 @@ export { FilterAndSortWallets, FilterBridgeChainsName, FilterChain, FilterWallet
114
114
  export {
115
115
  /** @deprecated */
116
116
  DynamicWidgetContextProvider, } from './lib/widgets/DynamicWidget/context';
117
- export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedWallet, useEmbeddedWalletAuthenticator, usePasskeyRecovery, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useWalletOptions, useSmartWallets, EmbeddedWalletVersion, useTelegramLogin, useUpgradeEmbeddedWallet, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, } from './lib/utils/hooks';
117
+ export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedWallet, useEmbeddedWalletAuthenticator, usePasskeyRecovery, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useWalletOptions, useSmartWallets, EmbeddedWalletVersion, useTelegramLogin, useUpgradeEmbeddedWallet, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, useDynamicWaas, } from './lib/utils/hooks';
118
118
  export {
119
119
  /** @deprecated use useOnramp instead */
120
120
  useFunding, } from './lib/utils/hooks/useFunding';
package/src/index.js CHANGED
@@ -138,6 +138,7 @@ export { WalletList } from './lib/views/WalletList/WalletList.js';
138
138
  export { FarcasterConnectView } from './lib/views/FarcasterConnectView/FarcasterConnectView.js';
139
139
  export { NetworkNotSupportedSwitchManual } from './lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js';
140
140
  export { viewToComponentMap } from './lib/views/viewToComponentMap.js';
141
+ export { useDynamicWaas } from './lib/utils/hooks/useDynamicWaas/useDynamicWaas.js';
141
142
  export { useDynamicModals } from './lib/utils/hooks/useDynamicModals/useDynamicModals.js';
142
143
  export { useMfa } from './lib/utils/hooks/useMfa/useMfa.js';
143
144
  export { useTokenBalances } from './lib/utils/hooks/useTokenBalances/useTokenBalances.js';
@@ -95,9 +95,11 @@ var useSyncEmbeddedWalletFlow = require('../../utils/hooks/useSyncEmbeddedWallet
95
95
  var useSyncOnboardingFlow = require('../../utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs');
96
96
  var useSyncMfaFlow = require('../../utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs');
97
97
  require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
98
+ var useSyncDynamicWaas = require('../../utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs');
98
99
 
99
100
  const SyncAuthFlow = () => {
100
101
  useSyncOnboardingFlow.useSyncOnboardingFlow();
102
+ useSyncDynamicWaas.useSyncDynamicWaas();
101
103
  useSyncEmbeddedWalletFlow.useSyncEmbeddedWalletFlow();
102
104
  useSyncMfaFlow.useSyncMfaFlow();
103
105
  return null;
@@ -91,9 +91,11 @@ import { useSyncEmbeddedWalletFlow } from '../../utils/hooks/useSyncEmbeddedWall
91
91
  import { useSyncOnboardingFlow } from '../../utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js';
92
92
  import { useSyncMfaFlow } from '../../utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js';
93
93
  import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
94
+ import { useSyncDynamicWaas } from '../../utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js';
94
95
 
95
96
  const SyncAuthFlow = () => {
96
97
  useSyncOnboardingFlow();
98
+ useSyncDynamicWaas();
97
99
  useSyncEmbeddedWalletFlow();
98
100
  useSyncMfaFlow();
99
101
  return null;
@@ -995,7 +995,8 @@ const translation = {
995
995
  delete_account: {
996
996
  title: 'Delete My Account',
997
997
  description: 'Deleting your account will permanently remove all data, including wallet details and linked smart contract wallets. This action cannot be undone.',
998
- backup_confirmation: "I confirm I've backed up my wallet key. If I return, a new wallet will be created.",
998
+ backup_confirmation_embedded: "I confirm I've backed up my wallet keys. If I proceed, a new wallet will be created. Any wallets or assets not backed up will be lost permanently.",
999
+ backup_confirmation_no_embedded: 'I confirm that all of my information will be deleted. If I return, a new user profile will be created. These changes cannot be undone.',
999
1000
  type_delete: 'Enter DELETE in the box below to confirm this action.',
1000
1001
  cancel: 'Cancel',
1001
1002
  confirm: 'Delete Account',
@@ -991,7 +991,8 @@ export declare const translation: {
991
991
  delete_account: {
992
992
  title: string;
993
993
  description: string;
994
- backup_confirmation: string;
994
+ backup_confirmation_embedded: string;
995
+ backup_confirmation_no_embedded: string;
995
996
  type_delete: string;
996
997
  cancel: string;
997
998
  confirm: string;
@@ -991,7 +991,8 @@ const translation = {
991
991
  delete_account: {
992
992
  title: 'Delete My Account',
993
993
  description: 'Deleting your account will permanently remove all data, including wallet details and linked smart contract wallets. This action cannot be undone.',
994
- backup_confirmation: "I confirm I've backed up my wallet key. If I return, a new wallet will be created.",
994
+ backup_confirmation_embedded: "I confirm I've backed up my wallet keys. If I proceed, a new wallet will be created. Any wallets or assets not backed up will be lost permanently.",
995
+ backup_confirmation_no_embedded: 'I confirm that all of my information will be deleted. If I return, a new user profile will be created. These changes cannot be undone.',
995
996
  type_delete: 'Enter DELETE in the box below to confirm this action.',
996
997
  cancel: 'Cancel',
997
998
  confirm: 'Delete Account',
@@ -20,6 +20,7 @@ const setEnvironmentId = (environmentId) => {
20
20
  const props = getDynamicContextProps();
21
21
  setDynamicContextProps(Object.assign(Object.assign({}, props), { settings: Object.assign(Object.assign({}, props.settings), { environmentId }) }));
22
22
  };
23
+ const useApiBaseUrl = () => useDynamicSettings().apiBaseUrl;
23
24
  const applyDefaultSettings = (settings) => {
24
25
  const newSettings = Object.assign({}, settings);
25
26
  Object.keys(defaultDynamicSettings.defaultDynamicSettings).forEach((key) => {
@@ -72,6 +73,7 @@ exports.getDynamicSettings = getDynamicSettings;
72
73
  exports.getEnvironmentId = getEnvironmentId;
73
74
  exports.setDynamicContextProps = setDynamicContextProps;
74
75
  exports.setEnvironmentId = setEnvironmentId;
76
+ exports.useApiBaseUrl = useApiBaseUrl;
75
77
  exports.useDynamicContextProps = useDynamicContextProps;
76
78
  exports.useDynamicSettings = useDynamicSettings;
77
79
  exports.useEnvironmentId = useEnvironmentId;
@@ -7,6 +7,8 @@ export declare const useDynamicSettings: () => SettingsWithDefaults;
7
7
  export declare const getEnvironmentId: () => string;
8
8
  export declare const useEnvironmentId: () => string;
9
9
  export declare const setEnvironmentId: (environmentId: string) => void;
10
+ export declare const getApiBaseUrl: () => string | undefined;
11
+ export declare const useApiBaseUrl: () => string | undefined;
10
12
  export declare const isBridgeFlow: () => boolean;
11
13
  export declare const applyDefaultSettings: (settings: DynamicContextProps['settings']) => SettingsWithDefaults;
12
14
  export declare const useSyncDynamicContextProps: ({ settings, emitErrors, enableInstrumentation, locale, theme, }: DynamicContextProps) => void;
@@ -16,6 +16,7 @@ const setEnvironmentId = (environmentId) => {
16
16
  const props = getDynamicContextProps();
17
17
  setDynamicContextProps(Object.assign(Object.assign({}, props), { settings: Object.assign(Object.assign({}, props.settings), { environmentId }) }));
18
18
  };
19
+ const useApiBaseUrl = () => useDynamicSettings().apiBaseUrl;
19
20
  const applyDefaultSettings = (settings) => {
20
21
  const newSettings = Object.assign({}, settings);
21
22
  Object.keys(defaultDynamicSettings).forEach((key) => {
@@ -62,4 +63,4 @@ const useSyncDynamicContextProps = ({ settings, emitErrors, enableInstrumentatio
62
63
  ]);
63
64
  };
64
65
 
65
- export { applyDefaultSettings, getDynamicContextProps, getDynamicSettings, getEnvironmentId, setDynamicContextProps, setEnvironmentId, useDynamicContextProps, useDynamicSettings, useEnvironmentId, useSyncDynamicContextProps };
66
+ export { applyDefaultSettings, getDynamicContextProps, getDynamicSettings, getEnvironmentId, setDynamicContextProps, setEnvironmentId, useApiBaseUrl, useDynamicContextProps, useDynamicSettings, useEnvironmentId, useSyncDynamicContextProps };
@@ -11,8 +11,8 @@ const formatCoinbaseOnrampUrl = (url, wallet) => {
11
11
  }
12
12
  const filteredNetworks = networks.filter((network) => !network.isTestnet);
13
13
  const onlyKeys = filteredNetworks
14
- .map((network) => network.key)
15
- .filter((key) => Boolean(key));
14
+ .filter((network) => Boolean(network.key)) // filter out networks without keys
15
+ .map((network) => network.key);
16
16
  const addressesObj = {
17
17
  [wallet.address]: onlyKeys,
18
18
  };
@@ -7,8 +7,8 @@ const formatCoinbaseOnrampUrl = (url, wallet) => {
7
7
  }
8
8
  const filteredNetworks = networks.filter((network) => !network.isTestnet);
9
9
  const onlyKeys = filteredNetworks
10
- .map((network) => network.key)
11
- .filter((key) => Boolean(key));
10
+ .filter((network) => Boolean(network.key)) // filter out networks without keys
11
+ .map((network) => network.key);
12
12
  const addressesObj = {
13
13
  [wallet.address]: onlyKeys,
14
14
  };
@@ -74,3 +74,5 @@ export * from './useEmbeddedWallet';
74
74
  export { useUpgradeEmbeddedWallet } from './useUpgradeEmbeddedWallet';
75
75
  export { useAggregateWalletEvents } from './useAggregateWalletEvents';
76
76
  export { useDeleteUserAccount } from './useDeleteUserAccount';
77
+ export { useDynamicWaas } from './useDynamicWaas';
78
+ export { useSyncDynamicWaas } from './useSyncDynamicWaas';
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains';
7
+ const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
8
+
9
+ exports.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR;
10
+ exports.NO_ENABLED_CHAINS_ERROR = NO_ENABLED_CHAINS_ERROR;
@@ -0,0 +1,2 @@
1
+ export declare const NO_ENABLED_CHAINS_ERROR = "No enabled embedded wallet chains";
2
+ export declare const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = "Dynamic Waas connector not found";
@@ -0,0 +1,5 @@
1
+ 'use client'
2
+ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains';
3
+ const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
4
+
5
+ export { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, NO_ENABLED_CHAINS_ERROR };
@@ -0,0 +1 @@
1
+ export * from './useDynamicWaas';
@@ -0,0 +1,220 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var React = require('react');
8
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
9
+ var utils = require('@dynamic-labs/utils');
10
+ require('../../constants/values.cjs');
11
+ require('@dynamic-labs/multi-wallet');
12
+ var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
13
+ require('../../../shared/logger.cjs');
14
+ require('../../constants/colors.cjs');
15
+ require('react-international-phone');
16
+ require('@dynamic-labs/iconic');
17
+ require('@dynamic-labs/wallet-connector-core');
18
+ require('react/jsx-runtime');
19
+ require('../../../context/ViewContext/ViewContext.cjs');
20
+ require('@dynamic-labs/wallet-book');
21
+ require('../../../shared/consts/index.cjs');
22
+ require('../../../store/state/nonce/nonce.cjs');
23
+ var isCookieEnabled = require('../../functions/isCookieEnabled/isCookieEnabled.cjs');
24
+ var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
25
+ var updatePrimaryWalletId = require('../../functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs');
26
+ var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
27
+ var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
28
+ var user = require('../../../store/state/user/user.cjs');
29
+ var walletOptions = require('../../../store/state/walletOptions/walletOptions.cjs');
30
+ require('../../../context/DynamicContext/DynamicContext.cjs');
31
+ require('../../../events/dynamicEvents.cjs');
32
+ require('../../../context/CaptchaContext/CaptchaContext.cjs');
33
+ require('../../../context/ErrorContext/ErrorContext.cjs');
34
+ require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
35
+ require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
36
+ require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
37
+ require('../../../config/ApiEndpoint.cjs');
38
+ require('../../../locale/locale.cjs');
39
+ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
40
+ require('../../../context/VerificationContext/VerificationContext.cjs');
41
+ require('react-dom');
42
+ require('../../functions/compareChains/compareChains.cjs');
43
+ require('../../../context/ThemeContext/ThemeContext.cjs');
44
+ require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
45
+ require('bs58');
46
+ require('@dynamic-labs/types');
47
+ require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
48
+ require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
49
+ require('../../../context/LoadingContext/LoadingContext.cjs');
50
+ require('../../../context/WalletContext/WalletContext.cjs');
51
+ require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
52
+ require('yup');
53
+ require('../../../context/MockContext/MockContext.cjs');
54
+ require('../../../views/CollectUserDataView/useFields.cjs');
55
+ require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
56
+ require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
57
+ require('@dynamic-labs/rpc-providers');
58
+ require('../../../store/state/loadingAndLifecycle.cjs');
59
+ require('react-i18next');
60
+ require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
61
+ require('../../../components/Alert/Alert.cjs');
62
+ require('../../../components/ShadowDOM/ShadowDOM.cjs');
63
+ require('../../../components/IconButton/IconButton.cjs');
64
+ require('../../../components/InlineWidget/InlineWidget.cjs');
65
+ require('../../../components/Input/Input.cjs');
66
+ require('../../../components/IsBrowser/IsBrowser.cjs');
67
+ require('../../../components/MenuList/Dropdown/Dropdown.cjs');
68
+ require('../../../components/OverlayCard/OverlayCard.cjs');
69
+ require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
70
+ require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
71
+ require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
72
+ require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
73
+ require('../../../components/Popper/Popper/Popper.cjs');
74
+ require('../../../components/Popper/PopperContext/PopperContext.cjs');
75
+ require('react-focus-lock');
76
+ require('qrcode');
77
+ require('formik');
78
+ require('../useSubdomainCheck/useSubdomainCheck.cjs');
79
+ require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
80
+ require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
81
+ require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
82
+ require('../../../context/ConnectWithOtpContext/constants.cjs');
83
+ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
84
+ require('@hcaptcha/react-hcaptcha');
85
+ require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
86
+ require('../../../context/FooterAnimationContext/index.cjs');
87
+ require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
88
+ require('../../../context/PasskeyContext/PasskeyContext.cjs');
89
+ require('../../../store/state/sendBalances.cjs');
90
+ require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
91
+ require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
92
+ require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
93
+ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
94
+ require('../../../context/OnrampContext/OnrampContext.cjs');
95
+ require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
96
+ require('../../../../index.cjs');
97
+ var constants = require('./constants.cjs');
98
+ require('../../../store/state/tokenBalances.cjs');
99
+ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
100
+ var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
101
+
102
+ const dynamicWaasKey = 'dynamicwaas';
103
+ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, }) => {
104
+ walletConnector.setEnvironmentId(environmentId);
105
+ walletConnector.setBaseApiUrl(apiBaseUrl === null || apiBaseUrl === void 0 ? void 0 : apiBaseUrl.replace('/api/v0', ''));
106
+ walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
107
+ return walletConnector;
108
+ };
109
+ const useDynamicWaas = () => {
110
+ var _a;
111
+ const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
112
+ const { user: user$1 } = user.useUser();
113
+ const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
114
+ const projectSettings$1 = projectSettings.useProjectSettings();
115
+ const environmentId = dynamicContextProps.useEnvironmentId();
116
+ const walletConnectorOptions = walletOptions.useWalletConnectorOptions();
117
+ const refresh = useRefreshUser.useRefreshUser();
118
+ const embeddedWalletSettings = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.embeddedWallets;
119
+ const enabledChains = (_a = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _a === void 0 ? void 0 : _a.filter((c) => c.enabled);
120
+ const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
121
+ const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
122
+ const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
123
+ const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreationForExternal;
124
+ const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
125
+ const dynamicWaasIsEnabled = defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3;
126
+ const authToken = getAuthToken.getAuthToken();
127
+ const isCookieAuthEnabled = projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1);
128
+ const getWalletConnector = React.useCallback((chainName) => {
129
+ var _a;
130
+ if (!isCookieAuthEnabled && !authToken) {
131
+ return undefined;
132
+ }
133
+ if (!walletConnectorOptions.length || !environmentId || !apiBaseUrl)
134
+ return undefined;
135
+ const connectorKey = chainName === 'EVM' ? dynamicWaasKey : `${dynamicWaasKey}-svm`;
136
+ const walletConnector = (_a = walletConnectorOptions.find((option) => option.key.includes(connectorKey))) === null || _a === void 0 ? void 0 : _a.walletConnector;
137
+ if (!walletConnector) {
138
+ throw new utils.DynamicError(constants.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR);
139
+ }
140
+ const configuredWalletConnector = configWaasWalletConnector({
141
+ apiBaseUrl,
142
+ authToken,
143
+ environmentId,
144
+ walletConnector,
145
+ });
146
+ return configuredWalletConnector;
147
+ }, [
148
+ walletConnectorOptions,
149
+ environmentId,
150
+ authToken,
151
+ apiBaseUrl,
152
+ isCookieAuthEnabled,
153
+ ]);
154
+ const createWalletAccount = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
155
+ if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
156
+ throw new utils.DynamicError(constants.NO_ENABLED_CHAINS_ERROR);
157
+ }
158
+ const createdWalletAccounts = yield Promise.all(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.map((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
159
+ const walletConnector = getWalletConnector(chain);
160
+ if (!walletConnector)
161
+ return undefined;
162
+ const createdWalletAccount = yield walletConnector.createWalletAccount();
163
+ return Object.assign(Object.assign({}, createdWalletAccount), { chainName: chain });
164
+ })));
165
+ const primaryWalletAccount = createdWalletAccounts === null || createdWalletAccounts === void 0 ? void 0 : createdWalletAccounts.find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chainName) === (primaryChain === null || primaryChain === void 0 ? void 0 : primaryChain.name));
166
+ const refreshedUser = yield refresh();
167
+ const createdPrimaryWallet = refreshedUser === null || refreshedUser === void 0 ? void 0 : refreshedUser.verifiedCredentials.find((wallet) => {
168
+ var _a, _b, _c;
169
+ return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes(dynamicWaasKey)) &&
170
+ ((_b = wallet.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
171
+ ((_c = primaryWalletAccount === null || primaryWalletAccount === void 0 ? void 0 : primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
172
+ });
173
+ if (createdPrimaryWallet) {
174
+ updatePrimaryWalletId.updatePrimaryWalletId(createdPrimaryWallet.id);
175
+ }
176
+ setShowAuthFlow(false, { performMultiWalletChecks: false }); // close email otp pin modal
177
+ return createdWalletAccounts;
178
+ }), [getWalletConnector, primaryChain, enabledChainNames, refresh]);
179
+ const shouldAutoCreateDynamicWaasWallet = React.useMemo(() => {
180
+ const hasDynamicWaasWallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((wallet) => { var _a; return (_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes('dynamicwaas'); });
181
+ if (!user$1 ||
182
+ hasDynamicWaasWallet || // already has a dynamic waas wallet
183
+ !dynamicWaasIsEnabled || // dynamic waas is not enabled
184
+ !automaticEmbeddedWalletCreationEnabled // automatic embedded wallet creation is not enabled
185
+ )
186
+ return false;
187
+ const hasExternalWallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((vc) => vc.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain &&
188
+ vc.walletProvider !== sdkApiCore.WalletProviderEnum.EmbeddedWallet);
189
+ const shouldCreateDynamicWaasWallet = hasExternalWallet
190
+ ? automaticEmbeddedWalletCreationForExternalEnabled
191
+ : true;
192
+ return shouldCreateDynamicWaasWallet;
193
+ }, [
194
+ user$1,
195
+ dynamicWaasIsEnabled,
196
+ automaticEmbeddedWalletCreationEnabled,
197
+ automaticEmbeddedWalletCreationForExternalEnabled,
198
+ walletConnectorOptions,
199
+ ]);
200
+ const importPrivateKey = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ chainName, privateKey, }) {
201
+ const walletConnector = getWalletConnector(chainName);
202
+ if (!walletConnector)
203
+ return;
204
+ yield walletConnector.importPrivateKey({
205
+ chainName,
206
+ privateKey,
207
+ });
208
+ yield refresh();
209
+ });
210
+ return {
211
+ createWalletAccount,
212
+ dynamicWaasIsEnabled,
213
+ getWalletConnector,
214
+ importPrivateKey,
215
+ shouldAutoCreateDynamicWaasWallet,
216
+ };
217
+ };
218
+
219
+ exports.configWaasWalletConnector = configWaasWalletConnector;
220
+ exports.useDynamicWaas = useDynamicWaas;
@@ -0,0 +1,21 @@
1
+ import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
2
+ export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, }: {
3
+ walletConnector: IDynamicWaasConnector;
4
+ environmentId: string;
5
+ apiBaseUrl: string;
6
+ authToken: string | undefined;
7
+ }) => IDynamicWaasConnector;
8
+ export declare const useDynamicWaas: () => {
9
+ createWalletAccount: () => Promise<({
10
+ chainName: string;
11
+ accountAddress: string;
12
+ publicKeyHex: string;
13
+ } | undefined)[]>;
14
+ dynamicWaasIsEnabled: boolean;
15
+ getWalletConnector: (chainName: string) => IDynamicWaasConnector | undefined;
16
+ importPrivateKey: ({ chainName, privateKey, }: {
17
+ chainName: string;
18
+ privateKey: string;
19
+ }) => Promise<void>;
20
+ shouldAutoCreateDynamicWaasWallet: boolean | undefined;
21
+ };