@dynamic-labs/sdk-react-core 2.2.2 → 2.2.3
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 +12 -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/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 +5 -0
- 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/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 +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/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,20 @@
|
|
|
1
1
|
|
|
2
|
+
### [2.2.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.2...v2.2.3) (2024-06-19)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* return userWallets connected state async ([#6080](https://github.com/dynamic-labs/DynamicAuth/issues/6080)) ([6ffa444](https://github.com/dynamic-labs/DynamicAuth/commit/6ffa444ad374d1923a07bbc12191455cb3a1d276))
|
|
8
|
+
* 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))
|
|
9
|
+
* 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))
|
|
10
|
+
* 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))
|
|
11
|
+
|
|
2
12
|
### [2.2.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.1...v2.2.2) (2024-06-18)
|
|
3
13
|
|
|
4
14
|
|
|
5
15
|
### Bug Fixes
|
|
6
16
|
|
|
7
|
-
* make account change
|
|
17
|
+
* 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
18
|
|
|
9
19
|
### [2.2.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0...v2.2.1) (2024-06-17)
|
|
10
20
|
|
|
@@ -101,7 +111,7 @@
|
|
|
101
111
|
|
|
102
112
|
- 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
113
|
|
|
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.
|
|
114
|
+
- 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
115
|
|
|
106
116
|
|
|
107
117
|
## 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.3",
|
|
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.3",
|
|
21
|
+
"@dynamic-labs/logger": "2.2.3",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.2.3",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.2.3",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.2.3",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.2.3",
|
|
26
|
+
"@dynamic-labs/store": "2.2.3",
|
|
27
|
+
"@dynamic-labs/types": "2.2.3",
|
|
28
|
+
"@dynamic-labs/utils": "2.2.3",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.2.3",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.2.3",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.2.3",
|
|
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 };
|
|
@@ -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;
|