@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
|
@@ -16,8 +16,8 @@ require('../../constants/colors.cjs');
|
|
|
16
16
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
17
|
require('ethers');
|
|
18
18
|
require('../../../shared/consts/index.cjs');
|
|
19
|
+
var useWalletConnectorEvent = require('../useWalletConnectorEvent/useWalletConnectorEvent.cjs');
|
|
19
20
|
|
|
20
|
-
const orderedSecondaryWalletAddresses = (wallets) => wallets.map((wallet) => wallet.address).sort();
|
|
21
21
|
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, }) => {
|
|
22
22
|
const [loadingNetwork, setLoadingNetwork] = React.useState(true);
|
|
23
23
|
const [network, setNetwork] = React.useState(undefined);
|
|
@@ -39,31 +39,100 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
39
39
|
});
|
|
40
40
|
fetchNetwork();
|
|
41
41
|
}, [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id]);
|
|
42
|
-
|
|
42
|
+
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
|
|
43
|
+
logger.logger.debug('primary wallet disconnect');
|
|
44
|
+
handleLogOut();
|
|
45
|
+
});
|
|
46
|
+
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', (_, { chain }) => {
|
|
47
|
+
logger.logger.debug('primary wallet chain change', { chain });
|
|
43
48
|
if (!primaryWallet) {
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
52
|
+
// https://linear.app/dynamic-labs/issue/QNTM-84/breaking-change-rename-network-to-primarywalletnetwork
|
|
53
|
+
if (primaryWallet.chain === 'starknet') {
|
|
54
|
+
setNetwork(chain);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
setNetwork(parseInt(chain));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
useWalletConnectorEvent.useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'accountChange', (_, { accounts }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
logger.logger.debug('primary wallet account change', {
|
|
62
|
+
accounts,
|
|
63
|
+
});
|
|
64
|
+
// change the api here
|
|
65
|
+
if (!primaryWallet)
|
|
66
|
+
return;
|
|
67
|
+
const [newAddress] = accounts;
|
|
68
|
+
const newWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
69
|
+
if (authMode === 'connect-only') {
|
|
70
|
+
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (walletConnectorCore.isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
|
|
74
|
+
setMultiWalletWidgetState('idle');
|
|
75
|
+
}
|
|
76
|
+
else if (!multiWallet) {
|
|
77
|
+
yield handleLogOut();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
else if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
81
|
+
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
82
|
+
}
|
|
83
|
+
else if (multiWalletWidgetState === 'idle' && newWallet) {
|
|
84
|
+
setPrimaryWalletId(newWallet.id);
|
|
85
|
+
}
|
|
86
|
+
else if (multiWalletWidgetState === 'idle' && !newWallet) {
|
|
87
|
+
if (user) {
|
|
88
|
+
setMultiWalletWidgetState('detected_new_wallet');
|
|
89
|
+
setSelectedWalletConnector(primaryWallet.connector);
|
|
90
|
+
yield computeConnectedStateForWallets();
|
|
91
|
+
return;
|
|
53
92
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
logger.logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
|
|
96
|
+
setMultiWalletWidgetState('idle');
|
|
97
|
+
}
|
|
98
|
+
yield computeConnectedStateForWallets();
|
|
99
|
+
}));
|
|
100
|
+
const uniqueNonPrimaryWallets = React.useMemo(() => {
|
|
101
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
102
|
+
const secondaryConnectors = secondaryWallets.map(({ connector }) => connector);
|
|
103
|
+
const allWalletConnectors = new Set([
|
|
104
|
+
...secondaryConnectors,
|
|
105
|
+
primaryConnector,
|
|
106
|
+
selectedWalletConnector,
|
|
107
|
+
].filter((connector) => Boolean(connector)));
|
|
108
|
+
if (primaryConnector) {
|
|
109
|
+
allWalletConnectors.delete(primaryConnector);
|
|
110
|
+
}
|
|
111
|
+
return Array.from(allWalletConnectors);
|
|
112
|
+
}, [secondaryWallets, selectedWalletConnector, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector]);
|
|
113
|
+
useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'accountChange', () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
+
logger.logger.debug('secondary wallet account change');
|
|
115
|
+
if (authMode === 'connect-only' && secondaryWallets.length) {
|
|
116
|
+
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
120
|
+
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
121
|
+
}
|
|
122
|
+
yield computeConnectedStateForWallets();
|
|
123
|
+
}));
|
|
124
|
+
useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
logger.logger.debug('secondary wallet chain change');
|
|
126
|
+
// We should pass the proper walletId here
|
|
127
|
+
if (!secondaryWallets.length) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
131
|
+
}));
|
|
132
|
+
useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'disconnect', () => {
|
|
133
|
+
logger.logger.debug('secondary wallet disconnect');
|
|
134
|
+
computeConnectedStateForWallets();
|
|
135
|
+
});
|
|
67
136
|
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
68
137
|
const linkedSecondaryWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
69
138
|
// this means the user is linking a new account, so we need proof of ownership...
|
|
@@ -86,120 +155,6 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
86
155
|
setSelectedWalletWithAction,
|
|
87
156
|
setPrimaryWalletId,
|
|
88
157
|
]);
|
|
89
|
-
const addPrimaryWalletEventListeners = React.useCallback((seen) => {
|
|
90
|
-
if (!primaryWallet) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
seen.add(primaryWallet.connector.name);
|
|
94
|
-
primaryWallet.connector.setupEventListeners({
|
|
95
|
-
onAccountChange: (accounts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
const [newAddress] = accounts;
|
|
97
|
-
const newWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
98
|
-
if (authMode === 'connect-only') {
|
|
99
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (walletConnectorCore.isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
|
|
103
|
-
setMultiWalletWidgetState('idle');
|
|
104
|
-
}
|
|
105
|
-
else if (!multiWallet) {
|
|
106
|
-
yield handleLogOut();
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
else if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
110
|
-
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
111
|
-
}
|
|
112
|
-
else if (multiWalletWidgetState === 'idle' && newWallet) {
|
|
113
|
-
setPrimaryWalletId(newWallet.id);
|
|
114
|
-
}
|
|
115
|
-
else if (multiWalletWidgetState === 'idle' && !newWallet) {
|
|
116
|
-
if (user) {
|
|
117
|
-
setMultiWalletWidgetState('detected_new_wallet');
|
|
118
|
-
setSelectedWalletConnector(primaryWallet.connector);
|
|
119
|
-
yield computeConnectedStateForWallets();
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
logger.logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
|
|
125
|
-
setMultiWalletWidgetState('idle');
|
|
126
|
-
}
|
|
127
|
-
yield computeConnectedStateForWallets();
|
|
128
|
-
}),
|
|
129
|
-
onChainChange: (chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
-
if (!primaryWallet) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
134
|
-
// https://linear.app/dynamic-labs/issue/QNTM-84/breaking-change-rename-network-to-primarywalletnetwork
|
|
135
|
-
if (primaryWallet.chain === 'starknet') {
|
|
136
|
-
setNetwork(chain);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
setNetwork(parseInt(chain));
|
|
140
|
-
}
|
|
141
|
-
}),
|
|
142
|
-
onDisconnect: handleLogOut,
|
|
143
|
-
});
|
|
144
|
-
}, [
|
|
145
|
-
authMode,
|
|
146
|
-
primaryWallet,
|
|
147
|
-
setMultiWalletWidgetState,
|
|
148
|
-
multiWallet,
|
|
149
|
-
user,
|
|
150
|
-
computeConnectedStateForWallets,
|
|
151
|
-
handleLogOut,
|
|
152
|
-
multiWalletWidgetState,
|
|
153
|
-
secondaryWallets,
|
|
154
|
-
setSelectedWalletConnector,
|
|
155
|
-
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
156
|
-
setPrimaryWalletId,
|
|
157
|
-
refreshConnectedWallet,
|
|
158
|
-
]);
|
|
159
|
-
const addSecondaryWalletEventListeners = React.useCallback((seen) => {
|
|
160
|
-
const secondaryListeners = {
|
|
161
|
-
onAccountChange: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
-
if (authMode === 'connect-only' && secondaryWallets.length) {
|
|
163
|
-
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
167
|
-
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
168
|
-
}
|
|
169
|
-
yield computeConnectedStateForWallets();
|
|
170
|
-
}),
|
|
171
|
-
onChainChange: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
172
|
-
// We should pass the proper walletId here
|
|
173
|
-
if (!secondaryWallets.length) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
177
|
-
}),
|
|
178
|
-
onDisconnect: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
-
yield computeConnectedStateForWallets();
|
|
180
|
-
}),
|
|
181
|
-
};
|
|
182
|
-
if (selectedWalletConnector && !seen.has(selectedWalletConnector.name)) {
|
|
183
|
-
seen.add(selectedWalletConnector.name);
|
|
184
|
-
selectedWalletConnector.setupEventListeners(secondaryListeners);
|
|
185
|
-
}
|
|
186
|
-
for (const wallet of secondaryWallets) {
|
|
187
|
-
if (seen.has(wallet.connector.name)) {
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
seen.add(wallet.connector.name);
|
|
191
|
-
wallet.connector.setupEventListeners(secondaryListeners);
|
|
192
|
-
}
|
|
193
|
-
}, [
|
|
194
|
-
authMode,
|
|
195
|
-
computeConnectedStateForWallets,
|
|
196
|
-
selectedWalletConnector,
|
|
197
|
-
selectedWalletWithAction,
|
|
198
|
-
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
199
|
-
multiWalletWidgetState,
|
|
200
|
-
secondaryWallets,
|
|
201
|
-
refreshConnectedWallet,
|
|
202
|
-
]);
|
|
203
158
|
return {
|
|
204
159
|
loadingNetwork,
|
|
205
160
|
network,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
3
3
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -12,8 +12,8 @@ import '../../constants/colors.js';
|
|
|
12
12
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
13
13
|
import 'ethers';
|
|
14
14
|
import '../../../shared/consts/index.js';
|
|
15
|
+
import { useWalletConnectorEvent } from '../useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
15
16
|
|
|
16
|
-
const orderedSecondaryWalletAddresses = (wallets) => wallets.map((wallet) => wallet.address).sort();
|
|
17
17
|
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, }) => {
|
|
18
18
|
const [loadingNetwork, setLoadingNetwork] = useState(true);
|
|
19
19
|
const [network, setNetwork] = useState(undefined);
|
|
@@ -35,31 +35,100 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
35
35
|
});
|
|
36
36
|
fetchNetwork();
|
|
37
37
|
}, [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id]);
|
|
38
|
-
|
|
38
|
+
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'disconnect', () => {
|
|
39
|
+
logger.debug('primary wallet disconnect');
|
|
40
|
+
handleLogOut();
|
|
41
|
+
});
|
|
42
|
+
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'chainChange', (_, { chain }) => {
|
|
43
|
+
logger.debug('primary wallet chain change', { chain });
|
|
39
44
|
if (!primaryWallet) {
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
48
|
+
// https://linear.app/dynamic-labs/issue/QNTM-84/breaking-change-rename-network-to-primarywalletnetwork
|
|
49
|
+
if (primaryWallet.chain === 'starknet') {
|
|
50
|
+
setNetwork(chain);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setNetwork(parseInt(chain));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
useWalletConnectorEvent(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, 'accountChange', (_, { accounts }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
logger.debug('primary wallet account change', {
|
|
58
|
+
accounts,
|
|
59
|
+
});
|
|
60
|
+
// change the api here
|
|
61
|
+
if (!primaryWallet)
|
|
62
|
+
return;
|
|
63
|
+
const [newAddress] = accounts;
|
|
64
|
+
const newWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
65
|
+
if (authMode === 'connect-only') {
|
|
66
|
+
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
|
|
70
|
+
setMultiWalletWidgetState('idle');
|
|
71
|
+
}
|
|
72
|
+
else if (!multiWallet) {
|
|
73
|
+
yield handleLogOut();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
else if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
77
|
+
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
78
|
+
}
|
|
79
|
+
else if (multiWalletWidgetState === 'idle' && newWallet) {
|
|
80
|
+
setPrimaryWalletId(newWallet.id);
|
|
81
|
+
}
|
|
82
|
+
else if (multiWalletWidgetState === 'idle' && !newWallet) {
|
|
83
|
+
if (user) {
|
|
84
|
+
setMultiWalletWidgetState('detected_new_wallet');
|
|
85
|
+
setSelectedWalletConnector(primaryWallet.connector);
|
|
86
|
+
yield computeConnectedStateForWallets();
|
|
87
|
+
return;
|
|
49
88
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
|
|
92
|
+
setMultiWalletWidgetState('idle');
|
|
93
|
+
}
|
|
94
|
+
yield computeConnectedStateForWallets();
|
|
95
|
+
}));
|
|
96
|
+
const uniqueNonPrimaryWallets = useMemo(() => {
|
|
97
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
98
|
+
const secondaryConnectors = secondaryWallets.map(({ connector }) => connector);
|
|
99
|
+
const allWalletConnectors = new Set([
|
|
100
|
+
...secondaryConnectors,
|
|
101
|
+
primaryConnector,
|
|
102
|
+
selectedWalletConnector,
|
|
103
|
+
].filter((connector) => Boolean(connector)));
|
|
104
|
+
if (primaryConnector) {
|
|
105
|
+
allWalletConnectors.delete(primaryConnector);
|
|
106
|
+
}
|
|
107
|
+
return Array.from(allWalletConnectors);
|
|
108
|
+
}, [secondaryWallets, selectedWalletConnector, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector]);
|
|
109
|
+
useWalletConnectorEvent(uniqueNonPrimaryWallets, 'accountChange', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
logger.debug('secondary wallet account change');
|
|
111
|
+
if (authMode === 'connect-only' && secondaryWallets.length) {
|
|
112
|
+
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
116
|
+
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
117
|
+
}
|
|
118
|
+
yield computeConnectedStateForWallets();
|
|
119
|
+
}));
|
|
120
|
+
useWalletConnectorEvent(uniqueNonPrimaryWallets, 'chainChange', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
logger.debug('secondary wallet chain change');
|
|
122
|
+
// We should pass the proper walletId here
|
|
123
|
+
if (!secondaryWallets.length) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
127
|
+
}));
|
|
128
|
+
useWalletConnectorEvent(uniqueNonPrimaryWallets, 'disconnect', () => {
|
|
129
|
+
logger.debug('secondary wallet disconnect');
|
|
130
|
+
computeConnectedStateForWallets();
|
|
131
|
+
});
|
|
63
132
|
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
64
133
|
const linkedSecondaryWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
65
134
|
// this means the user is linking a new account, so we need proof of ownership...
|
|
@@ -82,120 +151,6 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
82
151
|
setSelectedWalletWithAction,
|
|
83
152
|
setPrimaryWalletId,
|
|
84
153
|
]);
|
|
85
|
-
const addPrimaryWalletEventListeners = useCallback((seen) => {
|
|
86
|
-
if (!primaryWallet) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
seen.add(primaryWallet.connector.name);
|
|
90
|
-
primaryWallet.connector.setupEventListeners({
|
|
91
|
-
onAccountChange: (accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
-
const [newAddress] = accounts;
|
|
93
|
-
const newWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
94
|
-
if (authMode === 'connect-only') {
|
|
95
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
|
|
99
|
-
setMultiWalletWidgetState('idle');
|
|
100
|
-
}
|
|
101
|
-
else if (!multiWallet) {
|
|
102
|
-
yield handleLogOut();
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
else if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
106
|
-
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
107
|
-
}
|
|
108
|
-
else if (multiWalletWidgetState === 'idle' && newWallet) {
|
|
109
|
-
setPrimaryWalletId(newWallet.id);
|
|
110
|
-
}
|
|
111
|
-
else if (multiWalletWidgetState === 'idle' && !newWallet) {
|
|
112
|
-
if (user) {
|
|
113
|
-
setMultiWalletWidgetState('detected_new_wallet');
|
|
114
|
-
setSelectedWalletConnector(primaryWallet.connector);
|
|
115
|
-
yield computeConnectedStateForWallets();
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
|
|
121
|
-
setMultiWalletWidgetState('idle');
|
|
122
|
-
}
|
|
123
|
-
yield computeConnectedStateForWallets();
|
|
124
|
-
}),
|
|
125
|
-
onChainChange: (chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
-
if (!primaryWallet) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
refreshConnectedWallet(primaryWallet.id, primaryWallet.connector);
|
|
130
|
-
// https://linear.app/dynamic-labs/issue/QNTM-84/breaking-change-rename-network-to-primarywalletnetwork
|
|
131
|
-
if (primaryWallet.chain === 'starknet') {
|
|
132
|
-
setNetwork(chain);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
setNetwork(parseInt(chain));
|
|
136
|
-
}
|
|
137
|
-
}),
|
|
138
|
-
onDisconnect: handleLogOut,
|
|
139
|
-
});
|
|
140
|
-
}, [
|
|
141
|
-
authMode,
|
|
142
|
-
primaryWallet,
|
|
143
|
-
setMultiWalletWidgetState,
|
|
144
|
-
multiWallet,
|
|
145
|
-
user,
|
|
146
|
-
computeConnectedStateForWallets,
|
|
147
|
-
handleLogOut,
|
|
148
|
-
multiWalletWidgetState,
|
|
149
|
-
secondaryWallets,
|
|
150
|
-
setSelectedWalletConnector,
|
|
151
|
-
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
152
|
-
setPrimaryWalletId,
|
|
153
|
-
refreshConnectedWallet,
|
|
154
|
-
]);
|
|
155
|
-
const addSecondaryWalletEventListeners = useCallback((seen) => {
|
|
156
|
-
const secondaryListeners = {
|
|
157
|
-
onAccountChange: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
-
if (authMode === 'connect-only' && secondaryWallets.length) {
|
|
159
|
-
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
163
|
-
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
164
|
-
}
|
|
165
|
-
yield computeConnectedStateForWallets();
|
|
166
|
-
}),
|
|
167
|
-
onChainChange: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
-
// We should pass the proper walletId here
|
|
169
|
-
if (!secondaryWallets.length) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
refreshConnectedWallet(secondaryWallets[0].id, secondaryWallets[0].connector);
|
|
173
|
-
}),
|
|
174
|
-
onDisconnect: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
175
|
-
yield computeConnectedStateForWallets();
|
|
176
|
-
}),
|
|
177
|
-
};
|
|
178
|
-
if (selectedWalletConnector && !seen.has(selectedWalletConnector.name)) {
|
|
179
|
-
seen.add(selectedWalletConnector.name);
|
|
180
|
-
selectedWalletConnector.setupEventListeners(secondaryListeners);
|
|
181
|
-
}
|
|
182
|
-
for (const wallet of secondaryWallets) {
|
|
183
|
-
if (seen.has(wallet.connector.name)) {
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
seen.add(wallet.connector.name);
|
|
187
|
-
wallet.connector.setupEventListeners(secondaryListeners);
|
|
188
|
-
}
|
|
189
|
-
}, [
|
|
190
|
-
authMode,
|
|
191
|
-
computeConnectedStateForWallets,
|
|
192
|
-
selectedWalletConnector,
|
|
193
|
-
selectedWalletWithAction,
|
|
194
|
-
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
195
|
-
multiWalletWidgetState,
|
|
196
|
-
secondaryWallets,
|
|
197
|
-
refreshConnectedWallet,
|
|
198
|
-
]);
|
|
199
154
|
return {
|
|
200
155
|
loadingNetwork,
|
|
201
156
|
network,
|
|
@@ -39,7 +39,7 @@ require('../../context/MockContext/MockContext.cjs');
|
|
|
39
39
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
40
40
|
var useMutation = require('../../utils/hooks/useMutation/useMutation.cjs');
|
|
41
41
|
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
42
|
-
var
|
|
42
|
+
var useFindSocialIcon = require('../../utils/hooks/useFindSocialIcon/useFindSocialIcon.cjs');
|
|
43
43
|
var IconListTile = require('../../components/IconListTile/IconListTile.cjs');
|
|
44
44
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
45
45
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
@@ -55,7 +55,7 @@ const AccountExistsView = () => {
|
|
|
55
55
|
const { existentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
56
56
|
const { email, embeddedSocialSigninProvider } = existentAccountData || {};
|
|
57
57
|
const { socialProvider, setSocialProvider, socialWalletConnector } = SocialRedirectContext.useSocialRedirectContext();
|
|
58
|
-
const
|
|
58
|
+
const findSocialIcon = useFindSocialIcon.useFindSocialIcon();
|
|
59
59
|
const { mutate: handleNewLoging } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
60
60
|
setSocialProvider(embeddedSocialSigninProvider);
|
|
61
61
|
yield (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.endSession());
|
|
@@ -67,7 +67,7 @@ const AccountExistsView = () => {
|
|
|
67
67
|
: '. Please log in with your email.';
|
|
68
68
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["It looks like an account already exists using ", jsxRuntime.jsx("strong", { children: email }), '', messageTrail] }));
|
|
69
69
|
};
|
|
70
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'account-exists__image' }), jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon:
|
|
70
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'account-exists__image' }), jsxRuntime.jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize.capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsxRuntime.jsx(LoginWithEmailForm.LoginWithEmailForm, {}))] }))] })));
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
exports.AccountExistsView = AccountExistsView;
|
|
@@ -35,7 +35,7 @@ import '../../context/MockContext/MockContext.js';
|
|
|
35
35
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
36
36
|
import { useMutation } from '../../utils/hooks/useMutation/useMutation.js';
|
|
37
37
|
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
38
|
-
import {
|
|
38
|
+
import { useFindSocialIcon } from '../../utils/hooks/useFindSocialIcon/useFindSocialIcon.js';
|
|
39
39
|
import { IconListTile } from '../../components/IconListTile/IconListTile.js';
|
|
40
40
|
import '../../components/Popper/Popper/Popper.js';
|
|
41
41
|
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
@@ -51,7 +51,7 @@ const AccountExistsView = () => {
|
|
|
51
51
|
const { existentAccountData } = useAccountExistsContext();
|
|
52
52
|
const { email, embeddedSocialSigninProvider } = existentAccountData || {};
|
|
53
53
|
const { socialProvider, setSocialProvider, socialWalletConnector } = useSocialRedirectContext();
|
|
54
|
-
const
|
|
54
|
+
const findSocialIcon = useFindSocialIcon();
|
|
55
55
|
const { mutate: handleNewLoging } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
56
|
setSocialProvider(embeddedSocialSigninProvider);
|
|
57
57
|
yield (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.endSession());
|
|
@@ -63,7 +63,7 @@ const AccountExistsView = () => {
|
|
|
63
63
|
: '. Please log in with your email.';
|
|
64
64
|
return (jsxs(Fragment, { children: ["It looks like an account already exists using ", jsx("strong", { children: email }), '', messageTrail] }));
|
|
65
65
|
};
|
|
66
|
-
return (jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsx(UserProfileIcon, { className: 'account-exists__image' }), jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon:
|
|
66
|
+
return (jsxs("div", Object.assign({ className: 'account-exists__container' }, { children: [jsx(UserProfileIcon, { className: 'account-exists__image' }), jsxs("div", Object.assign({ className: 'account-exists__main' }, { children: [jsx("div", Object.assign({ className: 'account-exists__content' }, { children: jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'account-exists__content--secondary' }, { children: renderFullMessage() })) })), embeddedSocialSigninProvider ? (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${embeddedSocialSigninProvider}`, onClick: () => handleNewLoging(), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: findSocialIcon(embeddedSocialSigninProvider), isSpinning: socialProvider === embeddedSocialSigninProvider, iconSize: 32 }), jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with", ' ', capitalize(embeddedSocialSigninProvider === null || embeddedSocialSigninProvider === void 0 ? void 0 : embeddedSocialSigninProvider.toString())] }))] }), embeddedSocialSigninProvider)) : (jsx(LoginWithEmailForm, {}))] }))] })));
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
export { AccountExistsView };
|
|
@@ -41,6 +41,7 @@ require('../../../components/Alert/Alert.cjs');
|
|
|
41
41
|
require('../../../context/MockContext/MockContext.cjs');
|
|
42
42
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
43
43
|
require('../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
44
|
+
var Tooltip = require('../../../components/Tooltip/Tooltip.cjs');
|
|
44
45
|
require('../../../components/Popper/Popper/Popper.cjs');
|
|
45
46
|
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
46
47
|
require('yup');
|
|
@@ -63,6 +64,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
|
|
|
63
64
|
else if (name === 'policiesConsent') {
|
|
64
65
|
return (jsxRuntime.jsx("div", Object.assign({ role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container' }, { children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxRuntime.jsxs("div", Object.assign({ className: 'user-data-fields__consent-checkbox' }, { children: [jsxRuntime.jsx(formik.Field, { as: Checkbox.Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsxRuntime.jsx("label", Object.assign({ htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: component })) }))] }), `policiesConsent_${index}`))) }), 'policiesConsentGroup'));
|
|
65
66
|
}
|
|
67
|
+
else if (name === 'email' && !enabled) {
|
|
68
|
+
return (jsxRuntime.jsx(Tooltip.Tooltip, Object.assign({ content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip' }, { children: jsxRuntime.jsx(formik.Field, { disabled: true, as: Input.Input, type: type, id: name, name: name, label: label }, name) }), 'disabled-email-tooltip'));
|
|
69
|
+
}
|
|
66
70
|
else {
|
|
67
71
|
return (jsxRuntime.jsx(formik.Field, { disabled: !enabled, as: Input.Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage.getDisplayErrorMessage(label, errors[name]) }, name));
|
|
68
72
|
}
|
|
@@ -37,6 +37,7 @@ import '../../../components/Alert/Alert.js';
|
|
|
37
37
|
import '../../../context/MockContext/MockContext.js';
|
|
38
38
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
39
39
|
import '../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
40
|
+
import { Tooltip } from '../../../components/Tooltip/Tooltip.js';
|
|
40
41
|
import '../../../components/Popper/Popper/Popper.js';
|
|
41
42
|
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
42
43
|
import 'yup';
|
|
@@ -59,6 +60,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
|
|
|
59
60
|
else if (name === 'policiesConsent') {
|
|
60
61
|
return (jsx("div", Object.assign({ role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container' }, { children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxs("div", Object.assign({ className: 'user-data-fields__consent-checkbox' }, { children: [jsx(Field, { as: Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsx("label", Object.assign({ htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label' }, { children: jsx(Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: component })) }))] }), `policiesConsent_${index}`))) }), 'policiesConsentGroup'));
|
|
61
62
|
}
|
|
63
|
+
else if (name === 'email' && !enabled) {
|
|
64
|
+
return (jsx(Tooltip, Object.assign({ content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip' }, { children: jsx(Field, { disabled: true, as: Input, type: type, id: name, name: name, label: label }, name) }), 'disabled-email-tooltip'));
|
|
65
|
+
}
|
|
62
66
|
else {
|
|
63
67
|
return (jsx(Field, { disabled: !enabled, as: Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage(label, errors[name]) }, name));
|
|
64
68
|
}
|