@dynamic-labs/multi-wallet 0.18.0-RC.0 → 0.18.0-RC.2

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,35 @@
1
1
 
2
+ ## [0.18.0-RC.2](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.1...v0.18.0-RC.2) (2023-06-16)
3
+
4
+
5
+ ### Features
6
+
7
+ * add Dynamic Bridge widget ([#2316](https://github.com/dynamic-labs/DynamicAuth/issues/2316)) ([0e71a88](https://github.com/dynamic-labs/DynamicAuth/commit/0e71a88c6dd740583448ed7b45fa335aaa736079))
8
+ * add search bar to bridge wallets view ([#2357](https://github.com/dynamic-labs/DynamicAuth/issues/2357)) ([a8415fc](https://github.com/dynamic-labs/DynamicAuth/commit/a8415fc744216660a78c1443962711699e45429a))
9
+ * bridge flow improvements ([#2367](https://github.com/dynamic-labs/DynamicAuth/issues/2367)) ([38a44be](https://github.com/dynamic-labs/DynamicAuth/commit/38a44be417fd1363b0d8e45ec1834f9aaf680427))
10
+ * **Bridge:** add bridge navigation component ([#2340](https://github.com/dynamic-labs/DynamicAuth/issues/2340)) ([1e9adae](https://github.com/dynamic-labs/DynamicAuth/commit/1e9adaed3682bc9a7aab385221818946cad397f2))
11
+ * **Bridge:** integrate dynamic bridge ui ([#2354](https://github.com/dynamic-labs/DynamicAuth/issues/2354)) ([1465bf8](https://github.com/dynamic-labs/DynamicAuth/commit/1465bf8717cbc9905285c2d867bc3e1d0cd1114b))
12
+ * **DYN-2519:** create state for multiple connected wallets ([#2326](https://github.com/dynamic-labs/DynamicAuth/issues/2326)) ([fc05aa4](https://github.com/dynamic-labs/DynamicAuth/commit/fc05aa4d91b0af8950c5da84c69130557ba36b09)), closes [#2319](https://github.com/dynamic-labs/DynamicAuth/issues/2319)
13
+ * **MultiWalletStepSelectorModal:** add modal to connect multiple wallets ([#2348](https://github.com/dynamic-labs/DynamicAuth/issues/2348)) ([39ce0b2](https://github.com/dynamic-labs/DynamicAuth/commit/39ce0b26fdf6494a4e1ba7867e80bf399d11631f))
14
+ * use wallet-book from CDN ([#2352](https://github.com/dynamic-labs/DynamicAuth/issues/2352)) ([9d1498f](https://github.com/dynamic-labs/DynamicAuth/commit/9d1498f2aec4bb9f3e3d6b386d9cafea3a33bd58))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * handle email only without primary wallet state ([#2342](https://github.com/dynamic-labs/DynamicAuth/issues/2342)) ([98583bb](https://github.com/dynamic-labs/DynamicAuth/commit/98583bb8820ac80967bf1059cbaf47d04bfd603a))
20
+ * s3 cp for walletbook json ([8127b79](https://github.com/dynamic-labs/DynamicAuth/commit/8127b790333b36f40a2cc230a576c01aaad42196))
21
+ * setting initial view when error in auth flow ([#2345](https://github.com/dynamic-labs/DynamicAuth/issues/2345)) ([85dcefb](https://github.com/dynamic-labs/DynamicAuth/commit/85dcefb54be498b540904b381b53f9ea7e0cd024))
22
+ * typo in github action ([d746bc0](https://github.com/dynamic-labs/DynamicAuth/commit/d746bc01981a3263e3ab4f654debf77b408cda3a))
23
+ * **widget:** add fallback icon when oauth provider does not exist ([#2349](https://github.com/dynamic-labs/DynamicAuth/issues/2349)) ([bd2a505](https://github.com/dynamic-labs/DynamicAuth/commit/bd2a505724affd6f5356c0c4f31586ffd188e539))
24
+
25
+ ## [0.18.0-RC.1](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.0...v0.18.0-RC.1) (2023-06-14)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * await setEmailInput in handleSubmit for LoginWithemailForm ([#2336](https://github.com/dynamic-labs/DynamicAuth/issues/2336)) ([05b1fe0](https://github.com/dynamic-labs/DynamicAuth/commit/05b1fe09abaa1563fb187cf410b1e0e991f29c60))
31
+ * don't remove project settings from ls if there's a connected wallet ([#2329](https://github.com/dynamic-labs/DynamicAuth/issues/2329)) ([bc2f627](https://github.com/dynamic-labs/DynamicAuth/commit/bc2f627a80d0a8e6a4637dc60c699ffd07362a19))
32
+
2
33
  ## [0.18.0-RC.0](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0...v0.18.0-RC.0) (2023-06-14)
3
34
 
4
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/multi-wallet",
3
- "version": "0.18.0-RC.0",
3
+ "version": "0.18.0-RC.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -10,11 +10,11 @@
10
10
  "@dynamic-labs/sdk-api": "0.0.218",
11
11
  "ethers": "5.7.2",
12
12
  "tslib": "2.4.1",
13
- "@dynamic-labs/rpc-providers": "0.18.0-RC.0",
14
- "@dynamic-labs/types": "0.18.0-RC.0",
15
- "@dynamic-labs/utils": "0.18.0-RC.0",
16
- "@dynamic-labs/wallet-book": "0.18.0-RC.0",
17
- "@dynamic-labs/wallet-connector-core": "0.18.0-RC.0"
13
+ "@dynamic-labs/rpc-providers": "0.18.0-RC.2",
14
+ "@dynamic-labs/types": "0.18.0-RC.2",
15
+ "@dynamic-labs/utils": "0.18.0-RC.2",
16
+ "@dynamic-labs/wallet-book": "0.18.0-RC.2",
17
+ "@dynamic-labs/wallet-connector-core": "0.18.0-RC.2"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@walletconnect/types": "2.4.2"
@@ -20,7 +20,7 @@ const defaultWalletUiUtils = {
20
20
  },
21
21
  };
22
22
  const getSupportedWallets = (args) => {
23
- const { appLogoUrl = '', appName = '', chainRpcProviders, flowNetwork, isWalletConnectV2Enabled = false, networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, customerApiProviders = [], skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, } = args;
23
+ const { appLogoUrl = '', appName = '', chainRpcProviders, flowNetwork, isWalletConnectV2Enabled = false, networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, customerApiProviders = [], skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, } = args;
24
24
  if (!skipMemo && wallets.length > 0) {
25
25
  return wallets;
26
26
  }
@@ -39,6 +39,7 @@ const getSupportedWallets = (args) => {
39
39
  isWalletConnectV2Enabled,
40
40
  projectId: walletConnectProjectId,
41
41
  solNetworks: solanaNetworkConfigs,
42
+ walletBook,
42
43
  walletUiUtils: walletUiUtils || defaultWalletUiUtils,
43
44
  };
44
45
  const allWallets = walletConnectorsProp
@@ -46,19 +47,19 @@ const getSupportedWallets = (args) => {
46
47
  .flat()
47
48
  .map((wallet) => new wallet(opts).getMobileOrInstalledWallet());
48
49
  // Memoize the wallets
49
- const filteredWallets = filterWalletsForPlatform(allWallets);
50
- wallets = applyLinksOverrides(filteredWallets);
50
+ const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
51
+ wallets = applyLinksOverrides(walletBook, filteredWallets);
51
52
  return wallets;
52
53
  };
53
- const applyLinksOverrides = (wallets) => wallets.map((wallet) => {
54
- const metadata = walletBook.getWalletBookWallet(wallet.name);
54
+ const applyLinksOverrides = (walletBook$1, wallets) => wallets.map((wallet) => {
55
+ const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.name);
55
56
  if (metadata.switchNetworkOnlyFromWallet !== undefined) {
56
57
  wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
57
58
  }
58
59
  return wallet;
59
60
  });
60
- const filterWalletsForPlatform = (wallets) => wallets.filter((wallet) => {
61
- const metadata = walletBook.getWalletBookWallet(wallet.name);
61
+ const filterWalletsForPlatform = (walletBook$1, wallets) => wallets.filter((wallet) => {
62
+ const metadata = walletBook.getWalletBookWallet(walletBook$1, wallet.name);
62
63
  if (wallet.isInstalledOnBrowser()) {
63
64
  return true;
64
65
  }
@@ -72,10 +73,10 @@ const filterWalletsForPlatform = (wallets) => wallets.filter((wallet) => {
72
73
  return true;
73
74
  }
74
75
  else {
75
- return handleMobileWalletFilter(wallet.name, metadata);
76
+ return handleMobileWalletFilter(walletBook$1, wallet.name, metadata);
76
77
  }
77
78
  });
78
- const handleMobileWalletFilter = (walletName, metadata) => {
79
+ const handleMobileWalletFilter = (walletBook$1, walletName, metadata) => {
79
80
  if (!metadata.mobile)
80
81
  return false;
81
82
  /**
@@ -87,13 +88,13 @@ const handleMobileWalletFilter = (walletName, metadata) => {
87
88
  const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
88
89
  const isWalletConnectWallet = metadata.walletConnect !== undefined;
89
90
  if (utils.isIPad() || utils.isIPhone()) {
90
- const hasIOSLink = Boolean(walletBook.getWalletLinks(walletName).ios);
91
+ const hasIOSLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletName).ios);
91
92
  return !isWalletConnectWallet
92
93
  ? hasIOSLink
93
94
  : hasIOSLink && hasWalletConnectLink;
94
95
  }
95
96
  else {
96
- const hasAndroidLink = Boolean(walletBook.getWalletLinks(walletName).android);
97
+ const hasAndroidLink = Boolean(walletBook.getWalletLinks(walletBook$1, walletName).android);
97
98
  return !isWalletConnectWallet
98
99
  ? hasAndroidLink
99
100
  : hasAndroidLink && hasWalletConnectLink;
@@ -103,9 +104,9 @@ const chainStringToChains = {
103
104
  'eip155:1': ['ETH', 'EVM'],
104
105
  'flow:mainnet': ['FLOW'],
105
106
  };
106
- const getSupportedChainsForWalletConnector = (walletConnector) => {
107
+ const getSupportedChainsForWalletConnector = (walletBook$1, walletConnector) => {
107
108
  var _a;
108
- const metadata = walletBook.getWalletBookWallet(walletConnector.name);
109
+ const metadata = walletBook.getWalletBookWallet(walletBook$1, walletConnector.name);
109
110
  /**
110
111
  * chains could contain multiple eth networks eg
111
112
  * "eip155:1",
@@ -130,7 +131,7 @@ const getSupportedChainsForWalletConnector = (walletConnector) => {
130
131
  };
131
132
  const getEnabledWallets = (props) => {
132
133
  const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
133
- const allEnabledWallets = supportedWallets.filter((wallet) => (props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(wallet).includes(chain)) &&
134
+ const allEnabledWallets = supportedWallets.filter((wallet) => (props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) &&
134
135
  wallet.isInstalledOnBrowser() === props.installed) ||
135
136
  wallet.key === 'magiclink');
136
137
  return allEnabledWallets;
@@ -1,7 +1,8 @@
1
1
  import { Chain, WalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
2
3
  import { GetSupportedWallets, GetSupportedWalletsOpts } from './types';
3
4
  export declare const getSupportedWallets: GetSupportedWallets;
4
- export declare const getSupportedChainsForWalletConnector: (walletConnector: WalletConnector) => Chain[];
5
+ export declare const getSupportedChainsForWalletConnector: (walletBook: WalletBookSchema, walletConnector: WalletConnector) => Chain[];
5
6
  export declare const getEnabledWallets: (props: {
6
7
  enabledChains: Chain[];
7
8
  getSupportedWalletOpts: GetSupportedWalletsOpts;
@@ -16,7 +16,7 @@ const defaultWalletUiUtils = {
16
16
  },
17
17
  };
18
18
  const getSupportedWallets = (args) => {
19
- const { appLogoUrl = '', appName = '', chainRpcProviders, flowNetwork, isWalletConnectV2Enabled = false, networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, customerApiProviders = [], skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, } = args;
19
+ const { appLogoUrl = '', appName = '', chainRpcProviders, flowNetwork, isWalletConnectV2Enabled = false, networkConfigurations = { cosmos: [], evm: [], solana: [], starknet: [] }, customerApiProviders = [], skipMemo = false, walletConnectProjectId = '', walletConnectorsProp, walletUiUtils = undefined, walletBook, } = args;
20
20
  if (!skipMemo && wallets.length > 0) {
21
21
  return wallets;
22
22
  }
@@ -35,6 +35,7 @@ const getSupportedWallets = (args) => {
35
35
  isWalletConnectV2Enabled,
36
36
  projectId: walletConnectProjectId,
37
37
  solNetworks: solanaNetworkConfigs,
38
+ walletBook,
38
39
  walletUiUtils: walletUiUtils || defaultWalletUiUtils,
39
40
  };
40
41
  const allWallets = walletConnectorsProp
@@ -42,19 +43,19 @@ const getSupportedWallets = (args) => {
42
43
  .flat()
43
44
  .map((wallet) => new wallet(opts).getMobileOrInstalledWallet());
44
45
  // Memoize the wallets
45
- const filteredWallets = filterWalletsForPlatform(allWallets);
46
- wallets = applyLinksOverrides(filteredWallets);
46
+ const filteredWallets = filterWalletsForPlatform(walletBook, allWallets);
47
+ wallets = applyLinksOverrides(walletBook, filteredWallets);
47
48
  return wallets;
48
49
  };
49
- const applyLinksOverrides = (wallets) => wallets.map((wallet) => {
50
- const metadata = getWalletBookWallet(wallet.name);
50
+ const applyLinksOverrides = (walletBook, wallets) => wallets.map((wallet) => {
51
+ const metadata = getWalletBookWallet(walletBook, wallet.name);
51
52
  if (metadata.switchNetworkOnlyFromWallet !== undefined) {
52
53
  wallet.switchNetworkOnlyFromWallet = metadata.switchNetworkOnlyFromWallet;
53
54
  }
54
55
  return wallet;
55
56
  });
56
- const filterWalletsForPlatform = (wallets) => wallets.filter((wallet) => {
57
- const metadata = getWalletBookWallet(wallet.name);
57
+ const filterWalletsForPlatform = (walletBook, wallets) => wallets.filter((wallet) => {
58
+ const metadata = getWalletBookWallet(walletBook, wallet.name);
58
59
  if (wallet.isInstalledOnBrowser()) {
59
60
  return true;
60
61
  }
@@ -68,10 +69,10 @@ const filterWalletsForPlatform = (wallets) => wallets.filter((wallet) => {
68
69
  return true;
69
70
  }
70
71
  else {
71
- return handleMobileWalletFilter(wallet.name, metadata);
72
+ return handleMobileWalletFilter(walletBook, wallet.name, metadata);
72
73
  }
73
74
  });
74
- const handleMobileWalletFilter = (walletName, metadata) => {
75
+ const handleMobileWalletFilter = (walletBook, walletName, metadata) => {
75
76
  if (!metadata.mobile)
76
77
  return false;
77
78
  /**
@@ -83,13 +84,13 @@ const handleMobileWalletFilter = (walletName, metadata) => {
83
84
  const hasWalletConnectLink = Boolean(metadata.mobile.universal) || Boolean(metadata.mobile.native);
84
85
  const isWalletConnectWallet = metadata.walletConnect !== undefined;
85
86
  if (isIPad() || isIPhone()) {
86
- const hasIOSLink = Boolean(getWalletLinks(walletName).ios);
87
+ const hasIOSLink = Boolean(getWalletLinks(walletBook, walletName).ios);
87
88
  return !isWalletConnectWallet
88
89
  ? hasIOSLink
89
90
  : hasIOSLink && hasWalletConnectLink;
90
91
  }
91
92
  else {
92
- const hasAndroidLink = Boolean(getWalletLinks(walletName).android);
93
+ const hasAndroidLink = Boolean(getWalletLinks(walletBook, walletName).android);
93
94
  return !isWalletConnectWallet
94
95
  ? hasAndroidLink
95
96
  : hasAndroidLink && hasWalletConnectLink;
@@ -99,9 +100,9 @@ const chainStringToChains = {
99
100
  'eip155:1': ['ETH', 'EVM'],
100
101
  'flow:mainnet': ['FLOW'],
101
102
  };
102
- const getSupportedChainsForWalletConnector = (walletConnector) => {
103
+ const getSupportedChainsForWalletConnector = (walletBook, walletConnector) => {
103
104
  var _a;
104
- const metadata = getWalletBookWallet(walletConnector.name);
105
+ const metadata = getWalletBookWallet(walletBook, walletConnector.name);
105
106
  /**
106
107
  * chains could contain multiple eth networks eg
107
108
  * "eip155:1",
@@ -126,7 +127,7 @@ const getSupportedChainsForWalletConnector = (walletConnector) => {
126
127
  };
127
128
  const getEnabledWallets = (props) => {
128
129
  const supportedWallets = getSupportedWallets(props.getSupportedWalletOpts);
129
- const allEnabledWallets = supportedWallets.filter((wallet) => (props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(wallet).includes(chain)) &&
130
+ const allEnabledWallets = supportedWallets.filter((wallet) => (props.enabledChains.some((chain) => getSupportedChainsForWalletConnector(props.getSupportedWalletOpts.walletBook, wallet).includes(chain)) &&
130
131
  wallet.isInstalledOnBrowser() === props.installed) ||
131
132
  wallet.key === 'magiclink');
132
133
  return allEnabledWallets;
package/src/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { Provider } from '@dynamic-labs/sdk-api';
2
2
  import { WalletConnector, Chain, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
3
3
  import { NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
4
4
  import { ChainRpcProviders } from '@dynamic-labs/rpc-providers';
5
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
5
6
  export type GetSupportedWalletsOpts = {
6
7
  appLogoUrl?: string;
7
8
  appName?: string;
@@ -11,6 +12,7 @@ export type GetSupportedWalletsOpts = {
11
12
  isWalletConnectV2Enabled?: boolean;
12
13
  networkConfigurations?: NetworkConfigurationMap;
13
14
  skipMemo?: boolean;
15
+ walletBook: WalletBookSchema;
14
16
  walletConnectProjectId?: string;
15
17
  walletConnectorsProp: WalletConnectorsMethod[];
16
18
  walletUiUtils?: WalletUiUtils;