@dynamic-labs/ethereum 4.8.6 → 4.9.1-preview.0

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.
Files changed (26) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +9 -10
  5. package/src/EthereumWalletConnectors.cjs +2 -1
  6. package/src/EthereumWalletConnectors.js +2 -1
  7. package/src/injected/InjectedWalletBase.cjs +2 -2
  8. package/src/injected/InjectedWalletBase.js +2 -2
  9. package/src/metaMask/MetaMaskConnector.cjs +3 -0
  10. package/src/metaMask/MetaMaskConnector.d.ts +1 -0
  11. package/src/metaMask/MetaMaskConnector.js +3 -0
  12. package/src/walletConnect/WalletConnectConnector/WalletConnectConnector.cjs +289 -0
  13. package/src/walletConnect/{walletConnect.d.ts → WalletConnectConnector/WalletConnectConnector.d.ts} +14 -53
  14. package/src/walletConnect/WalletConnectConnector/WalletConnectConnector.js +285 -0
  15. package/src/walletConnect/WalletConnectConnector/index.d.ts +1 -0
  16. package/src/walletConnect/WalletConnectProvider/WalletConnectProvider.cjs +197 -0
  17. package/src/walletConnect/WalletConnectProvider/WalletConnectProvider.d.ts +64 -0
  18. package/src/walletConnect/WalletConnectProvider/WalletConnectProvider.js +189 -0
  19. package/src/walletConnect/WalletConnectProvider/index.d.ts +1 -0
  20. package/src/walletConnect/index.d.ts +1 -1
  21. package/src/walletConnect/utils/fetchWalletConnectWallets.cjs +2 -2
  22. package/src/walletConnect/utils/fetchWalletConnectWallets.js +2 -2
  23. package/src/walletConnect/utils/getWalletConnectConnector.cjs +2 -2
  24. package/src/walletConnect/utils/getWalletConnectConnector.js +2 -2
  25. package/src/walletConnect/walletConnect.cjs +0 -504
  26. package/src/walletConnect/walletConnect.js +0 -495
package/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
 
