@dynamic-labs/sdk-react-core 0.18.0-RC.11 → 0.18.0-RC.13
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 +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/lib/Main.cjs +2 -2
- package/src/lib/Main.js +2 -2
- package/src/lib/assets/index.d.ts +1 -0
- package/src/lib/assets/no-wallet-found.cjs +75 -0
- package/src/lib/assets/no-wallet-found.js +51 -0
- package/src/lib/components/TosAndPp/TosAndPp.cjs +18 -3
- package/src/lib/components/TosAndPp/TosAndPp.d.ts +1 -6
- package/src/lib/components/TosAndPp/TosAndPp.js +19 -4
- package/src/lib/components/WalletInformationCard/WalletInformationCard.cjs +33 -0
- package/src/lib/components/WalletInformationCard/WalletInformationCard.d.ts +11 -0
- package/src/lib/components/WalletInformationCard/WalletInformationCard.js +29 -0
- package/src/lib/components/WalletInformationCard/index.d.ts +1 -0
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +10 -7
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +8 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +10 -7
- package/src/lib/context/WalletContext/WalletContext.cjs +4 -2
- package/src/lib/context/WalletContext/WalletContext.d.ts +3 -1
- package/src/lib/context/WalletContext/WalletContext.js +4 -2
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.cjs +4 -3
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.js +4 -3
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/isEmailProviderEnabled/isEmailProviderEnabled.cjs +1 -0
- package/src/lib/utils/functions/isEmailProviderEnabled/isEmailProviderEnabled.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +5 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -6
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +9 -2
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +5 -2
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +9 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +5 -3
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +5 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +14 -27
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +15 -28
- package/src/lib/utils/hooks/useConnectWithEmail/index.d.ts +1 -0
- package/src/lib/utils/hooks/useConnectWithEmail/useConnectWithEmail.cjs +1 -4
- package/src/lib/utils/hooks/useConnectWithEmail/useConnectWithEmail.d.ts +1 -4
- package/src/lib/utils/hooks/useConnectWithEmail/useConnectWithEmail.js +1 -4
- package/src/lib/utils/hooks/useEmailProvider/index.d.ts +1 -0
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +54 -0
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.d.ts +10 -0
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +50 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +3 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +3 -0
- package/src/lib/utils/hooks/useWalletConnectorEvents/useWalletConnectorEvents.cjs +17 -0
- package/src/lib/utils/hooks/useWalletConnectorEvents/useWalletConnectorEvents.d.ts +2 -0
- package/src/lib/utils/hooks/useWalletConnectorEvents/useWalletConnectorEvents.js +13 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +20 -3
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +3 -2
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +20 -3
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +8 -8
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +8 -8
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +24 -51
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +24 -51
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +7 -5
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +7 -5
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +14 -14
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +14 -14
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +20 -24
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +21 -25
- package/src/lib/views/WalletList/{SearchInstead/SearchInstead.cjs → SearchNotFoundMessage/SearchNotFoundMessage.cjs} +2 -2
- package/src/lib/views/WalletList/SearchNotFoundMessage/SearchNotFoundMessage.d.ts +8 -0
- package/src/lib/views/WalletList/{SearchInstead/SearchInstead.js → SearchNotFoundMessage/SearchNotFoundMessage.js} +2 -2
- package/src/lib/views/WalletList/SearchNotFoundMessage/index.d.ts +1 -0
- package/src/lib/views/WalletList/WalletList.cjs +3 -2
- package/src/lib/views/WalletList/WalletList.js +3 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +27 -8
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.d.ts +0 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +28 -9
- package/src/lib/views/WalletList/SearchInstead/SearchInstead.d.ts +0 -2
- package/src/lib/views/WalletList/SearchInstead/index.d.ts +0 -1
|
@@ -14,7 +14,7 @@ import 'ethers';
|
|
|
14
14
|
import '../../../shared/consts/index.js';
|
|
15
15
|
|
|
16
16
|
const orderedSecondaryWalletAddresses = (wallets) => wallets.map((wallet) => wallet.address).sort();
|
|
17
|
-
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, }) => {
|
|
17
|
+
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, authMode, }) => {
|
|
18
18
|
const [loadingNetwork, setLoadingNetwork] = useState(true);
|
|
19
19
|
const [network, setNetwork] = useState(undefined);
|
|
20
20
|
useEffect(() => {
|
|
@@ -91,6 +91,10 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
91
91
|
onAccountChange: (accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
92
|
const [newAddress] = accounts;
|
|
93
93
|
const newWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
94
|
+
if (authMode === 'connect-only') {
|
|
95
|
+
connectWalletByAddressAndChain(primaryWallet.connector.name, newAddress, primaryWallet.chain);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
94
98
|
if (isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
|
|
95
99
|
setMultiWalletWidgetState('idle');
|
|
96
100
|
}
|
|
@@ -120,11 +124,17 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
120
124
|
yield computeConnectedStateForWallets();
|
|
121
125
|
}),
|
|
122
126
|
onChainChange: (chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
|
|
127
|
+
if (primaryWallet.chain === 'starknet') {
|
|
128
|
+
setNetwork(chain);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
setNetwork(parseInt(chain));
|
|
132
|
+
}
|
|
124
133
|
}),
|
|
125
134
|
onDisconnect: handleLogOut,
|
|
126
135
|
});
|
|
127
136
|
}, [
|
|
137
|
+
authMode,
|
|
128
138
|
primaryWallet,
|
|
129
139
|
setMultiWalletWidgetState,
|
|
130
140
|
multiWallet,
|
|
@@ -140,7 +150,12 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
140
150
|
]);
|
|
141
151
|
const addSecondaryWalletEventListeners = useCallback((seen) => {
|
|
142
152
|
const secondaryListeners = {
|
|
143
|
-
onAccountChange: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
+
onAccountChange: (accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
+
if (authMode === 'connect-only' && secondaryWallets.length) {
|
|
155
|
+
const [newAddress] = accounts;
|
|
156
|
+
connectWalletByAddressAndChain(secondaryWallets[0].connector.name, newAddress, secondaryWallets[0].chain);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
144
159
|
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
145
160
|
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
146
161
|
}
|
|
@@ -162,7 +177,9 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
162
177
|
wallet.connector.setupEventListeners(secondaryListeners);
|
|
163
178
|
}
|
|
164
179
|
}, [
|
|
180
|
+
authMode,
|
|
165
181
|
computeConnectedStateForWallets,
|
|
182
|
+
connectWalletByAddressAndChain,
|
|
166
183
|
selectedWalletConnector,
|
|
167
184
|
selectedWalletWithAction,
|
|
168
185
|
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
@@ -25,20 +25,20 @@ var Balance = require('../../widgets/DynamicWidget/components/Balance/Balance.cj
|
|
|
25
25
|
|
|
26
26
|
const BridgeSummaryView = () => {
|
|
27
27
|
const { primaryWallet, setShowAuthFlow, appName, walletsByChain = [], } = useInternalDynamicContext.useInternalDynamicContext();
|
|
28
|
-
if (!primaryWallet) {
|
|
29
|
-
throw new Error('primaryWallet should be defined');
|
|
30
|
-
}
|
|
31
|
-
const PrimaryWalletChainIcon = getChainIcon.getChainIcon(primaryWallet.chain);
|
|
32
|
-
const primaryWalletChainInfo = walletConnectorCore.getChainInfo(primaryWallet.chain);
|
|
33
28
|
const onClickClose = () => setShowAuthFlow(false);
|
|
34
29
|
const body = React.useMemo(() => {
|
|
35
30
|
const blockchainNames = walletsByChain.map(({ chain }) => { var _a; return (_a = walletConnectorCore.getChainInfo(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
36
31
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
37
32
|
return `Congratulations on connecting both your ${firstBlockchainName} and ${secondBlockchainName} wallets`;
|
|
38
33
|
}, [walletsByChain]);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
const createPrimaryWalletCard = (wallet) => {
|
|
35
|
+
const PrimaryWalletChainIcon = getChainIcon.getChainIcon(wallet.chain);
|
|
36
|
+
const primaryWalletChainInfo = walletConnectorCore.getChainInfo(wallet.chain);
|
|
37
|
+
return (jsxRuntime.jsx(DynamicBridgeWalletCard.DynamicBridgeWalletCard, Object.assign({ networkIcon: jsxRuntime.jsx(PrimaryWalletChainIcon, {}), networkName: primaryWalletChainInfo === null || primaryWalletChainInfo === void 0 ? void 0 : primaryWalletChainInfo.displayName }, { children: jsxRuntime.jsx(DynamicBridgeWalletCardBody.DynamicBridgeWalletCardBody, { walletName: wallet.connector.name, walletAddress: wallet.address, walletBalance:
|
|
38
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
39
|
+
jsxRuntime.jsx(Balance.Balance, { address: wallet.address, connector: wallet.connector, network: wallet.chain }) }) })));
|
|
40
|
+
};
|
|
41
|
+
return (jsxRuntime.jsxs(ConnectedWalletsListLayout.ConnectedWalletsListLayout, Object.assign({ onClickClose: onClickClose, onClickAction: onClickClose, title: `Welcome to ${appName}`, body: body }, { children: [primaryWallet && createPrimaryWalletCard(primaryWallet), jsxRuntime.jsx(SecondaryWallets.MemoSecondaryWallets, { hideUnlinkAction: true })] })));
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
exports.BridgeSummaryView = BridgeSummaryView;
|
|
@@ -21,20 +21,20 @@ import { Balance } from '../../widgets/DynamicWidget/components/Balance/Balance.
|
|
|
21
21
|
|
|
22
22
|
const BridgeSummaryView = () => {
|
|
23
23
|
const { primaryWallet, setShowAuthFlow, appName, walletsByChain = [], } = useInternalDynamicContext();
|
|
24
|
-
if (!primaryWallet) {
|
|
25
|
-
throw new Error('primaryWallet should be defined');
|
|
26
|
-
}
|
|
27
|
-
const PrimaryWalletChainIcon = getChainIcon(primaryWallet.chain);
|
|
28
|
-
const primaryWalletChainInfo = getChainInfo(primaryWallet.chain);
|
|
29
24
|
const onClickClose = () => setShowAuthFlow(false);
|
|
30
25
|
const body = useMemo(() => {
|
|
31
26
|
const blockchainNames = walletsByChain.map(({ chain }) => { var _a; return (_a = getChainInfo(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
32
27
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
33
28
|
return `Congratulations on connecting both your ${firstBlockchainName} and ${secondBlockchainName} wallets`;
|
|
34
29
|
}, [walletsByChain]);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const createPrimaryWalletCard = (wallet) => {
|
|
31
|
+
const PrimaryWalletChainIcon = getChainIcon(wallet.chain);
|
|
32
|
+
const primaryWalletChainInfo = getChainInfo(wallet.chain);
|
|
33
|
+
return (jsx(DynamicBridgeWalletCard, Object.assign({ networkIcon: jsx(PrimaryWalletChainIcon, {}), networkName: primaryWalletChainInfo === null || primaryWalletChainInfo === void 0 ? void 0 : primaryWalletChainInfo.displayName }, { children: jsx(DynamicBridgeWalletCardBody, { walletName: wallet.connector.name, walletAddress: wallet.address, walletBalance:
|
|
34
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
35
|
+
jsx(Balance, { address: wallet.address, connector: wallet.connector, network: wallet.chain }) }) })));
|
|
36
|
+
};
|
|
37
|
+
return (jsxs(ConnectedWalletsListLayout, Object.assign({ onClickClose: onClickClose, onClickAction: onClickClose, title: `Welcome to ${appName}`, body: body }, { children: [primaryWallet && createPrimaryWalletCard(primaryWallet), jsx(MemoSecondaryWallets, { hideUnlinkAction: true })] })));
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export { BridgeSummaryView };
|
package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs
CHANGED
|
@@ -7,113 +7,86 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
9
|
var sdkApi = require('@dynamic-labs/sdk-api');
|
|
10
|
-
require('@dynamic-labs/utils');
|
|
11
|
-
var api = require('../../../../data/api.cjs');
|
|
12
10
|
var logger = require('../../../../shared/logger.cjs');
|
|
13
11
|
require('@dynamic-labs/iconic');
|
|
14
|
-
|
|
12
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
15
13
|
require('@dynamic-labs/wallet-book');
|
|
14
|
+
require('@dynamic-labs/utils');
|
|
16
15
|
require('../../../../utils/constants/colors.cjs');
|
|
17
16
|
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
17
|
require('ethers');
|
|
19
18
|
require('../../../../shared/consts/index.cjs');
|
|
20
|
-
require('@dynamic-labs/multi-wallet');
|
|
21
|
-
require('@dynamic-labs/rpc-providers');
|
|
22
|
-
require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
23
19
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
24
|
-
|
|
25
|
-
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
26
|
-
require('react-dom');
|
|
20
|
+
require('@dynamic-labs/multi-wallet');
|
|
27
21
|
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
28
22
|
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
29
23
|
var Input = require('../../../../components/Input/Input.cjs');
|
|
24
|
+
require('react-dom');
|
|
30
25
|
require('react-focus-lock');
|
|
31
26
|
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
32
27
|
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
33
28
|
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
34
|
-
var
|
|
29
|
+
var api = require('../../../../data/api.cjs');
|
|
30
|
+
require('@dynamic-labs/rpc-providers');
|
|
31
|
+
require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
32
|
+
var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
33
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
35
34
|
require('../../../../components/IconButton/IconButton.cjs');
|
|
35
|
+
var Button = require('../../../../components/Button/Button.cjs');
|
|
36
36
|
require('../../../../components/Alert/Alert.cjs');
|
|
37
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
38
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
39
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
37
40
|
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
38
41
|
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
39
42
|
require('formik');
|
|
40
43
|
require('yup');
|
|
41
44
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
42
|
-
var useWalletItemActions = require('../../../../utils/hooks/useWalletItemActions/useWalletItemActions.cjs');
|
|
43
|
-
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
44
|
-
var useConnectWithEmail = require('../../../../utils/hooks/useConnectWithEmail/useConnectWithEmail.cjs');
|
|
45
|
-
var EmailVerificationContext = require('../../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
46
45
|
var LoadingContext = require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
46
|
+
var useEmailProvider = require('../../../../utils/hooks/useEmailProvider/useEmailProvider.cjs');
|
|
47
47
|
|
|
48
48
|
const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
49
49
|
const LoginWithEmailForm = () => {
|
|
50
50
|
const { environmentId, wallets, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
51
|
-
const { setView } = ViewContext.useViewContext();
|
|
52
51
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
53
52
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
54
|
-
const { setEmail: setEmailForVerification, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
55
53
|
const [emailInput, setEmailInput] = React.useState('');
|
|
56
54
|
const [emailError, setEmailError] = React.useState(false);
|
|
57
55
|
const emailWalletConnector = wallets
|
|
58
56
|
.map(({ walletConnector }) => walletConnector)
|
|
59
57
|
.find(walletConnectorCore.isEmailWalletConnector);
|
|
60
|
-
const {
|
|
61
|
-
const { connectWithEmail, email: magicEmail, setEmail: setEmailForMagic, loading: isMagicLoading, } = useConnectWithEmail.useConnectWithEmail({
|
|
58
|
+
const { handleEmailOnlyLoginSubmit, submitEmail, isEmailProviderLoading } = useEmailProvider.useEmailProvider({
|
|
62
59
|
emailWalletConnector,
|
|
63
|
-
handleConnect: handleInstalledExtensionClick,
|
|
64
60
|
});
|
|
65
|
-
const isLoading = React.useMemo(() =>
|
|
66
|
-
const handleMagicOnChangeEvent = (event) => {
|
|
67
|
-
const { value } = event.currentTarget;
|
|
68
|
-
setEmailForMagic(value);
|
|
69
|
-
};
|
|
61
|
+
const isLoading = React.useMemo(() => isEmailProviderLoading || loading, [isEmailProviderLoading, loading]);
|
|
70
62
|
const handleEmailOnChangeEvent = (event) => {
|
|
71
63
|
const { value } = event.currentTarget;
|
|
72
64
|
setEmailInput(value);
|
|
73
65
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
const handleEmailLoginSubmit = (emailInputOverride) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
const emailToVerify = emailInputOverride !== null && emailInputOverride !== void 0 ? emailInputOverride : emailInput;
|
|
79
|
-
const { email, verificationUUID } = yield api.createEmailVerification({
|
|
80
|
-
email: emailToVerify,
|
|
81
|
-
environmentId,
|
|
82
|
-
});
|
|
83
|
-
setView('login-with-email-verification');
|
|
84
|
-
setEmailForVerification(email);
|
|
85
|
-
setVerificationUUID(verificationUUID);
|
|
86
|
-
});
|
|
87
|
-
const magicLinkEnabled = emailWalletConnector !== undefined;
|
|
88
|
-
const submitHandler = magicLinkEnabled
|
|
89
|
-
? handleMagicLinkSubmit
|
|
90
|
-
: handleEmailLoginSubmit;
|
|
91
|
-
const onChangeHandler = magicLinkEnabled
|
|
92
|
-
? handleMagicOnChangeEvent
|
|
93
|
-
: handleEmailOnChangeEvent;
|
|
94
|
-
const emailValue = magicLinkEnabled ? magicEmail : emailInput;
|
|
66
|
+
const isInjectedWalletProviderEnabled = emailWalletConnector !== undefined;
|
|
67
|
+
const onChangeHandler = handleEmailOnChangeEvent;
|
|
95
68
|
const handleSubmit = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
96
69
|
e.preventDefault();
|
|
97
|
-
if (!EMAIL_REGEX.test(
|
|
70
|
+
if (!EMAIL_REGEX.test(emailInput)) {
|
|
98
71
|
setEmailError(true);
|
|
99
72
|
return;
|
|
100
73
|
}
|
|
101
74
|
try {
|
|
102
75
|
setLoading(true);
|
|
103
|
-
if (
|
|
76
|
+
if (isInjectedWalletProviderEnabled &&
|
|
104
77
|
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.confirmEmailProviderForVerify)) {
|
|
105
78
|
// see: https://linear.app/dynamic-labs/issue/DYN-2517
|
|
106
79
|
// if confirmWalletTransfers setting is true, check api first to confirm emailProvider
|
|
107
80
|
const { emailProvider } = yield api.getEmailProvider({
|
|
108
|
-
email:
|
|
81
|
+
email: emailInput,
|
|
109
82
|
environmentId,
|
|
110
83
|
});
|
|
111
84
|
if (emailProvider === sdkApi.ProviderEnum.EmailOnly) {
|
|
112
|
-
yield
|
|
85
|
+
yield handleEmailOnlyLoginSubmit(emailInput);
|
|
113
86
|
return;
|
|
114
87
|
}
|
|
115
88
|
}
|
|
116
|
-
yield
|
|
89
|
+
yield submitEmail(emailInput);
|
|
117
90
|
}
|
|
118
91
|
catch (error) {
|
|
119
92
|
logger.logger.debug(error);
|
|
@@ -124,7 +97,7 @@ const LoginWithEmailForm = () => {
|
|
|
124
97
|
}
|
|
125
98
|
});
|
|
126
99
|
// social sign in currently coupled to email... might be better to decouple
|
|
127
|
-
return (jsxRuntime.jsxs("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: [jsxRuntime.jsx(Input.Input, { id: 'email_field', value:
|
|
100
|
+
return (jsxRuntime.jsxs("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: [jsxRuntime.jsx(Input.Input, { id: 'email_field', value: emailInput, onChange: onChangeHandler, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address' }), jsxRuntime.jsx(Button.Button, Object.assign({ buttonClassName: 'login-with-email-form__button', type: 'submit', loading: isLoading, disabled: isLoading, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'medium', expanded: true }, { children: "Continue" }))] })));
|
|
128
101
|
};
|
|
129
102
|
|
|
130
103
|
exports.EMAIL_REGEX = EMAIL_REGEX;
|
package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js
CHANGED
|
@@ -3,113 +3,86 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useState, useMemo } from 'react';
|
|
4
4
|
import { isEmailWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { ProviderEnum } from '@dynamic-labs/sdk-api';
|
|
6
|
-
import '@dynamic-labs/utils';
|
|
7
|
-
import { getEmailProvider, createEmailVerification } from '../../../../data/api.js';
|
|
8
6
|
import { logger } from '../../../../shared/logger.js';
|
|
9
7
|
import '@dynamic-labs/iconic';
|
|
10
|
-
import
|
|
8
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
11
9
|
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '@dynamic-labs/utils';
|
|
12
11
|
import '../../../../utils/constants/colors.js';
|
|
13
12
|
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
14
13
|
import 'ethers';
|
|
15
14
|
import '../../../../shared/consts/index.js';
|
|
16
|
-
import '@dynamic-labs/multi-wallet';
|
|
17
|
-
import '@dynamic-labs/rpc-providers';
|
|
18
|
-
import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
19
15
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
20
|
-
import
|
|
21
|
-
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
22
|
-
import 'react-dom';
|
|
16
|
+
import '@dynamic-labs/multi-wallet';
|
|
23
17
|
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
24
18
|
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
25
19
|
import { Input } from '../../../../components/Input/Input.js';
|
|
20
|
+
import 'react-dom';
|
|
26
21
|
import 'react-focus-lock';
|
|
27
22
|
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
28
23
|
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
29
24
|
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
30
|
-
import {
|
|
25
|
+
import { getEmailProvider } from '../../../../data/api.js';
|
|
26
|
+
import '@dynamic-labs/rpc-providers';
|
|
27
|
+
import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
28
|
+
import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
|
|
29
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
30
|
import '../../../../components/IconButton/IconButton.js';
|
|
31
|
+
import { Button } from '../../../../components/Button/Button.js';
|
|
32
32
|
import '../../../../components/Alert/Alert.js';
|
|
33
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
34
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
35
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
33
36
|
import '../../../../components/Popper/Popper/Popper.js';
|
|
34
37
|
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
35
38
|
import 'formik';
|
|
36
39
|
import 'yup';
|
|
37
40
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
38
|
-
import { useWalletItemActions } from '../../../../utils/hooks/useWalletItemActions/useWalletItemActions.js';
|
|
39
|
-
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
40
|
-
import { useConnectWithEmail } from '../../../../utils/hooks/useConnectWithEmail/useConnectWithEmail.js';
|
|
41
|
-
import { useEmailVerificationContext } from '../../../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
42
41
|
import { useLoadingContext } from '../../../../context/LoadingContext/LoadingContext.js';
|
|
42
|
+
import { useEmailProvider } from '../../../../utils/hooks/useEmailProvider/useEmailProvider.js';
|
|
43
43
|
|
|
44
44
|
const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
45
45
|
const LoginWithEmailForm = () => {
|
|
46
46
|
const { environmentId, wallets, projectSettings } = useInternalDynamicContext();
|
|
47
|
-
const { setView } = useViewContext();
|
|
48
47
|
const { loading, setLoading } = useLoadingContext();
|
|
49
48
|
const { setErrorMessage } = useErrorContext();
|
|
50
|
-
const { setEmail: setEmailForVerification, setVerificationUUID } = useEmailVerificationContext();
|
|
51
49
|
const [emailInput, setEmailInput] = useState('');
|
|
52
50
|
const [emailError, setEmailError] = useState(false);
|
|
53
51
|
const emailWalletConnector = wallets
|
|
54
52
|
.map(({ walletConnector }) => walletConnector)
|
|
55
53
|
.find(isEmailWalletConnector);
|
|
56
|
-
const {
|
|
57
|
-
const { connectWithEmail, email: magicEmail, setEmail: setEmailForMagic, loading: isMagicLoading, } = useConnectWithEmail({
|
|
54
|
+
const { handleEmailOnlyLoginSubmit, submitEmail, isEmailProviderLoading } = useEmailProvider({
|
|
58
55
|
emailWalletConnector,
|
|
59
|
-
handleConnect: handleInstalledExtensionClick,
|
|
60
56
|
});
|
|
61
|
-
const isLoading = useMemo(() =>
|
|
62
|
-
const handleMagicOnChangeEvent = (event) => {
|
|
63
|
-
const { value } = event.currentTarget;
|
|
64
|
-
setEmailForMagic(value);
|
|
65
|
-
};
|
|
57
|
+
const isLoading = useMemo(() => isEmailProviderLoading || loading, [isEmailProviderLoading, loading]);
|
|
66
58
|
const handleEmailOnChangeEvent = (event) => {
|
|
67
59
|
const { value } = event.currentTarget;
|
|
68
60
|
setEmailInput(value);
|
|
69
61
|
};
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
const handleEmailLoginSubmit = (emailInputOverride) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
-
const emailToVerify = emailInputOverride !== null && emailInputOverride !== void 0 ? emailInputOverride : emailInput;
|
|
75
|
-
const { email, verificationUUID } = yield createEmailVerification({
|
|
76
|
-
email: emailToVerify,
|
|
77
|
-
environmentId,
|
|
78
|
-
});
|
|
79
|
-
setView('login-with-email-verification');
|
|
80
|
-
setEmailForVerification(email);
|
|
81
|
-
setVerificationUUID(verificationUUID);
|
|
82
|
-
});
|
|
83
|
-
const magicLinkEnabled = emailWalletConnector !== undefined;
|
|
84
|
-
const submitHandler = magicLinkEnabled
|
|
85
|
-
? handleMagicLinkSubmit
|
|
86
|
-
: handleEmailLoginSubmit;
|
|
87
|
-
const onChangeHandler = magicLinkEnabled
|
|
88
|
-
? handleMagicOnChangeEvent
|
|
89
|
-
: handleEmailOnChangeEvent;
|
|
90
|
-
const emailValue = magicLinkEnabled ? magicEmail : emailInput;
|
|
62
|
+
const isInjectedWalletProviderEnabled = emailWalletConnector !== undefined;
|
|
63
|
+
const onChangeHandler = handleEmailOnChangeEvent;
|
|
91
64
|
const handleSubmit = (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
65
|
e.preventDefault();
|
|
93
|
-
if (!EMAIL_REGEX.test(
|
|
66
|
+
if (!EMAIL_REGEX.test(emailInput)) {
|
|
94
67
|
setEmailError(true);
|
|
95
68
|
return;
|
|
96
69
|
}
|
|
97
70
|
try {
|
|
98
71
|
setLoading(true);
|
|
99
|
-
if (
|
|
72
|
+
if (isInjectedWalletProviderEnabled &&
|
|
100
73
|
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.confirmEmailProviderForVerify)) {
|
|
101
74
|
// see: https://linear.app/dynamic-labs/issue/DYN-2517
|
|
102
75
|
// if confirmWalletTransfers setting is true, check api first to confirm emailProvider
|
|
103
76
|
const { emailProvider } = yield getEmailProvider({
|
|
104
|
-
email:
|
|
77
|
+
email: emailInput,
|
|
105
78
|
environmentId,
|
|
106
79
|
});
|
|
107
80
|
if (emailProvider === ProviderEnum.EmailOnly) {
|
|
108
|
-
yield
|
|
81
|
+
yield handleEmailOnlyLoginSubmit(emailInput);
|
|
109
82
|
return;
|
|
110
83
|
}
|
|
111
84
|
}
|
|
112
|
-
yield
|
|
85
|
+
yield submitEmail(emailInput);
|
|
113
86
|
}
|
|
114
87
|
catch (error) {
|
|
115
88
|
logger.debug(error);
|
|
@@ -120,7 +93,7 @@ const LoginWithEmailForm = () => {
|
|
|
120
93
|
}
|
|
121
94
|
});
|
|
122
95
|
// social sign in currently coupled to email... might be better to decouple
|
|
123
|
-
return (jsxs("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: [jsx(Input, { id: 'email_field', value:
|
|
96
|
+
return (jsxs("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: [jsx(Input, { id: 'email_field', value: emailInput, onChange: onChangeHandler, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address' }), jsx(Button, Object.assign({ buttonClassName: 'login-with-email-form__button', type: 'submit', loading: isLoading, disabled: isLoading, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'medium', expanded: true }, { children: "Continue" }))] })));
|
|
124
97
|
};
|
|
125
98
|
|
|
126
99
|
export { EMAIL_REGEX, LoginWithEmailForm };
|
|
@@ -19,7 +19,7 @@ require('../../../../utils/constants/colors.cjs');
|
|
|
19
19
|
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
20
|
require('ethers');
|
|
21
21
|
require('../../../../shared/consts/index.cjs');
|
|
22
|
-
require('../../../../context/DynamicContext/
|
|
22
|
+
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
23
23
|
require('@dynamic-labs/multi-wallet');
|
|
24
24
|
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
25
25
|
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
@@ -55,16 +55,18 @@ require('../../../../components/OverlayCard/OverlayCard.context.cjs');
|
|
|
55
55
|
var capitalize = require('../../../../shared/utils/functions/capitalize/capitalize.cjs');
|
|
56
56
|
|
|
57
57
|
const SocialSignIn = () => {
|
|
58
|
+
const { socialProvidersFilter = (providers) => providers } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
59
|
const { socialProvider, setSocialProvider, socialWalletConnector, enabledSocialProviders, } = SocialRedirectContext.useSocialRedirectContext();
|
|
59
60
|
const getSocialIcon = useGetSocialIcon.useGetSocialIcon();
|
|
60
61
|
const [showCard, setShowCard] = React.useState(false);
|
|
61
62
|
const closeCard = () => !isLoading && setShowCard(false);
|
|
62
|
-
const
|
|
63
|
+
const socialProviders = socialProvidersFilter(enabledSocialProviders);
|
|
64
|
+
const numberOfEnabledSocialProviders = socialProviders.length;
|
|
63
65
|
const showConnectText = numberOfEnabledSocialProviders === 1;
|
|
64
66
|
const showCardButton = numberOfEnabledSocialProviders > 5;
|
|
65
67
|
const socialProvidersToDisplayInline = showCardButton
|
|
66
|
-
?
|
|
67
|
-
:
|
|
68
|
+
? socialProviders.slice(0, 4)
|
|
69
|
+
: socialProviders.slice(0, 5);
|
|
68
70
|
const numberOfSocialGridItems = numberOfEnabledSocialProviders + (showCardButton ? 1 : 0);
|
|
69
71
|
const { mutate: onClickProvider, isLoading } = useMutation.useMutation((provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
70
72
|
setSocialProvider(provider);
|
|
@@ -74,7 +76,7 @@ const SocialSignIn = () => {
|
|
|
74
76
|
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button' }, { children: jsxRuntime.jsx(close.ReactComponent, {}) })));
|
|
75
77
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in', style: {
|
|
76
78
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
77
|
-
} }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize.capitalize(provider)] })))] }), provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-primary' }, { children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) })) }), 'show-more-options'))] })), jsxRuntime.jsx(OverlayCard.OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ trailing: closeButton }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsxRuntime.jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children:
|
|
79
|
+
} }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize.capitalize(provider)] })))] }), provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-primary' }, { children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) })) }), 'show-more-options'))] })), jsxRuntime.jsx(OverlayCard.OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ trailing: closeButton }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsxRuntime.jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile' }, { children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
|
|
78
80
|
};
|
|
79
81
|
|
|
80
82
|
exports.SocialSignIn = SocialSignIn;
|
|
@@ -15,7 +15,7 @@ import '../../../../utils/constants/colors.js';
|
|
|
15
15
|
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
16
16
|
import 'ethers';
|
|
17
17
|
import '../../../../shared/consts/index.js';
|
|
18
|
-
import '../../../../context/DynamicContext/
|
|
18
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
19
19
|
import '@dynamic-labs/multi-wallet';
|
|
20
20
|
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
21
21
|
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
@@ -51,16 +51,18 @@ import '../../../../components/OverlayCard/OverlayCard.context.js';
|
|
|
51
51
|
import { capitalize } from '../../../../shared/utils/functions/capitalize/capitalize.js';
|
|
52
52
|
|
|
53
53
|
const SocialSignIn = () => {
|
|
54
|
+
const { socialProvidersFilter = (providers) => providers } = useInternalDynamicContext();
|
|
54
55
|
const { socialProvider, setSocialProvider, socialWalletConnector, enabledSocialProviders, } = useSocialRedirectContext();
|
|
55
56
|
const getSocialIcon = useGetSocialIcon();
|
|
56
57
|
const [showCard, setShowCard] = useState(false);
|
|
57
58
|
const closeCard = () => !isLoading && setShowCard(false);
|
|
58
|
-
const
|
|
59
|
+
const socialProviders = socialProvidersFilter(enabledSocialProviders);
|
|
60
|
+
const numberOfEnabledSocialProviders = socialProviders.length;
|
|
59
61
|
const showConnectText = numberOfEnabledSocialProviders === 1;
|
|
60
62
|
const showCardButton = numberOfEnabledSocialProviders > 5;
|
|
61
63
|
const socialProvidersToDisplayInline = showCardButton
|
|
62
|
-
?
|
|
63
|
-
:
|
|
64
|
+
? socialProviders.slice(0, 4)
|
|
65
|
+
: socialProviders.slice(0, 5);
|
|
64
66
|
const numberOfSocialGridItems = numberOfEnabledSocialProviders + (showCardButton ? 1 : 0);
|
|
65
67
|
const { mutate: onClickProvider, isLoading } = useMutation((provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
68
|
setSocialProvider(provider);
|
|
@@ -70,7 +72,7 @@ const SocialSignIn = () => {
|
|
|
70
72
|
const closeButton = (jsx(IconButton, Object.assign({ onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button' }, { children: jsx(SvgClose, {}) })));
|
|
71
73
|
return (jsxs(Fragment, { children: [jsxs("div", Object.assign({ className: 'social-sign-in', style: {
|
|
72
74
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
73
|
-
} }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize(provider)] })))] }), provider))), showCardButton && (jsx(IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsx(Icon, Object.assign({ color: 'text-primary' }, { children: jsx(SvgDotsHorizontal, {}) })) }), 'show-more-options'))] })), jsx(OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsx(ModalHeader, Object.assign({ trailing: closeButton }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children:
|
|
75
|
+
} }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize(provider)] })))] }), provider))), showCardButton && (jsx(IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsx(Icon, Object.assign({ color: 'text-primary' }, { children: jsx(SvgDotsHorizontal, {}) })) }), 'show-more-options'))] })), jsx(OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsx(ModalHeader, Object.assign({ trailing: closeButton }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsx(IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile' }, { children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
export { SocialSignIn };
|
|
@@ -39,6 +39,7 @@ require('../../context/MockContext/MockContext.cjs');
|
|
|
39
39
|
var useConnectAndSign = require('../../utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs');
|
|
40
40
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
41
41
|
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
42
|
+
var useWalletConnectorEvents = require('../../utils/hooks/useWalletConnectorEvents/useWalletConnectorEvents.cjs');
|
|
42
43
|
var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
|
|
43
44
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
44
45
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
@@ -48,27 +49,26 @@ require('../../components/InlineWidget/InlineWidget.cjs');
|
|
|
48
49
|
var NetworkPicker = require('../../components/NetworkPicker/NetworkPicker.cjs');
|
|
49
50
|
var UserAddress = require('../../components/UserAddress/UserAddress.cjs');
|
|
50
51
|
var AuthProviderIcon = require('../../components/AuthProviderIcon/AuthProviderIcon.cjs');
|
|
51
|
-
var useUpdateUserProfileByJWTCallback = require('../../utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
52
52
|
var SelectNetworkButton = require('../../components/SelectNetworkButton/SelectNetworkButton.cjs');
|
|
53
53
|
|
|
54
54
|
const NetworkNotSupported = () => {
|
|
55
55
|
var _a, _b, _c, _d;
|
|
56
|
-
const { onboardingOnlyJwt, network, onboardingImageUrl, selectedWalletConnector: walletConnector, decodedOnboardingOnlyToken,
|
|
57
|
-
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
56
|
+
const { onboardingOnlyJwt, network, onboardingImageUrl, selectedWalletConnector: walletConnector, decodedOnboardingOnlyToken, setNetwork, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
57
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign();
|
|
59
58
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
59
|
+
const onChainChange = (network) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
if (isSupportedNetwork.isSupportedNetwork({ network, walletConnector })) {
|
|
61
|
+
finishConnectAndSign({
|
|
62
|
+
walletConnector: walletConnector,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// We can't listen on the network defined in the context,
|
|
67
|
+
// because events on the primaryWallet are defined after message is signed.
|
|
68
|
+
useWalletConnectorEvents.useWalletConnectorEvents(walletConnector, { onChainChange });
|
|
60
69
|
if (!walletConnector) {
|
|
61
70
|
return null;
|
|
62
71
|
}
|
|
63
|
-
const handleNetworkChange = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
if (!onboardingOnlyJwt) {
|
|
65
|
-
finishConnectAndSign({ walletConnector });
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
setCallback('authSuccess');
|
|
69
|
-
yield updateUserProfileByJWT(onboardingOnlyJwt);
|
|
70
|
-
setShowAuthFlow(false);
|
|
71
|
-
});
|
|
72
72
|
const userProfile = decodedOnboardingOnlyToken && createUserProfile.createUserProfile(decodedOnboardingOnlyToken);
|
|
73
73
|
const evmNetworks = walletConnector.evmNetworks || [];
|
|
74
74
|
const _isSupportedNetwork = isSupportedNetwork.isSupportedNetwork({ network, walletConnector });
|
|
@@ -78,13 +78,13 @@ const NetworkNotSupported = () => {
|
|
|
78
78
|
networkChainId: networkId,
|
|
79
79
|
});
|
|
80
80
|
setNetwork(networkId);
|
|
81
|
-
|
|
81
|
+
finishConnectAndSign({ walletConnector });
|
|
82
82
|
}
|
|
83
83
|
catch (e) {
|
|
84
84
|
logger.logger.debug(e);
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported', "data-testid": 'network-not-supported' }, { children: [onboardingImageUrl && (jsxRuntime.jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, Object.assign({ variant: 'info', withIcon: false, className: 'network-not-supported__error--not-supported' }, { children: "This network is not available, please update." }))), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__content-container' }, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__img-container' }, { children: [((_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _a === void 0 ? void 0 : _a.avatar) && (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsxRuntime.jsx("img", { src: (_b = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported__img' }) }))), !((_c = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _c === void 0 ? void 0 : _c.avatar) && onboardingOnlyJwt && (jsxRuntime.jsx(AuthProviderIcon.AuthProviderIcon, { jwt: onboardingOnlyJwt })), !((_d = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _d === void 0 ? void 0 : _d.avatar) && !onboardingOnlyJwt && (jsxRuntime.jsx(walletBook.WalletIcon, { style: { height: 64, width: 64 }, walletName: walletConnector.name }))] })), jsxRuntime.jsx(UserAddress.UserAddress, { walletConnector: walletConnector, userProfile: userProfile }), jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: evmNetworks.length > 1 && (jsxRuntime.jsx(NetworkPicker.NetworkPicker, { evmNetworks: evmNetworks, connector: walletConnector, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, showNetworkName: true, buttonClassName: 'network-not-supported__network-picker-button', mainClassName: 'network-not-supported__network-picker'
|
|
87
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported', "data-testid": 'network-not-supported' }, { children: [onboardingImageUrl && (jsxRuntime.jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, Object.assign({ variant: 'info', withIcon: false, className: 'network-not-supported__error--not-supported' }, { children: "This network is not available, please update." }))), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__content-container' }, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__img-container' }, { children: [((_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _a === void 0 ? void 0 : _a.avatar) && (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsxRuntime.jsx("img", { src: (_b = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported__img' }) }))), !((_c = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _c === void 0 ? void 0 : _c.avatar) && onboardingOnlyJwt && (jsxRuntime.jsx(AuthProviderIcon.AuthProviderIcon, { jwt: onboardingOnlyJwt })), !((_d = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _d === void 0 ? void 0 : _d.avatar) && !onboardingOnlyJwt && (jsxRuntime.jsx(walletBook.WalletIcon, { style: { height: 64, width: 64 }, walletName: walletConnector.name }))] })), jsxRuntime.jsx(UserAddress.UserAddress, { walletConnector: walletConnector, userProfile: userProfile }), jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: evmNetworks.length > 1 && (jsxRuntime.jsx(NetworkPicker.NetworkPicker, { evmNetworks: evmNetworks, connector: walletConnector, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, showNetworkName: true, buttonClassName: 'network-not-supported__network-picker-button', mainClassName: 'network-not-supported__network-picker' })) })), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__welcome-container' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'title', color: 'primary', className: 'network-not-supported__welcome-title' }, { children: "Update Network" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "Your wallet is not connected to a supported network. Please update before continuing." }))] })), evmNetworks.length === 1 && (jsxRuntime.jsx(SelectNetworkButton.SelectNetworkButton, { onClick: onSelectNetworkButtonClick, networkId: evmNetworks[0].networkId, networkName: evmNetworks[0].vanityName || evmNetworks[0].name, networkIconUrl: evmNetworks[0].iconUrls[0] }))] }))] })));
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
exports.NetworkNotSupported = NetworkNotSupported;
|