@dynamic-labs/sdk-react-core 4.20.7 → 4.20.8

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -2
  6. package/src/lib/context/DynamicContext/DynamicContext.js +2 -3
  7. package/src/lib/data/api/exchangeAccounts/exchangeAccounts.cjs +75 -0
  8. package/src/lib/data/api/exchangeAccounts/exchangeAccounts.js +70 -0
  9. package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +2 -0
  10. package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +2 -0
  11. package/src/lib/locale/en/translation.cjs +4 -1
  12. package/src/lib/locale/en/translation.d.ts +3 -0
  13. package/src/lib/locale/en/translation.js +4 -1
  14. package/src/lib/store/state/dynamicContextProps/dynamicContextProps.cjs +2 -3
  15. package/src/lib/store/state/dynamicContextProps/dynamicContextProps.js +2 -3
  16. package/src/lib/utils/hooks/index.d.ts +1 -0
  17. package/src/lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.cjs +57 -0
  18. package/src/lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.js +53 -0
  19. package/src/lib/utils/hooks/usePromptAndFundWithExchange/index.d.ts +1 -0
  20. package/src/lib/utils/hooks/usePromptAndFundWithExchange/usePromptAndFundWithExchange.d.ts +4 -0
  21. package/src/lib/utils/hooks/useSubmitExchangeFunding/useSubmitExchangeFunding.cjs +199 -0
  22. package/src/lib/utils/hooks/useSubmitExchangeFunding/useSubmitExchangeFunding.js +195 -0
  23. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +1 -0
  24. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +1 -0
  25. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +1 -0
  26. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
  27. package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.cjs +3 -3
  28. package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.js +3 -3
  29. package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs +85 -15
  30. package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js +85 -15
  31. package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/types.d.ts +14 -1
  32. package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useExchangeTokensForFunding/useExchangeTokensForFunding.cjs +131 -0
  33. package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useExchangeTokensForFunding/useExchangeTokensForFunding.js +127 -0
