@dynamic-labs/multi-wallet 3.4.3 → 3.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +8 -8
  5. package/src/index.cjs +9 -6
  6. package/src/index.d.ts +1 -2
  7. package/src/index.js +5 -2
  8. package/src/utils/{getApiProviders.d.ts → getApiProviders/getApiProviders.d.ts} +6 -0
  9. package/src/utils/getApiProviders/index.d.ts +1 -0
  10. package/src/utils/getEnabledProviders/getEnabledProviders.cjs +18 -0
  11. package/src/utils/getEnabledProviders/getEnabledProviders.d.ts +2 -0
  12. package/src/utils/getEnabledProviders/getEnabledProviders.js +14 -0
  13. package/src/utils/getEnabledProviders/index.d.ts +1 -0
  14. package/src/utils/getEnabledWallets/getEnabledWallets.cjs +16 -0
  15. package/src/utils/getEnabledWallets/getEnabledWallets.d.ts +6 -0
  16. package/src/utils/getEnabledWallets/getEnabledWallets.js +12 -0
  17. package/src/utils/getEnabledWallets/index.d.ts +1 -0
  18. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.cjs +38 -0
  19. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.d.ts +3 -0
  20. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.js +34 -0
  21. package/src/utils/getSupportedChainsForWalletConnector/index.d.ts +1 -0
  22. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.cjs +16 -0
  23. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.d.ts +3 -0
  24. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.js +12 -0
  25. package/src/utils/getSupportedWallets/applyLinksOverrides/index.d.ts +1 -0
  26. package/src/utils/getSupportedWallets/const.cjs +27 -0
  27. package/src/utils/getSupportedWallets/const.d.ts +3 -0
  28. package/src/utils/getSupportedWallets/const.js +23 -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 +95 -0
  34. package/src/utils/getSupportedWallets/getSupportedWallets.d.ts +2 -0
  35. package/src/utils/getSupportedWallets/getSupportedWallets.js +91 -0
  36. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.cjs +34 -0
  37. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.d.ts +2 -0
  38. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.js +30 -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/index.d.ts +5 -0
  42. package/src/utils/message/index.d.ts +1 -0
  43. package/src/multi-wallet.cjs +0 -178
  44. package/src/multi-wallet.d.ts +0 -11
  45. package/src/multi-wallet.js +0 -171
  46. /package/src/utils/{getApiProviders.cjs → getApiProviders/getApiProviders.cjs} +0 -0
  47. /package/src/utils/{getApiProviders.js → getApiProviders/getApiProviders.js} +0 -0
  48. /package/src/utils/{message.cjs → message/message.cjs} +0 -0
  49. /package/src/utils/{message.d.ts → message/message.d.ts} +0 -0
  50. /package/src/utils/{message.js → message/message.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
1
 
2
+ ### [3.4.5](https://github.com/dynamic-labs/DynamicAuth/compare/v3.4.4...v3.4.5) (2024-10-30)
3
+
4
+
5
+ ### Features
6
+
7
+ * add support for epicgames social ([#7222](https://github.com/dynamic-labs/DynamicAuth/issues/7222)) ([f34f027](https://github.com/dynamic-labs/DynamicAuth/commit/f34f02738a4d163792ff457dfe053335a4d57328))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * show connect view when user selects a wallet to connect with ([#7211](https://github.com/dynamic-labs/DynamicAuth/issues/7211)) ([c7d3ab0](https://github.com/dynamic-labs/DynamicAuth/commit/c7d3ab00d4ced00128e0e7bde908165707a15a5c))
13
+
14
+ ### [3.4.4](https://github.com/dynamic-labs/DynamicAuth/compare/v3.4.3...v3.4.4) (2024-10-24)
15
+
2
16
  ### [3.4.3](https://github.com/dynamic-labs/DynamicAuth/compare/v3.4.2...v3.4.3) (2024-10-23)
3
17
 
4
18
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "3.4.3";
6
+ var version = "3.4.5";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "3.4.3";
2
+ var version = "3.4.5";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@dynamic-labs/multi-wallet",
3
- "version": "3.4.3",
3
+ "version": "3.4.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
7
7
  "directory": "packages/multi-wallet"
8
8
  },
9
9
  "dependencies": {
10
- "@dynamic-labs/sdk-api-core": "0.0.547",
10
+ "@dynamic-labs/sdk-api-core": "0.0.559",
11
11
  "tslib": "2.4.1",
12
- "@dynamic-labs/assert-package-version": "3.4.3",
13
- "@dynamic-labs/rpc-providers": "3.4.3",
14
- "@dynamic-labs/types": "3.4.3",
15
- "@dynamic-labs/utils": "3.4.3",
16
- "@dynamic-labs/wallet-book": "3.4.3",
17
- "@dynamic-labs/wallet-connector-core": "3.4.3"
12
+ "@dynamic-labs/assert-package-version": "3.4.5",
13
+ "@dynamic-labs/rpc-providers": "3.4.5",
14
+ "@dynamic-labs/types": "3.4.5",
15
+ "@dynamic-labs/utils": "3.4.5",
16
+ "@dynamic-labs/wallet-book": "3.4.5",
17
+ "@dynamic-labs/wallet-connector-core": "3.4.5"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@walletconnect/types": "2.10.6"
package/src/index.cjs CHANGED
@@ -5,13 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var assertPackageVersion = require('@dynamic-labs/assert-package-version');
7
7
  var _package = require('../package.cjs');
8
- var multiWallet = require('./multi-wallet.cjs');
9
- var message = require('./utils/message.cjs');
8
+ var message = require('./utils/message/message.cjs');
9
+ var getEnabledProviders = require('./utils/getEnabledProviders/getEnabledProviders.cjs');
10
+ var getEnabledWallets = require('./utils/getEnabledWallets/getEnabledWallets.cjs');
11
+ var getSupportedWallets = require('./utils/getSupportedWallets/getSupportedWallets.cjs');
12
+ var getSupportedChainsForWalletConnector = require('./utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.cjs');
10
13
 
11
14
  assertPackageVersion.assertPackageVersion('@dynamic-labs/multi-wallet', _package.version);
12
15
 
13
- exports.getEnabledProviders = multiWallet.getEnabledProviders;
14
- exports.getEnabledWallets = multiWallet.getEnabledWallets;
15
- exports.getSupportedChainsForWalletConnector = multiWallet.getSupportedChainsForWalletConnector;
16
- exports.getSupportedWallets = multiWallet.getSupportedWallets;
17
16
  exports.generateMessageToSign = message.generateMessageToSign;
17
+ exports.getEnabledProviders = getEnabledProviders.getEnabledProviders;
18
+ exports.getEnabledWallets = getEnabledWallets.getEnabledWallets;
19
+ exports.getSupportedWallets = getSupportedWallets.getSupportedWallets;
20
+ exports.getSupportedChainsForWalletConnector = getSupportedChainsForWalletConnector.getSupportedChainsForWalletConnector;
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,10 @@
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';
6
9
 
7
10
  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,38 @@
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 metadata = walletBook.getWalletBookWallet(walletBook$1, walletConnector.key, walletConnector.walletFallback);
15
+ /**
16
+ * chains could contain multiple eth networks eg
17
+ * "eip155:1",
18
+ * "eip155:10",
19
+ * "eip155:56",
20
+ * "eip155:100",
21
+ *
22
+ * so we will use a set to ensure uniqueness
23
+ */
24
+ const chainSet = new Set();
25
+ const chainStringList = (_a = metadata.chains) !== null && _a !== void 0 ? _a : [];
26
+ chainStringList.forEach((chainString) => {
27
+ const chains = chainStringToChains[chainString];
28
+ chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
29
+ chainSet.add(chain);
30
+ });
31
+ });
32
+ walletConnector.supportedChains.forEach((chain) => {
33
+ chainSet.add(chain);
34
+ });
35
+ return [...chainSet];
36
+ };
37
+
38
+ 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,34 @@
1
+ 'use client'
2
+ import { getWalletBookWallet } 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 metadata = getWalletBookWallet(walletBook, walletConnector.key, walletConnector.walletFallback);
11
+ /**
12
+ * chains could contain multiple eth networks eg
13
+ * "eip155:1",
14
+ * "eip155:10",
15
+ * "eip155:56",
16
+ * "eip155:100",
17
+ *
18
+ * so we will use a set to ensure uniqueness
19
+ */
20
+ const chainSet = new Set();
21
+ const chainStringList = (_a = metadata.chains) !== null && _a !== void 0 ? _a : [];
22
+ chainStringList.forEach((chainString) => {
23
+ const chains = chainStringToChains[chainString];
24
+ chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
25
+ chainSet.add(chain);
26
+ });
27
+ });
28
+ walletConnector.supportedChains.forEach((chain) => {
29
+ chainSet.add(chain);
30
+ });
31
+ return [...chainSet];
32
+ };
33
+
34
+ export { getSupportedChainsForWalletConnector };
@@ -0,0 +1 @@
1
+ export { getSupportedChainsForWalletConnector } from './getSupportedChainsForWalletConnector';
@@ -0,0 +1,16 @@
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 metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
10
+ if (metadata.switchNetworkOnlyFromWallet !== undefined) {
11
+ wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
12
+ }
13
+ return wallet;
14
+ });
15
+
16
+ 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,12 @@
1
+ 'use client'
2
+ import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
3
+
4
+ const applyLinksOverrides = (walletBook, wallets) => wallets.map((wallet) => {
5
+ const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
6
+ if (metadata.switchNetworkOnlyFromWallet !== undefined) {
7
+ wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
8
+ }
9
+ return wallet;
10
+ });
11
+
12
+ export { applyLinksOverrides };
@@ -0,0 +1 @@
1
+ export * from './applyLinksOverrides';
@@ -0,0 +1,27 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const defaultWalletUiUtils = {
7
+ createPassword: () => {
8
+ throw Error('createPassword not implemented');
9
+ },
10
+ disabledConfirmationOnce: () => {
11
+ throw Error('disabledConfirmationOnce, not implemented');
12
+ },
13
+ enterPassword: () => {
14
+ throw Error('enterPassword not implemented');
15
+ },
16
+ sendTransaction: () => {
17
+ throw Error('requestSendTransactionConfirmation not implemented');
18
+ },
19
+ signMessage: () => {
20
+ throw Error('signMessage not implemented');
21
+ },
22
+ syncWallet: () => {
23
+ throw Error('syncWallet not implemented');
24
+ },
25
+ };
26
+
27
+ exports.defaultWalletUiUtils = defaultWalletUiUtils;
@@ -0,0 +1,3 @@
1
+ import { WalletUiUtils } from '@dynamic-labs/types';
2
+ import { InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
3
+ export declare const defaultWalletUiUtils: WalletUiUtils<InternalWalletConnector>;
@@ -0,0 +1,23 @@
1
+ 'use client'
2
+ const defaultWalletUiUtils = {
3
+ createPassword: () => {
4
+ throw Error('createPassword not implemented');
5
+ },
6
+ disabledConfirmationOnce: () => {
7
+ throw Error('disabledConfirmationOnce, not implemented');
8
+ },
9
+ enterPassword: () => {
10
+ throw Error('enterPassword not implemented');
11
+ },
12
+ sendTransaction: () => {
13
+ throw Error('requestSendTransactionConfirmation not implemented');
14
+ },
15
+ signMessage: () => {
16
+ throw Error('signMessage not implemented');
17
+ },
18
+ syncWallet: () => {
19
+ throw Error('syncWallet not implemented');
20
+ },
21
+ };
22
+
23
+ export { defaultWalletUiUtils };
@@ -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, wallets) => wallets.filter((wallet) => {
12
+ const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
13
+ if (wallet.isInstalledOnBrowser()) {
14
+ return true;
15
+ }
16
+ else if (walletConnectorCore.isEmbeddedConnector(wallet)) {
17
+ return true;
18
+ }
19
+ else if (metadata.showOnlyIfInstalled) {
20
+ return false;
21
+ }
22
+ else if (!utils.isMobile()) {
23
+ return true;
24
+ }
25
+ else {
26
+ return handleMobileWalletFilter.handleMobileWalletFilter(walletBook$1, wallet.key, metadata);
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, wallets: 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 { getWalletBookWallet } from '@dynamic-labs/wallet-book';
5
+ import { handleMobileWalletFilter } from '../handleMobileWalletFilter/handleMobileWalletFilter.js';
6
+
7
+ const filterWalletsForPlatform = (walletBook, wallets) => wallets.filter((wallet) => {
8
+ const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
9
+ if (wallet.isInstalledOnBrowser()) {
10
+ return true;
11
+ }
12
+ else if (isEmbeddedConnector(wallet)) {
13
+ return true;
14
+ }
15
+ else if (metadata.showOnlyIfInstalled) {
16
+ return false;
17
+ }
18
+ else if (!isMobile()) {
19
+ return true;
20
+ }
21
+ else {
22
+ return handleMobileWalletFilter(walletBook, wallet.key, metadata);
23
+ }
24
+ });
25
+
26
+ export { filterWalletsForPlatform };
@@ -0,0 +1 @@
1
+ export * from './filterWalletsForPlatform';
@@ -0,0 +1,95 @@
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 getApiProviders = require('../getApiProviders/getApiProviders.cjs');
8
+ var getEnabledProviders = require('../getEnabledProviders/getEnabledProviders.cjs');
9
+ var filterWalletsForPlatform = require('./filterWalletsForPlatform/filterWalletsForPlatform.cjs');
10
+ var applyLinksOverrides = require('./applyLinksOverrides/applyLinksOverrides.cjs');
11
+ var _const = require('./const.cjs');
12
+
13
+ const getSupportedWallets = (args) => {
14
+ var _a;
15
+ const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
16
+ let walletConnectors = [];
17
+ if (!skipMemo && walletConnectors.length > 0) {
18
+ return walletConnectors;
19
+ }
20
+ const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
21
+ const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
22
+ const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
23
+ const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
24
+ const apiProviders = getApiProviders.getApiProviders(getEnabledProviders.getEnabledProviders(settings.providers));
25
+ const disabledConnectors = (_a = settings.sdk.disabledWalletConnectors) !== null && _a !== void 0 ? _a : [];
26
+ const opts = {
27
+ apiProviders,
28
+ appLogoUrl,
29
+ appName,
30
+ chainRpcProviders,
31
+ coinbaseWalletPreference,
32
+ cosmosNetworks: cosmosNetworkConfigs,
33
+ deepLinkPreference,
34
+ evmNetworks: evmNetworkConfigs,
35
+ flowNetwork,
36
+ mobileExperience,
37
+ projectId: walletConnectProjectId,
38
+ settings,
39
+ solNetworks: solanaNetworkConfigs,
40
+ starknetNetworks: starknetNetworkConfigs,
41
+ walletBook,
42
+ walletConnectPreferredChains,
43
+ walletConnectorEventsEmitter: walletConnectorCore.walletConnectorEvents,
44
+ walletUiUtils: walletUiUtils || _const.defaultWalletUiUtils,
45
+ };
46
+ const allWalletConnectors = walletConnectorsProp
47
+ .map((getWalletConnectorConstructors) => getWalletConnectorConstructors(opts))
48
+ .flat()
49
+ .map((walletConnectorConstructor) => {
50
+ try {
51
+ // This may contain third party code so we must be ready for anything
52
+ return new walletConnectorConstructor(opts);
53
+ }
54
+ catch (error) {
55
+ walletConnectorCore.logger.error(`Failed to construct wallet ${walletConnectorConstructor.name}`, error);
56
+ return undefined;
57
+ }
58
+ })
59
+ // filter out undefined and disabled connectors
60
+ .filter((walletConnector) => {
61
+ var _a;
62
+ return walletConnector &&
63
+ (!((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
64
+ !disabledConnectors.includes(walletConnector.metadata.id));
65
+ })
66
+ // initialize the wallet connector if it's not a WalletConnect connector
67
+ // or just the generic 'walletconnect' connector, not other WC connectors
68
+ .map((walletConnector) => {
69
+ if (!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isWalletConnect) ||
70
+ walletConnector.key === 'walletconnect') {
71
+ walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.init();
72
+ }
73
+ return walletConnector;
74
+ })
75
+ // applies custom filter defined in the wallet connector
76
+ .filter((walletConnector) => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.filter())
77
+ .map((walletConnector) => walletConnector.getMobileOrInstalledWallet());
78
+ // Filter out duplicated wallets (WC vs. non-WC)
79
+ const nonDuplicatedWalletConnectors = allWalletConnectors.filter((walletConnector) => {
80
+ if (!walletConnector.isWalletConnect)
81
+ return true;
82
+ // if current wallet is WalletConnect, check if there is another wallet with the same key that is
83
+ // not WalletConnect
84
+ // if there is, return false(filter out WC wallet)
85
+ // if there is no other wallet with the same key that is not WalletConnect, return true (keep WC wallet)
86
+ return !allWalletConnectors.some((wc) => wc.key === walletConnector.key &&
87
+ !wc.isWalletConnect &&
88
+ wc.isInstalledOnBrowser());
89
+ });
90
+ const filteredWalletConnectors = filterWalletsForPlatform.filterWalletsForPlatform(walletBook, nonDuplicatedWalletConnectors);
91
+ walletConnectors = applyLinksOverrides.applyLinksOverrides(walletBook, filteredWalletConnectors);
92
+ return walletConnectors;
93
+ };
94
+
95
+ exports.getSupportedWallets = getSupportedWallets;
@@ -0,0 +1,2 @@
1
+ import { GetSupportedWallets } from '../../types';
2
+ export declare const getSupportedWallets: GetSupportedWallets;
@@ -0,0 +1,91 @@
1
+ 'use client'
2
+ import { logger, walletConnectorEvents } from '@dynamic-labs/wallet-connector-core';
3
+ import { getApiProviders } from '../getApiProviders/getApiProviders.js';
4
+ import { getEnabledProviders } from '../getEnabledProviders/getEnabledProviders.js';
5
+ import { filterWalletsForPlatform } from './filterWalletsForPlatform/filterWalletsForPlatform.js';
6
+ import { applyLinksOverrides } from './applyLinksOverrides/applyLinksOverrides.js';
7
+ import { defaultWalletUiUtils } from './const.js';
8
+
9
+ const getSupportedWallets = (args) => {
10
+ var _a;
11
+ const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
12
+ let walletConnectors = [];
13
+ if (!skipMemo && walletConnectors.length > 0) {
14
+ return walletConnectors;
15
+ }
16
+ const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
17
+ const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
18
+ const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
19
+ const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
20
+ const apiProviders = getApiProviders(getEnabledProviders(settings.providers));
21
+ const disabledConnectors = (_a = settings.sdk.disabledWalletConnectors) !== null && _a !== void 0 ? _a : [];
22
+ const opts = {
23
+ apiProviders,
24
+ appLogoUrl,
25
+ appName,
26
+ chainRpcProviders,
27
+ coinbaseWalletPreference,
28
+ cosmosNetworks: cosmosNetworkConfigs,
29
+ deepLinkPreference,
30
+ evmNetworks: evmNetworkConfigs,
31
+ flowNetwork,
32
+ mobileExperience,
33
+ projectId: walletConnectProjectId,
34
+ settings,
35
+ solNetworks: solanaNetworkConfigs,
36
+ starknetNetworks: starknetNetworkConfigs,
37
+ walletBook,
38
+ walletConnectPreferredChains,
39
+ walletConnectorEventsEmitter: walletConnectorEvents,
40
+ walletUiUtils: walletUiUtils || defaultWalletUiUtils,
41
+ };
42
+ const allWalletConnectors = walletConnectorsProp
43
+ .map((getWalletConnectorConstructors) => getWalletConnectorConstructors(opts))
44
+ .flat()
45
+ .map((walletConnectorConstructor) => {
46
+ try {
47
+ // This may contain third party code so we must be ready for anything
48
+ return new walletConnectorConstructor(opts);
49
+ }
50
+ catch (error) {
51
+ logger.error(`Failed to construct wallet ${walletConnectorConstructor.name}`, error);
52
+ return undefined;
53
+ }
54
+ })
55
+ // filter out undefined and disabled connectors
56
+ .filter((walletConnector) => {
57
+ var _a;
58
+ return walletConnector &&
59
+ (!((_a = walletConnector.metadata) === null || _a === void 0 ? void 0 : _a.id) ||
60
+ !disabledConnectors.includes(walletConnector.metadata.id));
61
+ })
62
+ // initialize the wallet connector if it's not a WalletConnect connector
63
+ // or just the generic 'walletconnect' connector, not other WC connectors
64
+ .map((walletConnector) => {
65
+ if (!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isWalletConnect) ||
66
+ walletConnector.key === 'walletconnect') {
67
+ walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.init();
68
+ }
69
+ return walletConnector;
70
+ })
71
+ // applies custom filter defined in the wallet connector
72
+ .filter((walletConnector) => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.filter())
73
+ .map((walletConnector) => walletConnector.getMobileOrInstalledWallet());
74
+ // Filter out duplicated wallets (WC vs. non-WC)
75
+ const nonDuplicatedWalletConnectors = allWalletConnectors.filter((walletConnector) => {
76
+ if (!walletConnector.isWalletConnect)
77
+ return true;
78
+ // if current wallet is WalletConnect, check if there is another wallet with the same key that is
79
+ // not WalletConnect
80
+ // if there is, return false(filter out WC wallet)
81
+ // if there is no other wallet with the same key that is not WalletConnect, return true (keep WC wallet)
82
+ return !allWalletConnectors.some((wc) => wc.key === walletConnector.key &&
83
+ !wc.isWalletConnect &&
84
+ wc.isInstalledOnBrowser());
85
+ });
86
+ const filteredWalletConnectors = filterWalletsForPlatform(walletBook, nonDuplicatedWalletConnectors);
87
+ walletConnectors = applyLinksOverrides(walletBook, filteredWalletConnectors);
88
+ return walletConnectors;
89
+ };
90
+
91
+ export { getSupportedWallets };
@@ -0,0 +1,34 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var utils = require('@dynamic-labs/utils');
7
+ var walletBook = require('@dynamic-labs/wallet-book');
8
+
9
+ const handleMobileWalletFilter = (walletBook$1, walletKey, metadata) => {
10
+ if (!metadata.mobile)
11
+ return false;
12
+ /**
13
+ * WalletConnect provides a "universal" and "native" deep link. They recommend using
14
+ * the universal deep link over the native one due to UX differences, and our current
15
+ * implementation uses only universal. This means we need to filter for wallets that
16
+ * have a universal deep link available.
17
+ */
18
+ const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
19
+ const isWalletConnectWallet = metadata.walletConnect !== undefined;
20
+ if (utils.isIPad() || utils.isIPhone()) {
21
+ const hasIOSLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).ios);
22
+ return !isWalletConnectWallet
23
+ ? hasIOSLink
24
+ : hasIOSLink && hasWalletConnectLink;
25
+ }
26
+ else {
27
+ const hasAndroidLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).android);
28
+ return !isWalletConnectWallet
29
+ ? hasAndroidLink
30
+ : hasAndroidLink && hasWalletConnectLink;
31
+ }
32
+ };
33
+
34
+ exports.handleMobileWalletFilter = handleMobileWalletFilter;
@@ -0,0 +1,2 @@
1
+ import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
2
+ export declare const handleMobileWalletFilter: (walletBook: WalletBookSchema, walletKey: string, metadata: WalletSchema) => boolean;
@@ -0,0 +1,30 @@
1
+ 'use client'
2
+ import { isIPad, isIPhone } from '@dynamic-labs/utils';
3
+ import { getWalletLinks } from '@dynamic-labs/wallet-book';
4
+
5
+ const handleMobileWalletFilter = (walletBook, walletKey, metadata) => {
6
+ if (!metadata.mobile)
7
+ return false;
8
+ /**
9
+ * WalletConnect provides a "universal" and "native" deep link. They recommend using
10
+ * the universal deep link over the native one due to UX differences, and our current
11
+ * implementation uses only universal. This means we need to filter for wallets that
12
+ * have a universal deep link available.
13
+ */
14
+ const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
15
+ const isWalletConnectWallet = metadata.walletConnect !== undefined;
16
+ if (isIPad() || isIPhone()) {
17
+ const hasIOSLink = Boolean(getWalletLinks(walletBook, walletKey).ios);
18
+ return !isWalletConnectWallet
19
+ ? hasIOSLink
20
+ : hasIOSLink && hasWalletConnectLink;
21
+ }
22
+ else {
23
+ const hasAndroidLink = Boolean(getWalletLinks(walletBook, walletKey).android);
24
+ return !isWalletConnectWallet
25
+ ? hasAndroidLink
26
+ : hasAndroidLink && hasWalletConnectLink;
27
+ }
28
+ };
29
+
30
+ export { handleMobileWalletFilter };
@@ -0,0 +1 @@
1
+ export * from './handleMobileWalletFilter';
@@ -0,0 +1 @@
1
+ export * from './getSupportedWallets';
@@ -0,0 +1,5 @@
1
+ export { generateMessageToSign } from './message';
2
+ export { getEnabledProviders } from './getEnabledProviders';
3
+ export { getEnabledWallets } from './getEnabledWallets';
4
+ export { getSupportedWallets } from './getSupportedWallets';
5
+ export { getSupportedChainsForWalletConnector } from './getSupportedChainsForWalletConnector';
@@ -0,0 +1 @@
1
+ export * from './message';
@@ -1,178 +0,0 @@
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 walletBook = require('@dynamic-labs/wallet-book');
8
- var utils = require('@dynamic-labs/utils');
9
- var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
- var getApiProviders = require('./utils/getApiProviders.cjs');
11
-
12
- let wallets = [];
13
- const defaultWalletUiUtils = {
14
- createPassword: () => {
15
- throw Error('createPassword not implemented');
16
- },
17
- disabledConfirmationOnce: () => {
18
- throw Error('disabledConfirmationOnce, not implemented');
19
- },
20
- enterPassword: () => {
21
- throw Error('enterPassword not implemented');
22
- },
23
- sendTransaction: () => {
24
- throw Error('requestSendTransactionConfirmation not implemented');
25
- },
26
- signMessage: () => {
27
- throw Error('signMessage not implemented');
28
- },
29
- syncWallet: () => {
30
- throw Error('syncWallet not implemented');
31
- },
32
- };
33
- const getSupportedWallets = (args) => {
34
- const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
35
- if (!skipMemo && wallets.length > 0) {
36
- return wallets;
37
- }
38
- const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
39
- const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
40
- const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
41
- const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
42
- const apiProviders = getApiProviders.getApiProviders(getEnabledProviders(settings.providers));
43
- const opts = {
44
- apiProviders,
45
- appLogoUrl,
46
- appName,
47
- chainRpcProviders,
48
- coinbaseWalletPreference,
49
- cosmosNetworks: cosmosNetworkConfigs,
50
- deepLinkPreference,
51
- evmNetworks: evmNetworkConfigs,
52
- flowNetwork,
53
- mobileExperience,
54
- projectId: walletConnectProjectId,
55
- settings,
56
- solNetworks: solanaNetworkConfigs,
57
- starknetNetworks: starknetNetworkConfigs,
58
- walletBook,
59
- walletConnectPreferredChains,
60
- walletUiUtils: walletUiUtils || defaultWalletUiUtils,
61
- };
62
- const allWallets = walletConnectorsProp
63
- .map((walletConnector) => walletConnector(opts))
64
- .flat()
65
- .map((wallet) => {
66
- try {
67
- // This may contain third party code so we must be ready for anything
68
- return new wallet(opts);
69
- }
70
- catch (error) {
71
- walletConnectorCore.logger.error(`Failed to construct wallet ${wallet.name}`, error);
72
- return undefined;
73
- }
74
- })
75
- .filter((wallet) => wallet === null || wallet === void 0 ? void 0 : wallet.filter())
76
- .map((wallet) => wallet.getMobileOrInstalledWallet());
77
- // Memoize the wallets
78
- const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
79
- wallets = applyLinksOverrides(walletBook, filteredWallets);
80
- return wallets;
81
- };
82
- const applyLinksOverrides = (walletBook$1, wallets) => wallets.map((wallet) => {
83
- const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
84
- if (metadata.switchNetworkOnlyFromWallet !== undefined) {
85
- wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
86
- }
87
- return wallet;
88
- });
89
- const filterWalletsForPlatform = (walletBook$1, wallets) => wallets.filter((wallet) => {
90
- const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
91
- if (wallet.isInstalledOnBrowser()) {
92
- return true;
93
- }
94
- else if (walletConnectorCore.isEmbeddedConnector(wallet)) {
95
- return true;
96
- }
97
- else if (metadata.showOnlyIfInstalled) {
98
- return false;
99
- }
100
- else if (!utils.isMobile()) {
101
- return true;
102
- }
103
- else {
104
- return handleMobileWalletFilter(walletBook$1, wallet.key, metadata);
105
- }
106
- });
107
- const handleMobileWalletFilter = (walletBook$1, walletKey, metadata) => {
108
- if (!metadata.mobile)
109
- return false;
110
- /**
111
- * WalletConnect provides a "universal" and "native" deep link. They recommend using
112
- * the universal deep link over the native one due to UX differences, and our current
113
- * implementation uses only universal. This means we need to filter for wallets that
114
- * have a universal deep link available.
115
- */
116
- const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
117
- const isWalletConnectWallet = metadata.walletConnect !== undefined;
118
- if (utils.isIPad() || utils.isIPhone()) {
119
- const hasIOSLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).ios);
120
- return !isWalletConnectWallet
121
- ? hasIOSLink
122
- : hasIOSLink && hasWalletConnectLink;
123
- }
124
- else {
125
- const hasAndroidLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).android);
126
- return !isWalletConnectWallet
127
- ? hasAndroidLink
128
- : hasAndroidLink && hasWalletConnectLink;
129
- }
130
- };
131
- const chainStringToChains = {
132
- 'eip155:1': ['ETH', 'EVM'],
133
- 'flow:mainnet': ['FLOW'],
134
- };
135
- const getSupportedChainsForWalletConnector = (walletBook$1, walletConnector) => {
136
- var _a;
137
- const metadata = walletBook.getWalletBookWallet(walletBook$1, walletConnector.key, walletConnector.walletFallback);
138
- /**
139
- * chains could contain multiple eth networks eg
140
- * "eip155:1",
141
- * "eip155:10",
142
- * "eip155:56",
143
- * "eip155:100",
144
- *
145
- * so we will use a set to ensure uniqueness
146
- */
147
- const chainSet = new Set();
148
- const chainStringList = (_a = metadata.chains) !== null && _a !== void 0 ? _a : [];
149
- chainStringList.forEach((chainString) => {
150
- const chains = chainStringToChains[chainString];
151
- chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
152
- chainSet.add(chain);
153
- });
154
- });
155
- walletConnector.supportedChains.forEach((chain) => {
156
- chainSet.add(chain);
157
- });
158
- return [...chainSet];
159
- };
160
- const getEnabledWallets = (props) => {
161
- const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
162
- const allEnabledWallets = supportedWallets.filter((wallet) => props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) || wallet.key === 'magiclink');
163
- return allEnabledWallets;
164
- };
165
- // get list of providers enabled in the sense that we should have wallet connectors for them
166
- // note: magic and turnkey are considered enabled when a provider exists (for magic, a providerProjectId exists)
167
- const getEnabledProviders = (providers) => {
168
- var _a;
169
- return (_a = providers === null || providers === void 0 ? void 0 : providers.filter((provider) => Boolean(provider.enabledAt) ||
170
- (provider.provider === sdkApiCore.ProviderEnum.MagicLink &&
171
- Boolean(provider.providerProjectId)) ||
172
- provider.provider === sdkApiCore.ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
173
- };
174
-
175
- exports.getEnabledProviders = getEnabledProviders;
176
- exports.getEnabledWallets = getEnabledWallets;
177
- exports.getSupportedChainsForWalletConnector = getSupportedChainsForWalletConnector;
178
- exports.getSupportedWallets = getSupportedWallets;
@@ -1,11 +0,0 @@
1
- import { Chain, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
2
- import { WalletBookSchema } from '@dynamic-labs/wallet-book';
3
- import { Provider } from '@dynamic-labs/sdk-api-core';
4
- import { GetSupportedWallets, GetSupportedWalletsOpts } from './types';
5
- export declare const getSupportedWallets: GetSupportedWallets;
6
- export declare const getSupportedChainsForWalletConnector: (walletBook: WalletBookSchema, walletConnector: InternalWalletConnector) => Chain[];
7
- export declare const getEnabledWallets: (props: {
8
- enabledChains: Chain[];
9
- getSupportedWalletOpts: GetSupportedWalletsOpts;
10
- }) => InternalWalletConnector[];
11
- export declare const getEnabledProviders: (providers: Provider[] | undefined) => Provider[];
@@ -1,171 +0,0 @@
1
- 'use client'
2
- import { logger, isEmbeddedConnector } from '@dynamic-labs/wallet-connector-core';
3
- import { getWalletBookWallet, getWalletLinks } from '@dynamic-labs/wallet-book';
4
- import { isMobile, isIPad, isIPhone } from '@dynamic-labs/utils';
5
- import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
6
- import { getApiProviders } from './utils/getApiProviders.js';
7
-
8
- let wallets = [];
9
- const defaultWalletUiUtils = {
10
- createPassword: () => {
11
- throw Error('createPassword not implemented');
12
- },
13
- disabledConfirmationOnce: () => {
14
- throw Error('disabledConfirmationOnce, not implemented');
15
- },
16
- enterPassword: () => {
17
- throw Error('enterPassword not implemented');
18
- },
19
- sendTransaction: () => {
20
- throw Error('requestSendTransactionConfirmation not implemented');
21
- },
22
- signMessage: () => {
23
- throw Error('signMessage not implemented');
24
- },
25
- syncWallet: () => {
26
- throw Error('syncWallet not implemented');
27
- },
28
- };
29
- const getSupportedWallets = (args) => {
30
- const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
31
- if (!skipMemo && wallets.length > 0) {
32
- return wallets;
33
- }
34
- const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
35
- const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
36
- const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
37
- const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
38
- const apiProviders = getApiProviders(getEnabledProviders(settings.providers));
39
- const opts = {
40
- apiProviders,
41
- appLogoUrl,
42
- appName,
43
- chainRpcProviders,
44
- coinbaseWalletPreference,
45
- cosmosNetworks: cosmosNetworkConfigs,
46
- deepLinkPreference,
47
- evmNetworks: evmNetworkConfigs,
48
- flowNetwork,
49
- mobileExperience,
50
- projectId: walletConnectProjectId,
51
- settings,
52
- solNetworks: solanaNetworkConfigs,
53
- starknetNetworks: starknetNetworkConfigs,
54
- walletBook,
55
- walletConnectPreferredChains,
56
- walletUiUtils: walletUiUtils || defaultWalletUiUtils,
57
- };
58
- const allWallets = walletConnectorsProp
59
- .map((walletConnector) => walletConnector(opts))
60
- .flat()
61
- .map((wallet) => {
62
- try {
63
- // This may contain third party code so we must be ready for anything
64
- return new wallet(opts);
65
- }
66
- catch (error) {
67
- logger.error(`Failed to construct wallet ${wallet.name}`, error);
68
- return undefined;
69
- }
70
- })
71
- .filter((wallet) => wallet === null || wallet === void 0 ? void 0 : wallet.filter())
72
- .map((wallet) => wallet.getMobileOrInstalledWallet());
73
- // Memoize the wallets
74
- const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
75
- wallets = applyLinksOverrides(walletBook, filteredWallets);
76
- return wallets;
77
- };
78
- const applyLinksOverrides = (walletBook, wallets) => wallets.map((wallet) => {
79
- const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
80
- if (metadata.switchNetworkOnlyFromWallet !== undefined) {
81
- wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
82
- }
83
- return wallet;
84
- });
85
- const filterWalletsForPlatform = (walletBook, wallets) => wallets.filter((wallet) => {
86
- const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
87
- if (wallet.isInstalledOnBrowser()) {
88
- return true;
89
- }
90
- else if (isEmbeddedConnector(wallet)) {
91
- return true;
92
- }
93
- else if (metadata.showOnlyIfInstalled) {
94
- return false;
95
- }
96
- else if (!isMobile()) {
97
- return true;
98
- }
99
- else {
100
- return handleMobileWalletFilter(walletBook, wallet.key, metadata);
101
- }
102
- });
103
- const handleMobileWalletFilter = (walletBook, walletKey, metadata) => {
104
- if (!metadata.mobile)
105
- return false;
106
- /**
107
- * WalletConnect provides a "universal" and "native" deep link. They recommend using
108
- * the universal deep link over the native one due to UX differences, and our current
109
- * implementation uses only universal. This means we need to filter for wallets that
110
- * have a universal deep link available.
111
- */
112
- const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
113
- const isWalletConnectWallet = metadata.walletConnect !== undefined;
114
- if (isIPad() || isIPhone()) {
115
- const hasIOSLink = Boolean(getWalletLinks(walletBook, walletKey).ios);
116
- return !isWalletConnectWallet
117
- ? hasIOSLink
118
- : hasIOSLink && hasWalletConnectLink;
119
- }
120
- else {
121
- const hasAndroidLink = Boolean(getWalletLinks(walletBook, walletKey).android);
122
- return !isWalletConnectWallet
123
- ? hasAndroidLink
124
- : hasAndroidLink && hasWalletConnectLink;
125
- }
126
- };
127
- const chainStringToChains = {
128
- 'eip155:1': ['ETH', 'EVM'],
129
- 'flow:mainnet': ['FLOW'],
130
- };
131
- const getSupportedChainsForWalletConnector = (walletBook, walletConnector) => {
132
- var _a;
133
- const metadata = getWalletBookWallet(walletBook, walletConnector.key, walletConnector.walletFallback);
134
- /**
135
- * chains could contain multiple eth networks eg
136
- * "eip155:1",
137
- * "eip155:10",
138
- * "eip155:56",
139
- * "eip155:100",
140
- *
141
- * so we will use a set to ensure uniqueness
142
- */
143
- const chainSet = new Set();
144
- const chainStringList = (_a = metadata.chains) !== null && _a !== void 0 ? _a : [];
145
- chainStringList.forEach((chainString) => {
146
- const chains = chainStringToChains[chainString];
147
- chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
148
- chainSet.add(chain);
149
- });
150
- });
151
- walletConnector.supportedChains.forEach((chain) => {
152
- chainSet.add(chain);
153
- });
154
- return [...chainSet];
155
- };
156
- const getEnabledWallets = (props) => {
157
- const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
158
- const allEnabledWallets = supportedWallets.filter((wallet) => props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) || wallet.key === 'magiclink');
159
- return allEnabledWallets;
160
- };
161
- // get list of providers enabled in the sense that we should have wallet connectors for them
162
- // note: magic and turnkey are considered enabled when a provider exists (for magic, a providerProjectId exists)
163
- const getEnabledProviders = (providers) => {
164
- var _a;
165
- return (_a = providers === null || providers === void 0 ? void 0 : providers.filter((provider) => Boolean(provider.enabledAt) ||
166
- (provider.provider === ProviderEnum.MagicLink &&
167
- Boolean(provider.providerProjectId)) ||
168
- provider.provider === ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
169
- };
170
-
171
- export { getEnabledProviders, getEnabledWallets, getSupportedChainsForWalletConnector, getSupportedWallets };
File without changes
File without changes