@dynamic-labs/sdk-react-core 3.0.0-alpha.22 → 3.0.0-alpha.24

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,20 @@
1
1
 
2
+ ## [3.0.0-alpha.24](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.23...v3.0.0-alpha.24) (2024-07-20)
3
+
4
+ ## [3.0.0-alpha.23](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.22...v3.0.0-alpha.23) (2024-07-19)
5
+
6
+
7
+ ### Features
8
+
9
+ * show custom labels in the sdk ([#6352](https://github.com/dynamic-labs/DynamicAuth/issues/6352)) ([6eec9b2](https://github.com/dynamic-labs/DynamicAuth/commit/6eec9b26dbfd25c5138378aa92de8379a5cd0ddc))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add missing await to viem controller ([#6354](https://github.com/dynamic-labs/DynamicAuth/issues/6354)) ([32c7362](https://github.com/dynamic-labs/DynamicAuth/commit/32c73625c5575f9134edd541c7221aba08a741b5))
15
+ * allow for react-native 0.74.x ([#6371](https://github.com/dynamic-labs/DynamicAuth/issues/6371)) ([37e08b6](https://github.com/dynamic-labs/DynamicAuth/commit/37e08b6b32bcaef7b7f6a4dedc45b2321f3f64a6))
16
+ * not able to switch to secondary wallet ([#6373](https://github.com/dynamic-labs/DynamicAuth/issues/6373)) ([f85ed10](https://github.com/dynamic-labs/DynamicAuth/commit/f85ed10aca8bf41658eb1418cd87e1c5061d4b1b))
17
+
2
18
  ## [3.0.0-alpha.22](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.21...v3.0.0-alpha.22) (2024-07-18)
3
19
 
4
20
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "3.0.0-alpha.22";
6
+ var version = "3.0.0-alpha.24";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.489",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "3.0.0-alpha.22";
2
+ var version = "3.0.0-alpha.24";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.489",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "3.0.0-alpha.22",
3
+ "version": "3.0.0-alpha.24",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -17,15 +17,15 @@
17
17
  "react-i18next": "13.5.0",
18
18
  "yup": "0.32.11",
19
19
  "react-international-phone": "4.2.5",
20
- "@dynamic-labs/iconic": "3.0.0-alpha.22",
21
- "@dynamic-labs/logger": "3.0.0-alpha.22",
22
- "@dynamic-labs/multi-wallet": "3.0.0-alpha.22",
23
- "@dynamic-labs/rpc-providers": "3.0.0-alpha.22",
24
- "@dynamic-labs/store": "3.0.0-alpha.22",
25
- "@dynamic-labs/types": "3.0.0-alpha.22",
26
- "@dynamic-labs/utils": "3.0.0-alpha.22",
27
- "@dynamic-labs/wallet-book": "3.0.0-alpha.22",
28
- "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.22",
20
+ "@dynamic-labs/iconic": "3.0.0-alpha.24",
21
+ "@dynamic-labs/logger": "3.0.0-alpha.24",
22
+ "@dynamic-labs/multi-wallet": "3.0.0-alpha.24",
23
+ "@dynamic-labs/rpc-providers": "3.0.0-alpha.24",
24
+ "@dynamic-labs/store": "3.0.0-alpha.24",
25
+ "@dynamic-labs/types": "3.0.0-alpha.24",
26
+ "@dynamic-labs/utils": "3.0.0-alpha.24",
27
+ "@dynamic-labs/wallet-book": "3.0.0-alpha.24",
28
+ "@dynamic-labs/wallet-connector-core": "3.0.0-alpha.24",
29
29
  "eventemitter3": "5.0.1"
30
30
  },
31
31
  "devDependencies": {
@@ -137,7 +137,7 @@ const UserProfile = ({ rootClassName }) => {
137
137
  // if it's multiwallet, the wallet should appear in the wallets tab
138
138
  // if there's a primary wallet, it will be displayed in the header
139
139
  const wallet = !multiWallet && !primaryWallet && userWallets[0];
140
- return (jsxRuntime.jsxs("div", { "data-testid": 'userProfile', className: classNames.classNames('user-profile', rootClassName), ref: containerRef, children: [error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), wallet && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: t('dyn_user_profile.my_wallet.title'), children: jsxRuntime.jsx(Wallet.Wallet, { ens: (_a = getWalletVerifiedCredential.getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet }, wallet.id) })), (allUserFields === null || allUserFields === void 0 ? void 0 : allUserFields.length) > 0 && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: t('dyn_user_profile.my_information.title'), children: jsxRuntime.jsx("div", { className: 'user-profile__fields', children: allUserFields.map(({ name, validationType, type }) => {
140
+ return (jsxRuntime.jsxs("div", { "data-testid": 'userProfile', className: classNames.classNames('user-profile', rootClassName), ref: containerRef, children: [error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), wallet && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: t('dyn_user_profile.my_wallet.title'), children: jsxRuntime.jsx(Wallet.Wallet, { ens: (_a = getWalletVerifiedCredential.getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet }, wallet.id) })), (allUserFields === null || allUserFields === void 0 ? void 0 : allUserFields.length) > 0 && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: t('dyn_user_profile.my_information.title'), children: jsxRuntime.jsx("div", { className: 'user-profile__fields', children: allUserFields.map(({ name, validationType, type, label }) => {
141
141
  var _a, _b;
142
142
  if (type === sdkApiCore.KycFieldType.Custom) {
143
143
  const value = (_b = (_a = user.metadata) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : '';
@@ -146,11 +146,10 @@ const UserProfile = ({ rootClassName }) => {
146
146
  fieldValue = value.length > 0 ? 'Checked' : 'Unchecked';
147
147
  return (jsxRuntime.jsx(UserProfileField.UserProfileField, { name: name, label: name, value: fieldValue }, name));
148
148
  }
149
- else {
150
- const { label, key } = index$1.getValueByKey(fieldsConfig, name);
151
- const value = mapFieldKeyToValue(name);
152
- return (jsxRuntime.jsx(UserProfileField.UserProfileField, { copykey: key, name: name, label: label, value: value }, name));
153
- }
149
+ const { label: defaultLabel, key } = index$1.getValueByKey(fieldsConfig, name);
150
+ label !== null && label !== void 0 ? label : (label = defaultLabel);
151
+ const value = mapFieldKeyToValue(name);
152
+ return (jsxRuntime.jsx(UserProfileField.UserProfileField, { copykey: key, name: name, label: label, value: value }, name));
154
153
  }) }) })), canLink && !multiWallet && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: t('dyn_user_profile.wallets.title'), children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'link-wallet-button', onClick: addNewWallet, startSlot: jsxRuntime.jsx(add.ReactComponent, {}), showInternalLoading: false, children: jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_user_profile.wallets.link_wallet_button', children: t('dyn_user_profile.wallets.link_wallet_button') }) }) })), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: t('dyn_user_profile.social_accounts.title'), children: jsxRuntime.jsx("div", { className: 'user-profile__social-accounts', children: providers.map(({ provider }) => (jsxRuntime.jsx(UserProfileSocialAccount.UserProfileSocialAccount, { provider: provider }, provider))) }) }))] }));
155
154
  };
156
155
 
@@ -133,7 +133,7 @@ const UserProfile = ({ rootClassName }) => {
133
133
  // if it's multiwallet, the wallet should appear in the wallets tab
134
134
  // if there's a primary wallet, it will be displayed in the header
135
135
  const wallet = !multiWallet && !primaryWallet && userWallets[0];
136
- return (jsxs("div", { "data-testid": 'userProfile', className: classNames('user-profile', rootClassName), ref: containerRef, children: [error && jsx(ErrorContainer, { children: error }), wallet && (jsx(UserProfileSection, { title: t('dyn_user_profile.my_wallet.title'), children: jsx(Wallet, { ens: (_a = getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet }, wallet.id) })), (allUserFields === null || allUserFields === void 0 ? void 0 : allUserFields.length) > 0 && (jsx(UserProfileSection, { title: t('dyn_user_profile.my_information.title'), children: jsx("div", { className: 'user-profile__fields', children: allUserFields.map(({ name, validationType, type }) => {
136
+ return (jsxs("div", { "data-testid": 'userProfile', className: classNames('user-profile', rootClassName), ref: containerRef, children: [error && jsx(ErrorContainer, { children: error }), wallet && (jsx(UserProfileSection, { title: t('dyn_user_profile.my_wallet.title'), children: jsx(Wallet, { ens: (_a = getWalletVerifiedCredential(wallet.address, user === null || user === void 0 ? void 0 : user.verifiedCredentials, wallet.chain)) === null || _a === void 0 ? void 0 : _a.nameService, wallet: wallet }, wallet.id) })), (allUserFields === null || allUserFields === void 0 ? void 0 : allUserFields.length) > 0 && (jsx(UserProfileSection, { title: t('dyn_user_profile.my_information.title'), children: jsx("div", { className: 'user-profile__fields', children: allUserFields.map(({ name, validationType, type, label }) => {
137
137
  var _a, _b;
138
138
  if (type === KycFieldType.Custom) {
139
139
  const value = (_b = (_a = user.metadata) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : '';
@@ -142,11 +142,10 @@ const UserProfile = ({ rootClassName }) => {
142
142
  fieldValue = value.length > 0 ? 'Checked' : 'Unchecked';
143
143
  return (jsx(UserProfileField, { name: name, label: name, value: fieldValue }, name));
144
144
  }
145
- else {
146
- const { label, key } = getValueByKey(fieldsConfig, name);
147
- const value = mapFieldKeyToValue(name);
148
- return (jsx(UserProfileField, { copykey: key, name: name, label: label, value: value }, name));
149
- }
145
+ const { label: defaultLabel, key } = getValueByKey(fieldsConfig, name);
146
+ label !== null && label !== void 0 ? label : (label = defaultLabel);
147
+ const value = mapFieldKeyToValue(name);
148
+ return (jsx(UserProfileField, { copykey: key, name: name, label: label, value: value }, name));
150
149
  }) }) })), canLink && !multiWallet && (jsx(UserProfileSection, { title: t('dyn_user_profile.wallets.title'), children: jsx(TypographyButton, { dataTestId: 'link-wallet-button', onClick: addNewWallet, startSlot: jsx(SvgAdd, {}), showInternalLoading: false, children: jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_user_profile.wallets.link_wallet_button', children: t('dyn_user_profile.wallets.link_wallet_button') }) }) })), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsx(UserProfileSection, { title: t('dyn_user_profile.social_accounts.title'), children: jsx("div", { className: 'user-profile__social-accounts', children: providers.map(({ provider }) => (jsx(UserProfileSocialAccount, { provider: provider }, provider))) }) }))] }));
151
150
  };
152
151
 
@@ -91,7 +91,7 @@ require('../../../../context/ReinitializeContext/ReinitializeContextProvider.cjs
91
91
  var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
92
92
 
93
93
  const useSyncPrimaryWallet = (canSync = true) => {
94
- const { setShowAuthFlow, isAuthenticated, authMode, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, setMultiWalletWidgetState, showLockedWalletView, secondaryWallets, setPrimaryWallet, setSelectedWalletWithAction, multiWallet, } = useInternalDynamicContext.useInternalDynamicContext();
94
+ const { setShowAuthFlow, isAuthenticated, authMode, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, setMultiWalletWidgetState, showLockedWalletView, secondaryWallets, setPrimaryWallet, setSelectedWalletWithAction, multiWallet, selectedWalletWithAction, } = useInternalDynamicContext.useInternalDynamicContext();
95
95
  const { setView } = ViewContext.useViewContext();
96
96
  const handlePrimaryWalletNotActive = React.useCallback((connectedAddress) => {
97
97
  logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('[useSyncPrimaryWallet] handlePrimaryWalletNotActive', {
@@ -112,7 +112,11 @@ const useSyncPrimaryWallet = (canSync = true) => {
112
112
  connectedWalletWithSameProvider,
113
113
  multiWallet,
114
114
  });
115
- if (multiWallet && connectedWalletWithSameProvider) {
115
+ // If user was explicitly trying to switch to this new wallet, let it be
116
+ const wasExplicitWalletChange = (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) === primaryWallet.address;
117
+ if (multiWallet &&
118
+ connectedWalletWithSameProvider &&
119
+ !wasExplicitWalletChange) {
116
120
  setPrimaryWallet(connectedWalletWithSameProvider.id);
117
121
  return;
118
122
  }
@@ -127,6 +131,7 @@ const useSyncPrimaryWallet = (canSync = true) => {
127
131
  primaryWallet,
128
132
  secondaryWallets,
129
133
  multiWallet,
134
+ selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address,
130
135
  setSelectedWalletWithAction,
131
136
  setMultiWalletWidgetState,
132
137
  connectWallet,
@@ -87,7 +87,7 @@ import '../../../../context/ReinitializeContext/ReinitializeContextProvider.js';
87
87
  import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
88
88
 
89
89
  const useSyncPrimaryWallet = (canSync = true) => {
90
- const { setShowAuthFlow, isAuthenticated, authMode, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, setMultiWalletWidgetState, showLockedWalletView, secondaryWallets, setPrimaryWallet, setSelectedWalletWithAction, multiWallet, } = useInternalDynamicContext();
90
+ const { setShowAuthFlow, isAuthenticated, authMode, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, setMultiWalletWidgetState, showLockedWalletView, secondaryWallets, setPrimaryWallet, setSelectedWalletWithAction, multiWallet, selectedWalletWithAction, } = useInternalDynamicContext();
91
91
  const { setView } = useViewContext();
92
92
  const handlePrimaryWalletNotActive = useCallback((connectedAddress) => {
93
93
  logVerboseTroubleshootingMessage('[useSyncPrimaryWallet] handlePrimaryWalletNotActive', {
@@ -108,7 +108,11 @@ const useSyncPrimaryWallet = (canSync = true) => {
108
108
  connectedWalletWithSameProvider,
109
109
  multiWallet,
110
110
  });
111
- if (multiWallet && connectedWalletWithSameProvider) {
111
+ // If user was explicitly trying to switch to this new wallet, let it be
112
+ const wasExplicitWalletChange = (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) === primaryWallet.address;
113
+ if (multiWallet &&
114
+ connectedWalletWithSameProvider &&
115
+ !wasExplicitWalletChange) {
112
116
  setPrimaryWallet(connectedWalletWithSameProvider.id);
113
117
  return;
114
118
  }
@@ -123,6 +127,7 @@ const useSyncPrimaryWallet = (canSync = true) => {
123
127
  primaryWallet,
124
128
  secondaryWallets,
125
129
  multiWallet,
130
+ selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address,
126
131
  setSelectedWalletWithAction,
127
132
  setMultiWalletWidgetState,
128
133
  connectWallet,
@@ -97,7 +97,7 @@ const renderCheckboxGroup = (key, name, label, validationRules, errors, touched,
97
97
  ? 'user-field__checkbox-container--error'
98
98
  : ''}`, children: (validationRules === null || validationRules === void 0 ? void 0 : validationRules.checkboxText) && (jsxRuntime.jsxs("div", { className: 'user-field__consent-checkbox', children: [jsxRuntime.jsx(formik.Field, { as: Checkbox.Checkbox, id: key, name: name, type: 'checkbox', value: '0', disabled: disabled, selectDataTestId: 'customFieldCheckbox' }, key), jsxRuntime.jsx("label", { htmlFor: key, className: 'user-field__checkbox-label', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', children: validationRules.checkboxText }) })] }, key)) }, 'customConsentGroup'), touched[name] && getDisplayErrorMessage.getDisplayErrorMessage(label, errors[name]) && (jsxRuntime.jsx(Typography.Typography, { variant: 'body_mini', className: 'user-field__error-message', children: `${name.charAt(0).toUpperCase() + name.slice(1)} is required` }))] }));
99
99
  const renderPoliciesConsentGroup = (key, policiesConsentInnerComponentArray, disabled) => (jsxRuntime.jsx("div", { role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-field__checkbox-container', children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxRuntime.jsxs("div", { className: 'user-field__consent-checkbox', children: [jsxRuntime.jsx(formik.Field, { copykey: key, as: Checkbox.Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}`, disabled: disabled }, `policiesConsent_${index}`), jsxRuntime.jsx("label", { htmlFor: `policiesConsent_${index}`, className: 'user-field__checkbox-label', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', children: component }) })] }, `policiesConsent_${index}`))) }, 'policiesConsentGroup'));
100
- const UserField = ({ fieldData: { validationRules, isCustom, key, label, type, autoComplete }, fieldSettings: { enabled, name, required, verify }, errors, touched, disabled, policiesConsentInnerComponentArray, }) => {
100
+ const UserField = ({ fieldData: { validationRules, isCustom, key, label: defaultLabel, type, autoComplete, }, fieldSettings: { enabled, name, required, verify, label = defaultLabel }, errors, touched, disabled, policiesConsentInnerComponentArray, }) => {
101
101
  if (isCustom) {
102
102
  if (type === sdkApiCore.CustomFieldType.Select && (validationRules === null || validationRules === void 0 ? void 0 : validationRules.validOptions)) {
103
103
  const options = validationRules.validOptions.map((opt) => opt.label);
@@ -93,7 +93,7 @@ const renderCheckboxGroup = (key, name, label, validationRules, errors, touched,
93
93
  ? 'user-field__checkbox-container--error'
94
94
  : ''}`, children: (validationRules === null || validationRules === void 0 ? void 0 : validationRules.checkboxText) && (jsxs("div", { className: 'user-field__consent-checkbox', children: [jsx(Field, { as: Checkbox, id: key, name: name, type: 'checkbox', value: '0', disabled: disabled, selectDataTestId: 'customFieldCheckbox' }, key), jsx("label", { htmlFor: key, className: 'user-field__checkbox-label', children: jsx(Typography, { variant: 'body_small', color: 'secondary', children: validationRules.checkboxText }) })] }, key)) }, 'customConsentGroup'), touched[name] && getDisplayErrorMessage(label, errors[name]) && (jsx(Typography, { variant: 'body_mini', className: 'user-field__error-message', children: `${name.charAt(0).toUpperCase() + name.slice(1)} is required` }))] }));
95
95
  const renderPoliciesConsentGroup = (key, policiesConsentInnerComponentArray, disabled) => (jsx("div", { role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-field__checkbox-container', children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxs("div", { className: 'user-field__consent-checkbox', children: [jsx(Field, { copykey: key, as: Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}`, disabled: disabled }, `policiesConsent_${index}`), jsx("label", { htmlFor: `policiesConsent_${index}`, className: 'user-field__checkbox-label', children: jsx(Typography, { variant: 'body_small', color: 'secondary', children: component }) })] }, `policiesConsent_${index}`))) }, 'policiesConsentGroup'));
96
- const UserField = ({ fieldData: { validationRules, isCustom, key, label, type, autoComplete }, fieldSettings: { enabled, name, required, verify }, errors, touched, disabled, policiesConsentInnerComponentArray, }) => {
96
+ const UserField = ({ fieldData: { validationRules, isCustom, key, label: defaultLabel, type, autoComplete, }, fieldSettings: { enabled, name, required, verify, label = defaultLabel }, errors, touched, disabled, policiesConsentInnerComponentArray, }) => {
97
97
  if (isCustom) {
98
98
  if (type === CustomFieldType.Select && (validationRules === null || validationRules === void 0 ? void 0 : validationRules.validOptions)) {
99
99
  const options = validationRules.validOptions.map((opt) => opt.label);