@dynamic-labs/sdk-react-core 4.51.0 → 4.52.0
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 +23 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +14 -14
- package/src/lib/context/DynamicContext/DynamicContext.cjs +13 -12
- package/src/lib/context/DynamicContext/DynamicContext.js +13 -12
- package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +10 -0
- package/src/lib/data/api/constants.cjs +12 -0
- package/src/lib/data/api/constants.d.ts +3 -0
- package/src/lib/data/api/constants.js +6 -0
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +12 -1
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +12 -1
- package/src/lib/data/api/user/user.cjs +19 -0
- package/src/lib/data/api/user/user.d.ts +5 -0
- package/src/lib/data/api/user/user.js +19 -1
- package/src/lib/shared/utils/functions/chain/getChainIcon.cjs +1 -0
- package/src/lib/shared/utils/functions/chain/getChainIcon.js +2 -1
- package/src/lib/utils/constants/values.cjs +2 -0
- package/src/lib/utils/constants/values.js +2 -0
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.cjs +33 -1
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.d.ts +11 -0
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.js +32 -2
- package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
- package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.cjs +1 -1
- package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.js +1 -1
- package/src/lib/utils/hooks/useGetTransactionHistory/useGetTransactionHistory.d.ts +29 -0
- package/src/lib/utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.cjs +1 -4
- package/src/lib/utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.js +1 -4
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +7 -2
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +2 -1
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +7 -2
- package/src/lib/utils/hooks/useRegisterPasskey/useRegisterPasskey.cjs +8 -1
- package/src/lib/utils/hooks/useRegisterPasskey/useRegisterPasskey.js +8 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +2 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +4 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +2 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.cjs +131 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.d.ts +6 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.js +127 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +3 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +2 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +3 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +14 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +15 -3
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +8 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +8 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
5
|
+
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
7
|
+
import '../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
8
|
+
import '@dynamic-labs/iconic';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
11
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import '../../../../shared/logger.js';
|
|
13
|
+
import '@dynamic-labs/wallet-book';
|
|
14
|
+
import '../../../constants/colors.js';
|
|
15
|
+
import '../../../constants/values.js';
|
|
16
|
+
import '../../../../shared/consts/index.js';
|
|
17
|
+
import '../../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import 'react-international-phone';
|
|
22
|
+
import '../../../../store/state/nonce/nonce.js';
|
|
23
|
+
import '@dynamic-labs-sdk/client/core';
|
|
24
|
+
import { getDynamicClient } from '../../../../client/client.js';
|
|
25
|
+
import '@dynamic-labs-sdk/client';
|
|
26
|
+
import '../../../../config/ApiEndpoint.js';
|
|
27
|
+
import '@dynamic-labs/locale';
|
|
28
|
+
import { unlinkEmail } from '../../../../data/api/user/user.js';
|
|
29
|
+
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
30
|
+
import { getPrimaryWalletId } from '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
31
|
+
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
32
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
|
+
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
|
+
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
35
|
+
import '../../../../store/state/authMode/authMode.js';
|
|
36
|
+
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
37
|
+
import 'react-dom';
|
|
38
|
+
import '../../../functions/compareChains/compareChains.js';
|
|
39
|
+
import '../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
40
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
41
|
+
import '../useUpdateUser/userFieldsSchema.js';
|
|
42
|
+
import 'bs58';
|
|
43
|
+
import '@dynamic-labs/types';
|
|
44
|
+
import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
45
|
+
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
46
|
+
import '../../../../context/WalletContext/WalletContext.js';
|
|
47
|
+
import '../../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
48
|
+
import 'yup';
|
|
49
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
50
|
+
import '../../../../views/CollectUserDataView/useFields.js';
|
|
51
|
+
import '../../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
52
|
+
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
53
|
+
import '@dynamic-labs/rpc-providers';
|
|
54
|
+
import '../../../../store/state/walletOptions/walletOptions.js';
|
|
55
|
+
import 'react-i18next';
|
|
56
|
+
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
57
|
+
import '../../../../components/Alert/Alert.js';
|
|
58
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
59
|
+
import '../../../../components/IconButton/IconButton.js';
|
|
60
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
61
|
+
import '../../../../components/Input/Input.js';
|
|
62
|
+
import '../../../../components/IsBrowser/IsBrowser.js';
|
|
63
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
64
|
+
import '../../../../components/OverlayCard/OverlayCard.js';
|
|
65
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
66
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
67
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
68
|
+
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
69
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
70
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
71
|
+
import 'react-focus-lock';
|
|
72
|
+
import 'qrcode';
|
|
73
|
+
import 'formik';
|
|
74
|
+
import '../../useSubdomainCheck/useSubdomainCheck.js';
|
|
75
|
+
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
76
|
+
import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
77
|
+
import '../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
78
|
+
import '../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
79
|
+
import '@hcaptcha/react-hcaptcha';
|
|
80
|
+
import '../../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
81
|
+
import '../../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
|
|
82
|
+
import '../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
83
|
+
import '../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
84
|
+
import '../../../../context/FooterAnimationContext/index.js';
|
|
85
|
+
import '../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
86
|
+
import '../../../../context/PasskeyContext/PasskeyContext.js';
|
|
87
|
+
import '../../../../context/OnrampContext/OnrampContext.js';
|
|
88
|
+
import '../../../../store/state/sendBalances.js';
|
|
89
|
+
import '../../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
90
|
+
import '../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
91
|
+
import '../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
92
|
+
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
93
|
+
import '../../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
|
|
94
|
+
import '../../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
|
|
95
|
+
import '../../../../../index.js';
|
|
96
|
+
import '../../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
97
|
+
import '../../../../store/state/tokenBalances.js';
|
|
98
|
+
import '../../../../store/state/multichainBalances.js';
|
|
99
|
+
import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
100
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
101
|
+
|
|
102
|
+
const useUnlinkUserEmail = () => {
|
|
103
|
+
const { environmentId } = useInternalDynamicContext();
|
|
104
|
+
const unlinkUserEmail = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ verifiedCredentialId }) {
|
|
105
|
+
var _b;
|
|
106
|
+
const user = (_b = getDynamicClient()) === null || _b === void 0 ? void 0 : _b.user;
|
|
107
|
+
const primaryWalletId = getPrimaryWalletId();
|
|
108
|
+
if (!primaryWalletId) {
|
|
109
|
+
throw new DynamicError('Primary wallet not found');
|
|
110
|
+
}
|
|
111
|
+
const verifiedCredential = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((credential) => credential.id === verifiedCredentialId);
|
|
112
|
+
if (!verifiedCredential) {
|
|
113
|
+
throw new DynamicError('Verified credential not found');
|
|
114
|
+
}
|
|
115
|
+
if (verifiedCredential.format !== JwtVerifiedCredentialFormatEnum.Email) {
|
|
116
|
+
throw new DynamicError('Verified credential is not an email');
|
|
117
|
+
}
|
|
118
|
+
return unlinkEmail({
|
|
119
|
+
environmentId,
|
|
120
|
+
primaryWalletId,
|
|
121
|
+
verifiedCredentialId,
|
|
122
|
+
});
|
|
123
|
+
}), [environmentId]);
|
|
124
|
+
return unlinkUserEmail;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export { useUnlinkUserEmail };
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var useUpdateUser = require('./useUpdateUser/useUpdateUser.cjs');
|
|
7
7
|
var useUpdateUserWithModal = require('./useUpdateUserWithModal/useUpdateUserWithModal.cjs');
|
|
8
|
+
var unlinkUserEmail = require('./unlinkUserEmail/unlinkUserEmail.cjs');
|
|
8
9
|
|
|
9
10
|
// Hook only available internally
|
|
10
11
|
const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
11
12
|
const updateUser = useUpdateUser.useUpdateUser(validationSchemaStripUnknown);
|
|
12
13
|
const updateUserWithModal = useUpdateUserWithModal.useUpdateUserWithModal(updateUser);
|
|
13
|
-
|
|
14
|
+
const unlinkUserEmail$1 = unlinkUserEmail.useUnlinkUserEmail();
|
|
15
|
+
return { unlinkUserEmail: unlinkUserEmail$1, updateUser, updateUserWithModal };
|
|
14
16
|
};
|
|
15
17
|
// Hook exposed to the clients
|
|
16
18
|
// We do not want customers to be able to edit properties such as policiesConsent or captchaToken
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export declare const useUserUpdateRequestInternal: ({ validationSchemaStripUnknown, }: {
|
|
2
2
|
validationSchemaStripUnknown: boolean;
|
|
3
3
|
}) => {
|
|
4
|
+
unlinkUserEmail: import("./unlinkUserEmail/unlinkUserEmail").UnlinkUserEmail;
|
|
4
5
|
updateUser: import("./useUpdateUser").UpdateUser;
|
|
5
6
|
updateUserWithModal: (fields: import("./useUpdateUserWithModal").UpdateUserWithModalFields, options?: import("./useUpdateUserWithModal").UpdateUserWithModalOptions | undefined) => Promise<import("@dynamic-labs/sdk-api-core").UserFields>;
|
|
6
7
|
};
|
|
7
8
|
export declare const useUserUpdateRequest: () => {
|
|
9
|
+
unlinkUserEmail: import("./unlinkUserEmail/unlinkUserEmail").UnlinkUserEmail;
|
|
8
10
|
updateUser: import("./useUpdateUser").UpdateUser;
|
|
9
11
|
updateUserWithModal: (fields: import("./useUpdateUserWithModal").UpdateUserWithModalFields, options?: import("./useUpdateUserWithModal").UpdateUserWithModalOptions | undefined) => Promise<import("@dynamic-labs/sdk-api-core").UserFields>;
|
|
10
12
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { useUpdateUser } from './useUpdateUser/useUpdateUser.js';
|
|
3
3
|
import { useUpdateUserWithModal } from './useUpdateUserWithModal/useUpdateUserWithModal.js';
|
|
4
|
+
import { useUnlinkUserEmail } from './unlinkUserEmail/unlinkUserEmail.js';
|
|
4
5
|
|
|
5
6
|
// Hook only available internally
|
|
6
7
|
const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
7
8
|
const updateUser = useUpdateUser(validationSchemaStripUnknown);
|
|
8
9
|
const updateUserWithModal = useUpdateUserWithModal(updateUser);
|
|
9
|
-
|
|
10
|
+
const unlinkUserEmail = useUnlinkUserEmail();
|
|
11
|
+
return { unlinkUserEmail, updateUser, updateUserWithModal };
|
|
10
12
|
};
|
|
11
13
|
// Hook exposed to the clients
|
|
12
14
|
// We do not want customers to be able to edit properties such as policiesConsent or captchaToken
|
|
@@ -107,7 +107,9 @@ require('../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds
|
|
|
107
107
|
var useNetworkDataFromWallet = require('../../utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.cjs');
|
|
108
108
|
var useTokenBalances = require('../../utils/hooks/useTokenBalances/useTokenBalances.cjs');
|
|
109
109
|
require('../../store/state/multichainBalances.cjs');
|
|
110
|
+
var usePromptMfaAuth = require('../../utils/hooks/usePromptMfaAuth/usePromptMfaAuth.cjs');
|
|
110
111
|
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
112
|
+
var useIsMfaRequiredForAction = require('../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.cjs');
|
|
111
113
|
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
112
114
|
|
|
113
115
|
const usingNative = (token) => Boolean(token.isNative);
|
|
@@ -135,6 +137,8 @@ const getSupportedChainName = (connectedChain) => {
|
|
|
135
137
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
136
138
|
const [stage, setStage] = React.useState('form');
|
|
137
139
|
const { primaryWallet, walletUiUtils } = useInternalDynamicContext.useInternalDynamicContext();
|
|
140
|
+
const isMfaRequiredForAction = useIsMfaRequiredForAction.useIsMfaRequiredForAction();
|
|
141
|
+
const promptMfaAuth = usePromptMfaAuth.usePromptMfaAuth();
|
|
138
142
|
const { t } = reactI18next.useTranslation();
|
|
139
143
|
const [isNativeToken, setIsNativeToken] = React.useState(false);
|
|
140
144
|
const [currentToken, setCurrentToken] = React.useState(undefined);
|
|
@@ -221,10 +225,18 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
221
225
|
const buildFormStage = () => (jsxRuntime.jsx(SendBalancePageLayout.SendBalancePageLayout, { transaction: transaction, onClickBack: onClickBack, networkName: networkData.vanityName || networkData.name, networkIcon: currencyIcon, networkCurrencyDecimals: networkData.nativeCurrency.symbol === 'SOL'
|
|
222
226
|
? 9
|
|
223
227
|
: networkData.nativeCurrency.decimals, walletAddress: shortenWalletAddress.shortenWalletAddress(currentToken === null || currentToken === void 0 ? void 0 : currentToken.address), walletKey: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: () => setStage('confirmation'), tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, isNativeToken: isNativeToken }));
|
|
224
|
-
const buildTransactionStage = () => (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, transaction: transaction, mutation: () => {
|
|
228
|
+
const buildTransactionStage = () => (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, transaction: transaction, mutation: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
229
|
+
if (primaryWallet.connector.key === 'dynamicwaas') {
|
|
230
|
+
const isMfaRequired = yield isMfaRequiredForAction({
|
|
231
|
+
mfaAction: sdkApiCore.MFAAction.WalletWaasSign,
|
|
232
|
+
});
|
|
233
|
+
if (isMfaRequired) {
|
|
234
|
+
yield promptMfaAuth({ createMfaToken: true });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
225
237
|
walletUiUtils.disabledConfirmationOnce();
|
|
226
238
|
return transaction.submit();
|
|
227
|
-
}, copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (txHash) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
239
|
+
}), copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (txHash) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
228
240
|
if (!txHash)
|
|
229
241
|
return;
|
|
230
242
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(txHash);
|
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useState, useEffect } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import { ChainEnum, MFAAction } from '@dynamic-labs/sdk-api-core';
|
|
7
7
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
8
8
|
import { isSendBalanceWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
9
9
|
import { ChainIcon } from '../../components/ChainIcon/ChainIcon.js';
|
|
@@ -103,7 +103,9 @@ import '../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.
|
|
|
103
103
|
import { useNetworkDataFromWallet } from '../../utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.js';
|
|
104
104
|
import { useTokenBalances } from '../../utils/hooks/useTokenBalances/useTokenBalances.js';
|
|
105
105
|
import '../../store/state/multichainBalances.js';
|
|
106
|
+
import { usePromptMfaAuth } from '../../utils/hooks/usePromptMfaAuth/usePromptMfaAuth.js';
|
|
106
107
|
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
108
|
+
import { useIsMfaRequiredForAction } from '../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.js';
|
|
107
109
|
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
108
110
|
|
|
109
111
|
const usingNative = (token) => Boolean(token.isNative);
|
|
@@ -131,6 +133,8 @@ const getSupportedChainName = (connectedChain) => {
|
|
|
131
133
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
132
134
|
const [stage, setStage] = useState('form');
|
|
133
135
|
const { primaryWallet, walletUiUtils } = useInternalDynamicContext();
|
|
136
|
+
const isMfaRequiredForAction = useIsMfaRequiredForAction();
|
|
137
|
+
const promptMfaAuth = usePromptMfaAuth();
|
|
134
138
|
const { t } = useTranslation();
|
|
135
139
|
const [isNativeToken, setIsNativeToken] = useState(false);
|
|
136
140
|
const [currentToken, setCurrentToken] = useState(undefined);
|
|
@@ -217,10 +221,18 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
217
221
|
const buildFormStage = () => (jsx(SendBalancePageLayout, { transaction: transaction, onClickBack: onClickBack, networkName: networkData.vanityName || networkData.name, networkIcon: currencyIcon, networkCurrencyDecimals: networkData.nativeCurrency.symbol === 'SOL'
|
|
218
222
|
? 9
|
|
219
223
|
: networkData.nativeCurrency.decimals, walletAddress: shortenWalletAddress(currentToken === null || currentToken === void 0 ? void 0 : currentToken.address), walletKey: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: () => setStage('confirmation'), tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, isNativeToken: isNativeToken }));
|
|
220
|
-
const buildTransactionStage = () => (jsx(TransactionConfirmationView, { walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, transaction: transaction, mutation: () => {
|
|
224
|
+
const buildTransactionStage = () => (jsx(TransactionConfirmationView, { walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, transaction: transaction, mutation: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
225
|
+
if (primaryWallet.connector.key === 'dynamicwaas') {
|
|
226
|
+
const isMfaRequired = yield isMfaRequiredForAction({
|
|
227
|
+
mfaAction: MFAAction.WalletWaasSign,
|
|
228
|
+
});
|
|
229
|
+
if (isMfaRequired) {
|
|
230
|
+
yield promptMfaAuth({ createMfaToken: true });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
221
233
|
walletUiUtils.disabledConfirmationOnce();
|
|
222
234
|
return transaction.submit();
|
|
223
|
-
}, copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (txHash) => __awaiter(void 0, void 0, void 0, function* () {
|
|
235
|
+
}), copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (txHash) => __awaiter(void 0, void 0, void 0, function* () {
|
|
224
236
|
if (!txHash)
|
|
225
237
|
return;
|
|
226
238
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(txHash);
|
|
@@ -159,7 +159,10 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
159
159
|
isFetchingSimulationRef.current = false;
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
|
-
if (!primaryWallet ||
|
|
162
|
+
if (!primaryWallet ||
|
|
163
|
+
(!chainId &&
|
|
164
|
+
(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== 'SOL' &&
|
|
165
|
+
(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== 'TON')) {
|
|
163
166
|
logger.logger.error('[TransactionConfirmationView] Simulation failed:', {
|
|
164
167
|
chain: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain,
|
|
165
168
|
chainId,
|
|
@@ -228,6 +231,10 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
228
231
|
value: ((_f = transaction.value) === null || _f === void 0 ? void 0 : _f.toString()) || '0',
|
|
229
232
|
});
|
|
230
233
|
}
|
|
234
|
+
else if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'TON') {
|
|
235
|
+
setSimulationState({ status: SimulationStatus.SKIPPED });
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
231
238
|
}
|
|
232
239
|
if (!result && ((_g = primaryWallet.connector) === null || _g === void 0 ? void 0 : _g.key) !== 'zerodev') {
|
|
233
240
|
logger.logger.warn('[TransactionConfirmationView] Simulation failed: No result');
|
|
@@ -151,7 +151,10 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
151
151
|
isFetchingSimulationRef.current = false;
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
-
if (!primaryWallet ||
|
|
154
|
+
if (!primaryWallet ||
|
|
155
|
+
(!chainId &&
|
|
156
|
+
(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== 'SOL' &&
|
|
157
|
+
(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== 'TON')) {
|
|
155
158
|
logger.error('[TransactionConfirmationView] Simulation failed:', {
|
|
156
159
|
chain: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain,
|
|
157
160
|
chainId,
|
|
@@ -220,6 +223,10 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
220
223
|
value: ((_f = transaction.value) === null || _f === void 0 ? void 0 : _f.toString()) || '0',
|
|
221
224
|
});
|
|
222
225
|
}
|
|
226
|
+
else if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'TON') {
|
|
227
|
+
setSimulationState({ status: SimulationStatus.SKIPPED });
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
223
230
|
}
|
|
224
231
|
if (!result && ((_g = primaryWallet.connector) === null || _g === void 0 ? void 0 : _g.key) !== 'zerodev') {
|
|
225
232
|
logger.warn('[TransactionConfirmationView] Simulation failed: No result');
|