@dynamic-labs/multi-wallet 4.0.0-alpha.9 → 4.0.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +483 -1
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +8 -8
  5. package/src/const.cjs +33 -0
  6. package/src/const.d.ts +3 -0
  7. package/src/const.js +29 -0
  8. package/src/index.cjs +11 -6
  9. package/src/index.d.ts +1 -2
  10. package/src/index.js +6 -2
  11. package/src/utils/{getApiProviders.d.ts → getApiProviders/getApiProviders.d.ts} +6 -0
  12. package/src/utils/getApiProviders/index.d.ts +1 -0
  13. package/src/utils/getEnabledProviders/getEnabledProviders.cjs +18 -0
  14. package/src/utils/getEnabledProviders/getEnabledProviders.d.ts +2 -0
  15. package/src/utils/getEnabledProviders/getEnabledProviders.js +14 -0
  16. package/src/utils/getEnabledProviders/index.d.ts +1 -0
  17. package/src/utils/getEnabledWallets/getEnabledWallets.cjs +16 -0
  18. package/src/utils/getEnabledWallets/getEnabledWallets.d.ts +6 -0
  19. package/src/utils/getEnabledWallets/getEnabledWallets.js +12 -0
  20. package/src/utils/getEnabledWallets/index.d.ts +1 -0
  21. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.cjs +41 -0
  22. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.d.ts +3 -0
  23. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.js +37 -0
  24. package/src/utils/getSupportedChainsForWalletConnector/index.d.ts +1 -0
  25. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.cjs +17 -0
  26. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.d.ts +3 -0
  27. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.js +13 -0
  28. package/src/utils/getSupportedWallets/applyLinksOverrides/index.d.ts +1 -0
  29. package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.cjs +30 -0
  30. package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.d.ts +3 -0
  31. package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.js +26 -0
  32. package/src/utils/getSupportedWallets/filterWalletsForPlatform/index.d.ts +1 -0
  33. package/src/utils/getSupportedWallets/getSupportedWallets.cjs +71 -0
  34. package/src/utils/getSupportedWallets/getSupportedWallets.d.ts +2 -0
  35. package/src/utils/getSupportedWallets/getSupportedWallets.js +67 -0
  36. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.cjs +35 -0
  37. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.d.ts +2 -0
  38. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.js +31 -0
  39. package/src/utils/getSupportedWallets/handleMobileWalletFilter/index.d.ts +1 -0
  40. package/src/utils/getSupportedWallets/index.d.ts +1 -0
  41. package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.cjs +42 -0
  42. package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.d.ts +162 -0
  43. package/src/utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.js +38 -0
  44. package/src/utils/getWalletConnectorConstructorOptions/index.d.ts +1 -0
  45. package/src/utils/index.d.ts +6 -0
  46. package/src/utils/message/index.d.ts +1 -0
  47. package/src/multi-wallet.cjs +0 -178
  48. package/src/multi-wallet.d.ts +0 -11
  49. package/src/multi-wallet.js +0 -171
  50. /package/src/utils/{getApiProviders.cjs → getApiProviders/getApiProviders.cjs} +0 -0
  51. /package/src/utils/{getApiProviders.js → getApiProviders/getApiProviders.js} +0 -0
  52. /package/src/utils/{message.cjs → message/message.cjs} +0 -0
  53. /package/src/utils/{message.d.ts → message/message.d.ts} +0 -0
  54. /package/src/utils/{message.js → message/message.js} +0 -0
package/src/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './multi-wallet';
2
1
  export * from './types';
3
- export { generateMessageToSign } from './utils/message';
2
+ export * from './utils';
package/src/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  'use client'
2
2
  import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
3
3
  import { version } from '../package.js';
4
- export { getEnabledProviders, getEnabledWallets, getSupportedChainsForWalletConnector, getSupportedWallets } from './multi-wallet.js';
5
- export { generateMessageToSign } from './utils/message.js';
4
+ export { generateMessageToSign } from './utils/message/message.js';
5
+ export { getEnabledProviders } from './utils/getEnabledProviders/getEnabledProviders.js';
6
+ export { getEnabledWallets } from './utils/getEnabledWallets/getEnabledWallets.js';
7
+ export { getSupportedWallets } from './utils/getSupportedWallets/getSupportedWallets.js';
8
+ export { getSupportedChainsForWalletConnector } from './utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.js';
9
+ export { getWalletConnectorConstructorOptions } from './utils/getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.js';
6
10
 
