@dynamic-labs/sdk-react-core 4.70.0 → 4.71.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 +13 -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/client/extension/hooks/useInitializeSdkClient/syncEvents/syncEvents.cjs +12 -0
- package/src/lib/client/extension/hooks/useInitializeSdkClient/syncEvents/syncEvents.js +12 -0
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +15 -2
- package/src/lib/components/SendBalanceForm/SendBalanceForm.d.ts +4 -0
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +15 -2
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +25 -3
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +26 -4
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.cjs +4 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.js +4 -1
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.cjs +9 -5
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.js +9 -5
- package/src/lib/events/deviceRegistration.d.ts +4 -0
- package/src/lib/events/dynamicEvents.cjs +2 -0
- package/src/lib/events/dynamicEvents.d.ts +3 -2
- package/src/lib/events/dynamicEvents.js +2 -0
- 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/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +2 -2
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +26 -34
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.d.ts +5 -2
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +27 -35
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +7 -2
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +2 -1
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +7 -2
- package/src/lib/views/WalletList/data.cjs +1 -0
- package/src/lib/views/WalletList/data.d.ts +1 -1
- package/src/lib/views/WalletList/data.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +9 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +9 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.cjs +2 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.js +2 -1
- package/src/lib/widgets/DynamicWidget/helpers/helpers.cjs +22 -0
- package/src/lib/widgets/DynamicWidget/helpers/helpers.js +22 -0
- package/src/lib/data/api/externalAuth/externalAuth.cjs +0 -66
- package/src/lib/data/api/externalAuth/externalAuth.js +0 -62
|
@@ -2,7 +2,7 @@ import { DynamicEvents } from '../../../../events';
|
|
|
2
2
|
import { EventArgs } from '../types';
|
|
3
3
|
type DynamicEventListener<E extends keyof DynamicEvents> = (...args: EventArgs<DynamicEvents, E>) => void;
|
|
4
4
|
/** Allows us to subscribe to all dynamicEvents with a hook, even the internal ones */
|
|
5
|
-
export declare const useInternalDynamicEvents: <E extends keyof import("../../../../events/auth").AuthEvents | keyof import("../../../../events/ui").UIEvents | keyof import("../../../../events/otp").OTPEvents | keyof import("../../../../events/wallets").WalletEvents | keyof import("../../../../events/passkey").PasskeyEvents | "farcasterConnectCancelled" | keyof import("../../../../events/embeddedWallet").EmbeddedWalletEvents | keyof import("../../../../events/multiWallet").MultiWalletInternalEvents | "tokenBalancesChanged" | "userProfileUpdated" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
5
|
+
export declare const useInternalDynamicEvents: <E extends keyof import("../../../../events/auth").AuthEvents | keyof import("../../../../events/deviceRegistration").DeviceRegistrationEvents | keyof import("../../../../events/ui").UIEvents | keyof import("../../../../events/otp").OTPEvents | keyof import("../../../../events/wallets").WalletEvents | keyof import("../../../../events/passkey").PasskeyEvents | "farcasterConnectCancelled" | keyof import("../../../../events/embeddedWallet").EmbeddedWalletEvents | keyof import("../../../../events/multiWallet").MultiWalletInternalEvents | "tokenBalancesChanged" | "userProfileUpdated" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
6
6
|
/** Allows subscribing to dynamic events directly inside components with a hook */
|
|
7
|
-
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "walletConnectionFailed" | "walletConnectionQrCodeReady" | "walletReturnFromDeepLink" | "embeddedWalletCreated" | "embeddedWalletRevealCompleted" | "embeddedWalletRevealFailed" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
7
|
+
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "deviceRegistrationCompleted" | "deviceRegistrationCompletedInAnotherTab" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "walletConnectionFailed" | "walletConnectionQrCodeReady" | "walletReturnFromDeepLink" | "embeddedWalletCreated" | "embeddedWalletRevealCompleted" | "embeddedWalletRevealFailed" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
8
8
|
export {};
|
|
@@ -7,36 +7,35 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var client = require('@dynamic-labs-sdk/client');
|
|
9
9
|
var getClientSessionKeys = require('../../functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
10
|
-
require('
|
|
11
|
-
require('
|
|
12
|
-
require('@dynamic-labs-sdk/client/core');
|
|
13
|
-
require('../../../client/client.cjs');
|
|
14
|
-
require('../../../config/ApiEndpoint.cjs');
|
|
10
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
11
|
+
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
15
12
|
require('@dynamic-labs/iconic');
|
|
16
13
|
require('@dynamic-labs/wallet-connector-core');
|
|
17
14
|
require('react/jsx-runtime');
|
|
18
15
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
19
16
|
require('../../../shared/logger.cjs');
|
|
20
17
|
require('@dynamic-labs/wallet-book');
|
|
18
|
+
require('@dynamic-labs/utils');
|
|
21
19
|
require('../../constants/colors.cjs');
|
|
22
20
|
require('../../constants/values.cjs');
|
|
21
|
+
require('@dynamic-labs/sdk-api-core');
|
|
23
22
|
var hasPendingRequirements = require('../../../shared/utils/functions/hasPendingRequirements/hasPendingRequirements.cjs');
|
|
24
23
|
require('../../../shared/consts/index.cjs');
|
|
24
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
25
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
26
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
27
|
require('@dynamic-labs/multi-wallet');
|
|
26
28
|
require('react-international-phone');
|
|
27
29
|
require('../../../store/state/nonce/nonce.cjs');
|
|
30
|
+
require('@dynamic-labs-sdk/client/core');
|
|
31
|
+
require('../../../client/client.cjs');
|
|
32
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
33
|
+
var convertSdkUserToUserProfile = require('../../../client/extension/user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.cjs');
|
|
34
|
+
require('@dynamic-labs/locale');
|
|
28
35
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
29
36
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
30
37
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
31
38
|
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
32
|
-
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
33
|
-
var convertSdkUserToUserProfile = require('../../../client/extension/user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.cjs');
|
|
34
|
-
var externalAuth = require('../../../data/api/externalAuth/externalAuth.cjs');
|
|
35
|
-
require('@dynamic-labs/locale');
|
|
36
|
-
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
37
|
-
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
38
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
39
|
-
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
40
39
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
41
40
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
42
41
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -162,28 +161,21 @@ const useExternalAuth = () => {
|
|
|
162
161
|
shouldRegisterSessionKeysOnSignin,
|
|
163
162
|
]);
|
|
164
163
|
/**
|
|
165
|
-
*
|
|
164
|
+
* Requests an elevated access token using an external auth assertion JWT.
|
|
165
|
+
*
|
|
166
|
+
* The assertion JWT must be signed by the customer's backend using the same key
|
|
167
|
+
* registered in the environment's external auth JWKS URL. It must include
|
|
168
|
+
* `sub`, `scope`, `jti`, and `exp` claims.
|
|
169
|
+
*
|
|
170
|
+
* @param {string} props.externalJwt - Assertion JWT signed by the customer's backend
|
|
171
|
+
*
|
|
172
|
+
* @returns The assertion response containing the elevated access token
|
|
166
173
|
*/
|
|
167
|
-
const verifyWithExternalJwt = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
setCallback('authSuccess');
|
|
174
|
-
setShowAuthFlow(false);
|
|
175
|
-
return userProfile;
|
|
176
|
-
}
|
|
177
|
-
catch (e) {
|
|
178
|
-
dynamicEvents.dynamicEvents.emit('authFailure', {
|
|
179
|
-
externalUserId,
|
|
180
|
-
option: externalUserId,
|
|
181
|
-
type: 'externalAuth',
|
|
182
|
-
}, { error: e });
|
|
183
|
-
throw e;
|
|
184
|
-
}
|
|
185
|
-
}), [environmentId, setCallback, setShowAuthFlow]);
|
|
186
|
-
return React.useMemo(() => ({ signInWithExternalJwt, verifyWithExternalJwt }), [signInWithExternalJwt, verifyWithExternalJwt]);
|
|
174
|
+
const verifyWithExternalJwt = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ externalJwt, }) { return client.requestExternalAuthElevatedToken({ externalJwt }); }), []);
|
|
175
|
+
return React.useMemo(() => ({
|
|
176
|
+
signInWithExternalJwt,
|
|
177
|
+
verifyWithExternalJwt,
|
|
178
|
+
}), [signInWithExternalJwt, verifyWithExternalJwt]);
|
|
187
179
|
};
|
|
188
180
|
|
|
189
181
|
exports.useExternalAuth = useExternalAuth;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { ExternalAuthAssertionResponse } from '@dynamic-labs/sdk-api-core';
|
|
1
2
|
import { UserProfile } from '../../../..';
|
|
2
3
|
type Props = {
|
|
3
4
|
externalUserId: string;
|
|
4
5
|
externalJwt?: string;
|
|
5
6
|
};
|
|
6
7
|
export declare const useExternalAuth: () => {
|
|
7
|
-
signInWithExternalJwt: (
|
|
8
|
-
verifyWithExternalJwt: (
|
|
8
|
+
signInWithExternalJwt: (props: Props) => Promise<UserProfile | undefined>;
|
|
9
|
+
verifyWithExternalJwt: (props: {
|
|
10
|
+
externalJwt: string;
|
|
11
|
+
}) => Promise<ExternalAuthAssertionResponse>;
|
|
9
12
|
};
|
|
10
13
|
export {};
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback, useMemo } from 'react';
|
|
4
|
-
import { signInWithExternalJwt } from '@dynamic-labs-sdk/client';
|
|
4
|
+
import { signInWithExternalJwt, requestExternalAuthElevatedToken } from '@dynamic-labs-sdk/client';
|
|
5
5
|
import { generateClientSessionKeys } from '../../functions/clientSessionKeys/getClientSessionKeys.js';
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import '@dynamic-labs-sdk/client/core';
|
|
9
|
-
import '../../../client/client.js';
|
|
10
|
-
import '../../../config/ApiEndpoint.js';
|
|
6
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
|
+
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
11
8
|
import '@dynamic-labs/iconic';
|
|
12
9
|
import '@dynamic-labs/wallet-connector-core';
|
|
13
10
|
import 'react/jsx-runtime';
|
|
14
11
|
import '../../../context/ViewContext/ViewContext.js';
|
|
15
12
|
import '../../../shared/logger.js';
|
|
16
13
|
import '@dynamic-labs/wallet-book';
|
|
14
|
+
import '@dynamic-labs/utils';
|
|
17
15
|
import '../../constants/colors.js';
|
|
18
16
|
import '../../constants/values.js';
|
|
17
|
+
import '@dynamic-labs/sdk-api-core';
|
|
19
18
|
import { hasPendingRequirements } from '../../../shared/utils/functions/hasPendingRequirements/hasPendingRequirements.js';
|
|
20
19
|
import '../../../shared/consts/index.js';
|
|
20
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
21
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
22
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
21
23
|
import '@dynamic-labs/multi-wallet';
|
|
22
24
|
import 'react-international-phone';
|
|
23
25
|
import '../../../store/state/nonce/nonce.js';
|
|
26
|
+
import '@dynamic-labs-sdk/client/core';
|
|
27
|
+
import '../../../client/client.js';
|
|
28
|
+
import '../../../config/ApiEndpoint.js';
|
|
29
|
+
import { convertSdkUserToUserProfile } from '../../../client/extension/user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.js';
|
|
30
|
+
import '@dynamic-labs/locale';
|
|
24
31
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
25
32
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
26
33
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
27
34
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
28
|
-
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
29
|
-
import { convertSdkUserToUserProfile } from '../../../client/extension/user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.js';
|
|
30
|
-
import { externalAuthVerify } from '../../../data/api/externalAuth/externalAuth.js';
|
|
31
|
-
import '@dynamic-labs/locale';
|
|
32
|
-
import '../../../context/DynamicContext/DynamicContext.js';
|
|
33
|
-
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
34
|
-
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
35
|
-
import '../../../context/ErrorContext/ErrorContext.js';
|
|
36
35
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
37
36
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
38
37
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -158,28 +157,21 @@ const useExternalAuth = () => {
|
|
|
158
157
|
shouldRegisterSessionKeysOnSignin,
|
|
159
158
|
]);
|
|
160
159
|
/**
|
|
161
|
-
*
|
|
160
|
+
* Requests an elevated access token using an external auth assertion JWT.
|
|
161
|
+
*
|
|
162
|
+
* The assertion JWT must be signed by the customer's backend using the same key
|
|
163
|
+
* registered in the environment's external auth JWKS URL. It must include
|
|
164
|
+
* `sub`, `scope`, `jti`, and `exp` claims.
|
|
165
|
+
*
|
|
166
|
+
* @param {string} props.externalJwt - Assertion JWT signed by the customer's backend
|
|
167
|
+
*
|
|
168
|
+
* @returns The assertion response containing the elevated access token
|
|
162
169
|
*/
|
|
163
|
-
const verifyWithExternalJwt = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
setCallback('authSuccess');
|
|
170
|
-
setShowAuthFlow(false);
|
|
171
|
-
return userProfile;
|
|
172
|
-
}
|
|
173
|
-
catch (e) {
|
|
174
|
-
dynamicEvents.emit('authFailure', {
|
|
175
|
-
externalUserId,
|
|
176
|
-
option: externalUserId,
|
|
177
|
-
type: 'externalAuth',
|
|
178
|
-
}, { error: e });
|
|
179
|
-
throw e;
|
|
180
|
-
}
|
|
181
|
-
}), [environmentId, setCallback, setShowAuthFlow]);
|
|
182
|
-
return useMemo(() => ({ signInWithExternalJwt: signInWithExternalJwt$1, verifyWithExternalJwt }), [signInWithExternalJwt$1, verifyWithExternalJwt]);
|
|
170
|
+
const verifyWithExternalJwt = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ externalJwt, }) { return requestExternalAuthElevatedToken({ externalJwt }); }), []);
|
|
171
|
+
return useMemo(() => ({
|
|
172
|
+
signInWithExternalJwt: signInWithExternalJwt$1,
|
|
173
|
+
verifyWithExternalJwt,
|
|
174
|
+
}), [signInWithExternalJwt$1, verifyWithExternalJwt]);
|
|
183
175
|
};
|
|
184
176
|
|
|
185
177
|
export { useExternalAuth };
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
|
|
8
|
-
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }) => React.useMemo(() => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
8
|
+
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }) => React.useMemo(() => {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
10
10
|
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
11
11
|
if (!networks)
|
|
12
12
|
return {};
|
|
@@ -22,6 +22,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
22
22
|
const ton = networks.find((configurations) => configurations.chainName === 'ton');
|
|
23
23
|
const bitcoin = networks.find((configurations) => configurations.chainName === 'bitcoin');
|
|
24
24
|
const aleo = networks.find((configurations) => configurations.chainName === 'aleo');
|
|
25
|
+
const tempo = networks.find((configurations) => configurations.chainName === 'tempo');
|
|
25
26
|
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, Number.parseInt));
|
|
26
27
|
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
27
28
|
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, Number.parseInt));
|
|
@@ -51,6 +52,8 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
51
52
|
bitcoinNetworks = overrideNetworks(bitcoinNetworksOverrides, bitcoinNetworks);
|
|
52
53
|
let aleoNetworks = (_m = aleo === null || aleo === void 0 ? void 0 : aleo.networks) === null || _m === void 0 ? void 0 : _m.map((net) => createNetwork(net));
|
|
53
54
|
aleoNetworks = overrideNetworks(aleoNetworksOverrides, aleoNetworks);
|
|
55
|
+
let tempoNetworks = (_o = tempo === null || tempo === void 0 ? void 0 : tempo.networks) === null || _o === void 0 ? void 0 : _o.map((net) => createNetwork(net, Number.parseInt));
|
|
56
|
+
tempoNetworks = overrideNetworks(tempoNetworksOverrides, tempoNetworks);
|
|
54
57
|
const networkConfigurations = {
|
|
55
58
|
aleo: aleoNetworks,
|
|
56
59
|
aptos: aptosNetworks,
|
|
@@ -62,6 +65,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
62
65
|
starknet: starknetNetworks,
|
|
63
66
|
stellar: stellarNetworks,
|
|
64
67
|
sui: suiNetworks,
|
|
68
|
+
tempo: tempoNetworks,
|
|
65
69
|
ton: tonNetworks,
|
|
66
70
|
tron: tronNetworks,
|
|
67
71
|
};
|
|
@@ -74,6 +78,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
74
78
|
solanaNetworksOverrides,
|
|
75
79
|
tronNetworksOverrides,
|
|
76
80
|
aptosNetworksOverrides,
|
|
81
|
+
tempoNetworksOverrides,
|
|
77
82
|
tonNetworksOverrides,
|
|
78
83
|
stellarNetworksOverrides,
|
|
79
84
|
bitcoinNetworksOverrides,
|
|
@@ -9,8 +9,9 @@ type UseNetworkConfigurationsFromProjectSettingsProps = {
|
|
|
9
9
|
tronNetworksOverrides?: NetworksOverrides;
|
|
10
10
|
aptosNetworksOverrides?: NetworksOverrides;
|
|
11
11
|
stellarNetworksOverrides?: NetworksOverrides;
|
|
12
|
+
tempoNetworksOverrides?: NetworksOverrides;
|
|
12
13
|
tonNetworksOverrides?: NetworksOverrides;
|
|
13
14
|
bitcoinNetworksOverrides?: NetworksOverrides;
|
|
14
15
|
};
|
|
15
|
-
export declare const useNetworkConfigurationsFromProjectSettings: ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }: UseNetworkConfigurationsFromProjectSettingsProps) => {};
|
|
16
|
+
export declare const useNetworkConfigurationsFromProjectSettings: ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }: UseNetworkConfigurationsFromProjectSettingsProps) => {};
|
|
16
17
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
|
|
4
|
-
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }) => useMemo(() => {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4
|
+
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }) => useMemo(() => {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
6
6
|
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
7
7
|
if (!networks)
|
|
8
8
|
return {};
|
|
@@ -18,6 +18,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
18
18
|
const ton = networks.find((configurations) => configurations.chainName === 'ton');
|
|
19
19
|
const bitcoin = networks.find((configurations) => configurations.chainName === 'bitcoin');
|
|
20
20
|
const aleo = networks.find((configurations) => configurations.chainName === 'aleo');
|
|
21
|
+
const tempo = networks.find((configurations) => configurations.chainName === 'tempo');
|
|
21
22
|
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, Number.parseInt));
|
|
22
23
|
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
23
24
|
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, Number.parseInt));
|
|
@@ -47,6 +48,8 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
47
48
|
bitcoinNetworks = overrideNetworks(bitcoinNetworksOverrides, bitcoinNetworks);
|
|
48
49
|
let aleoNetworks = (_m = aleo === null || aleo === void 0 ? void 0 : aleo.networks) === null || _m === void 0 ? void 0 : _m.map((net) => createNetwork(net));
|
|
49
50
|
aleoNetworks = overrideNetworks(aleoNetworksOverrides, aleoNetworks);
|
|
51
|
+
let tempoNetworks = (_o = tempo === null || tempo === void 0 ? void 0 : tempo.networks) === null || _o === void 0 ? void 0 : _o.map((net) => createNetwork(net, Number.parseInt));
|
|
52
|
+
tempoNetworks = overrideNetworks(tempoNetworksOverrides, tempoNetworks);
|
|
50
53
|
const networkConfigurations = {
|
|
51
54
|
aleo: aleoNetworks,
|
|
52
55
|
aptos: aptosNetworks,
|
|
@@ -58,6 +61,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
58
61
|
starknet: starknetNetworks,
|
|
59
62
|
stellar: stellarNetworks,
|
|
60
63
|
sui: suiNetworks,
|
|
64
|
+
tempo: tempoNetworks,
|
|
61
65
|
ton: tonNetworks,
|
|
62
66
|
tron: tronNetworks,
|
|
63
67
|
};
|
|
@@ -70,6 +74,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
|
|
|
70
74
|
solanaNetworksOverrides,
|
|
71
75
|
tronNetworksOverrides,
|
|
72
76
|
aptosNetworksOverrides,
|
|
77
|
+
tempoNetworksOverrides,
|
|
73
78
|
tonNetworksOverrides,
|
|
74
79
|
stellarNetworksOverrides,
|
|
75
80
|
bitcoinNetworksOverrides,
|
|
@@ -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" | "ALGO" | "APTOS" | "ATOM" | "BTC" | "COSMOS" | "ECLIPSE" | "ETH" | "EVM" | "FLOW" | "SOL" | "SPARK" | "SUI" | "
|
|
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")[];
|
|
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
|
@@ -132,12 +132,14 @@ 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
|
+
// Tempo has no native token, so always need fiat values to show aggregated token balance
|
|
136
|
+
const isTempo = (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain) === 'TEMPO';
|
|
135
137
|
const authMode$1 = authMode.useAuthMode();
|
|
136
138
|
const projectSettings = useProjectSettings.useProjectSettings();
|
|
137
139
|
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 });
|
|
138
140
|
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, fetchAccountBalances, } = useTokenBalances.useTokenBalances({
|
|
139
141
|
chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
|
|
140
|
-
includeFiat: showFiat,
|
|
142
|
+
includeFiat: showFiat || isTempo,
|
|
141
143
|
includeNativeBalance: true,
|
|
142
144
|
});
|
|
143
145
|
const filteredTokenBalances = React.useMemo(() => (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [], [tokenBalances]);
|
|
@@ -200,6 +202,12 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
200
202
|
if (!primaryWallet || isLoadingTokenBalances || isLoading) {
|
|
201
203
|
return jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-container__skeleton' });
|
|
202
204
|
}
|
|
205
|
+
// Tempo has no native token - always show aggregated token values
|
|
206
|
+
if (isTempo) {
|
|
207
|
+
return (jsxRuntime.jsx(Typography.Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
208
|
+
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
209
|
+
: '<$0.01' }));
|
|
210
|
+
}
|
|
203
211
|
return canShowFiat ? (jsxRuntime.jsx(Typography.Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
204
212
|
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
205
213
|
: '<$0.01' })) : (jsxRuntime.jsx(Balance.Balance, { className: 'balance-header__balance', wallet: primaryWallet, network: network, variant: 'numbers_display' }));
|
|
@@ -128,12 +128,14 @@ 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
|
+
// Tempo has no native token, so always need fiat values to show aggregated token balance
|
|
132
|
+
const isTempo = (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain) === 'TEMPO';
|
|
131
133
|
const authMode = useAuthMode();
|
|
132
134
|
const projectSettings = useProjectSettings();
|
|
133
135
|
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 });
|
|
134
136
|
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, fetchAccountBalances, } = useTokenBalances({
|
|
135
137
|
chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
|
|
136
|
-
includeFiat: showFiat,
|
|
138
|
+
includeFiat: showFiat || isTempo,
|
|
137
139
|
includeNativeBalance: true,
|
|
138
140
|
});
|
|
139
141
|
const filteredTokenBalances = useMemo(() => (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [], [tokenBalances]);
|
|
@@ -196,6 +198,12 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
|
|
|
196
198
|
if (!primaryWallet || isLoadingTokenBalances || isLoading) {
|
|
197
199
|
return jsx(Skeleton, { className: 'balance-container__skeleton' });
|
|
198
200
|
}
|
|
201
|
+
// Tempo has no native token - always show aggregated token values
|
|
202
|
+
if (isTempo) {
|
|
203
|
+
return (jsx(Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
204
|
+
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
205
|
+
: '<$0.01' }));
|
|
206
|
+
}
|
|
199
207
|
return canShowFiat ? (jsx(Typography, { variant: 'numbers_display', color: 'primary', children: totalValue === 0 || totalValue >= 0.01
|
|
200
208
|
? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
|
|
201
209
|
: '<$0.01' })) : (jsx(Balance, { className: 'balance-header__balance', wallet: primaryWallet, network: network, variant: 'numbers_display' }));
|
|
@@ -71,6 +71,7 @@ require('../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCard
|
|
|
71
71
|
require('../../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
72
72
|
require('../../DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
73
73
|
require('react-focus-lock');
|
|
74
|
+
var helpers = require('../../../helpers/helpers.cjs');
|
|
74
75
|
require('../../../context/DynamicWidgetContext.cjs');
|
|
75
76
|
require('../../../../../components/IconButton/IconButton.cjs');
|
|
76
77
|
require('../../../../../utils/hooks/useGetMfaToken/useGetMfaToken.cjs');
|
|
@@ -126,7 +127,7 @@ const TokenBalanceItem = ({ tokenBalance, }) => {
|
|
|
126
127
|
? currencyFormatter.format(parseFloat((_a = tokenBalance.marketValue) === null || _a === void 0 ? void 0 : _a.toFixed(2)))
|
|
127
128
|
: '<$0.01';
|
|
128
129
|
};
|
|
129
|
-
return (jsxRuntime.jsxs("div", { className: 'token-balance-item', children: [jsxRuntime.jsxs("div", { className: 'token-balance-item__name', children: [tokenBalance.logoURI ? (jsxRuntime.jsx(Image.Image, { src: tokenBalance.logoURI, alt: tokenBalance.symbol, className: 'token-balance-item__icon', dataTestId: 'token-balance-item-icon' })) : (jsxRuntime.jsx("div", { className: 'token-balance-item__skeleton-icon', "data-testid": 'token-balance-item__skeleton-icon' })), jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', className: 'token-balance-item__title', color: 'primary', children: tokenBalance.name }) })] }), jsxRuntime.jsxs("div", { className: 'flex', children: [showFiat ? (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', color: 'primary', style: { textAlign: 'right' }, children: formattedFiatValue() })) : null, jsxRuntime.jsx("div", { className: 'token-balance-item__value', children: jsxRuntime.jsxs("div", { className: 'token-balance-item__value__balance', "data-testid": 'token-balance-item-balance', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', style: { marginRight: '2px' }, children: tokenBalance.balance }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'token-balance-item__symbol', children: tokenBalance.symbol })] }) })] })] }, tokenBalance.address));
|
|
130
|
+
return (jsxRuntime.jsxs("div", { className: 'token-balance-item', children: [jsxRuntime.jsxs("div", { className: 'token-balance-item__name', children: [tokenBalance.logoURI ? (jsxRuntime.jsx(Image.Image, { src: tokenBalance.logoURI, alt: tokenBalance.symbol, className: 'token-balance-item__icon', dataTestId: 'token-balance-item-icon' })) : (jsxRuntime.jsx("div", { className: 'token-balance-item__skeleton-icon', "data-testid": 'token-balance-item__skeleton-icon' })), jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', className: 'token-balance-item__title', color: 'primary', children: tokenBalance.name }) })] }), jsxRuntime.jsxs("div", { className: 'flex', children: [showFiat ? (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', color: 'primary', style: { textAlign: 'right' }, children: formattedFiatValue() })) : null, jsxRuntime.jsx("div", { className: 'token-balance-item__value', children: jsxRuntime.jsxs("div", { className: 'token-balance-item__value__balance', "data-testid": 'token-balance-item-balance', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', style: { marginRight: '2px' }, children: helpers.roundBalance(String(tokenBalance.balance)) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'token-balance-item__symbol', children: tokenBalance.symbol })] }) })] })] }, tokenBalance.address));
|
|
130
131
|
};
|
|
131
132
|
|
|
132
133
|
exports.TokenBalanceItem = TokenBalanceItem;
|
|
@@ -67,6 +67,7 @@ import '../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardT
|
|
|
67
67
|
import '../../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
68
68
|
import '../../DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
69
69
|
import 'react-focus-lock';
|
|
70
|
+
import { roundBalance } from '../../../helpers/helpers.js';
|
|
70
71
|
import '../../../context/DynamicWidgetContext.js';
|
|
71
72
|
import '../../../../../components/IconButton/IconButton.js';
|
|
72
73
|
import '../../../../../utils/hooks/useGetMfaToken/useGetMfaToken.js';
|
|
@@ -122,7 +123,7 @@ const TokenBalanceItem = ({ tokenBalance, }) => {
|
|
|
122
123
|
? currencyFormatter.format(parseFloat((_a = tokenBalance.marketValue) === null || _a === void 0 ? void 0 : _a.toFixed(2)))
|
|
123
124
|
: '<$0.01';
|
|
124
125
|
};
|
|
125
|
-
return (jsxs("div", { className: 'token-balance-item', children: [jsxs("div", { className: 'token-balance-item__name', children: [tokenBalance.logoURI ? (jsx(Image, { src: tokenBalance.logoURI, alt: tokenBalance.symbol, className: 'token-balance-item__icon', dataTestId: 'token-balance-item-icon' })) : (jsx("div", { className: 'token-balance-item__skeleton-icon', "data-testid": 'token-balance-item__skeleton-icon' })), jsx("div", { children: jsx(Typography, { variant: 'body_small', className: 'token-balance-item__title', color: 'primary', children: tokenBalance.name }) })] }), jsxs("div", { className: 'flex', children: [showFiat ? (jsx(Typography, { variant: 'body_small', weight: 'bold', color: 'primary', style: { textAlign: 'right' }, children: formattedFiatValue() })) : null, jsx("div", { className: 'token-balance-item__value', children: jsxs("div", { className: 'token-balance-item__value__balance', "data-testid": 'token-balance-item-balance', children: [jsx(Typography, { variant: 'body_small', color: 'secondary', style: { marginRight: '2px' }, children: tokenBalance.balance }), jsx(Typography, { variant: 'body_small', color: 'secondary', className: 'token-balance-item__symbol', children: tokenBalance.symbol })] }) })] })] }, tokenBalance.address));
|
|
126
|
+
return (jsxs("div", { className: 'token-balance-item', children: [jsxs("div", { className: 'token-balance-item__name', children: [tokenBalance.logoURI ? (jsx(Image, { src: tokenBalance.logoURI, alt: tokenBalance.symbol, className: 'token-balance-item__icon', dataTestId: 'token-balance-item-icon' })) : (jsx("div", { className: 'token-balance-item__skeleton-icon', "data-testid": 'token-balance-item__skeleton-icon' })), jsx("div", { children: jsx(Typography, { variant: 'body_small', className: 'token-balance-item__title', color: 'primary', children: tokenBalance.name }) })] }), jsxs("div", { className: 'flex', children: [showFiat ? (jsx(Typography, { variant: 'body_small', weight: 'bold', color: 'primary', style: { textAlign: 'right' }, children: formattedFiatValue() })) : null, jsx("div", { className: 'token-balance-item__value', children: jsxs("div", { className: 'token-balance-item__value__balance', "data-testid": 'token-balance-item-balance', children: [jsx(Typography, { variant: 'body_small', color: 'secondary', style: { marginRight: '2px' }, children: roundBalance(String(tokenBalance.balance)) }), jsx(Typography, { variant: 'body_small', color: 'secondary', className: 'token-balance-item__symbol', children: tokenBalance.symbol })] }) })] })] }, tokenBalance.address));
|
|
126
127
|
};
|
|
127
128
|
|
|
128
129
|
export { TokenBalanceItem };
|
|
@@ -32,6 +32,28 @@ const MAX_BALANCE_VALUE = 1000000;
|
|
|
32
32
|
const PRECISION_FLOOR_DIVIDER = 10000;
|
|
33
33
|
const roundBalance = (balanceString, decimals = 4) => {
|
|
34
34
|
const clearedBalance = parseFloat(replaceAll(balanceString, '"', ''));
|
|
35
|
+
// Guard against NaN (e.g., when balance is undefined/null)
|
|
36
|
+
if (Number.isNaN(clearedBalance)) {
|
|
37
|
+
return '0';
|
|
38
|
+
}
|
|
39
|
+
// Handle extremely large numbers (e.g., scientific notation like 1e+24)
|
|
40
|
+
// These are likely data errors or testnet faucet amounts
|
|
41
|
+
if (clearedBalance >= 1e15) {
|
|
42
|
+
// For numbers >= 1 quadrillion, show in trillions
|
|
43
|
+
const trillions = clearedBalance / 1e12;
|
|
44
|
+
if (trillions >= 1000) {
|
|
45
|
+
return `${(trillions / 1000).toFixed(2)}Q`; // Quadrillions
|
|
46
|
+
}
|
|
47
|
+
return `${trillions.toFixed(2)}T`; // Trillions
|
|
48
|
+
}
|
|
49
|
+
if (clearedBalance >= 1e12) {
|
|
50
|
+
// Trillions
|
|
51
|
+
return `${(clearedBalance / 1e12).toFixed(2)}T`;
|
|
52
|
+
}
|
|
53
|
+
if (clearedBalance >= 1e9) {
|
|
54
|
+
// Billions
|
|
55
|
+
return `${(clearedBalance / 1e9).toFixed(2)}B`;
|
|
56
|
+
}
|
|
35
57
|
if (clearedBalance > MAX_BALANCE_VALUE) {
|
|
36
58
|
const dividedValue = Math.floor(clearedBalance);
|
|
37
59
|
const roundedBalance = Math.floor((dividedValue / MAX_BALANCE_VALUE) * PRECISION_FLOOR_DIVIDER) /
|
|
@@ -28,6 +28,28 @@ const MAX_BALANCE_VALUE = 1000000;
|
|
|
28
28
|
const PRECISION_FLOOR_DIVIDER = 10000;
|
|
29
29
|
const roundBalance = (balanceString, decimals = 4) => {
|
|
30
30
|
const clearedBalance = parseFloat(replaceAll(balanceString, '"', ''));
|
|
31
|
+
// Guard against NaN (e.g., when balance is undefined/null)
|
|
32
|
+
if (Number.isNaN(clearedBalance)) {
|
|
33
|
+
return '0';
|
|
34
|
+
}
|
|
35
|
+
// Handle extremely large numbers (e.g., scientific notation like 1e+24)
|
|
36
|
+
// These are likely data errors or testnet faucet amounts
|
|
37
|
+
if (clearedBalance >= 1e15) {
|
|
38
|
+
// For numbers >= 1 quadrillion, show in trillions
|
|
39
|
+
const trillions = clearedBalance / 1e12;
|
|
40
|
+
if (trillions >= 1000) {
|
|
41
|
+
return `${(trillions / 1000).toFixed(2)}Q`; // Quadrillions
|
|
42
|
+
}
|
|
43
|
+
return `${trillions.toFixed(2)}T`; // Trillions
|
|
44
|
+
}
|
|
45
|
+
if (clearedBalance >= 1e12) {
|
|
46
|
+
// Trillions
|
|
47
|
+
return `${(clearedBalance / 1e12).toFixed(2)}T`;
|
|
48
|
+
}
|
|
49
|
+
if (clearedBalance >= 1e9) {
|
|
50
|
+
// Billions
|
|
51
|
+
return `${(clearedBalance / 1e9).toFixed(2)}B`;
|
|
52
|
+
}
|
|
31
53
|
if (clearedBalance > MAX_BALANCE_VALUE) {
|
|
32
54
|
const dividedValue = Math.floor(clearedBalance);
|
|
33
55
|
const roundedBalance = Math.floor((dividedValue / MAX_BALANCE_VALUE) * PRECISION_FLOOR_DIVIDER) /
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
-
var client = require('@dynamic-labs-sdk/client');
|
|
8
|
-
var utils$1 = require('@dynamic-labs/utils');
|
|
9
|
-
require('@dynamic-labs-sdk/client/core');
|
|
10
|
-
require('@dynamic-labs/sdk-api-core');
|
|
11
|
-
require('../../../client/client.cjs');
|
|
12
|
-
require('react');
|
|
13
|
-
require('../../../config/ApiEndpoint.cjs');
|
|
14
|
-
require('@dynamic-labs/iconic');
|
|
15
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
16
|
-
require('react/jsx-runtime');
|
|
17
|
-
require('../../../context/ViewContext/ViewContext.cjs');
|
|
18
|
-
require('../../../shared/logger.cjs');
|
|
19
|
-
require('@dynamic-labs/wallet-book');
|
|
20
|
-
require('../../../utils/constants/colors.cjs');
|
|
21
|
-
require('../../../utils/constants/values.cjs');
|
|
22
|
-
require('../../../shared/consts/index.cjs');
|
|
23
|
-
require('@dynamic-labs/multi-wallet');
|
|
24
|
-
require('react-international-phone');
|
|
25
|
-
require('../../../store/state/nonce/nonce.cjs');
|
|
26
|
-
var api = require('../api.cjs');
|
|
27
|
-
var utils = require('../utils.cjs');
|
|
28
|
-
require('@dynamic-labs/locale');
|
|
29
|
-
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
30
|
-
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
31
|
-
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
32
|
-
require('../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
33
|
-
require('../../../events/dynamicEvents.cjs');
|
|
34
|
-
var storeTokenAndUser = require('../../../client/extension/storeTokenAndUser/storeTokenAndUser.cjs');
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated Use `signInWithExternalJwt` instead.
|
|
38
|
-
* This currently does not work.
|
|
39
|
-
*/
|
|
40
|
-
const externalAuthVerify = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, externalJwt, }) {
|
|
41
|
-
try {
|
|
42
|
-
/* istanbul ignore next */
|
|
43
|
-
const response = (yield api.sdkApi().externalAuthVerify({
|
|
44
|
-
environmentId,
|
|
45
|
-
externalAuthSigninRequest: {
|
|
46
|
-
jwt: externalJwt,
|
|
47
|
-
},
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
}));
|
|
50
|
-
return storeTokenAndUser.storeTokenAndUser(response);
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
const data = yield utils.logResponseError(e, 'Error verifying external JWT');
|
|
54
|
-
if (data.code === 'invalid_external_auth') {
|
|
55
|
-
throw new client.InvalidExternalAuthError({
|
|
56
|
-
cause: data,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
60
|
-
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
61
|
-
}
|
|
62
|
-
throw new utils$1.DynamicError(data.error);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
exports.externalAuthVerify = externalAuthVerify;
|