@dynamic-labs/ethereum 3.9.5 → 3.9.7

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,18 @@
1
1
 
2
+ ### [3.9.7](https://github.com/dynamic-labs/DynamicAuth/compare/v3.9.6...v3.9.7) (2025-01-02)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * wc wallet client interactions on some wallets ([#7728](https://github.com/dynamic-labs/DynamicAuth/issues/7728)) ([f1190d9](https://github.com/dynamic-labs/DynamicAuth/commit/f1190d9bd119f00787b61009d28c2d0f564f1ed8))
8
+
9
+ ### [3.9.6](https://github.com/dynamic-labs/DynamicAuth/compare/v3.9.5...v3.9.6) (2024-12-28)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * properly cancel transaction confirmation UI when using account abstraction and embedded wallets ([#7713](https://github.com/dynamic-labs/DynamicAuth/issues/7713)) ([ef3020b](https://github.com/dynamic-labs/DynamicAuth/commit/ef3020b5985928178c7cda7bbeb9e96dcbc3a925)), closes [#7669](https://github.com/dynamic-labs/DynamicAuth/issues/7669)
15
+
2
16
  ### [3.9.5](https://github.com/dynamic-labs/DynamicAuth/compare/v3.9.4...v3.9.5) (2024-12-20)
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.9.5";
6
+ var version = "3.9.7";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "3.9.5";
2
+ var version = "3.9.7";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "3.9.5",
3
+ "version": "3.9.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -31,13 +31,13 @@
31
31
  "@walletconnect/types": "2.10.6",
32
32
  "eventemitter3": "5.0.1",
33
33
  "buffer": "6.0.3",
34
- "@dynamic-labs/assert-package-version": "3.9.5",
35
- "@dynamic-labs/embedded-wallet-evm": "3.9.5",
36
- "@dynamic-labs/ethereum-core": "3.9.5",
37
- "@dynamic-labs/types": "3.9.5",
38
- "@dynamic-labs/utils": "3.9.5",
39
- "@dynamic-labs/wallet-book": "3.9.5",
40
- "@dynamic-labs/wallet-connector-core": "3.9.5"
34
+ "@dynamic-labs/assert-package-version": "3.9.7",
35
+ "@dynamic-labs/embedded-wallet-evm": "3.9.7",
36
+ "@dynamic-labs/ethereum-core": "3.9.7",
37
+ "@dynamic-labs/types": "3.9.7",
38
+ "@dynamic-labs/utils": "3.9.7",
39
+ "@dynamic-labs/wallet-book": "3.9.7",
40
+ "@dynamic-labs/wallet-connector-core": "3.9.7"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "viem": "^2.7.12"
@@ -50,10 +50,7 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
50
50
  : undefined;
51
51
  }
52
52
  getMappedChains() {
53
- return (this.evmNetworks
54
- // Filters out palm that crashes Trust Wallet
55
- .filter((network) => network.chainId !== 11297108109)
56
- .map((network) => `eip155:${network.chainId}`));
53
+ return this.evmNetworks.map((network) => `eip155:${network.chainId}`);
57
54
  }
58
55
  getMappedChainsByPreferredOrder() {
59
56
  const allChains = this.getMappedChains();
@@ -100,15 +97,19 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
100
97
  });
101
98
  });
102
99
  }
