@dynamic-labs/sdk-react-core 4.9.0 → 4.9.1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +10 -4
  6. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +10 -4
  7. package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +12 -5
  8. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.cjs +18 -1
  9. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.d.ts +2 -2
  10. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.js +19 -2
  11. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +5 -5
  12. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +5 -5
  13. package/src/lib/utils/functions/findWalletOptionFor/findWalletOptionFor.cjs +1 -1
  14. package/src/lib/utils/functions/findWalletOptionFor/findWalletOptionFor.js +1 -1
  15. package/src/lib/utils/functions/generateMessages/index.cjs +19 -9
  16. package/src/lib/utils/functions/generateMessages/index.js +19 -9
  17. package/src/lib/utils/functions/index.d.ts +0 -1
  18. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.cjs +31 -18
  19. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.d.ts +3 -0
  20. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.js +31 -18
  21. package/src/lib/utils/functions/onrampProviders/coinbase.cjs +55 -0
  22. package/src/lib/utils/functions/onrampProviders/coinbase.d.ts +15 -0
  23. package/src/lib/utils/functions/onrampProviders/coinbase.js +50 -0
  24. package/src/lib/utils/functions/onrampProviders/index.cjs +24 -0
  25. package/src/lib/utils/functions/onrampProviders/index.d.ts +11 -0
  26. package/src/lib/utils/functions/onrampProviders/index.js +19 -0
  27. package/src/lib/utils/functions/openOnrampPopup.cjs +8 -5
  28. package/src/lib/utils/functions/openOnrampPopup.d.ts +4 -2
  29. package/src/lib/utils/functions/openOnrampPopup.js +8 -5
  30. package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +2 -0
  31. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +2 -2
  32. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +2 -2
  33. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +2 -0
  34. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +2 -1
  35. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +2 -0
  36. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +5 -1
  37. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
  38. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +5 -1
  39. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +2 -1
  40. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +2 -1
  41. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +2 -1
  42. package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +8 -2
  43. package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +9 -3
  44. package/src/lib/widgets/OnrampWidget/OnrampWidget.cjs +11 -2
  45. package/src/lib/widgets/OnrampWidget/OnrampWidget.d.ts +4 -0
  46. package/src/lib/widgets/OnrampWidget/OnrampWidget.js +11 -2
  47. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.cjs +0 -27
  48. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.d.ts +0 -2
  49. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.js +0 -23
  50. package/src/lib/utils/functions/coinbaseOnramp/index.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,4 +1,21 @@
1
1
 
