@dynamic-labs/ethereum 1.0.6 → 1.0.8

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,23 @@
1
1
 
2
+ ### [1.0.8](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.7...v1.0.8) (2024-01-26)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * pass id to wagmi chain override ([#4512](https://github.com/dynamic-labs/DynamicAuth/issues/4512)) ([#4514](https://github.com/dynamic-labs/DynamicAuth/issues/4514)) ([0e6da01](https://github.com/dynamic-labs/DynamicAuth/commit/0e6da0108d30b9ae65062126f4a41543740acc87))
8
+
9
+ ### [1.0.7](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.6...v1.0.7) (2024-01-25)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add support for newest backpack extension ([66786ce](https://github.com/dynamic-labs/DynamicAuth/commit/66786ceb7927046c1cdb439888271f3070ca93a4))
15
+ * broken help icon in create passkey view ([2e38ea5](https://github.com/dynamic-labs/DynamicAuth/commit/2e38ea580e55f3349a2d3040d7b07bb2923631f7))
16
+ * connect to wallet with wallet connect even if network is not supported ([#4465](https://github.com/dynamic-labs/DynamicAuth/issues/4465)) ([#4472](https://github.com/dynamic-labs/DynamicAuth/issues/4472)) ([8270b94](https://github.com/dynamic-labs/DynamicAuth/commit/8270b9468c289e7c49cd2ef104fb73dfaaa9f41c))
17
+ * infinite loop when connecting with trust wallet ([#4448](https://github.com/dynamic-labs/DynamicAuth/issues/4448)) ([#4450](https://github.com/dynamic-labs/DynamicAuth/issues/4450)) ([c5ffee6](https://github.com/dynamic-labs/DynamicAuth/commit/c5ffee67a6a95ee62e779da69ce311c90575388f))
18
+ * logging in with an email linked to a third party wallet gets stu… ([#4422](https://github.com/dynamic-labs/DynamicAuth/issues/4422)) ([995889b](https://github.com/dynamic-labs/DynamicAuth/commit/995889b5d03bcbafecd6959c52a88db8d9db940e))
19
+ * switching wallet in extension caused connected flag to be false ([#4464](https://github.com/dynamic-labs/DynamicAuth/issues/4464)) ([a53dc1a](https://github.com/dynamic-labs/DynamicAuth/commit/a53dc1a9869a270c98753041cfbd587855629af4)), closes [#4454](https://github.com/dynamic-labs/DynamicAuth/issues/4454)
20
+
2
21
  ### [1.0.6](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.5...v1.0.6) (2024-01-18)
3
22
 
4
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -32,12 +32,12 @@
32
32
  "@walletconnect/universal-provider": "2.10.6",
33
33
  "eventemitter3": "5.0.1",
34
34
  "buffer": "6.0.3",
35
- "@dynamic-labs/rpc-providers": "1.0.6",
36
- "@dynamic-labs/turnkey": "1.0.6",
37
- "@dynamic-labs/types": "1.0.6",
38
- "@dynamic-labs/utils": "1.0.6",
39
- "@dynamic-labs/wallet-book": "1.0.6",
40
- "@dynamic-labs/wallet-connector-core": "1.0.6",
35
+ "@dynamic-labs/rpc-providers": "1.0.8",
36
+ "@dynamic-labs/turnkey": "1.0.8",
37
+ "@dynamic-labs/types": "1.0.8",
38
+ "@dynamic-labs/utils": "1.0.8",
39
+ "@dynamic-labs/wallet-book": "1.0.8",
40
+ "@dynamic-labs/wallet-connector-core": "1.0.8",
41
41
  "stream": "0.0.2"
42
42
  },
43
43
  "peerDependencies": {
@@ -16,7 +16,10 @@ class EthProviderHelper {
16
16
  getInstalledProvider() {
17
17
  const eip6963Config = this.getEip6963Config();
18
18
  if (eip6963Config) {
19
- return this.eip6963ProviderLookup(eip6963Config.rdns);
19
+ const eip6963Provider = this.eip6963ProviderLookup(eip6963Config.rdns);
20
+ if (eip6963Provider) {
21
+ return eip6963Provider;
22
+ }
20
23
  }
21
24
  const config = this.getInjectedConfig();
22
25
  if (!config ||
@@ -12,7 +12,10 @@ class EthProviderHelper {
12
12
  getInstalledProvider() {
13
13
  const eip6963Config = this.getEip6963Config();
14
14
  if (eip6963Config) {
15
- return this.eip6963ProviderLookup(eip6963Config.rdns);
15
+ const eip6963Provider = this.eip6963ProviderLookup(eip6963Config.rdns);
16
+ if (eip6963Provider) {
17
+ return eip6963Provider;
18
+ }
16
19
  }
17
20
  const config = this.getInjectedConfig();
18
21
  if (!config ||
@@ -39,9 +39,6 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
39
39
  this.projectId = opts.projectId;
40
40
  this.deepLinkPreference = opts.deepLinkPreference || 'native';
41
41
  this.preferredChains = opts.walletConnectPreferredChains || [];
42
- if (!this.preferredChains.includes('eip155:1')) {
43
- this.preferredChains.push('eip155:1');
44
- }
45
42
  this.hasSwitchedNetwork =
46
43
  (_a = Boolean(localStorage.getItem(this.swicthedNetworkKey))) !== null && _a !== void 0 ? _a : false;
47
44
  const lsCurrentChain = localStorage.getItem(this.currentChainKey);
@@ -55,6 +52,16 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
55
52
  .filter((network) => network.chainId !== 11297108109)
56
53
  .map((network) => `eip155:${network.chainId}`));
57
54
  }
55
+ getMappedChainsByPreferredOrder() {
56
+ // adding Ethereum to avoid an error connecting if none of the evm networks are supported by the wallet
57
+ const allChains = this.getMappedChains();
58
+ if (!allChains.includes('eip155:1')) {
59
+ allChains.push('eip155:1');
60
+ }
61
+ const reorderedChains = this.preferredChains.filter((chain) => allChains.includes(chain));
62
+ const remainingChains = allChains.filter((chain) => !this.preferredChains.includes(chain));
63
+ return [...reorderedChains, ...remainingChains];
64
+ }
58
65
  initConnection() {
59
66
  return _tslib.__awaiter(this, void 0, void 0, function* () {
60
67
  const { provider } = WalletConnectV2;
@@ -67,7 +74,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
67
74
  }
68
75
  const optionalNamespaces = {
69
76
  eip155: {
70
- chains: this.getMappedChains(),
77
+ chains: this.getMappedChainsByPreferredOrder(),
71
78
  events: ['chainChanged', 'accountsChanged'],
72
79
  methods: [
73
80
  'eth_chainId',
@@ -89,7 +96,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
89
96
  })
90
97
  .catch((e) => {
91
98
  walletConnectorCore.logger.error(e);
92
- ee.emit('walletconnect_connection_failed');
99
+ ee.emit('walletconnect_connection_failed', e);
93
100
  });
94
101
  });
95
102
  }
@@ -27,6 +27,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
27
27
  private _hasSwitchedNetwork;
28
28
  constructor(opts: WalletConnectorV2Opts);
29
29
  private getMappedChains;
30
+ private getMappedChainsByPreferredOrder;
30
31
  private initConnection;
31
32
  private createInitProviderPromise;
32
33
  private initProvider;
@@ -30,9 +30,6 @@ class WalletConnectV2 extends EthWalletConnector {
30
30
  this.projectId = opts.projectId;
31
31
  this.deepLinkPreference = opts.deepLinkPreference || 'native';
32
32
  this.preferredChains = opts.walletConnectPreferredChains || [];
33
- if (!this.preferredChains.includes('eip155:1')) {
34
- this.preferredChains.push('eip155:1');
35
- }
36
33
  this.hasSwitchedNetwork =
37
34
  (_a = Boolean(localStorage.getItem(this.swicthedNetworkKey))) !== null && _a !== void 0 ? _a : false;
38
35
  const lsCurrentChain = localStorage.getItem(this.currentChainKey);
@@ -46,6 +43,16 @@ class WalletConnectV2 extends EthWalletConnector {
46
43
  .filter((network) => network.chainId !== 11297108109)
47
44
  .map((network) => `eip155:${network.chainId}`));
48
45
  }
46
+ getMappedChainsByPreferredOrder() {
47
+ // adding Ethereum to avoid an error connecting if none of the evm networks are supported by the wallet
48
+ const allChains = this.getMappedChains();
49
+ if (!allChains.includes('eip155:1')) {
50
+ allChains.push('eip155:1');
51
+ }
52
+ const reorderedChains = this.preferredChains.filter((chain) => allChains.includes(chain));
53
+ const remainingChains = allChains.filter((chain) => !this.preferredChains.includes(chain));
54
+ return [...reorderedChains, ...remainingChains];
55
+ }
49
56
  initConnection() {
50
57
  return __awaiter(this, void 0, void 0, function* () {
51
58
  const { provider } = WalletConnectV2;
@@ -58,7 +65,7 @@ class WalletConnectV2 extends EthWalletConnector {
58
65
  }
59
66
  const optionalNamespaces = {
60
67
  eip155: {
61
- chains: this.getMappedChains(),
68
+ chains: this.getMappedChainsByPreferredOrder(),
62
69
  events: ['chainChanged', 'accountsChanged'],
63
70
  methods: [
64
71
  'eth_chainId',
@@ -80,7 +87,7 @@ class WalletConnectV2 extends EthWalletConnector {
80
87
  })
81
88
  .catch((e) => {
82
89
  logger.error(e);
83
- ee.emit('walletconnect_connection_failed');
90
+ ee.emit('walletconnect_connection_failed', e);
84
91
  });
85
92
  });
86
93
  }