@dynamic-labs/sdk-react-core 4.6.2 → 4.7.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 +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/lib/Main.cjs +1 -1
- package/src/lib/Main.js +1 -1
- package/src/lib/components/BaseButton/BaseButton.cjs +20 -0
- package/src/lib/components/BaseButton/BaseButton.d.ts +21 -0
- package/src/lib/components/BaseButton/BaseButton.js +16 -0
- package/src/lib/components/BaseButton/index.d.ts +1 -0
- package/src/lib/components/Button/Button.cjs +5 -1
- package/src/lib/components/Button/Button.d.ts +6 -7
- package/src/lib/components/Button/Button.js +5 -1
- package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/NetworkSwitchControl.cjs +2 -2
- package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/NetworkSwitchControl.js +2 -2
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +2 -1
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.cjs +2 -2
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.js +2 -2
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +2 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +2 -2
- package/src/lib/locale/en/translation.cjs +10 -0
- package/src/lib/locale/en/translation.d.ts +10 -0
- package/src/lib/locale/en/translation.js +10 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -0
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +2 -1
- package/src/lib/utils/functions/generateMessages/index.cjs +1 -1
- package/src/lib/utils/functions/generateMessages/index.js +1 -1
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +2 -2
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +2 -2
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.cjs +1 -3
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.d.ts +2 -1
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.js +1 -3
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +4 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +4 -1
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +1 -1
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +1 -1
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
- package/src/lib/utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.cjs +4 -96
- package/src/lib/utils/hooks/useNetworkDataFromWallet/useNetworkDataFromWallet.js +4 -96
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +32 -19
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.d.ts +2 -2
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +31 -18
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.cjs +1 -1
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.js +1 -1
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs +2 -2
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js +2 -2
- package/src/lib/utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.cjs +12 -16
- package/src/lib/utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.js +13 -17
- package/src/lib/utils/types/ButtonAriaProps.d.ts +5 -0
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +3 -1
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +3 -1
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +2 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -1
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.cjs +130 -0
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.d.ts +3 -0
- package/src/lib/views/UserDeleteAccountView/UserDeleteAccountView.js +125 -0
- package/src/lib/views/UserDeleteAccountView/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.cjs +20 -8
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.js +21 -9
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.js +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +6 -16
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +6 -16
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +13 -4
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +13 -4
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +18 -6
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +19 -7
- package/src/lib/shared/assets/gear.cjs +0 -54
- package/src/lib/shared/assets/gear.js +0 -30
- package/src/lib/utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.cjs +0 -13
- package/src/lib/utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.d.ts +0 -3
- package/src/lib/utils/functions/getWalletConnectorNetworks/getWalletConnectorNetworks.js +0 -9
|
@@ -19,6 +19,7 @@ const EMBEDDED_WALLET_SESSION_SETTINGS = 'dynamic_embedded_wallet_session_settin
|
|
|
19
19
|
const EMBEDDED_WALLET_SECURE_BANNER = 'dynamic_embedded_secure_banner';
|
|
20
20
|
const PHONE_INPUT_DEFAULT_COUNTRY = 'dynamic_phone_input_default_country';
|
|
21
21
|
const CAPTCHA_TOKEN = 'dynamic_captcha_token';
|
|
22
|
+
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
22
23
|
/**
|
|
23
24
|
* Used to identify the purpose of a signature after phantom redirects back to the app in mobile
|
|
24
25
|
*/
|
|
@@ -49,3 +50,4 @@ exports.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS = SECURE_ENCLAVE_WALL
|
|
|
49
50
|
exports.STORE_STORAGE_KEY = STORE_STORAGE_KEY;
|
|
50
51
|
exports.WAGMI_LAST_SESSION_SETTINGS = WAGMI_LAST_SESSION_SETTINGS;
|
|
51
52
|
exports.WALLET_PICKER_SEARCH_KEY = WALLET_PICKER_SEARCH_KEY;
|
|
53
|
+
exports.ZERODEV_AUTHORIZATION = ZERODEV_AUTHORIZATION;
|
|
@@ -17,6 +17,7 @@ export declare const EMBEDDED_WALLET_SESSION_SETTINGS = "dynamic_embedded_wallet
|
|
|
17
17
|
export declare const EMBEDDED_WALLET_SECURE_BANNER = "dynamic_embedded_secure_banner";
|
|
18
18
|
export declare const PHONE_INPUT_DEFAULT_COUNTRY = "dynamic_phone_input_default_country";
|
|
19
19
|
export declare const CAPTCHA_TOKEN = "dynamic_captcha_token";
|
|
20
|
+
export declare const ZERODEV_AUTHORIZATION = "zerodev_authorization";
|
|
20
21
|
export type PhantomSignatureState = {
|
|
21
22
|
/**
|
|
22
23
|
* Whether the user has agreed to transfer a wallet even if that means
|
|
@@ -15,6 +15,7 @@ const EMBEDDED_WALLET_SESSION_SETTINGS = 'dynamic_embedded_wallet_session_settin
|
|
|
15
15
|
const EMBEDDED_WALLET_SECURE_BANNER = 'dynamic_embedded_secure_banner';
|
|
16
16
|
const PHONE_INPUT_DEFAULT_COUNTRY = 'dynamic_phone_input_default_country';
|
|
17
17
|
const CAPTCHA_TOKEN = 'dynamic_captcha_token';
|
|
18
|
+
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
18
19
|
/**
|
|
19
20
|
* Used to identify the purpose of a signature after phantom redirects back to the app in mobile
|
|
20
21
|
*/
|
|
@@ -25,4 +26,4 @@ const SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS = {
|
|
|
25
26
|
priority: ['secureStorage', 'localStorage'],
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
export { AUTH_EXPIRES_AT, AUTH_MIN_TOKEN, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CAPTCHA_TOKEN, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, DEVICE_FINGERPRINT, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY };
|
|
29
|
+
export { AUTH_EXPIRES_AT, AUTH_MIN_TOKEN, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CAPTCHA_TOKEN, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, DEVICE_FINGERPRINT, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY, ZERODEV_AUTHORIZATION };
|
|
@@ -14,7 +14,7 @@ const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEn
|
|
|
14
14
|
if (!walletConnector.connectedChain) {
|
|
15
15
|
throw new utils.DynamicError('Wallet is not connected');
|
|
16
16
|
}
|
|
17
|
-
let chainId = yield walletConnector.getNetwork();
|
|
17
|
+
let chainId = yield walletConnector.getNetwork(true);
|
|
18
18
|
if (chainId === undefined) {
|
|
19
19
|
if (walletConnector.key === 'bloctoevm') {
|
|
20
20
|
chainId = 137;
|
|
@@ -10,7 +10,7 @@ const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEn
|
|
|
10
10
|
if (!walletConnector.connectedChain) {
|
|
11
11
|
throw new DynamicError('Wallet is not connected');
|
|
12
12
|
}
|
|
13
|
-
let chainId = yield walletConnector.getNetwork();
|
|
13
|
+
let chainId = yield walletConnector.getNetwork(true);
|
|
14
14
|
if (chainId === undefined) {
|
|
15
15
|
if (walletConnector.key === 'bloctoevm') {
|
|
16
16
|
chainId = 137;
|
|
@@ -18,7 +18,7 @@ const getVerifyArgs = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* (
|
|
|
18
18
|
const chain = walletConnector.connectedChain;
|
|
19
19
|
if (signedMessageOverride && messageToSignOverride) {
|
|
20
20
|
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
21
|
-
walletConnector.getNetwork(),
|
|
21
|
+
walletConnector.getNetwork(true),
|
|
22
22
|
walletConnector.getAdditionalAddresses(publicWalletAddress),
|
|
23
23
|
]);
|
|
24
24
|
return {
|
|
@@ -37,7 +37,7 @@ const getVerifyArgs = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* (
|
|
|
37
37
|
// generate message to sign and then initiate signing step to prove ownership
|
|
38
38
|
const { messageToSign, signedMessage } = yield index.generateMessages(publicWalletAddress, walletConnector, nonce$1, environmentId, displaySiweStatement, siweStatement);
|
|
39
39
|
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
40
|
-
walletConnector.getNetwork(),
|
|
40
|
+
walletConnector.getNetwork(true),
|
|
41
41
|
walletConnector.getAdditionalAddresses(publicWalletAddress),
|
|
42
42
|
]);
|
|
43
43
|
return {
|
|
@@ -14,7 +14,7 @@ const getVerifyArgs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walle
|
|
|
14
14
|
const chain = walletConnector.connectedChain;
|
|
15
15
|
if (signedMessageOverride && messageToSignOverride) {
|
|
16
16
|
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
17
|
-
walletConnector.getNetwork(),
|
|
17
|
+
walletConnector.getNetwork(true),
|
|
18
18
|
walletConnector.getAdditionalAddresses(publicWalletAddress),
|
|
19
19
|
]);
|
|
20
20
|
return {
|
|
@@ -33,7 +33,7 @@ const getVerifyArgs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walle
|
|
|
33
33
|
// generate message to sign and then initiate signing step to prove ownership
|
|
34
34
|
const { messageToSign, signedMessage } = yield generateMessages(publicWalletAddress, walletConnector, nonce, environmentId, displaySiweStatement, siweStatement);
|
|
35
35
|
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
36
|
-
walletConnector.getNetwork(),
|
|
36
|
+
walletConnector.getNetwork(true),
|
|
37
37
|
walletConnector.getAdditionalAddresses(publicWalletAddress),
|
|
38
38
|
]);
|
|
39
39
|
return {
|
|
@@ -32,7 +32,6 @@ export * from './getSocialSignInProviderFromString';
|
|
|
32
32
|
export * from './getUserProfileFields';
|
|
33
33
|
export * from './getUserWalletsFromVerifiedCredentials';
|
|
34
34
|
export * from './getVerifyArgs';
|
|
35
|
-
export * from './getWalletConnectorNetworks/getWalletConnectorNetworks';
|
|
36
35
|
export * from './getWalletIdentifier';
|
|
37
36
|
export * from './groupBy';
|
|
38
37
|
export * from './isAccountAbstractionWallet';
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var getWalletConnectorNetworks = require('../getWalletConnectorNetworks/getWalletConnectorNetworks.cjs');
|
|
7
|
-
|
|
8
6
|
const isSupportedNetwork = ({ walletConnector, network }) => {
|
|
9
|
-
const supportedNetworks =
|
|
7
|
+
const supportedNetworks = walletConnector.getEnabledNetworks();
|
|
10
8
|
if (!supportedNetworks.length) {
|
|
11
9
|
return true;
|
|
12
10
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
1
2
|
type Props = {
|
|
2
3
|
network: number | string | undefined;
|
|
3
|
-
walletConnector:
|
|
4
|
+
walletConnector: WalletConnector;
|
|
4
5
|
};
|
|
5
6
|
export declare const isSupportedNetwork: ({ walletConnector, network }: Props) => boolean;
|
|
6
7
|
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { getWalletConnectorNetworks } from '../getWalletConnectorNetworks/getWalletConnectorNetworks.js';
|
|
3
|
-
|
|
4
2
|
const isSupportedNetwork = ({ walletConnector, network }) => {
|
|
5
|
-
const supportedNetworks =
|
|
3
|
+
const supportedNetworks = walletConnector.getEnabledNetworks();
|
|
6
4
|
if (!supportedNetworks.length) {
|
|
7
5
|
return true;
|
|
8
6
|
}
|
|
@@ -153,7 +153,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
const { address } = connectionResult;
|
|
156
|
-
const walletNetwork = yield walletConnector.getNetwork();
|
|
156
|
+
const walletNetwork = yield walletConnector.getNetwork(true);
|
|
157
157
|
const usesSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
|
|
158
158
|
network: walletNetwork,
|
|
159
159
|
walletConnector,
|
|
@@ -149,7 +149,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
const { address } = connectionResult;
|
|
152
|
-
const walletNetwork = yield walletConnector.getNetwork();
|
|
152
|
+
const walletNetwork = yield walletConnector.getNetwork(true);
|
|
153
153
|
const usesSupportedNetwork = isSupportedNetwork({
|
|
154
154
|
network: walletNetwork,
|
|
155
155
|
walletConnector,
|
|
@@ -166,7 +166,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
166
166
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
const walletNetwork = yield walletConnector.getNetwork();
|
|
169
|
+
const walletNetwork = yield walletConnector.getNetwork(true);
|
|
170
170
|
const usesSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
|
|
171
171
|
network: walletNetwork,
|
|
172
172
|
walletConnector,
|
|
@@ -162,7 +162,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
162
162
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
const walletNetwork = yield walletConnector.getNetwork();
|
|
165
|
+
const walletNetwork = yield walletConnector.getNetwork(true);
|
|
166
166
|
const usesSupportedNetwork = isSupportedNetwork({
|
|
167
167
|
network: walletNetwork,
|
|
168
168
|
walletConnector,
|
|
@@ -204,13 +204,16 @@ const useAuthLayoutChecks = () => {
|
|
|
204
204
|
view.type !== 'qr-code' &&
|
|
205
205
|
view.type !== 'mfa-verification' &&
|
|
206
206
|
view.type !== 'mfa-display-backup-codes' &&
|
|
207
|
-
view.type !== 'mfa-recovery'
|
|
207
|
+
view.type !== 'mfa-recovery' &&
|
|
208
|
+
view.type !== 'user-delete-account';
|
|
209
|
+
const showBackButton = view.type !== 'user-delete-account';
|
|
208
210
|
const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
|
|
209
211
|
const shouldHideDynamicFooterSeparator = showDynamicFooter && showToSFooter;
|
|
210
212
|
return {
|
|
211
213
|
displayBorderBelowHeader,
|
|
212
214
|
isWalletListTypeView,
|
|
213
215
|
shouldHideDynamicFooterSeparator,
|
|
216
|
+
showBackButton,
|
|
214
217
|
showCloseButton,
|
|
215
218
|
showConnectedWalletProgress,
|
|
216
219
|
showDefaultFooter,
|
|
@@ -2,6 +2,7 @@ export declare const useAuthLayoutChecks: () => {
|
|
|
2
2
|
displayBorderBelowHeader: boolean;
|
|
3
3
|
isWalletListTypeView: boolean;
|
|
4
4
|
shouldHideDynamicFooterSeparator: boolean;
|
|
5
|
+
showBackButton: boolean;
|
|
5
6
|
showCloseButton: boolean;
|
|
6
7
|
showConnectedWalletProgress: boolean;
|
|
7
8
|
showDefaultFooter: boolean;
|
|
@@ -200,13 +200,16 @@ const useAuthLayoutChecks = () => {
|
|
|
200
200
|
view.type !== 'qr-code' &&
|
|
201
201
|
view.type !== 'mfa-verification' &&
|
|
202
202
|
view.type !== 'mfa-display-backup-codes' &&
|
|
203
|
-
view.type !== 'mfa-recovery'
|
|
203
|
+
view.type !== 'mfa-recovery' &&
|
|
204
|
+
view.type !== 'user-delete-account';
|
|
205
|
+
const showBackButton = view.type !== 'user-delete-account';
|
|
204
206
|
const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
|
|
205
207
|
const shouldHideDynamicFooterSeparator = showDynamicFooter && showToSFooter;
|
|
206
208
|
return {
|
|
207
209
|
displayBorderBelowHeader,
|
|
208
210
|
isWalletListTypeView,
|
|
209
211
|
shouldHideDynamicFooterSeparator,
|
|
212
|
+
showBackButton,
|
|
210
213
|
showCloseButton,
|
|
211
214
|
showConnectedWalletProgress,
|
|
212
215
|
showDefaultFooter,
|
|
@@ -105,7 +105,7 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
105
105
|
const connectedWalletsWithInvalidNetwork = [];
|
|
106
106
|
for (const connectedWallet of connectedWallets) {
|
|
107
107
|
const isChainInWalletsToConnect = bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.some((walletToConnectByChain) => walletToConnectByChain.chain === connectedWallet.chain);
|
|
108
|
-
const network = yield connectedWallet.connector.getNetwork();
|
|
108
|
+
const network = yield connectedWallet.connector.getNetwork(true);
|
|
109
109
|
const isSupported = isSupportedNetwork.isSupportedNetwork({
|
|
110
110
|
network,
|
|
111
111
|
walletConnector: connectedWallet.connector,
|
|
@@ -101,7 +101,7 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
101
101
|
const connectedWalletsWithInvalidNetwork = [];
|
|
102
102
|
for (const connectedWallet of connectedWallets) {
|
|
103
103
|
const isChainInWalletsToConnect = bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.some((walletToConnectByChain) => walletToConnectByChain.chain === connectedWallet.chain);
|
|
104
|
-
const network = yield connectedWallet.connector.getNetwork();
|
|
104
|
+
const network = yield connectedWallet.connector.getNetwork(true);
|
|
105
105
|
const isSupported = isSupportedNetwork({
|
|
106
106
|
network,
|
|
107
107
|
walletConnector: connectedWallet.connector,
|
|
@@ -271,6 +271,10 @@ const useDynamicLayoutData = ({ view, authMode, }) => {
|
|
|
271
271
|
copykey: 'dyn_login.select_wallet_in_wallet_group.title',
|
|
272
272
|
heading: t('dyn_login.select_wallet_in_wallet_group.title'),
|
|
273
273
|
},
|
|
274
|
+
'user-delete-account': {
|
|
275
|
+
copykey: 'dyn_settings.delete_account.title',
|
|
276
|
+
heading: t('dyn_settings.delete_account.title'),
|
|
277
|
+
},
|
|
274
278
|
'verify-email': {
|
|
275
279
|
copykey: 'dyn_otp_verification.confirm_code',
|
|
276
280
|
heading: t('dyn_otp_verification.confirm_code'),
|
|
@@ -267,6 +267,10 @@ const useDynamicLayoutData = ({ view, authMode, }) => {
|
|
|
267
267
|
copykey: 'dyn_login.select_wallet_in_wallet_group.title',
|
|
268
268
|
heading: t('dyn_login.select_wallet_in_wallet_group.title'),
|
|
269
269
|
},
|
|
270
|
+
'user-delete-account': {
|
|
271
|
+
copykey: 'dyn_settings.delete_account.title',
|
|
272
|
+
heading: t('dyn_settings.delete_account.title'),
|
|
273
|
+
},
|
|
270
274
|
'verify-email': {
|
|
271
275
|
copykey: 'dyn_otp_verification.confirm_code',
|
|
272
276
|
heading: t('dyn_otp_verification.confirm_code'),
|
|
@@ -4,108 +4,16 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var usePromise = require('../usePromise/usePromise.cjs');
|
|
7
|
-
require('react');
|
|
8
|
-
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
9
|
-
require('@dynamic-labs/sdk-api-core');
|
|
10
|
-
require('../../../shared/logger.cjs');
|
|
11
|
-
require('@dynamic-labs/iconic');
|
|
12
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
-
require('react/jsx-runtime');
|
|
14
|
-
require('../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
-
require('@dynamic-labs/wallet-book');
|
|
16
|
-
require('@dynamic-labs/utils');
|
|
17
|
-
require('../../constants/colors.cjs');
|
|
18
|
-
require('../../constants/values.cjs');
|
|
19
|
-
require('../../../shared/consts/index.cjs');
|
|
20
|
-
require('../../../events/dynamicEvents.cjs');
|
|
21
|
-
require('../../../../../_virtual/_tslib.cjs');
|
|
22
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
|
-
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
|
-
require('@dynamic-labs/multi-wallet');
|
|
25
|
-
require('react-international-phone');
|
|
26
|
-
require('../../../store/state/nonce/nonce.cjs');
|
|
27
|
-
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
28
|
-
require('../../../config/ApiEndpoint.cjs');
|
|
29
|
-
require('../../../store/state/user/user.cjs');
|
|
30
|
-
require('../../../locale/locale.cjs');
|
|
31
|
-
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
32
|
-
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
33
|
-
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
34
|
-
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
35
|
-
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
36
|
-
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
37
|
-
require('react-dom');
|
|
38
|
-
require('../../functions/compareChains/compareChains.cjs');
|
|
39
|
-
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
40
|
-
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
41
|
-
require('bs58');
|
|
42
|
-
require('@dynamic-labs/types');
|
|
43
|
-
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
44
|
-
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
45
|
-
require('../../../context/WalletContext/WalletContext.cjs');
|
|
46
|
-
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
47
|
-
require('yup');
|
|
48
|
-
require('../../../context/MockContext/MockContext.cjs');
|
|
49
|
-
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
50
|
-
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
51
|
-
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
52
|
-
require('@dynamic-labs/rpc-providers');
|
|
53
|
-
require('../../../store/state/loadingAndLifecycle.cjs');
|
|
54
|
-
require('@dynamic-labs/store');
|
|
55
|
-
require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
56
|
-
require('react-i18next');
|
|
57
|
-
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
58
|
-
require('../../../components/Alert/Alert.cjs');
|
|
59
|
-
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
60
|
-
require('../../../components/IconButton/IconButton.cjs');
|
|
61
|
-
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
62
|
-
require('../../../components/Input/Input.cjs');
|
|
63
|
-
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
64
|
-
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
65
|
-
require('../../../components/OverlayCard/OverlayCard.cjs');
|
|
66
|
-
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
67
|
-
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
68
|
-
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
69
|
-
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
70
|
-
require('../../../components/Popper/Popper/Popper.cjs');
|
|
71
|
-
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
72
|
-
require('react-focus-lock');
|
|
73
|
-
require('qrcode');
|
|
74
|
-
require('formik');
|
|
75
|
-
require('../useSubdomainCheck/useSubdomainCheck.cjs');
|
|
76
|
-
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
77
|
-
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
78
|
-
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
79
|
-
require('../../../context/ConnectWithOtpContext/constants.cjs');
|
|
80
|
-
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
81
|
-
require('@hcaptcha/react-hcaptcha');
|
|
82
|
-
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
83
|
-
require('../../../context/FooterAnimationContext/index.cjs');
|
|
84
|
-
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
85
|
-
require('../../../store/state/sendBalances.cjs');
|
|
86
|
-
require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
87
|
-
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
88
|
-
require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
89
|
-
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
90
|
-
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
91
|
-
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
92
|
-
require('../../../../index.cjs');
|
|
93
|
-
require('../../../store/state/tokenBalances.cjs');
|
|
94
|
-
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
95
|
-
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
96
7
|
|
|
97
8
|
const useNetworkDataFromWallet = (wallet) => {
|
|
98
|
-
|
|
99
|
-
const { data: network } = usePromise.usePromise(() => wallet === null || wallet === void 0 ? void 0 : wallet.connector.getNetwork(), {
|
|
9
|
+
const { data: network } = usePromise.usePromise(() => wallet === null || wallet === void 0 ? void 0 : wallet.connector.getNetwork(true), {
|
|
100
10
|
enabled: Boolean(wallet),
|
|
101
11
|
});
|
|
102
|
-
const { networkConfigurations } = useInternalDynamicContext.useInternalDynamicContext();
|
|
103
12
|
if (!wallet || !network)
|
|
104
13
|
return undefined;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return (_b = networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations[wallet.connector.connectedChain.toLowerCase()]) === null || _b === void 0 ? void 0 : _b.find((_network) => _network.chainId === network);
|
|
14
|
+
return wallet.connector
|
|
15
|
+
.getEnabledNetworks()
|
|
16
|
+
.find((_network) => _network.chainId === network);
|
|
109
17
|
};
|
|
110
18
|
|
|
111
19
|
exports.useNetworkDataFromWallet = useNetworkDataFromWallet;
|
|
@@ -1,107 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { usePromise } from '../usePromise/usePromise.js';
|
|
3
|
-
import 'react';
|
|
4
|
-
import '../../../context/DynamicContext/DynamicContext.js';
|
|
5
|
-
import '@dynamic-labs/sdk-api-core';
|
|
6
|
-
import '../../../shared/logger.js';
|
|
7
|
-
import '@dynamic-labs/iconic';
|
|
8
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
-
import 'react/jsx-runtime';
|
|
10
|
-
import '../../../context/ViewContext/ViewContext.js';
|
|
11
|
-
import '@dynamic-labs/wallet-book';
|
|
12
|
-
import '@dynamic-labs/utils';
|
|
13
|
-
import '../../constants/colors.js';
|
|
14
|
-
import '../../constants/values.js';
|
|
15
|
-
import '../../../shared/consts/index.js';
|
|
16
|
-
import '../../../events/dynamicEvents.js';
|
|
17
|
-
import '../../../../../_virtual/_tslib.js';
|
|
18
|
-
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
|
-
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
-
import '@dynamic-labs/multi-wallet';
|
|
21
|
-
import 'react-international-phone';
|
|
22
|
-
import '../../../store/state/nonce/nonce.js';
|
|
23
|
-
import '../../../store/state/projectSettings/projectSettings.js';
|
|
24
|
-
import '../../../config/ApiEndpoint.js';
|
|
25
|
-
import '../../../store/state/user/user.js';
|
|
26
|
-
import '../../../locale/locale.js';
|
|
27
|
-
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
28
|
-
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
29
|
-
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
30
|
-
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
31
|
-
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
32
|
-
import '../../../context/VerificationContext/VerificationContext.js';
|
|
33
|
-
import 'react-dom';
|
|
34
|
-
import '../../functions/compareChains/compareChains.js';
|
|
35
|
-
import '../../../context/ThemeContext/ThemeContext.js';
|
|
36
|
-
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
37
|
-
import 'bs58';
|
|
38
|
-
import '@dynamic-labs/types';
|
|
39
|
-
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
40
|
-
import '../../../context/LoadingContext/LoadingContext.js';
|
|
41
|
-
import '../../../context/WalletContext/WalletContext.js';
|
|
42
|
-
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
43
|
-
import 'yup';
|
|
44
|
-
import '../../../context/MockContext/MockContext.js';
|
|
45
|
-
import '../../../views/CollectUserDataView/useFields.js';
|
|
46
|
-
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
47
|
-
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
48
|
-
import '@dynamic-labs/rpc-providers';
|
|
49
|
-
import '../../../store/state/loadingAndLifecycle.js';
|
|
50
|
-
import '@dynamic-labs/store';
|
|
51
|
-
import '../../../store/state/walletOptions/walletOptions.js';
|
|
52
|
-
import 'react-i18next';
|
|
53
|
-
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
54
|
-
import '../../../components/Alert/Alert.js';
|
|
55
|
-
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
56
|
-
import '../../../components/IconButton/IconButton.js';
|
|
57
|
-
import '../../../components/InlineWidget/InlineWidget.js';
|
|
58
|
-
import '../../../components/Input/Input.js';
|
|
59
|
-
import '../../../components/IsBrowser/IsBrowser.js';
|
|
60
|
-
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
61
|
-
import '../../../components/OverlayCard/OverlayCard.js';
|
|
62
|
-
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
63
|
-
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
64
|
-
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
65
|
-
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
66
|
-
import '../../../components/Popper/Popper/Popper.js';
|
|
67
|
-
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
68
|
-
import 'react-focus-lock';
|
|
69
|
-
import 'qrcode';
|
|
70
|
-
import 'formik';
|
|
71
|
-
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
72
|
-
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
73
|
-
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
74
|
-
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
75
|
-
import '../../../context/ConnectWithOtpContext/constants.js';
|
|
76
|
-
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
77
|
-
import '@hcaptcha/react-hcaptcha';
|
|
78
|
-
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
79
|
-
import '../../../context/FooterAnimationContext/index.js';
|
|
80
|
-
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
81
|
-
import '../../../store/state/sendBalances.js';
|
|
82
|
-
import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
83
|
-
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
84
|
-
import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
85
|
-
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
86
|
-
import '../../../context/OnrampContext/OnrampContext.js';
|
|
87
|
-
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
88
|
-
import '../../../../index.js';
|
|
89
|
-
import '../../../store/state/tokenBalances.js';
|
|
90
|
-
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
91
|
-
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
92
3
|
|
|
93
4
|
const useNetworkDataFromWallet = (wallet) => {
|
|
94
|
-
|
|
95
|
-
const { data: network } = usePromise(() => wallet === null || wallet === void 0 ? void 0 : wallet.connector.getNetwork(), {
|
|
5
|
+
const { data: network } = usePromise(() => wallet === null || wallet === void 0 ? void 0 : wallet.connector.getNetwork(true), {
|
|
96
6
|
enabled: Boolean(wallet),
|
|
97
7
|
});
|
|
98
|
-
const { networkConfigurations } = useInternalDynamicContext();
|
|
99
8
|
if (!wallet || !network)
|
|
100
9
|
return undefined;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return (_b = networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations[wallet.connector.connectedChain.toLowerCase()]) === null || _b === void 0 ? void 0 : _b.find((_network) => _network.chainId === network);
|
|
10
|
+
return wallet.connector
|
|
11
|
+
.getEnabledNetworks()
|
|
12
|
+
.find((_network) => _network.chainId === network);
|
|
105
13
|
};
|
|
106
14
|
|
|
107
15
|
export { useNetworkDataFromWallet };
|
|
@@ -9,7 +9,7 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
|
9
9
|
var tokenBalances = require('../../../store/state/tokenBalances.cjs');
|
|
10
10
|
var balances = require('../../../data/api/chains/balances.cjs');
|
|
11
11
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
12
|
-
require('../../../shared/logger.cjs');
|
|
12
|
+
var logger = require('../../../shared/logger.cjs');
|
|
13
13
|
require('@dynamic-labs/iconic');
|
|
14
14
|
require('@dynamic-labs/wallet-connector-core');
|
|
15
15
|
require('react/jsx-runtime');
|
|
@@ -26,10 +26,10 @@ var errors = require('../../constants/errors.cjs');
|
|
|
26
26
|
require('@dynamic-labs/multi-wallet');
|
|
27
27
|
require('react-international-phone');
|
|
28
28
|
require('../../../store/state/nonce/nonce.cjs');
|
|
29
|
-
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
29
|
+
var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
30
30
|
require('../../../config/ApiEndpoint.cjs');
|
|
31
31
|
var utils = require('../../../data/api/utils.cjs');
|
|
32
|
-
require('../../../store/state/user/user.cjs');
|
|
32
|
+
var user = require('../../../store/state/user/user.cjs');
|
|
33
33
|
require('../../../locale/locale.cjs');
|
|
34
34
|
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
35
35
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
@@ -101,48 +101,61 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
101
101
|
const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.ChainEnum.Evm, tokenAddresses, includeFiat = false, includeNativeBalance = false, } = {}) => {
|
|
102
102
|
const tokenBalancesState = tokenBalances.useTokenBalancesState();
|
|
103
103
|
const { tokenBalances: tokenBalances$1, isLoading, error } = tokenBalancesState;
|
|
104
|
-
const { primaryWallet,
|
|
104
|
+
const { primaryWallet, authMode, network } = useInternalDynamicContext.useInternalDynamicContext();
|
|
105
105
|
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
106
|
-
const requestChainName = chainName !== null && chainName !== void 0 ? chainName : walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain;
|
|
107
106
|
const requestAccount = accountAddress !== null && accountAddress !== void 0 ? accountAddress : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address;
|
|
108
|
-
const
|
|
107
|
+
const requestChainName = chainName !== null && chainName !== void 0 ? chainName : walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain;
|
|
109
108
|
const fetchAccountBalances = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (forceRefresh = false) {
|
|
110
109
|
var _a;
|
|
111
|
-
|
|
110
|
+
const user$1 = user.getUser();
|
|
111
|
+
if (authMode !== 'connect-only' && !user$1) {
|
|
112
112
|
tokenBalances.setTokenBalanceVariable('error', errors.USER_NOT_LOGGED_IN);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
+
const projectSettings$1 = projectSettings.getProjectSettings();
|
|
115
116
|
if (authMode === 'connect-only' &&
|
|
116
|
-
!((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.featureFlags) === null || _a === void 0 ? void 0 : _a.connectOnlyMultiAsset)) {
|
|
117
|
+
!((_a = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.featureFlags) === null || _a === void 0 ? void 0 : _a.connectOnlyMultiAsset)) {
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
if (![sdkApiCore.ChainEnum.Evm, sdkApiCore.ChainEnum.Sol].includes(requestChainName)) {
|
|
120
121
|
tokenBalances.setTokenBalanceVariable('error', `Chain ${requestChainName} is not supported for token balances`);
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
+
// the reason why we need to get the network here again insteaf of using the value
|
|
125
|
+
// from DynamicContext is because this function might run before the network state is
|
|
126
|
+
// properly set when switching wallets, so we want to make sure we have the latest network
|
|
127
|
+
const requestNetwork = networkId !== null && networkId !== void 0 ? networkId : (yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(true)));
|
|
128
|
+
const isValidEvmRequest = requestChainName === sdkApiCore.ChainEnum.Evm &&
|
|
124
129
|
requestNetwork &&
|
|
125
130
|
!isNaN(Number(requestNetwork));
|
|
126
|
-
const isValidRequest = isValidEvmRequest ||
|
|
131
|
+
const isValidRequest = isValidEvmRequest || requestChainName === sdkApiCore.ChainEnum.Sol;
|
|
132
|
+
logger.logger.logVerboseTroubleshootingMessage('[useTokenBalances] will try to fetch token balances', {
|
|
133
|
+
isLoading,
|
|
134
|
+
isValidRequest,
|
|
135
|
+
networkId,
|
|
136
|
+
requestAccount,
|
|
137
|
+
requestChainName,
|
|
138
|
+
requestNetwork,
|
|
139
|
+
});
|
|
127
140
|
if (isLoading || !requestAccount || !isValidRequest) {
|
|
128
141
|
tokenBalances.setTokenBalanceVariable('tokenBalances', undefined);
|
|
129
142
|
return;
|
|
130
143
|
}
|
|
131
144
|
tokenBalances.setTokenBalanceVariable('isLoading', true);
|
|
145
|
+
let response = [];
|
|
132
146
|
try {
|
|
133
|
-
|
|
147
|
+
response = yield balances.getAccountTokenBalances({
|
|
134
148
|
accountAddress: requestAccount,
|
|
135
149
|
chainName: requestChainName,
|
|
136
|
-
environmentId,
|
|
150
|
+
environmentId: dynamicContextProps.getEnvironmentId(),
|
|
137
151
|
forceRefresh,
|
|
138
152
|
includeNative: includeNativeBalance,
|
|
139
153
|
includePrices: includeFiat,
|
|
140
|
-
networkId:
|
|
154
|
+
networkId: requestChainName === sdkApiCore.ChainEnum.Evm ? Number(requestNetwork) : 0,
|
|
141
155
|
});
|
|
142
156
|
if (!response)
|
|
143
157
|
return;
|
|
144
158
|
tokenBalances.setTokenBalanceVariable('error', undefined);
|
|
145
|
-
tokenBalances.setTokenBalanceVariable('tokenBalances', response);
|
|
146
159
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
160
|
}
|
|
148
161
|
catch (e) {
|
|
@@ -151,23 +164,23 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.Ch
|
|
|
151
164
|
tokenBalances.setTokenBalanceVariable('error', errorMessage);
|
|
152
165
|
}
|
|
153
166
|
finally {
|
|
167
|
+
tokenBalances.setTokenBalanceVariable('tokenBalances', response);
|
|
154
168
|
tokenBalances.setTokenBalanceVariable('isLoading', false);
|
|
155
169
|
}
|
|
156
170
|
}), [
|
|
157
|
-
user,
|
|
158
171
|
requestChainName,
|
|
159
|
-
chainName,
|
|
160
|
-
requestNetwork,
|
|
161
172
|
isLoading,
|
|
162
173
|
requestAccount,
|
|
163
|
-
environmentId,
|
|
164
174
|
includeNativeBalance,
|
|
165
175
|
includeFiat,
|
|
176
|
+
authMode,
|
|
177
|
+
networkId,
|
|
178
|
+
walletConnector,
|
|
166
179
|
]);
|
|
167
180
|
useDynamicEvents.useInternalDynamicEvents('tokenBalancesChanged', () => fetchAccountBalances(true));
|
|
168
181
|
React.useEffect(() => {
|
|
169
182
|
fetchAccountBalances();
|
|
170
|
-
}, [requestAccount,
|
|
183
|
+
}, [requestAccount, network, networkId]);
|
|
171
184
|
const { tokensFilter } = dynamicContextProps.useDynamicSettings();
|
|
172
185
|
const lowerTokenAddresses = tokenAddresses === null || tokenAddresses === void 0 ? void 0 : tokenAddresses.map((address) => address.toLowerCase());
|
|
173
186
|
const initialTokenBalances = lowerTokenAddresses
|