103
- getWalletClientFromInitializedProvider() {
104
- return _tslib.__awaiter(this, void 0, void 0, function* () {
105
- const walletConnect = this.createProvider();
106
- const walletClient = viem.createWalletClient({
107
- account: this.getActiveAccount(),
108
- transport: viem.custom(yield walletConnect),
109
- });
110
- return walletClient;
100
+ getWalletClient(chainId) {
101
+ const walletConnect = this.createProvider();
102
+ const walletClient = viem.createWalletClient({
103
+ account: this.getActiveAccount(),
104
+ chain: ethereumCore.chainsMap[chainId !== null && chainId !== void 0 ? chainId : String(this.currentChainId)],
105
+ transport: viem.custom({
106
+ request: (args) => _tslib.__awaiter(this, void 0, void 0, function* () {
107
+ const provider = yield walletConnect;
108
+ return provider.request(args);
109
+ }),
110
+ }),
111
111
  });
112
+ return walletClient;
112
113
  }
113
114
  createInitProviderPromise() {
114
115
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -132,14 +133,23 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
132
133
  });
133
134
  }
134
135
  refreshSession() {
135
- var _a, _b, _c, _d, _e;
136
- if ((_b = (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.session) === null || _b === void 0 ? void 0 : _b.topic) {
137
- if (localStorage.getItem(this.sessionTopicKey) ===
138
- ((_d = (_c = WalletConnect.provider) === null || _c === void 0 ? void 0 : _c.session) === null || _d === void 0 ? void 0 : _d.topic)) {
139
- this.session = WalletConnect.provider.session;
140
- this.setActiveAccount(((_e = localStorage.getItem(this.activeAccountKey)) !== null && _e !== void 0 ? _e : undefined));
136
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
137
+ var _a, _b, _c, _d, _e;
138
+ if ((_b = (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.session) === null || _b === void 0 ? void 0 : _b.topic) {
139
+ if (localStorage.getItem(this.sessionTopicKey) ===
140
+ ((_d = (_c = WalletConnect.provider) === null || _c === void 0 ? void 0 : _c.session) === null || _d === void 0 ? void 0 : _d.topic)) {
141
+ this.session = WalletConnect.provider.session;
142
+ this.setActiveAccount(((_e = localStorage.getItem(this.activeAccountKey)) !== null && _e !== void 0 ? _e : undefined));
143
+ }
141
144
  }
142
- }
145
+ const walletClient = this.getWalletClient();
146
+ const walletChainId = yield walletClient.getChainId();
147
+ walletConnectorCore.logger.debug('checking selected chain in refreshSession', this.name, walletChainId, this.currentChainId);
148
+ if (this.currentChainId && this.currentChainId !== walletChainId) {
149
+ walletConnectorCore.logger.debug('switching to selected chain', this.currentChainId);
150
+ yield walletClient.switchChain({ id: this.currentChainId });
151
+ }
152
+ });
143
153
  }
144
154
  init() {
145
155
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -239,16 +249,6 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
239
249
  WalletConnect.provider.off('session_event', this.sessionEventHandler);
240
250
  WalletConnect.provider.off('session_delete', this.sessionDeleteHandler);
241
251
  }
242
- getWalletClient(chainId) {
243
- if (!WalletConnect.provider) {
244
- return;
245
- }
246
- return viem.createWalletClient({
247
- account: this.getActiveAccount(),
248
- chain: ethereumCore.chainsMap[chainId !== null && chainId !== void 0 ? chainId : String(this.currentChainId)],
249
- transport: viem.custom(WalletConnect.provider),
250
- });
251
- }
252
252
  getAddress(opts) {
253
253
  return _tslib.__awaiter(this, void 0, void 0, function* () {
254
254
  var _a, _b;
@@ -385,7 +385,7 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
385
385
  if (!activeAccount) {
386
386
  return;
387
387
  }
388
- const walletClient = yield this.getWalletClientFromInitializedProvider();
388
+ const walletClient = yield this.getWalletClient();
389
389
  return walletClient.signMessage({
390
390
  account: activeAccount,
391
391
  message: messageToSign,
@@ -466,7 +466,7 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
466
466
  if (!this.supportsNetworkSwitching()) {
467
467
  throw new utils.DynamicError('Network switching not supported');
468
468
  }
469
- const walletClient = yield this.getWalletClientFromInitializedProvider();
469
+ const walletClient = yield this.getWalletClient();
470
470
  if (this.isMetaMask()) {
471
471
  const deepLink = this.getDeepLink();
472
472
  if (deepLink) {
@@ -483,7 +483,7 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
483
483
  return _tslib.__awaiter(this, void 0, void 0, function* () {
484
484
  if (this.isInitialized === false) {
485
485
  yield this.initProvider();
486
- this.refreshSession();
486
+ yield this.refreshSession();
487
487
  this.isInitialized = true;
488
488
  }
489
489
  const activeAccount = this.getActiveAccount();
@@ -501,7 +501,7 @@ class WalletConnect extends ethereumCore.EthereumWalletConnector {
501
501
  return _tslib.__awaiter(this, void 0, void 0, function* () {
502
502
  var _a;
503
503
  yield this.initProvider();
504
- this.refreshSession();
504
+ yield this.refreshSession();
505
505
  if (this.isMetaMask()) {
506
506
  if (this.hasSwitchedNetwork) {
507
507
  return [String(this.currentChainId)];