@dynamic-labs/sdk-react-core 3.8.0 → 3.8.1
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 +7 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +7 -2
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +7 -2
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +3 -3
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +4 -4
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +5 -2
|
@@ -89,16 +89,21 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
89
89
|
const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.ChainEnum.Evm, tokenAddresses, includeFiat = false, includeNativeBalance = false, } = {}) => {
|
|
90
90
|
const tokenBalancesState = tokenBalances.useTokenBalancesState();
|
|
91
91
|
const { tokenBalances: tokenBalances$1, isLoading, error } = tokenBalancesState;
|
|
92
|
-
const { primaryWallet, environmentId, network, user } = useInternalDynamicContext.useInternalDynamicContext();
|
|
92
|
+
const { primaryWallet, environmentId, network, user, projectSettings, authMode, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
93
93
|
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
94
94
|
const requestChainName = chainName !== null && chainName !== void 0 ? chainName : walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain;
|
|
95
95
|
const requestAccount = accountAddress !== null && accountAddress !== void 0 ? accountAddress : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address;
|
|
96
96
|
const requestNetwork = networkId !== null && networkId !== void 0 ? networkId : network;
|
|
97
97
|
const fetchAccountBalances = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (forceRefresh = false) {
|
|
98
|
-
|
|
98
|
+
var _a;
|
|
99
|
+
if (authMode !== 'connect-only' && !user) {
|
|
99
100
|
tokenBalances.setTokenBalanceVariable('error', errors.USER_NOT_LOGGED_IN);
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
103
|
+
if (authMode === 'connect-only' &&
|
|
104
|
+
!((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _a === void 0 ? void 0 : _a.connectOnlyMultiAsset)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
102
107
|
if (![sdkApiCore.ChainEnum.Evm, sdkApiCore.ChainEnum.Sol].includes(requestChainName)) {
|
|
103
108
|
tokenBalances.setTokenBalanceVariable('error', `Chain ${requestChainName} is not supported for token balances`);
|
|
104
109
|
return;
|
|
@@ -85,16 +85,21 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
85
85
|
const useTokenBalances = ({ accountAddress, networkId, chainName = ChainEnum.Evm, tokenAddresses, includeFiat = false, includeNativeBalance = false, } = {}) => {
|
|
86
86
|
const tokenBalancesState = useTokenBalancesState();
|
|
87
87
|
const { tokenBalances, isLoading, error } = tokenBalancesState;
|
|
88
|
-
const { primaryWallet, environmentId, network, user } = useInternalDynamicContext();
|
|
88
|
+
const { primaryWallet, environmentId, network, user, projectSettings, authMode, } = useInternalDynamicContext();
|
|
89
89
|
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
90
90
|
const requestChainName = chainName !== null && chainName !== void 0 ? chainName : walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain;
|
|
91
91
|
const requestAccount = accountAddress !== null && accountAddress !== void 0 ? accountAddress : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address;
|
|
92
92
|
const requestNetwork = networkId !== null && networkId !== void 0 ? networkId : network;
|
|
93
93
|
const fetchAccountBalances = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (forceRefresh = false) {
|
|
94
|
-
|
|
94
|
+
var _a;
|
|
95
|
+
if (authMode !== 'connect-only' && !user) {
|
|
95
96
|
setTokenBalanceVariable('error', USER_NOT_LOGGED_IN);
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
99
|
+
if (authMode === 'connect-only' &&
|
|
100
|
+
!((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _a === void 0 ? void 0 : _a.connectOnlyMultiAsset)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
98
103
|
if (![ChainEnum.Evm, ChainEnum.Sol].includes(requestChainName)) {
|
|
99
104
|
setTokenBalanceVariable('error', `Chain ${requestChainName} is not supported for token balances`);
|
|
100
105
|
return;
|
|
@@ -51,13 +51,13 @@ require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
|
51
51
|
require('@dynamic-labs/rpc-providers');
|
|
52
52
|
require('../../store/state/environmentId.cjs');
|
|
53
53
|
require('../../store/state/walletConnectorOptions.cjs');
|
|
54
|
-
var
|
|
55
|
-
require('../../context/FooterAnimationContext/index.cjs');
|
|
54
|
+
var DynamicFooter = require('../../components/DynamicFooter/DynamicFooter.cjs');
|
|
56
55
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
57
56
|
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
58
57
|
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
59
58
|
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
60
59
|
require('../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
60
|
+
require('../../context/FooterAnimationContext/index.cjs');
|
|
61
61
|
var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
62
62
|
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
63
63
|
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
@@ -90,7 +90,7 @@ const SocialRedirectView = () => {
|
|
|
90
90
|
const { socialProvider, signInProvider } = SocialRedirectContext.useSocialRedirectContext();
|
|
91
91
|
const findSocialIcon = useFindSocialIcon.useFindSocialIcon();
|
|
92
92
|
const { t } = reactI18next.useTranslation();
|
|
93
|
-
return (jsxRuntime.jsxs("div", { className: classNames.classNames('social-redirect-view__container'), children: [socialProvider && (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: findSocialIcon(socialProvider), isSpinning: true })), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'title', className: classNames.classNames('social-redirect-view__title'), copykey: 'dyn_social_redirect.logging_in', children: t('dyn_social_redirect.logging_in') }), signInProvider !== sdkApiCore.SignInProviderEnum.MagicLink &&
|
|
93
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: classNames.classNames('social-redirect-view__container'), children: [socialProvider && (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: findSocialIcon(socialProvider), isSpinning: true })), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'title', className: classNames.classNames('social-redirect-view__title'), copykey: 'dyn_social_redirect.logging_in', children: t('dyn_social_redirect.logging_in') })] }), signInProvider !== sdkApiCore.SignInProviderEnum.MagicLink && jsxRuntime.jsx(DynamicFooter.DynamicFooter, {})] }));
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
exports.SocialRedirectView = SocialRedirectView;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { SignInProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
@@ -47,13 +47,13 @@ import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
|
47
47
|
import '@dynamic-labs/rpc-providers';
|
|
48
48
|
import '../../store/state/environmentId.js';
|
|
49
49
|
import '../../store/state/walletConnectorOptions.js';
|
|
50
|
-
import {
|
|
51
|
-
import '../../context/FooterAnimationContext/index.js';
|
|
50
|
+
import { DynamicFooter } from '../../components/DynamicFooter/DynamicFooter.js';
|
|
52
51
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
53
52
|
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
54
53
|
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
55
54
|
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
56
55
|
import '../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
56
|
+
import '../../context/FooterAnimationContext/index.js';
|
|
57
57
|
import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
58
58
|
import '../../context/WalletGroupContext/WalletGroupContext.js';
|
|
59
59
|
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
@@ -86,7 +86,7 @@ const SocialRedirectView = () => {
|
|
|
86
86
|
const { socialProvider, signInProvider } = useSocialRedirectContext();
|
|
87
87
|
const findSocialIcon = useFindSocialIcon();
|
|
88
88
|
const { t } = useTranslation();
|
|
89
|
-
return (jsxs("div", { className: classNames('social-redirect-view__container'), children: [socialProvider && (jsx(IconWithSpinner, { iconSize: 64, Icon: findSocialIcon(socialProvider), isSpinning: true })), jsx(Typography, { weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title'), copykey: 'dyn_social_redirect.logging_in', children: t('dyn_social_redirect.logging_in') }), signInProvider !== SignInProviderEnum.MagicLink &&
|
|
89
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: classNames('social-redirect-view__container'), children: [socialProvider && (jsx(IconWithSpinner, { iconSize: 64, Icon: findSocialIcon(socialProvider), isSpinning: true })), jsx(Typography, { weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title'), copykey: 'dyn_social_redirect.logging_in', children: t('dyn_social_redirect.logging_in') })] }), signInProvider !== SignInProviderEnum.MagicLink && jsx(DynamicFooter, {})] }));
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
export { SocialRedirectView };
|
package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs
CHANGED
|
@@ -101,7 +101,7 @@ var TokenBalanceList = require('./TokenBalanceList/TokenBalanceList.cjs');
|
|
|
101
101
|
|
|
102
102
|
const ICON_SIZE = 28;
|
|
103
103
|
const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
104
|
-
var _a, _b, _c, _d, _e;
|
|
104
|
+
var _a, _b, _c, _d, _e, _f;
|
|
105
105
|
const { t } = reactI18next.useTranslation();
|
|
106
106
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
107
107
|
const [balanceIsExpanded, setBalanceIsExpanded] = React.useState(false);
|
|
@@ -169,7 +169,10 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
169
169
|
return (jsxRuntime.jsx(ActiveWalletAddress.ActiveWalletAddress, { address: address, nameServiceName: (nameService === null || nameService === void 0 ? void 0 : nameService.name) || (user === null || user === void 0 ? void 0 : user.email), menuOption: options, isLoading: isLoading, fullWidth: shouldHideNetwork }));
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
-
const enableMultiAsset = authMode === 'connect-and-sign'
|
|
172
|
+
const enableMultiAsset = (authMode === 'connect-and-sign' ||
|
|
173
|
+
(authMode === 'connect-only' &&
|
|
174
|
+
((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _f === void 0 ? void 0 : _f.connectOnlyMultiAsset))) &&
|
|
175
|
+
multiAsset;
|
|
173
176
|
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork.isMultiAssetSupportedNetwork(primaryConnector, network);
|
|
174
177
|
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
175
178
|
const showMultiAsset = !isTooManyRequests && isNetworkMultiAssetSupported && enableMultiAsset;
|
package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js
CHANGED
|
@@ -97,7 +97,7 @@ import { TokenBalanceList } from './TokenBalanceList/TokenBalanceList.js';
|
|
|
97
97
|
|
|
98
98
|
const ICON_SIZE = 28;
|
|
99
99
|
const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
100
|
-
var _a, _b, _c, _d, _e;
|
|
100
|
+
var _a, _b, _c, _d, _e, _f;
|
|
101
101
|
const { t } = useTranslation();
|
|
102
102
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
103
103
|
const [balanceIsExpanded, setBalanceIsExpanded] = useState(false);
|
|
@@ -165,7 +165,10 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
165
165
|
return (jsx(ActiveWalletAddress, { address: address, nameServiceName: (nameService === null || nameService === void 0 ? void 0 : nameService.name) || (user === null || user === void 0 ? void 0 : user.email), menuOption: options, isLoading: isLoading, fullWidth: shouldHideNetwork }));
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
-
const enableMultiAsset = authMode === 'connect-and-sign'
|
|
168
|
+
const enableMultiAsset = (authMode === 'connect-and-sign' ||
|
|
169
|
+
(authMode === 'connect-only' &&
|
|
170
|
+
((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _f === void 0 ? void 0 : _f.connectOnlyMultiAsset))) &&
|
|
171
|
+
multiAsset;
|
|
169
172
|
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork(primaryConnector, network);
|
|
170
173
|
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
171
174
|
const showMultiAsset = !isTooManyRequests && isNetworkMultiAssetSupported && enableMultiAsset;
|