@dynamic-labs/sdk-react-core 4.59.1 → 4.59.2
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 +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/lib/components/FormFieldLabel/FormFieldLabel.cjs +5 -1
- package/src/lib/components/FormFieldLabel/FormFieldLabel.d.ts +2 -1
- package/src/lib/components/FormFieldLabel/FormFieldLabel.js +5 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +4 -2
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +4 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +28 -3
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +29 -4
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +10 -3
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +10 -3
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +2 -1
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.59.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.59.1...v4.59.2) (2026-02-03)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add more copykeys in the send widget. ([#10271](https://github.com/dynamic-labs/dynamic-auth/issues/10271)) ([d62c4c5](https://github.com/dynamic-labs/dynamic-auth/commit/d62c4c50feaebb2449b1b3b8372638257761a729))
|
|
8
|
+
* add StellarWalletConnector ([#10249](https://github.com/dynamic-labs/dynamic-auth/issues/10249)) ([152b400](https://github.com/dynamic-labs/dynamic-auth/commit/152b4001fd17f3f11581e66502edd6e17b51ecd0))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* filter delegated wallets to only include EVM and Solana chains ([#10237](https://github.com/dynamic-labs/dynamic-auth/issues/10237)) ([53f9b00](https://github.com/dynamic-labs/dynamic-auth/commit/53f9b003b95dcd11ea380893f28085362e42f252))
|
|
14
|
+
|
|
2
15
|
### [4.59.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.59.0...v4.59.1) (2026-01-30)
|
|
3
16
|
|
|
4
17
|
This was a version bump only, there were no code changes.
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.59.
|
|
3
|
+
"version": "4.59.2",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.860",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.4.0",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"react-international-phone": "4.5.0",
|
|
17
17
|
"bs58": "5.0.0",
|
|
18
|
-
"@dynamic-labs/assert-package-version": "4.59.
|
|
19
|
-
"@dynamic-labs/iconic": "4.59.
|
|
20
|
-
"@dynamic-labs/locale": "4.59.
|
|
21
|
-
"@dynamic-labs/logger": "4.59.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "4.59.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "4.59.
|
|
24
|
-
"@dynamic-labs/store": "4.59.
|
|
25
|
-
"@dynamic-labs/types": "4.59.
|
|
26
|
-
"@dynamic-labs/utils": "4.59.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.59.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.59.
|
|
18
|
+
"@dynamic-labs/assert-package-version": "4.59.2",
|
|
19
|
+
"@dynamic-labs/iconic": "4.59.2",
|
|
20
|
+
"@dynamic-labs/locale": "4.59.2",
|
|
21
|
+
"@dynamic-labs/logger": "4.59.2",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "4.59.2",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "4.59.2",
|
|
24
|
+
"@dynamic-labs/store": "4.59.2",
|
|
25
|
+
"@dynamic-labs/types": "4.59.2",
|
|
26
|
+
"@dynamic-labs/utils": "4.59.2",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.59.2",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.59.2",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
6
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
8
9
|
|
|
9
|
-
const FormFieldLabel = (
|
|
10
|
+
const FormFieldLabel = (_a) => {
|
|
11
|
+
var { children, htmlFor, className, divider } = _a, props = _tslib.__rest(_a, ["children", "htmlFor", "className", "divider"]);
|
|
12
|
+
return (jsxRuntime.jsx("label", Object.assign({ className: classNames.classNames('form-field-label', { 'form-field-label__with-divider': divider }, className), htmlFor: htmlFor }, props, { children: children })));
|
|
13
|
+
};
|
|
10
14
|
|
|
11
15
|
exports.FormFieldLabel = FormFieldLabel;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { CopyKey } from '../../shared';
|
|
2
3
|
type FormFieldLabelProps = {
|
|
3
4
|
htmlFor?: string;
|
|
4
5
|
className?: string;
|
|
5
6
|
divider?: boolean;
|
|
6
|
-
};
|
|
7
|
+
} & CopyKey;
|
|
7
8
|
export declare const FormFieldLabel: FC<PropsWithChildren<FormFieldLabelProps>>;
|
|
8
9
|
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { __rest } from '../../../../_virtual/_tslib.js';
|
|
2
3
|
import { jsx } from 'react/jsx-runtime';
|
|
3
4
|
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
4
5
|
|
|
5
|
-
const FormFieldLabel = (
|
|
6
|
+
const FormFieldLabel = (_a) => {
|
|
7
|
+
var { children, htmlFor, className, divider } = _a, props = __rest(_a, ["children", "htmlFor", "className", "divider"]);
|
|
8
|
+
return (jsx("label", Object.assign({ className: classNames('form-field-label', { 'form-field-label__with-divider': divider }, className), htmlFor: htmlFor }, props, { children: children })));
|
|
9
|
+
};
|
|
6
10
|
|
|
7
11
|
export { FormFieldLabel };
|
|
@@ -169,7 +169,7 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
169
169
|
}, [decimals, validateAddress, validateAmount]);
|
|
170
170
|
return (jsxRuntime.jsx(formik.Formik, { initialValues: initialValues || sendBalanceFormInitialValues, validationSchema: sendBalanceFormValidationSchema, onSubmit: (values) => onSubmit(values), validateOnChange: false, validateOnBlur: false, children: ({ errors, touched, values, handleChange, setFieldValue, setErrors, handleBlur, setFieldTouched, validateField, }) => {
|
|
171
171
|
var _a;
|
|
172
|
-
return (jsxRuntime.jsxs(formik.Form, { className: 'send-balance-form', children: [jsxRuntime.jsxs("div", { className: 'send-balance-page-layout__balance-container', children: [jsxRuntime.jsx(FormFieldLabel.FormFieldLabel, {
|
|
172
|
+
return (jsxRuntime.jsxs(formik.Form, { className: 'send-balance-form', children: [jsxRuntime.jsxs("div", { className: 'send-balance-page-layout__balance-container', children: [jsxRuntime.jsx(FormFieldLabel.FormFieldLabel, { copykey: 'dyn_send_transaction.data.select_token', children: t('dyn_send_transaction.data.select_token') }), jsxRuntime.jsx(TokensBalanceDropdown.TokensBalanceDropdown, { tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, setFieldValue: setFieldValue, setErrors: setErrors })] }), jsxRuntime.jsxs("div", { className: 'send-balance-form__amount-container', children: [jsxRuntime.jsx(formik.Field, { variant: 'regular', className: `send-balance-form__amount-container__field ${showFiat ? 'fiat' : ''}`, name: 'amount', id: 'amount', onChange: (e) => {
|
|
173
173
|
const newValue = e.target.value;
|
|
174
174
|
// Matching 123, 123.45, .45, 123.
|
|
175
175
|
if (newValue !== '' && !/^(?:\d+|\d*\.\d*|)$/.test(newValue)) {
|
|
@@ -189,7 +189,9 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
189
189
|
}, placeholder: t('dyn_send_transaction.data.amount.placeholder'), as: Input.Input, error: errors['amount'], copykey: 'dyn_send_transaction.data.amount.label', message: touched['amount'] &&
|
|
190
190
|
getDisplayErrorMessage(errors, t, 'amount', decimals), style: {
|
|
191
191
|
paddingLeft: `${leftSymbolPadding}px`,
|
|
192
|
-
} }), jsxRuntime.jsx("div", { className: 'send-balance-form__amount-container__floating_value', ref: floatingValueRef, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', weight: 'regular', color: 'secondary', children: currentToken === null || currentToken === void 0 ? void 0 : currentToken.symbol }) }), jsxRuntime.jsx("div", { className: 'send-balance-form__amount-container__balance', children: showFiat && !Number.isNaN(amount) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_mini', weight: 'bold', color: 'secondary', children: "$" }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_mini', weight: 'regular', color: 'secondary', children: utils.getDisplayFiatPrice(amount, currentToken) })] })) })] }), jsxRuntime.jsx(Typography.Typography, { className: 'send-balance-form__amount_available', variant: 'body_small', weight: 'regular', color: 'secondary', as: 'div', children: jsxRuntime.jsxs("div", { style: { display: 'flex', gap: '0.225rem' }, children: [jsxRuntime.jsx(Typography.Typography, { className: 'send-balance-form__amount_available__line', variant: 'body_small', weight: 'bold', color: 'primary', as: 'div', children: (_a = currentToken === null || currentToken === void 0 ? void 0 : currentToken.balance) !== null && _a !== void 0 ? _a : 0 }),
|
|
192
|
+
} }), jsxRuntime.jsx("div", { className: 'send-balance-form__amount-container__floating_value', ref: floatingValueRef, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', weight: 'regular', color: 'secondary', children: currentToken === null || currentToken === void 0 ? void 0 : currentToken.symbol }) }), jsxRuntime.jsx("div", { className: 'send-balance-form__amount-container__balance', children: showFiat && !Number.isNaN(amount) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_mini', weight: 'bold', color: 'secondary', children: "$" }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_mini', weight: 'regular', color: 'secondary', children: utils.getDisplayFiatPrice(amount, currentToken) })] })) })] }), jsxRuntime.jsx(Typography.Typography, { className: 'send-balance-form__amount_available', variant: 'body_small', weight: 'regular', color: 'secondary', as: 'div', children: jsxRuntime.jsxs("div", { style: { display: 'flex', gap: '0.225rem' }, children: [jsxRuntime.jsx(Typography.Typography, { className: 'send-balance-form__amount_available__line', variant: 'body_small', weight: 'bold', color: 'primary', as: 'div', children: (_a = currentToken === null || currentToken === void 0 ? void 0 : currentToken.balance) !== null && _a !== void 0 ? _a : 0 }), t('dyn_send_transaction.data.symbol_available', {
|
|
193
|
+
symbol: currentToken === null || currentToken === void 0 ? void 0 : currentToken.symbol,
|
|
194
|
+
})] }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', copykey: 'dyn_send_transaction.data.recipient.label', children: "Recipient Address" }), jsxRuntime.jsx(formik.Field, { className: 'send-balance-form__field', placeholder: t('dyn_send_transaction.data.recipient.placeholder'), label: t('dyn_send_transaction.data.recipient.label'), id: 'recipient', name: 'recipient', as: Input.Input, error: errors['recipient'], copykey: 'dyn_send_transaction.data.recipient.label', message: touched['recipient'] &&
|
|
193
195
|
getDisplayErrorMessage(errors, t, 'recipient') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'sendBalanceFormSubmitButton', expanded: true, type: 'submit', buttonVariant: 'primary', buttonPadding: 'small', buttonClassName: 'send-balance-form__button', copykey: 'dyn_send_transaction.preview_transaction', children: t('dyn_send_transaction.preview_transaction') })] }));
|
|
194
196
|
} }));
|
|
195
197
|
};
|
|
@@ -165,7 +165,7 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
165
165
|
}, [decimals, validateAddress, validateAmount]);
|
|
166
166
|
return (jsx(Formik, { initialValues: initialValues || sendBalanceFormInitialValues, validationSchema: sendBalanceFormValidationSchema, onSubmit: (values) => onSubmit(values), validateOnChange: false, validateOnBlur: false, children: ({ errors, touched, values, handleChange, setFieldValue, setErrors, handleBlur, setFieldTouched, validateField, }) => {
|
|
167
167
|
var _a;
|
|
168
|
-
return (jsxs(Form, { className: 'send-balance-form', children: [jsxs("div", { className: 'send-balance-page-layout__balance-container', children: [jsx(FormFieldLabel, {
|
|
168
|
+
return (jsxs(Form, { className: 'send-balance-form', children: [jsxs("div", { className: 'send-balance-page-layout__balance-container', children: [jsx(FormFieldLabel, { copykey: 'dyn_send_transaction.data.select_token', children: t('dyn_send_transaction.data.select_token') }), jsx(TokensBalanceDropdown, { tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, setFieldValue: setFieldValue, setErrors: setErrors })] }), jsxs("div", { className: 'send-balance-form__amount-container', children: [jsx(Field, { variant: 'regular', className: `send-balance-form__amount-container__field ${showFiat ? 'fiat' : ''}`, name: 'amount', id: 'amount', onChange: (e) => {
|
|
169
169
|
const newValue = e.target.value;
|
|
170
170
|
// Matching 123, 123.45, .45, 123.
|
|
171
171
|
if (newValue !== '' && !/^(?:\d+|\d*\.\d*|)$/.test(newValue)) {
|
|
@@ -185,7 +185,9 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
|
|
|
185
185
|
}, placeholder: t('dyn_send_transaction.data.amount.placeholder'), as: Input, error: errors['amount'], copykey: 'dyn_send_transaction.data.amount.label', message: touched['amount'] &&
|
|
186
186
|
getDisplayErrorMessage(errors, t, 'amount', decimals), style: {
|
|
187
187
|
paddingLeft: `${leftSymbolPadding}px`,
|
|
188
|
-
} }), jsx("div", { className: 'send-balance-form__amount-container__floating_value', ref: floatingValueRef, children: jsx(Typography, { variant: 'title', weight: 'regular', color: 'secondary', children: currentToken === null || currentToken === void 0 ? void 0 : currentToken.symbol }) }), jsx("div", { className: 'send-balance-form__amount-container__balance', children: showFiat && !Number.isNaN(amount) && (jsxs(Fragment, { children: [jsx(Typography, { variant: 'body_mini', weight: 'bold', color: 'secondary', children: "$" }), jsx(Typography, { variant: 'body_mini', weight: 'regular', color: 'secondary', children: getDisplayFiatPrice(amount, currentToken) })] })) })] }), jsx(Typography, { className: 'send-balance-form__amount_available', variant: 'body_small', weight: 'regular', color: 'secondary', as: 'div', children: jsxs("div", { style: { display: 'flex', gap: '0.225rem' }, children: [jsx(Typography, { className: 'send-balance-form__amount_available__line', variant: 'body_small', weight: 'bold', color: 'primary', as: 'div', children: (_a = currentToken === null || currentToken === void 0 ? void 0 : currentToken.balance) !== null && _a !== void 0 ? _a : 0 }),
|
|
188
|
+
} }), jsx("div", { className: 'send-balance-form__amount-container__floating_value', ref: floatingValueRef, children: jsx(Typography, { variant: 'title', weight: 'regular', color: 'secondary', children: currentToken === null || currentToken === void 0 ? void 0 : currentToken.symbol }) }), jsx("div", { className: 'send-balance-form__amount-container__balance', children: showFiat && !Number.isNaN(amount) && (jsxs(Fragment, { children: [jsx(Typography, { variant: 'body_mini', weight: 'bold', color: 'secondary', children: "$" }), jsx(Typography, { variant: 'body_mini', weight: 'regular', color: 'secondary', children: getDisplayFiatPrice(amount, currentToken) })] })) })] }), jsx(Typography, { className: 'send-balance-form__amount_available', variant: 'body_small', weight: 'regular', color: 'secondary', as: 'div', children: jsxs("div", { style: { display: 'flex', gap: '0.225rem' }, children: [jsx(Typography, { className: 'send-balance-form__amount_available__line', variant: 'body_small', weight: 'bold', color: 'primary', as: 'div', children: (_a = currentToken === null || currentToken === void 0 ? void 0 : currentToken.balance) !== null && _a !== void 0 ? _a : 0 }), t('dyn_send_transaction.data.symbol_available', {
|
|
189
|
+
symbol: currentToken === null || currentToken === void 0 ? void 0 : currentToken.symbol,
|
|
190
|
+
})] }) }), jsx(Typography, { variant: 'body_small', weight: 'regular', color: 'secondary', copykey: 'dyn_send_transaction.data.recipient.label', children: "Recipient Address" }), jsx(Field, { className: 'send-balance-form__field', placeholder: t('dyn_send_transaction.data.recipient.placeholder'), label: t('dyn_send_transaction.data.recipient.label'), id: 'recipient', name: 'recipient', as: Input, error: errors['recipient'], copykey: 'dyn_send_transaction.data.recipient.label', message: touched['recipient'] &&
|
|
189
191
|
getDisplayErrorMessage(errors, t, 'recipient') }), jsx(TypographyButton, { dataTestId: 'sendBalanceFormSubmitButton', expanded: true, type: 'submit', buttonVariant: 'primary', buttonPadding: 'small', buttonClassName: 'send-balance-form__button', copykey: 'dyn_send_transaction.preview_transaction', children: t('dyn_send_transaction.preview_transaction') })] }));
|
|
190
192
|
} }));
|
|
191
193
|
};
|
|
@@ -172,6 +172,7 @@ const useDynamicWaas = () => {
|
|
|
172
172
|
const getMfaToken = useGetMfaToken.useGetMfaToken();
|
|
173
173
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled.isCookieEnabled();
|
|
174
174
|
const isUpgrading = React.useRef(false);
|
|
175
|
+
const [recoveredWallets, setRecoveredWallets] = React.useState(() => new Set());
|
|
175
176
|
const getWaasWalletConnector = React.useCallback((chainName) => {
|
|
176
177
|
var _a;
|
|
177
178
|
if (!isCookieAuthEnabled && !authToken) {
|
|
@@ -292,6 +293,13 @@ const useDynamicWaas = () => {
|
|
|
292
293
|
time: totalElapsedTime,
|
|
293
294
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
294
295
|
});
|
|
296
|
+
// Track successfully recovered wallet
|
|
297
|
+
setRecoveredWallets((prev) => {
|
|
298
|
+
var _a;
|
|
299
|
+
const next = new Set(prev);
|
|
300
|
+
next.add((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
301
|
+
return next;
|
|
302
|
+
});
|
|
295
303
|
}
|
|
296
304
|
catch (error) {
|
|
297
305
|
walletConnectorCore.logger.warn('[useDynamicWaas] Error restoring wallet keyshare', {
|
|
@@ -627,20 +635,37 @@ const useDynamicWaas = () => {
|
|
|
627
635
|
}
|
|
628
636
|
yield refresh();
|
|
629
637
|
}), [user, getWaasWalletConnector, refresh]);
|
|
630
|
-
|
|
638
|
+
// Get wallets that need settings processing
|
|
639
|
+
const walletsNeedingSettings = React.useMemo(() => {
|
|
631
640
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials) || !dynamicWaasIsEnabled) {
|
|
632
|
-
return
|
|
641
|
+
return [];
|
|
633
642
|
}
|
|
634
|
-
return user.verifiedCredentials.
|
|
643
|
+
return user.verifiedCredentials.filter((vc) => {
|
|
635
644
|
var _a;
|
|
636
645
|
return vc.walletName === 'dynamicwaas' &&
|
|
646
|
+
vc.address &&
|
|
637
647
|
((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) &&
|
|
638
648
|
(vc.walletProperties.settings.shouldRefreshOnNextSignOn ||
|
|
639
649
|
vc.walletProperties.settings.reshareOnNextSignOn ||
|
|
640
650
|
vc.walletProperties.settings.revokeOnNextSignOn);
|
|
641
651
|
});
|
|
642
652
|
}, [user, dynamicWaasIsEnabled]);
|
|
653
|
+
// Derived from walletsNeedingSettings for backward compatibility
|
|
654
|
+
const needsSettingsProcessing = walletsNeedingSettings.length > 0;
|
|
655
|
+
// Check if all wallets needing settings have been recovered
|
|
656
|
+
const areWalletsReadyForSettings = React.useCallback(() => {
|
|
657
|
+
if (walletsNeedingSettings.length === 0) {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
return walletsNeedingSettings.every((wallet) => { var _a; return recoveredWallets.has((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
661
|
+
}, [walletsNeedingSettings, recoveredWallets]);
|
|
662
|
+
// Clear recovered wallets tracking (call on logout)
|
|
663
|
+
const clearRecoveredWallets = React.useCallback(() => {
|
|
664
|
+
setRecoveredWallets(new Set());
|
|
665
|
+
}, []);
|
|
643
666
|
return {
|
|
667
|
+
areWalletsReadyForSettings,
|
|
668
|
+
clearRecoveredWallets,
|
|
644
669
|
createWalletAccount,
|
|
645
670
|
dynamicWaasIsEnabled,
|
|
646
671
|
getWaasWalletConnector,
|
|
@@ -26,6 +26,8 @@ export declare const configWaasWalletConnector: ({ walletConnector, environmentI
|
|
|
26
26
|
svmGasSponsorshipEnabled?: boolean;
|
|
27
27
|
}) => IDynamicWaasConnector;
|
|
28
28
|
export declare const useDynamicWaas: () => {
|
|
29
|
+
areWalletsReadyForSettings: () => boolean;
|
|
30
|
+
clearRecoveredWallets: () => void;
|
|
29
31
|
createWalletAccount: (requirementsOrChainNames: WalletCreationRequirement[] | ChainEnum[], password?: string, bitcoinConfig?: {
|
|
30
32
|
addressType?: string;
|
|
31
33
|
network?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useRef, useCallback, useMemo } from 'react';
|
|
3
|
+
import { useRef, useState, useCallback, useMemo } from 'react';
|
|
4
4
|
import { EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum, WalletProviderEnum, ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
6
|
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -168,6 +168,7 @@ const useDynamicWaas = () => {
|
|
|
168
168
|
const getMfaToken = useGetMfaToken();
|
|
169
169
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled();
|
|
170
170
|
const isUpgrading = useRef(false);
|
|
171
|
+
const [recoveredWallets, setRecoveredWallets] = useState(() => new Set());
|
|
171
172
|
const getWaasWalletConnector = useCallback((chainName) => {
|
|
172
173
|
var _a;
|
|
173
174
|
if (!isCookieAuthEnabled && !authToken) {
|
|
@@ -288,6 +289,13 @@ const useDynamicWaas = () => {
|
|
|
288
289
|
time: totalElapsedTime,
|
|
289
290
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
290
291
|
});
|
|
292
|
+
// Track successfully recovered wallet
|
|
293
|
+
setRecoveredWallets((prev) => {
|
|
294
|
+
var _a;
|
|
295
|
+
const next = new Set(prev);
|
|
296
|
+
next.add((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
297
|
+
return next;
|
|
298
|
+
});
|
|
291
299
|
}
|
|
292
300
|
catch (error) {
|
|
293
301
|
logger.warn('[useDynamicWaas] Error restoring wallet keyshare', {
|
|
@@ -623,20 +631,37 @@ const useDynamicWaas = () => {
|
|
|
623
631
|
}
|
|
624
632
|
yield refresh();
|
|
625
633
|
}), [user, getWaasWalletConnector, refresh]);
|
|
626
|
-
|
|
634
|
+
// Get wallets that need settings processing
|
|
635
|
+
const walletsNeedingSettings = useMemo(() => {
|
|
627
636
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials) || !dynamicWaasIsEnabled) {
|
|
628
|
-
return
|
|
637
|
+
return [];
|
|
629
638
|
}
|
|
630
|
-
return user.verifiedCredentials.
|
|
639
|
+
return user.verifiedCredentials.filter((vc) => {
|
|
631
640
|
var _a;
|
|
632
641
|
return vc.walletName === 'dynamicwaas' &&
|
|
642
|
+
vc.address &&
|
|
633
643
|
((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) &&
|
|
634
644
|
(vc.walletProperties.settings.shouldRefreshOnNextSignOn ||
|
|
635
645
|
vc.walletProperties.settings.reshareOnNextSignOn ||
|
|
636
646
|
vc.walletProperties.settings.revokeOnNextSignOn);
|
|
637
647
|
});
|
|
638
648
|
}, [user, dynamicWaasIsEnabled]);
|
|
649
|
+
// Derived from walletsNeedingSettings for backward compatibility
|
|
650
|
+
const needsSettingsProcessing = walletsNeedingSettings.length > 0;
|
|
651
|
+
// Check if all wallets needing settings have been recovered
|
|
652
|
+
const areWalletsReadyForSettings = useCallback(() => {
|
|
653
|
+
if (walletsNeedingSettings.length === 0) {
|
|
654
|
+
return false;
|
|
655
|
+
}
|
|
656
|
+
return walletsNeedingSettings.every((wallet) => { var _a; return recoveredWallets.has((_a = wallet.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
657
|
+
}, [walletsNeedingSettings, recoveredWallets]);
|
|
658
|
+
// Clear recovered wallets tracking (call on logout)
|
|
659
|
+
const clearRecoveredWallets = useCallback(() => {
|
|
660
|
+
setRecoveredWallets(new Set());
|
|
661
|
+
}, []);
|
|
639
662
|
return {
|
|
663
|
+
areWalletsReadyForSettings,
|
|
664
|
+
clearRecoveredWallets,
|
|
640
665
|
createWalletAccount,
|
|
641
666
|
dynamicWaasIsEnabled,
|
|
642
667
|
getWaasWalletConnector,
|
|
@@ -220,7 +220,7 @@ const useWalletSettingsProcessor = () => {
|
|
|
220
220
|
* The hook ensures wallet creation only happens once per session until logout.
|
|
221
221
|
*/
|
|
222
222
|
const useSyncDynamicWaas = () => {
|
|
223
|
-
const {
|
|
223
|
+
const { areWalletsReadyForSettings, clearRecoveredWallets, needsAutoCreateWalletChains, initializeWaas, shouldInitializeWaas, } = useDynamicWaas.useDynamicWaas();
|
|
224
224
|
const validateWalletCreation = useWalletCreationValidation();
|
|
225
225
|
const { mutate: createWallets, isLoading: isCreatingWallets } = useWalletCreation();
|
|
226
226
|
const { mutate: processSettings, isLoading: isProcessingSettings } = useWalletSettingsProcessor();
|
|
@@ -234,6 +234,7 @@ const useSyncDynamicWaas = () => {
|
|
|
234
234
|
useDynamicEvents.useInternalDynamicEvents('logout', () => {
|
|
235
235
|
triggeredCreate.current = false;
|
|
236
236
|
triggeredSettingsProcessing.current = false;
|
|
237
|
+
clearRecoveredWallets();
|
|
237
238
|
});
|
|
238
239
|
const shouldCreateWallets = React.useCallback(() => {
|
|
239
240
|
if (triggeredCreate.current || isCreatingWallets) {
|
|
@@ -249,12 +250,17 @@ const useSyncDynamicWaas = () => {
|
|
|
249
250
|
if (triggeredSettingsProcessing.current || isProcessingSettings) {
|
|
250
251
|
return false;
|
|
251
252
|
}
|
|
252
|
-
|
|
253
|
+
// Settings processing requires wallets to be recovered first
|
|
254
|
+
if (!areWalletsReadyForSettings()) {
|
|
253
255
|
return false;
|
|
254
256
|
}
|
|
255
257
|
const validation = validateWalletCreation();
|
|
256
258
|
return validation.isValid;
|
|
257
|
-
}, [
|
|
259
|
+
}, [
|
|
260
|
+
areWalletsReadyForSettings,
|
|
261
|
+
validateWalletCreation,
|
|
262
|
+
isProcessingSettings,
|
|
263
|
+
]);
|
|
258
264
|
const handleSettingsProcessing = React.useCallback(() => {
|
|
259
265
|
if (!shouldProcessSettings()) {
|
|
260
266
|
return;
|
|
@@ -288,6 +294,7 @@ const useSyncDynamicWaas = () => {
|
|
|
288
294
|
sessionIdRef.current = undefined;
|
|
289
295
|
hasWaasInitializedRef.current = false;
|
|
290
296
|
initializingWaasRef.current = false;
|
|
297
|
+
clearRecoveredWallets();
|
|
291
298
|
}
|
|
292
299
|
if (shouldInitializeWaas && (user === null || user === void 0 ? void 0 : user.sessionId)) {
|
|
293
300
|
const { sessionId, id: userId } = user;
|
|
@@ -216,7 +216,7 @@ const useWalletSettingsProcessor = () => {
|
|
|
216
216
|
* The hook ensures wallet creation only happens once per session until logout.
|
|
217
217
|
*/
|
|
218
218
|
const useSyncDynamicWaas = () => {
|
|
219
|
-
const {
|
|
219
|
+
const { areWalletsReadyForSettings, clearRecoveredWallets, needsAutoCreateWalletChains, initializeWaas, shouldInitializeWaas, } = useDynamicWaas();
|
|
220
220
|
const validateWalletCreation = useWalletCreationValidation();
|
|
221
221
|
const { mutate: createWallets, isLoading: isCreatingWallets } = useWalletCreation();
|
|
222
222
|
const { mutate: processSettings, isLoading: isProcessingSettings } = useWalletSettingsProcessor();
|
|
@@ -230,6 +230,7 @@ const useSyncDynamicWaas = () => {
|
|
|
230
230
|
useInternalDynamicEvents('logout', () => {
|
|
231
231
|
triggeredCreate.current = false;
|
|
232
232
|
triggeredSettingsProcessing.current = false;
|
|
233
|
+
clearRecoveredWallets();
|
|
233
234
|
});
|
|
234
235
|
const shouldCreateWallets = useCallback(() => {
|
|
235
236
|
if (triggeredCreate.current || isCreatingWallets) {
|
|
@@ -245,12 +246,17 @@ const useSyncDynamicWaas = () => {
|
|
|
245
246
|
if (triggeredSettingsProcessing.current || isProcessingSettings) {
|
|
246
247
|
return false;
|
|
247
248
|
}
|
|
248
|
-
|
|
249
|
+
// Settings processing requires wallets to be recovered first
|
|
250
|
+
if (!areWalletsReadyForSettings()) {
|
|
249
251
|
return false;
|
|
250
252
|
}
|
|
251
253
|
const validation = validateWalletCreation();
|
|
252
254
|
return validation.isValid;
|
|
253
|
-
}, [
|
|
255
|
+
}, [
|
|
256
|
+
areWalletsReadyForSettings,
|
|
257
|
+
validateWalletCreation,
|
|
258
|
+
isProcessingSettings,
|
|
259
|
+
]);
|
|
254
260
|
const handleSettingsProcessing = useCallback(() => {
|
|
255
261
|
if (!shouldProcessSettings()) {
|
|
256
262
|
return;
|
|
@@ -284,6 +290,7 @@ const useSyncDynamicWaas = () => {
|
|
|
284
290
|
sessionIdRef.current = undefined;
|
|
285
291
|
hasWaasInitializedRef.current = false;
|
|
286
292
|
initializingWaasRef.current = false;
|
|
293
|
+
clearRecoveredWallets();
|
|
287
294
|
}
|
|
288
295
|
if (shouldInitializeWaas && (user === null || user === void 0 ? void 0 : user.sessionId)) {
|
|
289
296
|
const { sessionId, id: userId } = user;
|
|
@@ -227,7 +227,8 @@ const useWalletDelegation = () => {
|
|
|
227
227
|
return Object.assign(Object.assign({}, wallet), { isDismissedThisSession,
|
|
228
228
|
status });
|
|
229
229
|
})
|
|
230
|
-
.filter((wallet) => wallet !== null)
|
|
230
|
+
.filter((wallet) => wallet !== null)
|
|
231
|
+
.filter((wallet) => wallet.chain === sdkApiCore.ChainEnum.Evm || wallet.chain === sdkApiCore.ChainEnum.Sol);
|
|
231
232
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials, userWallets]);
|
|
232
233
|
const delegateKeyShares = React.useCallback((wallets) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
233
234
|
if (!delegatedAccessEnabled) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { StorageService } from '@dynamic-labs/utils';
|
|
5
|
-
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import { JwtVerifiedCredentialFormatEnum, ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
8
8
|
import '@dynamic-labs/iconic';
|
|
@@ -223,7 +223,8 @@ const useWalletDelegation = () => {
|
|
|
223
223
|
return Object.assign(Object.assign({}, wallet), { isDismissedThisSession,
|
|
224
224
|
status });
|
|
225
225
|
})
|
|
226
|
-
.filter((wallet) => wallet !== null)
|
|
226
|
+
.filter((wallet) => wallet !== null)
|
|
227
|
+
.filter((wallet) => wallet.chain === ChainEnum.Evm || wallet.chain === ChainEnum.Sol);
|
|
227
228
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials, userWallets]);
|
|
228
229
|
const delegateKeyShares = useCallback((wallets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
229
230
|
if (!delegatedAccessEnabled) {
|