@dynamic-labs/sdk-react-core 4.9.1-preview.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 (63) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/lib/components/NetworkPicker/components/NetworkDropdown/NetworkDropdown.cjs +11 -2
  6. package/src/lib/components/NetworkPicker/components/NetworkDropdown/NetworkDropdown.js +11 -2
  7. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +10 -4
  8. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +10 -4
  9. package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -3
  10. package/src/lib/context/DynamicContext/DynamicContext.js +2 -4
  11. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +1 -1
  12. package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +1 -1
  13. package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +2 -3
  14. package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +12 -5
  15. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.cjs +18 -1
  16. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.d.ts +2 -2
  17. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.js +19 -2
  18. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +6 -6
  19. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +6 -6
  20. package/src/lib/utils/functions/findWalletOptionFor/findWalletOptionFor.cjs +1 -1
  21. package/src/lib/utils/functions/findWalletOptionFor/findWalletOptionFor.js +1 -1
  22. package/src/lib/utils/functions/generateMessages/index.cjs +19 -9
  23. package/src/lib/utils/functions/generateMessages/index.js +19 -9
  24. package/src/lib/utils/functions/index.d.ts +0 -1
  25. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.cjs +31 -18
  26. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.d.ts +3 -0
  27. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.js +31 -18
  28. package/src/lib/utils/functions/onrampProviders/coinbase.cjs +55 -0
  29. package/src/lib/utils/functions/onrampProviders/coinbase.d.ts +15 -0
  30. package/src/lib/utils/functions/onrampProviders/coinbase.js +50 -0
  31. package/src/lib/utils/functions/onrampProviders/index.cjs +24 -0
  32. package/src/lib/utils/functions/onrampProviders/index.d.ts +11 -0
  33. package/src/lib/utils/functions/onrampProviders/index.js +19 -0
  34. package/src/lib/utils/functions/openOnrampPopup.cjs +8 -5
  35. package/src/lib/utils/functions/openOnrampPopup.d.ts +4 -2
  36. package/src/lib/utils/functions/openOnrampPopup.js +8 -5
  37. package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +2 -0
  38. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +2 -2
  39. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +2 -2
  40. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +2 -0
  41. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +2 -1
  42. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +2 -0
  43. package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +1 -7
  44. package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.js +1 -7
  45. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +5 -1
  46. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
  47. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +5 -1
  48. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +2 -1
  49. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +2 -1
  50. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +2 -1
  51. package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +8 -2
  52. package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +9 -3
  53. package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +2 -4
  54. package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +3 -5
  55. package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +5 -7
  56. package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +5 -7
  57. package/src/lib/widgets/OnrampWidget/OnrampWidget.cjs +11 -2
  58. package/src/lib/widgets/OnrampWidget/OnrampWidget.d.ts +4 -0
  59. package/src/lib/widgets/OnrampWidget/OnrampWidget.js +11 -2
  60. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.cjs +0 -27
  61. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.d.ts +0 -2
  62. package/src/lib/utils/functions/coinbaseOnramp/formatCoinbaseOnrampUrl.js +0 -23
  63. package/src/lib/utils/functions/coinbaseOnramp/index.d.ts +0 -1
