@dynamic-labs/sdk-react-core 3.0.0-alpha.6 → 3.0.0-alpha.7
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 +23 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/index.cjs +7 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +4 -1
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +14 -8
- package/src/lib/context/DynamicContext/DynamicContext.js +14 -8
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +15 -6
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +15 -6
- package/src/lib/context/DynamicContext/types/index.d.ts +4 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +3 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +3 -2
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.cjs +128 -0
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.d.ts +6 -0
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.js +122 -0
- package/src/lib/context/WidgetRegistry/index.d.ts +1 -0
- package/src/lib/data/api/wallets/wallets.cjs +2 -1
- package/src/lib/data/api/wallets/wallets.d.ts +2 -1
- package/src/lib/data/api/wallets/wallets.js +2 -1
- package/src/lib/events/dynamicEvents.d.ts +2 -1
- package/src/lib/events/multiWallet.d.ts +5 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/index.d.ts +1 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.cjs +28 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.d.ts +1 -0
- package/src/lib/utils/functions/logVerboseTroubleshootingMessage/logVerboseTroubleshootingMessage.js +24 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs +20 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +2 -2
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.js +20 -1
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +3 -1
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +3 -1
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +6 -2
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +6 -2
- package/src/lib/utils/hooks/useRefreshUser/index.d.ts +1 -0
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.cjs +90 -0
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.d.ts +8 -0
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.js +86 -0
- package/src/lib/utils/hooks/useSwitchNetwork/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.cjs +26 -0
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.d.ts +5 -0
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.js +22 -0
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +7 -6
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +7 -6
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +44 -27
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +45 -28
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +4 -14
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +5 -15
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +3 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +3 -1
- package/src/lib/views/WalletList/WalletList.cjs +1 -3
- package/src/lib/views/WalletList/WalletList.js +1 -3
- package/src/lib/views/WalletList/hooks/useTabState.cjs +6 -81
- package/src/lib/views/WalletList/hooks/useTabState.d.ts +6 -3
- package/src/lib/views/WalletList/hooks/useTabState.js +6 -81
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.cjs +5 -5
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.js +5 -5
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.cjs +4 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.js +4 -1
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +1 -1
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.cjs +0 -22
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.d.ts +0 -2
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.js +0 -18
- package/src/lib/views/WalletList/utils/getInitialTabIndex/index.d.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { IDynamicContext } from '../types';
|
|
3
|
-
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'getNameService' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | 'loadingNetwork' | 'locale' | 'loginWithEmail' | 'multiWalletWidgetState' | 'network' | 'networkConfigurations' | 'primaryWallet' | 'qrcodeUri' | 'sdkHasLoaded' | 'setLogInWithEmail' | 'setMultiWalletWidgetState' | 'setPrimaryWallet' | 'setShowDynamicUserProfile' | 'setShowQrcodeModal' | 'shadowDOMEnabled' | 'showAuthFlow' | 'showQrcodeModal' | 'user' | 'walletConnector' | 'walletConnectorOptions' | 'bridgeChains' | 'bridgeChainsToConnect' | 'setShowBridgeWidget' | 'sendWagmiSettings' | 'showDynamicUserProfile' | 'setAuthMode' | 'minAuthToken' | '
|
|
3
|
+
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'getNameService' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | 'loadingNetwork' | 'locale' | 'loginWithEmail' | 'multiWalletWidgetState' | 'network' | 'networkConfigurations' | 'primaryWallet' | 'qrcodeUri' | 'sdkHasLoaded' | 'setLogInWithEmail' | 'setMultiWalletWidgetState' | 'setPrimaryWallet' | 'setShowDynamicUserProfile' | 'setShowQrcodeModal' | 'shadowDOMEnabled' | 'showAuthFlow' | 'showQrcodeModal' | 'user' | 'walletConnector' | 'walletConnectorOptions' | 'bridgeChains' | 'bridgeChainsToConnect' | 'setShowBridgeWidget' | 'sendWagmiSettings' | 'showDynamicUserProfile' | 'setAuthMode' | 'minAuthToken' | 'selectedTabIndex' | 'setSelectedTabIndex'> & {
|
|
4
4
|
setShowAuthFlow: Dispatch<SetStateAction<boolean>>;
|
|
5
5
|
};
|
|
6
6
|
export declare const useDynamicContext: () => UseDynamicContext;
|
|
@@ -9,7 +9,7 @@ const useDynamicContext = () => {
|
|
|
9
9
|
if (context === undefined) {
|
|
10
10
|
throw new Error('useDynamicContext must be used within a DynamicContextProvider');
|
|
11
11
|
}
|
|
12
|
-
const { accountSwitchState, authMode, authToken, awaitingSignatureState, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, loadingNetwork, locale, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, sdkHasLoaded, setLogInWithEmail, setMultiWalletWidgetState, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, walletConnectorOptions, bridgeChains, bridgeChainsToConnect, primaryWallet, setShowBridgeWidget, sendWagmiSettings, showDynamicUserProfile, minAuthToken,
|
|
12
|
+
const { accountSwitchState, authMode, authToken, awaitingSignatureState, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, loadingNetwork, locale, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, sdkHasLoaded, setLogInWithEmail, setMultiWalletWidgetState, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, walletConnectorOptions, bridgeChains, bridgeChainsToConnect, primaryWallet, setShowBridgeWidget, sendWagmiSettings, showDynamicUserProfile, minAuthToken, selectedTabIndex, setSelectedTabIndex, } = context;
|
|
13
13
|
const { setAuthMode } = useOverrides(context);
|
|
14
14
|
return {
|
|
15
15
|
accountSwitchState,
|
|
@@ -32,12 +32,13 @@ const useDynamicContext = () => {
|
|
|
32
32
|
primaryWallet,
|
|
33
33
|
qrcodeUri,
|
|
34
34
|
sdkHasLoaded,
|
|
35
|
+
selectedTabIndex,
|
|
35
36
|
sendWagmiSettings,
|
|
36
37
|
setAuthMode,
|
|
37
|
-
setDefaultTabIndex,
|
|
38
38
|
setLogInWithEmail,
|
|
39
39
|
setMultiWalletWidgetState,
|
|
40
40
|
setPrimaryWallet,
|
|
41
|
+
setSelectedTabIndex,
|
|
41
42
|
setShowAuthFlow: (value) => setShowAuthFlow(value, {
|
|
42
43
|
clearErrors: true,
|
|
43
44
|
emitCancelAuth: true,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
9
|
+
require('@dynamic-labs/sdk-api-core');
|
|
10
|
+
require('../../utils/constants/values.cjs');
|
|
11
|
+
require('@dynamic-labs/utils');
|
|
12
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
13
|
+
require('@dynamic-labs/multi-wallet');
|
|
14
|
+
require('../../shared/logger.cjs');
|
|
15
|
+
require('@dynamic-labs/iconic');
|
|
16
|
+
require('../ViewContext/ViewContext.cjs');
|
|
17
|
+
require('@dynamic-labs/wallet-book');
|
|
18
|
+
require('../../utils/constants/colors.cjs');
|
|
19
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
|
+
require('../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
21
|
+
require('../../shared/consts/index.cjs');
|
|
22
|
+
require('react-international-phone');
|
|
23
|
+
require('../../config/ApiEndpoint.cjs');
|
|
24
|
+
require('@dynamic-labs/store');
|
|
25
|
+
require('../../locale/locale.cjs');
|
|
26
|
+
var randomString = require('../../utils/functions/randomString/randomString.cjs');
|
|
27
|
+
require('../../events/dynamicEvents.cjs');
|
|
28
|
+
require('../DynamicContext/DynamicContext.cjs');
|
|
29
|
+
require('../CaptchaContext/CaptchaContext.cjs');
|
|
30
|
+
require('../ErrorContext/ErrorContext.cjs');
|
|
31
|
+
require('../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
32
|
+
require('../AccountExistsContext/AccountExistsContext.cjs');
|
|
33
|
+
require('../UserWalletsContext/UserWalletsContext.cjs');
|
|
34
|
+
require('../VerificationContext/VerificationContext.cjs');
|
|
35
|
+
require('react-dom');
|
|
36
|
+
require('../WalletContext/WalletContext.cjs');
|
|
37
|
+
require('../ThemeContext/ThemeContext.cjs');
|
|
38
|
+
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
39
|
+
require('@dynamic-labs/types');
|
|
40
|
+
require('../LoadingContext/LoadingContext.cjs');
|
|
41
|
+
require('yup');
|
|
42
|
+
require('../MockContext/MockContext.cjs');
|
|
43
|
+
require('../../views/CollectUserDataView/useFields.cjs');
|
|
44
|
+
require('../FieldsStateContext/FieldsStateContext.cjs');
|
|
45
|
+
require('../UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
46
|
+
require('@dynamic-labs/rpc-providers');
|
|
47
|
+
require('react-i18next');
|
|
48
|
+
require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
49
|
+
require('../../components/Alert/Alert.cjs');
|
|
50
|
+
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
51
|
+
require('../../components/IconButton/IconButton.cjs');
|
|
52
|
+
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
53
|
+
require('../../components/Input/Input.cjs');
|
|
54
|
+
require('../../components/IsBrowser/IsBrowser.cjs');
|
|
55
|
+
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
56
|
+
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
57
|
+
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
58
|
+
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
59
|
+
require('../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
60
|
+
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
61
|
+
require('../../components/Popper/Popper/Popper.cjs');
|
|
62
|
+
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
63
|
+
require('react-focus-lock');
|
|
64
|
+
require('qrcode');
|
|
65
|
+
require('formik');
|
|
66
|
+
require('../../views/WalletList/WalletList.cjs');
|
|
67
|
+
require('../SocialRedirectContext/SocialRedirectContext.cjs');
|
|
68
|
+
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
69
|
+
require('@hcaptcha/react-hcaptcha');
|
|
70
|
+
require('../FooterAnimationContext/index.cjs');
|
|
71
|
+
require('../WalletGroupContext/WalletGroupContext.cjs');
|
|
72
|
+
require('../MfaSettingsContext/MfaSettingsContext.cjs');
|
|
73
|
+
require('../IpConfigurationContext/IpConfigurationContext.cjs');
|
|
74
|
+
require('../PasskeyContext/PasskeyContext.cjs');
|
|
75
|
+
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
76
|
+
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
77
|
+
require('../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
78
|
+
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
79
|
+
|
|
80
|
+
const widgetRegistryContext = React.createContext(null);
|
|
81
|
+
const WidgetRegistryContextProvider = ({ children, }) => {
|
|
82
|
+
const [registry, setRegistry] = React.useState({});
|
|
83
|
+
const registerId = React.useCallback((widgetId, widgetType) => {
|
|
84
|
+
setRegistry((prevRegistry) => (Object.assign(Object.assign({}, prevRegistry), { [widgetId]: {
|
|
85
|
+
type: widgetType,
|
|
86
|
+
} })));
|
|
87
|
+
}, [setRegistry]);
|
|
88
|
+
const removeId = React.useCallback((widgetId) => {
|
|
89
|
+
setRegistry((prevRegistry) => {
|
|
90
|
+
const newRegistry = Object.assign({}, prevRegistry);
|
|
91
|
+
delete newRegistry[widgetId];
|
|
92
|
+
return newRegistry;
|
|
93
|
+
});
|
|
94
|
+
}, [setRegistry]);
|
|
95
|
+
const checkWidgetPresence = React.useCallback((widgetType) => Object.values(registry).some((widget) => widget.type === widgetType), [registry]);
|
|
96
|
+
return (jsxRuntime.jsx(widgetRegistryContext.Provider, { value: { checkWidgetPresence, registerId, removeId }, children: children }));
|
|
97
|
+
};
|
|
98
|
+
const useWidgetRegistry = () => {
|
|
99
|
+
const context = React.useContext(widgetRegistryContext);
|
|
100
|
+
if (context === null) {
|
|
101
|
+
throw new Error('usage of useWidgetRegistry not wrapped in `WidgetRegistryContextProvider`.');
|
|
102
|
+
}
|
|
103
|
+
return context;
|
|
104
|
+
};
|
|
105
|
+
const useRegisterWidget = (widgetType, enabled = true) => {
|
|
106
|
+
const idRef = React.useRef(randomString.randomString(8));
|
|
107
|
+
const { registerId, removeId } = useWidgetRegistry();
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
if (enabled === false) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
registerId(idRef.current, widgetType);
|
|
113
|
+
return () => {
|
|
114
|
+
// This is disabled because eslint think we are using state value
|
|
115
|
+
// but this is fine because it is a ref
|
|
116
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
|
+
removeId(idRef.current);
|
|
118
|
+
};
|
|
119
|
+
}, [widgetType, enabled, registerId, removeId]);
|
|
120
|
+
};
|
|
121
|
+
const useWidgetRegistryCheck = (widgetType) => {
|
|
122
|
+
const { checkWidgetPresence } = useWidgetRegistry();
|
|
123
|
+
return checkWidgetPresence(widgetType);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
exports.WidgetRegistryContextProvider = WidgetRegistryContextProvider;
|
|
127
|
+
exports.useRegisterWidget = useRegisterWidget;
|
|
128
|
+
exports.useWidgetRegistryCheck = useWidgetRegistryCheck;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
type WidgetType = 'user-profile';
|
|
3
|
+
export declare const WidgetRegistryContextProvider: FC<PropsWithChildren>;
|
|
4
|
+
export declare const useRegisterWidget: (widgetType: WidgetType, enabled?: boolean) => void;
|
|
5
|
+
export declare const useWidgetRegistryCheck: (widgetType: WidgetType) => boolean;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { createContext, useState, useCallback, useContext, useRef, useEffect } from 'react';
|
|
4
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import '../../utils/constants/values.js';
|
|
7
|
+
import '@dynamic-labs/utils';
|
|
8
|
+
import '../../../../_virtual/_tslib.js';
|
|
9
|
+
import '@dynamic-labs/multi-wallet';
|
|
10
|
+
import '../../shared/logger.js';
|
|
11
|
+
import '@dynamic-labs/iconic';
|
|
12
|
+
import '../ViewContext/ViewContext.js';
|
|
13
|
+
import '@dynamic-labs/wallet-book';
|
|
14
|
+
import '../../utils/constants/colors.js';
|
|
15
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
+
import '../../shared/utils/classes/storage/sessionStorage.js';
|
|
17
|
+
import '../../shared/consts/index.js';
|
|
18
|
+
import 'react-international-phone';
|
|
19
|
+
import '../../config/ApiEndpoint.js';
|
|
20
|
+
import '@dynamic-labs/store';
|
|
21
|
+
import '../../locale/locale.js';
|
|
22
|
+
import { randomString } from '../../utils/functions/randomString/randomString.js';
|
|
23
|
+
import '../../events/dynamicEvents.js';
|
|
24
|
+
import '../DynamicContext/DynamicContext.js';
|
|
25
|
+
import '../CaptchaContext/CaptchaContext.js';
|
|
26
|
+
import '../ErrorContext/ErrorContext.js';
|
|
27
|
+
import '../AccessDeniedContext/AccessDeniedContext.js';
|
|
28
|
+
import '../AccountExistsContext/AccountExistsContext.js';
|
|
29
|
+
import '../UserWalletsContext/UserWalletsContext.js';
|
|
30
|
+
import '../VerificationContext/VerificationContext.js';
|
|
31
|
+
import 'react-dom';
|
|
32
|
+
import '../WalletContext/WalletContext.js';
|
|
33
|
+
import '../ThemeContext/ThemeContext.js';
|
|
34
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
35
|
+
import '@dynamic-labs/types';
|
|
36
|
+
import '../LoadingContext/LoadingContext.js';
|
|
37
|
+
import 'yup';
|
|
38
|
+
import '../MockContext/MockContext.js';
|
|
39
|
+
import '../../views/CollectUserDataView/useFields.js';
|
|
40
|
+
import '../FieldsStateContext/FieldsStateContext.js';
|
|
41
|
+
import '../UserFieldEditorContext/UserFieldEditorContext.js';
|
|
42
|
+
import '@dynamic-labs/rpc-providers';
|
|
43
|
+
import 'react-i18next';
|
|
44
|
+
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
45
|
+
import '../../components/Alert/Alert.js';
|
|
46
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
47
|
+
import '../../components/IconButton/IconButton.js';
|
|
48
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
49
|
+
import '../../components/Input/Input.js';
|
|
50
|
+
import '../../components/IsBrowser/IsBrowser.js';
|
|
51
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
52
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
53
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
54
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
55
|
+
import '../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
56
|
+
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
57
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
58
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
59
|
+
import 'react-focus-lock';
|
|
60
|
+
import 'qrcode';
|
|
61
|
+
import 'formik';
|
|
62
|
+
import '../../views/WalletList/WalletList.js';
|
|
63
|
+
import '../SocialRedirectContext/SocialRedirectContext.js';
|
|
64
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
65
|
+
import '@hcaptcha/react-hcaptcha';
|
|
66
|
+
import '../FooterAnimationContext/index.js';
|
|
67
|
+
import '../WalletGroupContext/WalletGroupContext.js';
|
|
68
|
+
import '../MfaSettingsContext/MfaSettingsContext.js';
|
|
69
|
+
import '../IpConfigurationContext/IpConfigurationContext.js';
|
|
70
|
+
import '../PasskeyContext/PasskeyContext.js';
|
|
71
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
72
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
73
|
+
import '../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
74
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
75
|
+
|
|
76
|
+
const widgetRegistryContext = createContext(null);
|
|
77
|
+
const WidgetRegistryContextProvider = ({ children, }) => {
|
|
78
|
+
const [registry, setRegistry] = useState({});
|
|
79
|
+
const registerId = useCallback((widgetId, widgetType) => {
|
|
80
|
+
setRegistry((prevRegistry) => (Object.assign(Object.assign({}, prevRegistry), { [widgetId]: {
|
|
81
|
+
type: widgetType,
|
|
82
|
+
} })));
|
|
83
|
+
}, [setRegistry]);
|
|
84
|
+
const removeId = useCallback((widgetId) => {
|
|
85
|
+
setRegistry((prevRegistry) => {
|
|
86
|
+
const newRegistry = Object.assign({}, prevRegistry);
|
|
87
|
+
delete newRegistry[widgetId];
|
|
88
|
+
return newRegistry;
|
|
89
|
+
});
|
|
90
|
+
}, [setRegistry]);
|
|
91
|
+
const checkWidgetPresence = useCallback((widgetType) => Object.values(registry).some((widget) => widget.type === widgetType), [registry]);
|
|
92
|
+
return (jsx(widgetRegistryContext.Provider, { value: { checkWidgetPresence, registerId, removeId }, children: children }));
|
|
93
|
+
};
|
|
94
|
+
const useWidgetRegistry = () => {
|
|
95
|
+
const context = useContext(widgetRegistryContext);
|
|
96
|
+
if (context === null) {
|
|
97
|
+
throw new Error('usage of useWidgetRegistry not wrapped in `WidgetRegistryContextProvider`.');
|
|
98
|
+
}
|
|
99
|
+
return context;
|
|
100
|
+
};
|
|
101
|
+
const useRegisterWidget = (widgetType, enabled = true) => {
|
|
102
|
+
const idRef = useRef(randomString(8));
|
|
103
|
+
const { registerId, removeId } = useWidgetRegistry();
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (enabled === false) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
registerId(idRef.current, widgetType);
|
|
109
|
+
return () => {
|
|
110
|
+
// This is disabled because eslint think we are using state value
|
|
111
|
+
// but this is fine because it is a ref
|
|
112
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
+
removeId(idRef.current);
|
|
114
|
+
};
|
|
115
|
+
}, [widgetType, enabled, registerId, removeId]);
|
|
116
|
+
};
|
|
117
|
+
const useWidgetRegistryCheck = (widgetType) => {
|
|
118
|
+
const { checkWidgetPresence } = useWidgetRegistry();
|
|
119
|
+
return checkWidgetPresence(widgetType);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { WidgetRegistryContextProvider, useRegisterWidget, useWidgetRegistryCheck };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetRegistryContextProvider, useRegisterWidget, useWidgetRegistryCheck, } from './WidgetRegistryContextProvider';
|
|
@@ -76,7 +76,7 @@ const linkWallet = (environmentId_1, _b) => _tslib.__awaiter(void 0, [environmen
|
|
|
76
76
|
throw new utils.DynamicError(data.error);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
-
const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
79
|
+
const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, onSuccess, }) {
|
|
80
80
|
try {
|
|
81
81
|
const response = yield api.sdkApi().verifyUnlink({
|
|
82
82
|
environmentId,
|
|
@@ -85,6 +85,7 @@ const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({
|
|
|
85
85
|
walletId,
|
|
86
86
|
},
|
|
87
87
|
});
|
|
88
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
88
89
|
const user = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
89
90
|
return user;
|
|
90
91
|
}
|
|
@@ -6,10 +6,11 @@ export declare const storeSelectedWallet: ({ environmentId, walletId, }: {
|
|
|
6
6
|
walletId: string;
|
|
7
7
|
}) => Promise<UserProfile | undefined>;
|
|
8
8
|
export declare const linkWallet: (environmentId: string, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, password, passwordSource, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
9
|
-
export declare const unlinkWallet: ({ environmentId, primaryWalletId, walletId, }: {
|
|
9
|
+
export declare const unlinkWallet: ({ environmentId, primaryWalletId, walletId, onSuccess, }: {
|
|
10
10
|
environmentId: string;
|
|
11
11
|
primaryWalletId: string | undefined;
|
|
12
12
|
walletId: string;
|
|
13
|
+
onSuccess?: () => void;
|
|
13
14
|
}) => Promise<UserProfile | undefined>;
|
|
14
15
|
export declare const transferWallet: (environmentId: string, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck, }: VerifyWallet) => Promise<UserProfile | undefined>;
|
|
15
16
|
export declare const verifyWallet: (environmentId: string, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, additionalWalletAddresses, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
@@ -72,7 +72,7 @@ const linkWallet = (environmentId_1, _b) => __awaiter(void 0, [environmentId_1,
|
|
|
72
72
|
throw new DynamicError(data.error);
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
-
const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
75
|
+
const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, onSuccess, }) {
|
|
76
76
|
try {
|
|
77
77
|
const response = yield sdkApi().verifyUnlink({
|
|
78
78
|
environmentId,
|
|
@@ -81,6 +81,7 @@ const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ enviro
|
|
|
81
81
|
walletId,
|
|
82
82
|
},
|
|
83
83
|
});
|
|
84
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
84
85
|
const user = storeAuthTokenAndUser(response);
|
|
85
86
|
return user;
|
|
86
87
|
}
|
|
@@ -6,7 +6,8 @@ import { PasskeyEvents } from './passkey';
|
|
|
6
6
|
import { SocialEvents } from './social';
|
|
7
7
|
import { UIEvents } from './ui';
|
|
8
8
|
import { WalletEvents } from './wallets';
|
|
9
|
+
import { MultiWalletInternalEvents } from './multiWallet';
|
|
9
10
|
/** Maps internal event names to their listeners */
|
|
10
|
-
export type DynamicEvents = AuthEvents & UIEvents & OTPEvents & WalletEvents & PasskeyEvents & SocialEvents & EmbeddedWalletEvents;
|
|
11
|
+
export type DynamicEvents = AuthEvents & UIEvents & OTPEvents & WalletEvents & PasskeyEvents & SocialEvents & EmbeddedWalletEvents & MultiWalletInternalEvents;
|
|
11
12
|
export declare const dynamicEvents: EventEmitter<DynamicEvents, any>;
|
|
12
13
|
export type DynamicEventEmitter = typeof dynamicEvents;
|