@dynamic-labs/sdk-react-core 4.65.0 → 4.67.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 (70) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.cjs +4 -4
  3. package/package.js +4 -4
  4. package/package.json +15 -15
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +2 -2
  7. package/src/index.js +1 -0
  8. package/src/lib/Main.cjs +1 -0
  9. package/src/lib/Main.js +1 -0
  10. package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.cjs +18 -0
  11. package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.d.ts +1 -0
  12. package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.js +14 -0
  13. package/src/lib/client/extension/functions/hasElevatedAccessToken/index.d.ts +1 -0
  14. package/src/lib/client/extension/index.d.ts +1 -0
  15. package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -19
  16. package/src/lib/context/DynamicContext/DynamicContext.js +20 -19
  17. package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +10 -0
  18. package/src/lib/styles/index.shadow.cjs +1 -1
  19. package/src/lib/styles/index.shadow.js +1 -1
  20. package/src/lib/utils/constants/values.cjs +2 -0
  21. package/src/lib/utils/constants/values.js +2 -0
  22. package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
  23. package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
  24. package/src/lib/utils/hooks/index.d.ts +2 -1
  25. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +7 -3
  26. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +4 -1
  27. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +7 -3
  28. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +7 -2
  29. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +2 -1
  30. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +7 -2
  31. package/src/lib/utils/hooks/useSignEip7702Authorization/index.d.ts +1 -0
  32. package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.cjs +162 -0
  33. package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.d.ts +78 -0
  34. package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.js +158 -0
  35. package/src/lib/utils/hooks/useStepUpAuthentication/index.d.ts +1 -1
  36. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +102 -23
  37. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.d.ts +35 -15
  38. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +103 -24
  39. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +3 -1
  40. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +3 -1
  41. package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs +3 -2
  42. package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js +3 -2
  43. package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +24 -2
  44. package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +24 -2
  45. package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.cjs +10 -6
  46. package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.js +11 -7
  47. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +1 -1
  48. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +1 -1
  49. package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.cjs +5 -21
  50. package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.js +5 -21
  51. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -0
  52. package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -0
  53. package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs +9 -1
  54. package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js +9 -1
  55. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +21 -1
  56. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +21 -1
  57. package/src/lib/views/WalletList/data.cjs +1 -0
  58. package/src/lib/views/WalletList/data.d.ts +1 -1
  59. package/src/lib/views/WalletList/data.js +1 -0
  60. package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs +26 -5
  61. package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js +26 -5
  62. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs +3 -2
  63. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts +2 -0
  64. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js +3 -2
  65. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.cjs +2 -2
  66. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.d.ts +2 -0
  67. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.js +2 -2
  68. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +30 -22
  69. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.d.ts +2 -1
  70. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +30 -22