@@ -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;
@@ -0,0 +1,50 @@
1
+ 'use client'
2
+ /**
3
+ * Gets the enabled non-testnet networks for a wallet
4
+ * @param wallet User's wallet
5
+ * @returns Array of enabled non-testnet networks, or empty array if no wallet or networks
6
+ */
7
+ const getEnabledNonTestnetNetworks = (wallet) => {
8
+ if (!wallet ||
9
+ !wallet.connector ||
10
+ typeof wallet.connector.getEnabledNetworks !== 'function') {
11
+ return [];
12
+ }
13
+ const networks = wallet.connector.getEnabledNetworks();
14
+ if (!networks || networks.length === 0) {
15
+ return [];
16
+ }
17
+ return networks.filter((network) => !network.isTestnet);
18
+ };
19
+ /**
20
+ * Formats a Coinbase onramp URL with wallet information
21
+ * @param url Base URL from Coinbase
22
+ * @param wallet User's wallet
23
+ * @returns Formatted URL with wallet information
24
+ */
25
+ const formatCoinbaseOnrampUrl = (url, wallet) => {
26
+ const nonTestnetNetworks = getEnabledNonTestnetNetworks(wallet);
27
+ if (nonTestnetNetworks.length === 0 || !(wallet === null || wallet === void 0 ? void 0 : wallet.address)) {
28
+ return url;
29
+ }
30
+ const baseUrl = new URL(url);
31
+ const appId = baseUrl.searchParams.get('appId');
32
+ // If no appId is present, return the original URL
33
+ if (!appId) {
34
+ return url;
35
+ }
36
+ // Filter out networks with empty or undefined keys and remove duplicates
37
+ const uniqueNetworkKeys = Array.from(new Set(nonTestnetNetworks
38
+ .map((network) => network.key)
39
+ .filter((key) => Boolean(key))));
40
+ if (uniqueNetworkKeys.length === 0) {
41
+ return url;
42
+ }
43
+ // Construct the URL with the raw query parameters
44
+ const finalUrl = `${baseUrl.origin}${baseUrl.pathname}?appId=${appId}&addresses=${encodeURIComponent(JSON.stringify({
45
+ [wallet.address]: uniqueNetworkKeys,
46
+ }))}`;
47
+ return finalUrl;
48
+ };
49
+
50
+ export { formatCoinbaseOnrampUrl, getEnabledNonTestnetNetworks };
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var coinbase = require('./coinbase.cjs');
7
+
8
+ /**
9
+ * Registry of provider-specific URL formatters
10
+ */
11
+ const providerUrlFormatters = {
12
+ coinbaseOnramp: coinbase.formatCoinbaseOnrampUrl,
13
+ };
14
+ /**
15
+ * Registry of provider display modes (iframe or popup)
16
+ */
17
+ const providerDisplayModes = {
18
+ coinbaseOnramp: 'popup',
19
+ // Default for other providers is iframe
20
+ };
21
+
22
+ exports.formatCoinbaseOnrampUrl = coinbase.formatCoinbaseOnrampUrl;
23
+ exports.providerDisplayModes = providerDisplayModes;
24
+ exports.providerUrlFormatters = providerUrlFormatters;
@@ -0,0 +1,11 @@
1
+ import type { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import { formatCoinbaseOnrampUrl } from './coinbase';
3
+ /**
4
+ * Registry of provider-specific URL formatters
5
+ */
6
+ export declare const providerUrlFormatters: Record<string, (url: string, wallet: Wallet) => string>;
7
+ /**
8
+ * Registry of provider display modes (iframe or popup)
9
+ */
10
+ export declare const providerDisplayModes: Record<string, 'iframe' | 'popup'>;
11
+ export { formatCoinbaseOnrampUrl };
@@ -0,0 +1,19 @@
1
+ 'use client'
2
+ import { formatCoinbaseOnrampUrl } from './coinbase.js';
3
+ export { formatCoinbaseOnrampUrl } from './coinbase.js';
4
+
5
+ /**
6
+ * Registry of provider-specific URL formatters
7
+ */
8
+ const providerUrlFormatters = {
9
+ coinbaseOnramp: formatCoinbaseOnrampUrl,
10
+ };
11
+ /**
12
+ * Registry of provider display modes (iframe or popup)
13
+ */
14
+ const providerDisplayModes = {
15
+ coinbaseOnramp: 'popup',
16
+ // Default for other providers is iframe
17
+ };
18
+
19
+ export { providerDisplayModes, providerUrlFormatters };
@@ -4,7 +4,8 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../_virtual/_tslib.cjs');
7
- var formatCoinbaseOnrampUrl = require('./coinbaseOnramp/formatCoinbaseOnrampUrl.cjs');
7
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
8
+ var index = require('./onrampProviders/index.cjs');
8
9
  var openPopup = require('./openPopup/openPopup.cjs');
9
10
 
10
11
  const ONRAMP_POPUP_CONFIG = {
@@ -12,15 +13,17 @@ const ONRAMP_POPUP_CONFIG = {
12
13
  width: 500,
13
14
  };
14
15
  /**
15
- * Opens an onramp popup for Coinbase and sets up event listeners to handle popup closure
16
+ * Opens an onramp popup and sets up event listeners to handle popup closure
16
17
  * @param url The base URL to open in the popup
17
18
  * @param wallet The user's wallet (optional)
18
19
  * @param setShowOnramp Callback to update the UI state when popup is closed
20
+ * @param provider The onramp provider ID
19
21
  * @returns A promise that resolves when the popup is opened
20
22
  */
21
- const openOnrampPopup = (url, wallet, setShowOnramp) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
22
- // Format the URL with wallet information for Coinbase if wallet is provided
23
- const formattedUrl = wallet ? formatCoinbaseOnrampUrl.formatCoinbaseOnrampUrl(url, wallet) : url;
23
+ const openOnrampPopup = (url_1, wallet_1, setShowOnramp_1, ...args_1) => _tslib.__awaiter(void 0, [url_1, wallet_1, setShowOnramp_1, ...args_1], void 0, function* (url, wallet, setShowOnramp, provider = sdkApiCore.OnrampProviders.CoinbaseOnramp) {
24
+ // Format the URL with wallet information if a formatter exists for this provider
25
+ const formatUrl = index.providerUrlFormatters[provider] || ((url) => url);
26
+ const formattedUrl = wallet ? formatUrl(url, wallet) : url;
24
27
  // Open the popup - errors will propagate to the caller
25
28
  yield openPopup.openPopup(formattedUrl, ONRAMP_POPUP_CONFIG.width, ONRAMP_POPUP_CONFIG.height, () => {
26
29
  // When the popup is closed (by user or programmatically), update the UI
@@ -1,13 +1,15 @@
1
1
  import type { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import { OnrampProviders } from '@dynamic-labs/sdk-api-core';
2
3
  export declare const ONRAMP_POPUP_CONFIG: {
3
4
  readonly height: 600;
4
5
  readonly width: 500;
5
6
  };
6
7
  /**
7
- * Opens an onramp popup for Coinbase and sets up event listeners to handle popup closure
8
+ * Opens an onramp popup and sets up event listeners to handle popup closure
8
9
  * @param url The base URL to open in the popup
9
10
  * @param wallet The user's wallet (optional)
10
11
  * @param setShowOnramp Callback to update the UI state when popup is closed
12
+ * @param provider The onramp provider ID
11
13
  * @returns A promise that resolves when the popup is opened
12
14
  */
13
- export declare const openOnrampPopup: (url: string, wallet: Wallet | undefined, setShowOnramp: (show: boolean) => void) => Promise<void>;
15
+ export declare const openOnrampPopup: (url: string, wallet: Wallet | undefined, setShowOnramp: (show: boolean) => void, provider?: OnrampProviders) => Promise<void>;
@@ -1,6 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../_virtual/_tslib.js';
3
- import { formatCoinbaseOnrampUrl } from './coinbaseOnramp/formatCoinbaseOnrampUrl.js';
3
+ import { OnrampProviders } from '@dynamic-labs/sdk-api-core';
4
+ import { providerUrlFormatters } from './onrampProviders/index.js';
4
5
  import { openPopup } from './openPopup/openPopup.js';
5
6
 
6
7
  const ONRAMP_POPUP_CONFIG = {
@@ -8,15 +9,17 @@ const ONRAMP_POPUP_CONFIG = {
8
9
  width: 500,
9
10
  };
10
11
  /**
11
- * Opens an onramp popup for Coinbase and sets up event listeners to handle popup closure
12
+ * Opens an onramp popup and sets up event listeners to handle popup closure
12
13
  * @param url The base URL to open in the popup
13
14
  * @param wallet The user's wallet (optional)
14
15
  * @param setShowOnramp Callback to update the UI state when popup is closed
16
+ * @param provider The onramp provider ID
15
17
  * @returns A promise that resolves when the popup is opened
16
18
  */
17
- const openOnrampPopup = (url, wallet, setShowOnramp) => __awaiter(void 0, void 0, void 0, function* () {
18
- // Format the URL with wallet information for Coinbase if wallet is provided
19
- const formattedUrl = wallet ? formatCoinbaseOnrampUrl(url, wallet) : url;
19
+ const openOnrampPopup = (url_1, wallet_1, setShowOnramp_1, ...args_1) => __awaiter(void 0, [url_1, wallet_1, setShowOnramp_1, ...args_1], void 0, function* (url, wallet, setShowOnramp, provider = OnrampProviders.CoinbaseOnramp) {
20
+ // Format the URL with wallet information if a formatter exists for this provider
21
+ const formatUrl = providerUrlFormatters[provider] || ((url) => url);
22
+ const formattedUrl = wallet ? formatUrl(url, wallet) : url;
20
23
  // Open the popup - errors will propagate to the caller
21
24
  yield openPopup(formattedUrl, ONRAMP_POPUP_CONFIG.width, ONRAMP_POPUP_CONFIG.height, () => {
22
25
  // When the popup is closed (by user or programmatically), update the UI
@@ -13,6 +13,8 @@ export type SocialStorageItem = {
13
13
  code?: string;
14
14
  /** Social auth mode, either sign-in or link */
15
15
  mode: SocialAuthMode;
16
+ /** Whether to show the widget after a connection is made */
17
+ showWidgetAfterConnection?: boolean;
16
18
  };
17
19
  export type SocialStorage = Partial<Record<ProviderEnum, SocialStorageItem>>;
18
20
  export declare const searchSocialStorageByState: (targetState: string) => SocialStorageItem | undefined;
@@ -133,8 +133,8 @@ const useDynamicWaas = () => {
133
133
  }
134
134
  if (!walletConnectorOptions.length || !environmentId || !apiBaseUrl)
135
135
  return undefined;
136
- const connectorKey = chainName === 'EVM' ? dynamicWaasKey : `${dynamicWaasKey}-svm`;
137
- const walletConnector = (_a = walletConnectorOptions.find((option) => option.key.includes(connectorKey))) === null || _a === void 0 ? void 0 : _a.walletConnector;
136
+ const walletConnector = (_a = walletConnectorOptions.find((option) => option.key.includes(dynamicWaasKey) &&
137
+ option.walletConnector.connectedChain === chainName)) === null || _a === void 0 ? void 0 : _a.walletConnector;
138
138
  if (!walletConnector) {
139
139
  throw new utils.DynamicError(constants.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR);
140
140
  }
@@ -129,8 +129,8 @@ const useDynamicWaas = () => {
129
129
  }
130
130
  if (!walletConnectorOptions.length || !environmentId || !apiBaseUrl)
131
131
  return undefined;
132
- const connectorKey = chainName === 'EVM' ? dynamicWaasKey : `${dynamicWaasKey}-svm`;
133
- const walletConnector = (_a = walletConnectorOptions.find((option) => option.key.includes(connectorKey))) === null || _a === void 0 ? void 0 : _a.walletConnector;
132
+ const walletConnector = (_a = walletConnectorOptions.find((option) => option.key.includes(dynamicWaasKey) &&
133
+ option.walletConnector.connectedChain === chainName)) === null || _a === void 0 ? void 0 : _a.walletConnector;
134
134
  if (!walletConnector) {
135
135
  throw new DynamicError(DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR);
136
136
  }
@@ -160,6 +160,7 @@ const useEmbeddedWallet = () => {
160
160
  return revealTurnkeyEmbeddedWalletKey(options);
161
161
  });
162
162
  const shouldPromptForKeyExport = React.useCallback(() => { var _a; return Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.promptForKeyExport); }, [projectSettings]);
163
+ const embeddedWalletSettingVersion = React.useCallback(() => { var _a; return (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion; }, [projectSettings]);
163
164
  const shouldAutoCreateEmbeddedWallet = React.useCallback((verifiedUser) => {
164
165
  var _a, _b, _c, _d, _e, _f;
165
166
  const hasEmbeddedWalletProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
@@ -197,6 +198,7 @@ const useEmbeddedWallet = () => {
197
198
  createEmbeddedWalletAccount,
198
199
  createOrRestoreSession,
199
200
  createPasskey,
201
+ embeddedWalletSettingVersion,
200
202
  getPasskeys,
201
203
  getWalletVersion,
202
204
  isLoadingEmbeddedWallet,
@@ -1,4 +1,4 @@
1
- import { EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
1
+ import { EmbeddedWalletChainEnum, EmbeddedWalletVersionEnum } from '@dynamic-labs/sdk-api-core';
2
2
  import { Wallet } from '../../../shared';
3
3
  import { UserProfile } from '../../../..';
4
4
  /**
@@ -27,6 +27,7 @@ export declare const useEmbeddedWallet: () => {
27
27
  readonly createPasskey: (options: {
28
28
  oneTimeCode: string;
29
29
  } | undefined) => Promise<import("dist/packages/wallet-connector-core/src").WebAuthnAttestation>;
30
+ readonly embeddedWalletSettingVersion: () => EmbeddedWalletVersionEnum | undefined;
30
31
  readonly getPasskeys: () => Promise<import("@dynamic-labs/sdk-api-core").UserPasskey[]>;
31
32
  readonly getWalletVersion: () => import(".").EmbeddedWalletVersion | undefined;
32
33
  readonly isLoadingEmbeddedWallet: boolean;
@@ -156,6 +156,7 @@ const useEmbeddedWallet = () => {
156
156
  return revealTurnkeyEmbeddedWalletKey(options);
157
157
  });
158
158
  const shouldPromptForKeyExport = useCallback(() => { var _a; return Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.promptForKeyExport); }, [projectSettings]);
159
+ const embeddedWalletSettingVersion = useCallback(() => { var _a; return (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion; }, [projectSettings]);
159
160
  const shouldAutoCreateEmbeddedWallet = useCallback((verifiedUser) => {
160
161
  var _a, _b, _c, _d, _e, _f;
161
162
  const hasEmbeddedWalletProviderEnabled = isTurnkeyEnabled(projectSettings);
@@ -193,6 +194,7 @@ const useEmbeddedWallet = () => {
193
194
  createEmbeddedWalletAccount,
194
195
  createOrRestoreSession,
195
196
  createPasskey,
197
+ embeddedWalletSettingVersion,
196
198
  getPasskeys,
197
199
  getWalletVersion,
198
200
  isLoadingEmbeddedWallet,
@@ -9,7 +9,6 @@ var logger = require('../../../shared/logger.cjs');
9
9
  var index = require('../../../shared/utils/functions/lastAuthenticatedAccount/index.cjs');
10
10
  var shouldFetchNonce = require('../../../shared/utils/functions/shouldFetchNonce/shouldFetchNonce.cjs');
11
11
  var loadingAndLifecycle = require('../../../store/state/loadingAndLifecycle.cjs');
12
- var connectorsInitializing = require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
13
12
 
14
13
  const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWalletId, primaryWallet, user, isUserLoading, walletBook: walletBook$1, enableInstrumentation, appName, environmentId, nonce, }) => {
15
14
  var _a;
@@ -17,8 +16,6 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
17
16
  const hasLoaded = React.useRef(false);
18
17
  const loadingStart = React.useRef(new Date().getTime());
19
18
  const { sessionValidation } = loadingAndLifecycle.useLoadingAndLifecycle();
20
- const connectorsInitializingState = connectorsInitializing.useConnectorsInitializing();
21
- const isWaitingForConnectorsInitialization = React.useMemo(() => Object.values(connectorsInitializingState).some(Boolean), [connectorsInitializingState]);
22
19
  const isFetchingNonce = React.useMemo(() => shouldFetchNonce.shouldFetchNonce({
23
20
  authMode,
24
21
  }) && !nonce, [authMode, nonce]);
@@ -59,14 +56,12 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
59
56
  connectedWallets.length === 0;
60
57
  const isValidatingSession = !sessionValidation;
61
58
  logger.logger.logVerboseTroubleshootingMessage('[useGlobalLoading] SDK loading', {
62
- connectorsInitializingState,
63
59
  isConnectOnlyWalletsLoading,
64
60
  isFetchingNonce,
65
61
  isPrimaryWalletLoading,
66
62
  isProjectSettingsLoading,
67
63
  isUserLoading,
68
64
  isValidatingSession,
69
- isWaitingForConnectorsInitialization,
70
65
  isWalletBookLoading,
71
66
  });
72
67
  if (!isWalletBookLoading &&
@@ -75,8 +70,7 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
75
70
  !isPrimaryWalletLoading &&
76
71
  !isConnectOnlyWalletsLoading &&
77
72
  !isValidatingSession &&
78
- !isFetchingNonce &&
79
- !isWaitingForConnectorsInitialization) {
73
+ !isFetchingNonce) {
80
74
  finishLoading();
81
75
  }
82
76
  return hasLoaded.current;
@@ -5,7 +5,6 @@ import { logger } from '../../../shared/logger.js';
5
5
  import { lastAuthenticatedAccount } from '../../../shared/utils/functions/lastAuthenticatedAccount/index.js';
6
6
  import { shouldFetchNonce } from '../../../shared/utils/functions/shouldFetchNonce/shouldFetchNonce.js';
7
7
  import { useLoadingAndLifecycle } from '../../../store/state/loadingAndLifecycle.js';
8
- import { useConnectorsInitializing } from '../../../store/state/connectorsInitializing/connectorsInitializing.js';
9
8
 
10
9
  const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWalletId, primaryWallet, user, isUserLoading, walletBook, enableInstrumentation, appName, environmentId, nonce, }) => {
11
10
  var _a;
@@ -13,8 +12,6 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
13
12
  const hasLoaded = useRef(false);
14
13
  const loadingStart = useRef(new Date().getTime());
15
14
  const { sessionValidation } = useLoadingAndLifecycle();
16
- const connectorsInitializingState = useConnectorsInitializing();
17
- const isWaitingForConnectorsInitialization = useMemo(() => Object.values(connectorsInitializingState).some(Boolean), [connectorsInitializingState]);
18
15
  const isFetchingNonce = useMemo(() => shouldFetchNonce({
19
16
  authMode,
20
17
  }) && !nonce, [authMode, nonce]);
@@ -55,14 +52,12 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
55
52
  connectedWallets.length === 0;
56
53
  const isValidatingSession = !sessionValidation;
57
54
  logger.logVerboseTroubleshootingMessage('[useGlobalLoading] SDK loading', {
58
- connectorsInitializingState,
59
55
  isConnectOnlyWalletsLoading,
60
56
  isFetchingNonce,
61
57
  isPrimaryWalletLoading,
62
58
  isProjectSettingsLoading,
63
59
  isUserLoading,
64
60
  isValidatingSession,
65
- isWaitingForConnectorsInitialization,
66
61
  isWalletBookLoading,
67
62
  });
68
63
  if (!isWalletBookLoading &&
@@ -71,8 +66,7 @@ const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSe
71
66
  !isPrimaryWalletLoading &&
72
67
  !isConnectOnlyWalletsLoading &&
73
68
  !isValidatingSession &&
74
- !isFetchingNonce &&
75
- !isWaitingForConnectorsInitialization) {
69
+ !isFetchingNonce) {
76
70
  finishLoading();
77
71
  }
78
72
  return hasLoaded.current;
@@ -144,11 +144,15 @@ const useSocialAccounts = () => {
144
144
  }
145
145
  return true;
146
146
  }, [handleError, projectSettings]);
147
- const linkSocialAccount = React.useCallback((provider_1, ...args_1) => _tslib.__awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl } = { redirectUrl: undefined }) {
147
+ const linkSocialAccount = React.useCallback((provider_1, ...args_1) => _tslib.__awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl, showWidgetAfterConnection } = {
148
+ redirectUrl: undefined,
149
+ showWidgetAfterConnection: false,
150
+ }) {
148
151
  connectSocialAccount({
149
152
  authMode: 'link',
150
153
  provider,
151
154
  redirectUrl,
155
+ showWidgetAfterConnection,
152
156
  validator: checkValidOAuthLinking,
153
157
  });
154
158
  }), [checkValidOAuthLinking, connectSocialAccount]);
@@ -5,6 +5,10 @@ type ConnectSocialProps = {
5
5
  * Overrides the redirectUrl provided by DynamicContextProvider
6
6
  */
7
7
  redirectUrl?: string;
8
+ /**
9
+ * Whether to show the widget after a connection is made
10
+ */
11
+ showWidgetAfterConnection?: boolean;
8
12
  };
9
13
  export declare const useSocialAccounts: () => {
10
14
  readonly error: import("@dynamic-labs/types").SocialOAuthError | undefined;
@@ -12,7 +16,7 @@ export declare const useSocialAccounts: () => {
12
16
  readonly getLinkedAccounts: (provider: ProviderEnum) => SocialAccountInformation[];
13
17
  readonly isLinked: (provider: ProviderEnum) => boolean;
14
18
  readonly isProcessing: boolean;
15
- readonly linkSocialAccount: (provider: ProviderEnum, { redirectUrl }?: ConnectSocialProps) => Promise<void>;
19
+ readonly linkSocialAccount: (provider: ProviderEnum, { redirectUrl, showWidgetAfterConnection }?: ConnectSocialProps) => Promise<void>;
16
20
  readonly signInWithSocialAccount: (provider: ProviderEnum, { redirectUrl }?: ConnectSocialProps) => Promise<void>;
17
21
  readonly unlinkSocialAccount: (provider: ProviderEnum, verifiedCredentialId?: string) => Promise<void>;
18
22
  };
@@ -140,11 +140,15 @@ const useSocialAccounts = () => {
140
140
  }
141
141
  return true;
142
142
  }, [handleError, projectSettings]);
143
- const linkSocialAccount = useCallback((provider_1, ...args_1) => __awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl } = { redirectUrl: undefined }) {
143
+ const linkSocialAccount = useCallback((provider_1, ...args_1) => __awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl, showWidgetAfterConnection } = {
144
+ redirectUrl: undefined,
145
+ showWidgetAfterConnection: false,
146
+ }) {
144
147
  connectSocialAccount({
145
148
  authMode: 'link',
146
149
  provider,
147
150
  redirectUrl,
151
+ showWidgetAfterConnection,
148
152
  validator: checkValidOAuthLinking,
149
153
  });
150
154
  }), [checkValidOAuthLinking, connectSocialAccount]);
@@ -354,7 +354,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
354
354
  shouldRegisterSessionKeysOnSignin,
355
355
  signInAccount,
356
356
  ]);
357
- const connectSocialAccount = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ authMode, provider, validator, captchaToken, redirectUrl, telegramAuthToken, }) {
357
+ const connectSocialAccount = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ authMode, provider, validator, captchaToken, redirectUrl, telegramAuthToken, showWidgetAfterConnection, }) {
358
358
  var _d, _e;
359
359
  clearError();
360
360
  setIsProcessing(true);
@@ -388,6 +388,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
388
388
  captchaToken,
389
389
  codeVerifier: usingPkce ? verifier : undefined,
390
390
  mode: authMode,
391
+ showWidgetAfterConnection,
391
392
  state,
392
393
  });
393
394
  const loginUrlString = getOauthLoginUrl.getOauthLoginUrl((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);