@dynamic-labs/sdk-react-core 4.74.1 → 4.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +14 -14
- package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
- package/src/lib/components/SendBalanceForm/FeeTokenSelector/FeeTokenSelector.cjs +165 -0
- package/src/lib/components/SendBalanceForm/FeeTokenSelector/FeeTokenSelector.d.ts +11 -0
- package/src/lib/components/SendBalanceForm/FeeTokenSelector/FeeTokenSelector.js +161 -0
- package/src/lib/components/SendBalanceForm/FeeTokenSelector/index.d.ts +1 -0
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +5 -13
- package/src/lib/components/SendBalanceForm/SendBalanceForm.d.ts +1 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +5 -13
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +10 -13
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +10 -13
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.cjs +6 -7
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.js +6 -7
- package/src/lib/context/ErrorContext/hooks/useErrorText/useErrorText.cjs +1 -0
- package/src/lib/context/ErrorContext/hooks/useErrorText/useErrorText.js +1 -0
- package/src/lib/data/api/email/email.cjs +3 -0
- package/src/lib/data/api/email/email.js +4 -1
- package/src/lib/data/api/oauth/oauth.cjs +6 -0
- package/src/lib/data/api/oauth/oauth.js +7 -1
- package/src/lib/data/api/sms/sms.cjs +6 -0
- package/src/lib/data/api/sms/sms.js +7 -1
- package/src/lib/data/api/wallets/wallets.cjs +6 -0
- package/src/lib/data/api/wallets/wallets.js +7 -1
- package/src/lib/shared/utils/functions/chain/getChainIcon.cjs +1 -0
- package/src/lib/shared/utils/functions/chain/getChainIcon.js +2 -1
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +3 -0
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +3 -0
- package/src/lib/utils/hooks/useTransition/useTransition.cjs +14 -3
- package/src/lib/utils/hooks/useTransition/useTransition.js +14 -3
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +4 -0
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +5 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +6 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +7 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +8 -8
- package/src/lib/views/SendBalanceView/SendBalanceView.js +9 -9
- package/src/lib/views/WalletList/data.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +6 -7
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +6 -7
|
@@ -14,6 +14,11 @@ const useTransition = (_a) => {
|
|
|
14
14
|
const [stage, setStage] = useState(initialStage);
|
|
15
15
|
const [mount, setMount] = useState(!animateOnMount);
|
|
16
16
|
const [currentDuration, setCurrentDuration] = useState(duration);
|
|
17
|
+
// Track current stage in a ref so the transition effect doesn't need `stage`
|
|
18
|
+
// as a dependency. This prevents the effect's cleanup from cancelling an
|
|
19
|
+
// in-flight rAF every time stage changes (the race condition).
|
|
20
|
+
const stageRef = useRef(initialStage);
|
|
21
|
+
stageRef.current = stage;
|
|
17
22
|
const performTransition = (runTransition, transitionDelay) => {
|
|
18
23
|
if (transitionDelay) {
|
|
19
24
|
timeoutIdRef.current = animationFrameTimeout(runTransition, transitionDelay);
|
|
@@ -41,11 +46,14 @@ const useTransition = (_a) => {
|
|
|
41
46
|
}, animationDuration);
|
|
42
47
|
}, [duration, outDuration]);
|
|
43
48
|
useEffect(() => {
|
|
44
|
-
|
|
49
|
+
const currentStage = stageRef.current;
|
|
50
|
+
if (isShown && currentStage !== 'ENTERED' && currentStage !== 'ENTERING') {
|
|
45
51
|
const enterDelay = inDelay || delay;
|
|
46
52
|
performTransition(performEnter, enterDelay);
|
|
47
53
|
}
|
|
48
|
-
else if (!isShown &&
|
|
54
|
+
else if (!isShown &&
|
|
55
|
+
currentStage !== 'UNMOUNT' &&
|
|
56
|
+
currentStage !== 'EXITING') {
|
|
49
57
|
const exitDelay = outDelay || delay;
|
|
50
58
|
performTransition(performExit, exitDelay);
|
|
51
59
|
}
|
|
@@ -53,7 +61,10 @@ const useTransition = (_a) => {
|
|
|
53
61
|
clearAnimationFrameTimeout(animationFrameTimeoutIdRef.current);
|
|
54
62
|
clearAnimationFrameTimeout(timeoutIdRef.current);
|
|
55
63
|
};
|
|
56
|
-
|
|
64
|
+
// `stage` is intentionally excluded from deps — we read it via stageRef to
|
|
65
|
+
// prevent the cleanup from cancelling an in-flight rAF on every stage change.
|
|
66
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
+
}, [inDelay, outDelay, performEnter, performExit, isShown, delay]);
|
|
57
68
|
useTransitionEvents(stage, events);
|
|
58
69
|
return { currentDuration, mount, stage };
|
|
59
70
|
};
|
|
@@ -186,6 +186,10 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
186
186
|
(error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED') {
|
|
187
187
|
throw error;
|
|
188
188
|
}
|
|
189
|
+
if (error.code === utils.ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN) {
|
|
190
|
+
setError(error.message, error.code);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
189
193
|
if (onError) {
|
|
190
194
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
191
195
|
return;
|
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { MfaInvalidOtpError, MfaRateLimitedError, SandboxMaximumThresholdReachedError as SandboxMaximumThresholdReachedError$1 } from '@dynamic-labs-sdk/client';
|
|
5
5
|
import { WalletProviderEnum, EmbeddedWalletVersionEnum, MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';
|
|
6
|
-
import { EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, SandboxMaximumThresholdReachedError, UserHasAccountWithEmailError, DynamicError, sleep } from '@dynamic-labs/utils';
|
|
6
|
+
import { EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, SandboxMaximumThresholdReachedError, UserHasAccountWithEmailError, ErrorCode, DynamicError, sleep } from '@dynamic-labs/utils';
|
|
7
7
|
import '@dynamic-labs-sdk/client/core';
|
|
8
8
|
import '../../../client/client.js';
|
|
9
9
|
import '../../../config/ApiEndpoint.js';
|
|
@@ -182,6 +182,10 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
182
182
|
(error === null || error === void 0 ? void 0 : error.code) === 'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED') {
|
|
183
183
|
throw error;
|
|
184
184
|
}
|
|
185
|
+
if (error.code === ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN) {
|
|
186
|
+
setError(error.message, error.code);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
185
189
|
if (onError) {
|
|
186
190
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
187
191
|
return;
|
|
@@ -266,6 +266,12 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
266
266
|
pushView('account-exists');
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
|
+
if (e.code === utils.ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN) {
|
|
270
|
+
handleDisconnectWallet({ walletConnector });
|
|
271
|
+
clearStackAndPushInitialView();
|
|
272
|
+
setError(e.message, e.code);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
269
275
|
const authMode$1 = authMode.getAuthMode();
|
|
270
276
|
if (connectedWallets.length && authMode$1 === 'connect-only') {
|
|
271
277
|
throw new utils.DynamicError(e.message);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { DynamicError, StorageService, EmbeddedWalletExistsError, WalletUsedError, MergeAccountsConfirmationError, ChainalysisError, GateBlockedError, SandboxMaximumThresholdReachedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
3
|
+
import { DynamicError, StorageService, EmbeddedWalletExistsError, WalletUsedError, MergeAccountsConfirmationError, ChainalysisError, GateBlockedError, SandboxMaximumThresholdReachedError, NoAccessError, AccountExistsError, ErrorCode } from '@dynamic-labs/utils';
|
|
4
4
|
import { getWalletProvider, isSocialWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import 'react';
|
|
6
6
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
@@ -262,6 +262,12 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
262
262
|
pushView('account-exists');
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
|
+
if (e.code === ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN) {
|
|
266
|
+
handleDisconnectWallet({ walletConnector });
|
|
267
|
+
clearStackAndPushInitialView();
|
|
268
|
+
setError(e.message, e.code);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
265
271
|
const authMode = getAuthMode();
|
|
266
272
|
if (connectedWallets.length && authMode === 'connect-only') {
|
|
267
273
|
throw new DynamicError(e.message);
|
|
@@ -89,6 +89,7 @@ require('../../utils/hooks/useGetMfaToken/useGetMfaToken.cjs');
|
|
|
89
89
|
require('../../utils/hooks/useWalletBackup/useWalletBackup.cjs');
|
|
90
90
|
require('../../utils/hooks/useWalletBackup/types.cjs');
|
|
91
91
|
require('../../utils/hooks/useWalletBackup/cloudProviders.cjs');
|
|
92
|
+
var useStepUpAuthentication = require('../../utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs');
|
|
92
93
|
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
93
94
|
require('../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
94
95
|
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
@@ -114,9 +115,7 @@ require('../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds
|
|
|
114
115
|
var useNetworkDataFromWallet = require('../../utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.cjs');
|
|
115
116
|
var useTokenBalances = require('../../utils/hooks/useTokenBalances/useTokenBalances.cjs');
|
|
116
117
|
require('../../store/state/multichainBalances.cjs');
|
|
117
|
-
var usePromptMfaAuth = require('../../utils/hooks/usePromptMfaAuth/usePromptMfaAuth.cjs');
|
|
118
118
|
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
119
|
-
var useIsMfaRequiredForAction = require('../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.cjs');
|
|
120
119
|
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
121
120
|
|
|
122
121
|
const usingNative = (token) => Boolean(token.isNative);
|
|
@@ -148,8 +147,7 @@ const getSupportedChainName = (connectedChain) => {
|
|
|
148
147
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
149
148
|
const [stage, setStage] = React.useState('form');
|
|
150
149
|
const { primaryWallet, walletUiUtils } = useInternalDynamicContext.useInternalDynamicContext();
|
|
151
|
-
const
|
|
152
|
-
const promptMfaAuth = usePromptMfaAuth.usePromptMfaAuth();
|
|
150
|
+
const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication.useStepUpAuthentication();
|
|
153
151
|
const { t } = reactI18next.useTranslation();
|
|
154
152
|
const [isNativeToken, setIsNativeToken] = React.useState(false);
|
|
155
153
|
const [currentToken, setCurrentToken] = React.useState(undefined);
|
|
@@ -238,11 +236,13 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
238
236
|
: networkData.nativeCurrency.decimals, walletAddress: shortenWalletAddress.shortenWalletAddress(currentToken === null || currentToken === void 0 ? void 0 : currentToken.address), walletKey: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: () => setStage('confirmation'), tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, isNativeToken: isNativeToken }));
|
|
239
237
|
const buildTransactionStage = () => (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, transaction: transaction, mutation: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
240
238
|
if (primaryWallet.connector.key === 'dynamicwaas') {
|
|
241
|
-
const
|
|
242
|
-
|
|
239
|
+
const requiresStepUp = yield isStepUpRequired({
|
|
240
|
+
scope: sdkApiCore.TokenScope.Walletsign,
|
|
243
241
|
});
|
|
244
|
-
if (
|
|
245
|
-
yield
|
|
242
|
+
if (requiresStepUp) {
|
|
243
|
+
yield promptStepUpAuth({
|
|
244
|
+
requestedScopes: [sdkApiCore.TokenScope.Walletsign],
|
|
245
|
+
});
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
walletUiUtils.disabledConfirmationOnce();
|
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useState, useEffect } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { ChainEnum,
|
|
6
|
+
import { ChainEnum, TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
7
7
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
8
8
|
import { isSendBalanceWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
9
9
|
import { ChainIcon } from '../../components/ChainIcon/ChainIcon.js';
|
|
@@ -85,6 +85,7 @@ import '../../utils/hooks/useGetMfaToken/useGetMfaToken.js';
|
|
|
85
85
|
import '../../utils/hooks/useWalletBackup/useWalletBackup.js';
|
|
86
86
|
import '../../utils/hooks/useWalletBackup/types.js';
|
|
87
87
|
import '../../utils/hooks/useWalletBackup/cloudProviders.js';
|
|
88
|
+
import { useStepUpAuthentication } from '../../utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js';
|
|
88
89
|
import '../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
89
90
|
import '../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
90
91
|
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
@@ -110,9 +111,7 @@ import '../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.
|
|
|
110
111
|
import { useNetworkDataFromWallet } from '../../utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.js';
|
|
111
112
|
import { useTokenBalances } from '../../utils/hooks/useTokenBalances/useTokenBalances.js';
|
|
112
113
|
import '../../store/state/multichainBalances.js';
|
|
113
|
-
import { usePromptMfaAuth } from '../../utils/hooks/usePromptMfaAuth/usePromptMfaAuth.js';
|
|
114
114
|
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
115
|
-
import { useIsMfaRequiredForAction } from '../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.js';
|
|
116
115
|
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
117
116
|
|
|
118
117
|
const usingNative = (token) => Boolean(token.isNative);
|
|
@@ -144,8 +143,7 @@ const getSupportedChainName = (connectedChain) => {
|
|
|
144
143
|
const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
|
|
145
144
|
const [stage, setStage] = useState('form');
|
|
146
145
|
const { primaryWallet, walletUiUtils } = useInternalDynamicContext();
|
|
147
|
-
const
|
|
148
|
-
const promptMfaAuth = usePromptMfaAuth();
|
|
146
|
+
const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication();
|
|
149
147
|
const { t } = useTranslation();
|
|
150
148
|
const [isNativeToken, setIsNativeToken] = useState(false);
|
|
151
149
|
const [currentToken, setCurrentToken] = useState(undefined);
|
|
@@ -234,11 +232,13 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
234
232
|
: networkData.nativeCurrency.decimals, walletAddress: shortenWalletAddress(currentToken === null || currentToken === void 0 ? void 0 : currentToken.address), walletKey: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.key, onClickClose: onClickClose, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSubmit: () => setStage('confirmation'), tokenBalances: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : (currentToken && [currentToken]), currentToken: currentToken, setCurrentToken: setCurrentToken, isLoading: isLoading, isNativeToken: isNativeToken }));
|
|
235
233
|
const buildTransactionStage = () => (jsx(TransactionConfirmationView, { walletConnector: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector, transaction: transaction, mutation: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
236
234
|
if (primaryWallet.connector.key === 'dynamicwaas') {
|
|
237
|
-
const
|
|
238
|
-
|
|
235
|
+
const requiresStepUp = yield isStepUpRequired({
|
|
236
|
+
scope: TokenScope.Walletsign,
|
|
239
237
|
});
|
|
240
|
-
if (
|
|
241
|
-
yield
|
|
238
|
+
if (requiresStepUp) {
|
|
239
|
+
yield promptStepUpAuth({
|
|
240
|
+
requestedScopes: [TokenScope.Walletsign],
|
|
241
|
+
});
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
walletUiUtils.disabledConfirmationOnce();
|
|
@@ -4,7 +4,7 @@ interface IChain {
|
|
|
4
4
|
enabled: boolean;
|
|
5
5
|
name: string;
|
|
6
6
|
}
|
|
7
|
-
export declare const getEnabledChains: (chains: IChain[]) => ("ALEO" | "STARK" | "STELLAR" | "TEMPO" | "ALGO" | "APTOS" | "ATOM" | "BTC" | "COSMOS" | "ECLIPSE" | "ETH" | "EVM" | "FLOW" | "SOL" | "SPARK" | "SUI" | "TRON" | "TON")[];
|
|
7
|
+
export declare const getEnabledChains: (chains: IChain[]) => ("ALEO" | "STARK" | "STELLAR" | "TEMPO" | "ALGO" | "APTOS" | "ATOM" | "BTC" | "COSMOS" | "ECLIPSE" | "ETH" | "EVM" | "FLOW" | "MIDNIGHT" | "SOL" | "SPARK" | "SUI" | "TRON" | "TON")[];
|
|
8
8
|
type BaseGetSupportedWalletOpts = Omit<GetSupportedWalletsOpts, 'walletConnectProjectId' | 'chainRpcProviders'>;
|
|
9
9
|
export declare const getWallets: (props: {
|
|
10
10
|
getSupportedWalletOpts: BaseGetSupportedWalletOpts;
|
package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs
CHANGED
|
@@ -120,7 +120,7 @@ var TokenBalanceList = require('./TokenBalanceList/TokenBalanceList.cjs');
|
|
|
120
120
|
|
|
121
121
|
/** Component to display token balances for the primary wallet */
|
|
122
122
|
const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
123
|
-
var _a;
|
|
123
|
+
var _a, _b, _c;
|
|
124
124
|
const { t } = reactI18next.useTranslation();
|
|
125
125
|
/** Controls for the multi asset balance accordion */
|
|
126
126
|
const [balanceIsExpanded, setBalanceIsExpanded] = React.useState(false);
|
|
@@ -132,14 +132,13 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
132
132
|
const successTimeoutRef = React.useRef(null);
|
|
133
133
|
const refreshTimeoutRef = React.useRef(null);
|
|
134
134
|
const { primaryWallet, network, showFiat, multiAsset } = useInternalDynamicContext.useInternalDynamicContext();
|
|
135
|
-
|
|
136
|
-
const isTempo = (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain) === 'TEMPO';
|
|
135
|
+
const hasNativeToken = (_b = (_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _a === void 0 ? void 0 : _a.hasNativeToken) !== null && _b !== void 0 ? _b : true;
|
|
137
136
|
const authMode$1 = authMode.useAuthMode();
|
|
138
137
|
const projectSettings = useProjectSettings.useProjectSettings();
|
|
139
138
|
const { data: testnet } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () { return Boolean(yield (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.isTestnet())); }), { deps: [network], initialData: false });
|
|
140
139
|
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, fetchAccountBalances, } = useTokenBalances.useTokenBalances({
|
|
141
140
|
chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
|
|
142
|
-
includeFiat: showFiat ||
|
|
141
|
+
includeFiat: showFiat || !hasNativeToken,
|
|
143
142
|
includeNativeBalance: true,
|
|
144
143
|
});
|
|
145
144
|
const filteredTokenBalances = React.useMemo(() => (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [], [tokenBalances]);
|
|
@@ -152,7 +151,7 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
152
151
|
multiAsset;
|
|
153
152
|
}, [
|
|
154
153
|
authMode$1,
|
|
155
|
-
(
|
|
154
|
+
(_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _c === void 0 ? void 0 : _c.connectOnlyMultiAsset,
|
|
156
155
|
multiAsset,
|
|
157
156
|
]);
|
|
158
157
|
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
@@ -202,8 +201,8 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
202
201
|
if (!primaryWallet || isLoadingTokenBalances || isLoading) {
|
|
203
202
|
return jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-container__skeleton' });
|
|
204
203
|
}
|
|
205
|
-
//
|
|
206
|
-
if (
|
|
204
|
+
// Chain has no native token - show aggregated fiat token values
|
|
205
|
+
if (!hasNativeToken) {
|
|
207
206
|
return (jsxRuntime.jsx(Typography.Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
208
207
|
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
209
208
|
: '<$0.01' }));
|
|
@@ -116,7 +116,7 @@ import { TokenBalanceList } from './TokenBalanceList/TokenBalanceList.js';
|
|
|
116
116
|
|
|
117
117
|
/** Component to display token balances for the primary wallet */
|
|
118
118
|
const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
119
|
-
var _a;
|
|
119
|
+
var _a, _b, _c;
|
|
120
120
|
const { t } = useTranslation();
|
|
121
121
|
/** Controls for the multi asset balance accordion */
|
|
122
122
|
const [balanceIsExpanded, setBalanceIsExpanded] = useState(false);
|
|
@@ -128,14 +128,13 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
128
128
|
const successTimeoutRef = useRef(null);
|
|
129
129
|
const refreshTimeoutRef = useRef(null);
|
|
130
130
|
const { primaryWallet, network, showFiat, multiAsset } = useInternalDynamicContext();
|
|
131
|
-
|
|
132
|
-
const isTempo = (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain) === 'TEMPO';
|
|
131
|
+
const hasNativeToken = (_b = (_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _a === void 0 ? void 0 : _a.hasNativeToken) !== null && _b !== void 0 ? _b : true;
|
|
133
132
|
const authMode = useAuthMode();
|
|
134
133
|
const projectSettings = useProjectSettings();
|
|
135
134
|
const { data: testnet } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () { return Boolean(yield (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.isTestnet())); }), { deps: [network], initialData: false });
|
|
136
135
|
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, fetchAccountBalances, } = useTokenBalances({
|
|
137
136
|
chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
|
|
138
|
-
includeFiat: showFiat ||
|
|
137
|
+
includeFiat: showFiat || !hasNativeToken,
|
|
139
138
|
includeNativeBalance: true,
|
|
140
139
|
});
|
|
141
140
|
const filteredTokenBalances = useMemo(() => (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [], [tokenBalances]);
|
|
@@ -148,7 +147,7 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
148
147
|
multiAsset;
|
|
149
148
|
}, [
|
|
150
149
|
authMode,
|
|
151
|
-
(
|
|
150
|
+
(_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _c === void 0 ? void 0 : _c.connectOnlyMultiAsset,
|
|
152
151
|
multiAsset,
|
|
153
152
|
]);
|
|
154
153
|
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
@@ -198,8 +197,8 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
198
197
|
if (!primaryWallet || isLoadingTokenBalances || isLoading) {
|
|
199
198
|
return jsx(Skeleton, { className: 'balance-container__skeleton' });
|
|
200
199
|
}
|
|
201
|
-
//
|
|
202
|
-
if (
|
|
200
|
+
// Chain has no native token - show aggregated fiat token values
|
|
201
|
+
if (!hasNativeToken) {
|
|
203
202
|
return (jsx(Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
204
203
|
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
205
204
|
: '<$0.01' }));
|