2
+ ### [4.9.1-preview.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.0...v4.9.1-preview.0) (2025-03-07)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * 7702 on sepolia ([#8242](https://github.com/dynamic-labs/dynamic-auth/issues/8242)) ([8e1c63f](https://github.com/dynamic-labs/dynamic-auth/commit/8e1c63f240024f419e12787636dd2ebaacf8da94))
8
+ * embedded widget race condition that would show both embedded and non-embedded widgets at the same time ([8a52778](https://github.com/dynamic-labs/dynamic-auth/commit/8a5277888489e03871532331760c197aa6216495))
9
+
10
+ ## [4.9.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.6...v4.9.0) (2025-03-07)
11
+
12
+
13
+ ### Features
14
+
15
+ * add utility to use sdk-react-core in iframe ([#8219](https://github.com/dynamic-labs/dynamic-auth/issues/8219)) ([b7b0429](https://github.com/dynamic-labs/dynamic-auth/commit/b7b04292b18085d9cc95edae80100fd8dd667ed6))
16
+
2
17
  ### [4.8.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.5...v4.8.6) (2025-03-07)
3
18
 
4
19
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.8.6";
6
+ var version = "4.9.1-preview.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.8.6";
2
+ var version = "4.9.1-preview.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "4.8.6",
3
+ "version": "4.9.1-preview.0",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -20,18 +20,17 @@
20
20
  "dependencies": {
21
21
  "@coinbase/wallet-sdk": "4.3.0",
22
22
  "@walletconnect/ethereum-provider": "2.18.0",
23
- "@walletconnect/types": "2.18.0",
24
23
  "eventemitter3": "5.0.1",
25
24
  "buffer": "6.0.3",
26
25
  "@metamask/sdk": "0.32.0",
27
- "@dynamic-labs/assert-package-version": "4.8.6",
28
- "@dynamic-labs/embedded-wallet-evm": "4.8.6",
29
- "@dynamic-labs/ethereum-core": "4.8.6",
30
- "@dynamic-labs/logger": "4.8.6",
31
- "@dynamic-labs/types": "4.8.6",
32
- "@dynamic-labs/utils": "4.8.6",
33
- "@dynamic-labs/wallet-book": "4.8.6",
34
- "@dynamic-labs/wallet-connector-core": "4.8.6"
26
+ "@dynamic-labs/assert-package-version": "4.9.1-preview.0",
27
+ "@dynamic-labs/embedded-wallet-evm": "4.9.1-preview.0",
28
+ "@dynamic-labs/ethereum-core": "4.9.1-preview.0",
29
+ "@dynamic-labs/logger": "4.9.1-preview.0",
30
+ "@dynamic-labs/types": "4.9.1-preview.0",
31
+ "@dynamic-labs/utils": "4.9.1-preview.0",
32
+ "@dynamic-labs/wallet-book": "4.9.1-preview.0",
33
+ "@dynamic-labs/wallet-connector-core": "4.9.1-preview.0"
35
34
  },
36
35
  "peerDependencies": {
37
36
  "viem": "^2.21.55"
@@ -10,7 +10,8 @@ require('@dynamic-labs/ethereum-core');
10
10
  require('viem');
11
11
  require('@dynamic-labs/wallet-connector-core');
12
12
  require('@dynamic-labs/wallet-book');
13
- require('./walletConnect/walletConnect.cjs');
13
+ require('viem/accounts');
14
+ require('./walletConnect/WalletConnectProvider/WalletConnectProvider.cjs');
14
15
  var fetchWalletConnectWallets = require('./walletConnect/utils/fetchWalletConnectWallets.cjs');
15
16
  var getWalletConnectConnector = require('./walletConnect/utils/getWalletConnectConnector.cjs');
16
17
  var FallbackEvmConnector = require('./injected/FallbackEvmConnector.cjs');
@@ -6,7 +6,8 @@ import '@dynamic-labs/ethereum-core';
6
6
  import 'viem';
7
7
  import '@dynamic-labs/wallet-connector-core';
8
8
  import '@dynamic-labs/wallet-book';
9
- import './walletConnect/walletConnect.js';
9
+ import 'viem/accounts';
10
+ import './walletConnect/WalletConnectProvider/WalletConnectProvider.js';
10
11
  import { fetchWalletConnectWallets } from './walletConnect/utils/fetchWalletConnectWallets.js';
11
12
  import { getWalletConnectConnector } from './walletConnect/utils/getWalletConnectConnector.js';
12
13
  import { FallbackEvmConnector } from './injected/FallbackEvmConnector.js';
@@ -7,7 +7,7 @@ var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var utils = require('@dynamic-labs/utils');
8
8
  var ethereumCore = require('@dynamic-labs/ethereum-core');
9
9
  var ethProviderHelper = require('../ethProviderHelper.cjs');
10
- var walletConnect = require('../walletConnect/walletConnect.cjs');
10
+ var WalletConnectConnector = require('../walletConnect/WalletConnectConnector/WalletConnectConnector.cjs');
11
11
 
12
12
  class InjectedWalletBase extends ethereumCore.EthereumWalletConnector {
13
13
  constructor() {
@@ -39,7 +39,7 @@ class InjectedWalletBase extends ethereumCore.EthereumWalletConnector {
39
39
  if (!this.walletConnectorFallback) {
40
40
  return this;
41
41
  }
42
- return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
42
+ return new WalletConnectConnector.WalletConnectConnector(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
43
43
  }
44
44
  findProvider() {
45
45
  var _a;
@@ -3,7 +3,7 @@ import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { isMobile } from '@dynamic-labs/utils';
4
4
  import { EthereumWalletConnector } from '@dynamic-labs/ethereum-core';
5
5
  import { EthProviderHelper } from '../ethProviderHelper.js';
6
- import { WalletConnect } from '../walletConnect/walletConnect.js';
6
+ import { WalletConnectConnector } from '../walletConnect/WalletConnectConnector/WalletConnectConnector.js';
7
7
 
8
8
  class InjectedWalletBase extends EthereumWalletConnector {
9
9
  constructor() {
@@ -35,7 +35,7 @@ class InjectedWalletBase extends EthereumWalletConnector {
35
35
  if (!this.walletConnectorFallback) {
36
36
  return this;
37
37
  }
38
- return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
38
+ return new WalletConnectConnector(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
39
39
  }
40
40
  findProvider() {
41
41
  var _a;
@@ -371,6 +371,9 @@ class MetaMaskConnector extends InjectedWalletBase.InjectedWalletBase {
371
371
  return false;
372
372
  return true;
373
373
  }
374
+ getConnectionUri() {
375
+ return undefined;
376
+ }
374
377
  }
375
378
  // Utils
376
379
  const getReadonlyRPCMap = (evmNetworkRpcMap) => Object.keys(evmNetworkRpcMap).reduce((acc, chainId) => (Object.assign(Object.assign({}, acc), { [viem.toHex(parseInt(chainId))]: evmNetworkRpcMap[chainId] })), {});
@@ -50,4 +50,5 @@ export declare class MetaMaskConnector extends InjectedWalletBase implements IWa
50
50
  */
51
51
  private getIsInAppBrowser;
52
52
  private shouldDeepLinkToMetaMaskInAppBrowser;
53
+ getConnectionUri(): string | undefined;
53
54
  }
@@ -367,6 +367,9 @@ class MetaMaskConnector extends InjectedWalletBase {
367
367
  return false;
368
368
  return true;
369
369
  }
370
+ getConnectionUri() {
371
+ return undefined;
372
+ }
370
373
  }
371
374
  // Utils
372
375
  const getReadonlyRPCMap = (evmNetworkRpcMap) => Object.keys(evmNetworkRpcMap).reduce((acc, chainId) => (Object.assign(Object.assign({}, acc), { [toHex(parseInt(chainId))]: evmNetworkRpcMap[chainId] })), {});
@@ -0,0 +1,289 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var viem = require('viem');
8
+ var accounts = require('viem/accounts');
9
+ var ethereumCore = require('@dynamic-labs/ethereum-core');
10
+ var utils = require('@dynamic-labs/utils');
11
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
12
+ var normalizeRpcError = require('../../utils/normalizeRpcError/normalizeRpcError.cjs');
13
+ var WalletConnectProvider = require('../WalletConnectProvider/WalletConnectProvider.cjs');
14
+
15
+ const WC_CURRENT_CHAIN_KEY = 'dynamic-wc2-current-chain';
16
+ class WalletConnectConnector extends ethereumCore.EthereumWalletConnector {
17
+ constructor(opts) {
18
+ super(opts);
19
+ this.canConnectViaQrCode = true;
20
+ this.isWalletConnect = true;
21
+ this.name = opts.walletName;
22
+ this.deepLinkPreference = opts.deepLinkPreference || 'native';
23
+ const storedChainId = localStorage.getItem(WC_CURRENT_CHAIN_KEY);
24
+ if (storedChainId) {
25
+ this.currentChainId = utils.parseIntSafe(storedChainId);
26
+ }
27
+ if (!opts.projectId) {
28
+ throw new utils.DynamicError('WalletConnect project ID is required');
29
+ }
30
+ // set provider props generic to all wallets
31
+ WalletConnectProvider.WalletConnectProvider.projectId = opts.projectId;
32
+ WalletConnectProvider.WalletConnectProvider.enabledNetworks = opts.evmNetworks;
33
+ WalletConnectProvider.WalletConnectProvider.preferredChains =
34
+ opts.walletConnectPreferredChains || [];
35
+ WalletConnectProvider.WalletConnectProvider.evmNetworkRpcMap = this.evmNetworkRpcMap();
36
+ }
37
+ init() {
38
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
39
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] init called', {
40
+ isInitialized: WalletConnectProvider.WalletConnectProvider.isInitialized,
41
+ });
42
+ // we should only init the provider once as soon as possible
43
+ // the connection is established when a wallet is selected (with getAddress)
44
+ if (WalletConnectProvider.WalletConnectProvider.isInitialized) {
45
+ walletConnectorCore.logger.debug('[WalletConnect] init - already initialized - skipping');
46
+ return;
47
+ }
48
+ walletConnectorCore.logger.debug('[WalletConnect] init');
49
+ this.walletConnectorEventsEmitter.emit('connectorInitStarted', 'walletconnect');
50
+ yield WalletConnectProvider.WalletConnectProvider.init();
51
+ const provider = WalletConnectProvider.WalletConnectProvider.getProvider();
52
+ if (!provider) {
53
+ throw new utils.DynamicError('WalletConnectProvider is not initialized');
54
+ }
55
+ this.setupWCEventListeners();
56
+ this.walletConnectorEventsEmitter.emit('connectorInitCompleted', 'walletconnect');
57
+ });
58
+ }
59
+ setupWCEventListeners() {
60
+ walletConnectorCore.logger.debug('[WalletConnect] setupWCEventListeners');
61
+ WalletConnectProvider.WalletConnectProvider.teardownEventListeners();
62
+ WalletConnectProvider.WalletConnectProvider.setupEventListeners({
63
+ onAccountChanged: (account) => {
64
+ walletConnectorCore.logger.debug('[WalletConnect] onAccountChanged', { account });
65
+ this.emit('accountChange', { accounts: [account] });
66
+ },
67
+ onChainChanged: (chainId) => {
68
+ walletConnectorCore.logger.debug('[WalletConnect] onChainChange', { chainId });
69
+ if (chainId === this.currentChainId) {
70
+ walletConnectorCore.logger.debug(`[WalletConnect] onChainChange - ignoring chainChanged event with same chain id as current chain id: ${chainId}`);
71
+ return;
72
+ }
73
+ this.currentChainId = chainId;
74
+ this.emit('chainChange', { chain: String(chainId) });
75
+ },
76
+ onDisconnect: () => {
77
+ walletConnectorCore.logger.debug('[WalletConnect] onDisconnect');
78
+ this.endSession();
79
+ this.emit('disconnect');
80
+ },
81
+ });
82
+ }
83
+ endSession() {
84
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
85
+ walletConnectorCore.logger.debug('[WalletConnect] endSession');
86
+ this.currentChainId = undefined;
87
+ yield WalletConnectProvider.WalletConnectProvider.disconnect();
88
+ });
89
+ }
90
+ getAddress(opts) {
91
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
92
+ walletConnectorCore.logger.debug('[WalletConnect] getAddress', opts);
93
+ if (!WalletConnectProvider.WalletConnectProvider.isInitialized) {
94
+ walletConnectorCore.logger.debug('[WalletConnect] getAddress - WalletConnectProvider is not initialized');
95
+ throw new utils.DynamicError('WalletConnectProvider is not initialized');
96
+ }
97
+ walletConnectorCore.logger.debug('[WalletConnect] getAddress - connecting to WalletConnect');
98
+ const addresses = yield WalletConnectProvider.WalletConnectProvider.connect({
99
+ connectionOpts: opts,
100
+ deepLinkPreference: this.deepLinkPreference,
101
+ deepLinks: this.metadata.deepLinks,
102
+ });
103
+ walletConnectorCore.logger.debug('[WalletConnect] getAddress - connection result', addresses);
104
+ const address = addresses === null || addresses === void 0 ? void 0 : addresses[0];
105
+ return address;
106
+ });
107
+ }
108
+ getWalletClient(chainId) {
109
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] getWalletClient was called - chainId', chainId);
110
+ const provider = WalletConnectProvider.WalletConnectProvider.getProvider();
111
+ if (!provider) {
112
+ walletConnectorCore.logger.debug('[WalletConnect] getWalletClient - provider is not initialized');
113
+ throw new utils.DynamicError('WalletConnectProvider is not initialized');
114
+ }
115
+ const walletClient = viem.createWalletClient({
116
+ account: this.getActiveAccount(),
117
+ chain: ethereumCore.chainsMap[chainId !== null && chainId !== void 0 ? chainId : String(this.currentChainId)],
118
+ transport: viem.custom({
119
+ request: (args) => {
120
+ this.deepLinkIfApplicable(args.method);
121
+ return provider.request(args).catch(normalizeRpcError.normalizeRpcError);
122
+ },
123
+ }),
124
+ });
125
+ return walletClient;
126
+ }
127
+ deepLinkIfApplicable(method) {
128
+ const methodsThatRequireDeepLink = [
129
+ 'personal_sign',
130
+ 'eth_sendTransaction',
131
+ 'eth_signTypedData_v4',
132
+ ];
133
+ const deepLink = this.getDeepLink();
134
+ if (utils.isMobile() && deepLink && methodsThatRequireDeepLink.includes(method)) {
135
+ utils.PlatformService.openURL(deepLink);
136
+ }
137
+ }
138
+ signMessage(messageToSign) {
139
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
140
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] signMessage', messageToSign);
141
+ const activeAccount = this.getActiveAccount();
142
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] signMessage - activeAccount', activeAccount);
143
+ if (!activeAccount) {
144
+ return;
145
+ }
146
+ const walletClient = yield this.getWalletClient();
147
+ return walletClient.signMessage({
148
+ account: activeAccount,
149
+ message: messageToSign,
150
+ });
151
+ });
152
+ }
153
+ getConnectedAccounts() {
154
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
155
+ const activeAccount = this.getActiveAccount();
156
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] getConnectedAccounts - activeAccount', activeAccount);
157
+ return activeAccount ? [activeAccount.address] : [];
158
+ });
159
+ }
160
+ getActiveAccount() {
161
+ var _a;
162
+ const provider = WalletConnectProvider.WalletConnectProvider.getProvider();
163
+ const connectedAccount = (_a = provider === null || provider === void 0 ? void 0 : provider.accounts) === null || _a === void 0 ? void 0 : _a[0];
164
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] getActiveAccount - connectedAccount', connectedAccount);
165
+ if (!connectedAccount) {
166
+ return undefined;
167
+ }
168
+ return accounts.toAccount(connectedAccount);
169
+ }
170
+ get currentChainId() {
171
+ const lsCurrentChain = localStorage.getItem(WC_CURRENT_CHAIN_KEY);
172
+ try {
173
+ return lsCurrentChain ? utils.parseIntSafe(lsCurrentChain) : undefined;
174
+ }
175
+ catch (e) {
176
+ walletConnectorCore.logger.debug('[WalletConnect] getCurrentChainId - error', e);
177
+ return undefined;
178
+ }
179
+ }
180
+ set currentChainId(value) {
181
+ if (value) {
182
+ localStorage.setItem(WC_CURRENT_CHAIN_KEY, value.toString());
183
+ }
184
+ else {
185
+ localStorage.removeItem(WC_CURRENT_CHAIN_KEY);
186
+ }
187
+ }
188
+ getActiveChain() {
189
+ if (!this.currentChainId) {
190
+ return undefined;
191
+ }
192
+ return ethereumCore.chainsMap[this.currentChainId];
193
+ }
194
+ getNetwork() {
195
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
196
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] getNetwork');
197
+ const provider = WalletConnectProvider.WalletConnectProvider.getProvider();
198
+ if (provider === null || provider === void 0 ? void 0 : provider.chainId) {
199
+ const network = provider.chainId;
200
+ this.currentChainId = network;
201
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] getNetwork - provider network', network);
202
+ return network;
203
+ }
204
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] getNetwork - no provider found, returning current chain id', {
205
+ currentChainId: this.currentChainId,
206
+ });
207
+ return this.currentChainId;
208
+ });
209
+ }
210
+ providerSwitchNetwork(_a) {
211
+ const _super = Object.create(null, {
212
+ providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
213
+ });
214
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ network, }) {
215
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] providerSwitchNetwork - network', {
216
+ network,
217
+ switchNetworkOnlyFromWallet: this.switchNetworkOnlyFromWallet,
218
+ });
219
+ const currentNetworkId = yield this.getNetwork();
220
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] providerSwitchNetwork - currentNetworkId', currentNetworkId);
221
+ if (currentNetworkId && currentNetworkId === network.chainId) {
222
+ return;
223
+ }
224
+ if (this.switchNetworkOnlyFromWallet) {
225
+ throw new utils.DynamicError('Network switching is only supported through the wallet');
226
+ }
227
+ const walletClient = yield this.getWalletClient();
228
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] providerSwitchNetwork - will switch network');
229
+ yield _super.providerSwitchNetwork.call(this, { network, provider: walletClient });
230
+ this.currentChainId = network.chainId;
231
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] providerSwitchNetwork - switched network', network.chainId);
232
+ this.emit('chainChange', { chain: String(network.chainId) });
233
+ });
234
+ }
235
+ supportsNetworkSwitching() {
236
+ return true;
237
+ }
238
+ getSupportedNetworks() {
239
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
240
+ var _a;
241
+ const provider = WalletConnectProvider.WalletConnectProvider.getProvider();
242
+ if (!(provider === null || provider === void 0 ? void 0 : provider.session)) {
243
+ return [];
244
+ }
245
+ const chains = [];
246
+ // Some wallet (i.e ZenGo) use namespaces.account to list supported chains
247
+ // while others use keys within the namespaces object
248
+ Object.keys(provider === null || provider === void 0 ? void 0 : provider.session.namespaces).forEach((key) => {
249
+ if (key.startsWith('eip155:')) {
250
+ chains.push(key.split(':')[1]);
251
+ }
252
+ });
253
+ (_a = provider === null || provider === void 0 ? void 0 : provider.session.namespaces.eip155) === null || _a === void 0 ? void 0 : _a.accounts.forEach((account) => chains.push(account.split(':')[1]));
254
+ return chains.length
255
+ ? chains
256
+ : this.evmNetworks.map((network) => network.chainId.toString());
257
+ });
258
+ }
259
+ getDeepLink() {
260
+ var _a;
261
+ const provider = WalletConnectProvider.WalletConnectProvider.getProvider();
262
+ walletConnectorCore.logger.debug('[WalletConnect] getDeepLink', {
263
+ hasSession: Boolean(provider === null || provider === void 0 ? void 0 : provider.session),
264
+ topic: (_a = provider === null || provider === void 0 ? void 0 : provider.session) === null || _a === void 0 ? void 0 : _a.topic,
265
+ uri: provider === null || provider === void 0 ? void 0 : provider.signer.uri,
266
+ });
267
+ if (!(provider === null || provider === void 0 ? void 0 : provider.session)) {
268
+ return;
269
+ }
270
+ const deepLink = walletConnectorCore.getDeepLink({
271
+ deepLinks: this.metadata.deepLinks,
272
+ mode: 'regular',
273
+ preference: this.deepLinkPreference,
274
+ uri: provider.signer.uri,
275
+ });
276
+ walletConnectorCore.logger.logVerboseTroubleshootingMessage('[WalletConnect] getDeepLink - deepLink', deepLink);
277
+ if (!deepLink) {
278
+ return;
279
+ }
280
+ // we need to include the session topic here because it helps the wallet
281
+ // auto redirect back to the dapp after signing
282
+ return `${deepLink}?sessionTopic=${provider.session.topic}`;
283
+ }
284
+ getConnectionUri() {
285
+ return WalletConnectProvider.WalletConnectProvider.getConnectionUri();
286
+ }
287
+ }
288
+
289
+ exports.WalletConnectConnector = WalletConnectConnector;
@@ -1,45 +1,23 @@
1
- import EthereumProvider from '@walletconnect/ethereum-provider';
2
- import type { SessionTypes } from '@walletconnect/types';
3
1
  import { Account, Transport, Chain as ViemChain } from 'viem';
