@dynamic-labs/sdk-react-core 2.2.2 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -2
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +2 -1
- package/src/lib/context/WalletContext/WalletContext.cjs +1 -1
- package/src/lib/context/WalletContext/WalletContext.js +1 -1
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.cjs +77 -0
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.d.ts +6 -0
- package/src/lib/context/WidgetRegistry/WidgetRegistryContextProvider.js +71 -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 +6 -0
- package/src/lib/locale/en/translation.cjs +2 -2
- package/src/lib/locale/en/translation.d.ts +1 -1
- package/src/lib/locale/en/translation.js +2 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +39 -13
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +40 -14
- 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/useWalletConnectors/useWalletConnectors.cjs +1 -6
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +1 -6
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +69 -25
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +70 -26
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +20 -1
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +20 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +4 -14
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +5 -15
- package/src/lib/views/SelectHardwareWalletView/SelectHardwareWalletView.cjs +1 -5
- package/src/lib/views/SelectHardwareWalletView/SelectHardwareWalletView.js +2 -6
- package/src/lib/views/WalletGroupView/WalletGroupView.cjs +1 -6
- package/src/lib/views/WalletGroupView/WalletGroupView.js +2 -7
- 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/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
|
|
2
|
+
### [2.2.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.3...v2.2.4) (2024-06-21)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* always reconnect the wallet provider when calling getAddress ([#6097](https://github.com/dynamic-labs/DynamicAuth/issues/6097)) ([#6099](https://github.com/dynamic-labs/DynamicAuth/issues/6099)) ([428de7c](https://github.com/dynamic-labs/DynamicAuth/commit/428de7c67a61c2078566e2b967aef018282ad88a))
|
|
8
|
+
* set latest blockhash on solana transactions if tx confirmation ui is disabled ([#6102](https://github.com/dynamic-labs/DynamicAuth/issues/6102)) ([#6109](https://github.com/dynamic-labs/DynamicAuth/issues/6109)) ([01a25ed](https://github.com/dynamic-labs/DynamicAuth/commit/01a25ed37498c8046022483fdeb2ce572bd2d5c6))
|
|
9
|
+
* silently query unisat accounts ([#6101](https://github.com/dynamic-labs/DynamicAuth/issues/6101)) ([5402518](https://github.com/dynamic-labs/DynamicAuth/commit/5402518bb91c3ec02eee2f0bdd97d90a33d5d9f7))
|
|
10
|
+
* trigger sign when linking an already linked unknown wallet ([#6111](https://github.com/dynamic-labs/DynamicAuth/issues/6111)) ([9602055](https://github.com/dynamic-labs/DynamicAuth/commit/9602055527b5430e7a98e8836b585ead240bf1d7))
|
|
11
|
+
|
|
12
|
+
### [2.2.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.2...v2.2.3) (2024-06-19)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* return userWallets connected state async ([#6080](https://github.com/dynamic-labs/DynamicAuth/issues/6080)) ([6ffa444](https://github.com/dynamic-labs/DynamicAuth/commit/6ffa444ad374d1923a07bbc12191455cb3a1d276))
|
|
18
|
+
* ensure multi wallet prompts widget will not overlay the merge accounts UI ([#6087](https://github.com/dynamic-labs/DynamicAuth/issues/6087)) ([582f44f](https://github.com/dynamic-labs/DynamicAuth/commit/582f44f48b4d93917c4b20e9e6b4bbbfe4e4f94f))
|
|
19
|
+
* stop querying okx for accounts while locked ([#6081](https://github.com/dynamic-labs/DynamicAuth/issues/6081)) ([3374e38](https://github.com/dynamic-labs/DynamicAuth/commit/3374e38e2006f795809233de5bc03904d106bd2d))
|
|
20
|
+
* update copy for primary wallet not connected modal ([#6070](https://github.com/dynamic-labs/DynamicAuth/issues/6070)) ([d0466e1](https://github.com/dynamic-labs/DynamicAuth/commit/d0466e19f386adcd0ed83e73f783cfe827e1b94d))
|
|
21
|
+
|
|
2
22
|
### [2.2.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.1...v2.2.2) (2024-06-18)
|
|
3
23
|
|
|
4
24
|
|
|
5
25
|
### Bug Fixes
|
|
6
26
|
|
|
7
|
-
* make account change
|
|
27
|
+
* make phantom BTC account change requests idempotent ([#6062](https://github.com/dynamic-labs/DynamicAuth/issues/6062)) ([2308d32](https://github.com/dynamic-labs/DynamicAuth/commit/2308d32d18627f2673c8f4c9b5623a9c731e4752))
|
|
8
28
|
|
|
9
29
|
### [2.2.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0...v2.2.1) (2024-06-17)
|
|
10
30
|
|
|
@@ -101,7 +121,7 @@
|
|
|
101
121
|
|
|
102
122
|
- React Native - You can now build mobile-first onboarding experiences with the same Dynamic magic but for React Native, get started [here](https://docs.dynamic.xyz/react-native/introduction)
|
|
103
123
|
|
|
104
|
-
- Cookie Authentication - Dynamic can now be configured to set a secure, HttpOnly cookie that can be used for authenticating with Dynamic’s backend. This will contain a minified version of our JWT token.
|
|
124
|
+
- Cookie Authentication - Dynamic can now be configured to set a secure, HttpOnly cookie that can be used for authenticating with Dynamic’s backend. This will contain a minified version of our JWT token.
|
|
105
125
|
|
|
106
126
|
|
|
107
127
|
## Improvements
|
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": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "2.2.
|
|
21
|
-
"@dynamic-labs/logger": "2.2.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "2.2.
|
|
23
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.2.
|
|
24
|
-
"@dynamic-labs/rpc-provider-solana": "2.2.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "2.2.
|
|
26
|
-
"@dynamic-labs/store": "2.2.
|
|
27
|
-
"@dynamic-labs/types": "2.2.
|
|
28
|
-
"@dynamic-labs/utils": "2.2.
|
|
29
|
-
"@dynamic-labs/viem-utils": "2.2.
|
|
30
|
-
"@dynamic-labs/wallet-book": "2.2.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "2.2.
|
|
20
|
+
"@dynamic-labs/iconic": "2.2.4",
|
|
21
|
+
"@dynamic-labs/logger": "2.2.4",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.2.4",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.2.4",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.2.4",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.2.4",
|
|
26
|
+
"@dynamic-labs/store": "2.2.4",
|
|
27
|
+
"@dynamic-labs/types": "2.2.4",
|
|
28
|
+
"@dynamic-labs/utils": "2.2.4",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.2.4",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.2.4",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.2.4",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
package/src/lib/Main.cjs
CHANGED
|
@@ -84,6 +84,7 @@ var SocialRedirectContext = require('./context/SocialRedirectContext/SocialRedir
|
|
|
84
84
|
require('./context/WalletGroupContext/WalletGroupContext.cjs');
|
|
85
85
|
require('./widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
86
86
|
require('./widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
87
|
+
require('./context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
87
88
|
require('./context/FundingContext/FundingContext.cjs');
|
|
88
89
|
require('./views/WalletList/WalletList.cjs');
|
|
89
90
|
require('./widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
package/src/lib/Main.js
CHANGED
|
@@ -80,6 +80,7 @@ import { useSocialRedirectContext } from './context/SocialRedirectContext/Social
|
|
|
80
80
|
import './context/WalletGroupContext/WalletGroupContext.js';
|
|
81
81
|
import './widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
82
82
|
import './widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
83
|
+
import './context/WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
83
84
|
import './context/FundingContext/FundingContext.js';
|
|
84
85
|
import './views/WalletList/WalletList.js';
|
|
85
86
|
import './widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
@@ -104,6 +104,7 @@ require('../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetC
|
|
|
104
104
|
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
105
105
|
require('../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
106
106
|
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
107
|
+
var WidgetRegistryContextProvider = require('../WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
107
108
|
var FundingWidget = require('../../widgets/FundingWidget/FundingWidget.cjs');
|
|
108
109
|
var ConnectWithOtpProvider = require('../ConnectWithOtpContext/ConnectWithOtpProvider.cjs');
|
|
109
110
|
require('../ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
@@ -707,7 +708,7 @@ const DynamicContextProvider = (props) => {
|
|
|
707
708
|
logger.Logger.setEnvironmentId(props.settings.environmentId);
|
|
708
709
|
logger.Logger.setEmitErrors(props.emitErrors);
|
|
709
710
|
useParentDynamicContextGuard.useParentDynamicContextGuard();
|
|
710
|
-
return (jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { children: jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(UserWalletsContext.UserWalletsProvider, { children: jsxRuntime.jsx(FieldsStateContext.FieldsStateProvider, { children: jsxRuntime.jsx(IpConfigurationContext.IpConfigurationContextProvider, { children: jsxRuntime.jsx(MfaSettingsContext.MfaSettingsContextProvider, { children: jsxRuntime.jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }) }) }) }));
|
|
711
|
+
return (jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { children: jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(UserWalletsContext.UserWalletsProvider, { children: jsxRuntime.jsx(FieldsStateContext.FieldsStateProvider, { children: jsxRuntime.jsx(IpConfigurationContext.IpConfigurationContextProvider, { children: jsxRuntime.jsx(MfaSettingsContext.MfaSettingsContextProvider, { children: jsxRuntime.jsx(WidgetRegistryContextProvider.WidgetRegistryContextProvider, { children: jsxRuntime.jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }) }) }) }) }));
|
|
711
712
|
};
|
|
712
713
|
|
|
713
714
|
exports.DynamicContext = DynamicContext;
|
|
@@ -100,6 +100,7 @@ import '../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetCa
|
|
|
100
100
|
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
101
101
|
import '../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
102
102
|
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
103
|
+
import { WidgetRegistryContextProvider } from '../WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
103
104
|
import { FundingWidget } from '../../widgets/FundingWidget/FundingWidget.js';
|
|
104
105
|
import { ConnectWithOtpProvider } from '../ConnectWithOtpContext/ConnectWithOtpProvider.js';
|
|
105
106
|
import '../ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
@@ -703,7 +704,7 @@ const DynamicContextProvider = (props) => {
|
|
|
703
704
|
Logger.setEnvironmentId(props.settings.environmentId);
|
|
704
705
|
Logger.setEmitErrors(props.emitErrors);
|
|
705
706
|
useParentDynamicContextGuard();
|
|
706
|
-
return (jsx(ErrorBoundary, { children: jsx(ErrorContextProvider, { children: jsx(UserWalletsProvider, { children: jsx(FieldsStateProvider, { children: jsx(IpConfigurationContextProvider, { children: jsx(MfaSettingsContextProvider, { children: jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }) }) }) }));
|
|
707
|
+
return (jsx(ErrorBoundary, { children: jsx(ErrorContextProvider, { children: jsx(UserWalletsProvider, { children: jsx(FieldsStateProvider, { children: jsx(IpConfigurationContextProvider, { children: jsx(MfaSettingsContextProvider, { children: jsx(WidgetRegistryContextProvider, { children: jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }) }) }) }) }));
|
|
707
708
|
};
|
|
708
709
|
|
|
709
710
|
export { DynamicContext, DynamicContextProvider, InnerDynamicContextProvider, PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID };
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
8
9
|
require('../DynamicContext/DynamicContext.cjs');
|
|
9
10
|
require('@dynamic-labs/sdk-api-core');
|
|
10
11
|
require('../../shared/logger.cjs');
|
|
@@ -18,7 +19,6 @@ require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
18
19
|
require('@dynamic-labs/utils');
|
|
19
20
|
require('../../shared/consts/index.cjs');
|
|
20
21
|
require('../../events/dynamicEvents.cjs');
|
|
21
|
-
require('../../../../_virtual/_tslib.cjs');
|
|
22
22
|
require('../CaptchaContext/CaptchaContext.cjs');
|
|
23
23
|
require('../ErrorContext/ErrorContext.cjs');
|
|
24
24
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { createContext, useContext, useState, useMemo } from 'react';
|
|
4
|
+
import '../../../../_virtual/_tslib.js';
|
|
4
5
|
import '../DynamicContext/DynamicContext.js';
|
|
5
6
|
import '@dynamic-labs/sdk-api-core';
|
|
6
7
|
import '../../shared/logger.js';
|
|
@@ -14,7 +15,6 @@ import '../../shared/utils/classes/storage/localStorage.js';
|
|
|
14
15
|
import '@dynamic-labs/utils';
|
|
15
16
|
import '../../shared/consts/index.js';
|
|
16
17
|
import '../../events/dynamicEvents.js';
|
|
17
|
-
import '../../../../_virtual/_tslib.js';
|
|
18
18
|
import '../CaptchaContext/CaptchaContext.js';
|
|
19
19
|
import '../ErrorContext/ErrorContext.js';
|
|
20
20
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -0,0 +1,77 @@
|
|
|
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/consts/index.cjs');
|
|
21
|
+
require('react-international-phone');
|
|
22
|
+
var randomString = require('../../utils/functions/randomString/randomString.cjs');
|
|
23
|
+
require('viem');
|
|
24
|
+
require('viem/chains');
|
|
25
|
+
require('../../config/ApiEndpoint.cjs');
|
|
26
|
+
require('@dynamic-labs/store');
|
|
27
|
+
require('../../locale/locale.cjs');
|
|
28
|
+
|
|
29
|
+
const widgetRegistryContext = React.createContext(null);
|
|
30
|
+
const WidgetRegistryContextProvider = ({ children, }) => {
|
|
31
|
+
const [registry, setRegistry] = React.useState({});
|
|
32
|
+
const registerId = React.useCallback((widgetId, widgetType) => {
|
|
33
|
+
setRegistry((prevRegistry) => (Object.assign(Object.assign({}, prevRegistry), { [widgetId]: {
|
|
34
|
+
type: widgetType,
|
|
35
|
+
} })));
|
|
36
|
+
}, [setRegistry]);
|
|
37
|
+
const removeId = React.useCallback((widgetId) => {
|
|
38
|
+
setRegistry((prevRegistry) => {
|
|
39
|
+
const newRegistry = Object.assign({}, prevRegistry);
|
|
40
|
+
delete newRegistry[widgetId];
|
|
41
|
+
return newRegistry;
|
|
42
|
+
});
|
|
43
|
+
}, [setRegistry]);
|
|
44
|
+
const checkWidgetPresence = React.useCallback((widgetType) => Object.values(registry).some((widget) => widget.type === widgetType), [registry]);
|
|
45
|
+
return (jsxRuntime.jsx(widgetRegistryContext.Provider, { value: { checkWidgetPresence, registerId, removeId }, children: children }));
|
|
46
|
+
};
|
|
47
|
+
const useWidgetRegistry = () => {
|
|
48
|
+
const context = React.useContext(widgetRegistryContext);
|
|
49
|
+
if (context === null) {
|
|
50
|
+
throw new Error('usage of useWidgetRegistry not wrapped in `WidgetRegistryContextProvider`.');
|
|
51
|
+
}
|
|
52
|
+
return context;
|
|
53
|
+
};
|
|
54
|
+
const useRegisterWidget = (widgetType, enabled = true) => {
|
|
55
|
+
const idRef = React.useRef(randomString.randomString(8));
|
|
56
|
+
const { registerId, removeId } = useWidgetRegistry();
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
if (enabled === false) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
registerId(idRef.current, widgetType);
|
|
62
|
+
return () => {
|
|
63
|
+
// This is disabled because eslint think we are using state value
|
|
64
|
+
// but this is fine because it is a ref
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
removeId(idRef.current);
|
|
67
|
+
};
|
|
68
|
+
}, [widgetType, enabled, registerId, removeId]);
|
|
69
|
+
};
|
|
70
|
+
const useWidgetRegistryCheck = (widgetType) => {
|
|
71
|
+
const { checkWidgetPresence } = useWidgetRegistry();
|
|
72
|
+
return checkWidgetPresence(widgetType);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.WidgetRegistryContextProvider = WidgetRegistryContextProvider;
|
|
76
|
+
exports.useRegisterWidget = useRegisterWidget;
|
|
77
|
+
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,71 @@
|
|
|
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/consts/index.js';
|
|
17
|
+
import 'react-international-phone';
|
|
18
|
+
import { randomString } from '../../utils/functions/randomString/randomString.js';
|
|
19
|
+
import 'viem';
|
|
20
|
+
import 'viem/chains';
|
|
21
|
+
import '../../config/ApiEndpoint.js';
|
|
22
|
+
import '@dynamic-labs/store';
|
|
23
|
+
import '../../locale/locale.js';
|
|
24
|
+
|
|
25
|
+
const widgetRegistryContext = createContext(null);
|
|
26
|
+
const WidgetRegistryContextProvider = ({ children, }) => {
|
|
27
|
+
const [registry, setRegistry] = useState({});
|
|
28
|
+
const registerId = useCallback((widgetId, widgetType) => {
|
|
29
|
+
setRegistry((prevRegistry) => (Object.assign(Object.assign({}, prevRegistry), { [widgetId]: {
|
|
30
|
+
type: widgetType,
|
|
31
|
+
} })));
|
|
32
|
+
}, [setRegistry]);
|
|
33
|
+
const removeId = useCallback((widgetId) => {
|
|
34
|
+
setRegistry((prevRegistry) => {
|
|
35
|
+
const newRegistry = Object.assign({}, prevRegistry);
|
|
36
|
+
delete newRegistry[widgetId];
|
|
37
|
+
return newRegistry;
|
|
38
|
+
});
|
|
39
|
+
}, [setRegistry]);
|
|
40
|
+
const checkWidgetPresence = useCallback((widgetType) => Object.values(registry).some((widget) => widget.type === widgetType), [registry]);
|
|
41
|
+
return (jsx(widgetRegistryContext.Provider, { value: { checkWidgetPresence, registerId, removeId }, children: children }));
|
|
42
|
+
};
|
|
43
|
+
const useWidgetRegistry = () => {
|
|
44
|
+
const context = useContext(widgetRegistryContext);
|
|
45
|
+
if (context === null) {
|
|
46
|
+
throw new Error('usage of useWidgetRegistry not wrapped in `WidgetRegistryContextProvider`.');
|
|
47
|
+
}
|
|
48
|
+
return context;
|
|
49
|
+
};
|
|
50
|
+
const useRegisterWidget = (widgetType, enabled = true) => {
|
|
51
|
+
const idRef = useRef(randomString(8));
|
|
52
|
+
const { registerId, removeId } = useWidgetRegistry();
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (enabled === false) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
registerId(idRef.current, widgetType);
|
|
58
|
+
return () => {
|
|
59
|
+
// This is disabled because eslint think we are using state value
|
|
60
|
+
// but this is fine because it is a ref
|
|
61
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
+
removeId(idRef.current);
|
|
63
|
+
};
|
|
64
|
+
}, [widgetType, enabled, registerId, removeId]);
|
|
65
|
+
};
|
|
66
|
+
const useWidgetRegistryCheck = (widgetType) => {
|
|
67
|
+
const { checkWidgetPresence } = useWidgetRegistry();
|
|
68
|
+
return checkWidgetPresence(widgetType);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { WidgetRegistryContextProvider, useRegisterWidget, useWidgetRegistryCheck };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetRegistryContextProvider, useRegisterWidget, useWidgetRegistryCheck, } from './WidgetRegistryContextProvider';
|
|
@@ -75,7 +75,7 @@ const linkWallet = (environmentId_1, _b) => _tslib.__awaiter(void 0, [environmen
|
|
|
75
75
|
throw new utils.DynamicError(data.error);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
-
const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
78
|
+
const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, onSuccess, }) {
|
|
79
79
|
try {
|
|
80
80
|
const response = yield api.sdkApi().verifyUnlink({
|
|
81
81
|
environmentId,
|
|
@@ -84,6 +84,7 @@ const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({
|
|
|
84
84
|
walletId,
|
|
85
85
|
},
|
|
86
86
|
});
|
|
87
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
87
88
|
const user = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
88
89
|
return user;
|
|
89
90
|
}
|
|
@@ -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>;
|
|
@@ -71,7 +71,7 @@ const linkWallet = (environmentId_1, _b) => __awaiter(void 0, [environmentId_1,
|
|
|
71
71
|
throw new DynamicError(data.error);
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
-
const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
74
|
+
const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, onSuccess, }) {
|
|
75
75
|
try {
|
|
76
76
|
const response = yield sdkApi().verifyUnlink({
|
|
77
77
|
environmentId,
|
|
@@ -80,6 +80,7 @@ const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ enviro
|
|
|
80
80
|
walletId,
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
83
84
|
const user = storeAuthTokenAndUser(response);
|
|
84
85
|
return user;
|
|
85
86
|
}
|
|
@@ -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;
|
|
@@ -1600,12 +1600,12 @@ const translation = {
|
|
|
1600
1600
|
* @default
|
|
1601
1601
|
* {
|
|
1602
1602
|
description: "This wallet supports multiple chains. Select which chain you'd like to connect to",
|
|
1603
|
-
using_hardware_wallet_toggle_label: 'Using Ledger
|
|
1603
|
+
using_hardware_wallet_toggle_label: 'Using Ledger',
|
|
1604
1604
|
}
|
|
1605
1605
|
*/
|
|
1606
1606
|
dyn_select_chain: {
|
|
1607
1607
|
description: "This wallet supports multiple chains. Select which chain you'd like to connect to",
|
|
1608
|
-
using_hardware_wallet_toggle_label: 'Using Ledger
|
|
1608
|
+
using_hardware_wallet_toggle_label: 'Using Ledger',
|
|
1609
1609
|
},
|
|
1610
1610
|
/**
|
|
1611
1611
|
* @description copy keys for Select Wallet view
|
|
@@ -1596,7 +1596,7 @@ export declare const translation: {
|
|
|
1596
1596
|
* @default
|
|
1597
1597
|
* {
|
|
1598
1598
|
description: "This wallet supports multiple chains. Select which chain you'd like to connect to",
|
|
1599
|
-
using_hardware_wallet_toggle_label: 'Using Ledger
|
|
1599
|
+
using_hardware_wallet_toggle_label: 'Using Ledger',
|
|
1600
1600
|
}
|
|
1601
1601
|
*/
|
|
1602
1602
|
dyn_select_chain: {
|
|
@@ -1596,12 +1596,12 @@ const translation = {
|
|
|
1596
1596
|
* @default
|
|
1597
1597
|
* {
|
|
1598
1598
|
description: "This wallet supports multiple chains. Select which chain you'd like to connect to",
|
|
1599
|
-
using_hardware_wallet_toggle_label: 'Using Ledger
|
|
1599
|
+
using_hardware_wallet_toggle_label: 'Using Ledger',
|
|
1600
1600
|
}
|
|
1601
1601
|
*/
|
|
1602
1602
|
dyn_select_chain: {
|
|
1603
1603
|
description: "This wallet supports multiple chains. Select which chain you'd like to connect to",
|
|
1604
|
-
using_hardware_wallet_toggle_label: 'Using Ledger
|
|
1604
|
+
using_hardware_wallet_toggle_label: 'Using Ledger',
|
|
1605
1605
|
},
|
|
1606
1606
|
/**
|
|
1607
1607
|
* @description copy keys for Select Wallet view
|