@dynamic-labs/ethereum 0.17.16 → 0.17.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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ### [0.17.17](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.16...v0.17.17) (2023-06-29)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * walletconnect v2 fixes ([#2529](https://github.com/dynamic-labs/DynamicAuth/issues/2529)) ([6fe03d8](https://github.com/dynamic-labs/DynamicAuth/commit/6fe03d802b0a3b8f7995d3a52ce5183b3b0bfb83)), closes [#2523](https://github.com/dynamic-labs/DynamicAuth/issues/2523) [#2527](https://github.com/dynamic-labs/DynamicAuth/issues/2527)
8
+ * **wcv2:** use native or universal link when signing message ([#2502](https://github.com/dynamic-labs/DynamicAuth/issues/2502)) ([#2513](https://github.com/dynamic-labs/DynamicAuth/issues/2513)) ([01f7ca1](https://github.com/dynamic-labs/DynamicAuth/commit/01f7ca109c97d5cb04d6f4b4b574ec99aa8272f1))
9
+
2
10
  ### [0.17.16](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.15...v0.17.16) (2023-06-28)
3
11
 
4
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "0.17.16",
3
+ "version": "0.17.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -32,11 +32,11 @@
32
32
  "ethers": "5.7.2",
33
33
  "eventemitter3": "5.0.1",
34
34
  "buffer": "6.0.3",
35
- "@dynamic-labs/rpc-providers": "0.17.16",
36
- "@dynamic-labs/types": "0.17.16",
37
- "@dynamic-labs/utils": "0.17.16",
38
- "@dynamic-labs/wallet-book": "0.17.16",
39
- "@dynamic-labs/wallet-connector-core": "0.17.16"
35
+ "@dynamic-labs/rpc-providers": "0.17.17",
36
+ "@dynamic-labs/types": "0.17.17",
37
+ "@dynamic-labs/utils": "0.17.17",
38
+ "@dynamic-labs/wallet-book": "0.17.17",
39
+ "@dynamic-labs/wallet-connector-core": "0.17.17"
40
40
  },
41
41
  "peerDependencies": {}
42
42
  }
@@ -66,6 +66,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
66
66
  'eth_sign',
67
67
  'personal_sign',
68
68
  'eth_sendTransaction',
69
+ 'eth_signTypedData_v4',
69
70
  ],
70
71
  rpcMap: this.evmNetworkRpcMap(),
71
72
  },
@@ -166,24 +167,9 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
166
167
  WalletConnectV2.provider.client.removeAllListeners('session_event');
167
168
  WalletConnectV2.provider.client.removeAllListeners('session_delete');
168
169
  }
169
- getDeepLink() {
170
- var _a, _b;
171
- if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
172
- return;
173
- const wallet = walletBook.getWalletBookWallet(this.name);
174
- if (!utils.isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
175
- return undefined;
176
- }
177
- return walletConnectorCore.getDeepLink({
178
- isWC2: true,
179
- metadata: wallet,
180
- mode: 'regular',
181
- uri: WalletConnectV2.provider.uri,
182
- });
183
- }
184
170
  getWeb3Provider() {
185
171
  if (!WalletConnectV2.provider) {
186
- throw new Error('No provider found');
172
+ return;
187
173
  }
188
174
  return new ethers.ethers.providers.Web3Provider(WalletConnectV2.provider, 'any');
189
175
  }
@@ -238,6 +224,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
238
224
  });
239
225
  }