@@ -160,7 +160,9 @@ const useWalletCreation = () => {
160
160
  try {
161
161
  // If passcodeRequired is enabled, prompt user to set up password first
162
162
  const password = yield setupPassword();
163
- yield createWalletAccount(requirements, password);
163
+ yield createWalletAccount(requirements, password, undefined, {
164
+ skipCloseAuthFlow: Boolean(password),
165
+ });
164
166
  const duration = Date.now() - startTime;
165
167
  // Log successful wallet creation to DataDog
166
168
  logger.logger.instrument('Auto wallet creation successful', {
@@ -156,7 +156,9 @@ const useWalletCreation = () => {
156
156
  try {
157
157
  // If passcodeRequired is enabled, prompt user to set up password first
158
158
  const password = yield setupPassword();
159
- yield createWalletAccount(requirements, password);
159
+ yield createWalletAccount(requirements, password, undefined, {
160
+ skipCloseAuthFlow: Boolean(password),
161
+ });
160
162
  const duration = Date.now() - startTime;
161
163
  // Log successful wallet creation to DataDog
162
164
  logger.instrument('Auto wallet creation successful', {
@@ -50,9 +50,10 @@ const useWalletConnectorNetwork = (walletConnector, { onChange } = { onChange: (
50
50
  },
51
51
  });
52
52
  useWalletConnectorEvent.useWalletConnectorEvent(walletConnector || undefined, 'chainChange', ({ chain }) => {
53
- // STARK and STELLAR use string chainIds; others use numeric
53
+ // STARK, STELLAR and ALEO use string chainIds; others use numeric
54
54
  const useChainAsString = (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'STARK' ||
55
- (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'STELLAR';
55
+ (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'STELLAR' ||
56
+ (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'ALEO';
56
57
  const parsedChain = useChainAsString ? chain : parseInt(chain);
57
58
  setNetwork(parsedChain);
58
59
  onChange === null || onChange === void 0 ? void 0 : onChange(parsedChain);
@@ -46,9 +46,10 @@ const useWalletConnectorNetwork = (walletConnector, { onChange } = { onChange: (
46
46
  },
47
47
  });
48
48
  useWalletConnectorEvent(walletConnector || undefined, 'chainChange', ({ chain }) => {
49
- // STARK and STELLAR use string chainIds; others use numeric
49
+ // STARK, STELLAR and ALEO use string chainIds; others use numeric
50
50
  const useChainAsString = (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'STARK' ||
51
- (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'STELLAR';
51
+ (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'STELLAR' ||
52
+ (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'ALEO';
52
53
  const parsedChain = useChainAsString ? chain : parseInt(chain);
53
54
  setNetwork(parsedChain);
54
55
  onChange === null || onChange === void 0 ? void 0 : onChange(parsedChain);
@@ -18,6 +18,7 @@ require('../../constants/values.cjs');
18
18
  require('@dynamic-labs/sdk-api-core');
19
19
  require('../../../shared/consts/index.cjs');
20
20
  var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
21
+ var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
21
22
 
22
23
  const INITIAL_STATE = {
23
24
  error: null,
@@ -26,6 +27,7 @@ const INITIAL_STATE = {
26
27
  };
27
28
  const useWalletPassword = () => {
28
29
  const { getWaasWalletConnector } = useDynamicWaas.useDynamicWaas();
30
+ const refreshUser = useRefreshUser.useRefreshUser();
29
31
  const [state, setState] = React.useState(INITIAL_STATE);
30
32
  const resetState = React.useCallback(() => {
31
33
  setState(INITIAL_STATE);
@@ -46,6 +48,16 @@ const useWalletPassword = () => {
46
48
  newPassword,
47
49
  });
48
50
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
51
+ try {
52
+ yield refreshUser();
53
+ }
54
+ catch (refreshError) {
55
+ logger.logger.warn('Failed to refresh user after setting password', {
56
+ accountAddress,
57
+ chainName,
58
+ refreshError,
59
+ });
60
+ }
49
61
  return true;
50
62
  }
51
63
  catch (error) {
@@ -58,7 +70,7 @@ const useWalletPassword = () => {
58
70
  });
59
71
  return false;
60
72
  }
61
- }), [getWaasWalletConnector]);
73
+ }), [getWaasWalletConnector, refreshUser]);
62
74
  const updatePassword = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
63
75
  const { accountAddress, chainName, newPassword, existingPassword } = params;
64
76
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
@@ -76,6 +88,16 @@ const useWalletPassword = () => {
76
88
  newPassword,
77
89
  });
78
90
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
91
+ try {
92
+ yield refreshUser();
93
+ }
94
+ catch (refreshError) {
95
+ logger.logger.warn('Failed to refresh user after updating password', {
96
+ accountAddress,
97
+ chainName,
98
+ refreshError,
99
+ });
100
+ }
79
101
  return true;
80
102
  }
81
103
  catch (error) {
@@ -88,7 +110,7 @@ const useWalletPassword = () => {
88
110
  });
89
111
  return false;
90
112
  }
91
- }), [getWaasWalletConnector]);
113
+ }), [getWaasWalletConnector, refreshUser]);
92
114
  const unlockWallet = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
93
115
  const { accountAddress, chainName, password } = params;
94
116
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
@@ -14,6 +14,7 @@ import '../../constants/values.js';
14
14
  import '@dynamic-labs/sdk-api-core';
15
15
  import '../../../shared/consts/index.js';
16
16
  import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
17
+ import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
17
18
 
18
19
  const INITIAL_STATE = {
19
20
  error: null,
@@ -22,6 +23,7 @@ const INITIAL_STATE = {
22
23
  };
23
24
  const useWalletPassword = () => {
24
25
  const { getWaasWalletConnector } = useDynamicWaas();
26
+ const refreshUser = useRefreshUser();
25
27
  const [state, setState] = useState(INITIAL_STATE);
26
28
  const resetState = useCallback(() => {
27
29
  setState(INITIAL_STATE);
@@ -42,6 +44,16 @@ const useWalletPassword = () => {
42
44
  newPassword,
43
45
  });
44
46
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
47
+ try {
48
+ yield refreshUser();
49
+ }
50
+ catch (refreshError) {
51
+ logger.warn('Failed to refresh user after setting password', {
52
+ accountAddress,
53
+ chainName,
54
+ refreshError,
55
+ });
56
+ }
45
57
  return true;
46
58
  }
47
59
  catch (error) {
@@ -54,7 +66,7 @@ const useWalletPassword = () => {
54
66
  });
55
67
  return false;
56
68
  }
57
- }), [getWaasWalletConnector]);
69
+ }), [getWaasWalletConnector, refreshUser]);
58
70
  const updatePassword = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
59
71
  const { accountAddress, chainName, newPassword, existingPassword } = params;
60
72
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
@@ -72,6 +84,16 @@ const useWalletPassword = () => {
72
84
  newPassword,
73
85
  });
