@dynamic-labs/ethereum 0.19.0-alpha.6 → 0.19.0-alpha.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,51 @@
1
1
 
2
+ ## [0.19.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.7...v0.19.0-alpha.8) (2023-09-11)
3
+
4
+
5
+ ### Features
6
+
7
+ * add onSignedMessage callback ([#3118](https://github.com/dynamic-labs/DynamicAuth/issues/3118)) ([acc36f6](https://github.com/dynamic-labs/DynamicAuth/commit/acc36f6cf584eb05a019027475a6e2e413fd6bd5))
8
+ * add social sign-in without embedded wallet ([#3172](https://github.com/dynamic-labs/DynamicAuth/issues/3172)) ([ff1acc6](https://github.com/dynamic-labs/DynamicAuth/commit/ff1acc6d9753ba745ac01c5ef6d26f2e4291b752))
9
+ * show default wallet icon when image breaks ([#3234](https://github.com/dynamic-labs/DynamicAuth/issues/3234)) ([657e6bb](https://github.com/dynamic-labs/DynamicAuth/commit/657e6bbc1cdcd840562d25194a827ea833237c1a))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * catch error sending sdkSettings and log warning ([#3274](https://github.com/dynamic-labs/DynamicAuth/issues/3274)) ([fcbe01b](https://github.com/dynamic-labs/DynamicAuth/commit/fcbe01bc733a73f38aebd6ffb0969b040dd2f781))
15
+ * detect if oauth popup is blocked and throw error ([#3250](https://github.com/dynamic-labs/DynamicAuth/issues/3250)) ([b87ddf3](https://github.com/dynamic-labs/DynamicAuth/commit/b87ddf399104e29c56566abbbecab6ff947992d6))
16
+ * display error message to user if social account already exits ([#3258](https://github.com/dynamic-labs/DynamicAuth/issues/3258)) ([bb52cb4](https://github.com/dynamic-labs/DynamicAuth/commit/bb52cb4ae42d89310d435584ed4ece126f9b6a4a))
17
+ * don't call callbacks if window closed due to oauth process complete ([#3252](https://github.com/dynamic-labs/DynamicAuth/issues/3252)) ([09a3c73](https://github.com/dynamic-labs/DynamicAuth/commit/09a3c73446aa337f24e0875cd4a0af617ea8ca84))
18
+ * issue where unexpected token would occur when bundlers defined process.env ([#3283](https://github.com/dynamic-labs/DynamicAuth/issues/3283)) ([d31d0a4](https://github.com/dynamic-labs/DynamicAuth/commit/d31d0a4011256f59cb3760acdc2c3dfe6c5b504a))
19
+ * login view layout updates ([#3231](https://github.com/dynamic-labs/DynamicAuth/issues/3231)) ([7762d06](https://github.com/dynamic-labs/DynamicAuth/commit/7762d067bdd4b3f313a15308262f18dac0b961ab))
20
+ * **MagicWalletConnector:** remove async from getWeb3Provider method ([#3230](https://github.com/dynamic-labs/DynamicAuth/issues/3230)) ([69356e9](https://github.com/dynamic-labs/DynamicAuth/commit/69356e9b0bd1800acdf24fc96c72b094b595eaa7))
21
+ * remove react component props from sending to sdk api ([#3282](https://github.com/dynamic-labs/DynamicAuth/issues/3282)) ([b0d8f2b](https://github.com/dynamic-labs/DynamicAuth/commit/b0d8f2b9dd0856a5a7bd862f6c3499b65ec29f64))
22
+ * seprate ls checks for dynamiccontext and wagmi settings ([#3275](https://github.com/dynamic-labs/DynamicAuth/issues/3275)) ([aa4e756](https://github.com/dynamic-labs/DynamicAuth/commit/aa4e756a10310ce216b5942d0d6845f7092a89a2))
23
+ * use context to handle social sign-in and display message while processing ([#3216](https://github.com/dynamic-labs/DynamicAuth/issues/3216)) ([0e3ce73](https://github.com/dynamic-labs/DynamicAuth/commit/0e3ce73eafbb8d5725377c9a8cbd86a82d6c525f))
24
+ * **wallet-connect-v2:** use appropriate default chain id with WC v2 ([#3218](https://github.com/dynamic-labs/DynamicAuth/issues/3218)) ([2e6e7be](https://github.com/dynamic-labs/DynamicAuth/commit/2e6e7beb801ea5a8dc7429970bcd1e705610d605))
25
+
26
+ ## [0.19.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.6...v0.19.0-alpha.7) (2023-08-31)
27
+
28
+
29
+ ### Features
30
+
31
+ * include deepLinkPreference option for wallet connect deep linking mode ([#3174](https://github.com/dynamic-labs/DynamicAuth/issues/3174)) ([f715948](https://github.com/dynamic-labs/DynamicAuth/commit/f715948050ddab52373ab742ea47cfc0879842ae))
32
+ * add option to disable the locked wallet view ([#3184](https://github.com/dynamic-labs/DynamicAuth/issues/3184)) ([d9a1290](https://github.com/dynamic-labs/DynamicAuth/commit/d9a1290214b7f86337abb544acd96f65ffe37759))
33
+ * migrate starknet version to v5 ([#3153](https://github.com/dynamic-labs/DynamicAuth/issues/3153)) ([b674011](https://github.com/dynamic-labs/DynamicAuth/commit/b67401133bf75d416118b51be11e3f099d2e2cda))
34
+ * add editable text with react i18next ([#3170](https://github.com/dynamic-labs/DynamicAuth/issues/3170)) ([a46b2ca](https://github.com/dynamic-labs/DynamicAuth/commit/a46b2ca880a4e14356024d2936920f72c8bc447e))
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * allow to select L2 wallet after changing L1 network ([#3158](https://github.com/dynamic-labs/DynamicAuth/issues/3158)) ([cf68472](https://github.com/dynamic-labs/DynamicAuth/commit/cf6847270181f7fd33537ac1ff2a03e70b67daf2))
40
+ * allow user to cancel magic login to choose another email ([#3123](https://github.com/dynamic-labs/DynamicAuth/issues/3123)) ([cd73d6d](https://github.com/dynamic-labs/DynamicAuth/commit/cd73d6d0500c313dda01bca6245c52d2d8fca93a))
41
+ * verify email OTP when email is updated ([#3168](https://github.com/dynamic-labs/DynamicAuth/issues/3168)) ([641eeb6](https://github.com/dynamic-labs/DynamicAuth/commit/641eeb685b0c9d77cc72912f29b137c699c192f0))
42
+ * end connector session when unlinking in bridge ([#3120](https://github.com/dynamic-labs/DynamicAuth/issues/3120)) ([4c15da2](https://github.com/dynamic-labs/DynamicAuth/commit/4c15da27646c7bd176f6080dee6d76833e30f8a1))
43
+ * improves loading the sdk setting once per session ([#3189](https://github.com/dynamic-labs/DynamicAuth/issues/3189)) ([c9b0241](https://github.com/dynamic-labs/DynamicAuth/commit/c9b0241da28d2a73c90fd7643280c8632772c90b))
44
+ * update wallet address when switching network on bridge ([#3171](https://github.com/dynamic-labs/DynamicAuth/issues/3171)) ([f35f35e](https://github.com/dynamic-labs/DynamicAuth/commit/f35f35e632bcf88794884b66e0466cdf2e924812))
45
+ * updates the user email when updateUserWithModal method is used ([#3186](https://github.com/dynamic-labs/DynamicAuth/issues/3186)) ([8c71863](https://github.com/dynamic-labs/DynamicAuth/commit/8c718632cef0165328b929c27b6eef313641458d))
46
+ * sign message for embedded wallet when auth mode is connect only ([#3185](https://github.com/dynamic-labs/DynamicAuth/issues/3185)) ([0e3859c](https://github.com/dynamic-labs/DynamicAuth/commit/0e3859cfc738d3ecf8f19976e5cdaebc0c4f01c9))
47
+ * sync wagmi with wallet connector ([#3149](https://github.com/dynamic-labs/DynamicAuth/issues/3149)) ([3216e15](https://github.com/dynamic-labs/DynamicAuth/commit/3216e1570ac12ded6b3ce50b7efb762fe6814815))
48
+
2
49
  ## [0.19.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.5...v0.19.0-alpha.6) (2023-08-25)
3
50
 
4
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "0.19.0-alpha.6",
3
+ "version": "0.19.0-alpha.8",
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.19.0-alpha.6",
36
- "@dynamic-labs/types": "0.19.0-alpha.6",
37
- "@dynamic-labs/utils": "0.19.0-alpha.6",
38
- "@dynamic-labs/wallet-book": "0.19.0-alpha.6",
39
- "@dynamic-labs/wallet-connector-core": "0.19.0-alpha.6",
35
+ "@dynamic-labs/rpc-providers": "0.19.0-alpha.8",
36
+ "@dynamic-labs/types": "0.19.0-alpha.8",
37
+ "@dynamic-labs/utils": "0.19.0-alpha.8",
38
+ "@dynamic-labs/wallet-book": "0.19.0-alpha.8",
39
+ "@dynamic-labs/wallet-connector-core": "0.19.0-alpha.8",
40
40
  "@ethersproject/providers": "5.7.2"
41
41
  },
42
42
  "peerDependencies": {}
@@ -100,7 +100,7 @@ class EthProviderHelper {
100
100
  return signedMessage;
101
101
  });
102
102
  }
103
- static _setupEventListeners(name, listeners, web3Provider) {
103
+ static _setupEventListeners(name, walletConnector, web3Provider) {
104
104
  if (!web3Provider) {
105
105
  return {
106
106
  tearDownEventListeners: () => { },
@@ -108,24 +108,23 @@ class EthProviderHelper {
108
108
  }
109
109
  const externalProvider = web3Provider.provider;
110
110
  const handleAccountChange = (accounts) => _tslib.__awaiter(this, void 0, void 0, function* () {
111
- var _b, _c;
112
111
  if (accounts.length === 0) {
113
- yield ((_b = listeners.onDisconnect) === null || _b === void 0 ? void 0 : _b.call(listeners));
112
+ walletConnector.emit('disconnect');
114
113
  return;
115
114
  }
116
- yield ((_c = listeners.onAccountChange) === null || _c === void 0 ? void 0 : _c.call(listeners, accounts));
115
+ walletConnector.emit('accountChange', { accounts });
117
116
  });
118
117
  const handleChainChange = () => _tslib.__awaiter(this, void 0, void 0, function* () {
119
- var _d;
120
118
  const network = yield web3Provider.getNetwork();
121
- yield ((_d = listeners.onChainChange) === null || _d === void 0 ? void 0 : _d.call(listeners, network.chainId.toString()));
119
+ walletConnector.emit('chainChange', {
120
+ chain: network.chainId.toString(),
121
+ });
122
122
  });
123
123
  const handleDisconnect = (error) => _tslib.__awaiter(this, void 0, void 0, function* () {
124
- var _e;
125
124
  if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
126
125
  return;
127
126
  }
128
- yield ((_e = listeners.onDisconnect) === null || _e === void 0 ? void 0 : _e.call(listeners));
127
+ walletConnector.emit('disconnect');
129
128
  });
130
129
  externalProvider.on('accountsChanged', handleAccountChange);
131
130
  externalProvider.on('chainChanged', handleChainChange);
@@ -1,5 +1,5 @@
1
1
  import { ethers } from 'ethers';
2
- import { ProviderCondition, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
2
+ import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
3
3
  import { IEthereum, ProviderFlag } from './types';
4
4
  type Provider = () => ethers.providers.ExternalProvider | undefined;
5
5
  export declare class EthProviderHelper {
@@ -29,7 +29,7 @@ export declare class EthProviderHelper {
29
29
  static fetchPublicAddressWithName(name: string): Promise<string | undefined>;
30
30
  static fetchPublicAddressWithProvider(provider: ethers.providers.Web3Provider): Promise<string | undefined>;
31
31
  static signMessageWithName(messageToSign: string, name: string): Promise<string | undefined>;
32
- static _setupEventListeners(name: string, listeners: WalletEventListeners, web3Provider?: ethers.providers.Web3Provider): {
32
+ static _setupEventListeners(name: string, walletConnector: WalletConnector, web3Provider?: ethers.providers.Web3Provider): {
33
33
  tearDownEventListeners: () => void;
34
34
  };
35
35
  }
@@ -96,7 +96,7 @@ class EthProviderHelper {
96
96
  return signedMessage;
97
97
  });
98
98
  }
99
- static _setupEventListeners(name, listeners, web3Provider) {
99
+ static _setupEventListeners(name, walletConnector, web3Provider) {
100
100
  if (!web3Provider) {
101
101
  return {
102
102
  tearDownEventListeners: () => { },
@@ -104,24 +104,23 @@ class EthProviderHelper {
104
104
  }
105
105
  const externalProvider = web3Provider.provider;
106
106
  const handleAccountChange = (accounts) => __awaiter(this, void 0, void 0, function* () {
107
- var _b, _c;
108
107
  if (accounts.length === 0) {
109
- yield ((_b = listeners.onDisconnect) === null || _b === void 0 ? void 0 : _b.call(listeners));
108
+ walletConnector.emit('disconnect');
110
109
  return;
111
110
  }
112
- yield ((_c = listeners.onAccountChange) === null || _c === void 0 ? void 0 : _c.call(listeners, accounts));
111
+ walletConnector.emit('accountChange', { accounts });
113
112
  });
114
113
  const handleChainChange = () => __awaiter(this, void 0, void 0, function* () {
115
- var _d;
116
114
  const network = yield web3Provider.getNetwork();
117
- yield ((_d = listeners.onChainChange) === null || _d === void 0 ? void 0 : _d.call(listeners, network.chainId.toString()));
115
+ walletConnector.emit('chainChange', {
116
+ chain: network.chainId.toString(),
117
+ });
118
118
  });
119
119
  const handleDisconnect = (error) => __awaiter(this, void 0, void 0, function* () {
120
- var _e;
121
120
  if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
122
121
  return;
123
122
  }
124
- yield ((_e = listeners.onDisconnect) === null || _e === void 0 ? void 0 : _e.call(listeners));
123
+ walletConnector.emit('disconnect');
125
124
  });
126
125
  externalProvider.on('accountsChanged', handleAccountChange);
127
126
  externalProvider.on('chainChanged', handleChainChange);
@@ -17,7 +17,7 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
17
17
  getMobileOrInstalledWallet() {
18
18
  var _a, _b, _c;
19
19
  if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
20
- const wallet = walletBook.getWalletBookWallet(this.walletBook, this.name);
20
+ const wallet = walletBook.getWalletBookWallet(this.walletBook, this.key);
21
21
  if (((_a = this.constructorProps) === null || _a === void 0 ? void 0 : _a.isWalletConnectV2Enabled) &&
22
22
  ((_c = (_b = wallet.walletConnect) === null || _b === void 0 ? void 0 : _b.sdks) === null || _c === void 0 ? void 0 : _c.includes('sign_v2'))) {
23
23
  return new walletConnectV2.WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
@@ -28,8 +28,8 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
28
28
  }
29
29
  return this;
30
30
  }
31
- setupEventListeners(listeners) {
32
- const { tearDownEventListeners } = ethProviderHelper.EthProviderHelper._setupEventListeners(this.name, listeners, this.getWeb3Provider());
31
+ setupEventListeners() {
32
+ const { tearDownEventListeners } = ethProviderHelper.EthProviderHelper._setupEventListeners(this.name, this, this.getWeb3Provider());
33
33
  this.teardownEventListeners = tearDownEventListeners;
34
34
  }
35
35
  getWeb3Provider() {
@@ -1,5 +1,5 @@
1
1
  import { ethers } from 'ethers';
2
- import { Chain, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
2
+ import { Chain } from '@dynamic-labs/wallet-connector-core';
3
3
  import { EvmNetwork } from '@dynamic-labs/types';
4
4
  import { EthWalletConnector } from '../EthWalletConnector';
5
5
  declare abstract class InjectedWalletBase extends EthWalletConnector {
@@ -8,7 +8,7 @@ declare abstract class InjectedWalletBase extends EthWalletConnector {
8
8
  publicAddress: string | undefined;
9
9
  walletConnectorFallback: boolean;
10
10
  getMobileOrInstalledWallet(): InjectedWalletBase;
11
- setupEventListeners(listeners: WalletEventListeners): void;
11
+ setupEventListeners(): void;
12
12
  getWeb3Provider(): ethers.providers.Web3Provider | undefined;
13
13
  isInstalledOnBrowser(): boolean;
14
14
  connect(): Promise<void>;
@@ -15,7 +15,7 @@ class InjectedWalletBase extends EthWalletConnector {
15
15
  getMobileOrInstalledWallet() {
16
16
  var _a, _b, _c;
17
17
  if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
18
- const wallet = getWalletBookWallet(this.walletBook, this.name);
18
+ const wallet = getWalletBookWallet(this.walletBook, this.key);
19
19
  if (((_a = this.constructorProps) === null || _a === void 0 ? void 0 : _a.isWalletConnectV2Enabled) &&
20
20
  ((_c = (_b = wallet.walletConnect) === null || _b === void 0 ? void 0 : _b.sdks) === null || _c === void 0 ? void 0 : _c.includes('sign_v2'))) {
21
21
  return new WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
@@ -26,8 +26,8 @@ class InjectedWalletBase extends EthWalletConnector {
26
26
  }
27
27
  return this;
28
28
  }
29
- setupEventListeners(listeners) {
30
- const { tearDownEventListeners } = EthProviderHelper._setupEventListeners(this.name, listeners, this.getWeb3Provider());
29
+ setupEventListeners() {
30
+ const { tearDownEventListeners } = EthProviderHelper._setupEventListeners(this.name, this, this.getWeb3Provider());
31
31
  this.teardownEventListeners = tearDownEventListeners;
32
32
  }
33
33
  getWeb3Provider() {
@@ -23,7 +23,7 @@ const initClient = (name, bridge, settings) => {
23
23
  /**
24
24
  * Attach event handlers to WalletConnect events.
25
25
  */
26
- const setupWalletConnectEventListeners = (opts, client) => {
26
+ const setupWalletConnectEventListeners = (walletConnector, client) => {
27
27
  if (!client) {
28
28
  return;
29
29
  }
@@ -35,11 +35,9 @@ const setupWalletConnectEventListeners = (opts, client) => {
35
35
  prevChain = client.chainId;
36
36
  }
37
37
  client.on('disconnect', () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
38
- var _a;
39
- yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
38
+ walletConnector.emit('disconnect');
40
39
  }));
41
40
  client.on('session_update', (_, payload) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
42
- var _b, _c;
43
41
  // eslint-disable-next-line prefer-destructuring
44
42
  const { accounts, chainId } = payload.params[0];
45
43
  const didAccountChange = !walletConnectorCore.isSameAddress(prevAccount || '', accounts[0], 'eip155');
@@ -48,10 +46,10 @@ const setupWalletConnectEventListeners = (opts, client) => {
48
46
  prevAccount = accounts[0];
49
47
  prevChain = chainId;
50
48
  if (didAccountChange) {
51
- yield ((_b = opts.onAccountChange) === null || _b === void 0 ? void 0 : _b.call(opts, accounts));
49
+ walletConnector.emit('accountChange', { accounts });
52
50
  }
53
51
  if (didChainChange) {
54
- yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
52
+ walletConnector.emit('chainChange', { chain: String(chainId) });
55
53
  }
56
54
  }));
57
55
  };
@@ -84,7 +82,7 @@ const createSession = (client) => _tslib.__awaiter(void 0, void 0, void 0, funct
84
82
  });
85
83
  });
86
84
  });
87
- const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
85
+ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, deepLinkPreference, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
88
86
  var _a;
89
87
  if (wcClient.connected) {
90
88
  const [accountPublicAddress] = wcClient.accounts;
@@ -95,13 +93,13 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => _tslib.
95
93
  walletConnectorCore.performPlatformSpecificConnectionMethod(wcClient.uri, metadata, {
96
94
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
97
95
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
98
- });
96
+ }, deepLinkPreference);
99
97
  const payload = yield createSession(wcClient);
100
98
  (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
101
99
  const [accountPublicAddress] = payload.params[0].accounts;
102
100
  return accountPublicAddress;
103
101
  });
104
- const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
102
+ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, deepLinkPreference, rpcProvider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
105
103
  var _b, _c;
106
104
  const isCryptoWallet = ((_b = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _b === void 0 ? void 0 : _b.name) === 'Crypto.com | DeFi Wallet' ||
107
105
  ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
@@ -113,6 +111,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
113
111
  const deepLink = walletConnectorCore.getDeepLink({
114
112
  metadata,
115
113
  mode: 'regular',
114
+ preference: deepLinkPreference,
116
115
  uri: client.uri,
117
116
  });
118
117
  window.location.href = deepLink;
@@ -1,17 +1,17 @@
1
1
  import Client from '@walletconnect/client';
2
2
  import { ethers } from 'ethers';
3
- import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
3
+ import { FetchPublicAddressOpts, PayloadParams, DeepLinkVariant, WalletConnector } from '@dynamic-labs/wallet-connector-core';
4
4
  import { WalletSchema } from '@dynamic-labs/wallet-book';
5
5
  export declare const initClient: (name: string, bridge: string, settings?: any) => Client;
6
6
  /**
7
7
  * Attach event handlers to WalletConnect events.
8
8
  */
9
- export declare const setupWalletConnectEventListeners: (opts: WalletEventListeners, client: Client) => void;
9
+ export declare const setupWalletConnectEventListeners: (walletConnector: WalletConnector, client: Client) => void;
10
10
  export declare const teardownWalletConnectEventListeners: (client: Client) => void;
11
11
  /**
12
12
  * Initialize a client from a stored session and terminate the connection.
13
13
  */
14
14
  export declare const killWalletConnectSession: (client: Client) => Promise<void>;
15
15
  export declare const createSession: (client: Client) => Promise<PayloadParams>;
16
- export declare const fetchWalletConnectEVMPublicAddress: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
17
- export declare const signWalletConnectPersonalMessage: (messageToSign: string, metadata: WalletSchema, client: Client, rpcProvider?: () => Promise<ethers.providers.JsonRpcProvider | undefined>) => Promise<string | undefined>;
16
+ export declare const fetchWalletConnectEVMPublicAddress: (metadata: WalletSchema, wcClient: Client, deepLinkPreference: DeepLinkVariant, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
17
+ export declare const signWalletConnectPersonalMessage: (messageToSign: string, metadata: WalletSchema, client: Client, deepLinkPreference: DeepLinkVariant, rpcProvider?: () => Promise<ethers.providers.JsonRpcProvider | undefined>) => Promise<string | undefined>;
@@ -15,7 +15,7 @@ const initClient = (name, bridge, settings) => {
15
15
  /**
16
16
  * Attach event handlers to WalletConnect events.
17
17
  */
18
- const setupWalletConnectEventListeners = (opts, client) => {
18
+ const setupWalletConnectEventListeners = (walletConnector, client) => {
19
19
  if (!client) {
20
20
  return;
21
21
  }
@@ -27,11 +27,9 @@ const setupWalletConnectEventListeners = (opts, client) => {
27
27
  prevChain = client.chainId;
28
28
  }
29
29
  client.on('disconnect', () => __awaiter(void 0, void 0, void 0, function* () {
30
- var _a;
31
- yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
30
+ walletConnector.emit('disconnect');
32
31
  }));
33
32
  client.on('session_update', (_, payload) => __awaiter(void 0, void 0, void 0, function* () {
34
- var _b, _c;
35
33
  // eslint-disable-next-line prefer-destructuring
36
34
  const { accounts, chainId } = payload.params[0];
37
35
  const didAccountChange = !isSameAddress(prevAccount || '', accounts[0], 'eip155');
@@ -40,10 +38,10 @@ const setupWalletConnectEventListeners = (opts, client) => {
40
38
  prevAccount = accounts[0];
41
39
  prevChain = chainId;
42
40
  if (didAccountChange) {
43
- yield ((_b = opts.onAccountChange) === null || _b === void 0 ? void 0 : _b.call(opts, accounts));
41
+ walletConnector.emit('accountChange', { accounts });
44
42
  }
45
43
  if (didChainChange) {
46
- yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
44
+ walletConnector.emit('chainChange', { chain: String(chainId) });
47
45
  }
48
46
  }));
49
47
  };
@@ -76,7 +74,7 @@ const createSession = (client) => __awaiter(void 0, void 0, void 0, function* ()
76
74
  });
77
75
  });
78
76
  });
79
- const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __awaiter(void 0, void 0, void 0, function* () {
77
+ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, deepLinkPreference, opts) => __awaiter(void 0, void 0, void 0, function* () {
80
78
  var _a;
81
79
  if (wcClient.connected) {
82
80
  const [accountPublicAddress] = wcClient.accounts;
@@ -87,13 +85,13 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __await
87
85
  performPlatformSpecificConnectionMethod(wcClient.uri, metadata, {
88
86
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
89
87
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
90
- });
88
+ }, deepLinkPreference);
91
89
  const payload = yield createSession(wcClient);
92
90
  (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
93
91
  const [accountPublicAddress] = payload.params[0].accounts;
94
92
  return accountPublicAddress;
95
93
  });
96
- const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
94
+ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, deepLinkPreference, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
97
95
  var _b, _c;
98
96
  const isCryptoWallet = ((_b = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _b === void 0 ? void 0 : _b.name) === 'Crypto.com | DeFi Wallet' ||
99
97
  ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
@@ -105,6 +103,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
105
103
  const deepLink = getDeepLink({
106
104
  metadata,
107
105
  mode: 'regular',
106
+ preference: deepLinkPreference,
108
107
  uri: client.uri,
109
108
  });
110
109
  window.location.href = deepLink;
@@ -30,6 +30,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
30
30
  if (walletConnectV1Bridge) {
31
31
  this.bridge = walletConnectV1Bridge;
32
32
  }
33
+ this.deepLinkPreference = props.deepLinkPreference || 'native';
33
34
  }
34
35
  getClient() {
35
36
  if (this.client) {
@@ -47,12 +48,8 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
47
48
  return Boolean(client === null || client === void 0 ? void 0 : client.chainId);
48
49
  }
49
50
  }
50
- setupEventListeners(listeners) {
51
- client.setupWalletConnectEventListeners({
52
- onAccountChange: listeners.onAccountChange,
53
- onChainChange: listeners.onChainChange,
54
- onDisconnect: listeners.onDisconnect,
55
- }, this.getClient());
51
+ setupEventListeners() {
52
+ client.setupWalletConnectEventListeners(this, this.getClient());
56
53
  }
57
54
  teardownEventListeners() {
58
55
  client.teardownWalletConnectEventListeners(this.getClient());
@@ -69,7 +66,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
69
66
  }
70
67
  fetchPublicAddress(opts) {
71
68
  return _tslib.__awaiter(this, void 0, void 0, function* () {
72
- return client.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(), Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
69
+ return client.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
73
70
  var _a;
74
71
  (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
75
72
  this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
@@ -78,19 +75,20 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
78
75
  }
79
76
  getDeepLink() {
80
77
  var _a;
81
- const wallet = walletBook.getWalletBookWallet(this.walletBook, this.name);
78
+ const wallet = walletBook.getWalletBookWallet(this.walletBook, this.key);
82
79
  if (!utils.isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
83
80
  return undefined;
84
81
  }
85
82
  return walletConnectorCore.getDeepLink({
86
83
  metadata: wallet,
87
84
  mode: 'regular',
85
+ preference: this.deepLinkPreference,
88
86
  uri: this.getClient().uri,
89
87
  });
90
88
  }
91
89
  signMessage(messageToSign) {
92
90
  return _tslib.__awaiter(this, void 0, void 0, function* () {
93
- return client.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.walletBook, this.name), this.getClient(),
91
+ return client.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference,
94
92
  // don't call getRpcProvider until we really need to
95
93
  () => _tslib.__awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
96
94
  });
@@ -122,8 +120,9 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
122
120
  }
123
121
  if (utils.isMobile()) {
124
122
  const deepLink = walletConnectorCore.getDeepLink({
125
- metadata: walletBook.getWalletBookWallet(this.walletBook, this.name),
123
+ metadata: walletBook.getWalletBookWallet(this.walletBook, this.key),
126
124
  mode: 'regular',
125
+ preference: this.deepLinkPreference,
127
126
  uri: client.uri,
128
127
  });
129
128
  window.location.href = deepLink;
@@ -1,6 +1,6 @@
1
1
  import Client from '@walletconnect/client';
2
2
  import { ethers } from 'ethers';
3
- import { Chain, FetchPublicAddressOpts, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
3
+ import { Chain, FetchPublicAddressOpts, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
4
4
  import { EvmNetwork } from '@dynamic-labs/types';
5
5
  import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
6
6
  type ConnectorSession = {
@@ -19,6 +19,7 @@ type ConnectorSession = {
19
19
  export type WalletConnectOpts = EthWalletConnectorOpts & {
20
20
  walletConnectV1Bridge: string;
21
21
  walletName: string;
22
+ deepLinkPreference?: DeepLinkVariant;
22
23
  };
23
24
  export declare class WalletConnect extends EthWalletConnector {
24
25
  supportedChains: Chain[];
@@ -28,12 +29,13 @@ export declare class WalletConnect extends EthWalletConnector {
28
29
  canConnectViaQrCode: boolean;
29
30
  isWalletConnect: boolean;
30
31
  switchNetworkOnlyFromWallet: boolean;
32
+ private deepLinkPreference;
31
33
  client?: Client;
32
34
  clientOptions?: any;
33
35
  constructor({ walletConnectV1Bridge, walletName, ...props }: WalletConnectOpts);
34
36
  getClient(): Client;
35
37
  supportsNetworkSwitching(): boolean;
36
- setupEventListeners(listeners: WalletEventListeners): void;
38
+ setupEventListeners(): void;
37
39
  teardownEventListeners(): void;
38
40
  getWeb3Provider(): ethers.providers.Web3Provider | undefined;
39
41
  fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
@@ -22,6 +22,7 @@ class WalletConnect extends EthWalletConnector {
22
22
  if (walletConnectV1Bridge) {
23
23
  this.bridge = walletConnectV1Bridge;
24
24
  }
25
+ this.deepLinkPreference = props.deepLinkPreference || 'native';
25
26
  }
26
27
  getClient() {
27
28
  if (this.client) {
@@ -39,12 +40,8 @@ class WalletConnect extends EthWalletConnector {
39
40
  return Boolean(client === null || client === void 0 ? void 0 : client.chainId);
40
41
  }
41
42
  }
42
- setupEventListeners(listeners) {
43
- setupWalletConnectEventListeners({
44
- onAccountChange: listeners.onAccountChange,
45
- onChainChange: listeners.onChainChange,
46
- onDisconnect: listeners.onDisconnect,
47
- }, this.getClient());
43
+ setupEventListeners() {
44
+ setupWalletConnectEventListeners(this, this.getClient());
48
45
  }
49
46
  teardownEventListeners() {
50
47
  teardownWalletConnectEventListeners(this.getClient());
@@ -61,7 +58,7 @@ class WalletConnect extends EthWalletConnector {
61
58
  }
62
59
  fetchPublicAddress(opts) {
63
60
  return __awaiter(this, void 0, void 0, function* () {
64
- return fetchWalletConnectEVMPublicAddress(getWalletBookWallet(this.walletBook, this.name), this.getClient(), Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
61
+ return fetchWalletConnectEVMPublicAddress(getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
65
62
  var _a;
66
63
  (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
67
64
  this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
@@ -70,19 +67,20 @@ class WalletConnect extends EthWalletConnector {
70
67
  }
71
68
  getDeepLink() {
72
69
  var _a;
73
- const wallet = getWalletBookWallet(this.walletBook, this.name);
70
+ const wallet = getWalletBookWallet(this.walletBook, this.key);
74
71
  if (!isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
75
72
  return undefined;
76
73
  }
77
74
  return getDeepLink({
78
75
  metadata: wallet,
79
76
  mode: 'regular',
77
+ preference: this.deepLinkPreference,
80
78
  uri: this.getClient().uri,
81
79
  });
82
80
  }
83
81
  signMessage(messageToSign) {
84
82
  return __awaiter(this, void 0, void 0, function* () {
85
- return signWalletConnectPersonalMessage(messageToSign, getWalletBookWallet(this.walletBook, this.name), this.getClient(),
83
+ return signWalletConnectPersonalMessage(messageToSign, getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference,
86
84
  // don't call getRpcProvider until we really need to
87
85
  () => __awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
88
86
  });
@@ -114,8 +112,9 @@ class WalletConnect extends EthWalletConnector {
114
112
  }
115
113
  if (isMobile()) {
116
114
  const deepLink = getDeepLink({
117
- metadata: getWalletBookWallet(this.walletBook, this.name),
115
+ metadata: getWalletBookWallet(this.walletBook, this.key),
118
116
  mode: 'regular',
117
+ preference: this.deepLinkPreference,
119
118
  uri: client.uri,
120
119
  });
121
120
  window.location.href = deepLink;
@@ -30,9 +30,17 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
30
30
  this.isWalletConnect = true;
31
31
  this.name = opts.walletName;
32
32
  this.projectId = opts.projectId;
33
+ this.deepLinkPreference = opts.deepLinkPreference || 'native';
34
+ }
35
+ getDefaultChainId() {
36
+ var _a, _b;
37
+ const etheriumMainnetNetwork = (_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.find((network) => network.chainId === 1);
38
+ if (!etheriumMainnetNetwork && ((_b = this.evmNetworks) === null || _b === void 0 ? void 0 : _b.length)) {
39
+ return this.evmNetworks[0].chainId;
40
+ }
41
+ return 1;
33
42
  }
34
43
  initConnection() {
35
- var _a;
36
44
  return _tslib.__awaiter(this, void 0, void 0, function* () {
37
45
  const { provider } = WalletConnectV2;
38
46
  if (!provider) {
@@ -42,9 +50,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
42
50
  if (provider === null || provider === void 0 ? void 0 : provider.uri) {
43
51
  return;
44
52
  }
45
- const defaultChain = ((_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.length)
46
- ? this.evmNetworks[0].chainId
47
- : 1;
53
+ const defaultChain = this.getDefaultChainId();
48
54
  provider
49
55
  .connect({
50
56
  namespaces: {
@@ -199,11 +205,11 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
199
205
  throw new utils.DynamicError('No provider found');
200
206
  }
201
207
  }
202
- const metadata = walletBook.getWalletBookWallet(this.walletBook, this.name);
208
+ const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key);
203
209
  walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
204
210
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
205
211
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
206
- });
212
+ }, this.deepLinkPreference);
207
213
  return new Promise((resolve, reject) => {
208
214
  if (!WalletConnectV2.provider) {
209
215
  reject(new utils.DynamicError('No provider found'));
@@ -254,12 +260,17 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
254
260
  });
255
261
  }
256
262
  getDeepLink() {
257
- var _a, _b;
263
+ var _a;
258
264
  if (!this.session) {
259
265
  return;
260
266
  }
261
- const metadata = walletBook.getWalletBookWallet(this.walletBook, this.name);
262
- const deepLink = ((_a = metadata['mobile']) === null || _a === void 0 ? void 0 : _a.native) || ((_b = metadata['mobile']) === null || _b === void 0 ? void 0 : _b.universal);
267
+ const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key);
268
+ const deepLink = walletConnectorCore.getDeepLink({
269
+ metadata,
270
+ mode: 'regular',
271
+ preference: this.deepLinkPreference,
272
+ uri: (_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri,
273
+ });
263
274
  if (!deepLink) {
264
275
  return;
265
276
  }
@@ -1,11 +1,12 @@
1
1
  import { ethers } from 'ethers';
2
2
  import type { SessionTypes } from '@walletconnect/types';
3
- import { Chain, FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
3
+ import { Chain, FetchPublicAddressOpts, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
4
4
  import { EvmNetwork } from '@dynamic-labs/types';
5
5
  import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
6
6
  export type WalletConnectorV2Opts = EthWalletConnectorOpts & {
7
7
  projectId?: string;
8
8
  walletName: string;
9
+ deepLinkPreference?: DeepLinkVariant;
9
10
  };
10
11
  export declare class WalletConnectV2 extends EthWalletConnector {
11
12
  supportedChains: Chain[];
@@ -19,7 +20,9 @@ export declare class WalletConnectV2 extends EthWalletConnector {
19
20
  isWalletConnect: boolean;
20
21
  private static provider;
21
22
  private projectId?;
23
+ private deepLinkPreference;
22
24
  constructor(opts: WalletConnectorV2Opts);
25
+ getDefaultChainId(): number;
23
26
  private initConnection;
24
27
  private createInitProviderPromise;
25
28
  private initProvider;
@@ -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, performPlatformSpecificConnectionMethod, getDeepLink, 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';
@@ -21,9 +21,17 @@ class WalletConnectV2 extends EthWalletConnector {
21
21
  this.isWalletConnect = true;
22
22
  this.name = opts.walletName;
23
23
  this.projectId = opts.projectId;
24
+ this.deepLinkPreference = opts.deepLinkPreference || 'native';
25
+ }
26
+ getDefaultChainId() {
27
+ var _a, _b;
28
+ const etheriumMainnetNetwork = (_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.find((network) => network.chainId === 1);
29
+ if (!etheriumMainnetNetwork && ((_b = this.evmNetworks) === null || _b === void 0 ? void 0 : _b.length)) {
30
+ return this.evmNetworks[0].chainId;
31
+ }
32
+ return 1;
24
33
  }
25
34
  initConnection() {
26
- var _a;
27
35
  return __awaiter(this, void 0, void 0, function* () {
28
36
  const { provider } = WalletConnectV2;
29
37
  if (!provider) {
@@ -33,9 +41,7 @@ class WalletConnectV2 extends EthWalletConnector {
33
41
  if (provider === null || provider === void 0 ? void 0 : provider.uri) {
34
42
  return;
35
43
  }
36
- const defaultChain = ((_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.length)
37
- ? this.evmNetworks[0].chainId
38
- : 1;
44
+ const defaultChain = this.getDefaultChainId();
39
45
  provider
40
46
  .connect({
41
47
  namespaces: {
@@ -190,11 +196,11 @@ class WalletConnectV2 extends EthWalletConnector {
190
196
  throw new DynamicError('No provider found');
191
197
  }
192
198
  }
193
- const metadata = getWalletBookWallet(this.walletBook, this.name);
199
+ const metadata = getWalletBookWallet(this.walletBook, this.key);
194
200
  performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
195
201
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
196
202
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
197
- });
203
+ }, this.deepLinkPreference);
198
204
  return new Promise((resolve, reject) => {
199
205
  if (!WalletConnectV2.provider) {
200
206
  reject(new DynamicError('No provider found'));
@@ -245,12 +251,17 @@ class WalletConnectV2 extends EthWalletConnector {
245
251
  });
246
252
  }
247
253
  getDeepLink() {
248
- var _a, _b;
254
+ var _a;
249
255
  if (!this.session) {
250
256
  return;
251
257
  }
252
- const metadata = getWalletBookWallet(this.walletBook, this.name);
253
- 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
+ const metadata = getWalletBookWallet(this.walletBook, this.key);
259
+ const deepLink = getDeepLink({
260
+ metadata,
261
+ mode: 'regular',
262
+ preference: this.deepLinkPreference,
263
+ uri: (_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri,
264
+ });
254
265
  if (!deepLink) {
255
266
  return;
256
267
  }