@dynamic-labs/sdk-react-core 1.1.0-alpha.25 → 1.1.0-alpha.26
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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- 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/OTPVerificationView/OTPVerificationView.cjs +13 -60
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +13 -60
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.cjs +97 -0
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.d.ts +9 -0
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.js +93 -0
- package/src/lib/components/RetrySendVerificationCodeSection/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +2 -2
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +3 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +2 -4
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +4 -50
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +1 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +4 -50
- package/src/lib/events/dynamicEvents.d.ts +2 -0
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +1 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +1 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -6
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -6
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +4 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +4 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +38 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +16 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +39 -6
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.cjs +3 -2
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.js +3 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +5 -13
- package/src/lib/views/EmailVerification/EmailVerification.js +5 -13
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +1 -2
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +6 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +6 -1
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +0 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +0 -49
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +0 -18
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +0 -44
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
var CaptchaContext = require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
7
8
|
require('react');
|
|
8
9
|
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
9
10
|
require('@dynamic-labs/sdk-api');
|
|
@@ -20,7 +21,6 @@ var localStorage = require('../../../../shared/utils/classes/storage/localStorag
|
|
|
20
21
|
require('viem');
|
|
21
22
|
require('../../../../shared/consts/index.cjs');
|
|
22
23
|
require('../../../../events/dynamicEvents.cjs');
|
|
23
|
-
var CaptchaContext = require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
24
|
var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
26
26
|
require('viem/chains');
|
|
@@ -77,7 +77,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
77
77
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
78
78
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
79
79
|
const { getCaptchaToken, engageCaptcha } = CaptchaContext.useCaptchaContext();
|
|
80
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode,
|
|
80
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
81
81
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
82
82
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
83
83
|
consumeNonce,
|
|
@@ -109,9 +109,8 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
109
109
|
setIsVerificationInProgress(true);
|
|
110
110
|
yield showPendingConnectView.showPendingConnectView(walletConnector, setView);
|
|
111
111
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
walletId: connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.id,
|
|
112
|
+
yield connectWallet(walletConnector, fetchPublicAddressOpts, {
|
|
113
|
+
raiseOnConnect: true,
|
|
115
114
|
});
|
|
116
115
|
if (isConnectOnly.isConnectOnly(user, authMode)) {
|
|
117
116
|
localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.key);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { MissingPublicAddressError, isMobile } from '@dynamic-labs/utils';
|
|
3
|
+
import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
3
4
|
import 'react';
|
|
4
5
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
5
6
|
import '@dynamic-labs/sdk-api';
|
|
@@ -16,7 +17,6 @@ import { LocalStorage } from '../../../../shared/utils/classes/storage/localStor
|
|
|
16
17
|
import 'viem';
|
|
17
18
|
import '../../../../shared/consts/index.js';
|
|
18
19
|
import '../../../../events/dynamicEvents.js';
|
|
19
|
-
import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
20
|
import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import '@dynamic-labs/multi-wallet';
|
|
22
22
|
import 'viem/chains';
|
|
@@ -73,7 +73,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
73
73
|
const { setView, goToInitialView } = useViewContext();
|
|
74
74
|
const { setErrorMessage } = useErrorContext();
|
|
75
75
|
const { getCaptchaToken, engageCaptcha } = useCaptchaContext();
|
|
76
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode,
|
|
76
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
77
77
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
78
78
|
const verifyWallet = useVerifyWallet({
|
|
79
79
|
consumeNonce,
|
|
@@ -105,9 +105,8 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
105
105
|
setIsVerificationInProgress(true);
|
|
106
106
|
yield showPendingConnectView(walletConnector, setView);
|
|
107
107
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
walletId: connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.id,
|
|
108
|
+
yield connectWallet(walletConnector, fetchPublicAddressOpts, {
|
|
109
|
+
raiseOnConnect: true,
|
|
111
110
|
});
|
|
112
111
|
if (isConnectOnly(user, authMode)) {
|
|
113
112
|
LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.key);
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
9
|
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
10
10
|
var api = require('../../../data/api.cjs');
|
|
11
11
|
require('@dynamic-labs/sdk-api');
|
|
@@ -22,14 +22,24 @@ require('viem');
|
|
|
22
22
|
var useLocalStorage = require('../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
23
23
|
require('../../../shared/consts/index.cjs');
|
|
24
24
|
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
var getWalletIdentifier = require('../../functions/getWalletIdentifier/getWalletIdentifier.cjs');
|
|
25
26
|
var shouldManuallyReconnectOnRefresh = require('../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
26
27
|
require('viem/chains');
|
|
27
28
|
var getWalletProvider = require('../../functions/getWalletProvider/getWalletProvider.cjs');
|
|
29
|
+
var isConnectOnly = require('../authenticationHooks/helpers/isConnectOnly.cjs');
|
|
30
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
28
31
|
var updateUserWalletsFromConnectedWallets = require('./updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.cjs');
|
|
29
32
|
|
|
30
|
-
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, }) => {
|
|
33
|
+
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, setIsVerificationInProgress, user, }) => {
|
|
31
34
|
const [connectedWalletsInfo, setConnectedWalletsInfo, removeConnectedWalletsInfo,] = useLocalStorage.useLocalStorage(localStorage.CONNECTED_WALLETS_INFO, []);
|
|
32
35
|
const [connectedWallets, _setConnectedWallets] = React.useState([]);
|
|
36
|
+
/**
|
|
37
|
+
* When a new wallet is connected with the onConnect callback enabled,
|
|
38
|
+
* this new wallet's id will hang in this array until we attest that the corresponding wallet object
|
|
39
|
+
* has been successfully built — at which point we raise the callback and pop the id from this array.
|
|
40
|
+
* Should be removed with QNTM-1082 refactor
|
|
41
|
+
*/
|
|
42
|
+
const onConnectWaitList = React.useRef(new Set());
|
|
33
43
|
const { setUserWallets } = UserWalletsContext.useInternalUserWallets();
|
|
34
44
|
/** This wrapper is to ensure userWallets is always properly updated alongside connectedWallets */
|
|
35
45
|
const setConnectedWallets = (newWallets) => {
|
|
@@ -107,7 +117,21 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
107
117
|
return walletObject;
|
|
108
118
|
})))).filter((wallet) => Boolean(wallet));
|
|
109
119
|
setConnectedWallets(updatedConnectedWallets);
|
|
110
|
-
|
|
120
|
+
// Raise any onConnect callbacks in wait list
|
|
121
|
+
for (const walletId of [...onConnectWaitList.current]) {
|
|
122
|
+
const wallet = updatedConnectedWallets.find((wallet) => getWalletIdentifier.getWalletIdentifier(wallet) === walletId);
|
|
123
|
+
if (!wallet)
|
|
124
|
+
continue;
|
|
125
|
+
onConnectWaitList.current.delete(walletId);
|
|
126
|
+
dynamicEvents.dynamicEvents.emit('walletConnected', wallet);
|
|
127
|
+
setIsVerificationInProgress(false);
|
|
128
|
+
}
|
|
129
|
+
}), [
|
|
130
|
+
connectedWalletsInfo,
|
|
131
|
+
setIsVerificationInProgress,
|
|
132
|
+
disconnectWallet,
|
|
133
|
+
walletConnectorOptions,
|
|
134
|
+
]);
|
|
111
135
|
// Generate the connectedWallets list when connectedWalletsInfo (localStorage) or memoized wallet connector updates
|
|
112
136
|
React.useEffect(() => {
|
|
113
137
|
updateConnectedWalletsList();
|
|
@@ -178,12 +202,14 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
178
202
|
});
|
|
179
203
|
});
|
|
180
204
|
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
181
|
-
const connectWallet = (walletConnector, fetchPublicAddressOpts,
|
|
205
|
+
const connectWallet = (walletConnector, fetchPublicAddressOpts, options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
206
|
+
const { applyOnBeforeConnectSuccessConfirmation = true, raiseOnConnect = false, } = options !== null && options !== void 0 ? options : {};
|
|
182
207
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
183
208
|
if (!walletAddress) {
|
|
184
209
|
throw new utils.MissingPublicAddressError();
|
|
185
210
|
}
|
|
186
|
-
if (onBeforeConnectSuccessConfirmation &&
|
|
211
|
+
if (onBeforeConnectSuccessConfirmation &&
|
|
212
|
+
applyOnBeforeConnectSuccessConfirmation) {
|
|
187
213
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
188
214
|
address: walletAddress,
|
|
189
215
|
chain: walletConnector.connectedChain,
|
|
@@ -196,6 +222,13 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
196
222
|
}
|
|
197
223
|
}
|
|
198
224
|
const walletId = `connect-wallet-${getNextIdAvailable(connectedWalletsInfo)}`;
|
|
225
|
+
// We are already using the new syntax for wallet ids for this.
|
|
226
|
+
// Eventually the connect-wallet-X syntax will be dropped
|
|
227
|
+
if (raiseOnConnect && isConnectOnly.isConnectOnly(user, authMode))
|
|
228
|
+
onConnectWaitList.current.add(getWalletIdentifier.getWalletIdentifier({
|
|
229
|
+
address: walletAddress,
|
|
230
|
+
connector: walletConnector,
|
|
231
|
+
}));
|
|
199
232
|
if (!primaryWalletId) {
|
|
200
233
|
setPrimaryWalletId(walletId);
|
|
201
234
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Chain, FetchPublicAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import { ConnectWalletResult } from '../../../context/DynamicContext/types';
|
|
3
|
-
import { AuthModeType, OnBeforeConnectSuccessConfirmation, Wallet, WalletOption } from '../../../shared';
|
|
4
2
|
import { SetShowAuthFlow } from '../../../context/DynamicContext/hooks';
|
|
3
|
+
import { ConnectWalletResult } from '../../../context/DynamicContext/types';
|
|
4
|
+
import { AuthModeType, OnBeforeConnectSuccessConfirmation, UserProfile, Wallet, WalletOption } from '../../../shared';
|
|
5
5
|
export type ConnectedWalletConnectorType = {
|
|
6
6
|
id: string;
|
|
7
7
|
walletChain?: Chain;
|
|
8
8
|
walletConnectorKey: string;
|
|
9
9
|
provider: string;
|
|
10
10
|
};
|
|
11
|
-
type
|
|
11
|
+
export type UseConnectWalletProps = {
|
|
12
12
|
authMode: AuthModeType;
|
|
13
13
|
clearPrimaryWalletId: () => void;
|
|
14
14
|
enableVisitTrackingOnConnectOnly: boolean;
|
|
@@ -21,9 +21,20 @@ type Props = {
|
|
|
21
21
|
removeIsFullyConnected: () => void;
|
|
22
22
|
setShowAuthFlow: SetShowAuthFlow;
|
|
23
23
|
isBridgeFlow: boolean;
|
|
24
|
+
setIsVerificationInProgress: (newValue: boolean, checkWasSetOnDisable?: boolean | undefined) => void;
|
|
25
|
+
user: UserProfile | undefined;
|
|
26
|
+
};
|
|
27
|
+
export type ConnectWalletOptions = {
|
|
28
|
+
/** Whether to call onBeforeConnectSuccessConfirmation */
|
|
29
|
+
applyOnBeforeConnectSuccessConfirmation?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to raise onConnected callback after the connected wallet is built
|
|
32
|
+
* Should be removed after the userWallets refactor (QNTM-1082)
|
|
33
|
+
*/
|
|
34
|
+
raiseOnConnect?: boolean;
|
|
24
35
|
};
|
|
25
36
|
type UseConnectWalletValue = {
|
|
26
|
-
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts,
|
|
37
|
+
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts, options?: ConnectWalletOptions) => Promise<ConnectWalletResult | undefined>;
|
|
27
38
|
connectedWallets: Wallet[];
|
|
28
39
|
connectedWalletsInfo: ConnectedWalletConnectorType[];
|
|
29
40
|
getConnectedWalletById: (walletId: string) => Wallet | undefined;
|
|
@@ -31,5 +42,5 @@ type UseConnectWalletValue = {
|
|
|
31
42
|
removeConnectedWalletsInfo: () => void;
|
|
32
43
|
disconnectWallet: (walletId: string) => Promise<void>;
|
|
33
44
|
};
|
|
34
|
-
export declare const useConnectWallet: ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, }:
|
|
45
|
+
export declare const useConnectWallet: ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, setIsVerificationInProgress, user, }: UseConnectWalletProps) => UseConnectWalletValue;
|
|
35
46
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
-
import { getWalletConnectorByKey, logger } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
3
|
import { MissingPublicAddressError } from '@dynamic-labs/utils';
|
|
4
|
+
import { getWalletConnectorByKey, logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
6
6
|
import { createVisit } from '../../../data/api.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api';
|
|
@@ -18,14 +18,24 @@ import 'viem';
|
|
|
18
18
|
import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
19
19
|
import '../../../shared/consts/index.js';
|
|
20
20
|
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import { getWalletIdentifier } from '../../functions/getWalletIdentifier/getWalletIdentifier.js';
|
|
21
22
|
import { shouldManuallyReconnectOnRefresh } from '../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
22
23
|
import 'viem/chains';
|
|
23
24
|
import { getWalletProvider } from '../../functions/getWalletProvider/getWalletProvider.js';
|
|
25
|
+
import { isConnectOnly } from '../authenticationHooks/helpers/isConnectOnly.js';
|
|
26
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
24
27
|
import { updateUserWalletsFromConnectedWallets } from './updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.js';
|
|
25
28
|
|
|
26
|
-
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, }) => {
|
|
29
|
+
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, setIsVerificationInProgress, user, }) => {
|
|
27
30
|
const [connectedWalletsInfo, setConnectedWalletsInfo, removeConnectedWalletsInfo,] = useLocalStorage(CONNECTED_WALLETS_INFO, []);
|
|
28
31
|
const [connectedWallets, _setConnectedWallets] = useState([]);
|
|
32
|
+
/**
|
|
33
|
+
* When a new wallet is connected with the onConnect callback enabled,
|
|
34
|
+
* this new wallet's id will hang in this array until we attest that the corresponding wallet object
|
|
35
|
+
* has been successfully built — at which point we raise the callback and pop the id from this array.
|
|
36
|
+
* Should be removed with QNTM-1082 refactor
|
|
37
|
+
*/
|
|
38
|
+
const onConnectWaitList = useRef(new Set());
|
|
29
39
|
const { setUserWallets } = useInternalUserWallets();
|
|
30
40
|
/** This wrapper is to ensure userWallets is always properly updated alongside connectedWallets */
|
|
31
41
|
const setConnectedWallets = (newWallets) => {
|
|
@@ -103,7 +113,21 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
103
113
|
return walletObject;
|
|
104
114
|
})))).filter((wallet) => Boolean(wallet));
|
|
105
115
|
setConnectedWallets(updatedConnectedWallets);
|
|
106
|
-
|
|
116
|
+
// Raise any onConnect callbacks in wait list
|
|
117
|
+
for (const walletId of [...onConnectWaitList.current]) {
|
|
118
|
+
const wallet = updatedConnectedWallets.find((wallet) => getWalletIdentifier(wallet) === walletId);
|
|
119
|
+
if (!wallet)
|
|
120
|
+
continue;
|
|
121
|
+
onConnectWaitList.current.delete(walletId);
|
|
122
|
+
dynamicEvents.emit('walletConnected', wallet);
|
|
123
|
+
setIsVerificationInProgress(false);
|
|
124
|
+
}
|
|
125
|
+
}), [
|
|
126
|
+
connectedWalletsInfo,
|
|
127
|
+
setIsVerificationInProgress,
|
|
128
|
+
disconnectWallet,
|
|
129
|
+
walletConnectorOptions,
|
|
130
|
+
]);
|
|
107
131
|
// Generate the connectedWallets list when connectedWalletsInfo (localStorage) or memoized wallet connector updates
|
|
108
132
|
useEffect(() => {
|
|
109
133
|
updateConnectedWalletsList();
|
|
@@ -174,12 +198,14 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
174
198
|
});
|
|
175
199
|
});
|
|
176
200
|
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
177
|
-
const connectWallet = (walletConnector, fetchPublicAddressOpts,
|
|
201
|
+
const connectWallet = (walletConnector, fetchPublicAddressOpts, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
202
|
+
const { applyOnBeforeConnectSuccessConfirmation = true, raiseOnConnect = false, } = options !== null && options !== void 0 ? options : {};
|
|
178
203
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
179
204
|
if (!walletAddress) {
|
|
180
205
|
throw new MissingPublicAddressError();
|
|
181
206
|
}
|
|
182
|
-
if (onBeforeConnectSuccessConfirmation &&
|
|
207
|
+
if (onBeforeConnectSuccessConfirmation &&
|
|
208
|
+
applyOnBeforeConnectSuccessConfirmation) {
|
|
183
209
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
184
210
|
address: walletAddress,
|
|
185
211
|
chain: walletConnector.connectedChain,
|
|
@@ -192,6 +218,13 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
192
218
|
}
|
|
193
219
|
}
|
|
194
220
|
const walletId = `connect-wallet-${getNextIdAvailable(connectedWalletsInfo)}`;
|
|
221
|
+
// We are already using the new syntax for wallet ids for this.
|
|
222
|
+
// Eventually the connect-wallet-X syntax will be dropped
|
|
223
|
+
if (raiseOnConnect && isConnectOnly(user, authMode))
|
|
224
|
+
onConnectWaitList.current.add(getWalletIdentifier({
|
|
225
|
+
address: walletAddress,
|
|
226
|
+
connector: walletConnector,
|
|
227
|
+
}));
|
|
195
228
|
if (!primaryWalletId) {
|
|
196
229
|
setPrimaryWalletId(walletId);
|
|
197
230
|
}
|
|
@@ -70,6 +70,7 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
70
70
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
71
71
|
|
|
72
72
|
const useIsLoggedIn = () => {
|
|
73
|
+
var _a, _b;
|
|
73
74
|
const { user, primaryWallet, authMode, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
74
75
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
75
76
|
// a user is set even when on connect-only mode if signing in with social,
|
|
@@ -78,8 +79,8 @@ const useIsLoggedIn = () => {
|
|
|
78
79
|
// if turnkey is enabled we need to check if the user that is logged/connected
|
|
79
80
|
// has a primaryWallet to not show the widget without secure
|
|
80
81
|
if (isTurnkeyProviderEnabled &&
|
|
81
|
-
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.automaticEmbeddedWalletCreation) &&
|
|
82
|
-
(
|
|
82
|
+
((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
83
|
+
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup)) {
|
|
83
84
|
return Boolean(primaryWallet && isLoggedIn);
|
|
84
85
|
}
|
|
85
86
|
// return isLoggedIn;
|
|
@@ -66,6 +66,7 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
66
66
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
67
67
|
|
|
68
68
|
const useIsLoggedIn = () => {
|
|
69
|
+
var _a, _b;
|
|
69
70
|
const { user, primaryWallet, authMode, projectSettings } = useInternalDynamicContext();
|
|
70
71
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
71
72
|
// a user is set even when on connect-only mode if signing in with social,
|
|
@@ -74,8 +75,8 @@ const useIsLoggedIn = () => {
|
|
|
74
75
|
// if turnkey is enabled we need to check if the user that is logged/connected
|
|
75
76
|
// has a primaryWallet to not show the widget without secure
|
|
76
77
|
if (isTurnkeyProviderEnabled &&
|
|
77
|
-
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.automaticEmbeddedWalletCreation) &&
|
|
78
|
-
(
|
|
78
|
+
((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
79
|
+
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup)) {
|
|
79
80
|
return Boolean(primaryWallet && isLoggedIn);
|
|
80
81
|
}
|
|
81
82
|
// return isLoggedIn;
|
|
@@ -14,7 +14,6 @@ var decodeJwt = require('../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
|
14
14
|
require('@dynamic-labs/iconic');
|
|
15
15
|
require('@dynamic-labs/wallet-connector-core');
|
|
16
16
|
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
17
|
-
var checkCircle = require('../../shared/assets/check-circle.cjs');
|
|
18
17
|
var check = require('../../shared/assets/check.cjs');
|
|
19
18
|
var signInWithEmail = require('../../shared/assets/sign-in-with-email.cjs');
|
|
20
19
|
var logger = require('../../shared/logger.cjs');
|
|
@@ -37,7 +36,6 @@ var AccountExistsContext = require('../../context/AccountExistsContext/AccountEx
|
|
|
37
36
|
var api = require('../../data/api.cjs');
|
|
38
37
|
var useEmailVerificationRequest = require('../../utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs');
|
|
39
38
|
require('react-dom');
|
|
40
|
-
var useCountdown = require('../../utils/hooks/useCountdown/useCountdown.cjs');
|
|
41
39
|
var useEmbeddedWallet = require('../../utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs');
|
|
42
40
|
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
43
41
|
var useOnUnmount = require('../../utils/hooks/useOnUnmount/useOnUnmount.cjs');
|
|
@@ -78,8 +76,9 @@ require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/
|
|
|
78
76
|
var TextButton = require('../../components/TextButton/TextButton.cjs');
|
|
79
77
|
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
80
78
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
81
|
-
var shortenEmail = require('../../shared/utils/functions/shortenEmail/shortenEmail.cjs');
|
|
82
79
|
var PinField = require('../../components/PinField/PinField.cjs');
|
|
80
|
+
var shortenEmail = require('../../shared/utils/functions/shortenEmail/shortenEmail.cjs');
|
|
81
|
+
var RetrySendVerificationCodeSection = require('../../components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.cjs');
|
|
83
82
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
84
83
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
85
84
|
require('../WalletList/WalletList.cjs');
|
|
@@ -92,8 +91,7 @@ const SECONDS_TO_RETRY = 15;
|
|
|
92
91
|
const sleepToShowSuccessMessage = () => utils.sleep(1500);
|
|
93
92
|
const EmailVerification = () => {
|
|
94
93
|
var _a, _b, _c, _d;
|
|
95
|
-
const [
|
|
96
|
-
const [retried, setRetried] = React.useState(false);
|
|
94
|
+
const [showRetryButton, setShowRetryButton] = React.useState(true);
|
|
97
95
|
const [showTransferMessage, setShowTransferMessage] = React.useState(false);
|
|
98
96
|
// Use a state to ensure UI is updated, but also a ref to access in effect cleanup
|
|
99
97
|
const [isValidated, _setIsValidated] = React.useState(false);
|
|
@@ -110,10 +108,6 @@ const EmailVerification = () => {
|
|
|
110
108
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
111
109
|
const { t } = reactI18next.useTranslation();
|
|
112
110
|
const { createEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
|
|
113
|
-
const { remainingSeconds, startCountdown } = useCountdown.useCountdown({
|
|
114
|
-
callback: () => setRetried(false),
|
|
115
|
-
seconds: SECONDS_TO_RETRY,
|
|
116
|
-
});
|
|
117
111
|
// When true, causes the component to call emailVerificationX callback on unmount
|
|
118
112
|
const callCallbackOnUnmount = React.useRef(true);
|
|
119
113
|
useOnUnmount.useOnUnmount(() => {
|
|
@@ -281,15 +275,13 @@ const EmailVerification = () => {
|
|
|
281
275
|
verificationUUID,
|
|
282
276
|
});
|
|
283
277
|
setVerificationUUID(newVerificationUUID);
|
|
284
|
-
setRetried(true);
|
|
285
|
-
startCountdown();
|
|
286
278
|
setError(undefined);
|
|
287
279
|
}
|
|
288
280
|
catch (error) {
|
|
289
281
|
logger.logger.debug(error);
|
|
290
282
|
setErrorMessage(error.code);
|
|
291
283
|
if (error.code === 'too_many_email_verification_attempts') {
|
|
292
|
-
|
|
284
|
+
setShowRetryButton(false);
|
|
293
285
|
}
|
|
294
286
|
if (error.code === 'invalid_email_verification') {
|
|
295
287
|
goToInitialView();
|
|
@@ -310,7 +302,7 @@ const EmailVerification = () => {
|
|
|
310
302
|
}, []);
|
|
311
303
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [error && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { withIcon: false, className: 'email-verification__error-message', children: error })), jsxRuntime.jsxs("div", { className: classNames.classNames('email-verification__container', {
|
|
312
304
|
'email-verification__container--error': Boolean(error),
|
|
313
|
-
}), children: [showTransferMessage && (jsxRuntime.jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_email_verification.complete', children: t('dyn_email_verification.complete') })), isValidated ? (jsxRuntime.jsx("div", { className: 'email-verification__icon-container', children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: check.ReactComponent }) })) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxRuntime.jsxs("div", { className: 'email-verification__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_email_verification.description', children: t('dyn_email_verification.description') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail.shortenEmail(email) })] }), !isLoginView && !isValidated && (jsxRuntime.jsx(TextButton.TextButton, { onClick: updateEmail, className: 'email-verification__text-button', disabled: loading, copykey: 'dyn_email_verification.edit_email', children: t('dyn_email_verification.edit_email') })), jsxRuntime.jsx(PinField.PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: isLoginView ? handleEmailLogin : handleComplete, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }),
|
|
305
|
+
}), children: [showTransferMessage && (jsxRuntime.jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_email_verification.complete', children: t('dyn_email_verification.complete') })), isValidated ? (jsxRuntime.jsx("div", { className: 'email-verification__icon-container', children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: check.ReactComponent }) })) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxRuntime.jsxs("div", { className: 'email-verification__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_email_verification.description', children: t('dyn_email_verification.description') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail.shortenEmail(email) })] }), !isLoginView && !isValidated && (jsxRuntime.jsx(TextButton.TextButton, { onClick: updateEmail, className: 'email-verification__text-button', disabled: loading, copykey: 'dyn_email_verification.edit_email', children: t('dyn_email_verification.edit_email') })), jsxRuntime.jsx(PinField.PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: isLoginView ? handleEmailLogin : handleComplete, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }), showRetryButton && (jsxRuntime.jsx(RetrySendVerificationCodeSection.RetrySendVerificationCodeSection, { className: 'email-verification__retry-container', retryHandler: handleRetry, secondsToRetry: SECONDS_TO_RETRY })), !isLoginView && (jsxRuntime.jsx(TextButton.TextButton, { className: 'email-verification__log-out', onClick: handleLogOut, copykey: 'dyn_email_verification.log_out_button', children: t('dyn_email_verification.log_out_button') }))] })] }));
|
|
314
306
|
};
|
|
315
307
|
|
|
316
308
|
exports.EmailVerification = EmailVerification;
|
|
@@ -10,7 +10,6 @@ import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
|
10
10
|
import '@dynamic-labs/iconic';
|
|
11
11
|
import '@dynamic-labs/wallet-connector-core';
|
|
12
12
|
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
13
|
-
import { ReactComponent as SvgCheckCircle } from '../../shared/assets/check-circle.js';
|
|
14
13
|
import { ReactComponent as SvgCheck } from '../../shared/assets/check.js';
|
|
15
14
|
import { ReactComponent as SvgSignInWithEmail } from '../../shared/assets/sign-in-with-email.js';
|
|
16
15
|
import { logger } from '../../shared/logger.js';
|
|
@@ -33,7 +32,6 @@ import { useAccountExistsContext } from '../../context/AccountExistsContext/Acco
|
|
|
33
32
|
import { signInWithEmailVerification, retryEmailVerification } from '../../data/api.js';
|
|
34
33
|
import { useEmailVerificationRequest } from '../../utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js';
|
|
35
34
|
import 'react-dom';
|
|
36
|
-
import { useCountdown } from '../../utils/hooks/useCountdown/useCountdown.js';
|
|
37
35
|
import { useEmbeddedWallet } from '../../utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js';
|
|
38
36
|
import '../../context/ThemeContext/ThemeContext.js';
|
|
39
37
|
import { useOnUnmount } from '../../utils/hooks/useOnUnmount/useOnUnmount.js';
|
|
@@ -74,8 +72,9 @@ import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/P
|
|
|
74
72
|
import { TextButton } from '../../components/TextButton/TextButton.js';
|
|
75
73
|
import '../../components/InlineWidget/InlineWidget.js';
|
|
76
74
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
77
|
-
import { shortenEmail } from '../../shared/utils/functions/shortenEmail/shortenEmail.js';
|
|
78
75
|
import { PinField } from '../../components/PinField/PinField.js';
|
|
76
|
+
import { shortenEmail } from '../../shared/utils/functions/shortenEmail/shortenEmail.js';
|
|
77
|
+
import { RetrySendVerificationCodeSection } from '../../components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.js';
|
|
79
78
|
import '../../components/Popper/Popper/Popper.js';
|
|
80
79
|
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
81
80
|
import '../WalletList/WalletList.js';
|
|
@@ -88,8 +87,7 @@ const SECONDS_TO_RETRY = 15;
|
|
|
88
87
|
const sleepToShowSuccessMessage = () => sleep(1500);
|
|
89
88
|
const EmailVerification = () => {
|
|
90
89
|
var _a, _b, _c, _d;
|
|
91
|
-
const [
|
|
92
|
-
const [retried, setRetried] = useState(false);
|
|
90
|
+
const [showRetryButton, setShowRetryButton] = useState(true);
|
|
93
91
|
const [showTransferMessage, setShowTransferMessage] = useState(false);
|
|
94
92
|
// Use a state to ensure UI is updated, but also a ref to access in effect cleanup
|
|
95
93
|
const [isValidated, _setIsValidated] = useState(false);
|
|
@@ -106,10 +104,6 @@ const EmailVerification = () => {
|
|
|
106
104
|
const { loading, setLoading } = useLoadingContext();
|
|
107
105
|
const { t } = useTranslation();
|
|
108
106
|
const { createEmbeddedWallet } = useEmbeddedWallet();
|
|
109
|
-
const { remainingSeconds, startCountdown } = useCountdown({
|
|
110
|
-
callback: () => setRetried(false),
|
|
111
|
-
seconds: SECONDS_TO_RETRY,
|
|
112
|
-
});
|
|
113
107
|
// When true, causes the component to call emailVerificationX callback on unmount
|
|
114
108
|
const callCallbackOnUnmount = useRef(true);
|
|
115
109
|
useOnUnmount(() => {
|
|
@@ -277,15 +271,13 @@ const EmailVerification = () => {
|
|
|
277
271
|
verificationUUID,
|
|
278
272
|
});
|
|
279
273
|
setVerificationUUID(newVerificationUUID);
|
|
280
|
-
setRetried(true);
|
|
281
|
-
startCountdown();
|
|
282
274
|
setError(undefined);
|
|
283
275
|
}
|
|
284
276
|
catch (error) {
|
|
285
277
|
logger.debug(error);
|
|
286
278
|
setErrorMessage(error.code);
|
|
287
279
|
if (error.code === 'too_many_email_verification_attempts') {
|
|
288
|
-
|
|
280
|
+
setShowRetryButton(false);
|
|
289
281
|
}
|
|
290
282
|
if (error.code === 'invalid_email_verification') {
|
|
291
283
|
goToInitialView();
|
|
@@ -306,7 +298,7 @@ const EmailVerification = () => {
|
|
|
306
298
|
}, []);
|
|
307
299
|
return (jsxs(Fragment, { children: [error && (jsx(ErrorContainer, { withIcon: false, className: 'email-verification__error-message', children: error })), jsxs("div", { className: classNames('email-verification__container', {
|
|
308
300
|
'email-verification__container--error': Boolean(error),
|
|
309
|
-
}), children: [showTransferMessage && (jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_email_verification.complete', children: t('dyn_email_verification.complete') })), isValidated ? (jsx("div", { className: 'email-verification__icon-container', children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: SvgCheck }) })) : (jsx(IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxs("div", { className: 'email-verification__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_email_verification.description', children: t('dyn_email_verification.description') }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail(email) })] }), !isLoginView && !isValidated && (jsx(TextButton, { onClick: updateEmail, className: 'email-verification__text-button', disabled: loading, copykey: 'dyn_email_verification.edit_email', children: t('dyn_email_verification.edit_email') })), jsx(PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: isLoginView ? handleEmailLogin : handleComplete, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }),
|
|
301
|
+
}), children: [showTransferMessage && (jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_email_verification.complete', children: t('dyn_email_verification.complete') })), isValidated ? (jsx("div", { className: 'email-verification__icon-container', children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: SvgCheck }) })) : (jsx(IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxs("div", { className: 'email-verification__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_email_verification.description', children: t('dyn_email_verification.description') }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail(email) })] }), !isLoginView && !isValidated && (jsx(TextButton, { onClick: updateEmail, className: 'email-verification__text-button', disabled: loading, copykey: 'dyn_email_verification.edit_email', children: t('dyn_email_verification.edit_email') })), jsx(PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: isLoginView ? handleEmailLogin : handleComplete, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }), showRetryButton && (jsx(RetrySendVerificationCodeSection, { className: 'email-verification__retry-container', retryHandler: handleRetry, secondsToRetry: SECONDS_TO_RETRY })), !isLoginView && (jsx(TextButton, { className: 'email-verification__log-out', onClick: handleLogOut, copykey: 'dyn_email_verification.log_out_button', children: t('dyn_email_verification.log_out_button') }))] })] }));
|
|
310
302
|
};
|
|
311
303
|
|
|
312
304
|
export { EmailVerification };
|
|
@@ -96,7 +96,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
96
96
|
dynamicEvents.dynamicEvents.emit('emailVerificationResult', true, email);
|
|
97
97
|
},
|
|
98
98
|
});
|
|
99
|
-
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, successBannerTextKey: 'dyn_otp_verification.banner_text' }));
|
|
99
|
+
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, retryHandler: emailWalletConnector.retryOneTypePassword.bind(emailWalletConnector), onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, successBannerTextKey: 'dyn_otp_verification.banner_text' }));
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
exports.EmailWalletOTPVerificationView = EmailWalletOTPVerificationView;
|
|
@@ -92,7 +92,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
92
92
|
dynamicEvents.emit('emailVerificationResult', true, email);
|
|
93
93
|
},
|
|
94
94
|
});
|
|
95
|
-
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, successBannerTextKey: 'dyn_otp_verification.banner_text' }));
|
|
95
|
+
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, retryHandler: emailWalletConnector.retryOneTypePassword.bind(emailWalletConnector), onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, successBannerTextKey: 'dyn_otp_verification.banner_text' }));
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
export { EmailWalletOTPVerificationView };
|
|
@@ -23,7 +23,6 @@ require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
|
23
23
|
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
24
|
require('@dynamic-labs/multi-wallet');
|
|
25
25
|
var isMagicConnector = require('../../../../utils/functions/isMagicConnector/isMagicConnector.cjs');
|
|
26
|
-
var sendTransactionWithAutoNonce = require('../../../../utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs');
|
|
27
26
|
require('viem/chains');
|
|
28
27
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
29
28
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -78,7 +77,7 @@ const TransactionStage = (_a) => {
|
|
|
78
77
|
provider,
|
|
79
78
|
transaction,
|
|
80
79
|
});
|
|
81
|
-
return (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () =>
|
|
80
|
+
return (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => mutation(transactionWithGasPrice) }, rest)));
|
|
82
81
|
};
|
|
83
82
|
|
|
84
83
|
exports.TransactionStage = TransactionStage;
|
|
@@ -19,7 +19,6 @@ import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
|
19
19
|
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
20
20
|
import '@dynamic-labs/multi-wallet';
|
|
21
21
|
import { isMagicConnector } from '../../../../utils/functions/isMagicConnector/isMagicConnector.js';
|
|
22
|
-
import { sendTransactionWithAutoNonce } from '../../../../utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js';
|
|
23
22
|
import 'viem/chains';
|
|
24
23
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
25
24
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -74,7 +73,7 @@ const TransactionStage = (_a) => {
|
|
|
74
73
|
provider,
|
|
75
74
|
transaction,
|
|
76
75
|
});
|
|
77
|
-
return (jsx(TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () =>
|
|
76
|
+
return (jsx(TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => mutation(transactionWithGasPrice) }, rest)));
|
|
78
77
|
};
|
|
79
78
|
|
|
80
79
|
export { TransactionStage };
|
|
@@ -11,7 +11,7 @@ var utils = require('@dynamic-labs/utils');
|
|
|
11
11
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
12
12
|
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
13
13
|
require('@dynamic-labs/sdk-api');
|
|
14
|
-
require('../../shared/logger.cjs');
|
|
14
|
+
var logger = require('../../shared/logger.cjs');
|
|
15
15
|
var getChainIcon = require('../../shared/utils/functions/chain/getChainIcon.cjs');
|
|
16
16
|
require('@dynamic-labs/wallet-book');
|
|
17
17
|
var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
|
|
@@ -100,6 +100,9 @@ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess
|
|
|
100
100
|
}
|
|
101
101
|
return primaryWallet.connector.canSponsorTransactionGas(transaction);
|
|
102
102
|
}, {
|
|
103
|
+
onReject: (error) => {
|
|
104
|
+
logger.logger.error(error);
|
|
105
|
+
},
|
|
103
106
|
onResolve: (isGasSponsored) => {
|
|
104
107
|
const { connector } = primaryWallet;
|
|
105
108
|
setIsGasSponsored(isGasSponsored);
|
|
@@ -111,12 +114,14 @@ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess
|
|
|
111
114
|
const { mutate: send, isLoading, error: transactionError, } = useMutation.useMutation(() => mutation(), {
|
|
112
115
|
onFailure: (error) => {
|
|
113
116
|
if (utils.TransactionGasCannotBeSponsoredError.isInstance(error)) {
|
|
117
|
+
logger.logger.debug(error);
|
|
114
118
|
setIsGasSponsored(false);
|
|
115
119
|
const { connector } = primaryWallet;
|
|
116
120
|
if (walletConnectorCore.isAccountAbstractionConnector(connector)) {
|
|
117
121
|
connector.disableGasSponsorshipOnce();
|
|
118
122
|
}
|
|
119
123
|
}
|
|
124
|
+
logger.logger.error(error);
|
|
120
125
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
121
126
|
},
|
|
122
127
|
onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
|