74
86
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
87
+ try {
88
+ yield refreshUser();
89
+ }
90
+ catch (refreshError) {
91
+ logger.warn('Failed to refresh user after updating password', {
92
+ accountAddress,
93
+ chainName,
94
+ refreshError,
95
+ });
96
+ }
75
97
  return true;
76
98
  }
77
99
  catch (error) {
@@ -84,7 +106,7 @@ const useWalletPassword = () => {
84
106
  });
85
107
  return false;
86
108
  }
87
- }), [getWaasWalletConnector]);
109
+ }), [getWaasWalletConnector, refreshUser]);
88
110
  const unlockWallet = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
89
111
  const { accountAddress, chainName, password } = params;
90
112
  setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
@@ -114,18 +114,22 @@ require('../../../../components/Popper/PopperContext/PopperContext.cjs');
114
114
  const UserPhoneField = ({ onChange, value: phone, onBlur, disabled, label, required, error, name, verify, }) => {
115
115
  const { selectedPhoneCountry } = FieldsStateContext.useFieldsState();
116
116
  const { projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
117
+ const initialPhoneRef = React.useRef(phone);
118
+ const onChangeRef = React.useRef(onChange);
119
+ const nameRef = React.useRef(name);
120
+ onChangeRef.current = onChange;
121
+ nameRef.current = name;
117
122
  const handleUpdate = React.useCallback(({ country, phone: newPhone }) => {
118
123
  selectedPhoneCountry.current = country;
119
- if (newPhone !== phone)
120
- onChange({
121
- target: { name, value: newPhone },
122
- });
123
- }, [onChange, phone, name, selectedPhoneCountry]);
124
+ onChangeRef.current({
125
+ target: { name: nameRef.current, value: newPhone },
126
+ });
127
+ }, [selectedPhoneCountry]);
124
128
  const countries = React.useMemo(() => {
125
129
  const enabledCountries = getSupportedCountriesForVerificationFromProjectSettings.getSupportedCountriesForVerificationFromProjectSettings(projectSettings);
126
130
  return getCustomCountries.getCustomCountries(verify ? getDefaultCountriesIfEmpty.getDefaultCountriesIfEmpty(enabledCountries) : undefined);
127
131
  }, [verify, projectSettings]);
128
- return (jsxRuntime.jsx(PhoneNumberField.PhoneNumberField, { countries: countries, initialPhone: phone, disabled: disabled, onUpdate: handleUpdate, onBlur: onBlur, label: label, appendRight: !disabled && !required ? (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'user-phone-field__optional-label', children: "Optional" })) : undefined, error: error }));
132
+ return (jsxRuntime.jsx(PhoneNumberField.PhoneNumberField, { countries: countries, initialPhone: initialPhoneRef.current, disabled: disabled, onUpdate: handleUpdate, onBlur: onBlur, label: label, appendRight: !disabled && !required ? (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'user-phone-field__optional-label', children: "Optional" })) : undefined, error: error }));
129
133
  };
130
134
 
131
135
  exports.UserPhoneField = UserPhoneField;
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useCallback, useMemo } from 'react';
3
+ import { useRef, useCallback, useMemo } from 'react';
4
4
  import '@dynamic-labs/utils';
5
5
  import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
6
6
  import 'react-i18next';