7
11
  assertPackageVersion('@dynamic-labs/multi-wallet', version);
@@ -6,6 +6,7 @@ export declare const getApiProviders: (providers: Provider[]) => {
6
6
  bitbucket?: Provider | undefined;
7
7
  coinbasesocial?: Provider | undefined;
8
8
  discord?: Provider | undefined;
9
+ epicgames?: Provider | undefined;
9
10
  facebook?: Provider | undefined;
10
11
  farcaster?: Provider | undefined;
11
12
  github?: Provider | undefined;
@@ -25,4 +26,9 @@ export declare const getApiProviders: (providers: Provider[]) => {
25
26
  turnkey?: Provider | undefined;
26
27
  coinbaseWaas?: Provider | undefined;
27
28
  sms?: Provider | undefined;
29
+ spotify?: Provider | undefined;
30
+ tiktok?: Provider | undefined;
31
+ line?: Provider | undefined;
32
+ steam?: Provider | undefined;
33
+ shopify?: Provider | undefined;
28
34
  };
@@ -0,0 +1 @@
1
+ export * from './getApiProviders';
@@ -0,0 +1,18 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
+
8
+ // get list of providers enabled in the sense that we should have wallet connectors for them
9
+ // note: magic and turnkey are considered enabled when a provider exists (for magic, a providerProjectId exists)
10
+ const getEnabledProviders = (providers) => {
11
+ var _a;
12
+ return (_a = providers === null || providers === void 0 ? void 0 : providers.filter((provider) => Boolean(provider.enabledAt) ||
13
+ (provider.provider === sdkApiCore.ProviderEnum.MagicLink &&
14
+ Boolean(provider.providerProjectId)) ||
15
+ provider.provider === sdkApiCore.ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
16
+ };
17
+
18
+ exports.getEnabledProviders = getEnabledProviders;
@@ -0,0 +1,2 @@
1
+ import { Provider } from '@dynamic-labs/sdk-api-core';
2
+ export declare const getEnabledProviders: (providers: Provider[] | undefined) => Provider[];
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
3
+
4
+ // get list of providers enabled in the sense that we should have wallet connectors for them
5
+ // note: magic and turnkey are considered enabled when a provider exists (for magic, a providerProjectId exists)
6
+ const getEnabledProviders = (providers) => {
7
+ var _a;
8
+ return (_a = providers === null || providers === void 0 ? void 0 : providers.filter((provider) => Boolean(provider.enabledAt) ||
9
+ (provider.provider === ProviderEnum.MagicLink &&
10
+ Boolean(provider.providerProjectId)) ||
11
+ provider.provider === ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
12
+ };
13
+
14
+ export { getEnabledProviders };
@@ -0,0 +1 @@
1
+ export * from './getEnabledProviders';
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var getSupportedWallets = require('../getSupportedWallets/getSupportedWallets.cjs');
7
+ var getSupportedChainsForWalletConnector = require('../getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.cjs');
8
+
9
+ // this function will return a list of connectors that are enabled based on the chains that are enabled
10
+ const getEnabledWallets = (props) => {
11
+ const supportedWallets = getSupportedWallets.getSupportedWallets(props.getSupportedWalletOpts);
12
+ const allEnabledWallets = supportedWallets.filter((wallet) => props.enabledChains.some((chain) => getSupportedChainsForWalletConnector.getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) || wallet.key === 'magiclink');
13
+ return allEnabledWallets;
14
+ };
15
+
16
+ exports.getEnabledWallets = getEnabledWallets;
@@ -0,0 +1,6 @@
1
+ import { Chain, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { GetSupportedWalletsOpts } from '../../types';
3
+ export declare const getEnabledWallets: (props: {
4
+ enabledChains: Chain[];
5
+ getSupportedWalletOpts: GetSupportedWalletsOpts;
6
+ }) => InternalWalletConnector[];
@@ -0,0 +1,12 @@
1
+ 'use client'
2
+ import { getSupportedWallets } from '../getSupportedWallets/getSupportedWallets.js';
3
+ import { getSupportedChainsForWalletConnector } from '../getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.js';
4
+
5
+ // this function will return a list of connectors that are enabled based on the chains that are enabled
6
+ const getEnabledWallets = (props) => {
7
+ const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
8
+ const allEnabledWallets = supportedWallets.filter((wallet) => props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) || wallet.key === 'magiclink');
9
+ return allEnabledWallets;
10
+ };
11
+
12
+ export { getEnabledWallets };
@@ -0,0 +1 @@
1
+ export * from './getEnabledWallets';
@@ -0,0 +1,41 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletBook = require('@dynamic-labs/wallet-book');
7
+
8
+ const chainStringToChains = {
9
+ 'eip155:1': ['ETH', 'EVM'],
10
+ 'flow:mainnet': ['FLOW'],
11
+ };
12
+ const getSupportedChainsForWalletConnector = (walletBook$1, walletConnector) => {
13
+ var _a;
14
+ const walletBookWallet = walletBook.findWalletBookWallet(walletBook$1, walletConnector.key);
15
+ if (!walletBookWallet) {
16
+ return walletConnector.supportedChains;
17
+ }
18
+ /**
19
+ * chains could contain multiple eth networks eg
20
+ * "eip155:1",
21
+ * "eip155:10",
22
+ * "eip155:56",
23
+ * "eip155:100",
24
+ *
25
+ * so we will use a set to ensure uniqueness
26
+ */
27
+ const chainSet = new Set();
28
+ const chainStringList = (_a = walletBookWallet.chains) !== null && _a !== void 0 ? _a : [];
29
+ chainStringList.forEach((chainString) => {
30
+ const chains = chainStringToChains[chainString];
31
+ chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
32
+ chainSet.add(chain);
33
+ });
34
+ });
35
+ walletConnector.supportedChains.forEach((chain) => {
36
+ chainSet.add(chain);
37
+ });
38
+ return [...chainSet];
39
+ };
40
+
41
+ exports.getSupportedChainsForWalletConnector = getSupportedChainsForWalletConnector;
@@ -0,0 +1,3 @@
1
+ import { Chain, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
3
+ export declare const getSupportedChainsForWalletConnector: (walletBook: WalletBookSchema, walletConnector: InternalWalletConnector) => Chain[];
@@ -0,0 +1,37 @@
1
+ 'use client'
2
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
3
+
4
+ const chainStringToChains = {
5
+ 'eip155:1': ['ETH', 'EVM'],
6
+ 'flow:mainnet': ['FLOW'],
7
+ };
8
+ const getSupportedChainsForWalletConnector = (walletBook, walletConnector) => {
9
+ var _a;
10
+ const walletBookWallet = findWalletBookWallet(walletBook, walletConnector.key);
11
+ if (!walletBookWallet) {
12
+ return walletConnector.supportedChains;
13
+ }
14
+ /**
15
+ * chains could contain multiple eth networks eg
16
+ * "eip155:1",
17
+ * "eip155:10",
18
+ * "eip155:56",
19
+ * "eip155:100",
20
+ *
21
+ * so we will use a set to ensure uniqueness
22
+ */
23
+ const chainSet = new Set();
24
+ const chainStringList = (_a = walletBookWallet.chains) !== null && _a !== void 0 ? _a : [];
25
+ chainStringList.forEach((chainString) => {
26
+ const chains = chainStringToChains[chainString];
27
+ chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
28
+ chainSet.add(chain);
29
+ });
30
+ });
31
+ walletConnector.supportedChains.forEach((chain) => {
32
+ chainSet.add(chain);
33
+ });
34
+ return [...chainSet];
35
+ };
36
+
37
+ export { getSupportedChainsForWalletConnector };
@@ -0,0 +1 @@
1
+ export { getSupportedChainsForWalletConnector } from './getSupportedChainsForWalletConnector';
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletBook = require('@dynamic-labs/wallet-book');
7
+
8
+ const applyLinksOverrides = (walletBook$1, wallets) => wallets.map((wallet) => {
9
+ const walletData = walletBook.findWalletBookWallet(walletBook$1, wallet.key);
10
+ if ((walletData === null || walletData === void 0 ? void 0 : walletData.switchNetworkOnlyFromWallet) !== undefined) {
11
+ wallet.switchNetworkOnlyFromWallet =
12
+ walletData.switchNetworkOnlyFromWallet;
13
+ }
14
+ return wallet;
15
+ });
16
+
17
+ exports.applyLinksOverrides = applyLinksOverrides;
@@ -0,0 +1,3 @@
1
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
2
+ import { InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
3
+ export declare const applyLinksOverrides: (walletBook: WalletBookSchema, wallets: InternalWalletConnector[]) => import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector[];
@@ -0,0 +1,13 @@
1
+ 'use client'
2
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
3
+
4
+ const applyLinksOverrides = (walletBook, wallets) => wallets.map((wallet) => {
5
+ const walletData = findWalletBookWallet(walletBook, wallet.key);
6
+ if ((walletData === null || walletData === void 0 ? void 0 : walletData.switchNetworkOnlyFromWallet) !== undefined) {
7
+ wallet.switchNetworkOnlyFromWallet =
8
+ walletData.switchNetworkOnlyFromWallet;
9
+ }
10
+ return wallet;
11
+ });
12
+
13
+ export { applyLinksOverrides };
@@ -0,0 +1 @@
1
+ export * from './applyLinksOverrides';
@@ -0,0 +1,30 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
+ var utils = require('@dynamic-labs/utils');
8
+ var walletBook = require('@dynamic-labs/wallet-book');
9
+ var handleMobileWalletFilter = require('../handleMobileWalletFilter/handleMobileWalletFilter.cjs');
10
+
11
+ const filterWalletsForPlatform = (walletBook$1, connectors) => connectors.filter((connector) => {
12
+ const walletBookWallet = walletBook.findWalletBookWallet(walletBook$1, connector.key);
13
+ if (connector.isInstalledOnBrowser()) {
14
+ return true;
15
+ }
16
+ else if (walletConnectorCore.isEmbeddedConnector(connector)) {
17
+ return true;
18
+ }
19
+ else if (walletBookWallet === null || walletBookWallet === void 0 ? void 0 : walletBookWallet.showOnlyIfInstalled) {
20
+ return false;
21
+ }
22
+ else if (!utils.isMobile()) {
23
+ return true;
24
+ }
25
+ else {
26
+ return handleMobileWalletFilter.handleMobileWalletFilter(connector);
27
+ }
28
+ });
29
+
30
+ exports.filterWalletsForPlatform = filterWalletsForPlatform;
@@ -0,0 +1,3 @@
1
+ import { InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
3
+ export declare const filterWalletsForPlatform: (walletBook: WalletBookSchema, connectors: InternalWalletConnector[]) => import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector[];
@@ -0,0 +1,26 @@
1
+ 'use client'
2
+ import { isEmbeddedConnector } from '@dynamic-labs/wallet-connector-core';
3
+ import { isMobile } from '@dynamic-labs/utils';
4
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
5
+ import { handleMobileWalletFilter } from '../handleMobileWalletFilter/handleMobileWalletFilter.js';
6
+
7
+ const filterWalletsForPlatform = (walletBook, connectors) => connectors.filter((connector) => {
8
+ const walletBookWallet = findWalletBookWallet(walletBook, connector.key);
9
+ if (connector.isInstalledOnBrowser()) {
10
+ return true;
11
+ }
12
+ else if (isEmbeddedConnector(connector)) {
13
+ return true;
14
+ }
15
+ else if (walletBookWallet === null || walletBookWallet === void 0 ? void 0 : walletBookWallet.showOnlyIfInstalled) {
16
+ return false;
17
+ }
18
+ else if (!isMobile()) {
19
+ return true;
20
+ }
21
+ else {
22
+ return handleMobileWalletFilter(connector);
23
+ }
24
+ });
25
+
26
+ export { filterWalletsForPlatform };
@@ -0,0 +1 @@
1
+ export * from './filterWalletsForPlatform';
@@ -0,0 +1,71 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
+ var getWalletConnectorConstructorOptions = require('../getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.cjs');
8
+ var filterWalletsForPlatform = require('./filterWalletsForPlatform/filterWalletsForPlatform.cjs');
9
+ var applyLinksOverrides = require('./applyLinksOverrides/applyLinksOverrides.cjs');
10
+
11
+ // needs to be a global variable, otherwise it breaks the list of wallets in the dashboard
12
+ // https://linear.app/dynamic-labs/issue/QNTM-2642/update-to-getsupportedwallets-broke-the-list-of-wallets-on-the
13
+ let walletConnectors = [];
14
+ const getSupportedWallets = (args) => {
15
+ var _a;
16
+ const { settings, skipMemo = false, walletConnectorsProp, walletBook } = args;
17
+ if (!skipMemo && walletConnectors.length > 0) {
18
+ return walletConnectors;
19
+ }
20
+ const disabledConnectors = (_a = settings.sdk.disabledWalletConnectors) !== null && _a !== void 0 ? _a : [];
21
+ const opts = getWalletConnectorConstructorOptions.getWalletConnectorConstructorOptions(args);
22
+ const allWalletConnectors = walletConnectorsProp
23
+ .map((getWalletConnectorConstructors) => getWalletConnectorConstructors(opts))
24
+ .flat()
25
+ .map((walletConnectorConstructor) => {
26
+ try {
27
+ // This may contain third party code so we must be ready for anything
28
+ return new walletConnectorConstructor(opts);
29
+ }
30
+ catch (error) {
31
+ walletConnectorCore.logger.error(`Failed to construct wallet ${walletConnectorConstructor.name}`, error);
32
+ return undefined;
33
+ }
34
+ })
35
+ // filter out undefined and disabled connectors
36
+ .filter((walletConnector) => {
37
+ var _a;
38
+ return walletConnector &&
39
+ (!((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
40
+ !disabledConnectors.includes(walletConnector.metadata.id));
41
+ })
42
+ // initialize the wallet connector if it's not a WalletConnect connector
43
+ // or just the generic 'walletconnect' connector, not other WC connectors
44
+ .map((walletConnector) => {
45
+ if (!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isWalletConnect) ||
46
+ walletConnector.key === 'walletconnect') {
47
+ walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.init();
48
+ }
49
+ return walletConnector;
50
+ })
51
+ // applies custom filter defined in the wallet connector
52
+ .filter((walletConnector) => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.filter())
53
+ .map((walletConnector) => walletConnector.getMobileOrInstalledWallet());
54
+ // Filter out duplicated wallets (WC vs. non-WC)
55
+ const nonDuplicatedWalletConnectors = allWalletConnectors.filter((walletConnector) => {
56
+ if (!walletConnector.isWalletConnect)
57
+ return true;
58
+ // if current wallet is WalletConnect, check if there is another wallet with the same key that is
59
+ // not WalletConnect
60
+ // if there is, return false (filter out WC wallet)
61
+ // if there is no other wallet with the same key that is not WalletConnect, return true (keep WC wallet)
62
+ return !allWalletConnectors.some((wc) => wc.key === walletConnector.key &&
63
+ !wc.isWalletConnect &&
64
+ wc.isInstalledOnBrowser());
65
+ });
66
+ const filteredWalletConnectors = filterWalletsForPlatform.filterWalletsForPlatform(walletBook, nonDuplicatedWalletConnectors);
67
+ walletConnectors = applyLinksOverrides.applyLinksOverrides(walletBook, filteredWalletConnectors);
68
+ return walletConnectors;
69
+ };
70
+
71
+ exports.getSupportedWallets = getSupportedWallets;
@@ -0,0 +1,2 @@
1
+ import { GetSupportedWallets } from '../../types';
2
+ export declare const getSupportedWallets: GetSupportedWallets;
@@ -0,0 +1,67 @@
1
+ 'use client'
2
+ import { logger } from '@dynamic-labs/wallet-connector-core';
3
+ import { getWalletConnectorConstructorOptions } from '../getWalletConnectorConstructorOptions/getWalletConnectorConstructorOptions.js';
4
+ import { filterWalletsForPlatform } from './filterWalletsForPlatform/filterWalletsForPlatform.js';
5
+ import { applyLinksOverrides } from './applyLinksOverrides/applyLinksOverrides.js';
6
+
7
+ // needs to be a global variable, otherwise it breaks the list of wallets in the dashboard
8
+ // https://linear.app/dynamic-labs/issue/QNTM-2642/update-to-getsupportedwallets-broke-the-list-of-wallets-on-the
9
+ let walletConnectors = [];
10
+ const getSupportedWallets = (args) => {
11
+ var _a;
12
+ const { settings, skipMemo = false, walletConnectorsProp, walletBook } = args;
13
+ if (!skipMemo && walletConnectors.length > 0) {
14
+ return walletConnectors;
15
+ }
16
+ const disabledConnectors = (_a = settings.sdk.disabledWalletConnectors) !== null && _a !== void 0 ? _a : [];
17
+ const opts = getWalletConnectorConstructorOptions(args);
18
+ const allWalletConnectors = walletConnectorsProp
19
+ .map((getWalletConnectorConstructors) => getWalletConnectorConstructors(opts))
20
+ .flat()
21
+ .map((walletConnectorConstructor) => {
22
+ try {
23
+ // This may contain third party code so we must be ready for anything
24
+ return new walletConnectorConstructor(opts);
25
+ }
26
+ catch (error) {
27
+ logger.error(`Failed to construct wallet ${walletConnectorConstructor.name}`, error);
28
+ return undefined;
29
+ }
30
+ })
31
+ // filter out undefined and disabled connectors
32
+ .filter((walletConnector) => {
33
+ var _a;
34
+ return walletConnector &&
35
+ (!((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
36
+ !disabledConnectors.includes(walletConnector.metadata.id));
37
+ })
38
+ // initialize the wallet connector if it's not a WalletConnect connector
39
+ // or just the generic 'walletconnect' connector, not other WC connectors
40
+ .map((walletConnector) => {
41
+ if (!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isWalletConnect) ||
42
+ walletConnector.key === 'walletconnect') {
43
+ walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.init();
44
+ }
45
+ return walletConnector;
46
+ })
47
+ // applies custom filter defined in the wallet connector
48
+ .filter((walletConnector) => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.filter())
49
+ .map((walletConnector) => walletConnector.getMobileOrInstalledWallet());
50
+ // Filter out duplicated wallets (WC vs. non-WC)
51
+ const nonDuplicatedWalletConnectors = allWalletConnectors.filter((walletConnector) => {
52
+ if (!walletConnector.isWalletConnect)
53
+ return true;
54
+ // if current wallet is WalletConnect, check if there is another wallet with the same key that is
55
+ // not WalletConnect
56
+ // if there is, return false (filter out WC wallet)
57
+ // if there is no other wallet with the same key that is not WalletConnect, return true (keep WC wallet)
58
+ return !allWalletConnectors.some((wc) => wc.key === walletConnector.key &&
59
+ !wc.isWalletConnect &&
60
+ wc.isInstalledOnBrowser());
61
+ });
62
+ const filteredWalletConnectors = filterWalletsForPlatform(walletBook, nonDuplicatedWalletConnectors);
63
+ walletConnectors = applyLinksOverrides(walletBook, filteredWalletConnectors);
64
+ return walletConnectors;
65
+ };
66
+
67
+ export { getSupportedWallets };
@@ -0,0 +1,35 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var utils = require('@dynamic-labs/utils');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
+
9
+ const handleMobileWalletFilter = (connector) => {
10
+ var _a, _b;
11
+ if (!connector.metadata)
12
+ return false;
13
+ const { downloadLinks, deepLinks } = connector.metadata;
14
+ /**
15
+ * WalletConnect provides a "universal" and "native" deep link. They recommend using
16
+ * the universal deep link over the native one due to UX differences, and our current
17
+ * implementation uses only universal. This means we need to filter for wallets that
18
+ * have a universal deep link available.
19
+ */
20
+ const hasWalletConnectLink = Boolean((_a = deepLinks === null || deepLinks === void 0 ? void 0 : deepLinks.mobile) === null || _a === void 0 ? void 0 : _a.universal) || Boolean((_b = deepLinks === null || deepLinks === void 0 ? void 0 : deepLinks.mobile) === null || _b === void 0 ? void 0 : _b.native);
21
+ const shouldShowIfHadDownloadLink = !connector.isWalletConnect ||
22
+ connector.key === 'walletconnect' ||
23
+ hasWalletConnectLink;
24
+ const walletLinks = walletConnectorCore.getWalletLinks(downloadLinks);
25
+ if (utils.isIPad() || utils.isIPhone()) {
26
+ const hasIOSLink = Boolean(walletLinks.ios);
27
+ return hasIOSLink && shouldShowIfHadDownloadLink;
28
+ }
29
+ else {
30
+ const hasAndroidLink = Boolean(walletLinks.android);
31
+ return hasAndroidLink && shouldShowIfHadDownloadLink;
32
+ }
33
+ };
34
+
35
+ exports.handleMobileWalletFilter = handleMobileWalletFilter;
@@ -0,0 +1,2 @@
1
+ import { InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ export declare const handleMobileWalletFilter: (connector: InternalWalletConnector) => boolean;
@@ -0,0 +1,31 @@
1
+ 'use client'
2
+ import { isIPad, isIPhone } from '@dynamic-labs/utils';
3
+ import { getWalletLinks } from '@dynamic-labs/wallet-connector-core';
4
+
5
+ const handleMobileWalletFilter = (connector) => {
6
+ var _a, _b;
7
+ if (!connector.metadata)
8
+ return false;
9
+ const { downloadLinks, deepLinks } = connector.metadata;
10
+ /**
11
+ * WalletConnect provides a "universal" and "native" deep link. They recommend using
12
+ * the universal deep link over the native one due to UX differences, and our current
13
+ * implementation uses only universal. This means we need to filter for wallets that
14
+ * have a universal deep link available.
15
+ */
16
+ const hasWalletConnectLink = Boolean((_a = deepLinks === null || deepLinks === void 0 ? void 0 : deepLinks.mobile) === null || _a === void 0 ? void 0 : _a.universal) || Boolean((_b = deepLinks === null || deepLinks === void 0 ? void 0 : deepLinks.mobile) === null || _b === void 0 ? void 0 : _b.native);
17
+ const shouldShowIfHadDownloadLink = !connector.isWalletConnect ||
18
+ connector.key === 'walletconnect' ||
19
+ hasWalletConnectLink;
20
+ const walletLinks = getWalletLinks(downloadLinks);
21
+ if (isIPad() || isIPhone()) {
22
+ const hasIOSLink = Boolean(walletLinks.ios);
23
+ return hasIOSLink && shouldShowIfHadDownloadLink;
24
+ }
25
+ else {
26
+ const hasAndroidLink = Boolean(walletLinks.android);
27
+ return hasAndroidLink && shouldShowIfHadDownloadLink;
28
+ }
29
+ };
30
+
31
+ export { handleMobileWalletFilter };
@@ -0,0 +1 @@
1
+ export * from './handleMobileWalletFilter';
@@ -0,0 +1 @@
1
+ export * from './getSupportedWallets';
@@ -0,0 +1,42 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
+ var getEnabledProviders = require('../getEnabledProviders/getEnabledProviders.cjs');
8
+ var getApiProviders = require('../getApiProviders/getApiProviders.cjs');
9
+ var _const = require('../../const.cjs');
10
+
11
+ const getWalletConnectorConstructorOptions = ({ appLogoUrl, appName, coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience, networkConfigurations, settings, walletConnectProjectId, walletUiUtils, walletBook, walletConnectPreferredChains, }) => {
12
+ const eclipseNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.eclipse) || [];
13
+ const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
14
+ const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
15
+ const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
16
+ const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
17
+ const apiProviders = getApiProviders.getApiProviders(getEnabledProviders.getEnabledProviders(settings.providers));
18
+ const opts = {
19
+ apiProviders,
20
+ appLogoUrl,
21
+ appName,
22
+ chainRpcProviders,
23
+ coinbaseWalletPreference,
24
+ cosmosNetworks: cosmosNetworkConfigs,
25
+ deepLinkPreference,
26
+ eclipseNetworks: eclipseNetworkConfigs,
27
+ evmNetworks: evmNetworkConfigs,
28
+ flowNetwork,
29
+ mobileExperience,
30
+ projectId: walletConnectProjectId,
31
+ settings,
32
+ solNetworks: solanaNetworkConfigs,
33
+ starknetNetworks: starknetNetworkConfigs,
34
+ walletBook,
35
+ walletConnectPreferredChains,
36
+ walletConnectorEventsEmitter: walletConnectorCore.walletConnectorEvents,
37
+ walletUiUtils: walletUiUtils || _const.defaultWalletUiUtils,
38
+ };
39
+ return opts;
40
+ };
41
+
42
+ exports.getWalletConnectorConstructorOptions = getWalletConnectorConstructorOptions;