@dynamic-labs/sdk-react-core 2.3.9 → 2.4.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 +20 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +1 -1
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +13 -9
- package/src/lib/context/DynamicContext/DynamicContext.js +14 -10
- package/src/lib/context/DynamicContext/types/index.d.ts +5 -1
- package/src/lib/data/api/oauth/oauth.cjs +0 -18
- package/src/lib/data/api/oauth/oauth.js +1 -18
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.cjs +1 -1
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.js +2 -2
- package/src/lib/shared/utils/functions/chain/getChainDisplayName.cjs +1 -1
- package/src/lib/shared/utils/functions/chain/getChainDisplayName.js +2 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +23 -75
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +26 -78
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +1 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +1 -1
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs +1 -1
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js +2 -2
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +2 -2
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +3 -3
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.cjs +2 -2
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.js +3 -3
- package/src/lib/views/LoginView/LoginViewSection/LoginViewSection.cjs +20 -16
- package/src/lib/views/LoginView/LoginViewSection/LoginViewSection.js +20 -16
- package/src/lib/views/LoginView/sections/ToggleableSection/ToggleableSection.d.ts +1 -2
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +1 -1
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +2 -2
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.js +2 -2
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.4.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.3.10...v2.4.0) (2024-08-17)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add chain display value override to the dynamic props ([bf57738](https://github.com/dynamic-labs/DynamicAuth/commit/bf577387d52ef0748e958b519218c3da6ddbbc64))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* display QR code when selecting wallet connect ([#6605](https://github.com/dynamic-labs/DynamicAuth/issues/6605)) ([#6615](https://github.com/dynamic-labs/DynamicAuth/issues/6615)) ([61d51c0](https://github.com/dynamic-labs/DynamicAuth/commit/61d51c0c40f71a26e171da82f4a78028990ddc21))
|
|
13
|
+
* fix jwt length when signing with embedded wallets ([#6638](https://github.com/dynamic-labs/DynamicAuth/issues/6638))
|
|
14
|
+
|
|
15
|
+
### [2.3.10](https://github.com/dynamic-labs/DynamicAuth/compare/v2.3.9...v2.3.10) (2024-08-15)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* twitter should no longer rely polling for oauth flow ([#6606](https://github.com/dynamic-labs/DynamicAuth/issues/6606)) ([38906ab](https://github.com/dynamic-labs/DynamicAuth/commit/38906ab02b41fd02d7993e229072290d046dbc0e))
|
|
21
|
+
|
|
2
22
|
### [2.3.9](https://github.com/dynamic-labs/DynamicAuth/compare/v2.3.8...v2.3.9) (2024-08-13)
|
|
3
23
|
|
|
4
24
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -17,18 +17,18 @@
|
|
|
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": "2.
|
|
21
|
-
"@dynamic-labs/logger": "2.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "2.
|
|
23
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.
|
|
24
|
-
"@dynamic-labs/rpc-provider-solana": "2.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "2.
|
|
26
|
-
"@dynamic-labs/store": "2.
|
|
27
|
-
"@dynamic-labs/types": "2.
|
|
28
|
-
"@dynamic-labs/utils": "2.
|
|
29
|
-
"@dynamic-labs/viem-utils": "2.
|
|
30
|
-
"@dynamic-labs/wallet-book": "2.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "2.
|
|
20
|
+
"@dynamic-labs/iconic": "2.4.0",
|
|
21
|
+
"@dynamic-labs/logger": "2.4.0",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.4.0",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.4.0",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.4.0",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.4.0",
|
|
26
|
+
"@dynamic-labs/store": "2.4.0",
|
|
27
|
+
"@dynamic-labs/types": "2.4.0",
|
|
28
|
+
"@dynamic-labs/utils": "2.4.0",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.4.0",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.4.0",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.4.0",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -88,7 +88,7 @@ require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs')
|
|
|
88
88
|
const NonNetworkSwitchingSupportedControl = ({ walletConnector, className, showNetworkName = false, }) => {
|
|
89
89
|
const { chain, isLoading } = useFetchChain.useFetchChain(walletConnector);
|
|
90
90
|
const chainName = (chain === null || chain === void 0 ? void 0 : chain.name) || '';
|
|
91
|
-
const ChainIcon = getChainIcon.getChainIcon(
|
|
91
|
+
const ChainIcon = getChainIcon.getChainIcon(walletConnector.connectedChain || '');
|
|
92
92
|
if (isLoading) {
|
|
93
93
|
return jsxRuntime.jsx(NetworkControlSkeleton.NetworkControlSkeleton, { className: className });
|
|
94
94
|
}
|
|
@@ -84,7 +84,7 @@ import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
|
84
84
|
const NonNetworkSwitchingSupportedControl = ({ walletConnector, className, showNetworkName = false, }) => {
|
|
85
85
|
const { chain, isLoading } = useFetchChain(walletConnector);
|
|
86
86
|
const chainName = (chain === null || chain === void 0 ? void 0 : chain.name) || '';
|
|
87
|
-
const ChainIcon = getChainIcon(
|
|
87
|
+
const ChainIcon = getChainIcon(walletConnector.connectedChain || '');
|
|
88
88
|
if (isLoading) {
|
|
89
89
|
return jsx(NetworkControlSkeleton, { className: className });
|
|
90
90
|
}
|
|
@@ -142,7 +142,7 @@ const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9
|
|
|
142
142
|
const DynamicContext = React.createContext(undefined);
|
|
143
143
|
/** The context provider itself we only use internally */
|
|
144
144
|
const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, locale: locale$1, enableInstrumentation = false, }) => {
|
|
145
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
145
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
146
146
|
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, defaultPhoneInputIso2, apiBaseUrl, coinbaseWalletPreference, enableConnectOnlyFallback = false, deepLinkPreference: deepLinkPreferenceProp = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, recommendedWallets, hideEmbeddedWalletTransactionUIs, handlers, headless = false, } = settings$1;
|
|
147
147
|
localStorage.LocalStorage.setSuffix(settings$1.localStorageSuffix);
|
|
148
148
|
/**
|
|
@@ -152,13 +152,17 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
152
152
|
environmentId,
|
|
153
153
|
storageSuffix: settings$1.localStorageSuffix,
|
|
154
154
|
});
|
|
155
|
+
/**
|
|
156
|
+
* Sets the chain info overrides if they are present
|
|
157
|
+
*/
|
|
158
|
+
walletConnectorCore.setChainInfoOverrides((_a = settings$1.overrides) === null || _a === void 0 ? void 0 : _a.chainDisplayValues);
|
|
155
159
|
/**
|
|
156
160
|
* For backwards compatibility, we allow the client to pass in
|
|
157
161
|
* `eventsCallbacks` instead of `events`. It should remove this
|
|
158
162
|
* in version 3.0.0.
|
|
159
163
|
* ticket: QNTM-1504
|
|
160
164
|
*/
|
|
161
|
-
const events = (
|
|
165
|
+
const events = (_b = settings$1.events) !== null && _b !== void 0 ? _b : settings$1.eventsCallbacks;
|
|
162
166
|
const networkValidationMode = helpers.resolveNetworkValidationMode({
|
|
163
167
|
bridgeChains: settings$1.bridgeChains,
|
|
164
168
|
networkValidationMode: settings$1.networkValidationMode,
|
|
@@ -171,14 +175,14 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
171
175
|
logger$1.logger.setLogLevel(logLevel);
|
|
172
176
|
walletConnectorCore.logger.setLogLevel(logLevel);
|
|
173
177
|
}
|
|
174
|
-
catch (
|
|
178
|
+
catch (_k) {
|
|
175
179
|
// logger could be messing up with SSR so we are catching the errors
|
|
176
180
|
/* empty */
|
|
177
181
|
}
|
|
178
182
|
if (environmentId === PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID) {
|
|
179
183
|
logger$1.logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
|
|
180
184
|
}
|
|
181
|
-
ApiEndpoint.setBaseUrl((
|
|
185
|
+
ApiEndpoint.setBaseUrl((_c = process.env.DYNAMIC_API_BASE_URL) !== null && _c !== void 0 ? _c : apiBaseUrl);
|
|
182
186
|
const i18nSDKInstance = locale.Locale.setup(locale$1);
|
|
183
187
|
const isBridgeFlow = Boolean(bridgeChains);
|
|
184
188
|
const deepLinkPreference = helpers.getDeepLinkPreference(deepLinkPreferenceProp, isBridgeFlow);
|
|
@@ -216,8 +220,8 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
216
220
|
useSendDynamicProps.useSendDynamicProps({ environmentId, settings: settings$1 });
|
|
217
221
|
const multiWallet = useMultiWallet.useMultiWallet({
|
|
218
222
|
isBridgeFlow,
|
|
219
|
-
multiWalletOverride: (
|
|
220
|
-
multiWalletSettings: (
|
|
223
|
+
multiWalletOverride: (_d = settings$1.overrides) === null || _d === void 0 ? void 0 : _d.multiWallet,
|
|
224
|
+
multiWalletSettings: (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.multiWallet,
|
|
221
225
|
});
|
|
222
226
|
// ensures that when user comes back to site and primary wallet is out of sync, we don't show widget popup
|
|
223
227
|
const [showWidgetStatePopup, setShowWidgetStatePopup] = React.useState(!multiWallet);
|
|
@@ -226,7 +230,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
226
230
|
const walletBook$1 = walletBook.useWalletBookCdn();
|
|
227
231
|
const { networkConfigurations: serverNetworkConfigurations } = useNetworkConfigurations.useNetworkConfigurations({
|
|
228
232
|
environmentId,
|
|
229
|
-
evmNetworksOverrides: (
|
|
233
|
+
evmNetworksOverrides: (_f = settings$1.overrides) === null || _f === void 0 ? void 0 : _f.evmNetworks,
|
|
230
234
|
projectSettings,
|
|
231
235
|
});
|
|
232
236
|
const { imageUserInAccessList, imageUserNotInAccessList, displayName, appLogo, } = (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.general) || {};
|
|
@@ -238,7 +242,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
238
242
|
appLogoUrl,
|
|
239
243
|
appName,
|
|
240
244
|
getAppOrigin: () => window.location.origin,
|
|
241
|
-
hideEmbeddedWalletTransactionUIs: hideEmbeddedWalletTransactionUIs !== null && hideEmbeddedWalletTransactionUIs !== void 0 ? hideEmbeddedWalletTransactionUIs : !((
|
|
245
|
+
hideEmbeddedWalletTransactionUIs: hideEmbeddedWalletTransactionUIs !== null && hideEmbeddedWalletTransactionUIs !== void 0 ? hideEmbeddedWalletTransactionUIs : !((_h = (_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _g === void 0 ? void 0 : _g.embeddedWallets) === null || _h === void 0 ? void 0 : _h.showEmbeddedWalletActionsUI),
|
|
242
246
|
});
|
|
243
247
|
const { walletConnectorOptions } = useWalletConnectorOptions.useWalletConnectorOptions({
|
|
244
248
|
appLogoUrl,
|
|
@@ -713,7 +717,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
713
717
|
}
|
|
714
718
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
715
719
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile]);
|
|
716
|
-
return (jsxRuntime.jsx(reactI18next.I18nextProvider, { i18n: i18nSDKInstance, children: jsxRuntime.jsx(DynamicContext.Provider, { value: value, children: jsxRuntime.jsx(walletBook.WalletBookContextProvider, { walletBook: walletBook$1, children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, { customerTheme: parseTheme.parseTheme(theme, ((
|
|
720
|
+
return (jsxRuntime.jsx(reactI18next.I18nextProvider, { i18n: i18nSDKInstance, children: jsxRuntime.jsx(DynamicContext.Provider, { value: value, children: jsxRuntime.jsx(walletBook.WalletBookContextProvider, { walletBook: walletBook$1, children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, { customerTheme: parseTheme.parseTheme(theme, ((_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _j === void 0 ? void 0 : _j.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design, children: jsxRuntime.jsx(LoadingContext.LoadingContextProvider, { children: jsxRuntime.jsxs(ViewContext.ViewContextProvider, { initialView: helpers.getInitialView({
|
|
717
721
|
bridgeOnboardingCompleted,
|
|
718
722
|
connectedWallets,
|
|
719
723
|
isAuthenticated: isAuthenticated || Boolean(primaryWallet),
|
|
@@ -7,7 +7,7 @@ import { getIconicSpriteUrl } from '@dynamic-labs/iconic';
|
|
|
7
7
|
import { Logger } from '@dynamic-labs/logger';
|
|
8
8
|
import { MissingEnvironmentIdError } from '@dynamic-labs/utils';
|
|
9
9
|
import { useWalletBookCdn, getWalletBookCdnUrl, WalletBookContextProvider } from '@dynamic-labs/wallet-book';
|
|
10
|
-
import { logger as logger$1 } from '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import { setChainInfoOverrides, logger as logger$1 } from '@dynamic-labs/wallet-connector-core';
|
|
11
11
|
import { DynamicAuthFlow } from '../../app.js';
|
|
12
12
|
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
13
13
|
import '../../components/Alert/Alert.js';
|
|
@@ -138,7 +138,7 @@ const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9
|
|
|
138
138
|
const DynamicContext = createContext(undefined);
|
|
139
139
|
/** The context provider itself we only use internally */
|
|
140
140
|
const InnerDynamicContextProvider = ({ children, theme, settings, locale, enableInstrumentation = false, }) => {
|
|
141
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
141
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
142
142
|
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, defaultPhoneInputIso2, apiBaseUrl, coinbaseWalletPreference, enableConnectOnlyFallback = false, deepLinkPreference: deepLinkPreferenceProp = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, recommendedWallets, hideEmbeddedWalletTransactionUIs, handlers, headless = false, } = settings;
|
|
143
143
|
LocalStorage.setSuffix(settings.localStorageSuffix);
|
|
144
144
|
/**
|
|
@@ -148,13 +148,17 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
148
148
|
environmentId,
|
|
149
149
|
storageSuffix: settings.localStorageSuffix,
|
|
150
150
|
});
|
|
151
|
+
/**
|
|
152
|
+
* Sets the chain info overrides if they are present
|
|
153
|
+
*/
|
|
154
|
+
setChainInfoOverrides((_a = settings.overrides) === null || _a === void 0 ? void 0 : _a.chainDisplayValues);
|
|
151
155
|
/**
|
|
152
156
|
* For backwards compatibility, we allow the client to pass in
|
|
153
157
|
* `eventsCallbacks` instead of `events`. It should remove this
|
|
154
158
|
* in version 3.0.0.
|
|
155
159
|
* ticket: QNTM-1504
|
|
156
160
|
*/
|
|
157
|
-
const events = (
|
|
161
|
+
const events = (_b = settings.events) !== null && _b !== void 0 ? _b : settings.eventsCallbacks;
|
|
158
162
|
const networkValidationMode = resolveNetworkValidationMode({
|
|
159
163
|
bridgeChains: settings.bridgeChains,
|
|
160
164
|
networkValidationMode: settings.networkValidationMode,
|
|
@@ -167,14 +171,14 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
167
171
|
logger.setLogLevel(logLevel);
|
|
168
172
|
logger$1.setLogLevel(logLevel);
|
|
169
173
|
}
|
|
170
|
-
catch (
|
|
174
|
+
catch (_k) {
|
|
171
175
|
// logger could be messing up with SSR so we are catching the errors
|
|
172
176
|
/* empty */
|
|
173
177
|
}
|
|
174
178
|
if (environmentId === PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID) {
|
|
175
179
|
logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
|
|
176
180
|
}
|
|
177
|
-
ApiEndpoint.setBaseUrl((
|
|
181
|
+
ApiEndpoint.setBaseUrl((_c = process.env.DYNAMIC_API_BASE_URL) !== null && _c !== void 0 ? _c : apiBaseUrl);
|
|
178
182
|
const i18nSDKInstance = Locale.setup(locale);
|
|
179
183
|
const isBridgeFlow = Boolean(bridgeChains);
|
|
180
184
|
const deepLinkPreference = getDeepLinkPreference(deepLinkPreferenceProp, isBridgeFlow);
|
|
@@ -212,8 +216,8 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
212
216
|
useSendDynamicProps({ environmentId, settings });
|
|
213
217
|
const multiWallet = useMultiWallet({
|
|
214
218
|
isBridgeFlow,
|
|
215
|
-
multiWalletOverride: (
|
|
216
|
-
multiWalletSettings: (
|
|
219
|
+
multiWalletOverride: (_d = settings.overrides) === null || _d === void 0 ? void 0 : _d.multiWallet,
|
|
220
|
+
multiWalletSettings: (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.multiWallet,
|
|
217
221
|
});
|
|
218
222
|
// ensures that when user comes back to site and primary wallet is out of sync, we don't show widget popup
|
|
219
223
|
const [showWidgetStatePopup, setShowWidgetStatePopup] = useState(!multiWallet);
|
|
@@ -222,7 +226,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
222
226
|
const walletBook = useWalletBookCdn();
|
|
223
227
|
const { networkConfigurations: serverNetworkConfigurations } = useNetworkConfigurations({
|
|
224
228
|
environmentId,
|
|
225
|
-
evmNetworksOverrides: (
|
|
229
|
+
evmNetworksOverrides: (_f = settings.overrides) === null || _f === void 0 ? void 0 : _f.evmNetworks,
|
|
226
230
|
projectSettings,
|
|
227
231
|
});
|
|
228
232
|
const { imageUserInAccessList, imageUserNotInAccessList, displayName, appLogo, } = (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.general) || {};
|
|
@@ -234,7 +238,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
234
238
|
appLogoUrl,
|
|
235
239
|
appName,
|
|
236
240
|
getAppOrigin: () => window.location.origin,
|
|
237
|
-
hideEmbeddedWalletTransactionUIs: hideEmbeddedWalletTransactionUIs !== null && hideEmbeddedWalletTransactionUIs !== void 0 ? hideEmbeddedWalletTransactionUIs : !((
|
|
241
|
+
hideEmbeddedWalletTransactionUIs: hideEmbeddedWalletTransactionUIs !== null && hideEmbeddedWalletTransactionUIs !== void 0 ? hideEmbeddedWalletTransactionUIs : !((_h = (_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _g === void 0 ? void 0 : _g.embeddedWallets) === null || _h === void 0 ? void 0 : _h.showEmbeddedWalletActionsUI),
|
|
238
242
|
});
|
|
239
243
|
const { walletConnectorOptions } = useWalletConnectorOptions({
|
|
240
244
|
appLogoUrl,
|
|
@@ -709,7 +713,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
|
|
|
709
713
|
}
|
|
710
714
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
711
715
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile]);
|
|
712
|
-
return (jsx(I18nextProvider, { i18n: i18nSDKInstance, children: jsx(DynamicContext.Provider, { value: value, children: jsx(WalletBookContextProvider, { walletBook: walletBook, children: jsx(ThemeContextProvider, { customerTheme: parseTheme(theme, ((
|
|
716
|
+
return (jsx(I18nextProvider, { i18n: i18nSDKInstance, children: jsx(DynamicContext.Provider, { value: value, children: jsx(WalletBookContextProvider, { walletBook: walletBook, children: jsx(ThemeContextProvider, { customerTheme: parseTheme(theme, ((_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _j === void 0 ? void 0 : _j.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design, children: jsx(LoadingContextProvider, { children: jsxs(ViewContextProvider, { initialView: getInitialView({
|
|
713
717
|
bridgeOnboardingCompleted,
|
|
714
718
|
connectedWallets,
|
|
715
719
|
isAuthenticated: isAuthenticated || Boolean(primaryWallet),
|
|
@@ -3,7 +3,7 @@ import { changeLanguage } from 'i18next';
|
|
|
3
3
|
import { CountryIso2 } from 'react-international-phone';
|
|
4
4
|
import { NameServiceData, ProjectSettings, SdkView } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { GenericNetwork, NetworkConfigurationMap, SocialProviderFilter, UserProfile, WalletUiUtils } from '@dynamic-labs/types';
|
|
6
|
-
import { Chain, GetAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import { Chain, ChainDisplayOverrides, GetAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import { PasskeySuccessEnum } from '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner';
|
|
8
8
|
import { AccessDeniedCustomButton, AccountSwitchState, AuthModeType, AwaitingSignatureState, ChainToWalletMap, DynamicEventsCallbacks, DynamicRPCProviders, MultiWalletWidgetState, RecommendedWallet, Wallet, WalletOption, WalletWithAction } from '../../../shared';
|
|
9
9
|
import { DynamicHandlers } from '../../../shared/types/dynamicHandlers';
|
|
@@ -52,6 +52,10 @@ export type SettingsOverrides = {
|
|
|
52
52
|
* Allows overriding the multi-wallet feature from the dashboard.
|
|
53
53
|
*/
|
|
54
54
|
multiWallet?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Allows overriding the chain info for a specific chain.
|
|
57
|
+
*/
|
|
58
|
+
chainDisplayValues?: ChainDisplayOverrides;
|
|
55
59
|
};
|
|
56
60
|
export type ConnectWalletResult = {
|
|
57
61
|
address: string;
|
|
@@ -95,23 +95,6 @@ const signInOAuth = (environmentId_2, providerType_2, _c) => _tslib.__awaiter(vo
|
|
|
95
95
|
return undefined;
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
|
-
const getOAuthResult = (environmentId_3, providerType_3, _e) => _tslib.__awaiter(void 0, [environmentId_3, providerType_3, _e], void 0, function* (environmentId, providerType, { state }) {
|
|
99
|
-
const oauthResultRequest = {
|
|
100
|
-
state,
|
|
101
|
-
};
|
|
102
|
-
try {
|
|
103
|
-
const result = yield api.sdkApi().oauthResult({
|
|
104
|
-
environmentId,
|
|
105
|
-
oauthResultRequest,
|
|
106
|
-
providerType,
|
|
107
|
-
});
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
catch (e) {
|
|
111
|
-
logger.logger.error(e);
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
98
|
const farcasterSignIn = (environmentId, farcasterSignInRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
116
99
|
try {
|
|
117
100
|
const response = yield api.sdkApi().farcasterSignIn({
|
|
@@ -151,7 +134,6 @@ const farcasterVerify = (farcasterVerifyRequest) => _tslib.__awaiter(void 0, voi
|
|
|
151
134
|
|
|
152
135
|
exports.farcasterSignIn = farcasterSignIn;
|
|
153
136
|
exports.farcasterVerify = farcasterVerify;
|
|
154
|
-
exports.getOAuthResult = getOAuthResult;
|
|
155
137
|
exports.signInOAuth = signInOAuth;
|
|
156
138
|
exports.unlinkOAuth = unlinkOAuth;
|
|
157
139
|
exports.verifyOAuth = verifyOAuth;
|
|
@@ -91,23 +91,6 @@ const signInOAuth = (environmentId_2, providerType_2, _c) => __awaiter(void 0, [
|
|
|
91
91
|
return undefined;
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
|
-
const getOAuthResult = (environmentId_3, providerType_3, _e) => __awaiter(void 0, [environmentId_3, providerType_3, _e], void 0, function* (environmentId, providerType, { state }) {
|
|
95
|
-
const oauthResultRequest = {
|
|
96
|
-
state,
|
|
97
|
-
};
|
|
98
|
-
try {
|
|
99
|
-
const result = yield sdkApi().oauthResult({
|
|
100
|
-
environmentId,
|
|
101
|
-
oauthResultRequest,
|
|
102
|
-
providerType,
|
|
103
|
-
});
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
logger.error(e);
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
94
|
const farcasterSignIn = (environmentId, farcasterSignInRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
95
|
try {
|
|
113
96
|
const response = yield sdkApi().farcasterSignIn({
|
|
@@ -145,4 +128,4 @@ const farcasterVerify = (farcasterVerifyRequest) => __awaiter(void 0, void 0, vo
|
|
|
145
128
|
}
|
|
146
129
|
});
|
|
147
130
|
|
|
148
|
-
export { farcasterSignIn, farcasterVerify,
|
|
131
|
+
export { farcasterSignIn, farcasterVerify, signInOAuth, unlinkOAuth, verifyOAuth };
|
|
@@ -89,7 +89,7 @@ const WalletProgressStepper = () => {
|
|
|
89
89
|
const chainsLeftToConnect = [...bridgeChainsToConnect].map(({ chain }) => chain);
|
|
90
90
|
return (jsxRuntime.jsx("div", { className: 'wallet-progress-stepper', "data-testid": 'wallet-progress-stepper', children: jsxRuntime.jsx(Stepper.Stepper, { children: allChains.map((chain, index) => {
|
|
91
91
|
var _a;
|
|
92
|
-
const chainInfo = walletConnectorCore.
|
|
92
|
+
const chainInfo = walletConnectorCore.getChainInfoWithOverrides(chain);
|
|
93
93
|
const PrimaryWalletChainIcon = getChainIcon.getChainIcon(chain);
|
|
94
94
|
return (jsxRuntime.jsx(Step.Step, { state: getChainStepState.getChainStepState(chain, chainsLeftToConnect), icon: jsxRuntime.jsx(PrimaryWalletChainIcon, {}), children: (_a = chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.blockchainName) !== null && _a !== void 0 ? _a : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName }, chain));
|
|
95
95
|
}) }) }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
5
5
|
import '../../../components/Alert/Alert.js';
|
|
6
6
|
import 'react';
|
|
@@ -85,7 +85,7 @@ const WalletProgressStepper = () => {
|
|
|
85
85
|
const chainsLeftToConnect = [...bridgeChainsToConnect].map(({ chain }) => chain);
|
|
86
86
|
return (jsx("div", { className: 'wallet-progress-stepper', "data-testid": 'wallet-progress-stepper', children: jsx(Stepper, { children: allChains.map((chain, index) => {
|
|
87
87
|
var _a;
|
|
88
|
-
const chainInfo =
|
|
88
|
+
const chainInfo = getChainInfoWithOverrides(chain);
|
|
89
89
|
const PrimaryWalletChainIcon = getChainIcon(chain);
|
|
90
90
|
return (jsx(Step, { state: getChainStepState(chain, chainsLeftToConnect), icon: jsx(PrimaryWalletChainIcon, {}), children: (_a = chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.blockchainName) !== null && _a !== void 0 ? _a : chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName }, chain));
|
|
91
91
|
}) }) }));
|
|
@@ -8,7 +8,7 @@ var logger = require('../../../logger.cjs');
|
|
|
8
8
|
|
|
9
9
|
const getChainDisplayName = (chain) => {
|
|
10
10
|
var _a;
|
|
11
|
-
const displayName = (_a = walletConnectorCore.
|
|
11
|
+
const displayName = (_a = walletConnectorCore.getChainInfoWithOverrides(chain)) === null || _a === void 0 ? void 0 : _a.displayName;
|
|
12
12
|
if (!displayName) {
|
|
13
13
|
logger.logger.error(`Chain name for "${chain}" not supported`);
|
|
14
14
|
return chain;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import {
|
|
2
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { logger } from '../../../logger.js';
|
|
4
4
|
|
|
5
5
|
const getChainDisplayName = (chain) => {
|
|
6
6
|
var _a;
|
|
7
|
-
const displayName = (_a =
|
|
7
|
+
const displayName = (_a = getChainInfoWithOverrides(chain)) === null || _a === void 0 ? void 0 : _a.displayName;
|
|
8
8
|
if (!displayName) {
|
|
9
9
|
logger.error(`Chain name for "${chain}" not supported`);
|
|
10
10
|
return chain;
|
|
@@ -103,7 +103,6 @@ const socialProviders = [
|
|
|
103
103
|
// pkce params are only required for twitter and break if added for other providers, like google
|
|
104
104
|
// so we should only add provider that support pkce to this list
|
|
105
105
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
106
|
-
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
107
106
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
108
107
|
const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }) => {
|
|
109
108
|
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
@@ -115,7 +114,6 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
115
114
|
const [error, setError] = React.useState();
|
|
116
115
|
const providersWaitingOauthMessage = React.useRef({});
|
|
117
116
|
const authWindowInterval = React.useRef();
|
|
118
|
-
const shouldPool = React.useRef(false);
|
|
119
117
|
const clearError = () => {
|
|
120
118
|
setError(undefined);
|
|
121
119
|
setContextError(undefined);
|
|
@@ -138,26 +136,6 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
138
136
|
setErrorMessage(code);
|
|
139
137
|
onFailed(provider, { error }, options);
|
|
140
138
|
};
|
|
141
|
-
const poolOauthResult = (provider, state) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
-
if (!shouldPool.current) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const result = yield oauth.getOAuthResult(environmentId, provider, {
|
|
146
|
-
state,
|
|
147
|
-
});
|
|
148
|
-
if ((result === null || result === void 0 ? void 0 : result.status) !== sdkApiCore.OauthResultStatus.Completed) {
|
|
149
|
-
setTimeout(() => poolOauthResult(provider, state), 1000);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
shouldPool.current = false;
|
|
153
|
-
const authMessage = {
|
|
154
|
-
code: result === null || result === void 0 ? void 0 : result.code,
|
|
155
|
-
error: result === null || result === void 0 ? void 0 : result.error,
|
|
156
|
-
provider,
|
|
157
|
-
type: 'authorization_response',
|
|
158
|
-
};
|
|
159
|
-
window.postMessage(authMessage, '*');
|
|
160
|
-
});
|
|
161
139
|
const checkValidProvider = (provider, authMode) => {
|
|
162
140
|
if (!provider) {
|
|
163
141
|
handleError(provider, types.SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required', { raiseAuthFailure: authMode === 'signin' });
|
|
@@ -230,17 +208,15 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
230
208
|
return;
|
|
231
209
|
}
|
|
232
210
|
let expectedOrigin = window.location.origin;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
211
|
+
try {
|
|
212
|
+
const redirectUri = new URL(apiProvider.redirectUrl);
|
|
213
|
+
expectedOrigin = redirectUri.origin;
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
logger.logger.error('Failed to parse social provider redirect url', {
|
|
217
|
+
error: e,
|
|
218
|
+
});
|
|
219
|
+
return;
|
|
244
220
|
}
|
|
245
221
|
if ((message === null || message === void 0 ? void 0 : message.type) === 'origin_check' && authWindow) {
|
|
246
222
|
logger.logger.debug('Origin check message received. Sending response now.', {
|
|
@@ -276,8 +252,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
276
252
|
// check that the state we receive from message is the same state we calculated earlier
|
|
277
253
|
// this could be an attack
|
|
278
254
|
// this state check is used only by providers with an open window opener reference (eg, not twitter)
|
|
279
|
-
if (
|
|
280
|
-
state !== authState) {
|
|
255
|
+
if (state !== authState) {
|
|
281
256
|
handleError(provider, types.SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: Invalid random state`, { raiseAuthFailure: authMode === 'signin' });
|
|
282
257
|
return;
|
|
283
258
|
}
|
|
@@ -328,48 +303,21 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
328
303
|
oauthLoginUrl = `${oauthLoginUrl}&${pkceParams}`;
|
|
329
304
|
}
|
|
330
305
|
authWindow === null || authWindow === void 0 ? void 0 : authWindow.location.assign(oauthLoginUrl);
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
clearInterval(authWindowInterval.current);
|
|
339
|
-
setIsProcessing(false);
|
|
340
|
-
// user didn't complete oauth
|
|
341
|
-
if ((_a = providersWaitingOauthMessage.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
342
|
-
onFailed(provider, 'user-cancelled');
|
|
343
|
-
}
|
|
344
|
-
}, 2000);
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
// For provider that don't support window.opener, we need to use a timeout to pool the oauth result
|
|
348
|
-
// If we don't get a valid result in {async sessionTimeout} ms, we'll assume the user closed the window
|
|
349
|
-
// and we'll clear all states/listeners
|
|
350
|
-
// start pooling oauth result
|
|
351
|
-
shouldPool.current = true;
|
|
352
|
-
poolOauthResult(provider, state);
|
|
353
|
-
// if this is mobile, set a longer timeout to allow the user to login to the provider in the browser
|
|
354
|
-
let authWindowTimeout = sessionTimeout;
|
|
355
|
-
if (utils.isMobile()) {
|
|
356
|
-
authWindowTimeout = authWindowTimeout * 3;
|
|
306
|
+
// For provider that support window.opener, we need to clear all states/listeners when the window is closed
|
|
307
|
+
authWindowInterval.current = setInterval(() => {
|
|
308
|
+
var _a;
|
|
309
|
+
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
|
|
310
|
+
return;
|
|
357
311
|
}
|
|
358
|
-
authWindowInterval.current
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
clearInterval(authWindowInterval.current);
|
|
367
|
-
setIsProcessing(false);
|
|
368
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
369
|
-
}), authWindowTimeout);
|
|
370
|
-
}
|
|
312
|
+
clearInterval(authWindowInterval.current);
|
|
313
|
+
setIsProcessing(false);
|
|
314
|
+
// user didn't complete oauth
|
|
315
|
+
if ((_a = providersWaitingOauthMessage.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
316
|
+
onFailed(provider, 'user-cancelled');
|
|
317
|
+
}
|
|
318
|
+
}, 2000);
|
|
371
319
|
});
|
|
372
|
-
const connectWithFarcaster = (authMode_1,
|
|
320
|
+
const connectWithFarcaster = (authMode_1, _f) => _tslib.__awaiter(void 0, [authMode_1, _f], void 0, function* (authMode, { captchaToken }) {
|
|
373
321
|
const dynamicNonce = consumeNonce();
|
|
374
322
|
const domain = utils.PlatformService.getHost();
|
|
375
323
|
const data = yield farcaster.connect({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
|
-
import { ProviderEnum
|
|
4
|
+
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
6
|
-
import {
|
|
6
|
+
import { PlatformService, isMobile, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
|
|
7
7
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
8
8
|
import { logger } from '../../../shared/logger.js';
|
|
9
9
|
import '@dynamic-labs/iconic';
|
|
@@ -31,7 +31,7 @@ import 'viem';
|
|
|
31
31
|
import 'viem/chains';
|
|
32
32
|
import '../../../config/ApiEndpoint.js';
|
|
33
33
|
import '@dynamic-labs/store';
|
|
34
|
-
import {
|
|
34
|
+
import { signInOAuth, verifyOAuth, farcasterSignIn, farcasterVerify } from '../../../data/api/oauth/oauth.js';
|
|
35
35
|
import '../../../locale/locale.js';
|
|
36
36
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
37
37
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -99,7 +99,6 @@ const socialProviders = [
|
|
|
99
99
|
// pkce params are only required for twitter and break if added for other providers, like google
|
|
100
100
|
// so we should only add provider that support pkce to this list
|
|
101
101
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
102
|
-
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
103
102
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
104
103
|
const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }) => {
|
|
105
104
|
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext();
|
|
@@ -111,7 +110,6 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
111
110
|
const [error, setError] = useState();
|
|
112
111
|
const providersWaitingOauthMessage = useRef({});
|
|
113
112
|
const authWindowInterval = useRef();
|
|
114
|
-
const shouldPool = useRef(false);
|
|
115
113
|
const clearError = () => {
|
|
116
114
|
setError(undefined);
|
|
117
115
|
setContextError(undefined);
|
|
@@ -134,26 +132,6 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
134
132
|
setErrorMessage(code);
|
|
135
133
|
onFailed(provider, { error }, options);
|
|
136
134
|
};
|
|
137
|
-
const poolOauthResult = (provider, state) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
if (!shouldPool.current) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const result = yield getOAuthResult(environmentId, provider, {
|
|
142
|
-
state,
|
|
143
|
-
});
|
|
144
|
-
if ((result === null || result === void 0 ? void 0 : result.status) !== OauthResultStatus.Completed) {
|
|
145
|
-
setTimeout(() => poolOauthResult(provider, state), 1000);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
shouldPool.current = false;
|
|
149
|
-
const authMessage = {
|
|
150
|
-
code: result === null || result === void 0 ? void 0 : result.code,
|
|
151
|
-
error: result === null || result === void 0 ? void 0 : result.error,
|
|
152
|
-
provider,
|
|
153
|
-
type: 'authorization_response',
|
|
154
|
-
};
|
|
155
|
-
window.postMessage(authMessage, '*');
|
|
156
|
-
});
|
|
157
135
|
const checkValidProvider = (provider, authMode) => {
|
|
158
136
|
if (!provider) {
|
|
159
137
|
handleError(provider, SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required', { raiseAuthFailure: authMode === 'signin' });
|
|
@@ -226,17 +204,15 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
226
204
|
return;
|
|
227
205
|
}
|
|
228
206
|
let expectedOrigin = window.location.origin;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
207
|
+
try {
|
|
208
|
+
const redirectUri = new URL(apiProvider.redirectUrl);
|
|
209
|
+
expectedOrigin = redirectUri.origin;
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
logger.error('Failed to parse social provider redirect url', {
|
|
213
|
+
error: e,
|
|
214
|
+
});
|
|
215
|
+
return;
|
|
240
216
|
}
|
|
241
217
|
if ((message === null || message === void 0 ? void 0 : message.type) === 'origin_check' && authWindow) {
|
|
242
218
|
logger.debug('Origin check message received. Sending response now.', {
|
|
@@ -272,8 +248,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
272
248
|
// check that the state we receive from message is the same state we calculated earlier
|
|
273
249
|
// this could be an attack
|
|
274
250
|
// this state check is used only by providers with an open window opener reference (eg, not twitter)
|
|
275
|
-
if (
|
|
276
|
-
state !== authState) {
|
|
251
|
+
if (state !== authState) {
|
|
277
252
|
handleError(provider, SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: Invalid random state`, { raiseAuthFailure: authMode === 'signin' });
|
|
278
253
|
return;
|
|
279
254
|
}
|
|
@@ -324,48 +299,21 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
324
299
|
oauthLoginUrl = `${oauthLoginUrl}&${pkceParams}`;
|
|
325
300
|
}
|
|
326
301
|
authWindow === null || authWindow === void 0 ? void 0 : authWindow.location.assign(oauthLoginUrl);
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
clearInterval(authWindowInterval.current);
|
|
335
|
-
setIsProcessing(false);
|
|
336
|
-
// user didn't complete oauth
|
|
337
|
-
if ((_a = providersWaitingOauthMessage.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
338
|
-
onFailed(provider, 'user-cancelled');
|
|
339
|
-
}
|
|
340
|
-
}, 2000);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
// For provider that don't support window.opener, we need to use a timeout to pool the oauth result
|
|
344
|
-
// If we don't get a valid result in {async sessionTimeout} ms, we'll assume the user closed the window
|
|
345
|
-
// and we'll clear all states/listeners
|
|
346
|
-
// start pooling oauth result
|
|
347
|
-
shouldPool.current = true;
|
|
348
|
-
poolOauthResult(provider, state);
|
|
349
|
-
// if this is mobile, set a longer timeout to allow the user to login to the provider in the browser
|
|
350
|
-
let authWindowTimeout = sessionTimeout;
|
|
351
|
-
if (isMobile()) {
|
|
352
|
-
authWindowTimeout = authWindowTimeout * 3;
|
|
302
|
+
// For provider that support window.opener, we need to clear all states/listeners when the window is closed
|
|
303
|
+
authWindowInterval.current = setInterval(() => {
|
|
304
|
+
var _a;
|
|
305
|
+
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
|
|
306
|
+
return;
|
|
353
307
|
}
|
|
354
|
-
authWindowInterval.current
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
clearInterval(authWindowInterval.current);
|
|
363
|
-
setIsProcessing(false);
|
|
364
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
365
|
-
}), authWindowTimeout);
|
|
366
|
-
}
|
|
308
|
+
clearInterval(authWindowInterval.current);
|
|
309
|
+
setIsProcessing(false);
|
|
310
|
+
// user didn't complete oauth
|
|
311
|
+
if ((_a = providersWaitingOauthMessage.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
312
|
+
onFailed(provider, 'user-cancelled');
|
|
313
|
+
}
|
|
314
|
+
}, 2000);
|
|
367
315
|
});
|
|
368
|
-
const connectWithFarcaster = (authMode_1,
|
|
316
|
+
const connectWithFarcaster = (authMode_1, _f) => __awaiter(void 0, [authMode_1, _f], void 0, function* (authMode, { captchaToken }) {
|
|
369
317
|
const dynamicNonce = consumeNonce();
|
|
370
318
|
const domain = PlatformService.getHost();
|
|
371
319
|
const data = yield connect({
|
|
@@ -118,7 +118,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
118
118
|
!wallet.connector.canConnectViaCustodialService, []);
|
|
119
119
|
const setPrimaryWallet = React.useCallback((walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
120
120
|
const { newWallet: newPrimaryWallet, connectedAccounts } = yield getSelectedWallet(walletId);
|
|
121
|
-
if (!primaryWalletId) {
|
|
121
|
+
if (!primaryWalletId && !checkIfShowQrCodeModal(newPrimaryWallet)) {
|
|
122
122
|
yield newPrimaryWallet.connector.connect();
|
|
123
123
|
setPrimaryWalletId(walletId);
|
|
124
124
|
return;
|
|
@@ -114,7 +114,7 @@ const useWalletConnectors = ({ authMode, connectedWallets, walletConnectorOption
|
|
|
114
114
|
!wallet.connector.canConnectViaCustodialService, []);
|
|
115
115
|
const setPrimaryWallet = useCallback((walletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
116
|
const { newWallet: newPrimaryWallet, connectedAccounts } = yield getSelectedWallet(walletId);
|
|
117
|
-
if (!primaryWalletId) {
|
|
117
|
+
if (!primaryWalletId && !checkIfShowQrCodeModal(newPrimaryWallet)) {
|
|
118
118
|
yield newPrimaryWallet.connector.connect();
|
|
119
119
|
setPrimaryWalletId(walletId);
|
|
120
120
|
return;
|
|
@@ -89,7 +89,7 @@ const BridgeNextWalletConnectionView = () => {
|
|
|
89
89
|
}
|
|
90
90
|
const [nextWalletToConnect] = bridgeChainsToConnect;
|
|
91
91
|
const { chain } = nextWalletToConnect;
|
|
92
|
-
const chainInfo = walletConnectorCore.
|
|
92
|
+
const chainInfo = walletConnectorCore.getChainInfoWithOverrides(chain);
|
|
93
93
|
const ChainIcon = getChainIcon.getChainIcon(chain);
|
|
94
94
|
if (!chainInfo) {
|
|
95
95
|
throw new utils.DynamicError('No chain info found for chain', chain);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
5
5
|
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
6
6
|
import { BridgeNextWalletToConnectLayout } from '../../layouts/BridgeNextWalletToConnectLayout/BridgeNextWalletToConnectLayout.js';
|
|
@@ -85,7 +85,7 @@ const BridgeNextWalletConnectionView = () => {
|
|
|
85
85
|
}
|
|
86
86
|
const [nextWalletToConnect] = bridgeChainsToConnect;
|
|
87
87
|
const { chain } = nextWalletToConnect;
|
|
88
|
-
const chainInfo =
|
|
88
|
+
const chainInfo = getChainInfoWithOverrides(chain);
|
|
89
89
|
const ChainIcon = getChainIcon(chain);
|
|
90
90
|
if (!chainInfo) {
|
|
91
91
|
throw new DynamicError('No chain info found for chain', chain);
|
|
@@ -89,7 +89,7 @@ const BridgeSummaryView = () => {
|
|
|
89
89
|
const { t } = reactI18next.useTranslation();
|
|
90
90
|
const onClickClose = () => setShowAuthFlow(false, { emitCancelAuth: true });
|
|
91
91
|
const body = React.useMemo(() => {
|
|
92
|
-
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = walletConnectorCore.
|
|
92
|
+
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = walletConnectorCore.getChainInfoWithOverrides(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
93
93
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
94
94
|
return t('dyn_bridge.summary_view.connection_succeed', {
|
|
95
95
|
firstBlockchainName,
|
|
@@ -98,7 +98,7 @@ const BridgeSummaryView = () => {
|
|
|
98
98
|
}, [bridgeChains, t]);
|
|
99
99
|
const createPrimaryWalletCard = (wallet) => {
|
|
100
100
|
const PrimaryWalletChainIcon = getChainIcon.getChainIcon(wallet.chain);
|
|
101
|
-
const primaryWalletChainInfo = walletConnectorCore.
|
|
101
|
+
const primaryWalletChainInfo = walletConnectorCore.getChainInfoWithOverrides(wallet.chain);
|
|
102
102
|
return (jsxRuntime.jsx(DynamicBridgeWalletCard.DynamicBridgeWalletCard, { networkIcon: jsxRuntime.jsx(PrimaryWalletChainIcon, {}), networkName: primaryWalletChainInfo === null || primaryWalletChainInfo === void 0 ? void 0 : primaryWalletChainInfo.displayName, children: jsxRuntime.jsx(DynamicBridgeWalletCardBody.DynamicBridgeWalletCardBody, { walletKey: wallet.connector.key, walletAddress: wallet.address, walletBalance:
|
|
103
103
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
104
104
|
jsxRuntime.jsx(Balance.Balance, { address: wallet.address, connector: wallet.connector, network: wallet.chain }) }) }));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import '../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api-core';
|
|
8
8
|
import '../../shared/logger.js';
|
|
@@ -85,7 +85,7 @@ const BridgeSummaryView = () => {
|
|
|
85
85
|
const { t } = useTranslation();
|
|
86
86
|
const onClickClose = () => setShowAuthFlow(false, { emitCancelAuth: true });
|
|
87
87
|
const body = useMemo(() => {
|
|
88
|
-
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a =
|
|
88
|
+
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = getChainInfoWithOverrides(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
89
89
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
90
90
|
return t('dyn_bridge.summary_view.connection_succeed', {
|
|
91
91
|
firstBlockchainName,
|
|
@@ -94,7 +94,7 @@ const BridgeSummaryView = () => {
|
|
|
94
94
|
}, [bridgeChains, t]);
|
|
95
95
|
const createPrimaryWalletCard = (wallet) => {
|
|
96
96
|
const PrimaryWalletChainIcon = getChainIcon(wallet.chain);
|
|
97
|
-
const primaryWalletChainInfo =
|
|
97
|
+
const primaryWalletChainInfo = getChainInfoWithOverrides(wallet.chain);
|
|
98
98
|
return (jsx(DynamicBridgeWalletCard, { networkIcon: jsx(PrimaryWalletChainIcon, {}), networkName: primaryWalletChainInfo === null || primaryWalletChainInfo === void 0 ? void 0 : primaryWalletChainInfo.displayName, children: jsx(DynamicBridgeWalletCardBody, { walletKey: wallet.connector.key, walletAddress: wallet.address, walletBalance:
|
|
99
99
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
100
100
|
jsx(Balance, { address: wallet.address, connector: wallet.connector, network: wallet.chain }) }) }));
|
|
@@ -87,7 +87,7 @@ const BridgeWelcomeView = () => {
|
|
|
87
87
|
const { setView } = ViewContext.useViewContext();
|
|
88
88
|
const { t } = reactI18next.useTranslation();
|
|
89
89
|
const body = React.useMemo(() => {
|
|
90
|
-
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = walletConnectorCore.
|
|
90
|
+
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = walletConnectorCore.getChainInfoWithOverrides(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
91
91
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
92
92
|
return t('dyn_bridge.welcome_view.description', {
|
|
93
93
|
firstBlockchainName,
|
|
@@ -96,7 +96,7 @@ const BridgeWelcomeView = () => {
|
|
|
96
96
|
}, [bridgeChains, t]);
|
|
97
97
|
const chains = React.useMemo(() => bridgeChains
|
|
98
98
|
.map(({ chain }, index) => {
|
|
99
|
-
const chainInfo = walletConnectorCore.
|
|
99
|
+
const chainInfo = walletConnectorCore.getChainInfoWithOverrides(chain);
|
|
100
100
|
const ChainIcon = getChainIcon.getChainIcon(chain);
|
|
101
101
|
if (chainInfo && ChainIcon) {
|
|
102
102
|
return {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import '../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api-core';
|
|
8
8
|
import '../../shared/logger.js';
|
|
@@ -83,7 +83,7 @@ const BridgeWelcomeView = () => {
|
|
|
83
83
|
const { setView } = useViewContext();
|
|
84
84
|
const { t } = useTranslation();
|
|
85
85
|
const body = useMemo(() => {
|
|
86
|
-
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a =
|
|
86
|
+
const blockchainNames = bridgeChains.map(({ chain }) => { var _a; return (_a = getChainInfoWithOverrides(chain)) === null || _a === void 0 ? void 0 : _a.blockchainName; });
|
|
87
87
|
const [firstBlockchainName, secondBlockchainName] = blockchainNames;
|
|
88
88
|
return t('dyn_bridge.welcome_view.description', {
|
|
89
89
|
firstBlockchainName,
|
|
@@ -92,7 +92,7 @@ const BridgeWelcomeView = () => {
|
|
|
92
92
|
}, [bridgeChains, t]);
|
|
93
93
|
const chains = useMemo(() => bridgeChains
|
|
94
94
|
.map(({ chain }, index) => {
|
|
95
|
-
const chainInfo =
|
|
95
|
+
const chainInfo = getChainInfoWithOverrides(chain);
|
|
96
96
|
const ChainIcon = getChainIcon(chain);
|
|
97
97
|
if (chainInfo && ChainIcon) {
|
|
98
98
|
return {
|
|
@@ -98,22 +98,26 @@ const LoginViewSection = ({ viewSection, index, walletCount, gotToWalletList, })
|
|
|
98
98
|
case sdkApiCore.SdkViewSectionType.Phone:
|
|
99
99
|
return (jsxRuntime.jsx(PhoneNumberSignInSection.PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }));
|
|
100
100
|
case sdkApiCore.SdkViewSectionType.EmailAndPhone:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
// eslint-disable-next-line no-case-declarations
|
|
102
|
+
const sections = [
|
|
103
|
+
{
|
|
104
|
+
button: t('dyn_login.email_or_phone.use_phone'),
|
|
105
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_phone',
|
|
106
|
+
component: (jsxRuntime.jsx(LoginEmailForm.LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
107
|
+
label: t('dyn_login.email_or_phone.prefer_phone'),
|
|
108
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_phone',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
button: t('dyn_login.email_or_phone.use_email'),
|
|
112
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_email',
|
|
113
|
+
component: (jsxRuntime.jsx(PhoneNumberSignInSection.PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
114
|
+
label: t('dyn_login.email_or_phone.prefer_email'),
|
|
115
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_email',
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
if (viewSection.defaultItem === 'phone')
|
|
119
|
+
sections.reverse();
|
|
120
|
+
return jsxRuntime.jsx(ToggleableSection.ToggleableSection, { sections: sections });
|
|
117
121
|
case sdkApiCore.SdkViewSectionType.Wallet:
|
|
118
122
|
return (jsxRuntime.jsx(WalletSignInSection.WalletSignInSection, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
119
123
|
// this view is just to show the back button
|
|
@@ -94,22 +94,26 @@ const LoginViewSection = ({ viewSection, index, walletCount, gotToWalletList, })
|
|
|
94
94
|
case SdkViewSectionType.Phone:
|
|
95
95
|
return (jsx(PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }));
|
|
96
96
|
case SdkViewSectionType.EmailAndPhone:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
// eslint-disable-next-line no-case-declarations
|
|
98
|
+
const sections = [
|
|
99
|
+
{
|
|
100
|
+
button: t('dyn_login.email_or_phone.use_phone'),
|
|
101
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_phone',
|
|
102
|
+
component: (jsx(LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
103
|
+
label: t('dyn_login.email_or_phone.prefer_phone'),
|
|
104
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_phone',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
button: t('dyn_login.email_or_phone.use_email'),
|
|
108
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_email',
|
|
109
|
+
component: (jsx(PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
110
|
+
label: t('dyn_login.email_or_phone.prefer_email'),
|
|
111
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_email',
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
if (viewSection.defaultItem === 'phone')
|
|
115
|
+
sections.reverse();
|
|
116
|
+
return jsx(ToggleableSection, { sections: sections });
|
|
113
117
|
case SdkViewSectionType.Wallet:
|
|
114
118
|
return (jsx(WalletSignInSection, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
115
119
|
// this view is just to show the back button
|
|
@@ -6,8 +6,7 @@ export type Section = {
|
|
|
6
6
|
buttonCopyKey?: string;
|
|
7
7
|
labelCopyKey?: string;
|
|
8
8
|
};
|
|
9
|
-
type ToggleableSectionProps = {
|
|
9
|
+
export type ToggleableSectionProps = {
|
|
10
10
|
sections: [Section, Section];
|
|
11
11
|
};
|
|
12
12
|
export declare const ToggleableSection: FC<ToggleableSectionProps>;
|
|
13
|
-
export {};
|
|
@@ -90,7 +90,7 @@ require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs')
|
|
|
90
90
|
const WalletGroupItem = ({ wallet, onClick, }) => {
|
|
91
91
|
const [supportedChain] = wallet.walletConnector.supportedChains;
|
|
92
92
|
const { walletBook: walletBook$1 } = walletBook.useWalletBookContext();
|
|
93
|
-
const chainInfo = walletConnectorCore.
|
|
93
|
+
const chainInfo = walletConnectorCore.getChainInfoWithOverrides(supportedChain);
|
|
94
94
|
const walletOverride = wallet.group
|
|
95
95
|
? walletBook.findWalletGroupOverride(walletBook$1, wallet.group, wallet.key)
|
|
96
96
|
: undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { useWalletBookContext, findWalletGroupOverride, BrandIcon } from '@dynamic-labs/wallet-book';
|
|
6
6
|
import '@dynamic-labs/sdk-api-core';
|
|
7
7
|
import '../../../../shared/logger.js';
|
|
@@ -86,7 +86,7 @@ import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
|
86
86
|
const WalletGroupItem = ({ wallet, onClick, }) => {
|
|
87
87
|
const [supportedChain] = wallet.walletConnector.supportedChains;
|
|
88
88
|
const { walletBook } = useWalletBookContext();
|
|
89
|
-
const chainInfo =
|
|
89
|
+
const chainInfo = getChainInfoWithOverrides(supportedChain);
|
|
90
90
|
const walletOverride = wallet.group
|
|
91
91
|
? findWalletGroupOverride(walletBook, wallet.group, wallet.key)
|
|
92
92
|
: undefined;
|
|
@@ -87,7 +87,7 @@ const DynamicBridgeWidgetEmptyCard = ({ chain }) => {
|
|
|
87
87
|
if (!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) || !chain) {
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
|
-
const chainInfo = walletConnectorCore.
|
|
90
|
+
const chainInfo = walletConnectorCore.getChainInfoWithOverrides(chain);
|
|
91
91
|
const ChainIcon = getChainIcon.getChainIcon(chain);
|
|
92
92
|
return (jsxRuntime.jsxs("div", { role: 'button', className: 'dynamic-bridge-widget-empty-card', onClick: () => {
|
|
93
93
|
setShowBridgeWidget(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import {
|
|
4
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api-core';
|
|
@@ -83,7 +83,7 @@ const DynamicBridgeWidgetEmptyCard = ({ chain }) => {
|
|
|
83
83
|
if (!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) || !chain) {
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
|
-
const chainInfo =
|
|
86
|
+
const chainInfo = getChainInfoWithOverrides(chain);
|
|
87
87
|
const ChainIcon = getChainIcon(chain);
|
|
88
88
|
return (jsxs("div", { role: 'button', className: 'dynamic-bridge-widget-empty-card', onClick: () => {
|
|
89
89
|
setShowBridgeWidget(false);
|
|
@@ -94,7 +94,7 @@ const WalletsView = () => {
|
|
|
94
94
|
if (!chainWallets.length)
|
|
95
95
|
return jsxRuntime.jsx(DynamicBridgeWidgetEmptyCard.DynamicBridgeWidgetEmptyCard, { chain: chain }, chain);
|
|
96
96
|
const WalletIcon = getChainIcon.getChainIcon(chain);
|
|
97
|
-
const walletInfo = walletConnectorCore.
|
|
97
|
+
const walletInfo = walletConnectorCore.getChainInfoWithOverrides(chain);
|
|
98
98
|
// Wallets info for chains with connected wallets
|
|
99
99
|
return chainWallets.map(({ connector, address, id }) => (jsxRuntime.jsx(DynamicBridgeWalletCard.DynamicBridgeWalletCard, { networkIcon: jsxRuntime.jsx(WalletIcon, {}), networkName: walletInfo === null || walletInfo === void 0 ? void 0 : walletInfo.displayName, children: jsxRuntime.jsx(DynamicBridgeWalletCardBody.DynamicBridgeWalletCardBody, { walletKey: connector.key, walletAddress: address, walletBalance: jsxRuntime.jsx(Balance.Balance, { address: address, connector: connector, network: chain }), onDisconnectClick: () => disconnectWallet(id) }) }, `${id}-${connector.name}`)));
|
|
100
100
|
}) }), jsxRuntime.jsx(DynamicWidgetFooter.DynamicWidgetFooter, { children: jsxRuntime.jsx(LogoutButton.LogoutButton, { buttonClassName: 'dynamic-bridge-widget-wallets-view__logout-button', isTextButton: true }) })] }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
5
5
|
import '../../../../components/Alert/Alert.js';
|
|
6
6
|
import 'react';
|
|
@@ -90,7 +90,7 @@ const WalletsView = () => {
|
|
|
90
90
|
if (!chainWallets.length)
|
|
91
91
|
return jsx(DynamicBridgeWidgetEmptyCard, { chain: chain }, chain);
|
|
92
92
|
const WalletIcon = getChainIcon(chain);
|
|
93
|
-
const walletInfo =
|
|
93
|
+
const walletInfo = getChainInfoWithOverrides(chain);
|
|
94
94
|
// Wallets info for chains with connected wallets
|
|
95
95
|
return chainWallets.map(({ connector, address, id }) => (jsx(DynamicBridgeWalletCard, { networkIcon: jsx(WalletIcon, {}), networkName: walletInfo === null || walletInfo === void 0 ? void 0 : walletInfo.displayName, children: jsx(DynamicBridgeWalletCardBody, { walletKey: connector.key, walletAddress: address, walletBalance: jsx(Balance, { address: address, connector: connector, network: chain }), onDisconnectClick: () => disconnectWallet(id) }) }, `${id}-${connector.name}`)));
|
|
96
96
|
}) }), jsx(DynamicWidgetFooter, { children: jsx(LogoutButton, { buttonClassName: 'dynamic-bridge-widget-wallets-view__logout-button', isTextButton: true }) })] }));
|
|
@@ -91,7 +91,7 @@ const SecondaryWallets = ({ hideUnlinkAction = false }) => {
|
|
|
91
91
|
const { disconnectWallet, getConnectedWalletById, bridgeChains } = useInternalDynamicContext.useInternalDynamicContext();
|
|
92
92
|
const wallet = getConnectedWalletById('connect-wallet-1');
|
|
93
93
|
const NetworkIcon = wallet && getChainIcon.getChainIcon(wallet === null || wallet === void 0 ? void 0 : wallet.chain);
|
|
94
|
-
const networkInfo = wallet && walletConnectorCore.
|
|
94
|
+
const networkInfo = wallet && walletConnectorCore.getChainInfoWithOverrides(wallet === null || wallet === void 0 ? void 0 : wallet.chain);
|
|
95
95
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!wallet && (jsxRuntime.jsx(DynamicBridgeWidgetEmptyCard.DynamicBridgeWidgetEmptyCard, { chain: bridgeChains === null || bridgeChains === void 0 ? void 0 : bridgeChains[1].chain })), wallet && NetworkIcon && (jsxRuntime.jsx(DynamicBridgeWalletCard.DynamicBridgeWalletCard, { networkIcon: jsxRuntime.jsx(NetworkIcon, {}), networkName: networkInfo === null || networkInfo === void 0 ? void 0 : networkInfo.displayName, children: jsxRuntime.jsx(DynamicBridgeWalletCardBody.DynamicBridgeWalletCardBody, { walletKey: wallet.connector.key, walletAddress: wallet.address, walletBalance:
|
|
96
96
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
97
97
|
jsxRuntime.jsx(Balance.Balance, { address: wallet.address, connector: wallet.connector, network: wallet.chain }), onDisconnectClick: !hideUnlinkAction ? () => disconnectWallet(wallet.id) : undefined }, wallet.id) }))] }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import '../../../../../../shared/logger.js';
|
|
7
7
|
import { getChainIcon } from '../../../../../../shared/utils/functions/chain/getChainIcon.js';
|
|
@@ -83,7 +83,7 @@ const SecondaryWallets = ({ hideUnlinkAction = false }) => {
|
|
|
83
83
|
const { disconnectWallet, getConnectedWalletById, bridgeChains } = useInternalDynamicContext();
|
|
84
84
|
const wallet = getConnectedWalletById('connect-wallet-1');
|
|
85
85
|
const NetworkIcon = wallet && getChainIcon(wallet === null || wallet === void 0 ? void 0 : wallet.chain);
|
|
86
|
-
const networkInfo = wallet &&
|
|
86
|
+
const networkInfo = wallet && getChainInfoWithOverrides(wallet === null || wallet === void 0 ? void 0 : wallet.chain);
|
|
87
87
|
return (jsxs(Fragment, { children: [!wallet && (jsx(DynamicBridgeWidgetEmptyCard, { chain: bridgeChains === null || bridgeChains === void 0 ? void 0 : bridgeChains[1].chain })), wallet && NetworkIcon && (jsx(DynamicBridgeWalletCard, { networkIcon: jsx(NetworkIcon, {}), networkName: networkInfo === null || networkInfo === void 0 ? void 0 : networkInfo.displayName, children: jsx(DynamicBridgeWalletCardBody, { walletKey: wallet.connector.key, walletAddress: wallet.address, walletBalance:
|
|
88
88
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
89
89
|
jsx(Balance, { address: wallet.address, connector: wallet.connector, network: wallet.chain }), onDisconnectClick: !hideUnlinkAction ? () => disconnectWallet(wallet.id) : undefined }, wallet.id) }))] }));
|
|
@@ -86,7 +86,7 @@ const useFetchChain = (connector) => {
|
|
|
86
86
|
return { name: '', symbol: undefined };
|
|
87
87
|
const chainId = yield connector.getNetwork();
|
|
88
88
|
const { connectedChain } = connector;
|
|
89
|
-
const chainInfo = walletConnectorCore.
|
|
89
|
+
const chainInfo = walletConnectorCore.getChainInfoWithOverrides(connectedChain || '');
|
|
90
90
|
const chainWithIcon = {
|
|
91
91
|
name: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
92
92
|
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import 'react';
|
|
5
5
|
import '../../../../events/dynamicEvents.js';
|
|
6
6
|
import '@dynamic-labs/utils';
|
|
@@ -82,7 +82,7 @@ const useFetchChain = (connector) => {
|
|
|
82
82
|
return { name: '', symbol: undefined };
|
|
83
83
|
const chainId = yield connector.getNetwork();
|
|
84
84
|
const { connectedChain } = connector;
|
|
85
|
-
const chainInfo =
|
|
85
|
+
const chainInfo = getChainInfoWithOverrides(connectedChain || '');
|
|
86
86
|
const chainWithIcon = {
|
|
87
87
|
name: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
88
88
|
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
@@ -85,7 +85,7 @@ const useFetchCurrency = (connector, network) => {
|
|
|
85
85
|
if (!connector)
|
|
86
86
|
return null;
|
|
87
87
|
const chainId = yield connector.getNetwork();
|
|
88
|
-
const chainInfo = walletConnectorCore.
|
|
88
|
+
const chainInfo = walletConnectorCore.getChainInfoWithOverrides((_a = connector.connectedChain) !== null && _a !== void 0 ? _a : '');
|
|
89
89
|
/* istanbul ignore else */
|
|
90
90
|
if (!chainId) {
|
|
91
91
|
return chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getChainInfoWithOverrides } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import 'react';
|
|
5
5
|
import '../../../../events/dynamicEvents.js';
|
|
6
6
|
import '@dynamic-labs/utils';
|
|
@@ -81,7 +81,7 @@ const useFetchCurrency = (connector, network) => {
|
|
|
81
81
|
if (!connector)
|
|
82
82
|
return null;
|
|
83
83
|
const chainId = yield connector.getNetwork();
|
|
84
|
-
const chainInfo =
|
|
84
|
+
const chainInfo = getChainInfoWithOverrides((_a = connector.connectedChain) !== null && _a !== void 0 ? _a : '');
|
|
85
85
|
/* istanbul ignore else */
|
|
86
86
|
if (!chainId) {
|
|
87
87
|
return chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol;
|