@@ -110,18 +110,22 @@ import '../../../../components/Popper/PopperContext/PopperContext.js';
110
110
  const UserPhoneField = ({ onChange, value: phone, onBlur, disabled, label, required, error, name, verify, }) => {
111
111
  const { selectedPhoneCountry } = useFieldsState();
112
112
  const { projectSettings } = useInternalDynamicContext();
113
+ const initialPhoneRef = useRef(phone);
114
+ const onChangeRef = useRef(onChange);
115
+ const nameRef = useRef(name);
116
+ onChangeRef.current = onChange;
117
+ nameRef.current = name;
113
118
  const handleUpdate = useCallback(({ country, phone: newPhone }) => {
114
119
  selectedPhoneCountry.current = country;
115
- if (newPhone !== phone)
116
- onChange({
117
- target: { name, value: newPhone },
118
- });
119
- }, [onChange, phone, name, selectedPhoneCountry]);
120
+ onChangeRef.current({
121
+ target: { name: nameRef.current, value: newPhone },
122
+ });
123
+ }, [selectedPhoneCountry]);
120
124
  const countries = useMemo(() => {
121
125
  const enabledCountries = getSupportedCountriesForVerificationFromProjectSettings(projectSettings);
122
126
  return getCustomCountries(verify ? getDefaultCountriesIfEmpty(enabledCountries) : undefined);
123
127
  }, [verify, projectSettings]);
124
- return (jsx(PhoneNumberField, { countries: countries, initialPhone: phone, disabled: disabled, onUpdate: handleUpdate, onBlur: onBlur, label: label, appendRight: !disabled && !required ? (jsx(Typography, { variant: 'body_small', color: 'secondary', className: 'user-phone-field__optional-label', children: "Optional" })) : undefined, error: error }));
128
+ return (jsx(PhoneNumberField, { countries: countries, initialPhone: initialPhoneRef.current, disabled: disabled, onUpdate: handleUpdate, onBlur: onBlur, label: label, appendRight: !disabled && !required ? (jsx(Typography, { variant: 'body_small', color: 'secondary', className: 'user-phone-field__optional-label', children: "Optional" })) : undefined, error: error }));
125
129
  };
126
130
 
127
131
  export { UserPhoneField };
@@ -124,8 +124,8 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
124
124
  const { data: codes, isLoading } = usePromise.usePromise(() => getRecoveryCodes(regenerateCodes));
125
125
  const codesAsString = (codes || []).join('\n');
126
126
  const handleCompleteAcknowledgement = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
127
- setShowAuthFlow(false);
128
127
  yield completeAcknowledgement();
128
+ setShowAuthFlow(false);
129
129
  });
130
130
  const handleDownload = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
131
131
  e.preventDefault();
@@ -120,8 +120,8 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
120
120
  const { data: codes, isLoading } = usePromise(() => getRecoveryCodes(regenerateCodes));
121
121
  const codesAsString = (codes || []).join('\n');
122
122
  const handleCompleteAcknowledgement = () => __awaiter(void 0, void 0, void 0, function* () {
123
- setShowAuthFlow(false);
124
123
  yield completeAcknowledgement();
124
+ setShowAuthFlow(false);
125
125
  });