@@ -0,0 +1,199 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var React = require('react');
9
+ var reactI18next = require('react-i18next');
10
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
11
+ var DynamicWidgetContext = require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
12
+ var useExchangeAccounts = require('../useExchangeAccounts/useExchangeAccounts.cjs');
13
+ require('../../../context/DynamicContext/DynamicContext.cjs');
14
+ require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
15
+ require('../../../shared/logger.cjs');
16
+ require('@dynamic-labs/iconic');
17
+ require('@dynamic-labs/wallet-connector-core');
18
+ var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
19
+ require('@dynamic-labs/wallet-book');
20
+ require('@dynamic-labs/utils');
21
+ require('../../constants/colors.cjs');
22
+ require('../../constants/values.cjs');
23
+ require('../../../shared/consts/index.cjs');
24
+ require('../../../events/dynamicEvents.cjs');
25
+ require('../../../context/CaptchaContext/CaptchaContext.cjs');
26
+ require('../../../context/ErrorContext/ErrorContext.cjs');
27
+ require('@dynamic-labs/multi-wallet');
28
+ require('react-international-phone');
29
+ require('../../../store/state/nonce/nonce.cjs');
30
+ require('../../../store/state/projectSettings/projectSettings.cjs');
31
+ require('../../../config/ApiEndpoint.cjs');
32
+ require('../../../store/state/user/user.cjs');
33
+ require('../../../locale/locale.cjs');
34
+ require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
35
+ require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
36
+ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
37
+ require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
38
+ require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
39
+ require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
40
+ require('../../../store/state/authMode/authMode.cjs');
41
+ require('../../../context/VerificationContext/VerificationContext.cjs');
42
+ require('react-dom');
43
+ require('../../functions/compareChains/compareChains.cjs');
44
+ require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
45
+ require('../../../context/ThemeContext/ThemeContext.cjs');
46
+ require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
47
+ require('bs58');
48
+ require('@dynamic-labs/types');
49
+ require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
50
+ require('../../../context/LoadingContext/LoadingContext.cjs');
51
+ require('../../../context/WalletContext/WalletContext.cjs');
52
+ require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
53
+ require('yup');
54
+ require('../../../context/MockContext/MockContext.cjs');
55
+ require('../../../views/CollectUserDataView/useFields.cjs');
56
+ require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
57
+ require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
58
+ require('@dynamic-labs/rpc-providers');
59
+ require('../../../store/state/walletOptions/walletOptions.cjs');
60
+ require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
61
+ require('../../../components/Alert/Alert.cjs');
62
+ var Typography = require('../../../components/Typography/Typography.cjs');
63
+ require('../../../components/ShadowDOM/ShadowDOM.cjs');
64
+ require('../../../components/IconButton/IconButton.cjs');
65
+ require('../../../components/InlineWidget/InlineWidget.cjs');
66
+ require('../../../components/Input/Input.cjs');
67
+ require('../../../components/IsBrowser/IsBrowser.cjs');
68
+ require('../../../components/MenuList/Dropdown/Dropdown.cjs');
69
+ require('../../../components/OverlayCard/OverlayCard.cjs');
70
+ require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
71
+ require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
72
+ require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
73
+ require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
74
+ require('../../../components/Popper/Popper/Popper.cjs');
75
+ require('../../../components/Popper/PopperContext/PopperContext.cjs');
76
+ require('react-focus-lock');
77
+ require('qrcode');
78
+ require('formik');
79
+ require('../useSubdomainCheck/useSubdomainCheck.cjs');
80
+ require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
81
+ require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
82
+ require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
83
+ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
84
+ require('@hcaptcha/react-hcaptcha');
85
+ require('../../../context/FooterAnimationContext/index.cjs');
86
+ require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
87
+ require('../../../context/PasskeyContext/PasskeyContext.cjs');
88
+ require('../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
89
+ require('../../../store/state/sendBalances.cjs');
90
+ require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
91
+ require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
92
+ require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
93
+ var getTransactionLink = require('../../functions/getTransactionLink/getTransactionLink.cjs');
94
+ require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
95
+ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
96
+ require('../../../context/OnrampContext/OnrampContext.cjs');
97
+ require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
98
+ require('../../../../index.cjs');
99
+ require('../../../store/state/tokenBalances.cjs');
100
+ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
101
+ var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
102
+
103
+ const useSubmitExchangeFunding = () => {
104
+ const { exchangeTransfer } = useExchangeAccounts.useExchangeAccounts();
105
+ const { setDynamicWidgetView, goToInitialDynamicWidgetView, setHeaderAlert } = DynamicWidgetContext.useWidgetContext();
106
+ const { clearStackAndPush } = ViewContext.useViewContext();
107
+ const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
108
+ const { t } = reactI18next.useTranslation();
109
+ const submit = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ tokenAmount, exchange, tokenSymbol, mfaCode, toAddress, props, }) {
110
+ if (!tokenAmount)
111
+ return;
112
+ try {
113
+ const result = yield exchangeTransfer({
114
+ exchange,
115
+ transferRequest: Object.assign({ amount: parseInt(tokenAmount, 10), currency: tokenSymbol, to: toAddress }, (mfaCode ? { mfaCode } : {})),
116
+ });
117
+ const txlink = yield getTransactionLink.getTransactionLink({
118
+ transactionHash: result.id,
119
+ walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
120
+ });
121
+ setShowAuthFlow(false);
122
+ setDynamicWidgetView('deposited-exchange', {
123
+ onClose: goToInitialDynamicWidgetView,
124
+ onSubmit: goToInitialDynamicWidgetView,
125
+ onView: () => {
126
+ if (txlink) {
127
+ window.open(txlink, '_blank', 'noopener,noreferrer');
128
+ }
129
+ },
130
+ toAddress,
131
+ transaction: result,
132
+ });
133
+ }
134
+ catch (error) {
135
+ let errorMessage = '';
136
+ let showError = false;
137
+ if (error.code ===
138
+ sdkApiCore.UnprocessableEntityErrorCode.TransferMfaRequired) {
139
+ setShowAuthFlow(true);
140
+ clearStackAndPush('mfa-exchange-view', {
141
+ onBack: () => {
142
+ setShowAuthFlow(false);
143
+ setDynamicWidgetView('confirm-exchange-transfer', Object.assign({}, props));
144
+ },
145
+ onSubmit: (code) => {
146
+ submit({
147
+ exchange,
148
+ mfaCode: code,
149
+ props,
150
+ toAddress,
151
+ tokenAmount,
152
+ tokenSymbol,
153
+ });
154
+ },
155
+ });
156
+ }
157
+ else if (error.code ===
158
+ sdkApiCore.UnprocessableEntityErrorCode.TransferMfaFailed) {
159
+ showError = true;
160
+ errorMessage = t('dyn_exchange_transfer_errors.mfa_failed');
161
+ }
162
+ else if (error.code ===
163
+ sdkApiCore.UnprocessableEntityErrorCode.InvalidTransferCurrency) {
164
+ showError = true;
165
+ errorMessage = t('dyn_exchange_transfer_errors.invalid_currency_description');
166
+ }
167
+ else if (error.code ===
168
+ sdkApiCore.UnprocessableEntityErrorCode.InvalidTransferFunds) {
169
+ showError = true;
170
+ errorMessage = t('dyn_exchange_transfer_errors.invalid_balance');
171
+ }
172
+ else {
173
+ showError = true;
174
+ errorMessage = t('dyn_exchange_transfer_errors.unknown');
175
+ }
176
+ if (showError) {
177
+ const errorAlert = (jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', color: 'current-color', children: [t('dyn_exchange_transfer_errors.title'), jsxRuntime.jsx(Typography.Typography, { color: 'current-color', children: errorMessage })] }));
178
+ setShowAuthFlow(false);
179
+ goToInitialDynamicWidgetView();
180
+ setHeaderAlert({
181
+ content: errorAlert,
182
+ variant: 'error',
183
+ });
184
+ }
185
+ }
186
+ }), [
187
+ clearStackAndPush,
188
+ exchangeTransfer,
189
+ goToInitialDynamicWidgetView,
190
+ primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
191
+ setDynamicWidgetView,
192
+ setHeaderAlert,
193
+ setShowAuthFlow,
194
+ t,
195
+ ]);
196
+ return submit;
197
+ };
198
+
199
+ exports.useSubmitExchangeFunding = useSubmitExchangeFunding;
@@ -0,0 +1,195 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { useCallback } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { UnprocessableEntityErrorCode } from '@dynamic-labs/sdk-api-core';
7
+ import { useWidgetContext } from '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
8
+ import { useExchangeAccounts } from '../useExchangeAccounts/useExchangeAccounts.js';
9
+ import '../../../context/DynamicContext/DynamicContext.js';
10
+ import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
11
+ import '../../../shared/logger.js';
12
+ import '@dynamic-labs/iconic';
13
+ import '@dynamic-labs/wallet-connector-core';
14
+ import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
15
+ import '@dynamic-labs/wallet-book';
16
+ import '@dynamic-labs/utils';
17
+ import '../../constants/colors.js';
18
+ import '../../constants/values.js';
19
+ import '../../../shared/consts/index.js';
20
+ import '../../../events/dynamicEvents.js';
21
+ import '../../../context/CaptchaContext/CaptchaContext.js';
22
+ import '../../../context/ErrorContext/ErrorContext.js';
23
+ import '@dynamic-labs/multi-wallet';
24
+ import 'react-international-phone';
25
+ import '../../../store/state/nonce/nonce.js';
26
+ import '../../../store/state/projectSettings/projectSettings.js';
27
+ import '../../../config/ApiEndpoint.js';
28
+ import '../../../store/state/user/user.js';
29
+ import '../../../locale/locale.js';
30
+ import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
31
+ import '../../../store/state/primaryWalletId/primaryWalletId.js';
32
+ import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
33
+ import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
34
+ import '../../../context/AccountExistsContext/AccountExistsContext.js';
35
+ import '../../../context/UserWalletsContext/UserWalletsContext.js';
36
+ import '../../../store/state/authMode/authMode.js';
37
+ import '../../../context/VerificationContext/VerificationContext.js';
38
+ import 'react-dom';
39
+ import '../../functions/compareChains/compareChains.js';
40
+ import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
41
+ import '../../../context/ThemeContext/ThemeContext.js';
42
+ import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
43
+ import 'bs58';
44
+ import '@dynamic-labs/types';
45
+ import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
46
+ import '../../../context/LoadingContext/LoadingContext.js';
47
+ import '../../../context/WalletContext/WalletContext.js';
48
+ import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
49
+ import 'yup';
50
+ import '../../../context/MockContext/MockContext.js';
51
+ import '../../../views/CollectUserDataView/useFields.js';
52
+ import '../../../context/FieldsStateContext/FieldsStateContext.js';
53
+ import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
54
+ import '@dynamic-labs/rpc-providers';
55
+ import '../../../store/state/walletOptions/walletOptions.js';
56
+ import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
57
+ import '../../../components/Alert/Alert.js';
58
+ import { Typography } from '../../../components/Typography/Typography.js';
59
+ import '../../../components/ShadowDOM/ShadowDOM.js';
60
+ import '../../../components/IconButton/IconButton.js';
61
+ import '../../../components/InlineWidget/InlineWidget.js';
62
+ import '../../../components/Input/Input.js';
63
+ import '../../../components/IsBrowser/IsBrowser.js';
64
+ import '../../../components/MenuList/Dropdown/Dropdown.js';
65
+ import '../../../components/OverlayCard/OverlayCard.js';
66
+ import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
67
+ import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
68
+ import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
69
+ import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
70
+ import '../../../components/Popper/Popper/Popper.js';
71
+ import '../../../components/Popper/PopperContext/PopperContext.js';
72
+ import 'react-focus-lock';
73
+ import 'qrcode';
74
+ import 'formik';
75
+ import '../useSubdomainCheck/useSubdomainCheck.js';
76
+ import '../../../context/WalletGroupContext/WalletGroupContext.js';
77
+ import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
78
+ import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
79
+ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
80
+ import '@hcaptcha/react-hcaptcha';
81
+ import '../../../context/FooterAnimationContext/index.js';
82
+ import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
83
+ import '../../../context/PasskeyContext/PasskeyContext.js';
84
+ import '../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
85
+ import '../../../store/state/sendBalances.js';
86
+ import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
87
+ import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
88
+ import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
89
+ import { getTransactionLink } from '../../functions/getTransactionLink/getTransactionLink.js';
90
+ import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
91
+ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
92
+ import '../../../context/OnrampContext/OnrampContext.js';
93
+ import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
94
+ import '../../../../index.js';
95
+ import '../../../store/state/tokenBalances.js';
96
+ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
97
+ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
98
+
99
+ const useSubmitExchangeFunding = () => {
100
+ const { exchangeTransfer } = useExchangeAccounts();
101
+ const { setDynamicWidgetView, goToInitialDynamicWidgetView, setHeaderAlert } = useWidgetContext();
102
+ const { clearStackAndPush } = useViewContext();
103
+ const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
104
+ const { t } = useTranslation();
105
+ const submit = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ tokenAmount, exchange, tokenSymbol, mfaCode, toAddress, props, }) {
106
+ if (!tokenAmount)
107
+ return;
108
+ try {
109
+ const result = yield exchangeTransfer({
110
+ exchange,
111
+ transferRequest: Object.assign({ amount: parseInt(tokenAmount, 10), currency: tokenSymbol, to: toAddress }, (mfaCode ? { mfaCode } : {})),
112
+ });
113
+ const txlink = yield getTransactionLink({
114
+ transactionHash: result.id,
115
+ walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
116
+ });
117
+ setShowAuthFlow(false);
118
+ setDynamicWidgetView('deposited-exchange', {
119
+ onClose: goToInitialDynamicWidgetView,
120
+ onSubmit: goToInitialDynamicWidgetView,
121
+ onView: () => {
122
+ if (txlink) {
123
+ window.open(txlink, '_blank', 'noopener,noreferrer');
124
+ }
125
+ },
126
+ toAddress,
127
+ transaction: result,
128
+ });
129
+ }
130
+ catch (error) {
131
+ let errorMessage = '';
132
+ let showError = false;
133
+ if (error.code ===
134
+ UnprocessableEntityErrorCode.TransferMfaRequired) {
135
+ setShowAuthFlow(true);
136
+ clearStackAndPush('mfa-exchange-view', {
137
+ onBack: () => {
138
+ setShowAuthFlow(false);
139
+ setDynamicWidgetView('confirm-exchange-transfer', Object.assign({}, props));
140
+ },
141
+ onSubmit: (code) => {
142
+ submit({
143
+ exchange,
144
+ mfaCode: code,
145
+ props,
146
+ toAddress,
147
+ tokenAmount,
148
+ tokenSymbol,
149
+ });
150
+ },
151
+ });
152
+ }
153
+ else if (error.code ===
154
+ UnprocessableEntityErrorCode.TransferMfaFailed) {
155
+ showError = true;
156
+ errorMessage = t('dyn_exchange_transfer_errors.mfa_failed');
157
+ }
158
+ else if (error.code ===
159
+ UnprocessableEntityErrorCode.InvalidTransferCurrency) {
160
+ showError = true;
161
+ errorMessage = t('dyn_exchange_transfer_errors.invalid_currency_description');
162
+ }
163
+ else if (error.code ===
164
+ UnprocessableEntityErrorCode.InvalidTransferFunds) {
165
+ showError = true;
166
+ errorMessage = t('dyn_exchange_transfer_errors.invalid_balance');
167
+ }
168
+ else {
169
+ showError = true;
170
+ errorMessage = t('dyn_exchange_transfer_errors.unknown');
171
+ }
172
+ if (showError) {
173
+ const errorAlert = (jsxs(Typography, { variant: 'body_normal', color: 'current-color', children: [t('dyn_exchange_transfer_errors.title'), jsx(Typography, { color: 'current-color', children: errorMessage })] }));
174
+ setShowAuthFlow(false);
175
+ goToInitialDynamicWidgetView();
176
+ setHeaderAlert({
177
+ content: errorAlert,
178
+ variant: 'error',
179
+ });
180
+ }
181
+ }
182
+ }), [
183
+ clearStackAndPush,
184
+ exchangeTransfer,
185
+ goToInitialDynamicWidgetView,
186
+ primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
187
+ setDynamicWidgetView,
188
+ setHeaderAlert,
189
+ setShowAuthFlow,
190
+ t,
191
+ ]);
192
+ return submit;
193
+ };
194
+
195
+ export { useSubmitExchangeFunding };
@@ -39,6 +39,7 @@ const mapViewToComponent = {
39
39
  'manage-mfa-no-footer': ManageMfaWidgetView.ManageMfaWidgetView,
40
40
  'manage-passkeys': ManagePasskeysWidgetView.ManagePasskeysWidgetView,
41
41
  profile: ProfileView.ProfileView,
42
+ 'receive-exchange-funds': ReceiveWalletFunds.ReceiveWalletFunds,
42
43
  'receive-wallet-funds': ReceiveWalletFunds.ReceiveWalletFunds,
43
44
  'send-balance': SendBalanceWidgetView.SendBalanceWidgetView,
44
45
  'session-management': SessionManagementView.SessionManagementView,
@@ -24,6 +24,7 @@ export declare const mapViewToComponent: {
24
24
  'manage-mfa-no-footer': import("react").FC;
25
25
  'manage-passkeys': import("react").FC;
26
26
  profile: import("react").FC;
27
+ 'receive-exchange-funds': import("react").FC<import("../../views/ReceiveWalletFunds/types").ReceiveWalletFundsProps>;
27
28
  'receive-wallet-funds': import("react").FC<import("../../views/ReceiveWalletFunds/types").ReceiveWalletFundsProps>;
28
29
  'send-balance': import("react").FC;
29
30
  'session-management': import("react").FC<import("../../views/SessionManagementView").SessionManagementViewProps>;
@@ -35,6 +35,7 @@ const mapViewToComponent = {
35
35
  'manage-mfa-no-footer': ManageMfaWidgetView,
36
36
  'manage-passkeys': ManagePasskeysWidgetView,
37
37
  profile: ProfileView,
38
+ 'receive-exchange-funds': ReceiveWalletFunds,
38
39
  'receive-wallet-funds': ReceiveWalletFunds,
39
40
  'send-balance': SendBalanceWidgetView,
40
41
  'session-management': SessionManagementView,
@@ -13,7 +13,7 @@ export declare const DynamicSessionManagementViews: readonly ["session-managemen
13
13
  export type DynamicSessionManagementViewsType = typeof DynamicSessionManagementViews[number];
14
14
  export declare const DynamicTransactionsWidgetViews: readonly ["send-balance"];
15
15
  export type DynamicTransactionsWidgetViewsType = typeof DynamicTransactionsWidgetViews[number];
16
- export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | 'choose-wallet-funding-method' | 'receive-wallet-funds' | 'deposited-exchange' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType | DynamicSessionManagementViewsType | 'connected-apps' | 'deposit-view' | 'confirm-exchange-transfer' | 'choose-onramp-provider' | 'choose-linked-wallet';
16
+ export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | 'choose-wallet-funding-method' | 'receive-wallet-funds' | 'deposited-exchange' | 'receive-exchange-funds' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType | DynamicSessionManagementViewsType | 'connected-apps' | 'deposit-view' | 'confirm-exchange-transfer' | 'choose-onramp-provider' | 'choose-linked-wallet';
17
17
  export type DynamicWidgetViewMapConstraint = Record<DynamicWidgetViews, FC<any>>;
18
18
  export type DynamicWidgetViewMap = typeof mapViewToComponent;
19
19
  export type SetDynamicWidgetView = <T extends DynamicWidgetViews>(view: T, props?: ComponentProps<DynamicWidgetViewMap[T]>) => void;
@@ -117,12 +117,12 @@ const ConfirmExchangeTransferView = ({ amount, toAddress, exchange, token, accou
117
117
  }) }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer_token-option__secondary', children: `${amount} ${token === null || token === void 0 ? void 0 : token.symbol}` })] })] }), jsxRuntime.jsx(Divider.Divider, {})] }), jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction', children: [jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__from', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'confirm-exchange-transfer__content__modal__transaction__from__title', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__title', children: t('dyn_exchange_transfer_confirmation.from') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: accountIdentifier
118
118
  ? `${(exchange === null || exchange === void 0 ? void 0 : exchange.charAt(0).toUpperCase()) + (exchange === null || exchange === void 0 ? void 0 : exchange.slice(1))} ${accountIdentifier}`
119
119
  : `${(exchange === null || exchange === void 0 ? void 0 : exchange.charAt(0).toUpperCase()) + (exchange === null || exchange === void 0 ? void 0 : exchange.slice(1))}` })] }), jsxRuntime.jsx(Divider.Divider, {}), jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__from', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'confirm-exchange-transfer__content__modal__transaction__from__title', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__title', children: t('dyn_exchange_transfer_confirmation.to') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: shortenWalletAddress.shortenWalletAddress(toAddress) })] }), jsxRuntime.jsx(Divider.Divider, {}), jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__from', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'confirm-exchange-transfer__content__modal__transaction__from__title', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__title', children: t('dyn_exchange_transfer_confirmation.fee') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: fee