4
2
  import { EthereumWalletConnector, EthereumWalletConnectorOpts } from '@dynamic-labs/ethereum-core';
5
3
  import { EvmNetwork } from '@dynamic-labs/types';
6
4
  import { DeepLinkVariant, GetAddressOpts, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
7
- export type WalletConnectOpts = EthereumWalletConnectorOpts & {
5
+ export type WalletConnectConnectorOpts = EthereumWalletConnectorOpts & {
8
6
  projectId?: string;
9
7
  walletName: string;
10
8
  deepLinkPreference?: DeepLinkVariant;
11
9
  walletConnectPreferredChains?: `eip155:${number}`[];
12
10
  };
13
- export declare class WalletConnect extends EthereumWalletConnector implements IWalletConnectConnector {
14
- private static provider;
11
+ export declare class WalletConnectConnector extends EthereumWalletConnector implements IWalletConnectConnector {
15
12
  name: string;
16
- session: SessionTypes.Struct | undefined;
17
- isInitialized: boolean;
18
- initializePromise: Promise<void> | undefined;
19
13
  canConnectViaQrCode: boolean;
20
14
  isWalletConnect: boolean;
21
- private projectId?;
22
15
  private deepLinkPreference;
23
- private preferredChains;
24
- private sessionEventHandler;
25
- private sessionDeleteHandler;
26
- private _currentChainId;
27
- supportsNetworkSwitching(): boolean;
28
- constructor(opts: WalletConnectOpts);
29
- /**
30
- * This method is used to get the address of the active account.
31
- * It will re-initialize the provider if the provider is not found.
32
- * @param opts
33
- * @returns
34
- */
35
- getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
16
+ constructor(opts: WalletConnectConnectorOpts);
36
17
  init(): Promise<void>;
37
- private initProvider;
38
- private createInitProviderPromise;
39
- private initConnection;
40
- createProvider(): Promise<EthereumProvider>;
41
- private refreshSession;
42
- private getMappedChainsByPreferredOrder;
18
+ private setupWCEventListeners;
19
+ endSession(): Promise<void>;
20
+ getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
43
21
  getWalletClient(chainId?: string): {
44
22
  account: Account;
45
23
  batch?: {
@@ -7697,36 +7675,19 @@ export declare class WalletConnect extends EthereumWalletConnector implements IW
7697
7675
  uid?: undefined;
7698
7676
  } & import("viem").ExactPartial<Pick<import("viem").PublicActions<Transport, ViemChain, Account>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<ViemChain, Account>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<Transport, ViemChain, Account, import("viem").WalletRpcSchema, import("viem").WalletActions<ViemChain, Account>>) => client) => import("viem").Client<Transport, ViemChain, Account, import("viem").WalletRpcSchema, { [K_1 in keyof client]: client[K_1]; } & import("viem").WalletActions<ViemChain, Account>>;
7699
7677
  };
7678
+ private deepLinkIfApplicable;
7679
+ signMessage(messageToSign: string): Promise<string | undefined>;
7680
+ getConnectedAccounts(): Promise<string[]>;
7681
+ getActiveAccount(): Account | undefined;
7700
7682
  private get currentChainId();
7701
7683
  private set currentChainId(value);
7702
- get sessionTopicKey(): string;
7703
- get activeAccountKey(): string;
7704
- get currentChainKey(): string;
7705
- setupEventListeners(): void;
7706
- teardownEventListeners(): void;
7707
- /**
7708
- * WalletConnect V2 will fail to send the sign message request if the chainId
7709
- * is not the same as the one in the session. This method will wait for the
7710
- * chainId to change and then retry the sign message request.
7711
- *
7712
- * Otherwise it will just return the result of the sign message request.
7713
- *
7714
- * @param signMessageFn - Function to sign message with provider
7715
- * @param messageToSign - Message to sign
7716
- * @returns
7717
- */
7718
- protected waitForSignMessage(signMessageFn: (messageToSign: string) => Promise<string | undefined>, messageToSign: string): Promise<string | undefined>;
7719
- getDeepLink(): string | undefined;
7720
- signMessage(messageToSign: string): Promise<string | undefined>;
7721
- private clearActiveAccount;
7722
- private clearSession;
7723
- private setWCActiveAccount;
7724
- private setSession;
7725
- endSession(): Promise<void>;
7684
+ getActiveChain(): ViemChain | undefined;
7726
7685
  getNetwork(): Promise<number | undefined>;
7727
7686
  providerSwitchNetwork({ network, }: {
7728
7687
  network: EvmNetwork;
7729
7688
  }): Promise<void>;
7730
- getConnectedAccounts(): Promise<string[]>;
7689
+ supportsNetworkSwitching(): boolean;
7731
7690
  getSupportedNetworks(): Promise<string[]>;
7691
+ getDeepLink(): string | undefined;
7692
+ getConnectionUri(): string | undefined;
7732
7693
  }