126
126
  const handleDownload = (e) => __awaiter(void 0, void 0, void 0, function* () {
127
127
  e.preventDefault();
@@ -3,7 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var _tslib = require('../../../../_virtual/_tslib.cjs');
7
6
  var jsxRuntime = require('react/jsx-runtime');
8
7
  var React = require('react');
9
8
  require('../../context/DynamicContext/DynamicContext.cjs');
@@ -11,7 +10,7 @@ require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
11
10
  require('@dynamic-labs/iconic');
12
11
  require('@dynamic-labs/wallet-connector-core');
13
12
  require('../../context/ViewContext/ViewContext.cjs');
14
- var logger = require('../../shared/logger.cjs');
13
+ require('../../shared/logger.cjs');
15
14
  require('@dynamic-labs/wallet-book');
16
15
  require('@dynamic-labs/utils');
17
16
  require('../../utils/constants/colors.cjs');
@@ -19,6 +18,7 @@ require('../../utils/constants/values.cjs');
19
18
  require('@dynamic-labs/sdk-api-core');
20
19
  require('../../shared/consts/index.cjs');
21
20
  require('../../events/dynamicEvents.cjs');
21
+ require('../../../../_virtual/_tslib.cjs');
22
22
  require('../../context/CaptchaContext/CaptchaContext.cjs');
23
23
  require('../../context/ErrorContext/ErrorContext.cjs');
24
24
  require('@dynamic-labs/multi-wallet');
@@ -42,7 +42,6 @@ require('react-dom');
42
42
  require('../../utils/functions/compareChains/compareChains.cjs');
43
43
  require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
44
44
  require('../../context/ThemeContext/ThemeContext.cjs');
45
- var useSmartWallets = require('../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
46
45
  require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
47
46
  require('bs58');
48
47
  require('@dynamic-labs/types');
@@ -92,7 +91,6 @@ require('../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
92
91
  require('../../context/FooterAnimationContext/index.cjs');
93
92
  require('../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
94
93
  require('../../context/PasskeyContext/PasskeyContext.cjs');
95
- var useWalletPassword = require('../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
96
94
  var ResetPasswordView = require('../../widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs');
97
95
  require('../../context/OnrampContext/OnrampContext.cjs');
98
96
  require('../../store/state/sendBalances.cjs');
@@ -110,24 +108,10 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
110
108
  var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
111
109
 
112
110
  const ResetPasswordForSettingsView = () => {
113
- const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
114
- const { getEOAWallet } = useSmartWallets.useSmartWallets();
115
- const { updatePassword } = useWalletPassword.useWalletPassword();
116
- const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
117
- const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
118
- const handleComplete = React.useCallback((oldPassword, newPassword) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
119
- if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
120
- logger.logger.error('No wallet address or chain available for password reset');
121
- return;
122
- }
123
- yield updatePassword({
124
- accountAddress: wallet.address,
125
- chainName: wallet.chain,
126
- existingPassword: oldPassword,
127
- newPassword,
128
- });
111
+ const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
112
+ const handleComplete = React.useCallback(() => {
129
113
  setShowAuthFlow(false);
130
- }), [wallet, updatePassword, setShowAuthFlow]);
114
+ }, [setShowAuthFlow]);
131
115
  return jsxRuntime.jsx(ResetPasswordView.ResetPasswordView, { onComplete: handleComplete });
132
116
  };
133
117
 
@@ -1,5 +1,4 @@
1
1
  'use client'
2
- import { __awaiter } from '../../../../_virtual/_tslib.js';
3
2
  import { jsx } from 'react/jsx-runtime';
4
3
  import { useCallback } from 'react';
5
4
  import '../../context/DynamicContext/DynamicContext.js';
@@ -7,7 +6,7 @@ import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
7
6
  import '@dynamic-labs/iconic';
8
7
  import '@dynamic-labs/wallet-connector-core';
9
8
  import '../../context/ViewContext/ViewContext.js';
10
- import { logger } from '../../shared/logger.js';
9
+ import '../../shared/logger.js';
11
10
  import '@dynamic-labs/wallet-book';
12
11
  import '@dynamic-labs/utils';
13
12
  import '../../utils/constants/colors.js';
@@ -15,6 +14,7 @@ import '../../utils/constants/values.js';
15
14
  import '@dynamic-labs/sdk-api-core';
16
15
  import '../../shared/consts/index.js';
17
16
  import '../../events/dynamicEvents.js';
17
+ import '../../../../_virtual/_tslib.js';
18
18
  import '../../context/CaptchaContext/CaptchaContext.js';
19
19
  import '../../context/ErrorContext/ErrorContext.js';
20
20
  import '@dynamic-labs/multi-wallet';
@@ -38,7 +38,6 @@ import 'react-dom';
38
38
  import '../../utils/functions/compareChains/compareChains.js';
39
39
  import '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
40
40
  import '../../context/ThemeContext/ThemeContext.js';
41
- import { useSmartWallets } from '../../utils/hooks/useSmartWallets/useSmartWallets.js';
42
41
  import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
43
42
  import 'bs58';
44
43
  import '@dynamic-labs/types';
@@ -88,7 +87,6 @@ import '../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
88
87
  import '../../context/FooterAnimationContext/index.js';
89
88
  import '../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
90
89
  import '../../context/PasskeyContext/PasskeyContext.js';
91
- import { useWalletPassword } from '../../utils/hooks/useWalletPassword/useWalletPassword.js';
92
90
  import { ResetPasswordView } from '../../widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js';
93
91
  import '../../context/OnrampContext/OnrampContext.js';
94
92
  import '../../store/state/sendBalances.js';
@@ -106,24 +104,10 @@ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
106
104
  import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
107
105
 
108
106
  const ResetPasswordForSettingsView = () => {
109
- const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
110
- const { getEOAWallet } = useSmartWallets();
111
- const { updatePassword } = useWalletPassword();
112
- const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
113
- const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
114
- const handleComplete = useCallback((oldPassword, newPassword) => __awaiter(void 0, void 0, void 0, function* () {
115
- if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
116
- logger.error('No wallet address or chain available for password reset');
117
- return;
118
- }
119
- yield updatePassword({
120
- accountAddress: wallet.address,
121
- chainName: wallet.chain,
122
- existingPassword: oldPassword,
123
- newPassword,
124
- });
107
+ const { setShowAuthFlow } = useInternalDynamicContext();
108
+ const handleComplete = useCallback(() => {
125
109
  setShowAuthFlow(false);
126
- }), [wallet, updatePassword, setShowAuthFlow]);
110
+ }, [setShowAuthFlow]);
127
111
  return jsx(ResetPasswordView, { onComplete: handleComplete });
128
112
  };
129
113
 
@@ -128,6 +128,7 @@ const getTransactionValue = (transaction, isNativeToken) => {
128
128
  };
129
129
  const getSupportedChainName = (connectedChain) => {
130
130
  const supportedChains = {
131
+ ALEO: sdkApiCore.ChainEnum.Aleo,
131
132
  APTOS: sdkApiCore.ChainEnum.Aptos,
132
133
  BTC: sdkApiCore.ChainEnum.Btc,
133
134
  EVM: sdkApiCore.ChainEnum.Evm,
@@ -124,6 +124,7 @@ const getTransactionValue = (transaction, isNativeToken) => {
124
124
  };
125
125
  const getSupportedChainName = (connectedChain) => {
126
126
  const supportedChains = {
127
+ ALEO: ChainEnum.Aleo,
127
128
  APTOS: ChainEnum.Aptos,
128
129
  BTC: ChainEnum.Btc,
129
130
  EVM: ChainEnum.Evm,
@@ -115,9 +115,17 @@ const SetupPasswordForWalletCreationView = () => {
115
115
  }, [setShowAuthFlow]);
116
116
  const handleComplete = React.useCallback((password) => {
117
117
  dynamicEvents.dynamicEvents.emit('embeddedWalletPasswordSetupCompleted', password);
118
+ // Return a Promise that resolves when embeddedWalletCreated fires.
119
+ // This keeps the knowledge check screen in loading state while wallet creation
120
+ // is in progress, then transitions to the done screen on success.
121
+ return new Promise((resolve) => {
122
+ dynamicEvents.dynamicEvents.once('embeddedWalletCreated', () => resolve());
123
+ });
124
+ }, []);
125
+ const handleDone = React.useCallback(() => {
118
126
  setShowAuthFlow(false);
119
127
  }, [setShowAuthFlow]);
120
- return (jsxRuntime.jsx(SetupPasswordView.SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel }));
128
+ return (jsxRuntime.jsx(SetupPasswordView.SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel, onDone: handleDone }));
121
129
  };
122
130
 
123
131
  exports.SetupPasswordForWalletCreationView = SetupPasswordForWalletCreationView;
@@ -111,9 +111,17 @@ const SetupPasswordForWalletCreationView = () => {
111
111
  }, [setShowAuthFlow]);
112
112
  const handleComplete = useCallback((password) => {
113
113
  dynamicEvents.emit('embeddedWalletPasswordSetupCompleted', password);
114
+ // Return a Promise that resolves when embeddedWalletCreated fires.
115
+ // This keeps the knowledge check screen in loading state while wallet creation
116
+ // is in progress, then transitions to the done screen on success.
117
+ return new Promise((resolve) => {
118
+ dynamicEvents.once('embeddedWalletCreated', () => resolve());
119
+ });
120
+ }, []);
121
+ const handleDone = useCallback(() => {
114
122
  setShowAuthFlow(false);
115
123
  }, [setShowAuthFlow]);
116
- return (jsx(SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel }));
124
+ return (jsx(SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel, onDone: handleDone }));
117
125
  };
