@dynamic-labs/sdk-react-core 4.0.0-alpha.46 → 4.0.0-alpha.48

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 (40) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/index.d.ts +1 -1
  6. package/src/lib/components/Divider/Divider.cjs +1 -0
  7. package/src/lib/components/Divider/Divider.js +1 -0
  8. package/src/lib/components/UserProfile/UserProfile.cjs +6 -1
  9. package/src/lib/components/UserProfile/UserProfile.js +7 -2
  10. package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.cjs +1 -1
  11. package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.js +2 -2
  12. package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -5
  13. package/src/lib/context/DynamicContext/DynamicContext.js +1 -5
  14. package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +2 -2
  15. package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +2 -5
  16. package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +1 -1
  17. package/src/lib/context/DynamicContext/types/index.d.ts +0 -1
  18. package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +1 -3
  19. package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
  20. package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +1 -3
  21. package/src/lib/events/multiWallet.d.ts +2 -1
  22. package/src/lib/shared/types/wallets.d.ts +10 -0
  23. package/src/lib/store/state/walletConnectorOptions.cjs +21 -2
  24. package/src/lib/store/state/walletConnectorOptions.d.ts +7 -1
  25. package/src/lib/store/state/walletConnectorOptions.js +21 -2
  26. package/src/lib/styles/index.shadow.cjs +1 -1
  27. package/src/lib/styles/index.shadow.js +1 -1
  28. package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +5 -3
  29. package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +5 -3
  30. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.cjs +1 -1
  31. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.js +2 -2
  32. package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +12 -6
  33. package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +12 -6
  34. package/src/lib/views/SubdomainField/SubdomainField.cjs +7 -1
  35. package/src/lib/views/SubdomainField/SubdomainField.js +7 -1
  36. package/src/lib/views/WalletList/WalletListGridTabs/WalletListGridTabs.d.ts +1 -1
  37. package/src/lib/views/WalletList/hooks/useTabState.d.ts +2 -2
  38. package/src/lib/views/WalletList/utils/getEffectiveRecommendedWallets.d.ts +1 -2
  39. package/src/lib/views/WalletList/utils/getEffectiveWalletFilter.d.ts +1 -1
  40. package/src/lib/context/DynamicContext/types/WalletListViewTabItem.d.ts +0 -11
