@dynamic-labs/multi-wallet 4.0.0-alpha.16 → 4.0.0-alpha.17

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 +13 -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/index.d.ts +1 -0
  9. package/src/utils/getEnabledProviders/getEnabledProviders.cjs +18 -0
  10. package/src/utils/getEnabledProviders/getEnabledProviders.d.ts +2 -0
  11. package/src/utils/getEnabledProviders/getEnabledProviders.js +14 -0
  12. package/src/utils/getEnabledProviders/index.d.ts +1 -0
  13. package/src/utils/getEnabledWallets/getEnabledWallets.cjs +16 -0
  14. package/src/utils/getEnabledWallets/getEnabledWallets.d.ts +6 -0
  15. package/src/utils/getEnabledWallets/getEnabledWallets.js +12 -0
  16. package/src/utils/getEnabledWallets/index.d.ts +1 -0
  17. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.cjs +38 -0
  18. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.d.ts +3 -0
  19. package/src/utils/getSupportedChainsForWalletConnector/getSupportedChainsForWalletConnector.js +34 -0
  20. package/src/utils/getSupportedChainsForWalletConnector/index.d.ts +1 -0
  21. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.cjs +16 -0
  22. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.d.ts +3 -0
  23. package/src/utils/getSupportedWallets/applyLinksOverrides/applyLinksOverrides.js +12 -0
  24. package/src/utils/getSupportedWallets/applyLinksOverrides/index.d.ts +1 -0
  25. package/src/utils/getSupportedWallets/const.cjs +30 -0
  26. package/src/utils/getSupportedWallets/const.d.ts +3 -0
  27. package/src/utils/getSupportedWallets/const.js +26 -0
  28. package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.cjs +30 -0
  29. package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.d.ts +3 -0
  30. package/src/utils/getSupportedWallets/filterWalletsForPlatform/filterWalletsForPlatform.js +26 -0
  31. package/src/utils/getSupportedWallets/filterWalletsForPlatform/index.d.ts +1 -0
  32. package/src/utils/getSupportedWallets/getSupportedWallets.cjs +73 -0
  33. package/src/utils/getSupportedWallets/getSupportedWallets.d.ts +2 -0
  34. package/src/utils/getSupportedWallets/getSupportedWallets.js +69 -0
  35. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.cjs +34 -0
  36. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.d.ts +2 -0
  37. package/src/utils/getSupportedWallets/handleMobileWalletFilter/handleMobileWalletFilter.js +30 -0
  38. package/src/utils/getSupportedWallets/handleMobileWalletFilter/index.d.ts +1 -0
  39. package/src/utils/getSupportedWallets/index.d.ts +1 -0
  40. package/src/utils/index.d.ts +5 -0
  41. package/src/utils/message/index.d.ts +1 -0
  42. package/src/multi-wallet.cjs +0 -182
  43. package/src/multi-wallet.d.ts +0 -11
  44. package/src/multi-wallet.js +0 -175
  45. /package/src/utils/{getApiProviders.cjs → getApiProviders/getApiProviders.cjs} +0 -0
  46. /package/src/utils/{getApiProviders.d.ts → getApiProviders/getApiProviders.d.ts} +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,17 @@
1
1
 
