@dynamic-labs/sdk-react-core 4.20.6 → 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.
- package/CHANGELOG.md +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +2 -3
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/data/api/exchangeAccounts/exchangeAccounts.cjs +75 -0
- package/src/lib/data/api/exchangeAccounts/exchangeAccounts.js +70 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +4 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +4 -0
- package/src/lib/locale/en/translation.cjs +24 -1
- package/src/lib/locale/en/translation.d.ts +23 -0
- package/src/lib/locale/en/translation.js +24 -1
- package/src/lib/shared/assets/index.d.ts +2 -0
- package/src/lib/shared/assets/locked.cjs +52 -0
- package/src/lib/shared/assets/locked.js +28 -0
- package/src/lib/shared/assets/white-check-black-circle.cjs +61 -0
- package/src/lib/shared/assets/white-check-black-circle.js +37 -0
- package/src/lib/store/state/dynamicContextProps/dynamicContextProps.cjs +2 -3
- package/src/lib/store/state/dynamicContextProps/dynamicContextProps.js +2 -3
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/authViewLayoutChecks.cjs +1 -0
- package/src/lib/utils/constants/authViewLayoutChecks.js +1 -0
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.cjs +3 -0
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.d.ts +1 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.js +3 -0
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +8 -5
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +8 -5
- package/src/lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.cjs +57 -0
- package/src/lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.js +53 -0
- package/src/lib/utils/hooks/usePromptAndFundWithExchange/index.d.ts +1 -0
- package/src/lib/utils/hooks/usePromptAndFundWithExchange/usePromptAndFundWithExchange.d.ts +4 -0
- package/src/lib/utils/hooks/useSubmitExchangeFunding/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSubmitExchangeFunding/useSubmitExchangeFunding.cjs +199 -0
- package/src/lib/utils/hooks/useSubmitExchangeFunding/useSubmitExchangeFunding.d.ts +11 -0
- package/src/lib/utils/hooks/useSubmitExchangeFunding/useSubmitExchangeFunding.js +195 -0
- package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.cjs +14 -4
- package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.js +14 -4
- package/src/lib/views/MfaExchangeView/MfaExchangeView.cjs +127 -0
- package/src/lib/views/MfaExchangeView/MfaExchangeView.d.ts +7 -0
- package/src/lib/views/MfaExchangeView/MfaExchangeView.js +123 -0
- package/src/lib/views/MfaExchangeView/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +4 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +3 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +9 -13
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +3 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.d.ts +1 -2
- package/src/lib/widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/DepositedExchangeView/DepositedExchangeView.cjs +121 -0
- package/src/lib/widgets/DynamicWidget/views/DepositedExchangeView/DepositedExchangeView.d.ts +11 -0
- package/src/lib/widgets/DynamicWidget/views/DepositedExchangeView/DepositedExchangeView.js +117 -0
- package/src/lib/widgets/DynamicWidget/views/DepositedExchangeView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs +85 -15
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js +85 -15
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/types.d.ts +14 -1
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useExchangeTokensForFunding/useExchangeTokensForFunding.cjs +131 -0
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useExchangeTokensForFunding/useExchangeTokensForFunding.js +127 -0
|
@@ -7,6 +7,9 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
7
7
|
|
|
8
8
|
const getTransactionLink = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, transactionHash, }) {
|
|
9
9
|
try {
|
|
10
|
+
if (!walletConnector) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
10
13
|
const [blockExplorerUrl] = yield walletConnector.getBlockExplorerUrlsForCurrentNetwork();
|
|
11
14
|
if (!blockExplorerUrl)
|
|
12
15
|
return undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
export declare const getTransactionLink: ({ walletConnector, transactionHash, }: {
|
|
3
|
-
walletConnector
|
|
3
|
+
walletConnector?: WalletConnector;
|
|
4
4
|
transactionHash: string;
|
|
5
5
|
}) => Promise<string | undefined>;
|
|
@@ -3,6 +3,9 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
|
|
4
4
|
const getTransactionLink = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, transactionHash, }) {
|
|
5
5
|
try {
|
|
6
|
+
if (!walletConnector) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
6
9
|
const [blockExplorerUrl] = yield walletConnector.getBlockExplorerUrlsForCurrentNetwork();
|
|
7
10
|
if (!blockExplorerUrl)
|
|
8
11
|
return undefined;
|
|
@@ -79,3 +79,5 @@ export { useSyncDynamicWaas } from './useSyncDynamicWaas';
|
|
|
79
79
|
export { useExchangeAccounts } from './useExchangeAccounts';
|
|
80
80
|
export { useConnectExchangeForFunding } from './useConnectExchangeForFunding';
|
|
81
81
|
export { useClientSessionKeys } from './useClientSessionKeys';
|
|
82
|
+
export { usePromptAmountAndFundWithExchange } from './usePromptAndFundWithExchange';
|
|
83
|
+
export { useSubmitExchangeFunding } from './useSubmitExchangeFunding';
|
|
@@ -177,7 +177,7 @@ const useDynamicWaas = () => {
|
|
|
177
177
|
if (invalidChains && invalidChains.length) {
|
|
178
178
|
throw new utils.DynamicError(`${constants.INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}`);
|
|
179
179
|
}
|
|
180
|
-
const
|
|
180
|
+
const previousVerifiedCredentials = (user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials) || [];
|
|
181
181
|
const results = yield Promise.allSettled(chainNames.map((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
182
182
|
const walletConnector = getWalletConnector(chain);
|
|
183
183
|
if (!walletConnector)
|
|
@@ -206,7 +206,7 @@ const useDynamicWaas = () => {
|
|
|
206
206
|
const refreshedUser = yield refresh();
|
|
207
207
|
if (refreshedUser) {
|
|
208
208
|
// Add new wallet IDs to trigger walletAdded events
|
|
209
|
-
const newWalletIds = getNewVerifiedCredentialsFromDiff.getNewVerifiedCredentialsFromDiff(
|
|
209
|
+
const newWalletIds = getNewVerifiedCredentialsFromDiff.getNewVerifiedCredentialsFromDiff(previousVerifiedCredentials, refreshedUser.verifiedCredentials)
|
|
210
210
|
.filter(({ format }) => format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain)
|
|
211
211
|
.map(({ id }) => id);
|
|
212
212
|
addedWalletsIds.current = addedWalletsIds.current.concat(newWalletIds);
|
|
@@ -218,9 +218,12 @@ const useDynamicWaas = () => {
|
|
|
218
218
|
((_c = primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
219
219
|
});
|
|
220
220
|
if (createdPrimaryWallet) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
// if the user already has a blockchain wallet, don't update the primary wallet
|
|
222
|
+
if (!previousVerifiedCredentials.find((vc) => vc.format === 'blockchain')) {
|
|
223
|
+
const smartWalletAccount = smartWallet.findSmartWallet(createdPrimaryWallet, refreshedUser.verifiedCredentials);
|
|
224
|
+
const walletIdToUse = (smartWalletAccount === null || smartWalletAccount === void 0 ? void 0 : smartWalletAccount.id) || createdPrimaryWallet.id;
|
|
225
|
+
updatePrimaryWalletId.updatePrimaryWalletId(walletIdToUse);
|
|
226
|
+
}
|
|
224
227
|
}
|
|
225
228
|
}
|
|
226
229
|
}
|
|
@@ -173,7 +173,7 @@ const useDynamicWaas = () => {
|
|
|
173
173
|
if (invalidChains && invalidChains.length) {
|
|
174
174
|
throw new DynamicError(`${INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}`);
|
|
175
175
|
}
|
|
176
|
-
const
|
|
176
|
+
const previousVerifiedCredentials = (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || [];
|
|
177
177
|
const results = yield Promise.allSettled(chainNames.map((chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
178
|
const walletConnector = getWalletConnector(chain);
|
|
179
179
|
if (!walletConnector)
|
|
@@ -202,7 +202,7 @@ const useDynamicWaas = () => {
|
|
|
202
202
|
const refreshedUser = yield refresh();
|
|
203
203
|
if (refreshedUser) {
|
|
204
204
|
// Add new wallet IDs to trigger walletAdded events
|
|
205
|
-
const newWalletIds = getNewVerifiedCredentialsFromDiff(
|
|
205
|
+
const newWalletIds = getNewVerifiedCredentialsFromDiff(previousVerifiedCredentials, refreshedUser.verifiedCredentials)
|
|
206
206
|
.filter(({ format }) => format === JwtVerifiedCredentialFormatEnum.Blockchain)
|
|
207
207
|
.map(({ id }) => id);
|
|
208
208
|
addedWalletsIds.current = addedWalletsIds.current.concat(newWalletIds);
|
|
@@ -214,9 +214,12 @@ const useDynamicWaas = () => {
|
|
|
214
214
|
((_c = primaryWalletAccount.accountAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
215
215
|
});
|
|
216
216
|
if (createdPrimaryWallet) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
// if the user already has a blockchain wallet, don't update the primary wallet
|
|
218
|
+
if (!previousVerifiedCredentials.find((vc) => vc.format === 'blockchain')) {
|
|
219
|
+
const smartWalletAccount = findSmartWallet(createdPrimaryWallet, refreshedUser.verifiedCredentials);
|
|
220
|
+
const walletIdToUse = (smartWalletAccount === null || smartWalletAccount === void 0 ? void 0 : smartWalletAccount.id) || createdPrimaryWallet.id;
|
|
221
|
+
updatePrimaryWalletId(walletIdToUse);
|
|
222
|
+
}
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
225
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
10
|
+
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
11
|
+
require('../../constants/values.cjs');
|
|
12
|
+
require('@dynamic-labs/multi-wallet');
|
|
13
|
+
require('../../../shared/logger.cjs');
|
|
14
|
+
require('../../constants/colors.cjs');
|
|
15
|
+
require('react-international-phone');
|
|
16
|
+
require('@dynamic-labs/iconic');
|
|
17
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
18
|
+
require('react');
|
|
19
|
+
require('react/jsx-runtime');
|
|
20
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
21
|
+
require('@dynamic-labs/wallet-book');
|
|
22
|
+
require('../../../shared/consts/index.cjs');
|
|
23
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
24
|
+
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
25
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
26
|
+
require('../../../store/state/user/user.cjs');
|
|
27
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
28
|
+
var exchangeAccounts = require('../../../data/api/exchangeAccounts/exchangeAccounts.cjs');
|
|
29
|
+
require('../../../locale/locale.cjs');
|
|
30
|
+
|
|
31
|
+
const useExchangeAccounts = () => {
|
|
32
|
+
const environmentId = dynamicContextProps.getEnvironmentId();
|
|
33
|
+
const getExchangeUserAccounts = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ exchange, }) {
|
|
34
|
+
return exchangeAccounts.getUserExchangeAccounts({
|
|
35
|
+
environmentId,
|
|
36
|
+
exchangeKey: exchange,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const exchangeTransfer = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ exchange, transferRequest, }) {
|
|
40
|
+
const accounts = yield getExchangeUserAccounts({
|
|
41
|
+
exchange,
|
|
42
|
+
});
|
|
43
|
+
const accountOfCorrectCurrency = accounts.find(({ balances }) => balances.some(({ currency }) => currency.toLowerCase() === transferRequest.currency.toLowerCase()));
|
|
44
|
+
if (!accountOfCorrectCurrency) {
|
|
45
|
+
throw new utils.DynamicError(`No ${transferRequest.currency}-denominated account found for exchange “${exchange}”.`, sdkApiCore.UnprocessableEntityErrorCode.InvalidTransferCurrency);
|
|
46
|
+
}
|
|
47
|
+
return exchangeAccounts.createExchangeAccountTransfer({
|
|
48
|
+
accountId: accountOfCorrectCurrency.id,
|
|
49
|
+
environmentId,
|
|
50
|
+
exchangeKey: exchange,
|
|
51
|
+
transfer: transferRequest,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return { exchangeTransfer, getExchangeUserAccounts };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.useExchangeAccounts = useExchangeAccounts;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { UnprocessableEntityErrorCode } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
5
|
+
import '../../../config/ApiEndpoint.js';
|
|
6
|
+
import '../../../store/state/projectSettings/projectSettings.js';
|
|
7
|
+
import '../../constants/values.js';
|
|
8
|
+
import '@dynamic-labs/multi-wallet';
|
|
9
|
+
import '../../../shared/logger.js';
|
|
10
|
+
import '../../constants/colors.js';
|
|
11
|
+
import 'react-international-phone';
|
|
12
|
+
import '@dynamic-labs/iconic';
|
|
13
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
14
|
+
import 'react';
|
|
15
|
+
import 'react/jsx-runtime';
|
|
16
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
17
|
+
import '@dynamic-labs/wallet-book';
|
|
18
|
+
import '../../../shared/consts/index.js';
|
|
19
|
+
import '../../../store/state/nonce/nonce.js';
|
|
20
|
+
import { getEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
21
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
22
|
+
import '../../../store/state/user/user.js';
|
|
23
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
24
|
+
import { getUserExchangeAccounts, createExchangeAccountTransfer } from '../../../data/api/exchangeAccounts/exchangeAccounts.js';
|
|
25
|
+
import '../../../locale/locale.js';
|
|
26
|
+
|
|
27
|
+
const useExchangeAccounts = () => {
|
|
28
|
+
const environmentId = getEnvironmentId();
|
|
29
|
+
const getExchangeUserAccounts = (_a) => __awaiter(void 0, [_a], void 0, function* ({ exchange, }) {
|
|
30
|
+
return getUserExchangeAccounts({
|
|
31
|
+
environmentId,
|
|
32
|
+
exchangeKey: exchange,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const exchangeTransfer = (_b) => __awaiter(void 0, [_b], void 0, function* ({ exchange, transferRequest, }) {
|
|
36
|
+
const accounts = yield getExchangeUserAccounts({
|
|
37
|
+
exchange,
|
|
38
|
+
});
|
|
39
|
+
const accountOfCorrectCurrency = accounts.find(({ balances }) => balances.some(({ currency }) => currency.toLowerCase() === transferRequest.currency.toLowerCase()));
|
|
40
|
+
if (!accountOfCorrectCurrency) {
|
|
41
|
+
throw new DynamicError(`No ${transferRequest.currency}-denominated account found for exchange “${exchange}”.`, UnprocessableEntityErrorCode.InvalidTransferCurrency);
|
|
42
|
+
}
|
|
43
|
+
return createExchangeAccountTransfer({
|
|
44
|
+
accountId: accountOfCorrectCurrency.id,
|
|
45
|
+
environmentId,
|
|
46
|
+
exchangeKey: exchange,
|
|
47
|
+
transfer: transferRequest,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return { exchangeTransfer, getExchangeUserAccounts };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { useExchangeAccounts };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './usePromptAndFundWithExchange';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSubmitExchangeFunding';
|
|
@@ -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,11 @@
|
|
|
1
|
+
import { ExchangeKeyEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { ConfirmExchangeTransferViewProps } from '../../../widgets/DynamicWidget/views/ConfirmExchangeTransferView/ConfirmExchangeTransferView';
|
|
3
|
+
export type SubmitExchangeFundingProps = {
|
|
4
|
+
tokenAmount: string | undefined;
|
|
5
|
+
exchange: ExchangeKeyEnum;
|
|
6
|
+
tokenSymbol: string;
|
|
7
|
+
mfaCode?: string;
|
|
8
|
+
toAddress: string;
|
|
9
|
+
props: ConfirmExchangeTransferViewProps;
|
|
10
|
+
};
|
|
11
|
+
export declare const useSubmitExchangeFunding: () => ({ tokenAmount, exchange, tokenSymbol, mfaCode, toAddress, props, }: SubmitExchangeFundingProps) => Promise<void>;
|