@dynamic-labs/ethereum 0.17.17 → 0.17.18

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,6 @@
1
1
 
2
+ ### [0.17.18](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.17...v0.17.18) (2023-06-29)
3
+
2
4
  ### [0.17.17](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.16...v0.17.17) (2023-06-29)
3
5
 
4
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "0.17.17",
3
+ "version": "0.17.18",
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.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"
35
+ "@dynamic-labs/rpc-providers": "0.17.18",
36
+ "@dynamic-labs/types": "0.17.18",
37
+ "@dynamic-labs/utils": "0.17.18",
38
+ "@dynamic-labs/wallet-book": "0.17.18",
39
+ "@dynamic-labs/wallet-connector-core": "0.17.18"
40
40
  },
41
41
  "peerDependencies": {}
42
42
  }
@@ -167,6 +167,21 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
167
167
  WalletConnectV2.provider.client.removeAllListeners('session_event');
168
168
  WalletConnectV2.provider.client.removeAllListeners('session_delete');
169
169
  }
170
+ getDeepLink() {
171
+ var _a, _b;
172
+ if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
173
+ return;
174
+ const wallet = walletBook.getWalletBookWallet(this.name);
175
+ if (!utils.isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
176
+ return undefined;
177
+ }
178
+ return walletConnectorCore.getDeepLink({
179
+ isWC2: true,
180
+ metadata: wallet,
181
+ mode: 'regular',
182
+ uri: WalletConnectV2.provider.uri,
183
+ });
184
+ }
170
185
  getWeb3Provider() {
171
186
  if (!WalletConnectV2.provider) {
172
187
  return;
@@ -224,7 +239,6 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
224
239
  });
225
240
  }
226
241
  signMessage(messageToSign) {
227
- var _a, _b;
228
242
  return _tslib.__awaiter(this, void 0, void 0, function* () {
229
243
  if (!this.session) {
230
244
  throw new utils.DynamicError('no session');
@@ -234,7 +248,14 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
234
248
  }
235
249
  const metadata = walletBook.getWalletBookWallet(this.name);
236
250
  if (utils.isMobile()) {
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) || '';
251
+ // for sign message, no uri is needed because the uri encodes connection details,
252
+ // and at this point we are already connected
253
+ const deepLink = walletConnectorCore.getDeepLink({
254
+ isWC2: true,
255
+ metadata,
256
+ mode: 'regular',
257
+ uri: WalletConnectV2.provider.uri,
258
+ });
238
259
  window.location.href = deepLink;
239
260
  }
240
261
  const web3Provider = this.getWeb3Provider();
@@ -30,6 +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;
33
34
  getWeb3Provider(): ethers.providers.Web3Provider | undefined;
34
35
  fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
35
36
  signMessage(messageToSign: string): Promise<string | undefined>;
@@ -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, performPlatformSpecificConnectionMethod, utf8ToHex } from '@dynamic-labs/wallet-connector-core';
5
+ import { logger, getDeepLink, 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';
@@ -158,6 +158,21 @@ class WalletConnectV2 extends EthWalletConnector {
158
158
  WalletConnectV2.provider.client.removeAllListeners('session_event');
159
159
  WalletConnectV2.provider.client.removeAllListeners('session_delete');
160
160
  }
161
+ getDeepLink() {
162
+ var _a, _b;
163
+ if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri))
164
+ return;
165
+ const wallet = getWalletBookWallet(this.name);
166
+ if (!isMobile() && !((_b = wallet.desktop) === null || _b === void 0 ? void 0 : _b.native)) {
167
+ return undefined;
168
+ }
169
+ return getDeepLink({
170
+ isWC2: true,
171
+ metadata: wallet,
172
+ mode: 'regular',
173
+ uri: WalletConnectV2.provider.uri,
174
+ });
175
+ }
161
176
  getWeb3Provider() {
162
177
  if (!WalletConnectV2.provider) {
163
178
  return;
@@ -215,7 +230,6 @@ class WalletConnectV2 extends EthWalletConnector {
215
230
  });
216
231
  }
217
232
  signMessage(messageToSign) {
218
- var _a, _b;
219
233
  return __awaiter(this, void 0, void 0, function* () {
220
234
  if (!this.session) {
221
235
  throw new DynamicError('no session');
@@ -225,7 +239,14 @@ class WalletConnectV2 extends EthWalletConnector {
225
239
  }
226
240
  const metadata = getWalletBookWallet(this.name);
227
241
  if (isMobile()) {
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) || '';
242
+ // for sign message, no uri is needed because the uri encodes connection details,
243
+ // and at this point we are already connected
244
+ const deepLink = getDeepLink({
245
+ isWC2: true,
246
+ metadata,
247
+ mode: 'regular',
248
+ uri: WalletConnectV2.provider.uri,
249
+ });
229
250
  window.location.href = deepLink;
230
251
  }
231
252
  const web3Provider = this.getWeb3Provider();