120
- ? `${fiatCurrencySymbol}${feeInFiat} (${fee} ${token === null || token === void 0 ? void 0 : token.symbol})`
120
+ ? `${feeInFiat} ${fiatCurrencySymbol} (${fee} ${token === null || token === void 0 ? void 0 : token.symbol})`
121
121
  : t('dyn_exchange_transfer_confirmation.fee_not_found') })] }), jsxRuntime.jsx(Divider.Divider, {}), jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__receive', children: [jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__receive__container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container', children: t('dyn_exchange_transfer_confirmation.receive') }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container__fees', children: fee
122
122
  ? t('dyn_exchange_transfer_confirmation.cost')
123
123
  : t('dyn_exchange_transfer_confirmation.cost_no_fee') })] }), jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__receive__amount-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container', children: fee && fiatAmount && feeInFiat
124
- ? `${fiatCurrencySymbol}${fiatAmount - feeInFiat}`
125
- : `${fiatCurrencySymbol}${fiatAmount}` }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container__fees', children: fee && amount
124
+ ? `${fiatAmount - feeInFiat} ${fiatCurrencySymbol}`
125
+ : `${fiatAmount} ${fiatCurrencySymbol}` }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container__fees', children: fee && amount
126
126
  ? `${amount - fee} ${token === null || token === void 0 ? void 0 : token.symbol}`
