@dynamic-labs/sdk-react-core 4.91.0 → 4.91.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 +43 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +34 -6
- package/src/lib/components/SendBalanceForm/SendBalanceForm.d.ts +2 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +35 -7
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +2 -2
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +2 -2
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.cjs +8 -7
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.d.ts +3 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.js +8 -7
- package/src/lib/modals/SignMessageConfirmationModal/getProperErrorMessage.cjs +3 -0
- package/src/lib/modals/SignMessageConfirmationModal/getProperErrorMessage.js +3 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +21 -3
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +7 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +21 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +5 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.d.ts +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +5 -3
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.cjs +1 -1
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.js +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +18 -11
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.d.ts +1 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +18 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/ActiveMidnightWalletBalance.cjs +38 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/ActiveMidnightWalletBalance.js +38 -11
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +5 -2
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.cjs +18 -2
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.js +18 -2
- package/src/lib/widgets/DynamicWidget/views/ExportAndRecoveryView/ExportAndRecoveryView.cjs +3 -1
- package/src/lib/widgets/DynamicWidget/views/ExportAndRecoveryView/ExportAndRecoveryView.js +3 -1
|
@@ -173,9 +173,10 @@ const EmbeddedWalletExportSection = () => {
|
|
|
173
173
|
}, [setShowAuthFlow, pushView]);
|
|
174
174
|
const handleExportClick = useCallback((recoveryPhrase) => __awaiter(void 0, void 0, void 0, function* () {
|
|
175
175
|
var _l;
|
|
176
|
+
const targetWalletId = wallet === null || wallet === void 0 ? void 0 : wallet.id;
|
|
176
177
|
logger.info('Starting embedded wallet export process', {
|
|
177
178
|
userId: user === null || user === void 0 ? void 0 : user.userId,
|
|
178
|
-
walletId:
|
|
179
|
+
walletId: targetWalletId,
|
|
179
180
|
walletName: (_l = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _l === void 0 ? void 0 : _l.name,
|
|
180
181
|
});
|
|
181
182
|
const stepUpRequired = yield isStepUpRequired({
|
|
@@ -211,8 +212,10 @@ const EmbeddedWalletExportSection = () => {
|
|
|
211
212
|
});
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
return initExportProcess(recoveryPhrase);
|
|
215
|
+
return initExportProcess(recoveryPhrase, false, targetWalletId);
|
|
215
216
|
}), [
|
|
217
|
+
wallet,
|
|
218
|
+
user,
|
|
216
219
|
isStepUpRequired,
|
|
217
220
|
promptStepUpAuth,
|
|
218
221
|
isMfaRequiredForAction,
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
7
8
|
var reactI18next = require('react-i18next');
|
|
9
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
10
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
11
|
var CopyButton = require('../../../../components/CopyButton/CopyButton.cjs');
|
|
9
12
|
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
10
13
|
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
@@ -12,13 +15,14 @@ var QRCode = require('../../../../components/QRCode/QRCode.cjs');
|
|
|
12
15
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
13
16
|
require('../../../../context/DynamicContext/useDynamicContext/useDynamicContext.cjs');
|
|
14
17
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
15
|
-
require('react');
|
|
16
18
|
var arrowLeft = require('../../../../shared/assets/arrow-left.cjs');
|
|
17
19
|
var copy = require('../../../../shared/assets/copy.cjs');
|
|
18
20
|
var embeddedWalletIcon = require('../../../../shared/assets/embedded-wallet-icon.cjs');
|
|
19
21
|
require('@dynamic-labs/iconic');
|
|
20
22
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
21
23
|
var shortenWalletAddress = require('../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
24
|
+
var classNames = require('../../../../utils/functions/classNames/classNames.cjs');
|
|
25
|
+
var getWalletAdditionalAddressByType = require('../../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.cjs');
|
|
22
26
|
var usePromise = require('../../../../utils/hooks/usePromise/usePromise.cjs');
|
|
23
27
|
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
24
28
|
var useFetchChain = require('../../hooks/useFetchChain/useFetchChain.cjs');
|
|
@@ -30,13 +34,25 @@ const DepositView = () => {
|
|
|
30
34
|
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
31
35
|
const { chain } = useFetchChain.useFetchChain(walletConnector);
|
|
32
36
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
37
|
+
const [midnightAddressType, setMidnightAddressType] = React.useState('unshielded');
|
|
33
38
|
const { data: ens } = usePromise.usePromise(() => getNameService(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address), { deps: [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address], initialData: undefined });
|
|
34
39
|
const ensName = (_a = ens === null || ens === void 0 ? void 0 : ens.name) !== null && _a !== void 0 ? _a : null;
|
|
35
40
|
if (!primaryWallet) {
|
|
36
41
|
return null;
|
|
37
42
|
}
|
|
43
|
+
const shieldedAddress = walletConnectorCore.isMidnightWallet(primaryWallet)
|
|
44
|
+
? getWalletAdditionalAddressByType.getWalletAdditionalAddressByType(sdkApiCore.WalletAddressType.MidnightShielded, primaryWallet)
|
|
45
|
+
: undefined;
|
|
46
|
+
const showMidnightToggle = Boolean(shieldedAddress);
|
|
47
|
+
const depositAddress = showMidnightToggle && midnightAddressType === 'shielded' && shieldedAddress
|
|
48
|
+
? shieldedAddress
|
|
49
|
+
: primaryWallet.address;
|
|
38
50
|
const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', id: 'back-button', "data-testid": 'back-button', onClick: () => setDynamicWidgetView('choose-wallet-funding-method'), children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }));
|
|
39
|
-
return (jsxRuntime.jsxs("div", { className: 'deposit-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxRuntime.jsxs("div", { className: 'deposit-view__content', children: [
|
|
51
|
+
return (jsxRuntime.jsxs("div", { className: 'deposit-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxRuntime.jsxs("div", { className: 'deposit-view__content', children: [showMidnightToggle && (jsxRuntime.jsxs("div", { className: 'deposit-view__content__toggle', children: [jsxRuntime.jsx("button", { type: 'button', "data-testid": 'deposit-toggle-unshielded', className: classNames.classNames('deposit-view__content__toggle__option', {
|
|
52
|
+
'deposit-view__content__toggle__option--active': midnightAddressType === 'unshielded',
|
|
53
|
+
}), "data-copykey": 'dyn_active_wallet_info.midnight_unshielded_address', onClick: () => setMidnightAddressType('unshielded'), children: t('dyn_active_wallet_info.midnight_unshielded_address') }), jsxRuntime.jsx("button", { type: 'button', "data-testid": 'deposit-toggle-shielded', className: classNames.classNames('deposit-view__content__toggle__option', {
|
|
54
|
+
'deposit-view__content__toggle__option--active': midnightAddressType === 'shielded',
|
|
55
|
+
}), "data-copykey": 'dyn_active_wallet_info.midnight_shielded_address', onClick: () => setMidnightAddressType('shielded'), children: t('dyn_active_wallet_info.midnight_shielded_address') })] })), jsxRuntime.jsx(QRCode.QRCode, { className: 'deposit-view__content__qr-code', value: depositAddress, Icon: jsxRuntime.jsx(embeddedWalletIcon.ReactComponent, {}), logoSize: 40, logoMargin: 64, size: 215 }), jsxRuntime.jsxs("div", { className: 'deposit-view__content__address', children: [ensName && (jsxRuntime.jsx(Typography.Typography, { className: 'deposit-view__content__address__ens', variant: 'title', children: ensName })), jsxRuntime.jsxs("div", { className: 'deposit-view__content__address__wrapper', children: [jsxRuntime.jsx(Typography.Typography, { "data-testid": 'deposit-view-address', variant: 'title', weight: 'medium', className: 'deposit-view__content__address__wrapper__text', children: shortenWalletAddress.shortenWalletAddress(depositAddress) }), jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'text', textToCopy: depositAddress, className: 'deposit-view__content__address__wrapper__copy', children: jsxRuntime.jsx(copy.ReactComponent, { "data-testid": 'copy-address' }) })] })] }), jsxRuntime.jsxs(Typography.Typography, { className: 'deposit-view__content__network', variant: 'body_small', color: 'secondary', copykey: 'dyn_deposit.receive_funds_on', children: [t('dyn_deposit.receive_funds_on'), chain === null || chain === void 0 ? void 0 : chain.name] })] })] }));
|
|
40
56
|
};
|
|
41
57
|
|
|
42
58
|
exports.DepositView = DepositView;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import { isMidnightWallet } from '@dynamic-labs/wallet-connector-core';
|
|
4
7
|
import { CopyButton } from '../../../../components/CopyButton/CopyButton.js';
|
|
5
8
|
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
6
9
|
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
@@ -8,13 +11,14 @@ import { QRCode } from '../../../../components/QRCode/QRCode.js';
|
|
|
8
11
|
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
9
12
|
import '../../../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
|
|
10
13
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
11
|
-
import 'react';
|
|
12
14
|
import { ReactComponent as SvgArrowLeft } from '../../../../shared/assets/arrow-left.js';
|
|
13
15
|
import { ReactComponent as SvgCopy } from '../../../../shared/assets/copy.js';
|
|
14
16
|
import { ReactComponent as SvgEmbeddedWalletIcon } from '../../../../shared/assets/embedded-wallet-icon.js';
|
|
15
17
|
import '@dynamic-labs/iconic';
|
|
16
18
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
17
19
|
import { shortenWalletAddress } from '../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
20
|
+
import { classNames } from '../../../../utils/functions/classNames/classNames.js';
|
|
21
|
+
import { getWalletAdditionalAddressByType } from '../../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.js';
|
|
18
22
|
import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
|
|
19
23
|
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
20
24
|
import { useFetchChain } from '../../hooks/useFetchChain/useFetchChain.js';
|
|
@@ -26,13 +30,25 @@ const DepositView = () => {
|
|
|
26
30
|
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
27
31
|
const { chain } = useFetchChain(walletConnector);
|
|
28
32
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
33
|
+
const [midnightAddressType, setMidnightAddressType] = useState('unshielded');
|
|
29
34
|
const { data: ens } = usePromise(() => getNameService(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address), { deps: [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address], initialData: undefined });
|
|
30
35
|
const ensName = (_a = ens === null || ens === void 0 ? void 0 : ens.name) !== null && _a !== void 0 ? _a : null;
|
|
31
36
|
if (!primaryWallet) {
|
|
32
37
|
return null;
|
|
33
38
|
}
|
|
39
|
+
const shieldedAddress = isMidnightWallet(primaryWallet)
|
|
40
|
+
? getWalletAdditionalAddressByType(WalletAddressType.MidnightShielded, primaryWallet)
|
|
41
|
+
: undefined;
|
|
42
|
+
const showMidnightToggle = Boolean(shieldedAddress);
|
|
43
|
+
const depositAddress = showMidnightToggle && midnightAddressType === 'shielded' && shieldedAddress
|
|
44
|
+
? shieldedAddress
|
|
45
|
+
: primaryWallet.address;
|
|
34
46
|
const backButton = (jsx(IconButton, { type: 'button', id: 'back-button', "data-testid": 'back-button', onClick: () => setDynamicWidgetView('choose-wallet-funding-method'), children: jsx(SvgArrowLeft, {}) }));
|
|
35
|
-
return (jsxs("div", { className: 'deposit-view', children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxs("div", { className: 'deposit-view__content', children: [
|
|
47
|
+
return (jsxs("div", { className: 'deposit-view', children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxs("div", { className: 'deposit-view__content', children: [showMidnightToggle && (jsxs("div", { className: 'deposit-view__content__toggle', children: [jsx("button", { type: 'button', "data-testid": 'deposit-toggle-unshielded', className: classNames('deposit-view__content__toggle__option', {
|
|
48
|
+
'deposit-view__content__toggle__option--active': midnightAddressType === 'unshielded',
|
|
49
|
+
}), "data-copykey": 'dyn_active_wallet_info.midnight_unshielded_address', onClick: () => setMidnightAddressType('unshielded'), children: t('dyn_active_wallet_info.midnight_unshielded_address') }), jsx("button", { type: 'button', "data-testid": 'deposit-toggle-shielded', className: classNames('deposit-view__content__toggle__option', {
|
|
50
|
+
'deposit-view__content__toggle__option--active': midnightAddressType === 'shielded',
|
|
51
|
+
}), "data-copykey": 'dyn_active_wallet_info.midnight_shielded_address', onClick: () => setMidnightAddressType('shielded'), children: t('dyn_active_wallet_info.midnight_shielded_address') })] })), jsx(QRCode, { className: 'deposit-view__content__qr-code', value: depositAddress, Icon: jsx(SvgEmbeddedWalletIcon, {}), logoSize: 40, logoMargin: 64, size: 215 }), jsxs("div", { className: 'deposit-view__content__address', children: [ensName && (jsx(Typography, { className: 'deposit-view__content__address__ens', variant: 'title', children: ensName })), jsxs("div", { className: 'deposit-view__content__address__wrapper', children: [jsx(Typography, { "data-testid": 'deposit-view-address', variant: 'title', weight: 'medium', className: 'deposit-view__content__address__wrapper__text', children: shortenWalletAddress(depositAddress) }), jsx(CopyButton, { variant: 'text', textToCopy: depositAddress, className: 'deposit-view__content__address__wrapper__copy', children: jsx(SvgCopy, { "data-testid": 'copy-address' }) })] })] }), jsxs(Typography, { className: 'deposit-view__content__network', variant: 'body_small', color: 'secondary', copykey: 'dyn_deposit.receive_funds_on', children: [t('dyn_deposit.receive_funds_on'), chain === null || chain === void 0 ? void 0 : chain.name] })] })] }));
|
|
36
52
|
};
|
|
37
53
|
|
|
38
54
|
export { DepositView };
|
|
@@ -42,6 +42,7 @@ const ExportAndRecoveryView = () => {
|
|
|
42
42
|
const isV3WaasWallet = Boolean(wallet && ((_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.startsWith('dynamicwaas')));
|
|
43
43
|
const handleBackClick = React.useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
44
44
|
const handlePrivateKeyClick = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
const targetWalletId = wallet === null || wallet === void 0 ? void 0 : wallet.id;
|
|
45
46
|
if (!isSessionKeyCompatible) {
|
|
46
47
|
if (yield shouldInitRecovery()) {
|
|
47
48
|
yield initPasskeyRecoveryProcess(undefined, {
|
|
@@ -49,8 +50,9 @@ const ExportAndRecoveryView = () => {
|
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
return initExportProcess();
|
|
53
|
+
return initExportProcess(false, false, targetWalletId);
|
|
53
54
|
}), [
|
|
55
|
+
wallet === null || wallet === void 0 ? void 0 : wallet.id,
|
|
54
56
|
isSessionKeyCompatible,
|
|
55
57
|
shouldInitRecovery,
|
|
56
58
|
initPasskeyRecoveryProcess,
|
|
@@ -38,6 +38,7 @@ const ExportAndRecoveryView = () => {
|
|
|
38
38
|
const isV3WaasWallet = Boolean(wallet && ((_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.startsWith('dynamicwaas')));
|
|
39
39
|
const handleBackClick = useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
40
40
|
const handlePrivateKeyClick = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
const targetWalletId = wallet === null || wallet === void 0 ? void 0 : wallet.id;
|
|
41
42
|
if (!isSessionKeyCompatible) {
|
|
42
43
|
if (yield shouldInitRecovery()) {
|
|
43
44
|
yield initPasskeyRecoveryProcess(undefined, {
|
|
@@ -45,8 +46,9 @@ const ExportAndRecoveryView = () => {
|
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
return initExportProcess();
|
|
49
|
+
return initExportProcess(false, false, targetWalletId);
|
|
49
50
|
}), [
|
|
51
|
+
wallet === null || wallet === void 0 ? void 0 : wallet.id,
|
|
50
52
|
isSessionKeyCompatible,
|
|
51
53
|
shouldInitRecovery,
|
|
52
54
|
initPasskeyRecoveryProcess,
|