@dynamic-labs/sdk-react-core 4.9.8 → 4.9.10
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 +19 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/components/ModalHeader/ModalHeader.cjs +5 -3
- package/src/lib/components/ModalHeader/ModalHeader.js +5 -3
- package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.cjs +1 -1
- package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.js +1 -1
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +11 -3
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.d.ts +4 -1
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +11 -3
- package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +2 -0
- package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.cjs +120 -0
- package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.d.ts +7 -0
- package/src/lib/context/DynamicContext/hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.js +116 -0
- package/src/lib/context/UserWalletsContext/UserWalletsContext.cjs +3 -0
- package/src/lib/context/UserWalletsContext/UserWalletsContext.js +3 -0
- package/src/lib/events/wallets.d.ts +2 -0
- package/src/lib/shared/utils/functions/isGlobalWalletPopup/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/isGlobalWalletPopup/isGlobalWalletPopup.cjs +8 -0
- package/src/lib/shared/utils/functions/isGlobalWalletPopup/isGlobalWalletPopup.d.ts +6 -0
- package/src/lib/shared/utils/functions/isGlobalWalletPopup/isGlobalWalletPopup.js +4 -0
- package/src/lib/store/state/dynamicContextProps/dynamicContextProps.cjs +2 -2
- package/src/lib/store/state/dynamicContextProps/dynamicContextProps.js +3 -3
- package/src/lib/utils/functions/generateMessages/index.cjs +3 -0
- package/src/lib/utils/functions/generateMessages/index.js +3 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +8 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +8 -2
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +4 -1
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +4 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +1 -5
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +1 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.9.10](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.9...v4.9.10) (2025-03-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* auto select primary wallet when embedded wallets are disabled ([#8374](https://github.com/dynamic-labs/dynamic-auth/issues/8374)) ([780f3f1](https://github.com/dynamic-labs/dynamic-auth/commit/780f3f16ebd06dd8bc41fa85e8b4393c906989e2))
|
|
8
|
+
|
|
9
|
+
### [4.9.9](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.8...v4.9.9) (2025-03-26)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **global-wallet-client:** properly clean up the popup state when popup is closed ([#8379](https://github.com/dynamic-labs/dynamic-auth/issues/8379)) ([782963f](https://github.com/dynamic-labs/dynamic-auth/commit/782963f87fcb2658b921ff6cc6f22c63be9714fb))
|
|
15
|
+
* hanging promises when a starknet wallet is connected but locked ([#8376](https://github.com/dynamic-labs/dynamic-auth/issues/8376)) ([a753939](https://github.com/dynamic-labs/dynamic-auth/commit/a7539395d4653be49f000ae51d15347a176b5b6c))
|
|
16
|
+
* token balance list should respect sort from backend ([#8383](https://github.com/dynamic-labs/dynamic-auth/issues/8383)) ([1c3bef4](https://github.com/dynamic-labs/dynamic-auth/commit/1c3bef47dbfd319e2444368a4a503b0839b5ad4b))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
* add message auth code to global wallet ([#8354](https://github.com/dynamic-labs/dynamic-auth/issues/8354)) ([c847bf8](https://github.com/dynamic-labs/dynamic-auth/commit/c847bf8d66db54534348622255997f30f4309542))
|
|
20
|
+
|
|
2
21
|
### [4.9.8](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.7...v4.9.8) (2025-03-24)
|
|
3
22
|
|
|
4
23
|
|
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.9.
|
|
3
|
+
"version": "4.9.10",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.644",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"yup": "0.32.11",
|
|
15
15
|
"react-international-phone": "4.2.5",
|
|
16
16
|
"bs58": "5.0.0",
|
|
17
|
-
"@dynamic-labs/assert-package-version": "4.9.
|
|
18
|
-
"@dynamic-labs/iconic": "4.9.
|
|
19
|
-
"@dynamic-labs/logger": "4.9.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "4.9.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "4.9.
|
|
22
|
-
"@dynamic-labs/store": "4.9.
|
|
23
|
-
"@dynamic-labs/types": "4.9.
|
|
24
|
-
"@dynamic-labs/utils": "4.9.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.9.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.9.
|
|
17
|
+
"@dynamic-labs/assert-package-version": "4.9.10",
|
|
18
|
+
"@dynamic-labs/iconic": "4.9.10",
|
|
19
|
+
"@dynamic-labs/logger": "4.9.10",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "4.9.10",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "4.9.10",
|
|
22
|
+
"@dynamic-labs/store": "4.9.10",
|
|
23
|
+
"@dynamic-labs/types": "4.9.10",
|
|
24
|
+
"@dynamic-labs/utils": "4.9.10",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.9.10",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.9.10",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -6,19 +6,21 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var classNames = require('../../utils/functions/classNames/classNames.cjs');
|
|
9
|
+
var isGlobalWalletPopup = require('../../shared/utils/functions/isGlobalWalletPopup/isGlobalWalletPopup.cjs');
|
|
9
10
|
|
|
10
11
|
const ModalHeader = ({ alignContent, children, leading, displayLeading = true, trailing, displayTrailing = true, style, displayBorder, description, }) => {
|
|
11
12
|
const hasLeading = displayLeading && leading && React.Children.count(leading);
|
|
12
13
|
const hasTrailing = displayTrailing && trailing && React.Children.count(trailing);
|
|
14
|
+
const trailingClassName = classNames.classNames('modal-header__content__trailing', {
|
|
15
|
+
'modal-header__content__trailing--empty': !hasTrailing,
|
|
16
|
+
});
|
|
13
17
|
return (jsxRuntime.jsxs("div", { className: classNames.classNames('modal-header', {
|
|
14
18
|
'modal-header--border': displayBorder,
|
|
15
19
|
'modal-header--empty': !hasLeading && !children && !hasTrailing,
|
|
16
20
|
}), style: style, children: [jsxRuntime.jsxs("div", { className: classNames.classNames('modal-header__content', alignContent &&
|
|
17
21
|
`modal-header__content--align-content-${alignContent}`), children: [displayLeading && (jsxRuntime.jsx("div", { className: classNames.classNames('modal-header__content__leading', {
|
|
18
22
|
'modal-header__content__leading--empty': !hasLeading,
|
|
19
|
-
}), children: leading })), children,
|
|
20
|
-
'modal-header__content__trailing--empty': !hasTrailing,
|
|
21
|
-
}), children: trailing }))] }), description] }));
|
|
23
|
+
}), children: leading })), children, isGlobalWalletPopup.isGlobalWalletPopup() && (jsxRuntime.jsx("div", { id: 'modal-header-gw-menu', className: trailingClassName })), displayTrailing && !isGlobalWalletPopup.isGlobalWalletPopup() && (jsxRuntime.jsx("div", { className: trailingClassName, children: trailing }))] }), description] }));
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
exports.ModalHeader = ModalHeader;
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Children } from 'react';
|
|
4
4
|
import { classNames } from '../../utils/functions/classNames/classNames.js';
|
|
5
|
+
import { isGlobalWalletPopup } from '../../shared/utils/functions/isGlobalWalletPopup/isGlobalWalletPopup.js';
|
|
5
6
|
|
|
6
7
|
const ModalHeader = ({ alignContent, children, leading, displayLeading = true, trailing, displayTrailing = true, style, displayBorder, description, }) => {
|
|
7
8
|
const hasLeading = displayLeading && leading && Children.count(leading);
|
|
8
9
|
const hasTrailing = displayTrailing && trailing && Children.count(trailing);
|
|
10
|
+
const trailingClassName = classNames('modal-header__content__trailing', {
|
|
11
|
+
'modal-header__content__trailing--empty': !hasTrailing,
|
|
12
|
+
});
|
|
9
13
|
return (jsxs("div", { className: classNames('modal-header', {
|
|
10
14
|
'modal-header--border': displayBorder,
|
|
11
15
|
'modal-header--empty': !hasLeading && !children && !hasTrailing,
|
|
12
16
|
}), style: style, children: [jsxs("div", { className: classNames('modal-header__content', alignContent &&
|
|
13
17
|
`modal-header__content--align-content-${alignContent}`), children: [displayLeading && (jsx("div", { className: classNames('modal-header__content__leading', {
|
|
14
18
|
'modal-header__content__leading--empty': !hasLeading,
|
|
15
|
-
}), children: leading })), children,
|
|
16
|
-
'modal-header__content__trailing--empty': !hasTrailing,
|
|
17
|
-
}), children: trailing }))] }), description] }));
|
|
19
|
+
}), children: leading })), children, isGlobalWalletPopup() && (jsx("div", { id: 'modal-header-gw-menu', className: trailingClassName })), displayTrailing && !isGlobalWalletPopup() && (jsx("div", { className: trailingClassName, children: trailing }))] }), description] }));
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
export { ModalHeader };
|
|
@@ -20,7 +20,7 @@ const NetworkControl = ({ loading, walletConnector, buttonClassName, network, ac
|
|
|
20
20
|
return jsxRuntime.jsx(NetworkControlSkeleton.NetworkControlSkeleton, { className: buttonClassName });
|
|
21
21
|
}
|
|
22
22
|
if (!walletConnector.supportsNetworkSwitching()) {
|
|
23
|
-
return (jsxRuntime.jsx(NonNetworkSwitchingSupportedControl.NonNetworkSwitchingSupportedControl, { className: buttonClassName, showNetworkName: showNetworkName, walletConnector: walletConnector }));
|
|
23
|
+
return (jsxRuntime.jsx(NonNetworkSwitchingSupportedControl.NonNetworkSwitchingSupportedControl, { className: buttonClassName, showNetworkName: showNetworkName, walletConnector: walletConnector, network: network, enabledNetworks: enabledNetworks }));
|
|
24
24
|
}
|
|
25
25
|
return (jsxRuntime.jsx(NetworkSwitchControl.NetworkSwitchControl, { showNetworkName: showNetworkName, enabledNetworks: enabledNetworks, activeClassName: activeClassName, className: buttonClassName, network: network, loading: loading, isOpen: isOpen, walletConnector: walletConnector, setIsOpen: setIsOpen }));
|
|
26
26
|
};
|
|
@@ -16,7 +16,7 @@ const NetworkControl = ({ loading, walletConnector, buttonClassName, network, ac
|
|
|
16
16
|
return jsx(NetworkControlSkeleton, { className: buttonClassName });
|
|
17
17
|
}
|
|
18
18
|
if (!walletConnector.supportsNetworkSwitching()) {
|
|
19
|
-
return (jsx(NonNetworkSwitchingSupportedControl, { className: buttonClassName, showNetworkName: showNetworkName, walletConnector: walletConnector }));
|
|
19
|
+
return (jsx(NonNetworkSwitchingSupportedControl, { className: buttonClassName, showNetworkName: showNetworkName, walletConnector: walletConnector, network: network, enabledNetworks: enabledNetworks }));
|
|
20
20
|
}
|
|
21
21
|
return (jsx(NetworkSwitchControl, { showNetworkName: showNetworkName, enabledNetworks: enabledNetworks, activeClassName: activeClassName, className: buttonClassName, network: network, loading: loading, isOpen: isOpen, walletConnector: walletConnector, setIsOpen: setIsOpen }));
|
|
22
22
|
};
|
|
@@ -4,10 +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 classNames = require('../../../../utils/functions/classNames/classNames.cjs');
|
|
8
9
|
require('../../../Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
9
10
|
require('../../../Alert/Alert.cjs');
|
|
10
|
-
require('react');
|
|
11
11
|
require('../../../../events/dynamicEvents.cjs');
|
|
12
12
|
require('../../../../../../_virtual/_tslib.cjs');
|
|
13
13
|
require('@dynamic-labs/utils');
|
|
@@ -101,14 +101,22 @@ require('../../../IsBrowser/IsBrowser.cjs');
|
|
|
101
101
|
require('../../../Popper/Popper/Popper.cjs');
|
|
102
102
|
require('../../../Popper/PopperContext/PopperContext.cjs');
|
|
103
103
|
|
|
104
|
-
const NonNetworkSwitchingSupportedControl = ({ walletConnector, className, showNetworkName = false, }) => {
|
|
104
|
+
const NonNetworkSwitchingSupportedControl = ({ walletConnector, className, showNetworkName = false, network, enabledNetworks, }) => {
|
|
105
105
|
const { chain, isLoading } = useFetchChain.useFetchChain(walletConnector);
|
|
106
106
|
const chainName = (chain === null || chain === void 0 ? void 0 : chain.name) || '';
|
|
107
107
|
const ChainIcon = getChainIcon.getChainIcon(walletConnector.connectedChain || '');
|
|
108
|
+
const currentNetwork = React.useMemo(() => {
|
|
109
|
+
var _a;
|
|
110
|
+
let networkName;
|
|
111
|
+
if (network && enabledNetworks) {
|
|
112
|
+
networkName = (_a = enabledNetworks.find((element) => element.chainId.toString() === network.toString())) === null || _a === void 0 ? void 0 : _a.name;
|
|
113
|
+
}
|
|
114
|
+
return capitalize.capitalize(networkName !== null && networkName !== void 0 ? networkName : chainName);
|
|
115
|
+
}, [enabledNetworks, network, chainName]);
|
|
108
116
|
if (isLoading) {
|
|
109
117
|
return jsxRuntime.jsx(NetworkControlSkeleton.NetworkControlSkeleton, { className: className });
|
|
110
118
|
}
|
|
111
|
-
return (jsxRuntime.jsxs("div", { "data-testid": 'NonNetworkSwitchingSupportedControl', className: classNames.classNames('non-network-switching-supported-control', className), children: [jsxRuntime.jsx(Icon.Icon, { size: 'small', children: (chain === null || chain === void 0 ? void 0 : chain.icon) ? (jsxRuntime.jsx("img", { src: chain.icon, alt: `${chain.name} icon` })) : (jsxRuntime.jsx(ChainIcon, {})) }), showNetworkName && (jsxRuntime.jsx(Typography.Typography, { className: classNames.classNames('non-network-switching-supported-control__network-name'), as: 'span', variant: 'body_small', children:
|
|
119
|
+
return (jsxRuntime.jsxs("div", { "data-testid": 'NonNetworkSwitchingSupportedControl', className: classNames.classNames('non-network-switching-supported-control', className), children: [jsxRuntime.jsx(Icon.Icon, { size: 'small', children: (chain === null || chain === void 0 ? void 0 : chain.icon) ? (jsxRuntime.jsx("img", { src: chain.icon, alt: `${chain.name} icon` })) : (jsxRuntime.jsx(ChainIcon, {})) }), showNetworkName && (jsxRuntime.jsx(Typography.Typography, { className: classNames.classNames('non-network-switching-supported-control__network-name'), as: 'span', variant: 'body_small', children: currentNetwork }))] }));
|
|
112
120
|
};
|
|
113
121
|
|
|
114
122
|
exports.NonNetworkSwitchingSupportedControl = NonNetworkSwitchingSupportedControl;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { GenericNetwork } from '@dynamic-labs/types';
|
|
3
4
|
type Props = {
|
|
4
5
|
className?: string;
|
|
5
6
|
showNetworkName?: boolean;
|
|
6
7
|
walletConnector: WalletConnector;
|
|
8
|
+
network?: string | number;
|
|
9
|
+
enabledNetworks?: GenericNetwork[];
|
|
7
10
|
};
|
|
8
|
-
export declare const NonNetworkSwitchingSupportedControl: ({ walletConnector, className, showNetworkName, }: Props) => JSX.Element;
|
|
11
|
+
export declare const NonNetworkSwitchingSupportedControl: ({ walletConnector, className, showNetworkName, network, enabledNetworks, }: Props) => JSX.Element;
|
|
9
12
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
3
4
|
import { classNames } from '../../../../utils/functions/classNames/classNames.js';
|
|
4
5
|
import '../../../Accordion/components/AccordionItem/AccordionItem.js';
|
|
5
6
|
import '../../../Alert/Alert.js';
|
|
6
|
-
import 'react';
|
|
7
7
|
import '../../../../events/dynamicEvents.js';
|
|
8
8
|
import '../../../../../../_virtual/_tslib.js';
|
|
9
9
|
import '@dynamic-labs/utils';
|
|
@@ -97,14 +97,22 @@ import '../../../IsBrowser/IsBrowser.js';
|
|
|
97
97
|
import '../../../Popper/Popper/Popper.js';
|
|
98
98
|
import '../../../Popper/PopperContext/PopperContext.js';
|
|
99
99
|
|
|
100
|
-
const NonNetworkSwitchingSupportedControl = ({ walletConnector, className, showNetworkName = false, }) => {
|
|
100
|
+
const NonNetworkSwitchingSupportedControl = ({ walletConnector, className, showNetworkName = false, network, enabledNetworks, }) => {
|
|
101
101
|
const { chain, isLoading } = useFetchChain(walletConnector);
|
|
102
102
|
const chainName = (chain === null || chain === void 0 ? void 0 : chain.name) || '';
|
|
103
103
|
const ChainIcon = getChainIcon(walletConnector.connectedChain || '');
|
|
104
|
+
const currentNetwork = useMemo(() => {
|
|
105
|
+
var _a;
|
|
106
|
+
let networkName;
|
|
107
|
+
if (network && enabledNetworks) {
|
|
108
|
+
networkName = (_a = enabledNetworks.find((element) => element.chainId.toString() === network.toString())) === null || _a === void 0 ? void 0 : _a.name;
|
|
109
|
+
}
|
|
110
|
+
return capitalize(networkName !== null && networkName !== void 0 ? networkName : chainName);
|
|
111
|
+
}, [enabledNetworks, network, chainName]);
|
|
104
112
|
if (isLoading) {
|
|
105
113
|
return jsx(NetworkControlSkeleton, { className: className });
|
|
106
114
|
}
|
|
107
|
-
return (jsxs("div", { "data-testid": 'NonNetworkSwitchingSupportedControl', className: classNames('non-network-switching-supported-control', className), children: [jsx(Icon, { size: 'small', children: (chain === null || chain === void 0 ? void 0 : chain.icon) ? (jsx("img", { src: chain.icon, alt: `${chain.name} icon` })) : (jsx(ChainIcon, {})) }), showNetworkName && (jsx(Typography, { className: classNames('non-network-switching-supported-control__network-name'), as: 'span', variant: 'body_small', children:
|
|
115
|
+
return (jsxs("div", { "data-testid": 'NonNetworkSwitchingSupportedControl', className: classNames('non-network-switching-supported-control', className), children: [jsx(Icon, { size: 'small', children: (chain === null || chain === void 0 ? void 0 : chain.icon) ? (jsx("img", { src: chain.icon, alt: `${chain.name} icon` })) : (jsx(ChainIcon, {})) }), showNetworkName && (jsx(Typography, { className: classNames('non-network-switching-supported-control__network-name'), as: 'span', variant: 'body_small', children: currentNetwork }))] }));
|
|
108
116
|
};
|
|
109
117
|
|
|
110
118
|
export { NonNetworkSwitchingSupportedControl };
|
|
@@ -147,6 +147,7 @@ var useShowAuthFlow = require('./hooks/useShowAuthFlow/useShowAuthFlow.cjs');
|
|
|
147
147
|
var usePasskeySuccessPopup = require('./hooks/usePasskeySuccessPopup/usePasskeySuccessPopup.cjs');
|
|
148
148
|
var useTieCallbacksToEvents = require('./hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs');
|
|
149
149
|
var useMultiWallet = require('./hooks/useMultiWallet/useMultiWallet.cjs');
|
|
150
|
+
var useAutoselectPrimaryWallet = require('./hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.cjs');
|
|
150
151
|
var useInitialViewType = require('./hooks/useInitialViewType/useInitialViewType.cjs');
|
|
151
152
|
var useMultiAsset = require('./hooks/useMultiAsset/useMultiAsset.cjs');
|
|
152
153
|
var useParentDynamicContextGuard = require('./hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.cjs');
|
|
@@ -325,6 +326,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
325
326
|
user: user$1 || userWithMissingInfo,
|
|
326
327
|
walletConnectorOptions,
|
|
327
328
|
});
|
|
329
|
+
useAutoselectPrimaryWallet.useAutoselectPrimaryWallet(isBridgeFlow);
|
|
328
330
|
React.useEffect(() => {
|
|
329
331
|
setRequiredWalletsConnected(!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) && Boolean(primaryWallet));
|
|
330
332
|
}, [bridgeChainsToConnect, primaryWallet]);
|
|
@@ -143,6 +143,7 @@ import { useShowAuthFlow } from './hooks/useShowAuthFlow/useShowAuthFlow.js';
|
|
|
143
143
|
import { usePasskeySuccessPopup } from './hooks/usePasskeySuccessPopup/usePasskeySuccessPopup.js';
|
|
144
144
|
import { useTieCallbacksToEvents } from './hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js';
|
|
145
145
|
import { useMultiWallet } from './hooks/useMultiWallet/useMultiWallet.js';
|
|
146
|
+
import { useAutoselectPrimaryWallet } from './hooks/useAutoselectPrimaryWallet/useAutoselectPrimaryWallet.js';
|
|
146
147
|
import { useInitialViewType } from './hooks/useInitialViewType/useInitialViewType.js';
|
|
147
148
|
import { useMultiAsset } from './hooks/useMultiAsset/useMultiAsset.js';
|
|
148
149
|
import { useParentDynamicContextGuard } from './hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.js';
|
|
@@ -321,6 +322,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
321
322
|
user: user || userWithMissingInfo,
|
|
322
323
|
walletConnectorOptions,
|
|
323
324
|
});
|
|
325
|
+
useAutoselectPrimaryWallet(isBridgeFlow);
|
|
324
326
|
useEffect(() => {
|
|
325
327
|
setRequiredWalletsConnected(!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) && Boolean(primaryWallet));
|
|
326
328
|
}, [bridgeChainsToConnect, primaryWallet]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useAutoselectPrimaryWallet';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var primaryWalletId = require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
7
|
+
require('@dynamic-labs/sdk-api-core');
|
|
8
|
+
require('../../../../utils/constants/values.cjs');
|
|
9
|
+
require('@dynamic-labs/utils');
|
|
10
|
+
require('../../../../../../_virtual/_tslib.cjs');
|
|
11
|
+
require('@dynamic-labs/multi-wallet');
|
|
12
|
+
require('../../../../shared/logger.cjs');
|
|
13
|
+
require('../../../../utils/constants/colors.cjs');
|
|
14
|
+
require('react-international-phone');
|
|
15
|
+
require('@dynamic-labs/iconic');
|
|
16
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
17
|
+
require('react');
|
|
18
|
+
require('react/jsx-runtime');
|
|
19
|
+
require('../../../ViewContext/ViewContext.cjs');
|
|
20
|
+
require('@dynamic-labs/wallet-book');
|
|
21
|
+
require('../../../../shared/consts/index.cjs');
|
|
22
|
+
require('../../../../store/state/nonce/nonce.cjs');
|
|
23
|
+
require('../../../../store/state/projectSettings/projectSettings.cjs');
|
|
24
|
+
var updatePrimaryWalletId = require('../../../../utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs');
|
|
25
|
+
var useDynamicEvents = require('../../../../utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs');
|
|
26
|
+
require('../../DynamicContext.cjs');
|
|
27
|
+
require('../../../CaptchaContext/CaptchaContext.cjs');
|
|
28
|
+
require('../../../ErrorContext/ErrorContext.cjs');
|
|
29
|
+
require('../../../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
30
|
+
require('../../../AccountExistsContext/AccountExistsContext.cjs');
|
|
31
|
+
require('../../../UserWalletsContext/UserWalletsContext.cjs');
|
|
32
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
33
|
+
require('../../../../store/state/user/user.cjs');
|
|
34
|
+
require('../../../../locale/locale.cjs');
|
|
35
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
36
|
+
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
37
|
+
require('../../../VerificationContext/VerificationContext.cjs');
|
|
38
|
+
require('react-dom');
|
|
39
|
+
require('../../../../utils/functions/compareChains/compareChains.cjs');
|
|
40
|
+
require('../../../ThemeContext/ThemeContext.cjs');
|
|
41
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
42
|
+
require('bs58');
|
|
43
|
+
require('@dynamic-labs/types');
|
|
44
|
+
require('../../../SocialRedirectContext/SocialRedirectContext.cjs');
|
|
45
|
+
require('../../../LoadingContext/LoadingContext.cjs');
|
|
46
|
+
require('../../../WalletContext/WalletContext.cjs');
|
|
47
|
+
require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
48
|
+
require('yup');
|
|
49
|
+
require('../../../MockContext/MockContext.cjs');
|
|
50
|
+
require('../../../../views/CollectUserDataView/useFields.cjs');
|
|
51
|
+
require('../../../FieldsStateContext/FieldsStateContext.cjs');
|
|
52
|
+
require('../../../UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
53
|
+
require('@dynamic-labs/rpc-providers');
|
|
54
|
+
require('../../../../store/state/loadingAndLifecycle.cjs');
|
|
55
|
+
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
56
|
+
require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
57
|
+
require('react-i18next');
|
|
58
|
+
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
59
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
60
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
61
|
+
require('../../../../components/IconButton/IconButton.cjs');
|
|
62
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
63
|
+
require('../../../../components/Input/Input.cjs');
|
|
64
|
+
require('../../../../components/IsBrowser/IsBrowser.cjs');
|
|
65
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
66
|
+
require('../../../../components/OverlayCard/OverlayCard.cjs');
|
|
67
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
68
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
69
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
70
|
+
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
71
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
72
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
73
|
+
require('react-focus-lock');
|
|
74
|
+
require('qrcode');
|
|
75
|
+
require('formik');
|
|
76
|
+
require('../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
77
|
+
require('../../../WalletGroupContext/WalletGroupContext.cjs');
|
|
78
|
+
require('../../../IpConfigurationContext/IpConfigurationContext.cjs');
|
|
79
|
+
require('../../../ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
80
|
+
require('../../../ConnectWithOtpContext/constants.cjs');
|
|
81
|
+
require('../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
82
|
+
require('@hcaptcha/react-hcaptcha');
|
|
83
|
+
require('../../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
84
|
+
require('../../../FooterAnimationContext/index.cjs');
|
|
85
|
+
require('../../../ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
86
|
+
require('../../../PasskeyContext/PasskeyContext.cjs');
|
|
87
|
+
require('../../../../store/state/sendBalances.cjs');
|
|
88
|
+
require('../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
89
|
+
require('../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
90
|
+
require('../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
91
|
+
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
92
|
+
require('../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
93
|
+
require('../../../OnrampContext/OnrampContext.cjs');
|
|
94
|
+
require('../../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
95
|
+
require('../../../../../index.cjs');
|
|
96
|
+
require('../../../../store/state/tokenBalances.cjs');
|
|
97
|
+
require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
98
|
+
|
|
99
|
+
/* eslint-disable prefer-destructuring */
|
|
100
|
+
/**
|
|
101
|
+
* Whenever user wallets are populated, this hook will automatically select a wallet as the primary wallet.
|
|
102
|
+
*
|
|
103
|
+
* This logic doesn't apply when embedded wallets are enabled though, as the primary wallet will be selected
|
|
104
|
+
* as the embedded wallet.
|
|
105
|
+
*/
|
|
106
|
+
const useAutoselectPrimaryWallet = (isBridgeFlow) => {
|
|
107
|
+
useDynamicEvents.useInternalDynamicEvents('userWalletsPopulated', (userWallets) => {
|
|
108
|
+
if (isBridgeFlow ||
|
|
109
|
+
userWallets.some((wallet) => wallet.connector.isEmbeddedWallet))
|
|
110
|
+
return;
|
|
111
|
+
if (primaryWalletId.getPrimaryWalletId())
|
|
112
|
+
return;
|
|
113
|
+
const firstWallet = userWallets[0];
|
|
114
|
+
if (!firstWallet)
|
|
115
|
+
return;
|
|
116
|
+
updatePrimaryWalletId.updatePrimaryWalletId(firstWallet.id);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
exports.useAutoselectPrimaryWallet = useAutoselectPrimaryWallet;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whenever user wallets are populated, this hook will automatically select a wallet as the primary wallet.
|
|
3
|
+
*
|
|
4
|
+
* This logic doesn't apply when embedded wallets are enabled though, as the primary wallet will be selected
|
|
5
|
+
* as the embedded wallet.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useAutoselectPrimaryWallet: (isBridgeFlow: boolean) => void;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getPrimaryWalletId } from '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
3
|
+
import '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import '../../../../utils/constants/values.js';
|
|
5
|
+
import '@dynamic-labs/utils';
|
|
6
|
+
import '../../../../../../_virtual/_tslib.js';
|
|
7
|
+
import '@dynamic-labs/multi-wallet';
|
|
8
|
+
import '../../../../shared/logger.js';
|
|
9
|
+
import '../../../../utils/constants/colors.js';
|
|
10
|
+
import 'react-international-phone';
|
|
11
|
+
import '@dynamic-labs/iconic';
|
|
12
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
13
|
+
import 'react';
|
|
14
|
+
import 'react/jsx-runtime';
|
|
15
|
+
import '../../../ViewContext/ViewContext.js';
|
|
16
|
+
import '@dynamic-labs/wallet-book';
|
|
17
|
+
import '../../../../shared/consts/index.js';
|
|
18
|
+
import '../../../../store/state/nonce/nonce.js';
|
|
19
|
+
import '../../../../store/state/projectSettings/projectSettings.js';
|
|
20
|
+
import { updatePrimaryWalletId } from '../../../../utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.js';
|
|
21
|
+
import { useInternalDynamicEvents } from '../../../../utils/hooks/events/useDynamicEvents/useDynamicEvents.js';
|
|
22
|
+
import '../../DynamicContext.js';
|
|
23
|
+
import '../../../CaptchaContext/CaptchaContext.js';
|
|
24
|
+
import '../../../ErrorContext/ErrorContext.js';
|
|
25
|
+
import '../../../AccessDeniedContext/AccessDeniedContext.js';
|
|
26
|
+
import '../../../AccountExistsContext/AccountExistsContext.js';
|
|
27
|
+
import '../../../UserWalletsContext/UserWalletsContext.js';
|
|
28
|
+
import '../../../../config/ApiEndpoint.js';
|
|
29
|
+
import '../../../../store/state/user/user.js';
|
|
30
|
+
import '../../../../locale/locale.js';
|
|
31
|
+
import '../../../../events/dynamicEvents.js';
|
|
32
|
+
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
33
|
+
import '../../../VerificationContext/VerificationContext.js';
|
|
34
|
+
import 'react-dom';
|
|
35
|
+
import '../../../../utils/functions/compareChains/compareChains.js';
|
|
36
|
+
import '../../../ThemeContext/ThemeContext.js';
|
|
37
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
38
|
+
import 'bs58';
|
|
39
|
+
import '@dynamic-labs/types';
|
|
40
|
+
import '../../../SocialRedirectContext/SocialRedirectContext.js';
|
|
41
|
+
import '../../../LoadingContext/LoadingContext.js';
|
|
42
|
+
import '../../../WalletContext/WalletContext.js';
|
|
43
|
+
import '../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
44
|
+
import 'yup';
|
|
45
|
+
import '../../../MockContext/MockContext.js';
|
|
46
|
+
import '../../../../views/CollectUserDataView/useFields.js';
|
|
47
|
+
import '../../../FieldsStateContext/FieldsStateContext.js';
|
|
48
|
+
import '../../../UserFieldEditorContext/UserFieldEditorContext.js';
|
|
49
|
+
import '@dynamic-labs/rpc-providers';
|
|
50
|
+
import '../../../../store/state/loadingAndLifecycle.js';
|
|
51
|
+
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
52
|
+
import '../../../../store/state/walletOptions/walletOptions.js';
|
|
53
|
+
import 'react-i18next';
|
|
54
|
+
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
55
|
+
import '../../../../components/Alert/Alert.js';
|
|
56
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
57
|
+
import '../../../../components/IconButton/IconButton.js';
|
|
58
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
59
|
+
import '../../../../components/Input/Input.js';
|
|
60
|
+
import '../../../../components/IsBrowser/IsBrowser.js';
|
|
61
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
62
|
+
import '../../../../components/OverlayCard/OverlayCard.js';
|
|
63
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
64
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
65
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
66
|
+
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
67
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
68
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
69
|
+
import 'react-focus-lock';
|
|
70
|
+
import 'qrcode';
|
|
71
|
+
import 'formik';
|
|
72
|
+
import '../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
73
|
+
import '../../../WalletGroupContext/WalletGroupContext.js';
|
|
74
|
+
import '../../../IpConfigurationContext/IpConfigurationContext.js';
|
|
75
|
+
import '../../../ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
76
|
+
import '../../../ConnectWithOtpContext/constants.js';
|
|
77
|
+
import '../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
78
|
+
import '@hcaptcha/react-hcaptcha';
|
|
79
|
+
import '../../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
80
|
+
import '../../../FooterAnimationContext/index.js';
|
|
81
|
+
import '../../../ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
82
|
+
import '../../../PasskeyContext/PasskeyContext.js';
|
|
83
|
+
import '../../../../store/state/sendBalances.js';
|
|
84
|
+
import '../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
85
|
+
import '../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
86
|
+
import '../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
87
|
+
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
88
|
+
import '../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
89
|
+
import '../../../OnrampContext/OnrampContext.js';
|
|
90
|
+
import '../../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
91
|
+
import '../../../../../index.js';
|
|
92
|
+
import '../../../../store/state/tokenBalances.js';
|
|
93
|
+
import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
94
|
+
|
|
95
|
+
/* eslint-disable prefer-destructuring */
|
|
96
|
+
/**
|
|
97
|
+
* Whenever user wallets are populated, this hook will automatically select a wallet as the primary wallet.
|
|
98
|
+
*
|
|
99
|
+
* This logic doesn't apply when embedded wallets are enabled though, as the primary wallet will be selected
|
|
100
|
+
* as the embedded wallet.
|
|
101
|
+
*/
|
|
102
|
+
const useAutoselectPrimaryWallet = (isBridgeFlow) => {
|
|
103
|
+
useInternalDynamicEvents('userWalletsPopulated', (userWallets) => {
|
|
104
|
+
if (isBridgeFlow ||
|
|
105
|
+
userWallets.some((wallet) => wallet.connector.isEmbeddedWallet))
|
|
106
|
+
return;
|
|
107
|
+
if (getPrimaryWalletId())
|
|
108
|
+
return;
|
|
109
|
+
const firstWallet = userWallets[0];
|
|
110
|
+
if (!firstWallet)
|
|
111
|
+
return;
|
|
112
|
+
updatePrimaryWalletId(firstWallet.id);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { useAutoselectPrimaryWallet };
|
|
@@ -20,6 +20,9 @@ const UserWalletsProvider = ({ children }) => {
|
|
|
20
20
|
// Use old state value if nothing changed to prevent unnecessary re-renders
|
|
21
21
|
if (updatedWallets.length === 0 && prevWallets.length === 0)
|
|
22
22
|
return prevWallets;
|
|
23
|
+
if (prevWallets.length === 0 && updatedWallets.length > 0) {
|
|
24
|
+
dynamicEvents.dynamicEvents.emit('userWalletsPopulated', updatedWallets);
|
|
25
|
+
}
|
|
23
26
|
prevUserWallets.current = prevWallets;
|
|
24
27
|
return updatedWallets;
|
|
25
28
|
});
|
|
@@ -16,6 +16,9 @@ const UserWalletsProvider = ({ children }) => {
|
|
|
16
16
|
// Use old state value if nothing changed to prevent unnecessary re-renders
|
|
17
17
|
if (updatedWallets.length === 0 && prevWallets.length === 0)
|
|
18
18
|
return prevWallets;
|
|
19
|
+
if (prevWallets.length === 0 && updatedWallets.length > 0) {
|
|
20
|
+
dynamicEvents.emit('userWalletsPopulated', updatedWallets);
|
|
21
|
+
}
|
|
19
22
|
prevUserWallets.current = prevWallets;
|
|
20
23
|
return updatedWallets;
|
|
21
24
|
});
|
|
@@ -33,4 +33,6 @@ export type WalletEvents = {
|
|
|
33
33
|
nonPrimaryWalletNetworkChanged: (newNetwork: string | number, connector: WalletConnector) => void;
|
|
34
34
|
/** Triggered when there is a change in user wallets */
|
|
35
35
|
userWalletsChanged: (params: UserWalletsChangedParams) => void;
|
|
36
|
+
/** Triggered when user wallets changes from an empty array to a non-empty array */
|
|
37
|
+
userWalletsPopulated: (userWallets: Wallet[]) => void;
|
|
36
38
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isGlobalWalletPopup } from './isGlobalWalletPopup';
|
|
@@ -41,7 +41,6 @@ const useSyncDynamicContextProps = ({ settings, emitErrors, enableInstrumentatio
|
|
|
41
41
|
// If it changes, the user should be logged out and we will detect that in useValidateSession.
|
|
42
42
|
settings.environmentId = environmentId;
|
|
43
43
|
React.useEffect(() => {
|
|
44
|
-
var _a;
|
|
45
44
|
if (environmentId === defaultDynamicSettings.PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID) {
|
|
46
45
|
logger.logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
|
|
47
46
|
}
|
|
@@ -49,7 +48,8 @@ const useSyncDynamicContextProps = ({ settings, emitErrors, enableInstrumentatio
|
|
|
49
48
|
logger.logger.setLogLevel(settings.logLevel);
|
|
50
49
|
walletConnectorCore.logger.setLogLevel(settings.logLevel);
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
const apiBaseUrl = utils.getEnvVarWithFallback('DYNAMIC_API_BASE_URL', settings.apiBaseUrl || '');
|
|
52
|
+
ApiEndpoint.setBaseUrl(apiBaseUrl);
|
|
53
53
|
setDynamicContextProps({
|
|
54
54
|
emitErrors,
|
|
55
55
|
enableInstrumentation,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import { MissingEnvironmentIdError } from '@dynamic-labs/utils';
|
|
3
|
+
import { MissingEnvironmentIdError, getEnvVarWithFallback } from '@dynamic-labs/utils';
|
|
4
4
|
import { logger as logger$1 } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import ApiEndpoint from '../../../config/ApiEndpoint.js';
|
|
6
6
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -37,7 +37,6 @@ const useSyncDynamicContextProps = ({ settings, emitErrors, enableInstrumentatio
|
|
|
37
37
|
// If it changes, the user should be logged out and we will detect that in useValidateSession.
|
|
38
38
|
settings.environmentId = environmentId;
|
|
39
39
|
useEffect(() => {
|
|
40
|
-
var _a;
|
|
41
40
|
if (environmentId === PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID) {
|
|
42
41
|
logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
|
|
43
42
|
}
|
|
@@ -45,7 +44,8 @@ const useSyncDynamicContextProps = ({ settings, emitErrors, enableInstrumentatio
|
|
|
45
44
|
logger.setLogLevel(settings.logLevel);
|
|
46
45
|
logger$1.setLogLevel(settings.logLevel);
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
const apiBaseUrl = getEnvVarWithFallback('DYNAMIC_API_BASE_URL', settings.apiBaseUrl || '');
|
|
48
|
+
ApiEndpoint.setBaseUrl(apiBaseUrl);
|
|
49
49
|
setDynamicContextProps({
|
|
50
50
|
emitErrors,
|
|
51
51
|
enableInstrumentation,
|
|
@@ -13,6 +13,9 @@ const getChainIdForMessage = (walletConnector) => _tslib.__awaiter(void 0, void
|
|
|
13
13
|
if (walletConnector.connectedChain === 'SOL') {
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
|
+
if (walletConnector.connectedChain === 'SUI') {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
16
19
|
const chain = yield walletConnector.getNetwork(true);
|
|
17
20
|
if (chain) {
|
|
18
21
|
return chain;
|
|
@@ -9,6 +9,9 @@ const getChainIdForMessage = (walletConnector) => __awaiter(void 0, void 0, void
|
|
|
9
9
|
if (walletConnector.connectedChain === 'SOL') {
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
|
+
if (walletConnector.connectedChain === 'SUI') {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
12
15
|
const chain = yield walletConnector.getNetwork(true);
|
|
13
16
|
if (chain) {
|
|
14
17
|
return chain;
|
|
@@ -182,10 +182,16 @@ const useDynamicWaas = () => {
|
|
|
182
182
|
}), [getWalletConnector, primaryChain, enabledChainNames, refresh]);
|
|
183
183
|
const shouldAutoCreateDynamicWaasWallet = React.useMemo(() => {
|
|
184
184
|
const hasDynamicWaasWallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((wallet) => { var _a; return (_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes('dynamicwaas'); });
|
|
185
|
+
const hasExistingV1orV2Wallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((wallet) => {
|
|
186
|
+
var _a, _b;
|
|
187
|
+
return ((_a = wallet.walletProperties) === null || _a === void 0 ? void 0 : _a.version) === sdkApiCore.EmbeddedWalletVersionEnum.V1 || // V1 wallet
|
|
188
|
+
((_b = wallet.walletProperties) === null || _b === void 0 ? void 0 : _b.version) === sdkApiCore.EmbeddedWalletVersionEnum.V2;
|
|
189
|
+
});
|
|
185
190
|
if (!user$1 ||
|
|
186
|
-
hasDynamicWaasWallet || // already has a dynamic waas wallet
|
|
191
|
+
hasDynamicWaasWallet || // already has a dynamic waas wallet for all enabled chains
|
|
187
192
|
!dynamicWaasIsEnabled || // dynamic waas is not enabled
|
|
188
|
-
!automaticEmbeddedWalletCreationEnabled // automatic embedded wallet creation is not enabled
|
|
193
|
+
!automaticEmbeddedWalletCreationEnabled || // automatic embedded wallet creation is not enabled
|
|
194
|
+
hasExistingV1orV2Wallet // already has a v2 or v1 wallet
|
|
189
195
|
)
|
|
190
196
|
return false;
|
|
191
197
|
const hasExternalWallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((vc) => vc.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain &&
|
|
@@ -178,10 +178,16 @@ const useDynamicWaas = () => {
|
|
|
178
178
|
}), [getWalletConnector, primaryChain, enabledChainNames, refresh]);
|
|
179
179
|
const shouldAutoCreateDynamicWaasWallet = useMemo(() => {
|
|
180
180
|
const hasDynamicWaasWallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((wallet) => { var _a; return (_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes('dynamicwaas'); });
|
|
181
|
+
const hasExistingV1orV2Wallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((wallet) => {
|
|
182
|
+
var _a, _b;
|
|
183
|
+
return ((_a = wallet.walletProperties) === null || _a === void 0 ? void 0 : _a.version) === EmbeddedWalletVersionEnum.V1 || // V1 wallet
|
|
184
|
+
((_b = wallet.walletProperties) === null || _b === void 0 ? void 0 : _b.version) === EmbeddedWalletVersionEnum.V2;
|
|
185
|
+
});
|
|
181
186
|
if (!user ||
|
|
182
|
-
hasDynamicWaasWallet || // already has a dynamic waas wallet
|
|
187
|
+
hasDynamicWaasWallet || // already has a dynamic waas wallet for all enabled chains
|
|
183
188
|
!dynamicWaasIsEnabled || // dynamic waas is not enabled
|
|
184
|
-
!automaticEmbeddedWalletCreationEnabled // automatic embedded wallet creation is not enabled
|
|
189
|
+
!automaticEmbeddedWalletCreationEnabled || // automatic embedded wallet creation is not enabled
|
|
190
|
+
hasExistingV1orV2Wallet // already has a v2 or v1 wallet
|
|
185
191
|
)
|
|
186
192
|
return false;
|
|
187
193
|
const hasExternalWallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((vc) => vc.format === JwtVerifiedCredentialFormatEnum.Blockchain &&
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
|
|
8
8
|
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, }) => React.useMemo(() => {
|
|
9
|
-
var _a, _b, _c, _d, _e;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
10
|
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
11
11
|
if (!networks)
|
|
12
12
|
return {};
|
|
@@ -15,6 +15,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
15
15
|
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
16
16
|
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
17
17
|
const eclipse = networks.find((configurations) => configurations.chainName === 'eclipse');
|
|
18
|
+
const sui = networks.find((configurations) => configurations.chainName === 'sui');
|
|
18
19
|
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, Number.parseInt));
|
|
19
20
|
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
20
21
|
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, Number.parseInt));
|
|
@@ -31,12 +32,14 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
31
32
|
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
const suiNetworks = (_f = sui === null || sui === void 0 ? void 0 : sui.networks) === null || _f === void 0 ? void 0 : _f.map((net) => createNetwork(net));
|
|
34
36
|
const networkConfigurations = {
|
|
35
37
|
cosmos: cosmosNetworks,
|
|
36
38
|
eclipse: eclipseNetworks,
|
|
37
39
|
evm: evmNetworks,
|
|
38
40
|
solana: solanaNetworks,
|
|
39
41
|
starknet: starknetNetworks,
|
|
42
|
+
sui: suiNetworks,
|
|
40
43
|
};
|
|
41
44
|
return networkConfigurations;
|
|
42
45
|
}, [
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
|
|
4
4
|
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, }) => useMemo(() => {
|
|
5
|
-
var _a, _b, _c, _d, _e;
|
|
5
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6
6
|
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
7
7
|
if (!networks)
|
|
8
8
|
return {};
|
|
@@ -11,6 +11,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
11
11
|
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
12
12
|
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
13
13
|
const eclipse = networks.find((configurations) => configurations.chainName === 'eclipse');
|
|
14
|
+
const sui = networks.find((configurations) => configurations.chainName === 'sui');
|
|
14
15
|
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, Number.parseInt));
|
|
15
16
|
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
16
17
|
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, Number.parseInt));
|
|
@@ -27,12 +28,14 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
27
28
|
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
const suiNetworks = (_f = sui === null || sui === void 0 ? void 0 : sui.networks) === null || _f === void 0 ? void 0 : _f.map((net) => createNetwork(net));
|
|
30
32
|
const networkConfigurations = {
|
|
31
33
|
cosmos: cosmosNetworks,
|
|
32
34
|
eclipse: eclipseNetworks,
|
|
33
35
|
evm: evmNetworks,
|
|
34
36
|
solana: solanaNetworks,
|
|
35
37
|
starknet: starknetNetworks,
|
|
38
|
+
sui: suiNetworks,
|
|
36
39
|
};
|
|
37
40
|
return networkConfigurations;
|
|
38
41
|
}, [
|
package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs
CHANGED
|
@@ -118,11 +118,7 @@ const ActiveWalletBalance = () => {
|
|
|
118
118
|
includeNativeBalance: true,
|
|
119
119
|
});
|
|
120
120
|
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
121
|
-
const filteredTokenBalances = React.useMemo(() =>
|
|
122
|
-
const balances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [];
|
|
123
|
-
balances.sort((a, b) => ((b === null || b === void 0 ? void 0 : b.marketValue) || 0) - ((a === null || a === void 0 ? void 0 : a.marketValue) || 0));
|
|
124
|
-
return balances;
|
|
125
|
-
}, [tokenBalances]);
|
|
121
|
+
const filteredTokenBalances = React.useMemo(() => (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [], [tokenBalances]);
|
|
126
122
|
const totalValue = React.useMemo(() => filteredTokenBalances.reduce((acc, token) => acc + ((token === null || token === void 0 ? void 0 : token.marketValue) || 0), 0), [filteredTokenBalances]);
|
|
127
123
|
const enableMultiAsset = (authMode === 'connect-and-sign' ||
|
|
128
124
|
(authMode === 'connect-only' &&
|
|
@@ -114,11 +114,7 @@ const ActiveWalletBalance = () => {
|
|
|
114
114
|
includeNativeBalance: true,
|
|
115
115
|
});
|
|
116
116
|
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
117
|
-
const filteredTokenBalances = useMemo(() =>
|
|
118
|
-
const balances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [];
|
|
119
|
-
balances.sort((a, b) => ((b === null || b === void 0 ? void 0 : b.marketValue) || 0) - ((a === null || a === void 0 ? void 0 : a.marketValue) || 0));
|
|
120
|
-
return balances;
|
|
121
|
-
}, [tokenBalances]);
|
|
117
|
+
const filteredTokenBalances = useMemo(() => (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [], [tokenBalances]);
|
|
122
118
|
const totalValue = useMemo(() => filteredTokenBalances.reduce((acc, token) => acc + ((token === null || token === void 0 ? void 0 : token.marketValue) || 0), 0), [filteredTokenBalances]);
|
|
123
119
|
const enableMultiAsset = (authMode === 'connect-and-sign' ||
|
|
124
120
|
(authMode === 'connect-only' &&
|