@dynamic-labs/sdk-react-core 0.19.0-alpha.0 → 0.19.0-alpha.1
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 +31 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +11 -10
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/lib/Main.cjs +5 -0
- package/src/lib/Main.js +5 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +9 -6
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +9 -6
- package/src/lib/components/Button/Button.cjs +10 -7
- package/src/lib/components/Button/Button.d.ts +3 -3
- package/src/lib/components/Button/Button.js +10 -7
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
- package/src/lib/components/Icon/Icon.cjs +1 -0
- package/src/lib/components/Icon/Icon.js +1 -0
- package/src/lib/components/Icon/Icon.types.d.ts +1 -1
- package/src/lib/components/IconWithSpinner/IconWithSpinner.d.ts +1 -1
- package/src/lib/components/ListTile/ListTile.cjs +1 -1
- package/src/lib/components/ListTile/ListTile.js +1 -1
- package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
- package/src/lib/components/ModalHeader/ModalHeader.cjs +2 -2
- package/src/lib/components/ModalHeader/ModalHeader.js +2 -2
- package/src/lib/components/ModalHeader/ModalHeader.types.d.ts +2 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.cjs +1 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.js +1 -1
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
- package/src/lib/components/PoweredByDynamic/PoweredByDynamic.cjs +6 -2
- package/src/lib/components/PoweredByDynamic/PoweredByDynamic.d.ts +1 -0
- package/src/lib/components/PoweredByDynamic/PoweredByDynamic.js +6 -2
- package/src/lib/components/UserProfileForm/UserProfileForm.cjs +26 -14
- package/src/lib/components/UserProfileForm/UserProfileForm.d.ts +14 -3
- package/src/lib/components/UserProfileForm/UserProfileForm.js +27 -15
- package/src/lib/components/UserProfileForm/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +9 -3
- package/src/lib/context/DynamicContext/DynamicContext.js +10 -4
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/data/api.cjs +16 -0
- package/src/lib/data/api.d.ts +1 -0
- package/src/lib/data/api.js +18 -3
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +10 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +10 -2
- package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
- package/src/lib/shared/assets/double-arrow-right.js +29 -0
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +3 -1
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +3 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
- package/src/lib/utils/functions/getUserProfileFields/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +2 -0
- package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -4
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +3 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -4
- package/src/lib/utils/hooks/index.d.ts +4 -1
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
- package/src/lib/utils/hooks/useFindSocialIcon/index.d.ts +1 -0
- package/src/lib/utils/hooks/{useGetSocialIcon/useGetSocialIcon.cjs → useFindSocialIcon/useFindSocialIcon.cjs} +3 -3
- package/src/lib/utils/hooks/useFindSocialIcon/useFindSocialIcon.d.ts +3 -0
- package/src/lib/utils/hooks/useFindSocialIcon/useFindSocialIcon.js +10 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +61 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useWalletConnectorEvent/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.cjs +42 -0
- package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.d.ts +12 -0
- package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.js +38 -0
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +12 -0
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +12 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +91 -136
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +92 -137
- package/src/lib/views/AccountExistsView/AccountExistsView.cjs +3 -3
- package/src/lib/views/AccountExistsView/AccountExistsView.js +3 -3
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +8 -2
- package/src/lib/views/EmailUpdate/EmailUpdate.js +8 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +13 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +15 -6
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +5 -3
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +6 -4
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +3 -3
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +3 -3
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +107 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +103 -0
- package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +13 -3
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +13 -3
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +14 -4
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +14 -4
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +3 -3
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +3 -3
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +3 -3
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +3 -3
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +2 -8
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +3 -9
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.cjs +2 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.js +2 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +1 -1
- package/src/lib/utils/hooks/useGetSocialIcon/index.d.ts +0 -1
- package/src/lib/utils/hooks/useGetSocialIcon/useGetSocialIcon.d.ts +0 -2
- package/src/lib/utils/hooks/useGetSocialIcon/useGetSocialIcon.js +0 -10
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
|
+
import { WalletIcon } from '@dynamic-labs/wallet-book';
|
|
5
|
+
import { UserProfileIcon } from '@dynamic-labs/iconic';
|
|
6
|
+
import 'react';
|
|
7
|
+
import { Typography } from '../../components/Typography/Typography.js';
|
|
8
|
+
import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import { ReactComponent as SvgDoubleArrowRight } from '../../shared/assets/double-arrow-right.js';
|
|
12
|
+
import '../../shared/logger.js';
|
|
13
|
+
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
14
|
+
import '../../utils/constants/colors.js';
|
|
15
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
+
import 'ethers';
|
|
17
|
+
import '../../shared/consts/index.js';
|
|
18
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
|
|
19
|
+
import { storeAuthToken } from '../../utils/functions/storeAuthToken/index.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import { createUserProfile } from '../../utils/functions/createUserProfile/createUserProfile.js';
|
|
22
|
+
import '@dynamic-labs/sdk-api';
|
|
23
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
24
|
+
import '../../context/ThemeContext/ThemeContext.js';
|
|
25
|
+
import { Icon } from '../../components/Icon/Icon.js';
|
|
26
|
+
import 'react-dom';
|
|
27
|
+
import 'react-focus-lock';
|
|
28
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
29
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
30
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
31
|
+
import { mergeUserAccounts } from '../../data/api.js';
|
|
32
|
+
import '@dynamic-labs/rpc-providers';
|
|
33
|
+
import '../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
34
|
+
import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
|
|
35
|
+
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
36
|
+
import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
37
|
+
import '../../components/IconButton/IconButton.js';
|
|
38
|
+
import { Button } from '../../components/Button/Button.js';
|
|
39
|
+
import '../../components/Alert/Alert.js';
|
|
40
|
+
import '../../context/MockContext/MockContext.js';
|
|
41
|
+
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
42
|
+
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
43
|
+
import { shortenEmail } from '../../shared/utils/functions/shortenEmail/shortenEmail.js';
|
|
44
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
45
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
46
|
+
import 'formik';
|
|
47
|
+
import 'yup';
|
|
48
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
49
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
50
|
+
import { useEmailVerificationContext } from '../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
51
|
+
|
|
52
|
+
const MergeUserAccountsView = () => {
|
|
53
|
+
const { environmentId, setUser, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, primaryWallet, user, authToken, onboardingOnlyJwt, } = useInternalDynamicContext();
|
|
54
|
+
const { setError } = useErrorContext();
|
|
55
|
+
const { setView, goToInitialView } = useViewContext();
|
|
56
|
+
const { email } = useEmailVerificationContext();
|
|
57
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
58
|
+
// If user tries to merge during KYC step, authToken is undefined and onboardingOnlyJwt is defined
|
|
59
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
60
|
+
const handleMergeUserAccounts = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
if (!jwtToken) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const newJwt = yield mergeUserAccounts(jwtToken, environmentId);
|
|
66
|
+
if (newJwt) {
|
|
67
|
+
storeAuthToken(newJwt);
|
|
68
|
+
const decodedJwt = decodeJwt(newJwt);
|
|
69
|
+
if (decodedJwt === undefined) {
|
|
70
|
+
throw new DynamicError('Invalid token!');
|
|
71
|
+
}
|
|
72
|
+
const newUser = createUserProfile(decodedJwt);
|
|
73
|
+
setOnboardingOnlyJwt(undefined);
|
|
74
|
+
setUser(newUser);
|
|
75
|
+
setShowAuthFlow(false);
|
|
76
|
+
setCallback('authSuccess');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
throw new DynamicError('Something went wrong, please try again.');
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
setError('Something went wrong, please try again.');
|
|
83
|
+
goToInitialView();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const handleUseDifferentEmail = () => {
|
|
87
|
+
setError(undefined);
|
|
88
|
+
if (user) {
|
|
89
|
+
setShowAuthFlow(false);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
setView('collect-user-data');
|
|
93
|
+
};
|
|
94
|
+
return (jsxs("div", Object.assign({ className: 'merge-user-accounts__container' }, { children: [jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts' }, { children: [jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsx(WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) }))] })), jsx("div", Object.assign({ className: 'merge-user-accounts__accounts__divider' }, { children: jsx(Icon, Object.assign({ color: 'text-secondary', size: 'small' }, { children: jsx(SvgDoubleArrowRight, {}) })) })), jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsx(UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenEmail(email, {
|
|
95
|
+
breakpoint: 4,
|
|
96
|
+
cutEnd: 1,
|
|
97
|
+
cutStart: 2,
|
|
98
|
+
}) }))] }))] })), jsx(Typography, Object.assign({ weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header' }, { children: "Would you like to link this wallet to this existing account?" })), jsxs(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body' }, { children: ["An account already exists that uses", ' ', jsx("span", Object.assign({ className: 'merge-user-accounts__text--bold' }, { children: shortenEmail(email, {
|
|
99
|
+
breakpoint: 14,
|
|
100
|
+
}) })), ' ', "email."] })), jsxs("div", Object.assign({ className: 'merge-user-accounts__buttons' }, { children: [jsx(Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Yes, link to existing account" })), jsx(Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "No, I'll use a different email" }))] }))] })));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { MergeUserAccountsView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MergeUserAccountsView } from './MergeUserAccountsView';
|
|
@@ -53,10 +53,12 @@ var SelectNetworkButton = require('../../components/SelectNetworkButton/SelectNe
|
|
|
53
53
|
var useApplyWalletConnectorNetwork = require('../../utils/hooks/useApplyWalletConnectorNetwork/useApplyWalletConnectorNetwork.cjs');
|
|
54
54
|
|
|
55
55
|
const NetworkNotSupported = () => {
|
|
56
|
-
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
56
|
+
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
57
57
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
58
58
|
const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
59
|
-
const finishConnectAndSign = useConnectAndSign.useConnectAndSign(
|
|
59
|
+
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
60
|
+
shouldUpdateWallets: !isFullyConnected,
|
|
61
|
+
});
|
|
60
62
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
61
63
|
// Finishes auth flow when wallet switches to proper network
|
|
62
64
|
React.useEffect(() => {
|
|
@@ -64,8 +66,16 @@ const NetworkNotSupported = () => {
|
|
|
64
66
|
finishConnectAndSign({
|
|
65
67
|
walletConnector: walletConnector,
|
|
66
68
|
});
|
|
69
|
+
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
70
|
+
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
71
|
+
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
72
|
+
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
73
|
+
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
74
|
+
if (isFullyConnected) {
|
|
75
|
+
setShowAuthFlow(false);
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
|
-
}, [walletConnectorNetwork]);
|
|
78
|
+
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
69
79
|
// Updates the contexts 'network' based on the selected wallet connector.
|
|
70
80
|
// It helps ensure that the 'network' is always in sync with the wallet's actual network,
|
|
71
81
|
// Prevents 'network' from being 'undefined'.
|
|
@@ -49,10 +49,12 @@ import { SelectNetworkButton } from '../../components/SelectNetworkButton/Select
|
|
|
49
49
|
import { useApplyWalletConnectorNetwork } from '../../utils/hooks/useApplyWalletConnectorNetwork/useApplyWalletConnectorNetwork.js';
|
|
50
50
|
|
|
51
51
|
const NetworkNotSupported = () => {
|
|
52
|
-
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, } = useInternalDynamicContext();
|
|
52
|
+
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext();
|
|
53
53
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
54
54
|
const { data: walletConnectorNetwork } = usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
55
|
-
const finishConnectAndSign = useConnectAndSign(
|
|
55
|
+
const finishConnectAndSign = useConnectAndSign({
|
|
56
|
+
shouldUpdateWallets: !isFullyConnected,
|
|
57
|
+
});
|
|
56
58
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
57
59
|
// Finishes auth flow when wallet switches to proper network
|
|
58
60
|
useEffect(() => {
|
|
@@ -60,8 +62,16 @@ const NetworkNotSupported = () => {
|
|
|
60
62
|
finishConnectAndSign({
|
|
61
63
|
walletConnector: walletConnector,
|
|
62
64
|
});
|
|
65
|
+
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
66
|
+
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
67
|
+
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
68
|
+
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
69
|
+
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
70
|
+
if (isFullyConnected) {
|
|
71
|
+
setShowAuthFlow(false);
|
|
72
|
+
}
|
|
63
73
|
}
|
|
64
|
-
}, [walletConnectorNetwork]);
|
|
74
|
+
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
65
75
|
// Updates the contexts 'network' based on the selected wallet connector.
|
|
66
76
|
// It helps ensure that the 'network' is always in sync with the wallet's actual network,
|
|
67
77
|
// Prevents 'network' from being 'undefined'.
|
|
@@ -54,20 +54,30 @@ var useApplyWalletConnectorNetwork = require('../../utils/hooks/useApplyWalletCo
|
|
|
54
54
|
// as the wallet does not support programmatic network change.
|
|
55
55
|
const NetworkNotSupportedSwitchManual = () => {
|
|
56
56
|
var _a, _b;
|
|
57
|
-
const { user, selectedWalletConnector: walletConnector, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
57
|
+
const { user, selectedWalletConnector: walletConnector, connectedWallets, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
58
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
59
59
|
const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), {
|
|
60
60
|
deps: [walletConnector, connectedWallets],
|
|
61
61
|
});
|
|
62
|
-
const finishConnectAndSign = useConnectAndSign.useConnectAndSign(
|
|
62
|
+
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
63
|
+
shouldUpdateWallets: !isFullyConnected,
|
|
64
|
+
});
|
|
63
65
|
// Finishes auth flow when wallet switches to proper network
|
|
64
66
|
React.useEffect(() => {
|
|
65
67
|
if (isSupportedNetwork.isSupportedNetwork({ network: walletConnectorNetwork, walletConnector })) {
|
|
66
68
|
finishConnectAndSign({
|
|
67
69
|
walletConnector: walletConnector,
|
|
68
70
|
});
|
|
71
|
+
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
72
|
+
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
73
|
+
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
74
|
+
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
75
|
+
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
76
|
+
if (isFullyConnected) {
|
|
77
|
+
setShowAuthFlow(false);
|
|
78
|
+
}
|
|
69
79
|
}
|
|
70
|
-
}, [walletConnectorNetwork]);
|
|
80
|
+
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
71
81
|
// Updates the contexts 'network' based on the selected wallet connector.
|
|
72
82
|
// It helps ensure that the 'network' is always in sync with the wallet's actual network,
|
|
73
83
|
// Prevents 'network' from being 'undefined'.
|
|
@@ -78,7 +88,7 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
78
88
|
width: pixelToRem.pixelToRem(iconSize * IconWithSpinner.iconRatio),
|
|
79
89
|
} }));
|
|
80
90
|
const walletConnectorNetworks = getWalletConnectorNetworks.getWalletConnectorNetworks(walletConnector);
|
|
81
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported-switch-manual' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__img-container' }, { children: ((_a = user === null || user === void 0 ? void 0 : user.ens) === null || _a === void 0 ? void 0 : _a.avatar) ? (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsxRuntime.jsx("img", { src: (_b = user === null || user === void 0 ? void 0 : user.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported-switch-manual__img' }) }))) : (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: icon, iconSize: iconSize, isSpinning: true }) }))) })), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported-switch-manual__content' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ className: 'network-not-supported-switch-manual__title', weight: 'medium', variant: 'title', color: 'primary' }, { children: "Update your Network" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', color: 'secondary' }, { children: walletConnectorNetworks.length
|
|
91
|
+
return (jsxRuntime.jsxs("div", Object.assign({ "data-testid": 'network-not-supported', className: 'network-not-supported-switch-manual' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__img-container' }, { children: ((_a = user === null || user === void 0 ? void 0 : user.ens) === null || _a === void 0 ? void 0 : _a.avatar) ? (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsxRuntime.jsx("img", { src: (_b = user === null || user === void 0 ? void 0 : user.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported-switch-manual__img' }) }))) : (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: icon, iconSize: iconSize, isSpinning: true }) }))) })), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported-switch-manual__content' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ className: 'network-not-supported-switch-manual__title', weight: 'medium', variant: 'title', color: 'primary' }, { children: "Update your Network" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', color: 'secondary' }, { children: walletConnectorNetworks.length
|
|
82
92
|
? `To continue, please update the network in your wallet to ${walletConnectorNetworks[0].name}`
|
|
83
93
|
: 'Your wallet does not support switching networks from this app. Switch networks directly in your wallet.' }))] }))] })));
|
|
84
94
|
};
|
|
@@ -50,20 +50,30 @@ import { useApplyWalletConnectorNetwork } from '../../utils/hooks/useApplyWallet
|
|
|
50
50
|
// as the wallet does not support programmatic network change.
|
|
51
51
|
const NetworkNotSupportedSwitchManual = () => {
|
|
52
52
|
var _a, _b;
|
|
53
|
-
const { user, selectedWalletConnector: walletConnector, connectedWallets, } = useInternalDynamicContext();
|
|
53
|
+
const { user, selectedWalletConnector: walletConnector, connectedWallets, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext();
|
|
54
54
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
55
55
|
const { data: walletConnectorNetwork } = usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), {
|
|
56
56
|
deps: [walletConnector, connectedWallets],
|
|
57
57
|
});
|
|
58
|
-
const finishConnectAndSign = useConnectAndSign(
|
|
58
|
+
const finishConnectAndSign = useConnectAndSign({
|
|
59
|
+
shouldUpdateWallets: !isFullyConnected,
|
|
60
|
+
});
|
|
59
61
|
// Finishes auth flow when wallet switches to proper network
|
|
60
62
|
useEffect(() => {
|
|
61
63
|
if (isSupportedNetwork({ network: walletConnectorNetwork, walletConnector })) {
|
|
62
64
|
finishConnectAndSign({
|
|
63
65
|
walletConnector: walletConnector,
|
|
64
66
|
});
|
|
67
|
+
// there are two scenarios here, one in not connected state and the other one in connected state.
|
|
68
|
+
// previously we were calling setShowAuthFlow(false) in useHandleWalletsToConnect.
|
|
69
|
+
// now, we don't call it in network-not-supported view, so we need to handle that scenario and close modal here
|
|
70
|
+
// this should be gone, once we're done with the useConnectAndSign hook refactor.
|
|
71
|
+
// TODO: https://linear.app/dynamic-labs/issue/QNTM-117/break-useconnectandsign-hook-to-small-parts
|
|
72
|
+
if (isFullyConnected) {
|
|
73
|
+
setShowAuthFlow(false);
|
|
74
|
+
}
|
|
65
75
|
}
|
|
66
|
-
}, [walletConnectorNetwork]);
|
|
76
|
+
}, [walletConnectorNetwork, setShowAuthFlow, isFullyConnected]);
|
|
67
77
|
// Updates the contexts 'network' based on the selected wallet connector.
|
|
68
78
|
// It helps ensure that the 'network' is always in sync with the wallet's actual network,
|
|
69
79
|
// Prevents 'network' from being 'undefined'.
|
|
@@ -74,7 +84,7 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
74
84
|
width: pixelToRem(iconSize * iconRatio),
|
|
75
85
|
} }));
|
|
76
86
|
const walletConnectorNetworks = getWalletConnectorNetworks(walletConnector);
|
|
77
|
-
return (jsxs("div", Object.assign({ className: 'network-not-supported-switch-manual' }, { children: [jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__img-container' }, { children: ((_a = user === null || user === void 0 ? void 0 : user.ens) === null || _a === void 0 ? void 0 : _a.avatar) ? (jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsx("img", { src: (_b = user === null || user === void 0 ? void 0 : user.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported-switch-manual__img' }) }))) : (jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsx(IconWithSpinner, { Icon: icon, iconSize: iconSize, isSpinning: true }) }))) })), jsxs("div", Object.assign({ className: 'network-not-supported-switch-manual__content' }, { children: [jsx(Typography, Object.assign({ className: 'network-not-supported-switch-manual__title', weight: 'medium', variant: 'title', color: 'primary' }, { children: "Update your Network" })), jsx(Typography, Object.assign({ variant: 'body_normal', color: 'secondary' }, { children: walletConnectorNetworks.length
|
|
87
|
+
return (jsxs("div", Object.assign({ "data-testid": 'network-not-supported', className: 'network-not-supported-switch-manual' }, { children: [jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__img-container' }, { children: ((_a = user === null || user === void 0 ? void 0 : user.ens) === null || _a === void 0 ? void 0 : _a.avatar) ? (jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsx("img", { src: (_b = user === null || user === void 0 ? void 0 : user.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported-switch-manual__img' }) }))) : (jsx("div", Object.assign({ className: 'network-not-supported-switch-manual__network-container' }, { children: jsx(IconWithSpinner, { Icon: icon, iconSize: iconSize, isSpinning: true }) }))) })), jsxs("div", Object.assign({ className: 'network-not-supported-switch-manual__content' }, { children: [jsx(Typography, Object.assign({ className: 'network-not-supported-switch-manual__title', weight: 'medium', variant: 'title', color: 'primary' }, { children: "Update your Network" })), jsx(Typography, Object.assign({ variant: 'body_normal', color: 'secondary' }, { children: walletConnectorNetworks.length
|
|
78
88
|
? `To continue, please update the network in your wallet to ${walletConnectorNetworks[0].name}`
|
|
79
89
|
: 'Your wallet does not support switching networks from this app. Switch networks directly in your wallet.' }))] }))] })));
|
|
80
90
|
};
|
|
@@ -38,7 +38,7 @@ require('../../components/Alert/Alert.cjs');
|
|
|
38
38
|
require('../../context/MockContext/MockContext.cjs');
|
|
39
39
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
40
40
|
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
41
|
-
var
|
|
41
|
+
var useFindSocialIcon = require('../../utils/hooks/useFindSocialIcon/useFindSocialIcon.cjs');
|
|
42
42
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
43
43
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
44
44
|
require('formik');
|
|
@@ -50,11 +50,11 @@ var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialR
|
|
|
50
50
|
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
51
51
|
const SocialRedirectView = () => {
|
|
52
52
|
const { socialProvider, socialWalletConnector } = SocialRedirectContext.useSocialRedirectContext();
|
|
53
|
-
const
|
|
53
|
+
const findSocialIcon = useFindSocialIcon.useFindSocialIcon();
|
|
54
54
|
if (!socialWalletConnector || !socialProvider) {
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-redirect-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon:
|
|
57
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-redirect-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: findSocialIcon(socialProvider), isSpinning: true }), jsxRuntime.jsxs(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames.classNames('social-redirect-view__title') }, { children: ["Connecting to ", capitalize(socialProvider), "..."] }))] })));
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
exports.SocialRedirectView = SocialRedirectView;
|
|
@@ -34,7 +34,7 @@ import '../../components/Alert/Alert.js';
|
|
|
34
34
|
import '../../context/MockContext/MockContext.js';
|
|
35
35
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
36
36
|
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
37
|
-
import {
|
|
37
|
+
import { useFindSocialIcon } from '../../utils/hooks/useFindSocialIcon/useFindSocialIcon.js';
|
|
38
38
|
import '../../components/Popper/Popper/Popper.js';
|
|
39
39
|
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
40
40
|
import 'formik';
|
|
@@ -46,11 +46,11 @@ import { useSocialRedirectContext } from '../../context/SocialRedirectContext/So
|
|
|
46
46
|
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
47
47
|
const SocialRedirectView = () => {
|
|
48
48
|
const { socialProvider, socialWalletConnector } = useSocialRedirectContext();
|
|
49
|
-
const
|
|
49
|
+
const findSocialIcon = useFindSocialIcon();
|
|
50
50
|
if (!socialWalletConnector || !socialProvider) {
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
|
-
return (jsxs("div", Object.assign({ className: classNames('social-redirect-view__container') }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon:
|
|
53
|
+
return (jsxs("div", Object.assign({ className: classNames('social-redirect-view__container') }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon: findSocialIcon(socialProvider), isSpinning: true }), jsxs(Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title') }, { children: ["Connecting to ", capitalize(socialProvider), "..."] }))] })));
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export { SocialRedirectView };
|
|
@@ -39,7 +39,7 @@ require('../../components/Alert/Alert.cjs');
|
|
|
39
39
|
require('../../context/MockContext/MockContext.cjs');
|
|
40
40
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
41
41
|
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
42
|
-
var
|
|
42
|
+
var useFindSocialIcon = require('../../utils/hooks/useFindSocialIcon/useFindSocialIcon.cjs');
|
|
43
43
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
44
44
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
45
45
|
require('formik');
|
|
@@ -51,10 +51,10 @@ var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialR
|
|
|
51
51
|
const SocialWrongAccountView = () => {
|
|
52
52
|
const [tryAgainClicked, setTryAgainClicked] = React.useState(false);
|
|
53
53
|
const { socialWalletConnector, socialAccount } = SocialRedirectContext.useSocialRedirectContext();
|
|
54
|
-
const
|
|
54
|
+
const findSocialIcon = useFindSocialIcon.useFindSocialIcon();
|
|
55
55
|
if (!socialAccount || !socialWalletConnector)
|
|
56
56
|
return null;
|
|
57
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-wrong-account-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon:
|
|
57
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-wrong-account-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(socialAccount.oauthProvider), isSpinning: tryAgainClicked, iconSize: 64 }), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames.classNames('social-wrong-account-view__title') }, { children: "Whoops. Wrong Account" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames.classNames('social-wrong-account-view__copy') }, { children: "You must connect with the same account you originally signed in with." })), jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames.classNames('social-wrong-account-view__copy') }, { children: ["Please connect with: ", jsxRuntime.jsx("b", { children: socialAccount.oauthUsername })] })), jsxRuntime.jsx(Button.Button, Object.assign({ buttonClassName: 'social-wrong-account-view__button', buttonRounded: 'medium', buttonVariant: 'primary', buttonPadding: 'large', expanded: true, typographyProps: {
|
|
58
58
|
variant: 'button_primary',
|
|
59
59
|
weight: 'medium',
|
|
60
60
|
}, disabled: tryAgainClicked, onClick: () => {
|
|
@@ -35,7 +35,7 @@ import '../../components/Alert/Alert.js';
|
|
|
35
35
|
import '../../context/MockContext/MockContext.js';
|
|
36
36
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
37
37
|
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
38
|
-
import {
|
|
38
|
+
import { useFindSocialIcon } from '../../utils/hooks/useFindSocialIcon/useFindSocialIcon.js';
|
|
39
39
|
import '../../components/Popper/Popper/Popper.js';
|
|
40
40
|
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
41
41
|
import 'formik';
|
|
@@ -47,10 +47,10 @@ import { useSocialRedirectContext } from '../../context/SocialRedirectContext/So
|
|
|
47
47
|
const SocialWrongAccountView = () => {
|
|
48
48
|
const [tryAgainClicked, setTryAgainClicked] = useState(false);
|
|
49
49
|
const { socialWalletConnector, socialAccount } = useSocialRedirectContext();
|
|
50
|
-
const
|
|
50
|
+
const findSocialIcon = useFindSocialIcon();
|
|
51
51
|
if (!socialAccount || !socialWalletConnector)
|
|
52
52
|
return null;
|
|
53
|
-
return (jsxs("div", Object.assign({ className: classNames('social-wrong-account-view__container') }, { children: [jsx(IconWithSpinner, { Icon:
|
|
53
|
+
return (jsxs("div", Object.assign({ className: classNames('social-wrong-account-view__container') }, { children: [jsx(IconWithSpinner, { Icon: findSocialIcon(socialAccount.oauthProvider), isSpinning: tryAgainClicked, iconSize: 64 }), jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames('social-wrong-account-view__title') }, { children: "Whoops. Wrong Account" })), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames('social-wrong-account-view__copy') }, { children: "You must connect with the same account you originally signed in with." })), jsxs(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames('social-wrong-account-view__copy') }, { children: ["Please connect with: ", jsx("b", { children: socialAccount.oauthUsername })] })), jsx(Button, Object.assign({ buttonClassName: 'social-wrong-account-view__button', buttonRounded: 'medium', buttonVariant: 'primary', buttonPadding: 'large', expanded: true, typographyProps: {
|
|
54
54
|
variant: 'button_primary',
|
|
55
55
|
weight: 'medium',
|
|
56
56
|
}, disabled: tryAgainClicked, onClick: () => {
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs
CHANGED
|
@@ -43,20 +43,14 @@ require('../../../../context/MockContext/MockContext.cjs');
|
|
|
43
43
|
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
44
44
|
var usePromise = require('../../../../utils/hooks/usePromise/usePromise.cjs');
|
|
45
45
|
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
46
|
+
var useTransactionEstimatedGas = require('../../../../utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs');
|
|
46
47
|
|
|
47
48
|
const useTransactionData = ({ provider, transaction, }) => {
|
|
48
49
|
const { data: transactionValue, isLoading: isEffectiveValueLoading } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
50
|
const val = yield transaction.value;
|
|
50
51
|
return val ? ethers.ethers.BigNumber.from(val) : undefined;
|
|
51
52
|
}));
|
|
52
|
-
const { data: estimatedGas, isLoading: isEstimatedGasLoading } =
|
|
53
|
-
// To safely run estimateGas using alchemy, we need to remove the from address
|
|
54
|
-
// because alchemy checks the origin address funds and can return an error if
|
|
55
|
-
// origin wallet has no funds for the transaction
|
|
56
|
-
// https://docs.alchemy.com/reference/eth-estimategas
|
|
57
|
-
const transactionWithNoOrigin = _tslib.__rest(transaction, ["from"]);
|
|
58
|
-
return provider.estimateGas(transactionWithNoOrigin);
|
|
59
|
-
});
|
|
53
|
+
const { data: estimatedGas, isLoading: isEstimatedGasLoading } = useTransactionEstimatedGas.useTransactionEstimatedGas(provider, transaction);
|
|
60
54
|
const { data: gasPrice, isLoading: isFeeDataLoading } = usePromise.usePromise(() => provider.getGasPrice());
|
|
61
55
|
const isGasPriceLoading = isEstimatedGasLoading || isFeeDataLoading;
|
|
62
56
|
const gasEstimate = React.useMemo(() => gasPrice && estimatedGas
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __awaiter
|
|
1
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import '@dynamic-labs/utils';
|
|
@@ -39,20 +39,14 @@ import '../../../../context/MockContext/MockContext.js';
|
|
|
39
39
|
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
40
40
|
import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
|
|
41
41
|
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
42
|
+
import { useTransactionEstimatedGas } from '../../../../utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js';
|
|
42
43
|
|
|
43
44
|
const useTransactionData = ({ provider, transaction, }) => {
|
|
44
45
|
const { data: transactionValue, isLoading: isEffectiveValueLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
46
|
const val = yield transaction.value;
|
|
46
47
|
return val ? ethers.BigNumber.from(val) : undefined;
|
|
47
48
|
}));
|
|
48
|
-
const { data: estimatedGas, isLoading: isEstimatedGasLoading } =
|
|
49
|
-
// To safely run estimateGas using alchemy, we need to remove the from address
|
|
50
|
-
// because alchemy checks the origin address funds and can return an error if
|
|
51
|
-
// origin wallet has no funds for the transaction
|
|
52
|
-
// https://docs.alchemy.com/reference/eth-estimategas
|
|
53
|
-
const transactionWithNoOrigin = __rest(transaction, ["from"]);
|
|
54
|
-
return provider.estimateGas(transactionWithNoOrigin);
|
|
55
|
-
});
|
|
49
|
+
const { data: estimatedGas, isLoading: isEstimatedGasLoading } = useTransactionEstimatedGas(provider, transaction);
|
|
56
50
|
const { data: gasPrice, isLoading: isFeeDataLoading } = usePromise(() => provider.getGasPrice());
|
|
57
51
|
const isGasPriceLoading = isEstimatedGasLoading || isFeeDataLoading;
|
|
58
52
|
const gasEstimate = useMemo(() => gasPrice && estimatedGas
|
|
@@ -29,6 +29,7 @@ var BridgeWelcomeView = require('./BridgeWelcomeView/BridgeWelcomeView.cjs');
|
|
|
29
29
|
var BridgeSummaryView = require('./BridgeSummaryView/BridgeSummaryView.cjs');
|
|
30
30
|
var BridgeNextWalletConnectionView = require('./BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs');
|
|
31
31
|
var AccountExistsView = require('./AccountExistsView/AccountExistsView.cjs');
|
|
32
|
+
var MergeUserAccountsView = require('./MergeUserAccountsView/MergeUserAccountsView.cjs');
|
|
32
33
|
|
|
33
34
|
const viewToComponentMap = {
|
|
34
35
|
'account-exists': jsxRuntime.jsx(AccountExistsView.AccountExistsView, {}),
|
|
@@ -44,6 +45,7 @@ const viewToComponentMap = {
|
|
|
44
45
|
'login-with-email-or-wallet': jsxRuntime.jsx(LoginWithEmailView.LoginWithEmailView, {}),
|
|
45
46
|
'login-with-email-or-wallet-full-wallet-list': jsxRuntime.jsx(WalletList.WalletList, {}),
|
|
46
47
|
'login-with-email-verification': jsxRuntime.jsx(EmailVerification.EmailVerification, {}),
|
|
48
|
+
'merge-user-accounts': jsxRuntime.jsx(MergeUserAccountsView.MergeUserAccountsView, {}),
|
|
47
49
|
'network-not-supported': jsxRuntime.jsx(NetworkNotSupported.NetworkNotSupported, {}),
|
|
48
50
|
'network-not-supported-manual': jsxRuntime.jsx(NetworkNotSupportedSwitchManual.NetworkNotSupportedSwitchManual, {}),
|
|
49
51
|
'no-access': jsxRuntime.jsx(NoAccess.NoAccess, {}),
|
|
@@ -25,6 +25,7 @@ import { BridgeWelcomeView } from './BridgeWelcomeView/BridgeWelcomeView.js';
|
|
|
25
25
|
import { BridgeSummaryView } from './BridgeSummaryView/BridgeSummaryView.js';
|
|
26
26
|
import { BridgeNextWalletConnectionView } from './BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js';
|
|
27
27
|
import { AccountExistsView } from './AccountExistsView/AccountExistsView.js';
|
|
28
|
+
import { MergeUserAccountsView } from './MergeUserAccountsView/MergeUserAccountsView.js';
|
|
28
29
|
|
|
29
30
|
const viewToComponentMap = {
|
|
30
31
|
'account-exists': jsx(AccountExistsView, {}),
|
|
@@ -40,6 +41,7 @@ const viewToComponentMap = {
|
|
|
40
41
|
'login-with-email-or-wallet': jsx(LoginWithEmailView, {}),
|
|
41
42
|
'login-with-email-or-wallet-full-wallet-list': jsx(WalletList, {}),
|
|
42
43
|
'login-with-email-verification': jsx(EmailVerification, {}),
|
|
44
|
+
'merge-user-accounts': jsx(MergeUserAccountsView, {}),
|
|
43
45
|
'network-not-supported': jsx(NetworkNotSupported, {}),
|
|
44
46
|
'network-not-supported-manual': jsx(NetworkNotSupportedSwitchManual, {}),
|
|
45
47
|
'no-access': jsx(NoAccess, {}),
|
|
@@ -32,6 +32,7 @@ require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
|
32
32
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
33
33
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
34
34
|
require('../../../../components/IconButton/IconButton.cjs');
|
|
35
|
+
var DynamicWidgetFooter = require('../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs');
|
|
35
36
|
require('../../../../components/Alert/Alert.cjs');
|
|
36
37
|
require('../../../../context/MockContext/MockContext.cjs');
|
|
37
38
|
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -44,7 +45,6 @@ require('yup');
|
|
|
44
45
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
45
46
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
46
47
|
var Balance = require('../../../DynamicWidget/components/Balance/Balance.cjs');
|
|
47
|
-
var DynamicWidgetFooter = require('../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs');
|
|
48
48
|
var DynamicBridgeWalletCard = require('../../components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.cjs');
|
|
49
49
|
var DynamicBridgeWalletCardBody = require('../../components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs');
|
|
50
50
|
var DynamicBridgeWidgetEmptyCard = require('../../components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.cjs');
|
|
@@ -28,6 +28,7 @@ import '../../../../context/ErrorContext/ErrorContext.js';
|
|
|
28
28
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
29
29
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
30
30
|
import '../../../../components/IconButton/IconButton.js';
|
|
31
|
+
import { DynamicWidgetFooter } from '../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.js';
|
|
31
32
|
import '../../../../components/Alert/Alert.js';
|
|
32
33
|
import '../../../../context/MockContext/MockContext.js';
|
|
33
34
|
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -40,7 +41,6 @@ import 'yup';
|
|
|
40
41
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
41
42
|
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
42
43
|
import { Balance } from '../../../DynamicWidget/components/Balance/Balance.js';
|
|
43
|
-
import { DynamicWidgetFooter } from '../../../DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.js';
|
|
44
44
|
import { DynamicBridgeWalletCard } from '../../components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.js';
|
|
45
45
|
import { DynamicBridgeWalletCardBody } from '../../components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js';
|
|
46
46
|
import { DynamicBridgeWidgetEmptyCard } from '../../components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js';
|
|
@@ -20,7 +20,8 @@ const DynamicNav = () => {
|
|
|
20
20
|
[];
|
|
21
21
|
if (!projectSettings)
|
|
22
22
|
return null;
|
|
23
|
-
|
|
23
|
+
const shouldHideNetwork = projectSettings.sdk.hideNetworkInDynamicWidget;
|
|
24
|
+
return (jsxRuntime.jsx(IsBrowser.IsBrowser, { children: jsxRuntime.jsxs("div", Object.assign({ ref: inlineControlsRef, "data-testid": 'DynamicNav', className: 'dynamic-widget-inline-controls' }, { children: [!shouldHideNetwork && primaryWallet && (jsxRuntime.jsx(NetworkPicker.NetworkPicker, { connector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, showNetworkName: true, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, mainClassName: 'dynamic-widget-inline-controls__network-picker-main', buttonClassName: 'dynamic-widget-inline-controls__network-picker', listClassName: 'dynamic-widget-inline-controls__network-picker-list', checkboxClassName: 'dynamic-widget-inline-controls__network-picker-checkbox', evmNetworks: evmNetworks })), jsxRuntime.jsx("div", Object.assign({ className: 'dynamic-widget-inline-controls__account-control-container' }, { children: jsxRuntime.jsx(AccountControl.AccountControl, { className: 'dynamic-widget-inline-controls__account-control' }) }))] })) }));
|
|
24
25
|
};
|
|
25
26
|
const ShadowedDynamicNav = () => (jsxRuntime.jsx(ShadowDOM.ShadowDOM, { children: jsxRuntime.jsx(DynamicNav, {}) }));
|
|
26
27
|
|
|
@@ -16,7 +16,8 @@ const DynamicNav = () => {
|
|
|
16
16
|
[];
|
|
17
17
|
if (!projectSettings)
|
|
18
18
|
return null;
|
|
19
|
-
|
|
19
|
+
const shouldHideNetwork = projectSettings.sdk.hideNetworkInDynamicWidget;
|
|
20
|
+
return (jsx(IsBrowser, { children: jsxs("div", Object.assign({ ref: inlineControlsRef, "data-testid": 'DynamicNav', className: 'dynamic-widget-inline-controls' }, { children: [!shouldHideNetwork && primaryWallet && (jsx(NetworkPicker, { connector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, showNetworkName: true, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, mainClassName: 'dynamic-widget-inline-controls__network-picker-main', buttonClassName: 'dynamic-widget-inline-controls__network-picker', listClassName: 'dynamic-widget-inline-controls__network-picker-list', checkboxClassName: 'dynamic-widget-inline-controls__network-picker-checkbox', evmNetworks: evmNetworks })), jsx("div", Object.assign({ className: 'dynamic-widget-inline-controls__account-control-container' }, { children: jsx(AccountControl, { className: 'dynamic-widget-inline-controls__account-control' }) }))] })) }));
|
|
20
21
|
};
|
|
21
22
|
const ShadowedDynamicNav = () => (jsx(ShadowDOM, { children: jsx(DynamicNav, {}) }));
|
|
22
23
|
|
package/src/lib/widgets/DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs
CHANGED
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
|
|
7
|
-
const DynamicWidgetFooter = ({ children }) => (jsxRuntime.jsx("div", Object.assign({ className: 'dynamic-widget-footer' }, { children: children })));
|
|
7
|
+
const DynamicWidgetFooter = ({ children }) => (jsxRuntime.jsx("div", Object.assign({ className: 'dynamic-widget-footer', "data-testid": 'dynamic-widget-footer' }, { children: children })));
|
|
8
8
|
|
|
9
9
|
exports.DynamicWidgetFooter = DynamicWidgetFooter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
const DynamicWidgetFooter = ({ children }) => (jsx("div", Object.assign({ className: 'dynamic-widget-footer' }, { children: children })));
|
|
3
|
+
const DynamicWidgetFooter = ({ children }) => (jsx("div", Object.assign({ className: 'dynamic-widget-footer', "data-testid": 'dynamic-widget-footer' }, { children: children })));
|
|
4
4
|
|
|
5
5
|
export { DynamicWidgetFooter };
|
|
@@ -21,6 +21,7 @@ require('ethers');
|
|
|
21
21
|
require('../../../../shared/consts/index.cjs');
|
|
22
22
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
23
23
|
require('@dynamic-labs/multi-wallet');
|
|
24
|
+
var getUserProfileFields = require('../../../../utils/functions/getUserProfileFields/getUserProfileFields.cjs');
|
|
24
25
|
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
25
26
|
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
26
27
|
require('react-dom');
|
|
@@ -37,7 +38,6 @@ require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
|
37
38
|
require('../../../../components/IconButton/IconButton.cjs');
|
|
38
39
|
var Button = require('../../../../components/Button/Button.cjs');
|
|
39
40
|
require('../../../../components/Alert/Alert.cjs');
|
|
40
|
-
var getUserProfileFields = require('../../../../utils/functions/getUserProfileFields/getUserProfileFields.cjs');
|
|
41
41
|
require('../../../../context/MockContext/MockContext.cjs');
|
|
42
42
|
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
43
43
|
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
@@ -17,6 +17,7 @@ import 'ethers';
|
|
|
17
17
|
import '../../../../shared/consts/index.js';
|
|
18
18
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
19
19
|
import '@dynamic-labs/multi-wallet';
|
|
20
|
+
import { getEditableUserProfileFields } from '../../../../utils/functions/getUserProfileFields/getUserProfileFields.js';
|
|
20
21
|
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
21
22
|
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
22
23
|
import 'react-dom';
|
|
@@ -33,7 +34,6 @@ import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
|
33
34
|
import '../../../../components/IconButton/IconButton.js';
|
|
34
35
|
import { Button } from '../../../../components/Button/Button.js';
|
|
35
36
|
import '../../../../components/Alert/Alert.js';
|
|
36
|
-
import { getEditableUserProfileFields } from '../../../../utils/functions/getUserProfileFields/getUserProfileFields.js';
|
|
37
37
|
import '../../../../context/MockContext/MockContext.js';
|
|
38
38
|
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
39
39
|
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|