2
+ ### [4.9.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.0...v4.9.1) (2025-03-11)
3
+
4
+
5
+ ### Features
6
+
7
+ * waas svm connector ([#8191](https://github.com/dynamic-labs/dynamic-auth/issues/8191)) ([049a360](https://github.com/dynamic-labs/dynamic-auth/commit/049a360642d6aa2122676c7a29d36a7baef9e49b))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 7702 on sepolia ([#8242](https://github.com/dynamic-labs/dynamic-auth/issues/8242)) ([8e1c63f](https://github.com/dynamic-labs/dynamic-auth/commit/8e1c63f240024f419e12787636dd2ebaacf8da94))
13
+ * close auth flow when promptExport enabled but createWallet is false ([#8239](https://github.com/dynamic-labs/dynamic-auth/issues/8239)) ([f82429f](https://github.com/dynamic-labs/dynamic-auth/commit/f82429f85e729a76c2516f0db112033fdd2a36d5))
14
+ * fix solana genesis hashes bug that was causing a breaking change ([#8250](https://github.com/dynamic-labs/dynamic-auth/issues/8250)) ([731c93b](https://github.com/dynamic-labs/dynamic-auth/commit/731c93bea4b8b95caa8cc665f2ecb53f9948ef8e))
15
+ * move setup-inside-iframe utility method to the utils package ([#8256](https://github.com/dynamic-labs/dynamic-auth/issues/8256)) ([d34eb6d](https://github.com/dynamic-labs/dynamic-auth/commit/d34eb6d211baecb496b84fefaee8179a5fb1b52a))
16
+ * **QNTM-2952:** support headless social sign in ([#8226](https://github.com/dynamic-labs/dynamic-auth/issues/8226)) ([0c3082d](https://github.com/dynamic-labs/dynamic-auth/commit/0c3082d593c633519c9eed20be15186f18f65c09))
17
+ * sign message with trust wallet on solana ([#8249](https://github.com/dynamic-labs/dynamic-auth/issues/8249)) ([99a7917](https://github.com/dynamic-labs/dynamic-auth/commit/99a791796f7d2c83b9f18e45367aa9689c67869d))
18
+
2
19
  ## [4.9.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.6...v4.9.0) (2025-03-07)
3
20
 
4
21
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.9.0";
6
+ var version = "4.9.1";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.638",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "4.9.0";
2
+ var version = "4.9.1";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.638",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.0.638",
6
6
  "@hcaptcha/react-hcaptcha": "1.4.4",
@@ -14,16 +14,16 @@
14
14
  "yup": "0.32.11",
15
15
  "react-international-phone": "4.2.5",
16
16
  "bs58": "5.0.0",
17
- "@dynamic-labs/assert-package-version": "4.9.0",
18
- "@dynamic-labs/iconic": "4.9.0",
19
- "@dynamic-labs/logger": "4.9.0",
20
- "@dynamic-labs/multi-wallet": "4.9.0",
21
- "@dynamic-labs/rpc-providers": "4.9.0",
22
- "@dynamic-labs/store": "4.9.0",
23
- "@dynamic-labs/types": "4.9.0",
24
- "@dynamic-labs/utils": "4.9.0",
25
- "@dynamic-labs/wallet-book": "4.9.0",
26
- "@dynamic-labs/wallet-connector-core": "4.9.0",
17
+ "@dynamic-labs/assert-package-version": "4.9.1",
18
+ "@dynamic-labs/iconic": "4.9.1",
19
+ "@dynamic-labs/logger": "4.9.1",
20
+ "@dynamic-labs/multi-wallet": "4.9.1",
21
+ "@dynamic-labs/rpc-providers": "4.9.1",
22
+ "@dynamic-labs/store": "4.9.1",
23
+ "@dynamic-labs/types": "4.9.1",
24
+ "@dynamic-labs/utils": "4.9.1",
25
+ "@dynamic-labs/wallet-book": "4.9.1",
26
+ "@dynamic-labs/wallet-connector-core": "4.9.1",
27
27
  "eventemitter3": "5.0.1"
28
28
  },
29
29
  "devDependencies": {
@@ -4,11 +4,11 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
7
8
  var iconic = require('@dynamic-labs/iconic');
8
9
  require('@dynamic-labs/utils');
9
10
  require('../../../Accordion/components/AccordionItem/AccordionItem.cjs');
10
11
  require('../../../Alert/Alert.cjs');
11
- require('react');
12
12
  require('../../../../events/dynamicEvents.cjs');
13
13
  require('../../../../../../_virtual/_tslib.cjs');
14
14
  require('../../../../context/DynamicContext/DynamicContext.cjs');
@@ -115,9 +115,15 @@ const UserProfileSocialAccount = ({ provider, }) => {
115
115
  const isActiveCredential = !primaryWallet &&
116
116
  connectedAccountInfo &&
117
117
  (connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.id) === (user === null || user === void 0 ? void 0 : user.lastVerifiedCredentialId);
118
- const renderButton = () => (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonPadding: 'none', onClick: () => isProviderLinked
119
- ? unlinkSocialAccount(provider)
120
- : linkSocialAccount(provider), loading: isProcessing, dataTestId: `social-account-${isProviderLinked ? 'disconnect' : 'connect'}-button`, typographyProps: {
118
+ const handleSocialAccountButton = React.useCallback(() => {
119
+ if (isProviderLinked) {
120
+ unlinkSocialAccount(provider);
121
+ }
122
+ else {
123
+ linkSocialAccount(provider, { showWidgetAfterConnection: true });
124
+ }
125
+ }, [isProviderLinked, linkSocialAccount, provider, unlinkSocialAccount]);
126
+ const renderButton = () => (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonPadding: 'none', onClick: handleSocialAccountButton, loading: isProcessing, dataTestId: `social-account-${isProviderLinked ? 'disconnect' : 'connect'}-button`, typographyProps: {
121
127
  color: 'secondary',
122
128
  variant: 'button_tertiary',
123
129
  }, startSlot:
@@ -1,10 +1,10 @@
1
1
  'use client'
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useCallback } from 'react';
3
4
  import { SocialIcon } from '@dynamic-labs/iconic';
4
5
  import '@dynamic-labs/utils';
5
6
  import '../../../Accordion/components/AccordionItem/AccordionItem.js';
6
7
  import '../../../Alert/Alert.js';
7
- import 'react';
8
8
  import '../../../../events/dynamicEvents.js';
9
9
  import '../../../../../../_virtual/_tslib.js';
10
10
  import '../../../../context/DynamicContext/DynamicContext.js';
@@ -111,9 +111,15 @@ const UserProfileSocialAccount = ({ provider, }) => {
111
111
  const isActiveCredential = !primaryWallet &&
112
112
  connectedAccountInfo &&
113
113
  (connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.id) === (user === null || user === void 0 ? void 0 : user.lastVerifiedCredentialId);
114
- const renderButton = () => (jsx(TypographyButton, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonPadding: 'none', onClick: () => isProviderLinked
115
- ? unlinkSocialAccount(provider)
116
- : linkSocialAccount(provider), loading: isProcessing, dataTestId: `social-account-${isProviderLinked ? 'disconnect' : 'connect'}-button`, typographyProps: {
114
+ const handleSocialAccountButton = useCallback(() => {
115
+ if (isProviderLinked) {
116
+ unlinkSocialAccount(provider);
117
+ }
118
+ else {
119
+ linkSocialAccount(provider, { showWidgetAfterConnection: true });
120
+ }
121
+ }, [isProviderLinked, linkSocialAccount, provider, unlinkSocialAccount]);
122
+ const renderButton = () => (jsx(TypographyButton, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonPadding: 'none', onClick: handleSocialAccountButton, loading: isProcessing, dataTestId: `social-account-${isProviderLinked ? 'disconnect' : 'connect'}-button`, typographyProps: {
117
123
  color: 'secondary',
118
124
  variant: 'button_tertiary',
119
125
  }, startSlot:
@@ -28,16 +28,23 @@ export type OnrampOption = {
28
28
  */
29
29
  id: string;
30
30
  /**
31
- * (optional) The iframe URL of the onramp provider to be displayed in UI
32
- * If provided, the SDK will use this iframe URL to display the onramp provider in the UI
33
- * and will ignore the `onClick` handler
31
+ * The URL of the onramp provider
32
+ * For iframe mode, this is displayed directly in the UI
33
+ * For popup mode, this is opened in a new window when the provider is selected
34
34
  * Example: "https://widget.coinbase.com/iframe/onramp?apiKey=YOUR_API_KEY&walletAddress=YOUR_WALLET_ADDRESS"
35
35
  */
36
- iframeUrl?: string;
36
+ url?: string;
37
+ /**
38
+ * The display mode for the onramp provider
39
+ * 'iframe' - The provider will be displayed in an iframe within the UI
40
+ * 'popup' - The provider will be opened in a new window when selected
41
+ * @default 'iframe'
42
+ */
43
+ openMode?: 'iframe' | 'popup';
37
44
  /**
38
45
  * The onClick handler for when the onramp provider is selected
39
46
  * takes the primary wallet as an argument
40
- * It will be ignored if `iframeUrl` is provided
47
+ * It will be ignored if in iframe mode with a URL provided
41
48
  */
42
49
  onClick: ({ wallet }: {
43
50
  wallet: Wallet;
@@ -10,6 +10,7 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
10
  var getWalletAdditionalAddressByType = require('../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.cjs');
11
11
  var usePromise = require('../../../utils/hooks/usePromise/usePromise.cjs');
12
12
  var onramp = require('../../../data/api/onramp/onramp.cjs');
13
+ var coinbase = require('../../../utils/functions/onrampProviders/coinbase.cjs');
13
14
 
14
15
  const useEnabledOnrampProviders = ({ primaryWallet, network, environmentId, projectSettingsOnramps, target, }) => {
15
16
  var _a;
@@ -20,6 +21,10 @@ const useEnabledOnrampProviders = ({ primaryWallet, network, environmentId, proj
20
21
  walletConnectorCore.isBitcoinConnector(primaryWallet.connector) &&
21
22
  getWalletAdditionalAddressByType.getWalletAdditionalAddressByType(sdkApiCore.WalletAddressType.Payment, primaryWallet);
22
23
  const chainHasNetwork = network && chainName === 'evm';
24
+ const nonTestnetNetworks = primaryWallet
25
+ ? coinbase.getEnabledNonTestnetNetworks(primaryWallet)
26
+ : [];
27
+ const hasNonTestnetNetworks = nonTestnetNetworks.length > 0;
23
28
  const { data: onrampProviders } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
24
29
  if (!chainName || !(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address))
25
30
  return [];
@@ -42,7 +47,19 @@ const useEnabledOnrampProviders = ({ primaryWallet, network, environmentId, proj
42
47
  enabled: Boolean(projectSettingsOnramps === null || projectSettingsOnramps === void 0 ? void 0 : projectSettingsOnramps.length),
43
48
  initialData: [],
44
49
  });
45
- return React.useMemo(() => onrampProviders.filter((p) => projectSettingsOnramps === null || projectSettingsOnramps === void 0 ? void 0 : projectSettingsOnramps.includes(p.provider)), [onrampProviders, projectSettingsOnramps]);
50
+ return React.useMemo(() => {
51
+ const filteredProviders = onrampProviders
52
+ .filter((p) => projectSettingsOnramps === null || projectSettingsOnramps === void 0 ? void 0 : projectSettingsOnramps.includes(p.provider))
53
+ .filter((p) => {
54
+ // Only apply network filtering to Coinbase
55
+ if (p.provider === sdkApiCore.ProviderEnum.CoinbaseOnramp) {
56
+ return hasNonTestnetNetworks;
57
+ }
58
+ // Always show other providers (like Banxa)
59
+ return true;
60
+ });
61
+ return filteredProviders;
62
+ }, [onrampProviders, projectSettingsOnramps, hasNonTestnetNetworks]);
46
63
  };
47
64
 
48
65
  exports.useEnabledOnrampProviders = useEnabledOnrampProviders;
@@ -1,5 +1,5 @@
1
- import { Wallet } from '@dynamic-labs/wallet-connector-core';
2
- import { OnrampConfiguration, OnrampProviders } from '@dynamic-labs/sdk-api-core';
1
+ import { type Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import { type OnrampConfiguration, type OnrampProviders } from '@dynamic-labs/sdk-api-core';
3
3
  export type EnabledOnrampProvidersTarget = {
4
4
  address?: string;
5
5
  token?: string;
@@ -2,10 +2,11 @@
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useMemo } from 'react';
4
4
  import { getChainInfo, isBitcoinConnector } from '@dynamic-labs/wallet-connector-core';
5
- import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
5
+ import { WalletAddressType, ProviderEnum } from '@dynamic-labs/sdk-api-core';
6
6
  import { getWalletAdditionalAddressByType } from '../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.js';
7
7
  import { usePromise } from '../../../utils/hooks/usePromise/usePromise.js';
8
8
  import { getOnrampProviders } from '../../../data/api/onramp/onramp.js';
9
+ import { getEnabledNonTestnetNetworks } from '../../../utils/functions/onrampProviders/coinbase.js';
9
10
 
10
11
  const useEnabledOnrampProviders = ({ primaryWallet, network, environmentId, projectSettingsOnramps, target, }) => {
11
12
  var _a;
@@ -16,6 +17,10 @@ const useEnabledOnrampProviders = ({ primaryWallet, network, environmentId, proj
16
17
  isBitcoinConnector(primaryWallet.connector) &&
17
18
  getWalletAdditionalAddressByType(WalletAddressType.Payment, primaryWallet);
18
19
  const chainHasNetwork = network && chainName === 'evm';
20
+ const nonTestnetNetworks = primaryWallet
21
+ ? getEnabledNonTestnetNetworks(primaryWallet)
22
+ : [];
23
+ const hasNonTestnetNetworks = nonTestnetNetworks.length > 0;
19
24
  const { data: onrampProviders } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
20
25
  if (!chainName || !(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address))
21
26
  return [];
@@ -38,7 +43,19 @@ const useEnabledOnrampProviders = ({ primaryWallet, network, environmentId, proj
38
43
  enabled: Boolean(projectSettingsOnramps === null || projectSettingsOnramps === void 0 ? void 0 : projectSettingsOnramps.length),
39
44
  initialData: [],
40
45
  });
41
- return useMemo(() => onrampProviders.filter((p) => projectSettingsOnramps === null || projectSettingsOnramps === void 0 ? void 0 : projectSettingsOnramps.includes(p.provider)), [onrampProviders, projectSettingsOnramps]);
46
+ return useMemo(() => {
47
+ const filteredProviders = onrampProviders
48
+ .filter((p) => projectSettingsOnramps === null || projectSettingsOnramps === void 0 ? void 0 : projectSettingsOnramps.includes(p.provider))
49
+ .filter((p) => {
50
+ // Only apply network filtering to Coinbase
51
+ if (p.provider === ProviderEnum.CoinbaseOnramp) {
52
+ return hasNonTestnetNetworks;
53
+ }
54
+ // Always show other providers (like Banxa)
55
+ return true;
56
+ });
57
+ return filteredProviders;
58
+ }, [onrampProviders, projectSettingsOnramps, hasNonTestnetNetworks]);
42
59
  };
43
60
 
44
61
  export { useEnabledOnrampProviders };
@@ -121,10 +121,6 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
121
121
  isRenderingEmbeddedAuthFlow,
122
122
  setShowAuthFlow,
123
123
  ]);
124
- const updateInterfaceStateForLink = React.useCallback(() => {
125
- setDynamicWidgetView('profile');
126
- setShowDynamicUserProfile(true);
127
- }, [setDynamicWidgetView, setShowDynamicUserProfile]);
128
124
  useEffectOnce.useEffectOnce(() => {
129
125
  // Do not run on server side
130
126
  if (isSSR.isSSR())
@@ -161,7 +157,11 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
161
157
  logger.logger.error(new utils.DynamicError('User not logged in'));
162
158
  return;
163
159
  }
164
- updateInterfaceStateForLink();
160
+ // Link was called from the widget, so show the profile on redirect
161
+ if (socialStorageItem.showWidgetAfterConnection) {
162
+ setDynamicWidgetView('profile');
163
+ setShowDynamicUserProfile(true);
164
+ }
165
165
  }
166
166
  yield completeConnection({
167
167
  authCode: socialStorageItem.code,
@@ -117,10 +117,6 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
117
117
  isRenderingEmbeddedAuthFlow,
118
118
  setShowAuthFlow,
119
119
  ]);
120
- const updateInterfaceStateForLink = useCallback(() => {
121
- setDynamicWidgetView('profile');
122
- setShowDynamicUserProfile(true);
123
- }, [setDynamicWidgetView, setShowDynamicUserProfile]);
124
120
  useEffectOnce(() => {
125
121
  // Do not run on server side
126
122
  if (isSSR())
@@ -157,7 +153,11 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
157
153
  logger.error(new DynamicError('User not logged in'));
158
154
  return;
159
155
  }
160
- updateInterfaceStateForLink();
156
+ // Link was called from the widget, so show the profile on redirect
157
+ if (socialStorageItem.showWidgetAfterConnection) {
158
+ setDynamicWidgetView('profile');
159
+ setShowDynamicUserProfile(true);
160
+ }
161
161
  }
162
162
  yield completeConnection({
163
163
  authCode: socialStorageItem.code,
@@ -8,7 +8,7 @@ var compareChains = require('../compareChains/compareChains.cjs');
8
8
 
9
9
  const findWalletOptionFor = (account, walletOptions) => {
10
10
  const { walletName } = account;
11
- if (walletName === 'turnkeyhd') {
11
+ if (walletName === 'turnkeyhd' || walletName === 'dynamicwaas') {
12
12
  const chain = account.chain
13
13
  ? values.VerifiedCredentialNameToChainEnum[account.chain]
14
14
  : undefined;
@@ -4,7 +4,7 @@ import { compareChains } from '../compareChains/compareChains.js';
4
4
 
5
5
  const findWalletOptionFor = (account, walletOptions) => {
6
6
  const { walletName } = account;
7
- if (walletName === 'turnkeyhd') {
7
+ if (walletName === 'turnkeyhd' || walletName === 'dynamicwaas') {
8
8
  const chain = account.chain
9
9
  ? VerifiedCredentialNameToChainEnum[account.chain]
10
10
  : undefined;
@@ -7,6 +7,24 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var multiWallet = require('@dynamic-labs/multi-wallet');
8
8
  var utils = require('@dynamic-labs/utils');
9
9
 
10
+ const getChainIdForMessage = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
11
+ // If it's a Solana wallet, we should not specify a chainId
12
+ // since it breaks the message signature in some wallets (e.g. Trust Wallet)
13
+ if (walletConnector.connectedChain === 'SOL') {
14
+ return undefined;
15
+ }
16
+ const chain = yield walletConnector.getNetwork(true);
17
+ if (chain) {
18
+ return chain;
19
+ }
20
+ if (walletConnector.key === 'bloctoevm') {
21
+ return 137;
22
+ }
23
+ if (walletConnector.connectedChain === 'EVM') {
24
+ return 1;
25
+ }
26
+ return chain;
27
+ });
10
28
  const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEnvironmentId, displaySiweStatement, siweStatement) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
11
29
  if (publicWalletAddress === undefined) {
12
30
  throw new utils.DynamicError('Unable to fetch the public address from the wallet');
@@ -14,15 +32,7 @@ const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEn
14
32
  if (!walletConnector.connectedChain) {
15
33
  throw new utils.DynamicError('Wallet is not connected');
16
34
  }
17
- let chainId = yield walletConnector.getNetwork(true);
18
- if (chainId === undefined) {
19
- if (walletConnector.key === 'bloctoevm') {
20
- chainId = 137;
21
- }
22
- else if (walletConnector.connectedChain === 'EVM') {
23
- chainId = 1;
24
- }
25
- }
35
+ const chainId = yield getChainIdForMessage(walletConnector);
26
36
  const parsedAddress = walletConnector.parseAddress(publicWalletAddress);
27
37
  const currentUrl = utils.PlatformService.getUrl();
28
38
  const messageToSign = multiWallet.generateMessageToSign({
@@ -3,6 +3,24 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { generateMessageToSign } from '@dynamic-labs/multi-wallet';
4
4
  import { DynamicError, PlatformService } from '@dynamic-labs/utils';
5
5
 
6
+ const getChainIdForMessage = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
7
+ // If it's a Solana wallet, we should not specify a chainId
8
+ // since it breaks the message signature in some wallets (e.g. Trust Wallet)
9
+ if (walletConnector.connectedChain === 'SOL') {
10
+ return undefined;
11
+ }
12
+ const chain = yield walletConnector.getNetwork(true);
13
+ if (chain) {
14
+ return chain;
15
+ }
16
+ if (walletConnector.key === 'bloctoevm') {
17
+ return 137;
18
+ }
19
+ if (walletConnector.connectedChain === 'EVM') {
20
+ return 1;
21
+ }
22
+ return chain;
23
+ });
6
24
  const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEnvironmentId, displaySiweStatement, siweStatement) => __awaiter(void 0, void 0, void 0, function* () {
7
25
  if (publicWalletAddress === undefined) {
8
26
  throw new DynamicError('Unable to fetch the public address from the wallet');
@@ -10,15 +28,7 @@ const generateMessages = (publicWalletAddress, walletConnector, nonce, projectEn
10
28
  if (!walletConnector.connectedChain) {
11
29
  throw new DynamicError('Wallet is not connected');
12
30
  }
13
- let chainId = yield walletConnector.getNetwork(true);
14
- if (chainId === undefined) {
15
- if (walletConnector.key === 'bloctoevm') {
16
- chainId = 137;
17
- }
18
- else if (walletConnector.connectedChain === 'EVM') {
19
- chainId = 1;
20
- }
21
- }
31
+ const chainId = yield getChainIdForMessage(walletConnector);
22
32
  const parsedAddress = walletConnector.parseAddress(publicWalletAddress);
23
33
  const currentUrl = PlatformService.getUrl();
24
34
  const messageToSign = generateMessageToSign({
@@ -78,5 +78,4 @@ export * from './isAuthenticatedWithAWallet';
78
78
  export * from './networksAndChains';
79
79
  export * from './updatePrimaryWalletId';
80
80
  export * from './getWalletUniqueId';
81
- export * from './coinbaseOnramp';
82
81
  export * from './openPopup';
@@ -4,28 +4,41 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var openOnrampPopup = require('../openOnrampPopup.cjs');
7
+ var index = require('../onrampProviders/index.cjs');
7
8
 
9
+ /**
10
+ * Converts an OnrampConfiguration to an OnrampOption based on the provider's display mode
11
+ */
8
12
  const onrampConfigurationToOnrampOption = (provider, onClick, setShowOnramp) => {
9
- var _a, _b, _c;
10
- const isPopupImplementation = provider.provider === 'coinbaseOnramp';
11
- return {
12
- displayName: (_b = (_a = provider.name) !== null && _a !== void 0 ? _a : provider.provider) !== null && _b !== void 0 ? _b : '',
13
- iconUrl: (_c = provider.iconUrl) !== null && _c !== void 0 ? _c : '',
13
+ var _a, _b, _c, _d;
14
+ // Determine if this provider uses popup or iframe mode
15
+ const providerKey = provider.provider;
16
+ const openMode = (_a = index.providerDisplayModes[providerKey]) !== null && _a !== void 0 ? _a : 'iframe';
17
+ // Create common properties
18
+ const baseProperties = {
19
+ displayName: (_c = (_b = provider.name) !== null && _b !== void 0 ? _b : provider.provider) !== null && _c !== void 0 ? _c : '',
20
+ iconUrl: (_d = provider.iconUrl) !== null && _d !== void 0 ? _d : '',
14
21
  id: String(provider.provider),
15
- // For Coinbase, we don't use the iframeUrl in the widget, we handle it in onClick
16
- iframeUrl: isPopupImplementation ? undefined : provider.url,
17
- onClick: (params) => {
18
- // Call the provided onClick to set the selected provider
19
- onClick({
20
- onrampProvider: provider.provider,
21
- });
22
- // For Coinbase, handle the popup opening directly in the onClick
23
- if (isPopupImplementation && provider.url && setShowOnramp) {
24
- // Use the new openOnrampPopup function to handle the popup logic
25
- openOnrampPopup.openOnrampPopup(provider.url, params.wallet, setShowOnramp);
26
- }
27
- },
22
+ openMode,
23
+ url: provider.url,
28
24
  };
25
+ // Create base onClick handler
26
+ const baseOnClick = (params) => {
27
+ onClick({
28
+ onrampProvider: provider.provider,
29
+ });
30
+ };
31
+ // For popup mode, enhance the onClick handler to open the popup
32
+ if (openMode === 'popup') {
33
+ return Object.assign(Object.assign({}, baseProperties), { onClick: (params) => {
34
+ baseOnClick();
35
+ if (provider.url && setShowOnramp) {
36
+ openOnrampPopup.openOnrampPopup(provider.url, params.wallet, setShowOnramp, provider.provider);
37
+ }
38
+ } });
39
+ }
40
+ // For iframe mode, use the base onClick handler
41
+ return Object.assign(Object.assign({}, baseProperties), { onClick: baseOnClick });
29
42
  };
30
43
 
31
44
  exports.onrampConfigurationToOnrampOption = onrampConfigurationToOnrampOption;
@@ -1,5 +1,8 @@
1
1
  import type { OnrampConfiguration, OnrampProviders } from '@dynamic-labs/sdk-api-core';
2
2
  import type { OnrampOption } from '../../../context/DynamicContext';
3
+ /**
4
+ * Converts an OnrampConfiguration to an OnrampOption based on the provider's display mode
5
+ */
3
6
  export declare const onrampConfigurationToOnrampOption: (provider: OnrampConfiguration, onClick: ({ onrampProvider }: {
4
7
  onrampProvider: OnrampProviders;
5
8
  }) => void, setShowOnramp?: (show: boolean) => void) => OnrampOption;
@@ -1,27 +1,40 @@
1
1
  'use client'
2
2
  import { openOnrampPopup } from '../openOnrampPopup.js';
3
+ import { providerDisplayModes } from '../onrampProviders/index.js';
3
4
 
5
+ /**
6
+ * Converts an OnrampConfiguration to an OnrampOption based on the provider's display mode
7
+ */
4
8
  const onrampConfigurationToOnrampOption = (provider, onClick, setShowOnramp) => {
5
- var _a, _b, _c;
6
- const isPopupImplementation = provider.provider === 'coinbaseOnramp';
7
- return {
8
- displayName: (_b = (_a = provider.name) !== null && _a !== void 0 ? _a : provider.provider) !== null && _b !== void 0 ? _b : '',
9
- iconUrl: (_c = provider.iconUrl) !== null && _c !== void 0 ? _c : '',
9
+ var _a, _b, _c, _d;
10
+ // Determine if this provider uses popup or iframe mode
11
+ const providerKey = provider.provider;
12
+ const openMode = (_a = providerDisplayModes[providerKey]) !== null && _a !== void 0 ? _a : 'iframe';
13
+ // Create common properties
14
+ const baseProperties = {
15
+ displayName: (_c = (_b = provider.name) !== null && _b !== void 0 ? _b : provider.provider) !== null && _c !== void 0 ? _c : '',
16
+ iconUrl: (_d = provider.iconUrl) !== null && _d !== void 0 ? _d : '',
10
17
  id: String(provider.provider),
11
- // For Coinbase, we don't use the iframeUrl in the widget, we handle it in onClick
12
- iframeUrl: isPopupImplementation ? undefined : provider.url,
13
- onClick: (params) => {
14
- // Call the provided onClick to set the selected provider
15
- onClick({
16
- onrampProvider: provider.provider,
17
- });
18
- // For Coinbase, handle the popup opening directly in the onClick
19
- if (isPopupImplementation && provider.url && setShowOnramp) {
20
- // Use the new openOnrampPopup function to handle the popup logic
21
- openOnrampPopup(provider.url, params.wallet, setShowOnramp);
22
- }
23
- },
18
+ openMode,
19
+ url: provider.url,
24
20
  };
21
+ // Create base onClick handler
22
+ const baseOnClick = (params) => {
23
+ onClick({
24
+ onrampProvider: provider.provider,
25
+ });
26
+ };
27
+ // For popup mode, enhance the onClick handler to open the popup
28
+ if (openMode === 'popup') {
29
+ return Object.assign(Object.assign({}, baseProperties), { onClick: (params) => {
30
+ baseOnClick();
31
+ if (provider.url && setShowOnramp) {
32
+ openOnrampPopup(provider.url, params.wallet, setShowOnramp, provider.provider);
33
+ }
34
+ } });
35
+ }
36
+ // For iframe mode, use the base onClick handler
37
+ return Object.assign(Object.assign({}, baseProperties), { onClick: baseOnClick });
25
38
  };
26
39
 
27
40
  export { onrampConfigurationToOnrampOption };
@@ -0,0 +1,55 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Gets the enabled non-testnet networks for a wallet
8
+ * @param wallet User's wallet
9
+ * @returns Array of enabled non-testnet networks, or empty array if no wallet or networks
10
+ */
11
+ const getEnabledNonTestnetNetworks = (wallet) => {
12
+ if (!wallet ||
13
+ !wallet.connector ||
14
+ typeof wallet.connector.getEnabledNetworks !== 'function') {
15
+ return [];
16
+ }
17
+ const networks = wallet.connector.getEnabledNetworks();
18
+ if (!networks || networks.length === 0) {
19
+ return [];
20
+ }
21
+ return networks.filter((network) => !network.isTestnet);
22
+ };
23
+ /**
24
+ * Formats a Coinbase onramp URL with wallet information
25
+ * @param url Base URL from Coinbase
26
+ * @param wallet User's wallet
27
+ * @returns Formatted URL with wallet information
28
+ */
29
+ const formatCoinbaseOnrampUrl = (url, wallet) => {
30
+ const nonTestnetNetworks = getEnabledNonTestnetNetworks(wallet);
31
+ if (nonTestnetNetworks.length === 0 || !(wallet === null || wallet === void 0 ? void 0 : wallet.address)) {
32
+ return url;
33
+ }
34
+ const baseUrl = new URL(url);
35
+ const appId = baseUrl.searchParams.get('appId');
36
+ // If no appId is present, return the original URL
37
+ if (!appId) {
38
+ return url;
39
+ }
40
+ // Filter out networks with empty or undefined keys and remove duplicates
41
+ const uniqueNetworkKeys = Array.from(new Set(nonTestnetNetworks
42
+ .map((network) => network.key)
43
+ .filter((key) => Boolean(key))));
44
+ if (uniqueNetworkKeys.length === 0) {
45
+ return url;
46
+ }
47
+ // Construct the URL with the raw query parameters
48
+ const finalUrl = `${baseUrl.origin}${baseUrl.pathname}?appId=${appId}&addresses=${encodeURIComponent(JSON.stringify({
49
+ [wallet.address]: uniqueNetworkKeys,
50
+ }))}`;
51
+ return finalUrl;
52
+ };
53
+
54
+ exports.formatCoinbaseOnrampUrl = formatCoinbaseOnrampUrl;
55
+ exports.getEnabledNonTestnetNetworks = getEnabledNonTestnetNetworks;
@@ -0,0 +1,15 @@
1
+ import type { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import type { GenericNetwork } from '@dynamic-labs/types';
3
+ /**
4
+ * Gets the enabled non-testnet networks for a wallet
5
+ * @param wallet User's wallet
6
+ * @returns Array of enabled non-testnet networks, or empty array if no wallet or networks
7
+ */
8
+ export declare const getEnabledNonTestnetNetworks: (wallet?: Wallet) => GenericNetwork[];
9
+ /**
10
+ * Formats a Coinbase onramp URL with wallet information
11
+ * @param url Base URL from Coinbase
12
+ * @param wallet User's wallet
13
+ * @returns Formatted URL with wallet information
14
+ */
15
+ export declare const formatCoinbaseOnrampUrl: (url: string, wallet?: Wallet) => string;