2
+ ## [4.0.0-alpha.17](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.16...v4.0.0-alpha.17) (2024-10-28)
3
+
4
+
5
+ ### Features
6
+
7
+ * add support for eclipse ([#7255](https://github.com/dynamic-labs/dynamic-auth/issues/7255)) ([70e9830](https://github.com/dynamic-labs/dynamic-auth/commit/70e9830c6c801e0298825b914ee825b578350cf0))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * adds missing packages to zerodev-extension package ([#7187](https://github.com/dynamic-labs/dynamic-auth/issues/7187)) ([052a7e7](https://github.com/dynamic-labs/dynamic-auth/commit/052a7e7c08d458996d1be56f7697448ad5a9a1c9))
13
+ * unpin reactivity package for vue projects ([#7246](https://github.com/dynamic-labs/dynamic-auth/issues/7246)) ([18013e0](https://github.com/dynamic-labs/dynamic-auth/commit/18013e00d6855f8b371c9edb97594a08764c3868))
14
+
2
15
  ## [4.0.0-alpha.16](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.15...v4.0.0-alpha.16) (2024-10-27)
3
16
 
4
17
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.0.0-alpha.16";
6
+ var version = "4.0.0-alpha.17";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.0.0-alpha.16";
2
+ var version = "4.0.0-alpha.17";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@dynamic-labs/multi-wallet",
3
- "version": "4.0.0-alpha.16",
3
+ "version": "4.0.0-alpha.17",
4
4
  "dependencies": {
5
- "@dynamic-labs/sdk-api-core": "0.0.555",
5
+ "@dynamic-labs/sdk-api-core": "0.0.556",
6
6
  "tslib": "2.4.1",
7
- "@dynamic-labs/assert-package-version": "4.0.0-alpha.16",
8
- "@dynamic-labs/rpc-providers": "4.0.0-alpha.16",
9
- "@dynamic-labs/types": "4.0.0-alpha.16",
10
- "@dynamic-labs/utils": "4.0.0-alpha.16",
11
- "@dynamic-labs/wallet-book": "4.0.0-alpha.16",
12
- "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.16"
7
+ "@dynamic-labs/assert-package-version": "4.0.0-alpha.17",
8
+ "@dynamic-labs/rpc-providers": "4.0.0-alpha.17",
9
+ "@dynamic-labs/types": "4.0.0-alpha.17",
10
+ "@dynamic-labs/utils": "4.0.0-alpha.17",
11
+ "@dynamic-labs/wallet-book": "4.0.0-alpha.17",
12
+ "@dynamic-labs/wallet-connector-core": "4.0.0-alpha.17"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@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);
@@ -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,30 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const defaultWalletUiUtils = {
7
+ addNetwork: () => {
8
+ throw Error('addNetwork not implemented');
9
+ },
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
+
30
+ 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,26 @@
1
+ 'use client'
2
+ const defaultWalletUiUtils = {
3
+ addNetwork: () => {
4
+ throw Error('addNetwork not implemented');
5
+ },
6
+ createPassword: () => {
7
+ throw Error('createPassword not implemented');
8
+ },
9
+ disabledConfirmationOnce: () => {
10
+ throw Error('disabledConfirmationOnce, not implemented');
11
+ },
12
+ enterPassword: () => {
13
+ throw Error('enterPassword not implemented');
14
+ },
15
+ sendTransaction: () => {
16
+ throw Error('requestSendTransactionConfirmation not implemented');
17
+ },
18
+ signMessage: () => {
19
+ throw Error('signMessage not implemented');
20
+ },
21
+ syncWallet: () => {
22
+ throw Error('syncWallet not implemented');
23
+ },
24
+ };
25
+
26
+ 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,73 @@
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
+ const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = {
15
+ cosmos: [],
16
+ eclipse: [],
17
+ evm: [],
18
+ solana: [],
19
+ starknet: [],
20
+ }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
21
+ let wallets = [];
22
+ if (!skipMemo && wallets.length > 0) {
23
+ return wallets;
24
+ }
25
+ const eclipseNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.eclipse) || [];
26
+ const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
27
+ const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
28
+ const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
29
+ const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
30
+ const apiProviders = getApiProviders.getApiProviders(getEnabledProviders.getEnabledProviders(settings.providers));
31
+ const opts = {
32
+ apiProviders,
33
+ appLogoUrl,
34
+ appName,
35
+ chainRpcProviders,
36
+ coinbaseWalletPreference,
37
+ cosmosNetworks: cosmosNetworkConfigs,
38
+ deepLinkPreference,
39
+ eclipseNetworks: eclipseNetworkConfigs,
40
+ evmNetworks: evmNetworkConfigs,
41
+ flowNetwork,
42
+ mobileExperience,
43
+ projectId: walletConnectProjectId,
44
+ settings,
45
+ solNetworks: solanaNetworkConfigs,
46
+ starknetNetworks: starknetNetworkConfigs,
47
+ walletBook,
48
+ walletConnectPreferredChains,
49
+ walletConnectorEventsEmitter: walletConnectorCore.walletConnectorEvents,
50
+ walletUiUtils: walletUiUtils || _const.defaultWalletUiUtils,
51
+ };
52
+ const allWallets = walletConnectorsProp
53
+ .map((walletConnector) => walletConnector(opts))
54
+ .flat()
55
+ .map((wallet) => {
56
+ try {
57
+ // This may contain third party code so we must be ready for anything
58
+ return new wallet(opts);
59
+ }
60
+ catch (error) {
61
+ walletConnectorCore.logger.error(`Failed to construct wallet ${wallet.name}`, error);
62
+ return undefined;
63
+ }
64
+ })
65
+ .filter((wallet) => wallet === null || wallet === void 0 ? void 0 : wallet.filter())
66
+ .map((wallet) => wallet.getMobileOrInstalledWallet());
67
+ // Memoize the wallets
68
+ const filteredWallets = filterWalletsForPlatform.filterWalletsForPlatform(walletBook, allWallets);
69
+ wallets = applyLinksOverrides.applyLinksOverrides(walletBook, filteredWallets);
70
+ return wallets;
71
+ };
72
+
73
+ exports.getSupportedWallets = getSupportedWallets;
@@ -0,0 +1,2 @@
1
+ import { GetSupportedWallets } from '../../types';
2
+ export declare const getSupportedWallets: GetSupportedWallets;
@@ -0,0 +1,69 @@
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
+ const { appLogoUrl = '', appName = '', coinbaseWalletPreference, chainRpcProviders, deepLinkPreference, flowNetwork, mobileExperience = 'in-app-browser', networkConfigurations = {
11
+ cosmos: [],
12
+ eclipse: [],
13
+ evm: [],
14
+ solana: [],
15
+ starknet: [],
16
+ }, settings, skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, walletConnectPreferredChains, } = args;
17
+ let wallets = [];
18
+ if (!skipMemo && wallets.length > 0) {
19
+ return wallets;
20
+ }
21
+ const eclipseNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.eclipse) || [];
22
+ const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
23
+ const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
24
+ const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
25
+ const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
26
+ const apiProviders = getApiProviders(getEnabledProviders(settings.providers));
27
+ const opts = {
28
+ apiProviders,
29
+ appLogoUrl,
30
+ appName,
31
+ chainRpcProviders,
32
+ coinbaseWalletPreference,
33
+ cosmosNetworks: cosmosNetworkConfigs,
34
+ deepLinkPreference,
35
+ eclipseNetworks: eclipseNetworkConfigs,
36
+ evmNetworks: evmNetworkConfigs,
37
+ flowNetwork,
38
+ mobileExperience,
39
+ projectId: walletConnectProjectId,
40
+ settings,
41
+ solNetworks: solanaNetworkConfigs,
42
+ starknetNetworks: starknetNetworkConfigs,
43
+ walletBook,
44
+ walletConnectPreferredChains,
45
+ walletConnectorEventsEmitter: walletConnectorEvents,
46
+ walletUiUtils: walletUiUtils || defaultWalletUiUtils,
47
+ };
48
+ const allWallets = walletConnectorsProp
49
+ .map((walletConnector) => walletConnector(opts))
50
+ .flat()
51
+ .map((wallet) => {
52
+ try {
53
+ // This may contain third party code so we must be ready for anything
54
+ return new wallet(opts);
55
+ }
56
+ catch (error) {
57
+ logger.error(`Failed to construct wallet ${wallet.name}`, error);
58
+ return undefined;
59
+ }
60
+ })
61
+ .filter((wallet) => wallet === null || wallet === void 0 ? void 0 : wallet.filter())
62
+ .map((wallet) => wallet.getMobileOrInstalledWallet());
63
+ // Memoize the wallets
64
+ const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
65
+ wallets = applyLinksOverrides(walletBook, filteredWallets);
66
+ return wallets;
67
+ };
68
+
69
+ 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,182 +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
- addNetwork: () => {
15
- throw Error('addNetwork not implemented');
16
- },
17
- createPassword: () => {
18
- throw Error('createPassword not implemented');
19
- },
20
- disabledConfirmationOnce: () => {
21
- throw Error('disabledConfirmationOnce, not implemented');
22
- },
23
- enterPassword: () => {
24
- throw Error('enterPassword not implemented');
25
- },
26
- sendTransaction: () => {
27
- throw Error('requestSendTransactionConfirmation not implemented');
28
- },
29
- signMessage: () => {
30
- throw Error('signMessage not implemented');
31
- },
32
- syncWallet: () => {
33
- throw Error('syncWallet not implemented');
34
- },
35
- };
36
- const getSupportedWallets = (args) => {
37
- 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;
38
- if (!skipMemo && wallets.length > 0) {
39
- return wallets;
40
- }
41
- const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
42
- const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
43
- const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
44
- const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
45
- const apiProviders = getApiProviders.getApiProviders(getEnabledProviders(settings.providers));
46
- const opts = {
47
- apiProviders,
48
- appLogoUrl,
49
- appName,
50
- chainRpcProviders,
51
- coinbaseWalletPreference,
52
- cosmosNetworks: cosmosNetworkConfigs,
53
- deepLinkPreference,
54
- evmNetworks: evmNetworkConfigs,
55
- flowNetwork,
56
- mobileExperience,
57
- projectId: walletConnectProjectId,
58
- settings,
59
- solNetworks: solanaNetworkConfigs,
60
- starknetNetworks: starknetNetworkConfigs,
61
- walletBook,
62
- walletConnectPreferredChains,
63
- walletConnectorEventsEmitter: walletConnectorCore.walletConnectorEvents,
64
- walletUiUtils: walletUiUtils || defaultWalletUiUtils,
65
- };
66
- const allWallets = walletConnectorsProp
67
- .map((walletConnector) => walletConnector(opts))
68
- .flat()
69
- .map((wallet) => {
70
- try {
71
- // This may contain third party code so we must be ready for anything
72
- return new wallet(opts);
73
- }
74
- catch (error) {
75
- walletConnectorCore.logger.error(`Failed to construct wallet ${wallet.name}`, error);
76
- return undefined;
77
- }
78
- })
79
- .filter((wallet) => wallet === null || wallet === void 0 ? void 0 : wallet.filter())
80
- .map((wallet) => wallet.getMobileOrInstalledWallet());
81
- // Memoize the wallets
82
- const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
83
- wallets = applyLinksOverrides(walletBook, filteredWallets);
84
- return wallets;
85
- };
86
- const applyLinksOverrides = (walletBook$1, wallets) => wallets.map((wallet) => {
87
- const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
88
- if (metadata.switchNetworkOnlyFromWallet !== undefined) {
89
- wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
90
- }
91
- return wallet;
92
- });
93
- const filterWalletsForPlatform = (walletBook$1, wallets) => wallets.filter((wallet) => {
94
- const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.key, wallet.walletFallback);
95
- if (wallet.isInstalledOnBrowser()) {
96
- return true;
97
- }
98
- else if (walletConnectorCore.isEmbeddedConnector(wallet)) {
99
- return true;
100
- }
101
- else if (metadata.showOnlyIfInstalled) {
102
- return false;
103
- }
104
- else if (!utils.isMobile()) {
105
- return true;
106
- }
107
- else {
108
- return handleMobileWalletFilter(walletBook$1, wallet.key, metadata);
109
- }
110
- });
111
- const handleMobileWalletFilter = (walletBook$1, walletKey, metadata) => {
112
- if (!metadata.mobile)
113
- return false;
114
- /**
115
- * WalletConnect provides a "universal" and "native" deep link. They recommend using
116
- * the universal deep link over the native one due to UX differences, and our current
117
- * implementation uses only universal. This means we need to filter for wallets that
118
- * have a universal deep link available.
119
- */
120
- const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
121
- const isWalletConnectWallet = metadata.walletConnect !== undefined;
122
- if (utils.isIPad() || utils.isIPhone()) {
123
- const hasIOSLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).ios);
124
- return !isWalletConnectWallet
125
- ? hasIOSLink
126
- : hasIOSLink && hasWalletConnectLink;
127
- }
128
- else {
129
- const hasAndroidLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletKey).android);
130
- return !isWalletConnectWallet
131
- ? hasAndroidLink
132
- : hasAndroidLink && hasWalletConnectLink;
133
- }
134
- };
135
- const chainStringToChains = {
136
- 'eip155:1': ['ETH', 'EVM'],
137
- 'flow:mainnet': ['FLOW'],
138
- };
139
- const getSupportedChainsForWalletConnector = (walletBook$1, walletConnector) => {
140
- var _a;
141
- const metadata = walletBook.getWalletBookWallet(walletBook$1, walletConnector.key, walletConnector.walletFallback);
142
- /**
143
- * chains could contain multiple eth networks eg
144
- * "eip155:1",
145
- * "eip155:10",
146
- * "eip155:56",
147
- * "eip155:100",
148
- *
149
- * so we will use a set to ensure uniqueness
150
- */
151
- const chainSet = new Set();
152
- const chainStringList = (_a = metadata.chains) !== null && _a !== void 0 ? _a : [];
153
- chainStringList.forEach((chainString) => {
154
- const chains = chainStringToChains[chainString];
155
- chains === null || chains === void 0 ? void 0 : chains.forEach((chain) => {
156
- chainSet.add(chain);
157
- });
158
- });
159
- walletConnector.supportedChains.forEach((chain) => {
160
- chainSet.add(chain);
161
- });
162
- return [...chainSet];
163
- };
164
- const getEnabledWallets = (props) => {
165
- const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
166
- const allEnabledWallets = supportedWallets.filter((wallet) => props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) || wallet.key === 'magiclink');
167
- return allEnabledWallets;
168
- };
169
- // get list of providers enabled in the sense that we should have wallet connectors for them
170
- // note: magic and turnkey are considered enabled when a provider exists (for magic, a providerProjectId exists)
171
- const getEnabledProviders = (providers) => {
172
- var _a;
173
- return (_a = providers === null || providers === void 0 ? void 0 : providers.filter((provider) => Boolean(provider.enabledAt) ||
174
- (provider.provider === sdkApiCore.ProviderEnum.MagicLink &&
175
- Boolean(provider.providerProjectId)) ||
176
- provider.provider === sdkApiCore.ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
177
- };
178
-
179
- exports.getEnabledProviders = getEnabledProviders;
180
- exports.getEnabledWallets = getEnabledWallets;
181
- exports.getSupportedChainsForWalletConnector = getSupportedChainsForWalletConnector;
182
- 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,175 +0,0 @@
1
- 'use client'
2
- import { logger, isEmbeddedConnector, walletConnectorEvents } 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
- addNetwork: () => {
11
- throw Error('addNetwork not implemented');
12
- },
13
- createPassword: () => {
14
- throw Error('createPassword not implemented');
15
- },
16
- disabledConfirmationOnce: () => {
17
- throw Error('disabledConfirmationOnce, not implemented');
18
- },
19
- enterPassword: () => {
20
- throw Error('enterPassword not implemented');
21
- },
22
- sendTransaction: () => {
23
- throw Error('requestSendTransactionConfirmation not implemented');
24
- },
25
- signMessage: () => {
26
- throw Error('signMessage not implemented');
27
- },
28
- syncWallet: () => {
29
- throw Error('syncWallet not implemented');
30
- },
31
- };
32
- const getSupportedWallets = (args) => {
33
- 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;
34
- if (!skipMemo && wallets.length > 0) {
35
- return wallets;
36
- }
37
- const evmNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) || [];
38
- const solanaNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.solana) || [];
39
- const cosmosNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.cosmos) || [];
40
- const starknetNetworkConfigs = (networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.starknet) || [];
41
- const apiProviders = getApiProviders(getEnabledProviders(settings.providers));
42
- const opts = {
43
- apiProviders,
44
- appLogoUrl,
45
- appName,
46
- chainRpcProviders,
47
- coinbaseWalletPreference,
48
- cosmosNetworks: cosmosNetworkConfigs,
49
- deepLinkPreference,
50
- evmNetworks: evmNetworkConfigs,
51
- flowNetwork,
52
- mobileExperience,
53
- projectId: walletConnectProjectId,
54
- settings,
55
- solNetworks: solanaNetworkConfigs,
56
- starknetNetworks: starknetNetworkConfigs,
57
- walletBook,
58
- walletConnectPreferredChains,
59
- walletConnectorEventsEmitter: walletConnectorEvents,
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
- 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, wallets) => wallets.map((wallet) => {
83
- const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
84
- if (metadata.switchNetworkOnlyFromWallet !== undefined) {
85
- wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
86
- }
87
- return wallet;
88
- });
89
- const filterWalletsForPlatform = (walletBook, wallets) => wallets.filter((wallet) => {
90
- const metadata = getWalletBookWallet(walletBook, wallet.key, wallet.walletFallback);
91
- if (wallet.isInstalledOnBrowser()) {
92
- return true;
93
- }
94
- else if (isEmbeddedConnector(wallet)) {
95
- return true;
96
- }
97
- else if (metadata.showOnlyIfInstalled) {
98
- return false;
99
- }
100
- else if (!isMobile()) {
101
- return true;
102
- }
103
- else {
104
- return handleMobileWalletFilter(walletBook, wallet.key, metadata);
105
- }
106
- });
107
- const handleMobileWalletFilter = (walletBook, 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 (isIPad() || isIPhone()) {
119
- const hasIOSLink = Boolean(getWalletLinks(walletBook, walletKey).ios);
120
- return !isWalletConnectWallet
121
- ? hasIOSLink
122
- : hasIOSLink && hasWalletConnectLink;
123
- }
124
- else {
125
- const hasAndroidLink = Boolean(getWalletLinks(walletBook, 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, walletConnector) => {
136
- var _a;
137
- const metadata = getWalletBookWallet(walletBook, 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 === ProviderEnum.MagicLink &&
171
- Boolean(provider.providerProjectId)) ||
172
- provider.provider === ProviderEnum.Turnkey)) !== null && _a !== void 0 ? _a : [];
173
- };
174
-
175
- export { getEnabledProviders, getEnabledWallets, getSupportedChainsForWalletConnector, getSupportedWallets };
File without changes
File without changes