127
127
  : `${amount} ${token === null || token === void 0 ? void 0 : token.symbol}` })] })] })] })] }) }), jsxRuntime.jsx("div", { className: 'confirm-exchange-transfer__content__terms', children: jsxRuntime.jsx(ModalCard.ModalCard, { border: false, sharpBorder: true, dropShadow: false, children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: t('dyn_exchange_transfer_confirmation.terms') }) }) }), jsxRuntime.jsxs("div", { className: 'confirm-exchange-transfer__content__buttons', children: [jsxRuntime.jsx("div", { className: 'confirm-exchange-transfer__content__buttons__button', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'cancel-button', buttonVariant: 'card', typographyProps: { weight: 'bold' }, className: 'confirm-exchange-transfer__content__buttons__button', onClick: () => {
128
128
  goToInitialDynamicWidgetView();
@@ -113,12 +113,12 @@ const ConfirmExchangeTransferView = ({ amount, toAddress, exchange, token, accou
113
113
  }) }), jsx(Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer_token-option__secondary', children: `${amount} ${token === null || token === void 0 ? void 0 : token.symbol}` })] })] }), jsx(Divider, {})] }), jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction', children: [jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__from', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'confirm-exchange-transfer__content__modal__transaction__from__title', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__title', children: t('dyn_exchange_transfer_confirmation.from') }), jsx(Typography, { variant: 'body_normal', weight: 'regular', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: accountIdentifier
114
114
  ? `${(exchange === null || exchange === void 0 ? void 0 : exchange.charAt(0).toUpperCase()) + (exchange === null || exchange === void 0 ? void 0 : exchange.slice(1))} ${accountIdentifier}`
115
115
  : `${(exchange === null || exchange === void 0 ? void 0 : exchange.charAt(0).toUpperCase()) + (exchange === null || exchange === void 0 ? void 0 : exchange.slice(1))}` })] }), jsx(Divider, {}), jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__from', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'confirm-exchange-transfer__content__modal__transaction__from__title', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__title', children: t('dyn_exchange_transfer_confirmation.to') }), jsx(Typography, { variant: 'body_normal', weight: 'regular', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: shortenWalletAddress(toAddress) })] }), jsx(Divider, {}), jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__from', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'confirm-exchange-transfer__content__modal__transaction__from__title', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__title', children: t('dyn_exchange_transfer_confirmation.fee') }), jsx(Typography, { variant: 'body_normal', weight: 'medium', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: fee
116
- ? `${fiatCurrencySymbol}${feeInFiat} (${fee} ${token === null || token === void 0 ? void 0 : token.symbol})`
116
+ ? `${feeInFiat} ${fiatCurrencySymbol} (${fee} ${token === null || token === void 0 ? void 0 : token.symbol})`
117
117
  : t('dyn_exchange_transfer_confirmation.fee_not_found') })] }), jsx(Divider, {}), jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__receive', children: [jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__receive__container', children: [jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container', children: t('dyn_exchange_transfer_confirmation.receive') }), jsx(Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container__fees', children: fee
118
118
  ? t('dyn_exchange_transfer_confirmation.cost')
119
119
  : t('dyn_exchange_transfer_confirmation.cost_no_fee') })] }), jsxs("div", { className: 'confirm-exchange-transfer__content__modal__transaction__receive__amount-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'bold', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container', children: fee && fiatAmount && feeInFiat
120
- ? `${fiatCurrencySymbol}${fiatAmount - feeInFiat}`
121
- : `${fiatCurrencySymbol}${fiatAmount}` }), jsx(Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container__fees', children: fee && amount
120
+ ? `${fiatAmount - feeInFiat} ${fiatCurrencySymbol}`
121
+ : `${fiatAmount} ${fiatCurrencySymbol}` }), jsx(Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__receive__container__fees', children: fee && amount
122
122
  ? `${amount - fee} ${token === null || token === void 0 ? void 0 : token.symbol}`
123
123
  : `${amount} ${token === null || token === void 0 ? void 0 : token.symbol}` })] })] })] })] }) }), jsx("div", { className: 'confirm-exchange-transfer__content__terms', children: jsx(ModalCard, { border: false, sharpBorder: true, dropShadow: false, children: jsx(Typography, { variant: 'body_small', weight: 'regular', className: 'confirm-exchange-transfer__content__modal__transaction__from__exchange', "data-testid": 'confirm-exchange-transfer__content__modal__transaction__from__exchange', children: t('dyn_exchange_transfer_confirmation.terms') }) }) }), jsxs("div", { className: 'confirm-exchange-transfer__content__buttons', children: [jsx("div", { className: 'confirm-exchange-transfer__content__buttons__button', children: jsx(TypographyButton, { dataTestId: 'cancel-button', buttonVariant: 'card', typographyProps: { weight: 'bold' }, className: 'confirm-exchange-transfer__content__buttons__button', onClick: () => {
124
124
  goToInitialDynamicWidgetView();