@dynamic-labs/sdk-react-core 4.4.3 → 4.4.4
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 +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/lib/components/HardwareWalletToggle/HardwareWalletToggle.cjs +12 -11
- package/src/lib/components/HardwareWalletToggle/HardwareWalletToggle.js +12 -11
- package/src/lib/components/Toggle/Toggle.cjs +1 -5
- package/src/lib/components/Toggle/Toggle.d.ts +6 -2
- package/src/lib/components/Toggle/Toggle.js +1 -5
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -2
- package/src/lib/context/ViewContext/types/index.d.ts +1 -2
- package/src/lib/data/api/exchangeRates/exchangeRates.cjs +9 -5
- package/src/lib/data/api/exchangeRates/exchangeRates.js +9 -5
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +2 -6
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +2 -6
- package/src/lib/store/internalImplementation/store.cjs +1 -0
- package/src/lib/store/internalImplementation/store.d.ts +5 -1
- package/src/lib/store/internalImplementation/store.js +1 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +5 -0
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +5 -0
- package/src/lib/utils/hooks/useFunding/useConnectWalletForFunding/useConnectWalletForFunding.cjs +25 -7
- package/src/lib/utils/hooks/useFunding/useConnectWalletForFunding/useConnectWalletForFunding.js +22 -4
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.cjs +12 -12
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.js +12 -12
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/handleStoreVersionChanged.cjs +12 -0
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/handleStoreVersionChanged.d.ts +7 -0
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/handleStoreVersionChanged.js +8 -0
- package/src/lib/utils/hooks/useValidateSession/handleStoreVersionChanged/index.d.ts +1 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +5 -3
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.d.ts +3 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +5 -3
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +1 -1
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +1 -1
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +12 -20
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.d.ts +6 -5
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +12 -20
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +1 -6
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +1 -6
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +5 -7
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +5 -7
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.cjs +9 -1
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.js +10 -2
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.cjs +0 -17
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.js +0 -17
|
@@ -16,7 +16,15 @@ require('../../../../context/ViewContext/ViewContext.cjs');
|
|
|
16
16
|
const DotsMenu = ({ options, buttonClassName, buttonClassNameWithOpenMenu, direction = 'right', iconOverride, }) => {
|
|
17
17
|
const dotsMenuRef = React.useRef(null);
|
|
18
18
|
const [showMenu, setShowMenu] = React.useState(false);
|
|
19
|
-
|
|
19
|
+
const handleIconClick = React.useCallback(() => {
|
|
20
|
+
// Use setTimeout here to prevent React 17 from triggering a click event
|
|
21
|
+
// when the dropdown is rendered.
|
|
22
|
+
setTimeout(() => setShowMenu(true), 0);
|
|
23
|
+
}, [setShowMenu]);
|
|
24
|
+
const handleMenuClose = React.useCallback(() => {
|
|
25
|
+
setShowMenu(false);
|
|
26
|
+
}, [setShowMenu]);
|
|
27
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(IconButton.IconButton, { ref: dotsMenuRef, onClick: handleIconClick, "data-testid": 'dotsMenu', className: showMenu ? buttonClassNameWithOpenMenu : buttonClassName, children: iconOverride ? (iconOverride) : (jsxRuntime.jsx(Icon.Icon, { children: jsxRuntime.jsx(threeDots.ReactComponent, {}) })) }), jsxRuntime.jsx(Dropdown.Dropdown, { isOpen: showMenu, onClickOutside: handleMenuClose, onScroll: handleMenuClose, anchorRef: dotsMenuRef, anchorOrigin: direction === 'right' ? 'bottom-left' : 'top-right', transformOrigin: direction === 'right' ? 'top-left' : 'bottom-right', children: jsxRuntime.jsx(DotsMenuDropdown.DotsMenuDropdown, { options: options, setShowMenu: setShowMenu }) })] }));
|
|
20
28
|
};
|
|
21
29
|
|
|
22
30
|
exports.DotsMenu = DotsMenu;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useRef, useState } from 'react';
|
|
3
|
+
import { useRef, useState, useCallback } from 'react';
|
|
4
4
|
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
5
5
|
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
6
6
|
import { Dropdown } from '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
@@ -12,7 +12,15 @@ import '../../../../context/ViewContext/ViewContext.js';
|
|
|
12
12
|
const DotsMenu = ({ options, buttonClassName, buttonClassNameWithOpenMenu, direction = 'right', iconOverride, }) => {
|
|
13
13
|
const dotsMenuRef = useRef(null);
|
|
14
14
|
const [showMenu, setShowMenu] = useState(false);
|
|
15
|
-
|
|
15
|
+
const handleIconClick = useCallback(() => {
|
|
16
|
+
// Use setTimeout here to prevent React 17 from triggering a click event
|
|
17
|
+
// when the dropdown is rendered.
|
|
18
|
+
setTimeout(() => setShowMenu(true), 0);
|
|
19
|
+
}, [setShowMenu]);
|
|
20
|
+
const handleMenuClose = useCallback(() => {
|
|
21
|
+
setShowMenu(false);
|
|
22
|
+
}, [setShowMenu]);
|
|
23
|
+
return (jsxs(Fragment, { children: [jsx(IconButton, { ref: dotsMenuRef, onClick: handleIconClick, "data-testid": 'dotsMenu', className: showMenu ? buttonClassNameWithOpenMenu : buttonClassName, children: iconOverride ? (iconOverride) : (jsx(Icon, { children: jsx(SvgThreeDots, {}) })) }), jsx(Dropdown, { isOpen: showMenu, onClickOutside: handleMenuClose, onScroll: handleMenuClose, anchorRef: dotsMenuRef, anchorOrigin: direction === 'right' ? 'bottom-left' : 'top-right', transformOrigin: direction === 'right' ? 'top-left' : 'bottom-right', children: jsx(DotsMenuDropdown, { options: options, setShowMenu: setShowMenu }) })] }));
|
|
16
24
|
};
|
|
17
25
|
|
|
18
26
|
export { DotsMenu };
|
|
@@ -5,33 +5,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var UserWalletsContext = require('../../../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
9
8
|
var projectSettings = require('../../../../../../store/state/projectSettings/projectSettings.cjs');
|
|
10
|
-
var walletOptions = require('../../../../../../store/state/walletOptions/walletOptions.cjs');
|
|
11
9
|
var useFunding = require('../../../../../../utils/hooks/useFunding/useFunding.cjs');
|
|
12
10
|
var DynamicWidgetContext = require('../../../../context/DynamicWidgetContext.cjs');
|
|
13
11
|
|
|
14
12
|
const useStartExternalWalletFunding = () => {
|
|
15
13
|
var _a, _b;
|
|
16
|
-
const userWallets = UserWalletsContext.useUserWallets();
|
|
17
14
|
const settings = projectSettings.useProjectSettings();
|
|
18
15
|
const { connectWalletForFunding } = useFunding.useFunding();
|
|
19
16
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
20
17
|
return React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
18
|
var _c, _d;
|
|
22
|
-
const hasWalletConnectWallet = userWallets.some((wallet) => wallet.connector.isWalletConnect);
|
|
23
|
-
// WC does not allow multiple sessions, so we have 2 cases here:
|
|
24
|
-
// 1. The user has a linked WalletConnect wallet.
|
|
25
|
-
// In this case, we should not do anything, and our logic will prevent other WCs from being
|
|
26
|
-
// selected for funding.
|
|
27
|
-
// 2. The user does not have a WalletConnect wallet linked.
|
|
28
|
-
// In this case, we should reset the WC session — this is because they might have just
|
|
29
|
-
// previously connected another WC wallet for funding and that session could still be active.
|
|
30
|
-
if (!hasWalletConnectWallet) {
|
|
31
|
-
const walletOption = walletOptions.getWalletConnectorOptions().find(({ walletConnector }) => walletConnector.isWalletConnect);
|
|
32
|
-
yield (walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector.endSession());
|
|
33
|
-
yield (walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector.init());
|
|
34
|
-
}
|
|
35
19
|
try {
|
|
36
20
|
const externalWallet = yield connectWalletForFunding();
|
|
37
21
|
const minAmount = (_d = (_c = settings === null || settings === void 0 ? void 0 : settings.sdk.funding) === null || _c === void 0 ? void 0 : _c.externalWallets) === null || _d === void 0 ? void 0 : _d.minAmount;
|
|
@@ -57,7 +41,6 @@ const useStartExternalWalletFunding = () => {
|
|
|
57
41
|
connectWalletForFunding,
|
|
58
42
|
setDynamicWidgetView,
|
|
59
43
|
(_b = (_a = settings === null || settings === void 0 ? void 0 : settings.sdk.funding) === null || _a === void 0 ? void 0 : _a.externalWallets) === null || _b === void 0 ? void 0 : _b.minAmount,
|
|
60
|
-
userWallets,
|
|
61
44
|
]);
|
|
62
45
|
};
|
|
63
46
|
|
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
-
import { useUserWallets } from '../../../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
5
4
|
import { useProjectSettings } from '../../../../../../store/state/projectSettings/projectSettings.js';
|
|
6
|
-
import { getWalletConnectorOptions } from '../../../../../../store/state/walletOptions/walletOptions.js';
|
|
7
5
|
import { useFunding } from '../../../../../../utils/hooks/useFunding/useFunding.js';
|
|
8
6
|
import { useWidgetContext } from '../../../../context/DynamicWidgetContext.js';
|
|
9
7
|
|
|
10
8
|
const useStartExternalWalletFunding = () => {
|
|
11
9
|
var _a, _b;
|
|
12
|
-
const userWallets = useUserWallets();
|
|
13
10
|
const settings = useProjectSettings();
|
|
14
11
|
const { connectWalletForFunding } = useFunding();
|
|
15
12
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
16
13
|
return useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
14
|
var _c, _d;
|
|
18
|
-
const hasWalletConnectWallet = userWallets.some((wallet) => wallet.connector.isWalletConnect);
|
|
19
|
-
// WC does not allow multiple sessions, so we have 2 cases here:
|
|
20
|
-
// 1. The user has a linked WalletConnect wallet.
|
|
21
|
-
// In this case, we should not do anything, and our logic will prevent other WCs from being
|
|
22
|
-
// selected for funding.
|
|
23
|
-
// 2. The user does not have a WalletConnect wallet linked.
|
|
24
|
-
// In this case, we should reset the WC session — this is because they might have just
|
|
25
|
-
// previously connected another WC wallet for funding and that session could still be active.
|
|
26
|
-
if (!hasWalletConnectWallet) {
|
|
27
|
-
const walletOption = getWalletConnectorOptions().find(({ walletConnector }) => walletConnector.isWalletConnect);
|
|
28
|
-
yield (walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector.endSession());
|
|
29
|
-
yield (walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector.init());
|
|
30
|
-
}
|
|
31
15
|
try {
|
|
32
16
|
const externalWallet = yield connectWalletForFunding();
|
|
33
17
|
const minAmount = (_d = (_c = settings === null || settings === void 0 ? void 0 : settings.sdk.funding) === null || _c === void 0 ? void 0 : _c.externalWallets) === null || _d === void 0 ? void 0 : _d.minAmount;
|
|
@@ -53,7 +37,6 @@ const useStartExternalWalletFunding = () => {
|
|
|
53
37
|
connectWalletForFunding,
|
|
54
38
|
setDynamicWidgetView,
|
|
55
39
|
(_b = (_a = settings === null || settings === void 0 ? void 0 : settings.sdk.funding) === null || _a === void 0 ? void 0 : _a.externalWallets) === null || _b === void 0 ? void 0 : _b.minAmount,
|
|
56
|
-
userWallets,
|
|
57
40
|
]);
|
|
58
41
|
};
|
|
59
42
|
|