@@ -94,18 +94,20 @@ const useVerifyOnAwaitingSignature = () => {
94
94
  // this is to prevent calling runConnectAndSign multiple times
95
95
  // due to changes in legacyIsVerifying
96
96
  const isVerifying = React.useRef(false);
97
- const runConnectAndSign = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
97
+ const runConnectAndSign = React.useCallback((walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
98
98
  logger.logger.debug('runConnectAndSign', {
99
99
  selectedWalletConnector,
100
+ walletConnector,
100
101
  });
101
- if (!selectedWalletConnector) {
102
+ const connector = walletConnector !== null && walletConnector !== void 0 ? walletConnector : selectedWalletConnector;
103
+ if (!connector) {
102
104
  return;
103
105
  }
104
106
  isVerifying.current = true;
105
107
  setLegacyIsVerifying(true);
106
108
  try {
107
109
  yield triggerConnectAndSign({
108
- walletConnector: selectedWalletConnector,
110
+ walletConnector: connector,
109
111
  });
110
112
  }
111
113
  catch (e) {
@@ -90,18 +90,20 @@ const useVerifyOnAwaitingSignature = () => {
90
90
  // this is to prevent calling runConnectAndSign multiple times
91
91
  // due to changes in legacyIsVerifying
92
92
  const isVerifying = useRef(false);
93
- const runConnectAndSign = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
93
+ const runConnectAndSign = useCallback((walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
94
94
  logger.debug('runConnectAndSign', {
95
95
  selectedWalletConnector,
96
+ walletConnector,
96
97
  });
97
- if (!selectedWalletConnector) {
98
+ const connector = walletConnector !== null && walletConnector !== void 0 ? walletConnector : selectedWalletConnector;
99
+ if (!connector) {
98
100
  return;
99
101
  }
100
102
  isVerifying.current = true;
101
103
  setLegacyIsVerifying(true);
102
104
  try {
103
105
  yield triggerConnectAndSign({
104
- walletConnector: selectedWalletConnector,
106
+ walletConnector: connector,
105
107
  });
106
108
  }
107
109
  catch (e) {
@@ -51,7 +51,7 @@ const useCreateWalletConnectorOptions = (_a) => {
51
51
  if (!projectSettings || walletConnectorOptions$1.length === 0)
52
52
  return;
53
53
  verifyRequiredConnectorsAreSetup.verifyRequiredConnectorsAreSetup(projectSettings, walletConnectorOptions$1.map(({ walletConnector }) => walletConnector));
54
- walletConnectorOptions.setWalletConnectorOptions(walletConnectorOptions$1);
54
+ walletConnectorOptions.mergeWalletConnectorOptions(walletConnectorOptions$1);
55
55
  }, [walletConnectorOptions$1, projectSettings]);
56
56
  return { walletConnectorOptions: walletConnectorOptions$1 };
57
57
  };
@@ -21,7 +21,7 @@ import '../../../store/state/user/user.js';
21
21
  import '../../../locale/locale.js';
22
22
  import { serializeWalletConnectors } from '../../functions/serializeWalletConnectors/serializeWalletConnectors.js';
23
23
  import '../../../store/state/projectSettings/projectSettings.js';
24
- import { setWalletConnectorOptions } from '../../../store/state/walletConnectorOptions.js';
24
+ import { mergeWalletConnectorOptions } from '../../../store/state/walletConnectorOptions.js';
25
25
  import { verifyRequiredConnectorsAreSetup } from './utils/verifyRequiredConnectorsAreSetup/verifyRequiredConnectorsAreSetup.js';
26
26
 
27
27
  const useCreateWalletConnectorOptions = (_a) => {
@@ -47,7 +47,7 @@ const useCreateWalletConnectorOptions = (_a) => {
47
47
  if (!projectSettings || walletConnectorOptions.length === 0)
48
48
  return;
49
49
  verifyRequiredConnectorsAreSetup(projectSettings, walletConnectorOptions.map(({ walletConnector }) => walletConnector));
50
- setWalletConnectorOptions(walletConnectorOptions);
50
+ mergeWalletConnectorOptions(walletConnectorOptions);
51
51
  }, [walletConnectorOptions, projectSettings]);
52
52
  return { walletConnectorOptions };
53
53
  };
@@ -19,7 +19,7 @@ require('../../constants/colors.cjs');
19
19
  require('../../constants/values.cjs');
20
20
  require('../../../store/state/loadingAndLifecycle.cjs');
21
21
  require('../../../shared/consts/index.cjs');
22
- require('../../../events/dynamicEvents.cjs');
22
+ var dynamicEvents = require('../../../events/dynamicEvents.cjs');
23
23
  var useConnectAndSign = require('../authenticationHooks/useConnectAndSign/useConnectAndSign.cjs');
24
24
  var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
25
25
  require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
@@ -182,14 +182,20 @@ const useWalletItemActions = () => {
182
182
  activeAccountAlreadyLinked,
183
183
  connectedAccounts,
184
184
  linkedWallets,
185
+ walletConnectorKey: walletConnector.key,
185
186
  });
186
- if (activeAccountAlreadyLinked) {
187
- setMultiWalletWidgetState('awaiting_account_switch', 'linking_new_wallet');
188
- }
189
- else {
187
+ setSelectedWalletConnectorKey(walletConnector.key);
188
+ if (!activeAccountAlreadyLinked) {
190
189
  setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
190
+ return;
191
191
  }
192
- setSelectedWalletConnectorKey(walletConnector.key);
192
+ const isTryingToUpdateUnkownWallet = activeAccountAlreadyLinked.connector.key === 'unknown';
193
+ if (isTryingToUpdateUnkownWallet) {
194
+ //prompt the user to connect and sign with the wallet
195
+ dynamicEvents.dynamicEvents.emit('triggerConnectAndSign', walletConnector);
196
+ return;
197
+ }
198
+ setMultiWalletWidgetState('awaiting_account_switch', 'linking_new_wallet');
193
199
  });
194
200
  const openWallet = (walletKey, handlers) => {
195
201
  var _a;
@@ -15,7 +15,7 @@ import '../../constants/colors.js';
15
15
  import '../../constants/values.js';
16
16
  import '../../../store/state/loadingAndLifecycle.js';
17
17
  import '../../../shared/consts/index.js';
18
- import '../../../events/dynamicEvents.js';
18
+ import { dynamicEvents } from '../../../events/dynamicEvents.js';
19
19
  import { useConnectAndSign } from '../authenticationHooks/useConnectAndSign/useConnectAndSign.js';
20
20
  import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
21
21
  import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
@@ -178,14 +178,20 @@ const useWalletItemActions = () => {
178
178
  activeAccountAlreadyLinked,
179
179
  connectedAccounts,
180
180
  linkedWallets,
181
+ walletConnectorKey: walletConnector.key,
181
182
  });
182
- if (activeAccountAlreadyLinked) {
183
- setMultiWalletWidgetState('awaiting_account_switch', 'linking_new_wallet');
184
- }
185
- else {
183
+ setSelectedWalletConnectorKey(walletConnector.key);
184
+ if (!activeAccountAlreadyLinked) {
186
185
  setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
186
+ return;
187
187
  }
188
- setSelectedWalletConnectorKey(walletConnector.key);
188
+ const isTryingToUpdateUnkownWallet = activeAccountAlreadyLinked.connector.key === 'unknown';
189
+ if (isTryingToUpdateUnkownWallet) {
190
+ //prompt the user to connect and sign with the wallet
191
+ dynamicEvents.emit('triggerConnectAndSign', walletConnector);
192
+ return;
193
+ }
194
+ setMultiWalletWidgetState('awaiting_account_switch', 'linking_new_wallet');
189
195
  });
190
196
  const openWallet = (walletKey, handlers) => {
191
197
  var _a;
@@ -94,6 +94,12 @@ const SubdomainField = ({ showDetails = false, }) => {
94
94
  const checkSubdomain = useSubdomainCheck.useSubdomainCheck();
95
95
  const { projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
96
96
  const [checkResponse, setCheckResponse] = React.useState(undefined);
97
+ // When the subdomain is saved, the value is stored in a metadata object
98
+ // instead, so we need to default to the initial value to prevent the
99
+ // value from disappearing
100
+ const subDomainValue = React.useMemo(() => values['name-service-subdomain-handle'] === undefined
101
+ ? initialValues['name-service-subdomain-handle'] || ''
102
+ : values['name-service-subdomain-handle'], [values, initialValues]);
97
103
  const ensDomain = React.useMemo(() => {
98
104
  var _a;
99
105
  const domain = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.nameService) === null || _a === void 0 ? void 0 : _a.evm.domain;
@@ -135,7 +141,7 @@ const SubdomainField = ({ showDetails = false, }) => {
135
141
  logger.logger.error('Failed to get ENS domain from settings.sdk.nameService');
136
142
  return null;
137
143
  }
138
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'subdomain-field__container', children: [jsxRuntime.jsx(Input.Input, { id: 'subdomain-field', className: 'input__container--available', value: values['name-service-subdomain-handle'] || '', onChange: onChange, label: t('dyn_subdomain_field.label'), error: message && !(checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available) ? true : false, success: checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available, message: message }), jsxRuntime.jsx(Typography.Typography, { as: 'span', color: 'secondary', variant: 'body_normal', children: ensDomain })] }), showDetails && (jsxRuntime.jsx(Typography.Typography, { as: 'p', color: 'secondary', variant: 'body_small', className: 'subdomain-field__details', children: t('dyn_subdomain_field.details') })), jsxRuntime.jsx(Divider.Divider, {})] }));
144
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'subdomain-field__container', children: [jsxRuntime.jsx(Input.Input, { id: 'subdomain-field', className: 'input__container--available', value: subDomainValue, onChange: onChange, label: t('dyn_subdomain_field.label'), error: message && !(checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available) ? true : false, success: checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available, message: message }), jsxRuntime.jsx(Typography.Typography, { as: 'span', color: 'secondary', variant: 'body_normal', children: ensDomain })] }), showDetails && (jsxRuntime.jsx(Typography.Typography, { as: 'p', color: 'secondary', variant: 'body_small', className: 'subdomain-field__details', children: t('dyn_subdomain_field.details') })), jsxRuntime.jsx(Divider.Divider, {})] }));
139
145
  };
