@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
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ### [4.20.8](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.7...v4.20.8) (2025-06-23)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * add log level to react-native ([#8993](https://github.com/dynamic-labs/dynamic-auth/issues/8993)) ([261e5d7](https://github.com/dynamic-labs/dynamic-auth/commit/261e5d74e66c3cf7b0dff75cd2a838a521888dd3))
8
+ * sui connector types ([#8995](https://github.com/dynamic-labs/dynamic-auth/issues/8995)) ([d41ad4a](https://github.com/dynamic-labs/dynamic-auth/commit/d41ad4ad98f7dd6139fbace142ac8852484cf098))
9
+
2
10
  ### [4.20.7](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.6...v4.20.7) (2025-06-20)
3
11
 
4
12
  ### Bug Fixes
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.20.7";
6
+ var version = "4.20.8";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.688",
9
9
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "4.20.7";
2
+ var version = "4.20.8";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.688",
5
5
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.20.7",
3
+ "version": "4.20.8",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.0.688",
6
6
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
@@ -15,16 +15,16 @@
15
15
  "yup": "0.32.11",
16
16
  "react-international-phone": "4.2.5",
17
17
  "bs58": "5.0.0",
18
- "@dynamic-labs/assert-package-version": "4.20.7",
19
- "@dynamic-labs/iconic": "4.20.7",
20
- "@dynamic-labs/logger": "4.20.7",
21
- "@dynamic-labs/multi-wallet": "4.20.7",
22
- "@dynamic-labs/rpc-providers": "4.20.7",
23
- "@dynamic-labs/store": "4.20.7",
24
- "@dynamic-labs/types": "4.20.7",
25
- "@dynamic-labs/utils": "4.20.7",
26
- "@dynamic-labs/wallet-book": "4.20.7",
27
- "@dynamic-labs/wallet-connector-core": "4.20.7",
18
+ "@dynamic-labs/assert-package-version": "4.20.8",
19
+ "@dynamic-labs/iconic": "4.20.8",
20
+ "@dynamic-labs/logger": "4.20.8",
21
+ "@dynamic-labs/multi-wallet": "4.20.8",
22
+ "@dynamic-labs/rpc-providers": "4.20.8",
23
+ "@dynamic-labs/store": "4.20.8",
24
+ "@dynamic-labs/types": "4.20.8",
25
+ "@dynamic-labs/utils": "4.20.8",
26
+ "@dynamic-labs/wallet-book": "4.20.8",
27
+ "@dynamic-labs/wallet-connector-core": "4.20.8",
28
28
  "eventemitter3": "5.0.1"
29
29
  },
30
30
  "devDependencies": {
@@ -196,8 +196,7 @@ const InnerDynamicContextProvider = (props) => {
196
196
  if (!environmentId) {
197
197
  throw new utils.MissingEnvironmentIdError();
198
198
  }
199
- logger$1.logger.setLogLevel(logLevel);
200
- walletConnectorCore.logger.setLogLevel(logLevel);
199
+ logger.Logger.setLogLevel(logLevel);
201
200
  if (environmentId === PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID) {
202
201
  logger$1.logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
203
202
  }
@@ -7,7 +7,7 @@ import { getIconicSpriteUrl } from '@dynamic-labs/iconic';
7
7
  import { Logger } from '@dynamic-labs/logger';
8
8
  import { MissingEnvironmentIdError, getEnvVarWithFallback, StorageService, tracing } from '@dynamic-labs/utils';
9
9
  import { useWalletBookCdn, getWalletBookCdnUrl, WalletBookContextProvider } from '@dynamic-labs/wallet-book';
10
- import { setChainInfoOverrides, logger as logger$1, isSessionKeyCompatibleWalletConnector } from '@dynamic-labs/wallet-connector-core';
10
+ import { setChainInfoOverrides, isSessionKeyCompatibleWalletConnector } from '@dynamic-labs/wallet-connector-core';
11
11
  import { VERSION } from '../../../version.js';
12
12
  import { DynamicAuthFlow } from '../../app.js';
13
13
  import { useInitializeSdkClient } from '../../client/extension/useInitializeSdkClient/useInitializeSdkClient.js';
@@ -192,8 +192,7 @@ const InnerDynamicContextProvider = (props) => {
192
192
  if (!environmentId) {
193
193
  throw new MissingEnvironmentIdError();
194
194
  }
195
- logger.setLogLevel(logLevel);
196
- logger$1.setLogLevel(logLevel);
195
+ Logger.setLogLevel(logLevel);
197
196
  if (environmentId === PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID) {
198
197
  logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
199
198
  }
@@ -0,0 +1,75 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var utils$1 = require('@dynamic-labs/utils');
8
+ var api = require('../api.cjs');
9
+ var utils = require('../utils.cjs');
10
+
11
+ /**
12
+ * Retrieve the list of exchange accounts linked to a user for a given exchange provider.
13
+ *
14
+ * @param environmentId – Dynamic environment ID
15
+ * @param exchangeKey – The key identifying the exchange provider (e.g., 'coinbase')
16
+ * @returns An array of `Account` objects representing the user's linked exchange accounts
17
+ */
18
+ const getUserExchangeAccounts = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, exchangeKey, }) {
19
+ try {
20
+ const accounts = yield api.sdkApi().getUserAccounts({
21
+ environmentId,
22
+ exchangeKey,
23
+ });
24
+ return accounts;
25
+ }
26
+ catch (e) {
27
+ const data = yield utils.logResponseError(e, 'Error retrieving accounts');
28
+ throw new utils$1.DynamicError(data.error);
29
+ }
30
+ });
31
+ /**
32
+ * Transfer funds from a user-linked exchange account to an external address
33
+ * or another Coinbase account.
34
+ *
35
+ * @param environmentId – Dynamic environment ID
36
+ * @param exchangeKey – The key identifying the exchange provider (e.g., `'coinbase'`)
37
+ * @param accountId – The exchange-account ID to transfer funds **from**
38
+ * @param transfer – JSON body matching `CreateExchangeTransferRequest`
39
+ * @returns Details of the created transfer (`ExchangeTransferResponse`)
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * await createExchangeAccountTransfer({
44
+ * environmentId: 'env_123',
45
+ * exchangeKey: ExchangeKeyEnum.COINBASE,
46
+ * accountId: 'acc_456',
47
+ * transfer: {
48
+ * to: '0xRecipientAddress',
49
+ * amount: 0.25,
50
+ * currency: 'ETH',
51
+ * network: 'ethereum',
52
+ * description: 'Withdrawal to cold wallet',
53
+ * mfaCode: '123456',
54
+ * },
55
+ * });
56
+ * ```
57
+ */
58
+ const createExchangeAccountTransfer = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ environmentId, exchangeKey, accountId, transfer, }) {
59
+ try {
60
+ const response = yield api.sdkApi().postExchangeAccountTransfer({
61
+ accountId,
62
+ createExchangeTransferRequest: transfer,
63
+ environmentId,
64
+ exchangeKey,
65
+ });
66
+ return response;
67
+ }
68
+ catch (e) {
69
+ const data = yield utils.logResponseError(e, 'Error creating exchange-account transfer');
70
+ throw new utils$1.DynamicError(data.error, data.code);
71
+ }
72
+ });
73
+
74
+ exports.createExchangeAccountTransfer = createExchangeAccountTransfer;
75
+ exports.getUserExchangeAccounts = getUserExchangeAccounts;
@@ -0,0 +1,70 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
+ import { DynamicError } from '@dynamic-labs/utils';
4
+ import { sdkApi } from '../api.js';
5
+ import { logResponseError } from '../utils.js';
6
+
7
+ /**
8
+ * Retrieve the list of exchange accounts linked to a user for a given exchange provider.
9
+ *
10
+ * @param environmentId – Dynamic environment ID
11
+ * @param exchangeKey – The key identifying the exchange provider (e.g., 'coinbase')
12
+ * @returns An array of `Account` objects representing the user's linked exchange accounts
13
+ */
14
+ const getUserExchangeAccounts = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, exchangeKey, }) {
15
+ try {
16
+ const accounts = yield sdkApi().getUserAccounts({
17
+ environmentId,
18
+ exchangeKey,
19
+ });
20
+ return accounts;
21
+ }
22
+ catch (e) {
23
+ const data = yield logResponseError(e, 'Error retrieving accounts');
24
+ throw new DynamicError(data.error);
25
+ }
26
+ });
27
+ /**
28
+ * Transfer funds from a user-linked exchange account to an external address
29
+ * or another Coinbase account.
30
+ *
31
+ * @param environmentId – Dynamic environment ID
32
+ * @param exchangeKey – The key identifying the exchange provider (e.g., `'coinbase'`)
33
+ * @param accountId – The exchange-account ID to transfer funds **from**
34
+ * @param transfer – JSON body matching `CreateExchangeTransferRequest`
35
+ * @returns Details of the created transfer (`ExchangeTransferResponse`)
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * await createExchangeAccountTransfer({
40
+ * environmentId: 'env_123',
41
+ * exchangeKey: ExchangeKeyEnum.COINBASE,
42
+ * accountId: 'acc_456',
43
+ * transfer: {
44
+ * to: '0xRecipientAddress',
45
+ * amount: 0.25,
46
+ * currency: 'ETH',
47
+ * network: 'ethereum',
48
+ * description: 'Withdrawal to cold wallet',
49
+ * mfaCode: '123456',
50
+ * },
51
+ * });
52
+ * ```
53
+ */
54
+ const createExchangeAccountTransfer = (_b) => __awaiter(void 0, [_b], void 0, function* ({ environmentId, exchangeKey, accountId, transfer, }) {
55
+ try {
56
+ const response = yield sdkApi().postExchangeAccountTransfer({
57
+ accountId,
58
+ createExchangeTransferRequest: transfer,
59
+ environmentId,
60
+ exchangeKey,
61
+ });
62
+ return response;
63
+ }
64
+ catch (e) {
65
+ const data = yield logResponseError(e, 'Error creating exchange-account transfer');
66
+ throw new DynamicError(data.error, data.code);
67
+ }
68
+ });
69
+
70
+ export { createExchangeAccountTransfer, getUserExchangeAccounts };
@@ -111,6 +111,7 @@ const shouldNotRenderHeaderViews = [
111
111
  ...DynamicWidgetContext_types.DynamicGlobalWalletViews,
112
112
  'receive-wallet-funds',
113
113
  'deposited-exchange',
114
+ 'receive-exchange-funds',
114
115
  'choose-wallet-funding-method',
115
116
  'deposit-view',
116
117
  'choose-linked-wallet',
@@ -122,6 +123,7 @@ const shouldNotRenderHeaderViews = [
122
123
  const shouldNotRenderBottomNavBarOptions = [
123
124
  'receive-wallet-funds',
124
125
  'deposited-exchange',
126
+ 'receive-exchange-funds',
125
127
  'choose-wallet-funding-method',
126
128
  'deposit-view',
127
129
  'confirm-exchange-transfer',
@@ -107,6 +107,7 @@ const shouldNotRenderHeaderViews = [
107
107
  ...DynamicGlobalWalletViews,
108
108
  'receive-wallet-funds',
109
109
  'deposited-exchange',
110
+ 'receive-exchange-funds',
110
111
  'choose-wallet-funding-method',
111
112
  'deposit-view',
112
113
  'choose-linked-wallet',
@@ -118,6 +119,7 @@ const shouldNotRenderHeaderViews = [
118
119
  const shouldNotRenderBottomNavBarOptions = [
119
120
  'receive-wallet-funds',
120
121
  'deposited-exchange',
122
+ 'receive-exchange-funds',
121
123
  'choose-wallet-funding-method',
122
124
  'deposit-view',
123
125
  'confirm-exchange-transfer',
@@ -518,7 +518,7 @@ const translation = {
518
518
  cost: 'Amount + Fees',
519
519
  cost_no_fee: 'Amount',
520
520
  terms: 'By confirming I agree to the Terms of Service and acknowledge this deposit is final.',
521
- send: 'Send {{fiatCurrencySymbol}}{{fiatCurrency}}',
521
+ send: 'Send {{fiatCurrency}} {{fiatCurrencySymbol}}',
522
522
  confirm: 'Confirm',
523
523
  cancel: 'Cancel',
524
524
  account: 'User {{exchange}}',
@@ -535,6 +535,9 @@ const translation = {
535
535
  description: 'Enter the code sent to you or generated by your authenticator app',
536
536
  button: 'Confirm',
537
537
  },
538
+ dyn_fund_from_exchange: {
539
+ title: 'Fund from Exchange',
540
+ },
538
541
  dyn_exchange_transfer_errors: {
539
542
  title: 'Unable to execute transfer.',
540
543
  mfa_failed: 'Incorrect security code. Please double-check your MFA code and try again.',
@@ -529,6 +529,9 @@ export declare const translation: {
529
529
  description: string;
530
530
  button: string;
531
531
  };
532
+ dyn_fund_from_exchange: {
533
+ title: string;
534
+ };
532
535
  dyn_exchange_transfer_errors: {
533
536
  title: string;
534
537
  mfa_failed: string;
@@ -514,7 +514,7 @@ const translation = {
514
514
  cost: 'Amount + Fees',
515
515
  cost_no_fee: 'Amount',
516
516
  terms: 'By confirming I agree to the Terms of Service and acknowledge this deposit is final.',
517
- send: 'Send {{fiatCurrencySymbol}}{{fiatCurrency}}',
517
+ send: 'Send {{fiatCurrency}} {{fiatCurrencySymbol}}',
518
518
  confirm: 'Confirm',
519
519
  cancel: 'Cancel',
520
520
  account: 'User {{exchange}}',
@@ -531,6 +531,9 @@ const translation = {
531
531
  description: 'Enter the code sent to you or generated by your authenticator app',
532
532
  button: 'Confirm',
533
533
  },
534
+ dyn_fund_from_exchange: {
535
+ title: 'Fund from Exchange',
536
+ },
534
537
  dyn_exchange_transfer_errors: {
535
538
  title: 'Unable to execute transfer.',
536
539
  mfa_failed: 'Incorrect security code. Please double-check your MFA code and try again.',
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var React = require('react');
7
7
  var utils = require('@dynamic-labs/utils');
8
- var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
+ var logger$1 = require('@dynamic-labs/logger');
9
9
  var ApiEndpoint = require('../../../config/ApiEndpoint.cjs');
10
10
  var logger = require('../../../shared/logger.cjs');
11
11
  var createStoreState = require('../../internalImplementation/utils/createStoreState/createStoreState.cjs');
@@ -46,8 +46,7 @@ const useSyncDynamicContextProps = ({ settings, emitErrors, enableInstrumentatio
46
46
  logger.logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
47
47
  }
48
48
  if (settings.logLevel) {
49
- logger.logger.setLogLevel(settings.logLevel);
50
- walletConnectorCore.logger.setLogLevel(settings.logLevel);
49
+ logger$1.Logger.setLogLevel(settings.logLevel);
51
50
  }
52
51
  const apiBaseUrl = utils.getEnvVarWithFallback('DYNAMIC_API_BASE_URL', settings.apiBaseUrl || '');
53
52
  ApiEndpoint.setBaseUrl(apiBaseUrl);
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { useEffect } from 'react';
3
3
  import { MissingEnvironmentIdError, getEnvVarWithFallback } from '@dynamic-labs/utils';
4
- import { logger as logger$1 } from '@dynamic-labs/wallet-connector-core';
4
+ import { Logger } from '@dynamic-labs/logger';
5
5
  import ApiEndpoint from '../../../config/ApiEndpoint.js';
6
6
  import { logger } from '../../../shared/logger.js';
7
7
  import { createStoreState } from '../../internalImplementation/utils/createStoreState/createStoreState.js';
@@ -42,8 +42,7 @@ const useSyncDynamicContextProps = ({ settings, emitErrors, enableInstrumentatio
42
42
  logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
43
43
  }
44
44
  if (settings.logLevel) {
45
- logger.setLogLevel(settings.logLevel);
46
- logger$1.setLogLevel(settings.logLevel);
45
+ Logger.setLogLevel(settings.logLevel);
47
46
  }
48
47
  const apiBaseUrl = getEnvVarWithFallback('DYNAMIC_API_BASE_URL', settings.apiBaseUrl || '');
49
48
  ApiEndpoint.setBaseUrl(apiBaseUrl);
@@ -79,4 +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';
82
83
  export { useSubmitExchangeFunding } from './useSubmitExchangeFunding';
@@ -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,4 @@
1
+ import { ExchangeKeyEnum } from '@dynamic-labs/sdk-api-core';
2
+ export declare const usePromptAmountAndFundWithExchange: () => ({ exchange }: {
3
+ exchange: ExchangeKeyEnum;
4
+ }) => Promise<void>;