118
126
 
119
127
  export { SetupPasswordForWalletCreationView };
@@ -151,6 +151,8 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
151
151
  status: SimulationStatus.LOADING,
152
152
  });
153
153
  const [recipient, setRecipient] = React.useState(undefined);
154
+ // Pre-submit validation error (e.g., Stellar account activation requirements)
155
+ const [preSubmitValidationError, setPreSubmitValidationError] = React.useState(undefined);
154
156
  const isFetchingSimulationRef = React.useRef(false);
155
157
  const fetchSimulationResult = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
156
158
  var _d, _e, _f, _g, _h, _j, _k;
@@ -278,6 +280,18 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
278
280
  }
279
281
  fetchSimulationResult();
280
282
  }, [fetchSimulationResult, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, simulationState.status]);
283
+ // Check destination account for chains that require it (e.g., Stellar)
284
+ React.useEffect(() => {
285
+ const checkDestination = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
286
+ var _a;
287
+ if (transaction.checkDestinationAccount) {
288
+ yield transaction.checkDestinationAccount();
289
+ const error = (_a = transaction.getPreSubmitValidationError) === null || _a === void 0 ? void 0 : _a.call(transaction);
290
+ setPreSubmitValidationError(error);
291
+ }
292
+ });
293
+ checkDestination();
294
+ }, [transaction]);
281
295
  /**
282
296
  * Update transaction fee and trigger a react update
283
297
  * to reflect the new fee on the UI
@@ -348,6 +362,10 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
348
362
  const alert = React.useMemo(() => {
349
363
  if (errorMessage)
350
364
  return null;
365
+ // Check for pre-submit validation errors (e.g., Stellar account activation)
366
+ if (preSubmitValidationError) {
367
+ return (jsxRuntime.jsx(Alert.Alert, { icon: 'error', variant: 'error', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'current-color', "data-testid": 'presubmit_error_content', children: preSubmitValidationError }) }));
368
+ }
351
369
  // Check for gas sponsorship errors
352
370
  if (utils.TransactionGasCannotBeSponsoredError.isInstance(transactionError)) {
353
371
  return (jsxRuntime.jsx(Alert.Alert, { icon: 'error', variant: 'error', copykey: 'dyn_send_transaction.error_message.gas_not_sponsored', children: t('dyn_send_transaction.error_message.gas_not_sponsored') }));
@@ -389,6 +407,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
389
407
  transaction,
390
408
  isGasSponsored,
391
409
  hasInsufficientFunds,
410
+ preSubmitValidationError,
392
411
  t,
393
412
  currency === null || currency === void 0 ? void 0 : currency.symbol,
394
413
  ]);
@@ -413,7 +432,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
413
432
  alert,
414
433
  copykey,
415
434
  currentToken,
416
- disableSendButton: isBalanceLoading,
435
+ disableSendButton: isBalanceLoading || Boolean(preSubmitValidationError),
417
436
  displayPoweredByDynamicFooter,
418
437
  error: errorMessage,
419
438
  fetchTransactionFee,
@@ -462,6 +481,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
462
481
  simulationState.result,
463
482
  sendBalanceTransaction,
464
483
  fetchTransactionFee,
484
+ preSubmitValidationError,
465
485
  ]);
466
486
  return simulationState.status === SimulationStatus.LOADING ? null : (jsxRuntime.jsx(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, Object.assign({}, layoutProps)));
467
487
  };
@@ -143,6 +143,8 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
143
143
  status: SimulationStatus.LOADING,
144
144
  });
145
145
  const [recipient, setRecipient] = useState(undefined);
146
+ // Pre-submit validation error (e.g., Stellar account activation requirements)
147
+ const [preSubmitValidationError, setPreSubmitValidationError] = useState(undefined);
146
148
  const isFetchingSimulationRef = useRef(false);
147
149
  const fetchSimulationResult = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
148
150
  var _d, _e, _f, _g, _h, _j, _k;
@@ -270,6 +272,18 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
270
272
  }
271
273
  fetchSimulationResult();
272
274
  }, [fetchSimulationResult, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, simulationState.status]);
275
+ // Check destination account for chains that require it (e.g., Stellar)
276
+ useEffect(() => {
277
+ const checkDestination = () => __awaiter(void 0, void 0, void 0, function* () {
278
+ var _a;
279
+ if (transaction.checkDestinationAccount) {
280
+ yield transaction.checkDestinationAccount();
281
+ const error = (_a = transaction.getPreSubmitValidationError) === null || _a === void 0 ? void 0 : _a.call(transaction);
282
+ setPreSubmitValidationError(error);
283
+ }
284
+ });
285
+ checkDestination();
286
+ }, [transaction]);
273
287
  /**
274
288
  * Update transaction fee and trigger a react update
275
289
  * to reflect the new fee on the UI
@@ -340,6 +354,10 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
340
354
  const alert = useMemo(() => {
341
355
  if (errorMessage)
342
356
  return null;
357
+ // Check for pre-submit validation errors (e.g., Stellar account activation)
358
+ if (preSubmitValidationError) {
359
+ return (jsx(Alert, { icon: 'error', variant: 'error', children: jsx(Typography, { variant: 'body_small', color: 'current-color', "data-testid": 'presubmit_error_content', children: preSubmitValidationError }) }));
360
+ }
343
361
  // Check for gas sponsorship errors
344
362
  if (TransactionGasCannotBeSponsoredError.isInstance(transactionError)) {
345
363
  return (jsx(Alert, { icon: 'error', variant: 'error', copykey: 'dyn_send_transaction.error_message.gas_not_sponsored', children: t('dyn_send_transaction.error_message.gas_not_sponsored') }));
@@ -381,6 +399,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
381
399
  transaction,
382
400
  isGasSponsored,
383
401
  hasInsufficientFunds,
402
+ preSubmitValidationError,
384
403
  t,
385
404
  currency === null || currency === void 0 ? void 0 : currency.symbol,
386
405
  ]);
@@ -405,7 +424,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
405
424
  alert,
406
425
  copykey,
407
426
  currentToken,
408
- disableSendButton: isBalanceLoading,
427
+ disableSendButton: isBalanceLoading || Boolean(preSubmitValidationError),
409
428
  displayPoweredByDynamicFooter,
410
429
  error: errorMessage,
411
430
  fetchTransactionFee,
@@ -454,6 +473,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
454
473
  simulationState.result,
455
474
  sendBalanceTransaction,
456
475
  fetchTransactionFee,
476
+ preSubmitValidationError,
457
477
  ]);
458
478
  return simulationState.status === SimulationStatus.LOADING ? null : (jsx(TransactionConfirmationPageLayout, Object.assign({}, layoutProps)));
459
479
  };
@@ -23,6 +23,7 @@ require('../../shared/consts/index.cjs');
23
23
  * getChainInfo differs from the one used in the wallet connectors
24
24
  */
