@dynamic-labs/sdk-react-core 0.17.0-RC.29 → 0.17.0-RC.30
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 +8 -0
- package/package.cjs +1 -2
- package/package.js +1 -2
- package/package.json +8 -8
- package/src/lib/Main.cjs +4 -4
- package/src/lib/Main.js +4 -4
- package/src/lib/context/DynamicContext/DynamicContext.cjs +8 -3
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -3
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs +27 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.d.ts +14 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js +23 -0
- package/src/lib/context/MockContext/MockContext.cjs +1 -0
- package/src/lib/context/MockContext/MockContext.js +1 -0
- package/src/lib/context/ViewContext/ViewContext.cjs +21 -12
- package/src/lib/context/ViewContext/ViewContext.d.ts +9 -7
- package/src/lib/context/ViewContext/ViewContext.js +22 -13
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +4 -9
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +4 -9
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +3 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -2
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -2
- package/src/lib/views/NoAccess/NoAccess.cjs +3 -3
- package/src/lib/views/NoAccess/NoAccess.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.17.0-RC.30](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.29...v0.17.0-RC.30) (2023-06-08)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **view-context:** refactor view context to have initial view ([#2268](https://github.com/dynamic-labs/DynamicAuth/issues/2268)) ([0afe6ae](https://github.com/dynamic-labs/DynamicAuth/commit/0afe6ae469f62fd16fd8471322f9295957f607f6))
|
|
8
|
+
* **wcv2:** upgrade universal provider and refactor wcv2 ([#2163](https://github.com/dynamic-labs/DynamicAuth/issues/2163)) ([e69c67c](https://github.com/dynamic-labs/DynamicAuth/commit/e69c67c95dca0f694c4a554702be96c3f7d3d77e))
|
|
9
|
+
|
|
2
10
|
## [0.17.0-RC.29](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.28...v0.17.0-RC.29) (2023-06-07)
|
|
3
11
|
|
|
4
12
|
|
package/package.cjs
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = "0.17.0-RC.
|
|
5
|
+
var version = "0.17.0-RC.30";
|
|
6
6
|
var dependencies = {
|
|
7
7
|
"react-focus-lock": "2.9.2",
|
|
8
8
|
"@dynamic-labs/iconic": "0.1.19",
|
|
9
9
|
"@dynamic-labs/sdk-api": "0.0.198",
|
|
10
|
-
"@dynamic-labs/wallet-book": "0.0.18",
|
|
11
10
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
12
11
|
"country-list": "2.3.0",
|
|
13
12
|
yup: "0.32.11",
|
package/package.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
var version = "0.17.0-RC.
|
|
1
|
+
var version = "0.17.0-RC.30";
|
|
2
2
|
var dependencies = {
|
|
3
3
|
"react-focus-lock": "2.9.2",
|
|
4
4
|
"@dynamic-labs/iconic": "0.1.19",
|
|
5
5
|
"@dynamic-labs/sdk-api": "0.0.198",
|
|
6
|
-
"@dynamic-labs/wallet-book": "0.0.18",
|
|
7
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
8
7
|
"country-list": "2.3.0",
|
|
9
8
|
yup: "0.32.11",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "0.17.0-RC.
|
|
3
|
+
"version": "0.17.0-RC.30",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"react-focus-lock": "2.9.2",
|
|
11
11
|
"@dynamic-labs/iconic": "0.1.19",
|
|
12
12
|
"@dynamic-labs/sdk-api": "0.0.198",
|
|
13
|
-
"@dynamic-labs/wallet-book": "0.0.18",
|
|
14
13
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
15
14
|
"country-list": "2.3.0",
|
|
16
15
|
"yup": "0.32.11",
|
|
17
16
|
"formik": "2.2.9",
|
|
18
17
|
"qrcode": "1.5.1",
|
|
19
18
|
"ethers": "5.7.2",
|
|
20
|
-
"@dynamic-labs/logger": "0.17.0-RC.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "0.17.0-RC.
|
|
22
|
-
"@dynamic-labs/rpc-providers": "0.17.0-RC.
|
|
23
|
-
"@dynamic-labs/types": "0.17.0-RC.
|
|
24
|
-
"@dynamic-labs/utils": "0.17.0-RC.
|
|
25
|
-
"@dynamic-labs/wallet-
|
|
19
|
+
"@dynamic-labs/logger": "0.17.0-RC.30",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "0.17.0-RC.30",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "0.17.0-RC.30",
|
|
22
|
+
"@dynamic-labs/types": "0.17.0-RC.30",
|
|
23
|
+
"@dynamic-labs/utils": "0.17.0-RC.30",
|
|
24
|
+
"@dynamic-labs/wallet-book": "0.17.0-RC.30",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "0.17.0-RC.30"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"semver": "7.3.8"
|
package/src/lib/Main.cjs
CHANGED
|
@@ -49,8 +49,8 @@ var viewToComponentMap = require('./views/viewToComponentMap.cjs');
|
|
|
49
49
|
require('./main.global.cjs');
|
|
50
50
|
|
|
51
51
|
const Main = () => {
|
|
52
|
-
const { selectedWalletConnector, appName, connectedWallets, isProjectSettingsLoading, projectSettings, privacyPolicyUrl, setShowAuthFlow, showAuthFlow, termsOfServiceUrl, newToWeb3WalletChainMap, wallets, clearStatesOnBackClick, user,
|
|
53
|
-
const { view,
|
|
52
|
+
const { selectedWalletConnector, appName, connectedWallets, isProjectSettingsLoading, projectSettings, privacyPolicyUrl, setShowAuthFlow, showAuthFlow, termsOfServiceUrl, newToWeb3WalletChainMap, wallets, clearStatesOnBackClick, user, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
53
|
+
const { view, goToInitialView } = ViewContext.useViewContext();
|
|
54
54
|
const { setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
55
55
|
usePreventPageScroll.usePreventPageScroll(showAuthFlow);
|
|
56
56
|
const handleClose = () => {
|
|
@@ -63,8 +63,8 @@ const Main = () => {
|
|
|
63
63
|
// IMPORTANT: we need to reset the view because we reset state that the view depends on
|
|
64
64
|
// so if the previous view renders when the user reopens the widget, it will crash
|
|
65
65
|
() => {
|
|
66
|
-
|
|
67
|
-
}, [
|
|
66
|
+
goToInitialView();
|
|
67
|
+
}, [goToInitialView]);
|
|
68
68
|
useVerifyOnAwaitingSignature.useVerifyOnAwaitingSignature();
|
|
69
69
|
const { handleAlreadyConnectedWallet, handleCustodialWalletClick, handleInstalledExtensionClick, handleMobileWalletClick, handleUninstalledClick, } = useWalletItemActions.useWalletItemActions();
|
|
70
70
|
/* istanbul ignore next */
|
package/src/lib/Main.js
CHANGED
|
@@ -45,8 +45,8 @@ import { viewToComponentMap } from './views/viewToComponentMap.js';
|
|
|
45
45
|
import './main.global.js';
|
|
46
46
|
|
|
47
47
|
const Main = () => {
|
|
48
|
-
const { selectedWalletConnector, appName, connectedWallets, isProjectSettingsLoading, projectSettings, privacyPolicyUrl, setShowAuthFlow, showAuthFlow, termsOfServiceUrl, newToWeb3WalletChainMap, wallets, clearStatesOnBackClick, user,
|
|
49
|
-
const { view,
|
|
48
|
+
const { selectedWalletConnector, appName, connectedWallets, isProjectSettingsLoading, projectSettings, privacyPolicyUrl, setShowAuthFlow, showAuthFlow, termsOfServiceUrl, newToWeb3WalletChainMap, wallets, clearStatesOnBackClick, user, } = useInternalDynamicContext();
|
|
49
|
+
const { view, goToInitialView } = useViewContext();
|
|
50
50
|
const { setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
51
51
|
usePreventPageScroll(showAuthFlow);
|
|
52
52
|
const handleClose = () => {
|
|
@@ -59,8 +59,8 @@ const Main = () => {
|
|
|
59
59
|
// IMPORTANT: we need to reset the view because we reset state that the view depends on
|
|
60
60
|
// so if the previous view renders when the user reopens the widget, it will crash
|
|
61
61
|
() => {
|
|
62
|
-
|
|
63
|
-
}, [
|
|
62
|
+
goToInitialView();
|
|
63
|
+
}, [goToInitialView]);
|
|
64
64
|
useVerifyOnAwaitingSignature();
|
|
65
65
|
const { handleAlreadyConnectedWallet, handleCustodialWalletClick, handleInstalledExtensionClick, handleMobileWalletClick, handleUninstalledClick, } = useWalletItemActions();
|
|
66
66
|
/* istanbul ignore next */
|
|
@@ -78,6 +78,7 @@ var useCustomerAuthFlowCallbacks = require('./useCustomerCallbacks/useCustomerAu
|
|
|
78
78
|
var useEmailLoginState = require('./hooks/useEmailLoginState/useEmailLoginState.cjs');
|
|
79
79
|
var useDisplayOrderState = require('./hooks/useDisplayOrderState/useDisplayOrderState.cjs');
|
|
80
80
|
var useNameService = require('./hooks/useNameService/useNameService.cjs');
|
|
81
|
+
var useSetShowAuthFlowWithInit = require('./hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs');
|
|
81
82
|
|
|
82
83
|
const EMPTY_INITIAL_USER = undefined;
|
|
83
84
|
const DynamicContext = React.createContext(undefined);
|
|
@@ -151,6 +152,10 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
151
152
|
projectSettings,
|
|
152
153
|
user,
|
|
153
154
|
});
|
|
155
|
+
const setShowAuthFlowWithInit = useSetShowAuthFlowWithInit.useSetShowAuthFlowWithInit({
|
|
156
|
+
setShowAuthFlow,
|
|
157
|
+
wallets,
|
|
158
|
+
});
|
|
154
159
|
const { getNameService, removeConnectedNameService } = useNameService.useNameService({
|
|
155
160
|
authToken: (_d = getAuthToken.getAuthToken()) !== null && _d !== void 0 ? _d : onboardingOnlyJwt,
|
|
156
161
|
currentWallet: primaryWallet !== null && primaryWallet !== void 0 ? primaryWallet : connectedWallet,
|
|
@@ -358,7 +363,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
358
363
|
setSdkHasLoaded,
|
|
359
364
|
setSelectedWalletConnector,
|
|
360
365
|
setSelectedWalletWithAction,
|
|
361
|
-
setShowAuthFlow,
|
|
366
|
+
setShowAuthFlow: setShowAuthFlowWithInit,
|
|
362
367
|
setShowDynamicUserProfile,
|
|
363
368
|
setShowQrcodeModal,
|
|
364
369
|
setShowWidgetStatePopup,
|
|
@@ -443,7 +448,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
443
448
|
setPrimaryWallet,
|
|
444
449
|
setPrimaryWalletId,
|
|
445
450
|
setSdkHasLoaded,
|
|
446
|
-
|
|
451
|
+
setShowAuthFlowWithInit,
|
|
447
452
|
setShowQrcodeModal,
|
|
448
453
|
setUser,
|
|
449
454
|
shadowDOMEnabled,
|
|
@@ -492,7 +497,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
492
497
|
setShowDynamicUserProfile(true);
|
|
493
498
|
}
|
|
494
499
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile, user]);
|
|
495
|
-
return (jsxRuntime.jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, Object.assign({ customerTheme: parseTheme.parseTheme(theme, ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsxRuntime.jsx(LoadingContext.LoadingContextProvider, { children: jsxRuntime.jsx(ViewContext.ViewContextProvider, Object.assign({
|
|
500
|
+
return (jsxRuntime.jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, Object.assign({ customerTheme: parseTheme.parseTheme(theme, ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsxRuntime.jsx(LoadingContext.LoadingContextProvider, { children: jsxRuntime.jsx(ViewContext.ViewContextProvider, Object.assign({ initialView: loginWithEmail ? 'login-with-email-or-wallet' : 'wallet-list' }, { children: jsxRuntime.jsx(QrCodeContext.QrCodeContextProvider, { children: jsxRuntime.jsx(EmailVerificationContext.EmailVerificationContextProvider, { children: jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsxs(SendBalanceContext.SendBalanceContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), confirmationModal, children] }) }) }) }) }) }) }) }) })) }) })) })));
|
|
496
501
|
};
|
|
497
502
|
|
|
498
503
|
exports.DynamicContext = DynamicContext;
|
|
@@ -74,6 +74,7 @@ import { useCustomerAuthFlowCallbacks } from './useCustomerCallbacks/useCustomer
|
|
|
74
74
|
import { useEmailLoginState } from './hooks/useEmailLoginState/useEmailLoginState.js';
|
|
75
75
|
import { useDisplayOrderState } from './hooks/useDisplayOrderState/useDisplayOrderState.js';
|
|
76
76
|
import { useNameService } from './hooks/useNameService/useNameService.js';
|
|
77
|
+
import { useSetShowAuthFlowWithInit } from './hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js';
|
|
77
78
|
|
|
78
79
|
const EMPTY_INITIAL_USER = undefined;
|
|
79
80
|
const DynamicContext = createContext(undefined);
|
|
@@ -147,6 +148,10 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
147
148
|
projectSettings,
|
|
148
149
|
user,
|
|
149
150
|
});
|
|
151
|
+
const setShowAuthFlowWithInit = useSetShowAuthFlowWithInit({
|
|
152
|
+
setShowAuthFlow,
|
|
153
|
+
wallets,
|
|
154
|
+
});
|
|
150
155
|
const { getNameService, removeConnectedNameService } = useNameService({
|
|
151
156
|
authToken: (_d = getAuthToken()) !== null && _d !== void 0 ? _d : onboardingOnlyJwt,
|
|
152
157
|
currentWallet: primaryWallet !== null && primaryWallet !== void 0 ? primaryWallet : connectedWallet,
|
|
@@ -354,7 +359,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
354
359
|
setSdkHasLoaded,
|
|
355
360
|
setSelectedWalletConnector,
|
|
356
361
|
setSelectedWalletWithAction,
|
|
357
|
-
setShowAuthFlow,
|
|
362
|
+
setShowAuthFlow: setShowAuthFlowWithInit,
|
|
358
363
|
setShowDynamicUserProfile,
|
|
359
364
|
setShowQrcodeModal,
|
|
360
365
|
setShowWidgetStatePopup,
|
|
@@ -439,7 +444,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
439
444
|
setPrimaryWallet,
|
|
440
445
|
setPrimaryWalletId,
|
|
441
446
|
setSdkHasLoaded,
|
|
442
|
-
|
|
447
|
+
setShowAuthFlowWithInit,
|
|
443
448
|
setShowQrcodeModal,
|
|
444
449
|
setUser,
|
|
445
450
|
shadowDOMEnabled,
|
|
@@ -488,7 +493,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
488
493
|
setShowDynamicUserProfile(true);
|
|
489
494
|
}
|
|
490
495
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile, user]);
|
|
491
|
-
return (jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsx(ThemeContextProvider, Object.assign({ customerTheme: parseTheme(theme, ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsx(LoadingContextProvider, { children: jsx(ViewContextProvider, Object.assign({
|
|
496
|
+
return (jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsx(ThemeContextProvider, Object.assign({ customerTheme: parseTheme(theme, ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _e === void 0 ? void 0 : _e.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsx(LoadingContextProvider, { children: jsx(ViewContextProvider, Object.assign({ initialView: loginWithEmail ? 'login-with-email-or-wallet' : 'wallet-list' }, { children: jsx(QrCodeContextProvider, { children: jsx(EmailVerificationContextProvider, { children: jsx(ErrorContextProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(CaptchaContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsxs(SendBalanceContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), confirmationModal, children] }) }) }) }) }) }) }) }) })) }) })) })));
|
|
492
497
|
};
|
|
493
498
|
|
|
494
499
|
export { DynamicContext, DynamicContextProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSetShowAuthFlowWithInit';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* this hook wraps `setShowAuthFlow`. WalletConnect requires initialization
|
|
9
|
+
* before we can connect a wallet. The goal here is that when a user clicks
|
|
10
|
+
* on the "Connect your wallet" button, the SDK starts initializing WalletConnect
|
|
11
|
+
* and will prime it for connection. This way, when the user clicks on the
|
|
12
|
+
* "Connect" button in the WalletConnect modal, there is a uri ready to go
|
|
13
|
+
* to immediately trigger the deep link on mobile
|
|
14
|
+
*/
|
|
15
|
+
const useSetShowAuthFlowWithInit = ({ setShowAuthFlow, wallets, }) => {
|
|
16
|
+
const setShowAuthFlowWithInit = React.useCallback((value) => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (value) {
|
|
19
|
+
(_a = wallets
|
|
20
|
+
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
21
|
+
}
|
|
22
|
+
setShowAuthFlow(value);
|
|
23
|
+
}, [setShowAuthFlow, wallets]);
|
|
24
|
+
return setShowAuthFlowWithInit;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.useSetShowAuthFlowWithInit = useSetShowAuthFlowWithInit;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { WalletOption } from '../../../../shared';
|
|
3
|
+
/**
|
|
4
|
+
* this hook wraps `setShowAuthFlow`. WalletConnect requires initialization
|
|
5
|
+
* before we can connect a wallet. The goal here is that when a user clicks
|
|
6
|
+
* on the "Connect your wallet" button, the SDK starts initializing WalletConnect
|
|
7
|
+
* and will prime it for connection. This way, when the user clicks on the
|
|
8
|
+
* "Connect" button in the WalletConnect modal, there is a uri ready to go
|
|
9
|
+
* to immediately trigger the deep link on mobile
|
|
10
|
+
*/
|
|
11
|
+
export declare const useSetShowAuthFlowWithInit: ({ setShowAuthFlow, wallets, }: {
|
|
12
|
+
setShowAuthFlow: Dispatch<SetStateAction<boolean>>;
|
|
13
|
+
wallets: WalletOption[];
|
|
14
|
+
}) => Dispatch<SetStateAction<boolean>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* this hook wraps `setShowAuthFlow`. WalletConnect requires initialization
|
|
5
|
+
* before we can connect a wallet. The goal here is that when a user clicks
|
|
6
|
+
* on the "Connect your wallet" button, the SDK starts initializing WalletConnect
|
|
7
|
+
* and will prime it for connection. This way, when the user clicks on the
|
|
8
|
+
* "Connect" button in the WalletConnect modal, there is a uri ready to go
|
|
9
|
+
* to immediately trigger the deep link on mobile
|
|
10
|
+
*/
|
|
11
|
+
const useSetShowAuthFlowWithInit = ({ setShowAuthFlow, wallets, }) => {
|
|
12
|
+
const setShowAuthFlowWithInit = useCallback((value) => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (value) {
|
|
15
|
+
(_a = wallets
|
|
16
|
+
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
17
|
+
}
|
|
18
|
+
setShowAuthFlow(value);
|
|
19
|
+
}, [setShowAuthFlow, wallets]);
|
|
20
|
+
return setShowAuthFlowWithInit;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { useSetShowAuthFlowWithInit };
|
|
@@ -22,6 +22,7 @@ var index$1 = require('../../shared/consts/index.cjs');
|
|
|
22
22
|
const MockContext = React.createContext(undefined);
|
|
23
23
|
const MockContextProvider = ({ children, walletName, view, mockedWalletConnector, customerTheme, dynamicLayoutClassName, }) => {
|
|
24
24
|
const viewContextValue = {
|
|
25
|
+
goToInitialView: () => { },
|
|
25
26
|
/* istanbul ignore next */
|
|
26
27
|
setView: () => { },
|
|
27
28
|
view,
|
|
@@ -18,6 +18,7 @@ import { defaultWalletsForChains } from '../../shared/consts/index.js';
|
|
|
18
18
|
const MockContext = createContext(undefined);
|
|
19
19
|
const MockContextProvider = ({ children, walletName, view, mockedWalletConnector, customerTheme, dynamicLayoutClassName, }) => {
|
|
20
20
|
const viewContextValue = {
|
|
21
|
+
goToInitialView: () => { },
|
|
21
22
|
/* istanbul ignore next */
|
|
22
23
|
setView: () => { },
|
|
23
24
|
view,
|
|
@@ -4,25 +4,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
var usePrevious = require('../../utils/hooks/usePrevious/usePrevious.cjs');
|
|
7
8
|
|
|
8
9
|
const ViewContext = React.createContext(undefined);
|
|
9
|
-
const ViewContextProvider = ({ children,
|
|
10
|
-
const [view, setView] = React.useState(
|
|
10
|
+
const ViewContextProvider = ({ children, initialView = 'wallet-list' }) => {
|
|
11
|
+
const [view, setView] = React.useState(initialView);
|
|
12
|
+
const previousInitialView = usePrevious.usePrevious(initialView);
|
|
13
|
+
const goToInitialView = React.useCallback(() => {
|
|
14
|
+
setView(initialView);
|
|
15
|
+
}, [initialView]);
|
|
11
16
|
React.useEffect(() => {
|
|
12
|
-
if (
|
|
17
|
+
if (!initialView)
|
|
13
18
|
return;
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const isInInitialView = view === previousInitialView || !previousInitialView;
|
|
20
|
+
if (!isInInitialView)
|
|
21
|
+
return;
|
|
22
|
+
setView((currentView) => {
|
|
23
|
+
const wasViewSetDuringRender = currentView !== previousInitialView;
|
|
24
|
+
if (wasViewSetDuringRender) {
|
|
25
|
+
return currentView;
|
|
26
|
+
}
|
|
27
|
+
return initialView;
|
|
28
|
+
});
|
|
29
|
+
}, [initialView, view]);
|
|
22
30
|
const value = React.useMemo(() => ({
|
|
31
|
+
goToInitialView,
|
|
23
32
|
setView,
|
|
24
33
|
view,
|
|
25
|
-
}), [view]);
|
|
34
|
+
}), [view, goToInitialView]);
|
|
26
35
|
return jsxRuntime.jsx(ViewContext.Provider, Object.assign({ value: value }, { children: children }));
|
|
27
36
|
};
|
|
28
37
|
const useViewContext = () => {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SetStateAction, Dispatch, PropsWithChildren, FC } from 'react';
|
|
2
2
|
export type ViewType = 'captcha' | 'chainalysis-blocked-wallet' | 'collect-user-data' | 'collect-user-data-login-with-email' | 'login-with-email-or-wallet-full-wallet-list' | 'login-with-email-or-wallet' | 'login-with-email-verification' | 'network-not-supported' | 'network-not-supported-manual' | 'no-access' | 'no-qr-not-installed' | 'pending-connect' | 'pending-signature-without-back-button' | 'pending-signature' | 'qr-code' | 'update-email' | 'verify-email' | 'wallet-connect-mobile-wallets-list' | 'wallet-list' | 'wallet-sign' | 'wallet-used' | 'wait-for-email-confirmation-view' | 'email-wallet-otp-verification-view' | 'social-redirect-view' | 'social-wrong-account';
|
|
3
|
-
export
|
|
3
|
+
export type ViewContextProps = {
|
|
4
4
|
setView: Dispatch<SetStateAction<ViewType>>;
|
|
5
5
|
view: ViewType;
|
|
6
|
-
|
|
6
|
+
goToInitialView: () => void;
|
|
7
|
+
};
|
|
8
|
+
type ViewContextProviderProps = {
|
|
9
|
+
initialView?: ViewType;
|
|
10
|
+
};
|
|
7
11
|
export declare const ViewContext: import("react").Context<ViewContextProps | undefined>;
|
|
8
|
-
export declare const ViewContextProvider:
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
loginWithEmail: boolean;
|
|
11
|
-
}) => JSX.Element;
|
|
12
|
+
export declare const ViewContextProvider: FC<PropsWithChildren<ViewContextProviderProps>>;
|
|
12
13
|
export declare const useViewContext: () => ViewContextProps;
|
|
14
|
+
export {};
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext, useState, useEffect, useMemo, useContext } from 'react';
|
|
2
|
+
import { createContext, useState, useCallback, useEffect, useMemo, useContext } from 'react';
|
|
3
|
+
import { usePrevious } from '../../utils/hooks/usePrevious/usePrevious.js';
|
|
3
4
|
|
|
4
5
|
const ViewContext = createContext(undefined);
|
|
5
|
-
const ViewContextProvider = ({ children,
|
|
6
|
-
const [view, setView] = useState(
|
|
6
|
+
const ViewContextProvider = ({ children, initialView = 'wallet-list' }) => {
|
|
7
|
+
const [view, setView] = useState(initialView);
|
|
8
|
+
const previousInitialView = usePrevious(initialView);
|
|
9
|
+
const goToInitialView = useCallback(() => {
|
|
10
|
+
setView(initialView);
|
|
11
|
+
}, [initialView]);
|
|
7
12
|
useEffect(() => {
|
|
8
|
-
if (
|
|
13
|
+
if (!initialView)
|
|
9
14
|
return;
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const isInInitialView = view === previousInitialView || !previousInitialView;
|
|
16
|
+
if (!isInInitialView)
|
|
17
|
+
return;
|
|
18
|
+
setView((currentView) => {
|
|
19
|
+
const wasViewSetDuringRender = currentView !== previousInitialView;
|
|
20
|
+
if (wasViewSetDuringRender) {
|
|
21
|
+
return currentView;
|
|
22
|
+
}
|
|
23
|
+
return initialView;
|
|
24
|
+
});
|
|
25
|
+
}, [initialView, view]);
|
|
18
26
|
const value = useMemo(() => ({
|
|
27
|
+
goToInitialView,
|
|
19
28
|
setView,
|
|
20
29
|
view,
|
|
21
|
-
}), [view]);
|
|
30
|
+
}), [view, goToInitialView]);
|
|
22
31
|
return jsx(ViewContext.Provider, Object.assign({ value: value }, { children: children }));
|
|
23
32
|
};
|
|
24
33
|
const useViewContext = () => {
|
|
@@ -44,21 +44,16 @@ require('yup');
|
|
|
44
44
|
var QrCodeContext = require('../../../context/QrCodeContext/QrCodeContext.cjs');
|
|
45
45
|
|
|
46
46
|
const Header = ({ onClose: handleClose, heading, projectSettings, }) => {
|
|
47
|
-
const { clearStatesOnBackClick,
|
|
47
|
+
const { clearStatesOnBackClick, selectedWalletConnector } = useInternalDynamicContext.useInternalDynamicContext();
|
|
48
48
|
const { showQrCodeMessage, setShowQrCodeImage, showQrCodeImage } = QrCodeContext.useQrCodeContext();
|
|
49
|
-
const { view,
|
|
49
|
+
const { view, goToInitialView } = ViewContext.useViewContext();
|
|
50
50
|
const handleBackClick = React.useCallback(() => {
|
|
51
|
-
|
|
51
|
+
goToInitialView();
|
|
52
52
|
// on back button click in Coinbase wallet clearing state would kill connection and refresh the page
|
|
53
53
|
if ((selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name) !== 'Coinbase') {
|
|
54
54
|
clearStatesOnBackClick();
|
|
55
55
|
}
|
|
56
|
-
}, [
|
|
57
|
-
clearStatesOnBackClick,
|
|
58
|
-
loginWithEmail,
|
|
59
|
-
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
60
|
-
setView,
|
|
61
|
-
]);
|
|
56
|
+
}, [clearStatesOnBackClick, selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name, goToInitialView]);
|
|
62
57
|
const positionAbsolute = view === 'login-with-email-verification';
|
|
63
58
|
const showCloseButton = view !== 'login-with-email-or-wallet-full-wallet-list' &&
|
|
64
59
|
view !== 'login-with-email-verification';
|
|
@@ -40,21 +40,16 @@ import 'yup';
|
|
|
40
40
|
import { useQrCodeContext } from '../../../context/QrCodeContext/QrCodeContext.js';
|
|
41
41
|
|
|
42
42
|
const Header = ({ onClose: handleClose, heading, projectSettings, }) => {
|
|
43
|
-
const { clearStatesOnBackClick,
|
|
43
|
+
const { clearStatesOnBackClick, selectedWalletConnector } = useInternalDynamicContext();
|
|
44
44
|
const { showQrCodeMessage, setShowQrCodeImage, showQrCodeImage } = useQrCodeContext();
|
|
45
|
-
const { view,
|
|
45
|
+
const { view, goToInitialView } = useViewContext();
|
|
46
46
|
const handleBackClick = useCallback(() => {
|
|
47
|
-
|
|
47
|
+
goToInitialView();
|
|
48
48
|
// on back button click in Coinbase wallet clearing state would kill connection and refresh the page
|
|
49
49
|
if ((selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name) !== 'Coinbase') {
|
|
50
50
|
clearStatesOnBackClick();
|
|
51
51
|
}
|
|
52
|
-
}, [
|
|
53
|
-
clearStatesOnBackClick,
|
|
54
|
-
loginWithEmail,
|
|
55
|
-
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
56
|
-
setView,
|
|
57
|
-
]);
|
|
52
|
+
}, [clearStatesOnBackClick, selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name, goToInitialView]);
|
|
58
53
|
const positionAbsolute = view === 'login-with-email-verification';
|
|
59
54
|
const showCloseButton = view !== 'login-with-email-or-wallet-full-wallet-list' &&
|
|
60
55
|
view !== 'login-with-email-verification';
|
|
@@ -35,9 +35,9 @@ var AccessDeniedContext = require('../../../context/AccessDeniedContext/AccessDe
|
|
|
35
35
|
// This logic is the best place to determine whether we should verify or verify and link.
|
|
36
36
|
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
37
37
|
const { setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
38
|
-
const { setView } = ViewContext.useViewContext();
|
|
38
|
+
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
39
39
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
40
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken,
|
|
40
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
41
|
// If the user is not already logged it means that we only need to verify
|
|
42
42
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
43
43
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -118,7 +118,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
118
118
|
if (connectedWallet && authMode === 'connect-only') {
|
|
119
119
|
throw new utils.DynamicError(e.message);
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
goToInitialView();
|
|
122
122
|
logger.logger.error(e);
|
|
123
123
|
if (debugError) {
|
|
124
124
|
setError(`${e.message}\n ${e.stack}`);
|
|
@@ -31,9 +31,9 @@ import { useAccessDeniedContext } from '../../../context/AccessDeniedContext/Acc
|
|
|
31
31
|
// This logic is the best place to determine whether we should verify or verify and link.
|
|
32
32
|
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
33
33
|
const { setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
34
|
-
const { setView } = useViewContext();
|
|
34
|
+
const { setView, goToInitialView } = useViewContext();
|
|
35
35
|
const { setErrorMessage, setError } = useErrorContext();
|
|
36
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken,
|
|
36
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, } = useInternalDynamicContext();
|
|
37
37
|
// If the user is not already logged it means that we only need to verify
|
|
38
38
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
39
39
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -114,7 +114,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
114
114
|
if (connectedWallet && authMode === 'connect-only') {
|
|
115
115
|
throw new DynamicError(e.message);
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
goToInitialView();
|
|
118
118
|
logger.error(e);
|
|
119
119
|
if (debugError) {
|
|
120
120
|
setError(`${e.message}\n ${e.stack}`);
|
|
@@ -62,7 +62,7 @@ const EmailVerification = () => {
|
|
|
62
62
|
const [retried, setRetried] = React.useState(false);
|
|
63
63
|
const [isValidated, setIsValidated] = React.useState(false);
|
|
64
64
|
const [showTransferMessage, setShowTransferMessage] = React.useState(false);
|
|
65
|
-
const { view, setView } = ViewContext.useViewContext();
|
|
65
|
+
const { view, setView, goToInitialView } = ViewContext.useViewContext();
|
|
66
66
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
67
67
|
const { environmentId, onboardingOnlyJwt, handleLogOut, termsOfServiceUrl, privacyPolicyUrl, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
68
68
|
const { email, verificationUUID, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
@@ -188,7 +188,7 @@ const EmailVerification = () => {
|
|
|
188
188
|
setHideRetryButton(true);
|
|
189
189
|
}
|
|
190
190
|
if (error.code === 'invalid_email_verification') {
|
|
191
|
-
|
|
191
|
+
goToInitialView();
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
finally {
|
|
@@ -58,7 +58,7 @@ const EmailVerification = () => {
|
|
|
58
58
|
const [retried, setRetried] = useState(false);
|
|
59
59
|
const [isValidated, setIsValidated] = useState(false);
|
|
60
60
|
const [showTransferMessage, setShowTransferMessage] = useState(false);
|
|
61
|
-
const { view, setView } = useViewContext();
|
|
61
|
+
const { view, setView, goToInitialView } = useViewContext();
|
|
62
62
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
63
63
|
const { environmentId, onboardingOnlyJwt, handleLogOut, termsOfServiceUrl, privacyPolicyUrl, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
64
64
|
const { email, verificationUUID, setVerificationUUID } = useEmailVerificationContext();
|
|
@@ -184,7 +184,7 @@ const EmailVerification = () => {
|
|
|
184
184
|
setHideRetryButton(true);
|
|
185
185
|
}
|
|
186
186
|
if (error.code === 'invalid_email_verification') {
|
|
187
|
-
|
|
187
|
+
goToInitialView();
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
finally {
|
|
@@ -48,9 +48,9 @@ var AuthProviderIcon = require('../../components/AuthProviderIcon/AuthProviderIc
|
|
|
48
48
|
|
|
49
49
|
const NoAccess = () => {
|
|
50
50
|
const { deniedAddress, setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
51
|
-
const {
|
|
51
|
+
const { selectedWalletConnector: walletConnector, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, notInTheListImageUrl, accessDeniedMessagePrimary, accessDeniedMessageSecondary, onboardingOnlyJwt, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
52
52
|
const { email } = EmailVerificationContext.useEmailVerificationContext();
|
|
53
|
-
const {
|
|
53
|
+
const { goToInitialView, view } = ViewContext.useViewContext();
|
|
54
54
|
const isChainalysisView = view === 'chainalysis-blocked-wallet';
|
|
55
55
|
const _socialMediaLinkText = !isChainalysisView
|
|
56
56
|
? socialMediaLinkText
|
|
@@ -59,7 +59,7 @@ const NoAccess = () => {
|
|
|
59
59
|
? socialMediaUrl
|
|
60
60
|
: 'https://docs.dynamic.xyz/docs';
|
|
61
61
|
const handleChangeWallet = () => {
|
|
62
|
-
|
|
62
|
+
goToInitialView();
|
|
63
63
|
setDeniedAddress('');
|
|
64
64
|
setDeniedOauthProvider(undefined);
|
|
65
65
|
walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.endSession();
|
|
@@ -44,9 +44,9 @@ import { AuthProviderIcon } from '../../components/AuthProviderIcon/AuthProvider
|
|
|
44
44
|
|
|
45
45
|
const NoAccess = () => {
|
|
46
46
|
const { deniedAddress, setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
47
|
-
const {
|
|
47
|
+
const { selectedWalletConnector: walletConnector, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, notInTheListImageUrl, accessDeniedMessagePrimary, accessDeniedMessageSecondary, onboardingOnlyJwt, } = useInternalDynamicContext();
|
|
48
48
|
const { email } = useEmailVerificationContext();
|
|
49
|
-
const {
|
|
49
|
+
const { goToInitialView, view } = useViewContext();
|
|
50
50
|
const isChainalysisView = view === 'chainalysis-blocked-wallet';
|
|
51
51
|
const _socialMediaLinkText = !isChainalysisView
|
|
52
52
|
? socialMediaLinkText
|
|
@@ -55,7 +55,7 @@ const NoAccess = () => {
|
|
|
55
55
|
? socialMediaUrl
|
|
56
56
|
: 'https://docs.dynamic.xyz/docs';
|
|
57
57
|
const handleChangeWallet = () => {
|
|
58
|
-
|
|
58
|
+
goToInitialView();
|
|
59
59
|
setDeniedAddress('');
|
|
60
60
|
setDeniedOauthProvider(undefined);
|
|
61
61
|
walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.endSession();
|