240
226
  signMessage(messageToSign) {
227
+ var _a, _b;
241
228
  return _tslib.__awaiter(this, void 0, void 0, function* () {
242
229
  if (!this.session) {
243
230
  throw new utils.DynamicError('no session');
@@ -247,17 +234,13 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
247
234
  }
248
235
  const metadata = walletBook.getWalletBookWallet(this.name);
249
236
  if (utils.isMobile()) {
250
- // for sign message, no uri is needed because the uri encodes connection details,
251
- // and at this point we are already connected
252
- const deepLink = walletConnectorCore.getDeepLink({
253
- isWC2: true,
254
- metadata,
255
- mode: 'regular',
256
- uri: WalletConnectV2.provider.uri,
257
- });
237
+ const deepLink = ((_a = metadata['mobile']) === null || _a === void 0 ? void 0 : _a.native) || ((_b = metadata['mobile']) === null || _b === void 0 ? void 0 : _b.universal) || '';
258
238
  window.location.href = deepLink;
259
239
  }
260
240
  const web3Provider = this.getWeb3Provider();
241
+ if (!web3Provider) {
242
+ throw new utils.DynamicError('No web3 provider found');
243
+ }
261
244
  const response = web3Provider.send('personal_sign', [
262
245
  walletConnectorCore.utf8ToHex(messageToSign, true),
263
246
  this.activeAccount,
@@ -30,8 +30,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
30
30
  supportsNetworkSwitching(): boolean;
31
31
  setupEventListeners(listeners: WalletEventListeners): void;
32
32
  teardownEventListeners(): void;
33
- getDeepLink(): string | undefined;
34
- getWeb3Provider(): ethers.providers.Web3Provider;
33
+ getWeb3Provider(): ethers.providers.Web3Provider | undefined;
35
34
  fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
36
35
  signMessage(messageToSign: string): Promise<string | undefined>;
37
36
  private clearActiveAccount;
@@ -2,7 +2,7 @@ import { __awaiter } from '../../_virtual/_tslib.js';
2
2
  import Provider from '@walletconnect/universal-provider';
3
3
  import { ethers } from 'ethers';
4
4
  import EventEmitter from 'eventemitter3';
5
- import { logger, getDeepLink, performPlatformSpecificConnectionMethod, utf8ToHex } from '@dynamic-labs/wallet-connector-core';
5
+ import { logger, performPlatformSpecificConnectionMethod, utf8ToHex } from '@dynamic-labs/wallet-connector-core';
6
6
  import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
7
7
  import { DynamicError, isMobile } from '@dynamic-labs/utils';
8
8
  import { EthWalletConnector } from '../EthWalletConnector.js';
@@ -57,6 +57,7 @@ class WalletConnectV2 extends EthWalletConnector {
57
57
  'eth_sign',
58
58
  'personal_sign',
59
59
  'eth_sendTransaction',
60
+ 'eth_signTypedData_v4',
60
61
  ],
61
62
  rpcMap: this.evmNetworkRpcMap(),
62
63
  },
@@ -157,24 +158,9 @@ class WalletConnectV2 extends EthWalletConnector {
157
158
  WalletConnectV2.provider.client.removeAllListeners('session_event');
158
159
  WalletConnectV2.provider.client.removeAllListeners('session_delete');
159
160
  }
160
- getDeepLink() {
161
- var _a, _b;
162
- if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
163
- return;
164
- const wallet = getWalletBookWallet(this.name);
165
- if (!isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
166
- return undefined;
167
- }
168
- return getDeepLink({
169
- isWC2: true,
170
- metadata: wallet,
171
- mode: 'regular',
172
- uri: WalletConnectV2.provider.uri,
173
- });
174
- }
175
161
  getWeb3Provider() {
176
162
  if (!WalletConnectV2.provider) {
177
- throw new Error('No provider found');
163
+ return;
178
164
  }
179
165
  return new ethers.providers.Web3Provider(WalletConnectV2.provider, 'any');
180
166
  }
@@ -229,6 +215,7 @@ class WalletConnectV2 extends EthWalletConnector {
229
215
  });
230
216
  }
231
217
  signMessage(messageToSign) {
218
+ var _a, _b;
232
219
  return __awaiter(this, void 0, void 0, function* () {
233
220
  if (!this.session) {
234
221
  throw new DynamicError('no session');
@@ -238,17 +225,13 @@ class WalletConnectV2 extends EthWalletConnector {
238
225
  }
239
226
  const metadata = getWalletBookWallet(this.name);
240
227
  if (isMobile()) {
241
- // for sign message, no uri is needed because the uri encodes connection details,
242
- // and at this point we are already connected
243
- const deepLink = getDeepLink({
244
- isWC2: true,
245
- metadata,
246
- mode: 'regular',
247
- uri: WalletConnectV2.provider.uri,
248
- });
228
+ const deepLink = ((_a = metadata['mobile']) === null || _a === void 0 ? void 0 : _a.native) || ((_b = metadata['mobile']) === null || _b === void 0 ? void 0 : _b.universal) || '';
249
229
  window.location.href = deepLink;
250
230
  }
251
231
  const web3Provider = this.getWeb3Provider();
232
+ if (!web3Provider) {
233
+ throw new DynamicError('No web3 provider found');
234
+ }
252
235
  const response = web3Provider.send('personal_sign', [
253
236
  utf8ToHex(messageToSign, true),
254
237
  this.activeAccount,