25
25
  const chainInfoOverrides = {
26
+ aleo: 'ALEO',
26
27
  starknet: 'STARK',
27
28
  stellar: 'STELLAR',
28
29
  };
@@ -4,7 +4,7 @@ interface IChain {
4
4
  enabled: boolean;
5
5
  name: string;
6
6
  }
7
- export declare const getEnabledChains: (chains: IChain[]) => ("STARK" | "STELLAR" | "ALGO" | "APTOS" | "ATOM" | "BTC" | "COSMOS" | "ECLIPSE" | "ETH" | "EVM" | "FLOW" | "SOL" | "SPARK" | "SUI" | "TRON" | "TON")[];
7
+ export declare const getEnabledChains: (chains: IChain[]) => ("ALEO" | "STARK" | "STELLAR" | "ALGO" | "APTOS" | "ATOM" | "BTC" | "COSMOS" | "ECLIPSE" | "ETH" | "EVM" | "FLOW" | "SOL" | "SPARK" | "SUI" | "TRON" | "TON")[];
8
8
  type BaseGetSupportedWalletOpts = Omit<GetSupportedWalletsOpts, 'walletConnectProjectId' | 'chainRpcProviders'>;
9
9
  export declare const getWallets: (props: {
10
10
  getSupportedWalletOpts: BaseGetSupportedWalletOpts;
@@ -19,6 +19,7 @@ import '../../shared/consts/index.js';
19
19
  * getChainInfo differs from the one used in the wallet connectors
20
20
  */
21
21
  const chainInfoOverrides = {
22
+ aleo: 'ALEO',
22
23
  starknet: 'STARK',
23
24
  stellar: 'STELLAR',
24
25
  };