@dynamic-labs/sdk-react-core 4.0.0-alpha.2 → 4.0.0-alpha.4
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/components/QRCode/QRCode.cjs +2 -2
- package/src/lib/components/QRCode/QRCode.js +2 -2
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +5 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +5 -1
- package/src/lib/components/TransactionConfirmationPageLayout/utils.cjs +5 -6
- package/src/lib/components/TransactionConfirmationPageLayout/utils.js +5 -6
- package/src/lib/context/DynamicContext/DynamicContext.cjs +14 -16
- package/src/lib/context/DynamicContext/DynamicContext.js +14 -16
- package/src/lib/data/api/oauth/oauth.cjs +14 -0
- package/src/lib/data/api/oauth/oauth.d.ts +1 -0
- package/src/lib/data/api/oauth/oauth.js +14 -1
- package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.cjs +1 -6
- package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.js +1 -6
- package/src/lib/store/stateConfig.cjs +0 -5
- package/src/lib/store/stateConfig.js +0 -5
- package/src/lib/store/types.d.ts +1 -6
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/index.d.ts +1 -0
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +63 -0
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +9 -0
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +59 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +8 -1
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +8 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +148 -114
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +151 -117
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs +20 -7
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.d.ts +1 -0
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.js +20 -7
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +1 -1
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +1 -1
- package/src/lib/views/WalletList/data.cjs +6 -1
- package/src/lib/views/WalletList/data.js +6 -1
- package/src/lib/store/state/networkConfigurations/index.d.ts +0 -1
- package/src/lib/store/state/networkConfigurations/networkConfigurations.cjs +0 -169
- package/src/lib/store/state/networkConfigurations/networkConfigurations.d.ts +0 -10
- package/src/lib/store/state/networkConfigurations/networkConfigurations.js +0 -161
|
@@ -1,169 +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 useDynamicEvents = require('../../../utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs');
|
|
8
|
-
require('react');
|
|
9
|
-
require('@dynamic-labs/utils');
|
|
10
|
-
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
11
|
-
require('@dynamic-labs/sdk-api-core');
|
|
12
|
-
require('../../../shared/logger.cjs');
|
|
13
|
-
require('@dynamic-labs/iconic');
|
|
14
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
15
|
-
require('react/jsx-runtime');
|
|
16
|
-
require('../../../context/ViewContext/ViewContext.cjs');
|
|
17
|
-
require('@dynamic-labs/wallet-book');
|
|
18
|
-
require('../../../utils/constants/colors.cjs');
|
|
19
|
-
require('../../../utils/constants/values.cjs');
|
|
20
|
-
require('../loadingAndLifecycle.cjs');
|
|
21
|
-
require('../../../shared/consts/index.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('../../../config/ApiEndpoint.cjs');
|
|
27
|
-
require('../user/user.cjs');
|
|
28
|
-
require('../../../locale/locale.cjs');
|
|
29
|
-
require('../projectSettings/projectSettings.cjs');
|
|
30
|
-
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
31
|
-
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
32
|
-
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
33
|
-
require('../../../events/dynamicEvents.cjs');
|
|
34
|
-
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
35
|
-
require('react-dom');
|
|
36
|
-
require('../../../context/WalletContext/WalletContext.cjs');
|
|
37
|
-
require('../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
38
|
-
var usePromise = require('../../../utils/hooks/usePromise/usePromise.cjs');
|
|
39
|
-
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
40
|
-
require('../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
41
|
-
require('@dynamic-labs/types');
|
|
42
|
-
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
43
|
-
require('yup');
|
|
44
|
-
require('../../../context/MockContext/MockContext.cjs');
|
|
45
|
-
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
46
|
-
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
47
|
-
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
48
|
-
require('@dynamic-labs/rpc-providers');
|
|
49
|
-
require('../environmentId.cjs');
|
|
50
|
-
require('../walletConnectorOptions.cjs');
|
|
51
|
-
require('react-i18next');
|
|
52
|
-
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
53
|
-
require('../../../components/Alert/Alert.cjs');
|
|
54
|
-
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
55
|
-
require('../../../components/IconButton/IconButton.cjs');
|
|
56
|
-
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
57
|
-
require('../../../components/Input/Input.cjs');
|
|
58
|
-
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
59
|
-
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
60
|
-
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
61
|
-
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
62
|
-
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
63
|
-
require('../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
64
|
-
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
65
|
-
require('../../../components/Popper/Popper/Popper.cjs');
|
|
66
|
-
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
67
|
-
require('react-focus-lock');
|
|
68
|
-
require('qrcode');
|
|
69
|
-
require('formik');
|
|
70
|
-
require('../../../context/FooterAnimationContext/index.cjs');
|
|
71
|
-
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
72
|
-
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
73
|
-
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
74
|
-
require('@hcaptcha/react-hcaptcha');
|
|
75
|
-
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
76
|
-
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
77
|
-
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
78
|
-
require('../sendBalances.cjs');
|
|
79
|
-
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
80
|
-
require('../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
81
|
-
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
82
|
-
require('../../../../polyfills.cjs');
|
|
83
|
-
require('../../../context/ErrorBoundary/ErrorBoundaryBase.cjs');
|
|
84
|
-
require('../../../context/ErrorBoundary/ErrorBoundaryContext.cjs');
|
|
85
|
-
require('../../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
86
|
-
require('../../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetCard.cjs');
|
|
87
|
-
require('../../../context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
88
|
-
require('../../../context/FundingContext/FundingContext.cjs');
|
|
89
|
-
require('../../../context/SendBalanceContext/SendBalanceContext.cjs');
|
|
90
|
-
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
91
|
-
require('../../../context/ConnectWithOtpContext/constants.cjs');
|
|
92
|
-
require('../../../context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
93
|
-
require('../tokenBalances.cjs');
|
|
94
|
-
var createStoreState = require('../../internalImplementation/utils/createStoreState/createStoreState.cjs');
|
|
95
|
-
|
|
96
|
-
const { getNetworkConfigurations, setNetworkConfigurations, useNetworkConfigurations, resetNetworkConfigurations, } = createStoreState.createStoreState('networkConfigurations');
|
|
97
|
-
const createNetwork = (network, parser = (input) => input) => ({
|
|
98
|
-
blockExplorerUrls: network.blockExplorerUrls,
|
|
99
|
-
chainId: parser(network.chainId),
|
|
100
|
-
iconUrls: network.iconUrls,
|
|
101
|
-
lcdUrl: network.lcdUrl,
|
|
102
|
-
name: network.name,
|
|
103
|
-
nativeCurrency: network.nativeCurrency,
|
|
104
|
-
networkId: parser(network.networkId),
|
|
105
|
-
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
106
|
-
rpcUrls: network.rpcUrls,
|
|
107
|
-
vanityName: network.vanityName,
|
|
108
|
-
});
|
|
109
|
-
const overrideNetworks = (networkOverrides, networks) => {
|
|
110
|
-
if (!networkOverrides) {
|
|
111
|
-
return networks;
|
|
112
|
-
}
|
|
113
|
-
if (Array.isArray(networkOverrides)) {
|
|
114
|
-
return networkOverrides;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return networkOverrides(networks !== null && networks !== void 0 ? networks : []);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const useFetchNetworkConfigurations = ({ environmentId, projectSettings, evmNetworksOverrides, cosmosNetworkOverrides, }) => {
|
|
121
|
-
const { retrigger } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
-
var _a, _b, _c, _d;
|
|
123
|
-
if (!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks))
|
|
124
|
-
return Promise.resolve({});
|
|
125
|
-
const { networks } = projectSettings;
|
|
126
|
-
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
127
|
-
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
128
|
-
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
129
|
-
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
130
|
-
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
131
|
-
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
132
|
-
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
133
|
-
evmNetworks = overrideNetworks(evmNetworksOverrides, evmNetworks);
|
|
134
|
-
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
135
|
-
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
136
|
-
if (evmNetworksOverrides) {
|
|
137
|
-
if (Array.isArray(evmNetworksOverrides)) {
|
|
138
|
-
evmNetworks = evmNetworksOverrides;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return Promise.resolve({
|
|
145
|
-
cosmos: cosmosNetworks,
|
|
146
|
-
evm: evmNetworks,
|
|
147
|
-
solana: solanaNetworks,
|
|
148
|
-
starknet: starknetNetworks,
|
|
149
|
-
});
|
|
150
|
-
}), {
|
|
151
|
-
deps: [environmentId, projectSettings, evmNetworksOverrides],
|
|
152
|
-
enabled: Boolean(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks),
|
|
153
|
-
initialData: undefined,
|
|
154
|
-
onResolve: (networkConfigurations) => {
|
|
155
|
-
const expiry = new Date().getTime() + 60000 * 5;
|
|
156
|
-
setNetworkConfigurations({
|
|
157
|
-
expiresAt: expiry,
|
|
158
|
-
networkConfigurations: networkConfigurations,
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
useDynamicEvents.useDynamicEvents('logout', retrigger);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
exports.getNetworkConfigurations = getNetworkConfigurations;
|
|
166
|
-
exports.resetNetworkConfigurations = resetNetworkConfigurations;
|
|
167
|
-
exports.setNetworkConfigurations = setNetworkConfigurations;
|
|
168
|
-
exports.useFetchNetworkConfigurations = useFetchNetworkConfigurations;
|
|
169
|
-
exports.useNetworkConfigurations = useNetworkConfigurations;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
import { NetworksOverrides } from '../../../context/DynamicContext/types';
|
|
3
|
-
export declare const getNetworkConfigurations: () => import("../..").StoredNetworkConfigurations, setNetworkConfigurations: (value: import("../..").StoredNetworkConfigurations) => void, useNetworkConfigurations: () => import("../..").StoredNetworkConfigurations, resetNetworkConfigurations: () => void;
|
|
4
|
-
export type UseNetworkConfigurationsProps = {
|
|
5
|
-
environmentId: string;
|
|
6
|
-
projectSettings?: ProjectSettings;
|
|
7
|
-
evmNetworksOverrides?: NetworksOverrides;
|
|
8
|
-
cosmosNetworkOverrides?: NetworksOverrides;
|
|
9
|
-
};
|
|
10
|
-
export declare const useFetchNetworkConfigurations: ({ environmentId, projectSettings, evmNetworksOverrides, cosmosNetworkOverrides, }: UseNetworkConfigurationsProps) => void;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useDynamicEvents } from '../../../utils/hooks/events/useDynamicEvents/useDynamicEvents.js';
|
|
4
|
-
import 'react';
|
|
5
|
-
import '@dynamic-labs/utils';
|
|
6
|
-
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
|
-
import '@dynamic-labs/sdk-api-core';
|
|
8
|
-
import '../../../shared/logger.js';
|
|
9
|
-
import '@dynamic-labs/iconic';
|
|
10
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
11
|
-
import 'react/jsx-runtime';
|
|
12
|
-
import '../../../context/ViewContext/ViewContext.js';
|
|
13
|
-
import '@dynamic-labs/wallet-book';
|
|
14
|
-
import '../../../utils/constants/colors.js';
|
|
15
|
-
import '../../../utils/constants/values.js';
|
|
16
|
-
import '../loadingAndLifecycle.js';
|
|
17
|
-
import '../../../shared/consts/index.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 '../../../config/ApiEndpoint.js';
|
|
23
|
-
import '../user/user.js';
|
|
24
|
-
import '../../../locale/locale.js';
|
|
25
|
-
import '../projectSettings/projectSettings.js';
|
|
26
|
-
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
27
|
-
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
28
|
-
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
29
|
-
import '../../../events/dynamicEvents.js';
|
|
30
|
-
import '../../../context/VerificationContext/VerificationContext.js';
|
|
31
|
-
import 'react-dom';
|
|
32
|
-
import '../../../context/WalletContext/WalletContext.js';
|
|
33
|
-
import '../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
34
|
-
import { usePromise } from '../../../utils/hooks/usePromise/usePromise.js';
|
|
35
|
-
import '../../../context/ThemeContext/ThemeContext.js';
|
|
36
|
-
import '../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
37
|
-
import '@dynamic-labs/types';
|
|
38
|
-
import '../../../context/LoadingContext/LoadingContext.js';
|
|
39
|
-
import 'yup';
|
|
40
|
-
import '../../../context/MockContext/MockContext.js';
|
|
41
|
-
import '../../../views/CollectUserDataView/useFields.js';
|
|
42
|
-
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
43
|
-
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
44
|
-
import '@dynamic-labs/rpc-providers';
|
|
45
|
-
import '../environmentId.js';
|
|
46
|
-
import '../walletConnectorOptions.js';
|
|
47
|
-
import 'react-i18next';
|
|
48
|
-
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
49
|
-
import '../../../components/Alert/Alert.js';
|
|
50
|
-
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
51
|
-
import '../../../components/IconButton/IconButton.js';
|
|
52
|
-
import '../../../components/InlineWidget/InlineWidget.js';
|
|
53
|
-
import '../../../components/Input/Input.js';
|
|
54
|
-
import '../../../components/IsBrowser/IsBrowser.js';
|
|
55
|
-
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
56
|
-
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
57
|
-
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
58
|
-
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
59
|
-
import '../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
60
|
-
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
61
|
-
import '../../../components/Popper/Popper/Popper.js';
|
|
62
|
-
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
63
|
-
import 'react-focus-lock';
|
|
64
|
-
import 'qrcode';
|
|
65
|
-
import 'formik';
|
|
66
|
-
import '../../../context/FooterAnimationContext/index.js';
|
|
67
|
-
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
68
|
-
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
69
|
-
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
70
|
-
import '@hcaptcha/react-hcaptcha';
|
|
71
|
-
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
72
|
-
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
73
|
-
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
74
|
-
import '../sendBalances.js';
|
|
75
|
-
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
76
|
-
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
77
|
-
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
78
|
-
import '../../../../polyfills.js';
|
|
79
|
-
import '../../../context/ErrorBoundary/ErrorBoundaryBase.js';
|
|
80
|
-
import '../../../context/ErrorBoundary/ErrorBoundaryContext.js';
|
|
81
|
-
import '../../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
82
|
-
import '../../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetCard.js';
|
|
83
|
-
import '../../../context/WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
84
|
-
import '../../../context/FundingContext/FundingContext.js';
|
|
85
|
-
import '../../../context/SendBalanceContext/SendBalanceContext.js';
|
|
86
|
-
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
87
|
-
import '../../../context/ConnectWithOtpContext/constants.js';
|
|
88
|
-
import '../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
89
|
-
import '../tokenBalances.js';
|
|
90
|
-
import { createStoreState } from '../../internalImplementation/utils/createStoreState/createStoreState.js';
|
|
91
|
-
|
|
92
|
-
const { getNetworkConfigurations, setNetworkConfigurations, useNetworkConfigurations, resetNetworkConfigurations, } = createStoreState('networkConfigurations');
|
|
93
|
-
const createNetwork = (network, parser = (input) => input) => ({
|
|
94
|
-
blockExplorerUrls: network.blockExplorerUrls,
|
|
95
|
-
chainId: parser(network.chainId),
|
|
96
|
-
iconUrls: network.iconUrls,
|
|
97
|
-
lcdUrl: network.lcdUrl,
|
|
98
|
-
name: network.name,
|
|
99
|
-
nativeCurrency: network.nativeCurrency,
|
|
100
|
-
networkId: parser(network.networkId),
|
|
101
|
-
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
102
|
-
rpcUrls: network.rpcUrls,
|
|
103
|
-
vanityName: network.vanityName,
|
|
104
|
-
});
|
|
105
|
-
const overrideNetworks = (networkOverrides, networks) => {
|
|
106
|
-
if (!networkOverrides) {
|
|
107
|
-
return networks;
|
|
108
|
-
}
|
|
109
|
-
if (Array.isArray(networkOverrides)) {
|
|
110
|
-
return networkOverrides;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return networkOverrides(networks !== null && networks !== void 0 ? networks : []);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const useFetchNetworkConfigurations = ({ environmentId, projectSettings, evmNetworksOverrides, cosmosNetworkOverrides, }) => {
|
|
117
|
-
const { retrigger } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
var _a, _b, _c, _d;
|
|
119
|
-
if (!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks))
|
|
120
|
-
return Promise.resolve({});
|
|
121
|
-
const { networks } = projectSettings;
|
|
122
|
-
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
123
|
-
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
124
|
-
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
125
|
-
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
126
|
-
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
127
|
-
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
128
|
-
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
129
|
-
evmNetworks = overrideNetworks(evmNetworksOverrides, evmNetworks);
|
|
130
|
-
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
131
|
-
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
132
|
-
if (evmNetworksOverrides) {
|
|
133
|
-
if (Array.isArray(evmNetworksOverrides)) {
|
|
134
|
-
evmNetworks = evmNetworksOverrides;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return Promise.resolve({
|
|
141
|
-
cosmos: cosmosNetworks,
|
|
142
|
-
evm: evmNetworks,
|
|
143
|
-
solana: solanaNetworks,
|
|
144
|
-
starknet: starknetNetworks,
|
|
145
|
-
});
|
|
146
|
-
}), {
|
|
147
|
-
deps: [environmentId, projectSettings, evmNetworksOverrides],
|
|
148
|
-
enabled: Boolean(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks),
|
|
149
|
-
initialData: undefined,
|
|
150
|
-
onResolve: (networkConfigurations) => {
|
|
151
|
-
const expiry = new Date().getTime() + 60000 * 5;
|
|
152
|
-
setNetworkConfigurations({
|
|
153
|
-
expiresAt: expiry,
|
|
154
|
-
networkConfigurations: networkConfigurations,
|
|
155
|
-
});
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
useDynamicEvents('logout', retrigger);
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export { getNetworkConfigurations, resetNetworkConfigurations, setNetworkConfigurations, useFetchNetworkConfigurations, useNetworkConfigurations };
|