140
146
 
141
147
  exports.SubdomainField = SubdomainField;
@@ -90,6 +90,12 @@ const SubdomainField = ({ showDetails = false, }) => {
90
90
  const checkSubdomain = useSubdomainCheck();
91
91
  const { projectSettings } = useInternalDynamicContext();
92
92
  const [checkResponse, setCheckResponse] = useState(undefined);
93
+ // When the subdomain is saved, the value is stored in a metadata object
94
+ // instead, so we need to default to the initial value to prevent the
95
+ // value from disappearing
96
+ const subDomainValue = useMemo(() => values['name-service-subdomain-handle'] === undefined
97
+ ? initialValues['name-service-subdomain-handle'] || ''
98
+ : values['name-service-subdomain-handle'], [values, initialValues]);
93
99
  const ensDomain = useMemo(() => {
94
100
  var _a;
95
101
  const domain = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.nameService) === null || _a === void 0 ? void 0 : _a.evm.domain;
@@ -131,7 +137,7 @@ const SubdomainField = ({ showDetails = false, }) => {
131
137
  logger.error('Failed to get ENS domain from settings.sdk.nameService');
132
138
  return null;
133
139
  }
134
- return (jsxs(Fragment, { children: [jsxs("div", { className: 'subdomain-field__container', children: [jsx(Input, { id: 'subdomain-field', className: 'input__container--available', value: values['name-service-subdomain-handle'] || '', onChange: onChange, label: t('dyn_subdomain_field.label'), error: message && !(checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available) ? true : false, success: checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available, message: message }), jsx(Typography, { as: 'span', color: 'secondary', variant: 'body_normal', children: ensDomain })] }), showDetails && (jsx(Typography, { as: 'p', color: 'secondary', variant: 'body_small', className: 'subdomain-field__details', children: t('dyn_subdomain_field.details') })), jsx(Divider, {})] }));
140
+ return (jsxs(Fragment, { children: [jsxs("div", { className: 'subdomain-field__container', children: [jsx(Input, { id: 'subdomain-field', className: 'input__container--available', value: subDomainValue, onChange: onChange, label: t('dyn_subdomain_field.label'), error: message && !(checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available) ? true : false, success: checkResponse === null || checkResponse === void 0 ? void 0 : checkResponse.available, message: message }), jsx(Typography, { as: 'span', color: 'secondary', variant: 'body_normal', children: ensDomain })] }), showDetails && (jsx(Typography, { as: 'p', color: 'secondary', variant: 'body_small', className: 'subdomain-field__details', children: t('dyn_subdomain_field.details') })), jsx(Divider, {})] }));
135
141
  };
136
142
 
137
143
  export { SubdomainField };
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { WalletListViewTabItem } from '../../../context/DynamicContext/types';
2
+ import { WalletListViewTabItem } from '../../../shared';
3
3
  type WalletListGridTabsProps = {
4
4
  items: WalletListViewTabItem[];
5
5
  onSelect: (index: number) => void;
@@ -4,7 +4,7 @@ export declare const useTabState: ({ settingsOverrides, }: {
4
4
  settingsOverrides: SettingsOverrides | undefined;
5
5
  }) => {
6
6
  selectedTabIndex: number;
7
- selectedTabSettings: import("../../../context/DynamicContext/types").WalletListViewTabItem | undefined;
7
+ selectedTabSettings: import("../../../shared").WalletListViewTabItem | undefined;
8
8
  setSelectedTabIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
9
- tabsItems: import("../../../context/DynamicContext/types").WalletListViewTabItem[] | undefined;
9
+ tabsItems: import("../../../shared").WalletListViewTabItem[] | undefined;
10
10
  };
@@ -1,3 +1,2 @@
1
- import { WalletListViewTabItem } from '../../../context/DynamicContext/types';
2
- import { RecommendedWallet } from '../../../shared';
1
+ import { RecommendedWallet, WalletListViewTabItem } from '../../../shared';
3
2
  export declare const getEffectiveRecommendedWallets: (selectedTabSettings: WalletListViewTabItem | undefined, recommendedWallets: RecommendedWallet[] | undefined) => RecommendedWallet[] | undefined;
@@ -1,2 +1,2 @@
1
- import { WalletListViewTabItem, WalletsFilter } from '../../../context/DynamicContext/types';
1
+ import { WalletListViewTabItem, WalletsFilter } from '../../../shared';
2
2
  export declare const getEffectiveWalletFilter: (selectedTabSettings: WalletListViewTabItem | undefined, walletsFilter: WalletsFilter | undefined) => WalletsFilter | undefined;
@@ -1,11 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { RecommendedWallet, WalletOption } from '../../../shared/types/wallets';
3
- export type WalletsFilter = (options: WalletOption[]) => WalletOption[];
4
- export type WalletListViewTabItem = {
5
- label: {
6
- text?: string;
7
- icon?: string | ReactElement;
8
- };
9
- walletsFilter?: WalletsFilter;
10
- recommendedWallets?: RecommendedWallet[];
11
- };