@dynamic-labs/sdk-react-core 4.0.0-alpha.3 → 4.0.0-alpha.5
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 +11 -12
- 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 +12 -14
- package/src/lib/context/DynamicContext/DynamicContext.js +12 -14
- package/src/lib/data/api/oauth/oauth.cjs +17 -2
- package/src/lib/data/api/oauth/oauth.d.ts +1 -0
- package/src/lib/data/api/oauth/oauth.js +17 -3
- package/src/lib/locale/en/translation.cjs +1 -1
- package/src/lib/locale/en/translation.js +1 -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/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/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/utils/hooks/useWalletOptions/useWalletOptions.cjs +1 -0
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +1 -0
- package/src/lib/views/NoAccess/NoAccess.cjs +4 -1
- package/src/lib/views/NoAccess/NoAccess.js +4 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.4...v4.0.0-alpha.5) (2024-09-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add isInstalledOnBrowser prop to wallet options in useWalletOptions ([#6976](https://github.com/dynamic-labs/DynamicAuth/issues/6976)) ([0fda409](https://github.com/dynamic-labs/DynamicAuth/commit/0fda409b293c83d73869d791c3d38ac421dcdecb))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **client:** return user profile when using sign in with external jwt ([#7004](https://github.com/dynamic-labs/DynamicAuth/issues/7004)) ([927cfb6](https://github.com/dynamic-labs/DynamicAuth/commit/927cfb69f3dd7f8b00e3f0f975277a84c99c830b))
|
|
13
|
+
* react-native-extension to include esm ([#6965](https://github.com/dynamic-labs/DynamicAuth/issues/6965)) ([336825b](https://github.com/dynamic-labs/DynamicAuth/commit/336825b50142002bbc67c6f8850bd63030bf384b))
|
|
14
|
+
|
|
15
|
+
## [4.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.3...v4.0.0-alpha.4) (2024-09-23)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* issue where builtin stream module was a dependency ([#6968](https://github.com/dynamic-labs/DynamicAuth/issues/6968)) ([0661129](https://github.com/dynamic-labs/DynamicAuth/commit/0661129920ba70ebbcd4d17ee5aa988c51d1b477))
|
|
21
|
+
* update in memory secure storage ([#6955](https://github.com/dynamic-labs/DynamicAuth/issues/6955)) ([697fc20](https://github.com/dynamic-labs/DynamicAuth/commit/697fc20740b243fa31ecf06e8b2ed9d09932a544))
|
|
22
|
+
|
|
2
23
|
## [4.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2024-09-20)
|
|
3
24
|
|
|
4
25
|
|
package/package.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "4.0.0-alpha.
|
|
6
|
+
var version = "4.0.0-alpha.5";
|
|
7
7
|
var dependencies = {
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "0.0.535",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
10
10
|
"country-list": "2.3.0",
|
|
11
11
|
formik: "2.2.9",
|
package/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "4.0.0-alpha.
|
|
2
|
+
var version = "4.0.0-alpha.5";
|
|
3
3
|
var dependencies = {
|
|
4
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
4
|
+
"@dynamic-labs/sdk-api-core": "0.0.535",
|
|
5
5
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
6
6
|
"country-list": "2.3.0",
|
|
7
7
|
formik: "2.2.9",
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
7
7
|
"directory": "packages/sdk-react-core"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
10
|
+
"@dynamic-labs/sdk-api-core": "0.0.535",
|
|
11
11
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
12
12
|
"country-list": "2.3.0",
|
|
13
13
|
"formik": "2.2.9",
|
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "4.0.0-alpha.
|
|
21
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
22
|
-
"@dynamic-labs/
|
|
23
|
-
"@dynamic-labs/
|
|
24
|
-
"@dynamic-labs/
|
|
25
|
-
"@dynamic-labs/
|
|
26
|
-
"@dynamic-labs/
|
|
27
|
-
"@dynamic-labs/
|
|
28
|
-
"@dynamic-labs/wallet-
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.3",
|
|
20
|
+
"@dynamic-labs/iconic": "4.0.0-alpha.5",
|
|
21
|
+
"@dynamic-labs/logger": "4.0.0-alpha.5",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "4.0.0-alpha.5",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.5",
|
|
24
|
+
"@dynamic-labs/store": "4.0.0-alpha.5",
|
|
25
|
+
"@dynamic-labs/types": "4.0.0-alpha.5",
|
|
26
|
+
"@dynamic-labs/utils": "4.0.0-alpha.5",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.5",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.5",
|
|
30
29
|
"eventemitter3": "5.0.1"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
@@ -37,13 +37,12 @@ const getValueRounded = (isNativeToken, transaction) => {
|
|
|
37
37
|
const calculateFiatPrice = (amount, price, decimals) => {
|
|
38
38
|
if (amount === undefined || isNaN(amount) || !decimals || !price)
|
|
39
39
|
return 0;
|
|
40
|
-
const
|
|
41
|
-
const paddedPrice = Number(price.toFixed(decimals));
|
|
40
|
+
const scalingFactor = Math.pow(10, decimals);
|
|
42
41
|
try {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
return Number(
|
|
42
|
+
const amountBigInt = BigInt(Math.round(amount * scalingFactor));
|
|
43
|
+
const priceBigInt = BigInt(Math.round(price * scalingFactor));
|
|
44
|
+
const fiatValue = (amountBigInt * priceBigInt) / BigInt(scalingFactor);
|
|
45
|
+
return Number(fiatValue) / scalingFactor;
|
|
47
46
|
}
|
|
48
47
|
catch (e) {
|
|
49
48
|
// Possible issue: getting wrong price / decimals.
|
|
@@ -33,13 +33,12 @@ const getValueRounded = (isNativeToken, transaction) => {
|
|
|
33
33
|
const calculateFiatPrice = (amount, price, decimals) => {
|
|
34
34
|
if (amount === undefined || isNaN(amount) || !decimals || !price)
|
|
35
35
|
return 0;
|
|
36
|
-
const
|
|
37
|
-
const paddedPrice = Number(price.toFixed(decimals));
|
|
36
|
+
const scalingFactor = Math.pow(10, decimals);
|
|
38
37
|
try {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
return Number(
|
|
38
|
+
const amountBigInt = BigInt(Math.round(amount * scalingFactor));
|
|
39
|
+
const priceBigInt = BigInt(Math.round(price * scalingFactor));
|
|
40
|
+
const fiatValue = (amountBigInt * priceBigInt) / BigInt(scalingFactor);
|
|
41
|
+
return Number(fiatValue) / scalingFactor;
|
|
43
42
|
}
|
|
44
43
|
catch (e) {
|
|
45
44
|
// Possible issue: getting wrong price / decimals.
|
|
@@ -122,7 +122,7 @@ var PhantomRedirectContext = require('../PhantomRedirectContext/PhantomRedirectC
|
|
|
122
122
|
var ReinitializeContextProvider = require('../ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
123
123
|
var SendBalanceContext = require('../SendBalanceContext/SendBalanceContext.cjs');
|
|
124
124
|
var UseNetworkValidation = require('../UseNetworkValidation/UseNetworkValidation.cjs');
|
|
125
|
-
var
|
|
125
|
+
var useNetworkConfigurationsFromProjectSettings = require('../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs');
|
|
126
126
|
var helpers = require('./helpers/helpers.cjs');
|
|
127
127
|
var useDisplayOrderState = require('./hooks/useDisplayOrderState/useDisplayOrderState.cjs');
|
|
128
128
|
var useEmailLoginState = require('./hooks/useEmailLoginState/useEmailLoginState.cjs');
|
|
@@ -208,6 +208,11 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
208
208
|
const [desktopUri, setDesktopUri] = React.useState('');
|
|
209
209
|
const [multiWalletWidgetState, setMultiWalletWidgetState, { awaiting_account_switch: [accountSwitchState], awaiting_signature: [awaitingSignatureState], },] = useMultiWalletWidgetState.useMultiWalletWidgetState();
|
|
210
210
|
const { settings: projectSettings$1 } = projectSettings.useProjectSettings();
|
|
211
|
+
const serverNetworkConfigurations = useNetworkConfigurationsFromProjectSettings.useNetworkConfigurationsFromProjectSettings({
|
|
212
|
+
cosmosNetworkOverrides: (_d = settings$1.overrides) === null || _d === void 0 ? void 0 : _d.cosmosNetworks,
|
|
213
|
+
evmNetworksOverrides: (_e = settings$1.overrides) === null || _e === void 0 ? void 0 : _e.evmNetworks,
|
|
214
|
+
projectSettings: projectSettings$1,
|
|
215
|
+
});
|
|
211
216
|
useSendDynamicProps.useSendDynamicProps({ environmentId, settings: settings$1 });
|
|
212
217
|
// Console warning for end user safety
|
|
213
218
|
useEndUserWarning.useEndUserWarning({
|
|
@@ -216,27 +221,20 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
216
221
|
});
|
|
217
222
|
const multiWallet = useMultiWallet.useMultiWallet({
|
|
218
223
|
isBridgeFlow,
|
|
219
|
-
multiWalletOverride: (
|
|
220
|
-
multiWalletSettings: (
|
|
224
|
+
multiWalletOverride: (_f = settings$1.overrides) === null || _f === void 0 ? void 0 : _f.multiWallet,
|
|
225
|
+
multiWalletSettings: (_g = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _g === void 0 ? void 0 : _g.multiWallet,
|
|
221
226
|
});
|
|
222
227
|
const multiAsset = useMultiAsset.useMultiAsset({
|
|
223
|
-
multiAssetOverride: (
|
|
224
|
-
multiAssetSettings: (
|
|
228
|
+
multiAssetOverride: (_h = settings$1.overrides) === null || _h === void 0 ? void 0 : _h.multiAsset,
|
|
229
|
+
multiAssetSettings: (_j = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _j === void 0 ? void 0 : _j.enableMultiAsset,
|
|
225
230
|
});
|
|
226
231
|
const showFiat = useShowFiat.useShowFiat({
|
|
227
|
-
showFiatOverride: (
|
|
228
|
-
showFiatSettings: (
|
|
232
|
+
showFiatOverride: (_k = settings$1.overrides) === null || _k === void 0 ? void 0 : _k.showFiat,
|
|
233
|
+
showFiatSettings: (_l = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _l === void 0 ? void 0 : _l.showFiat,
|
|
229
234
|
});
|
|
230
235
|
// Used inside useVerifyOnAwaitingSignature. Is legacy and should be removed asap
|
|
231
236
|
const [legacyIsVerifying, setLegacyIsVerifying] = React.useState(false);
|
|
232
237
|
const walletBook$1 = walletBook.useWalletBookCdn();
|
|
233
|
-
networkConfigurations.useFetchNetworkConfigurations({
|
|
234
|
-
cosmosNetworkOverrides: (_k = settings$1.overrides) === null || _k === void 0 ? void 0 : _k.cosmosNetworks,
|
|
235
|
-
environmentId,
|
|
236
|
-
evmNetworksOverrides: (_l = settings$1.overrides) === null || _l === void 0 ? void 0 : _l.evmNetworks,
|
|
237
|
-
projectSettings: projectSettings$1,
|
|
238
|
-
});
|
|
239
|
-
const { networkConfigurations: serverNetworkConfigurations } = networkConfigurations.useNetworkConfigurations();
|
|
240
238
|
const { imageUserInAccessList, imageUserNotInAccessList, displayName, appLogo, } = (projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.general) || {};
|
|
241
239
|
appLogoUrl = appLogo || appLogoUrl;
|
|
242
240
|
appName = displayName || appName;
|
|
@@ -118,7 +118,7 @@ import { PhantomRedirectContextProvider } from '../PhantomRedirectContext/Phanto
|
|
|
118
118
|
import { ReinitializeContextProvider } from '../ReinitializeContext/ReinitializeContextProvider.js';
|
|
119
119
|
import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceContext.js';
|
|
120
120
|
import { UseNetworkValidation } from '../UseNetworkValidation/UseNetworkValidation.js';
|
|
121
|
-
import {
|
|
121
|
+
import { useNetworkConfigurationsFromProjectSettings } from '../../utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js';
|
|
122
122
|
import { resolveNetworkValidationMode, initExpirationTime, getInitialView, getDeepLinkPreference } from './helpers/helpers.js';
|
|
123
123
|
import { useDisplayOrderState } from './hooks/useDisplayOrderState/useDisplayOrderState.js';
|
|
124
124
|
import { useEmailLoginState } from './hooks/useEmailLoginState/useEmailLoginState.js';
|
|
@@ -204,6 +204,11 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
204
204
|
const [desktopUri, setDesktopUri] = useState('');
|
|
205
205
|
const [multiWalletWidgetState, setMultiWalletWidgetState, { awaiting_account_switch: [accountSwitchState], awaiting_signature: [awaitingSignatureState], },] = useMultiWalletWidgetState();
|
|
206
206
|
const { settings: projectSettings } = useProjectSettings();
|
|
207
|
+
const serverNetworkConfigurations = useNetworkConfigurationsFromProjectSettings({
|
|
208
|
+
cosmosNetworkOverrides: (_d = settings.overrides) === null || _d === void 0 ? void 0 : _d.cosmosNetworks,
|
|
209
|
+
evmNetworksOverrides: (_e = settings.overrides) === null || _e === void 0 ? void 0 : _e.evmNetworks,
|
|
210
|
+
projectSettings,
|
|
211
|
+
});
|
|
207
212
|
useSendDynamicProps({ environmentId, settings });
|
|
208
213
|
// Console warning for end user safety
|
|
209
214
|
useEndUserWarning({
|
|
@@ -212,27 +217,20 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
212
217
|
});
|
|
213
218
|
const multiWallet = useMultiWallet({
|
|
214
219
|
isBridgeFlow,
|
|
215
|
-
multiWalletOverride: (
|
|
216
|
-
multiWalletSettings: (
|
|
220
|
+
multiWalletOverride: (_f = settings.overrides) === null || _f === void 0 ? void 0 : _f.multiWallet,
|
|
221
|
+
multiWalletSettings: (_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _g === void 0 ? void 0 : _g.multiWallet,
|
|
217
222
|
});
|
|
218
223
|
const multiAsset = useMultiAsset({
|
|
219
|
-
multiAssetOverride: (
|
|
220
|
-
multiAssetSettings: (
|
|
224
|
+
multiAssetOverride: (_h = settings.overrides) === null || _h === void 0 ? void 0 : _h.multiAsset,
|
|
225
|
+
multiAssetSettings: (_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _j === void 0 ? void 0 : _j.enableMultiAsset,
|
|
221
226
|
});
|
|
222
227
|
const showFiat = useShowFiat({
|
|
223
|
-
showFiatOverride: (
|
|
224
|
-
showFiatSettings: (
|
|
228
|
+
showFiatOverride: (_k = settings.overrides) === null || _k === void 0 ? void 0 : _k.showFiat,
|
|
229
|
+
showFiatSettings: (_l = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _l === void 0 ? void 0 : _l.showFiat,
|
|
225
230
|
});
|
|
226
231
|
// Used inside useVerifyOnAwaitingSignature. Is legacy and should be removed asap
|
|
227
232
|
const [legacyIsVerifying, setLegacyIsVerifying] = useState(false);
|
|
228
233
|
const walletBook = useWalletBookCdn();
|
|
229
|
-
useFetchNetworkConfigurations({
|
|
230
|
-
cosmosNetworkOverrides: (_k = settings.overrides) === null || _k === void 0 ? void 0 : _k.cosmosNetworks,
|
|
231
|
-
environmentId,
|
|
232
|
-
evmNetworksOverrides: (_l = settings.overrides) === null || _l === void 0 ? void 0 : _l.evmNetworks,
|
|
233
|
-
projectSettings,
|
|
234
|
-
});
|
|
235
|
-
const { networkConfigurations: serverNetworkConfigurations } = useNetworkConfigurations();
|
|
236
234
|
const { imageUserInAccessList, imageUserNotInAccessList, displayName, appLogo, } = (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.general) || {};
|
|
237
235
|
appLogoUrl = appLogo || appLogoUrl;
|
|
238
236
|
appName = displayName || appName;
|
|
@@ -29,8 +29,9 @@ const initAuth = (environmentId, providerType, oauthInitAuthRequest) => _tslib._
|
|
|
29
29
|
providerType,
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
catch (
|
|
33
|
-
logger.logger.error(
|
|
32
|
+
catch (err) {
|
|
33
|
+
logger.logger.error(err);
|
|
34
|
+
throw err;
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
const verifyOAuth = (environmentId_1, providerType_1, _a) => _tslib.__awaiter(void 0, [environmentId_1, providerType_1, _a], void 0, function* (environmentId, providerType, { code, codeVerifier, state }) {
|
|
@@ -143,6 +144,19 @@ const telegramSignIn = (environmentId, oauthResultRequest) => _tslib.__awaiter(v
|
|
|
143
144
|
return handleSignInError(e);
|
|
144
145
|
}
|
|
145
146
|
});
|
|
147
|
+
const isUserLinkedWithTelegram = (environmentId, oauthResultRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
+
const telegramCheckAuthRequest = {
|
|
149
|
+
environmentId,
|
|
150
|
+
oauthResultRequest,
|
|
151
|
+
};
|
|
152
|
+
try {
|
|
153
|
+
yield api.sdkApi().telegramCheckAuth(telegramCheckAuthRequest);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
146
160
|
const telegramVerify = (environmentId, oauthResultRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
147
161
|
const telegramVerifyRequest = {
|
|
148
162
|
environmentId,
|
|
@@ -195,6 +209,7 @@ exports.farcasterSignIn = farcasterSignIn;
|
|
|
195
209
|
exports.farcasterVerify = farcasterVerify;
|
|
196
210
|
exports.getOAuthResult = getOAuthResult;
|
|
197
211
|
exports.initAuth = initAuth;
|
|
212
|
+
exports.isUserLinkedWithTelegram = isUserLinkedWithTelegram;
|
|
198
213
|
exports.signInOAuth = signInOAuth;
|
|
199
214
|
exports.telegramSignIn = telegramSignIn;
|
|
200
215
|
exports.telegramVerify = telegramVerify;
|
|
@@ -13,4 +13,5 @@ export declare const getOAuthResult: (environmentId: string, providerType: Provi
|
|
|
13
13
|
export declare const farcasterSignIn: (environmentId: string, farcasterSignInRequest: FarcasterSignInRequest) => Promise<UserProfile | undefined>;
|
|
14
14
|
export declare const farcasterVerify: (farcasterVerifyRequest: FarcasterVerifyRequest) => Promise<UserProfile | undefined>;
|
|
15
15
|
export declare const telegramSignIn: (environmentId: string, oauthResultRequest: OauthResultRequest) => Promise<UserProfile | undefined>;
|
|
16
|
+
export declare const isUserLinkedWithTelegram: (environmentId: string, oauthResultRequest: OauthResultRequest) => Promise<boolean | undefined>;
|
|
16
17
|
export declare const telegramVerify: (environmentId: string, oauthResultRequest: OauthResultRequest) => Promise<UserProfile | undefined>;
|
|
@@ -25,8 +25,9 @@ const initAuth = (environmentId, providerType, oauthInitAuthRequest) => __awaite
|
|
|
25
25
|
providerType,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
catch (
|
|
29
|
-
logger.error(
|
|
28
|
+
catch (err) {
|
|
29
|
+
logger.error(err);
|
|
30
|
+
throw err;
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
const verifyOAuth = (environmentId_1, providerType_1, _a) => __awaiter(void 0, [environmentId_1, providerType_1, _a], void 0, function* (environmentId, providerType, { code, codeVerifier, state }) {
|
|
@@ -139,6 +140,19 @@ const telegramSignIn = (environmentId, oauthResultRequest) => __awaiter(void 0,
|
|
|
139
140
|
return handleSignInError(e);
|
|
140
141
|
}
|
|
141
142
|
});
|
|
143
|
+
const isUserLinkedWithTelegram = (environmentId, oauthResultRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
const telegramCheckAuthRequest = {
|
|
145
|
+
environmentId,
|
|
146
|
+
oauthResultRequest,
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
yield sdkApi().telegramCheckAuth(telegramCheckAuthRequest);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
142
156
|
const telegramVerify = (environmentId, oauthResultRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
157
|
const telegramVerifyRequest = {
|
|
144
158
|
environmentId,
|
|
@@ -187,4 +201,4 @@ const handleSignInError = (e) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
187
201
|
return undefined;
|
|
188
202
|
});
|
|
189
203
|
|
|
190
|
-
export { farcasterSignIn, farcasterVerify, getOAuthResult, initAuth, signInOAuth, telegramSignIn, telegramVerify, unlinkOAuth, verifyOAuth };
|
|
204
|
+
export { farcasterSignIn, farcasterVerify, getOAuthResult, initAuth, isUserLinkedWithTelegram, signInOAuth, telegramSignIn, telegramVerify, unlinkOAuth, verifyOAuth };
|
|
@@ -1781,7 +1781,7 @@ const translation = {
|
|
|
1781
1781
|
insufficient_funds: 'Insufficient funds due to gas price increase from estimate. Please add {{amountLeft}} {{currencySymbol}} to continue.',
|
|
1782
1782
|
insufficient_gas_funds: 'Insufficient gas funds. Please add {{amountLeft}} {{currencySymbol}} to continue.',
|
|
1783
1783
|
failed_simulation: 'Unable to simulate transaction, funds may be lost if submitted.',
|
|
1784
|
-
not_enough_solana: 'Insufficient funds
|
|
1784
|
+
not_enough_solana: 'Insufficient funds, your SOL balance after the transaction must be at least 0.001.',
|
|
1785
1785
|
},
|
|
1786
1786
|
error_message: {
|
|
1787
1787
|
gas_not_sponsored: 'The gas fee has increased. Confirm if you still want to complete this transaction.',
|
|
@@ -1777,7 +1777,7 @@ const translation = {
|
|
|
1777
1777
|
insufficient_funds: 'Insufficient funds due to gas price increase from estimate. Please add {{amountLeft}} {{currencySymbol}} to continue.',
|
|
1778
1778
|
insufficient_gas_funds: 'Insufficient gas funds. Please add {{amountLeft}} {{currencySymbol}} to continue.',
|
|
1779
1779
|
failed_simulation: 'Unable to simulate transaction, funds may be lost if submitted.',
|
|
1780
|
-
not_enough_solana: 'Insufficient funds
|
|
1780
|
+
not_enough_solana: 'Insufficient funds, your SOL balance after the transaction must be at least 0.001.',
|
|
1781
1781
|
},
|
|
1782
1782
|
error_message: {
|
|
1783
1783
|
gas_not_sponsored: 'The gas fee has increased. Confirm if you still want to complete this transaction.',
|
|
@@ -7,7 +7,7 @@ var utils = require('@dynamic-labs/utils');
|
|
|
7
7
|
var localStorage = require('../../../../utils/constants/localStorage.cjs');
|
|
8
8
|
|
|
9
9
|
const clearExpiredData = (store) => {
|
|
10
|
-
const { projectSettings,
|
|
10
|
+
const { projectSettings, user } = store.getState();
|
|
11
11
|
// TODO: we can clean this up once we move wallet info to the store
|
|
12
12
|
const [connectedWalletData] = utils.StorageService.getItem(localStorage.CONNECTED_WALLETS_INFO) || [];
|
|
13
13
|
const shouldRemoveSettingsAndConfigs = !user && !connectedWalletData;
|
|
@@ -18,11 +18,6 @@ const clearExpiredData = (store) => {
|
|
|
18
18
|
projectSettings: store.getInitialState().projectSettings,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
if (isExpired(networkConfigurations)) {
|
|
22
|
-
store.setState({
|
|
23
|
-
networkConfigurations: store.getInitialState().networkConfigurations,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
21
|
return store;
|
|
27
22
|
};
|
|
28
23
|
|
|
@@ -3,7 +3,7 @@ import { StorageService } from '@dynamic-labs/utils';
|
|
|
3
3
|
import { CONNECTED_WALLETS_INFO } from '../../../../utils/constants/localStorage.js';
|
|
4
4
|
|
|
5
5
|
const clearExpiredData = (store) => {
|
|
6
|
-
const { projectSettings,
|
|
6
|
+
const { projectSettings, user } = store.getState();
|
|
7
7
|
// TODO: we can clean this up once we move wallet info to the store
|
|
8
8
|
const [connectedWalletData] = StorageService.getItem(CONNECTED_WALLETS_INFO) || [];
|
|
9
9
|
const shouldRemoveSettingsAndConfigs = !user && !connectedWalletData;
|
|
@@ -14,11 +14,6 @@ const clearExpiredData = (store) => {
|
|
|
14
14
|
projectSettings: store.getInitialState().projectSettings,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
if (isExpired(networkConfigurations)) {
|
|
18
|
-
store.setState({
|
|
19
|
-
networkConfigurations: store.getInitialState().networkConfigurations,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
17
|
return store;
|
|
23
18
|
};
|
|
24
19
|
|
|
@@ -11,10 +11,6 @@ const createInitialStates = ({ environmentId, }) => ({
|
|
|
11
11
|
loadingAndLifecycle: {
|
|
12
12
|
sessionValidation: false,
|
|
13
13
|
},
|
|
14
|
-
networkConfigurations: {
|
|
15
|
-
expiresAt: undefined,
|
|
16
|
-
networkConfigurations: undefined,
|
|
17
|
-
},
|
|
18
14
|
projectSettings: { expiresAt: undefined, settings: undefined },
|
|
19
15
|
sendBalanceState: {
|
|
20
16
|
amount: undefined,
|
|
@@ -36,7 +32,6 @@ const createInitialStates = ({ environmentId, }) => ({
|
|
|
36
32
|
*/
|
|
37
33
|
const transformStateForLocalStorage = (state) => ({
|
|
38
34
|
environmentId: state.environmentId,
|
|
39
|
-
networkConfigurations: state.networkConfigurations,
|
|
40
35
|
projectSettings: state.projectSettings,
|
|
41
36
|
user: state.user,
|
|
42
37
|
});
|
|
@@ -7,10 +7,6 @@ const createInitialStates = ({ environmentId, }) => ({
|
|
|
7
7
|
loadingAndLifecycle: {
|
|
8
8
|
sessionValidation: false,
|
|
9
9
|
},
|
|
10
|
-
networkConfigurations: {
|
|
11
|
-
expiresAt: undefined,
|
|
12
|
-
networkConfigurations: undefined,
|
|
13
|
-
},
|
|
14
10
|
projectSettings: { expiresAt: undefined, settings: undefined },
|
|
15
11
|
sendBalanceState: {
|
|
16
12
|
amount: undefined,
|
|
@@ -32,7 +28,6 @@ const createInitialStates = ({ environmentId, }) => ({
|
|
|
32
28
|
*/
|
|
33
29
|
const transformStateForLocalStorage = (state) => ({
|
|
34
30
|
environmentId: state.environmentId,
|
|
35
|
-
networkConfigurations: state.networkConfigurations,
|
|
36
31
|
projectSettings: state.projectSettings,
|
|
37
32
|
user: state.user,
|
|
38
33
|
});
|
package/src/lib/store/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectSettings, TokenBalance } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
import {
|
|
2
|
+
import { UserProfile } from '@dynamic-labs/types';
|
|
3
3
|
import { WalletOption } from '../shared/types/wallets';
|
|
4
4
|
export type SdkStoreProps = {
|
|
5
5
|
environmentId: string;
|
|
@@ -9,7 +9,6 @@ export type SdkStore = {
|
|
|
9
9
|
environmentId: string;
|
|
10
10
|
user: UserProfile | undefined;
|
|
11
11
|
projectSettings: StoredProjectSettings;
|
|
12
|
-
networkConfigurations: StoredNetworkConfigurations;
|
|
13
12
|
tokenBalancesState: TokenBalancesState;
|
|
14
13
|
sendBalanceState: SendBalanceState;
|
|
15
14
|
walletConnectorOptions: WalletOption[];
|
|
@@ -36,10 +35,6 @@ export type StoredProjectSettings = {
|
|
|
36
35
|
expiresAt: number | undefined;
|
|
37
36
|
settings: ProjectSettings | undefined;
|
|
38
37
|
};
|
|
39
|
-
export type StoredNetworkConfigurations = {
|
|
40
|
-
expiresAt: number | undefined;
|
|
41
|
-
networkConfigurations: NetworkConfigurationMap | undefined;
|
|
42
|
-
};
|
|
43
38
|
export type StateConfig = {
|
|
44
39
|
[K in keyof SdkStore]: {
|
|
45
40
|
initialValue: SdkStore[K];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useNetworkConfigurationsFromProjectSettings } from './useNetworkConfigurationsFromProjectSettings';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, }) => React.useMemo(() => {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
11
|
+
if (!networks)
|
|
12
|
+
return {};
|
|
13
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
14
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
15
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
16
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
17
|
+
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
18
|
+
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
19
|
+
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
20
|
+
evmNetworks = overrideNetworks(evmNetworksOverrides, evmNetworks);
|
|
21
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
22
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
23
|
+
if (evmNetworksOverrides) {
|
|
24
|
+
if (Array.isArray(evmNetworksOverrides)) {
|
|
25
|
+
evmNetworks = evmNetworksOverrides;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const networkConfigurations = {
|
|
32
|
+
cosmos: cosmosNetworks,
|
|
33
|
+
evm: evmNetworks,
|
|
34
|
+
solana: solanaNetworks,
|
|
35
|
+
starknet: starknetNetworks,
|
|
36
|
+
};
|
|
37
|
+
return networkConfigurations;
|
|
38
|
+
}, [projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks, cosmosNetworkOverrides, evmNetworksOverrides]);
|
|
39
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
40
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
41
|
+
chainId: parser(network.chainId),
|
|
42
|
+
iconUrls: network.iconUrls,
|
|
43
|
+
lcdUrl: network.lcdUrl,
|
|
44
|
+
name: network.name,
|
|
45
|
+
nativeCurrency: network.nativeCurrency,
|
|
46
|
+
networkId: parser(network.networkId),
|
|
47
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
48
|
+
rpcUrls: network.rpcUrls,
|
|
49
|
+
vanityName: network.vanityName,
|
|
50
|
+
});
|
|
51
|
+
const overrideNetworks = (networkOverrides, networks) => {
|
|
52
|
+
if (!networkOverrides) {
|
|
53
|
+
return networks;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(networkOverrides)) {
|
|
56
|
+
return networkOverrides;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return networkOverrides(networks !== null && networks !== void 0 ? networks : []);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.useNetworkConfigurationsFromProjectSettings = useNetworkConfigurationsFromProjectSettings;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { NetworksOverrides } from '../../../context/DynamicContext';
|
|
3
|
+
type UseNetworkConfigurationsFromProjectSettingsProps = {
|
|
4
|
+
projectSettings: ProjectSettings | undefined;
|
|
5
|
+
evmNetworksOverrides?: NetworksOverrides;
|
|
6
|
+
cosmosNetworkOverrides?: NetworksOverrides;
|
|
7
|
+
};
|
|
8
|
+
export declare const useNetworkConfigurationsFromProjectSettings: ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, }: UseNetworkConfigurationsFromProjectSettingsProps) => {};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, }) => useMemo(() => {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
7
|
+
if (!networks)
|
|
8
|
+
return {};
|
|
9
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
10
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
11
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
12
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
13
|
+
let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
14
|
+
cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
|
|
15
|
+
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
16
|
+
evmNetworks = overrideNetworks(evmNetworksOverrides, evmNetworks);
|
|
17
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
18
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
19
|
+
if (evmNetworksOverrides) {
|
|
20
|
+
if (Array.isArray(evmNetworksOverrides)) {
|
|
21
|
+
evmNetworks = evmNetworksOverrides;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
evmNetworks = evmNetworksOverrides(evmNetworks !== null && evmNetworks !== void 0 ? evmNetworks : []);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const networkConfigurations = {
|
|
28
|
+
cosmos: cosmosNetworks,
|
|
29
|
+
evm: evmNetworks,
|
|
30
|
+
solana: solanaNetworks,
|
|
31
|
+
starknet: starknetNetworks,
|
|
32
|
+
};
|
|
33
|
+
return networkConfigurations;
|
|
34
|
+
}, [projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks, cosmosNetworkOverrides, evmNetworksOverrides]);
|
|
35
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
36
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
37
|
+
chainId: parser(network.chainId),
|
|
38
|
+
iconUrls: network.iconUrls,
|
|
39
|
+
lcdUrl: network.lcdUrl,
|
|
40
|
+
name: network.name,
|
|
41
|
+
nativeCurrency: network.nativeCurrency,
|
|
42
|
+
networkId: parser(network.networkId),
|
|
43
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
44
|
+
rpcUrls: network.rpcUrls,
|
|
45
|
+
vanityName: network.vanityName,
|
|
46
|
+
});
|
|
47
|
+
const overrideNetworks = (networkOverrides, networks) => {
|
|
48
|
+
if (!networkOverrides) {
|
|
49
|
+
return networks;
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(networkOverrides)) {
|
|
52
|
+
return networkOverrides;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return networkOverrides(networks !== null && networks !== void 0 ? networks : []);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { useNetworkConfigurationsFromProjectSettings };
|
|
@@ -22,6 +22,7 @@ require('../../../shared/consts/index.cjs');
|
|
|
22
22
|
var isProviderEnabled = require('../../functions/isProviderEnabled/isProviderEnabled.cjs');
|
|
23
23
|
require('../../../config/ApiEndpoint.cjs');
|
|
24
24
|
require('../../../store/state/user/user.cjs');
|
|
25
|
+
var oauth = require('../../../data/api/oauth/oauth.cjs');
|
|
25
26
|
require('../../../locale/locale.cjs');
|
|
26
27
|
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
27
28
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
@@ -94,23 +95,34 @@ require('../../../store/state/tokenBalances.cjs');
|
|
|
94
95
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
95
96
|
|
|
96
97
|
const useTelegramLogin = () => {
|
|
97
|
-
const { sdkHasLoaded, user, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
|
+
const { sdkHasLoaded, user, projectSettings, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
99
|
const providers = (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) || [];
|
|
99
100
|
const { completeConnection } = useSocialAuth.useSocialAuth({
|
|
100
101
|
sessionTimeout: 20000,
|
|
101
102
|
});
|
|
102
|
-
const
|
|
103
|
+
const getTelegramAuthToken = () => {
|
|
103
104
|
// in non-browser environments like Node.js
|
|
104
105
|
// or during server-side rendering (e.g., with frameworks like Next.js).
|
|
105
106
|
if (typeof window === 'undefined') {
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
108
109
|
const search = new URLSearchParams(window.location.search);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
return search.get('telegramAuthToken') || undefined;
|
|
111
|
+
};
|
|
112
|
+
const canProceedWithTelegram = (telegramAuthToken) => isProviderEnabled.isProviderEnabled(providers, sdkApiCore.ProviderEnum.Telegram) &&
|
|
113
|
+
sdkHasLoaded &&
|
|
114
|
+
!user &&
|
|
115
|
+
telegramAuthToken;
|
|
116
|
+
const isAuthWithTelegram = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
118
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
return oauth.isUserLinkedWithTelegram(environmentId, { telegramAuthToken });
|
|
122
|
+
});
|
|
123
|
+
const telegramSignIn = (...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, } = {}) {
|
|
124
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
125
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
114
126
|
return;
|
|
115
127
|
}
|
|
116
128
|
yield completeConnection({
|
|
@@ -122,6 +134,7 @@ const useTelegramLogin = () => {
|
|
|
122
134
|
});
|
|
123
135
|
});
|
|
124
136
|
return {
|
|
137
|
+
isAuthWithTelegram,
|
|
125
138
|
telegramSignIn,
|
|
126
139
|
};
|
|
127
140
|
};
|
|
@@ -18,6 +18,7 @@ import '../../../shared/consts/index.js';
|
|
|
18
18
|
import { isProviderEnabled } from '../../functions/isProviderEnabled/isProviderEnabled.js';
|
|
19
19
|
import '../../../config/ApiEndpoint.js';
|
|
20
20
|
import '../../../store/state/user/user.js';
|
|
21
|
+
import { isUserLinkedWithTelegram } from '../../../data/api/oauth/oauth.js';
|
|
21
22
|
import '../../../locale/locale.js';
|
|
22
23
|
import '../../../store/state/projectSettings/projectSettings.js';
|
|
23
24
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -90,23 +91,34 @@ import '../../../store/state/tokenBalances.js';
|
|
|
90
91
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
91
92
|
|
|
92
93
|
const useTelegramLogin = () => {
|
|
93
|
-
const { sdkHasLoaded, user, projectSettings } = useInternalDynamicContext();
|
|
94
|
+
const { sdkHasLoaded, user, projectSettings, environmentId } = useInternalDynamicContext();
|
|
94
95
|
const providers = (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) || [];
|
|
95
96
|
const { completeConnection } = useSocialAuth({
|
|
96
97
|
sessionTimeout: 20000,
|
|
97
98
|
});
|
|
98
|
-
const
|
|
99
|
+
const getTelegramAuthToken = () => {
|
|
99
100
|
// in non-browser environments like Node.js
|
|
100
101
|
// or during server-side rendering (e.g., with frameworks like Next.js).
|
|
101
102
|
if (typeof window === 'undefined') {
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
104
105
|
const search = new URLSearchParams(window.location.search);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
return search.get('telegramAuthToken') || undefined;
|
|
107
|
+
};
|
|
108
|
+
const canProceedWithTelegram = (telegramAuthToken) => isProviderEnabled(providers, ProviderEnum.Telegram) &&
|
|
109
|
+
sdkHasLoaded &&
|
|
110
|
+
!user &&
|
|
111
|
+
telegramAuthToken;
|
|
112
|
+
const isAuthWithTelegram = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
114
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
return isUserLinkedWithTelegram(environmentId, { telegramAuthToken });
|
|
118
|
+
});
|
|
119
|
+
const telegramSignIn = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ forceCreateUser = false, } = {}) {
|
|
120
|
+
const telegramAuthToken = getTelegramAuthToken();
|
|
121
|
+
if (!canProceedWithTelegram(telegramAuthToken)) {
|
|
110
122
|
return;
|
|
111
123
|
}
|
|
112
124
|
yield completeConnection({
|
|
@@ -118,6 +130,7 @@ const useTelegramLogin = () => {
|
|
|
118
130
|
});
|
|
119
131
|
});
|
|
120
132
|
return {
|
|
133
|
+
isAuthWithTelegram,
|
|
121
134
|
telegramSignIn,
|
|
122
135
|
};
|
|
123
136
|
};
|
|
@@ -104,7 +104,10 @@ require('qrcode');
|
|
|
104
104
|
const NoAccess = () => {
|
|
105
105
|
const { deniedAddress, setDeniedAddress, setDeniedOauthProvider, deniedOauthProvider, deniedOauthUsername, } = AccessDeniedContext.useAccessDeniedContext();
|
|
106
106
|
const { t } = reactI18next.useTranslation();
|
|
107
|
-
|
|
107
|
+
// deniedOauthProvider can be undefined
|
|
108
|
+
const accessIcon = deniedOauthProvider
|
|
109
|
+
? iconic.findSocialIcon(deniedOauthProvider)
|
|
110
|
+
: undefined;
|
|
108
111
|
const { selectedWalletConnector: walletConnector, socialMediaIconUrl, notInTheListImageUrl, accessDeniedButton, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
109
112
|
const { displayedDestination: email } = VerificationContext.useVerification();
|
|
110
113
|
const { goToInitialView } = ViewContext.useViewContext();
|
|
@@ -100,7 +100,10 @@ import 'qrcode';
|
|
|
100
100
|
const NoAccess = () => {
|
|
101
101
|
const { deniedAddress, setDeniedAddress, setDeniedOauthProvider, deniedOauthProvider, deniedOauthUsername, } = useAccessDeniedContext();
|
|
102
102
|
const { t } = useTranslation();
|
|
103
|
-
|
|
103
|
+
// deniedOauthProvider can be undefined
|
|
104
|
+
const accessIcon = deniedOauthProvider
|
|
105
|
+
? findSocialIcon(deniedOauthProvider)
|
|
106
|
+
: undefined;
|
|
104
107
|
const { selectedWalletConnector: walletConnector, socialMediaIconUrl, notInTheListImageUrl, accessDeniedButton, } = useInternalDynamicContext();
|
|
105
108
|
const { displayedDestination: email } = useVerification();
|
|
106
109
|
const { goToInitialView } = useViewContext();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './networkConfigurations';
|
|
@@ -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 };
|