@dynamic-labs/ethereum 2.0.0-alpha.9 → 2.1.0-alpha.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 (38) hide show
  1. package/CHANGELOG.md +316 -0
  2. package/package.json +10 -9
  3. package/src/EthWalletConnector.cjs +12 -1
  4. package/src/EthWalletConnector.d.ts +13 -10
  5. package/src/EthWalletConnector.js +12 -1
  6. package/src/coinbase/client/client.cjs +14 -14
  7. package/src/coinbase/client/client.d.ts +5 -4
  8. package/src/coinbase/client/client.js +13 -13
  9. package/src/coinbase/client/types.d.ts +6 -3
  10. package/src/coinbase/coinbase.cjs +30 -13
  11. package/src/coinbase/coinbase.d.ts +5 -4
  12. package/src/coinbase/coinbase.js +31 -14
  13. package/src/ethProviderHelper.cjs +11 -6
  14. package/src/ethProviderHelper.d.ts +6 -4
  15. package/src/ethProviderHelper.js +11 -6
  16. package/src/index.cjs +3 -1
  17. package/src/index.d.ts +1 -0
  18. package/src/index.js +3 -2
  19. package/src/injected/InjectedWalletBase.cjs +28 -11
  20. package/src/injected/InjectedWalletBase.d.ts +2 -2
  21. package/src/injected/InjectedWalletBase.js +28 -11
  22. package/src/injected/PhantomEvm.cjs +3 -3
  23. package/src/injected/PhantomEvm.d.ts +1 -1
  24. package/src/injected/PhantomEvm.js +3 -3
  25. package/src/injected/Zerion.cjs +38 -0
  26. package/src/injected/Zerion.d.ts +10 -0
  27. package/src/injected/Zerion.js +34 -0
  28. package/src/injected/fetchInjectedWalletConnectors.cjs +25 -0
  29. package/src/injected/fetchInjectedWalletConnectors.js +25 -0
  30. package/src/utils/index.d.ts +1 -0
  31. package/src/utils/isEthWalletConnector/index.d.ts +1 -0
  32. package/src/utils/isEthWalletConnector/isEthWalletConnector.cjs +7 -0
  33. package/src/utils/isEthWalletConnector/isEthWalletConnector.d.ts +3 -0
  34. package/src/utils/isEthWalletConnector/isEthWalletConnector.js +3 -0
  35. package/src/walletConnect/index.d.ts +1 -1
  36. package/src/walletConnect/walletConnect.cjs +114 -75
  37. package/src/walletConnect/walletConnect.d.ts +19 -18
  38. package/src/walletConnect/walletConnect.js +113 -74
@@ -3,18 +3,19 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../../_virtual/_tslib.cjs');
6
- var Provider = require('@walletconnect/universal-provider');
6
+ var EthereumProvider = require('@walletconnect/ethereum-provider');
7
7
  var EventEmitter = require('eventemitter3');
8
8
  var viem = require('viem');
9
- var utils = require('@dynamic-labs/utils');
10
- var walletBook = require('@dynamic-labs/wallet-book');
11
9
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
10
+ var walletBook = require('@dynamic-labs/wallet-book');
11
+ var utils = require('@dynamic-labs/utils');
12
+ var viemUtils = require('@dynamic-labs/viem-utils');
12
13
  var EthWalletConnector = require('../EthWalletConnector.cjs');
13
14
  var parseIntSafe = require('../utils/parseIntSafe.cjs');
14
15
 
15
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
17
 
17
- var Provider__default = /*#__PURE__*/_interopDefaultLegacy(Provider);
18
+ var EthereumProvider__default = /*#__PURE__*/_interopDefaultLegacy(EthereumProvider);
18
19
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
19
20
 
20
21
  const activeAccountKey = (walletName) => `dynamic-wc2-active-account-${walletName}`;
@@ -35,6 +36,8 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
35
36
  // When trying to switch network for MetaMask, the switch promise gets stuck
36
37
  // if the switch got trigged once already, so we need to keep track of that
37
38
  this._hasSwitchedNetwork = false;
39
+ this.sessionEventHandler = () => { };
40
+ this.sessionDeleteHandler = () => { };
38
41
  this.name = opts.walletName;
39
42
  this.projectId = opts.projectId;
40
43
  this.deepLinkPreference = opts.deepLinkPreference || 'native';
@@ -56,7 +59,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
56
59
  const allChains = this.getMappedChains();
57
60
  const reorderedChains = this.preferredChains.filter((chain) => allChains.includes(chain));
58
61
  const remainingChains = allChains.filter((chain) => !this.preferredChains.includes(chain));
59
- return [...reorderedChains, ...remainingChains];
62
+ return [...reorderedChains, ...remainingChains].map((chain) => Number(chain.split(':')[1]));
60
63
  }
61
64
  initConnection() {
62
65
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -65,43 +68,51 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
65
68
  throw new utils.DynamicError('No provider found (init connection)');
66
69
  }
67
70
  // this means there is already a connection in progress, so don't call connect again
68
- if (provider === null || provider === void 0 ? void 0 : provider.uri) {
71
+ if (provider === null || provider === void 0 ? void 0 : provider.signer.uri) {
69
72
  return;
70
73
  }
71
- const optionalNamespaces = {
72
- eip155: {
73
- chains: this.getMappedChainsByPreferredOrder(),
74
- events: ['chainChanged', 'accountsChanged'],
75
- methods: [
76
- 'eth_chainId',
77
- 'eth_signTypedData',
78
- 'eth_signTransaction',
79
- 'eth_sign',
80
- 'personal_sign',
81
- 'eth_sendTransaction',
82
- 'eth_signTypedData_v4',
83
- 'wallet_switchEthereumChain',
84
- 'wallet_addEthereumChain',
85
- ],
86
- rpcMap: this.evmNetworkRpcMap(),
87
- },
88
- };
89
- provider
90
- .connect({
91
- optionalNamespaces,
92
- })
93
- .catch((e) => {
74
+ provider.connect().catch((e) => {
94
75
  walletConnectorCore.logger.error(e);
95
76
  ee.emit('walletconnect_connection_failed', e);
96
77
  });
97
78
  });
98
79
  }
99
- createInitProviderPromise() {
80
+ createProvider() {
100
81
  return _tslib.__awaiter(this, void 0, void 0, function* () {
101
- WalletConnect.provider = yield Provider__default["default"].init({
102
- logger: walletConnectorCore.logger.logLevel.toLowerCase() === 'debug' ? 'debug' : undefined,
82
+ return EthereumProvider__default["default"].init({
83
+ events: ['chainChanged', 'accountsChanged'],
84
+ methods: [],
85
+ optionalChains: this.getMappedChainsByPreferredOrder(),
86
+ optionalMethods: [
87
+ 'eth_chainId',
88
+ 'eth_signTypedData',
89
+ 'eth_signTransaction',
90
+ 'eth_sign',
91
+ 'personal_sign',
92
+ 'eth_sendTransaction',
93
+ 'eth_signTypedData_v4',
94
+ 'wallet_switchEthereumChain',
95
+ 'wallet_addEthereumChain',
96
+ ],
103
97
  projectId: this.projectId,
98
+ rpcMap: this.evmNetworkRpcMap(),
99
+ showQrModal: false,
100
+ });
101
+ });
102
+ }
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),
104
109
  });
110
+ return walletClient;
111
+ });
112
+ }
113
+ createInitProviderPromise() {
114
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
115
+ WalletConnect.provider = yield this.createProvider();
105
116
  this.teardownEventListeners();
106
117
  this.setupEventListeners();
107
118
  });
@@ -126,7 +137,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
126
137
  if (localStorage.getItem(this.sessionTopicKey) ===
127
138
  ((_d = (_c = WalletConnect.provider) === null || _c === void 0 ? void 0 : _c.session) === null || _d === void 0 ? void 0 : _d.topic)) {
128
139
  this.session = WalletConnect.provider.session;
129
- this.activeAccount = ((_e = localStorage.getItem(this.activeAccountKey)) !== null && _e !== void 0 ? _e : undefined);
140
+ this.setActiveAccount(((_e = localStorage.getItem(this.activeAccountKey)) !== null && _e !== void 0 ? _e : undefined));
130
141
  }
131
142
  }
132
143
  }
@@ -180,7 +191,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
180
191
  if (!WalletConnect.provider) {
181
192
  return;
182
193
  }
183
- WalletConnect.provider.client.on('session_event', ({ params }) => {
194
+ this.sessionEventHandler = ({ params, }) => {
184
195
  walletConnectorCore.logger.debug('session_event was called', { params });
185
196
  if (!params || !params.event) {
186
197
  walletConnectorCore.logger.debug('session_event was called without params or params.event');
@@ -189,12 +200,17 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
189
200
  const { name, data } = params.event;
190
201
  if (name === 'chainChanged') {
191
202
  const chainId = parseIntSafe.parseIntSafe(data);
203
+ if (chainId === this.currentChainId) {
204
+ walletConnectorCore.logger.debug(`ignoring chainChanged event with same chain id as current chain id: ${chainId}`);
205
+ return;
206
+ }
192
207
  if (chainId === undefined) {
193
208
  walletConnectorCore.logger.debug(`received unexpected data for chainChanged: ${data} with type ${typeof data}}`);
194
209
  return;
195
210
  }
196
211
  this.currentChainId = chainId;
197
212
  this.emit('chainChange', { chain: String(chainId) });
213
+ this.hasSwitchedNetwork = true;
198
214
  // When a user switches network from their wallet, we need the provider to change network
199
215
  // such that any future calls to `getNetwork` will return the correct network
200
216
  this.switchNetwork({ networkChainId: chainId });
@@ -206,36 +222,41 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
206
222
  }
207
223
  // eslint-disable-next-line prefer-destructuring
208
224
  const account = data[0].split(':')[2];
209
- this.setActiveAccount(account);
225
+ this.setWCActiveAccount(account);
210
226
  }
211
- });
212
- WalletConnect.provider.client.on('session_delete', () => _tslib.__awaiter(this, void 0, void 0, function* () {
227
+ };
228
+ WalletConnect.provider.on('session_event', this.sessionEventHandler);
229
+ this.sessionDeleteHandler = () => _tslib.__awaiter(this, void 0, void 0, function* () {
213
230
  this.endSession();
214
231
  this.emit('disconnect');
215
- }));
232
+ });
233
+ WalletConnect.provider.on('session_delete', this.sessionDeleteHandler);
216
234
  }
217
235
  teardownEventListeners() {
218
236
  if (!WalletConnect.provider) {
219
237
  return;
220
238
  }
221
- WalletConnect.provider.client.removeAllListeners('session_event');
222
- WalletConnect.provider.client.removeAllListeners('session_delete');
239
+ WalletConnect.provider.off('session_event', this.sessionEventHandler);
240
+ WalletConnect.provider.off('session_delete', this.sessionDeleteHandler);
223
241
  }
224
- getWalletClient() {
242
+ getWalletClient(chainId) {
225
243
  if (!WalletConnect.provider) {
226
244
  return;
227
245
  }
228
246
  return viem.createWalletClient({
247
+ account: this.getActiveAccount(),
248
+ chain: viemUtils.chainsMap[chainId !== null && chainId !== void 0 ? chainId : String(this.currentChainId)],
229
249
  transport: viem.custom(WalletConnect.provider),
230
250
  });
231
251
  }
232
- fetchPublicAddress(opts) {
252
+ getAddress(opts) {
233
253
  var _a, _b;
234
254
  return _tslib.__awaiter(this, void 0, void 0, function* () {
235
- if (this.activeAccount) {
236
- return this.activeAccount;
255
+ const activeAccount = this.getActiveAccount();
256
+ if (activeAccount === null || activeAccount === void 0 ? void 0 : activeAccount.address) {
257
+ return activeAccount.address;
237
258
  }
238
- if (!WalletConnect.provider || !((_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.uri)) {
259
+ if (!WalletConnect.provider || !((_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.signer.uri)) {
239
260
  walletConnectorCore.logger.debug('No WC2 provider found, re-initializing...');
240
261
  yield this.endSession();
241
262
  yield this.init();
@@ -245,13 +266,13 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
245
266
  // finish setting up the connection URI and making it available
246
267
  // on the provider
247
268
  yield utils.sleep(1000);
248
- if (!WalletConnect.provider || !((_b = WalletConnect.provider) === null || _b === void 0 ? void 0 : _b.uri)) {
269
+ if (!WalletConnect.provider || !((_b = WalletConnect.provider) === null || _b === void 0 ? void 0 : _b.signer.uri)) {
249
270
  walletConnectorCore.logger.debug('No WC2 provider found, escaping and throwing error');
250
271
  throw new utils.DynamicError('No provider found');
251
272
  }
252
273
  }
253
- const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key);
254
- walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnect.provider.uri, metadata, {
274
+ const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key, this.walletFallback);
275
+ walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri, metadata, {
255
276
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
256
277
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
257
278
  }, this.deepLinkPreference);
@@ -264,7 +285,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
264
285
  const error = new utils.DynamicError('Connection rejected. Please try again.');
265
286
  error.code = 'connection_rejected';
266
287
  if (WalletConnect.provider) {
267
- WalletConnect.provider.uri = undefined;
288
+ WalletConnect.provider.signer.uri = undefined;
268
289
  // this is needed for mobile to work when using universal links.
269
290
  // if the user cancels the connection, we need to re-initialize the provider
270
291
  // so that the async work is done ahead of time, before the user tries to connect again,
@@ -276,13 +297,20 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
276
297
  // whenever the connection attempt either succeeds or fails
277
298
  cleanupListeners();
278
299
  };
279
- const onConnect = ({ session }) => {
300
+ const onConnect = () => {
301
+ var _a;
302
+ const session = (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.session;
280
303
  if (!session) {
281
304
  reject(new utils.DynamicError('No session found'));
305
+ return;
282
306
  }
283
307
  this.setSession(session);
284
- this.setActiveAccount(session.namespaces.eip155.accounts[0].split(':')[2]);
285
- resolve(this.activeAccount);
308
+ this.setWCActiveAccount(session.namespaces.eip155.accounts[0].split(':')[2]);
309
+ this.getNetwork().then((chainId) => {
310
+ var _a;
311
+ this.currentChainId = chainId;
312
+ resolve((_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address);
313
+ });
286
314
  // We must clean up the onConnect and onFail listeners
287
315
  // whenever the connection attempt either succeeds or fails
288
316
  cleanupListeners();
@@ -310,10 +338,12 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
310
338
  */
311
339
  waitForSignMessage(signMessageFn, messageToSign) {
312
340
  return _tslib.__awaiter(this, void 0, void 0, function* () {
313
- const raceConditionPromise = new Promise((resolve) => {
341
+ const raceConditionPromise = new Promise((resolve, reject) => {
314
342
  // Create listener for chain change event
315
343
  this.on('chainChange', () => resolve({ success: false }));
316
- signMessageFn(messageToSign).then((result) => resolve({ signedMessage: result, success: true }));
344
+ signMessageFn(messageToSign)
345
+ .then((result) => resolve({ signedMessage: result, success: true }))
346
+ .catch(reject);
317
347
  });
318
348
  const signedMessageResult = yield raceConditionPromise;
319
349
  if (signedMessageResult.success === false) {
@@ -332,7 +362,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
332
362
  metadata,
333
363
  mode: 'regular',
334
364
  preference: this.deepLinkPreference,
335
- uri: (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.uri,
365
+ uri: (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.signer.uri,
336
366
  });
337
367
  if (!deepLink) {
338
368
  return;
@@ -346,20 +376,17 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
346
376
  if (!this.session) {
347
377
  throw new utils.DynamicError('no session');
348
378
  }
349
- const web3Provider = this.getWalletClient();
350
- if (!web3Provider) {
351
- throw new utils.DynamicError('No WalletConnect provider found to handle signing');
352
- }
353
379
  const deepLink = this.getDeepLink();
354
380
  if (utils.isMobile() && deepLink) {
355
381
  window.location.href = deepLink;
356
382
  }
357
383
  const signMessageFn = (messageToSign) => _tslib.__awaiter(this, void 0, void 0, function* () {
358
- const { activeAccount } = this;
384
+ const activeAccount = this.getActiveAccount();
359
385
  if (!activeAccount) {
360
386
  return;
361
387
  }
362
- return web3Provider.signMessage({
388
+ const walletClient = yield this.getWalletClientFromInitializedProvider();
389
+ return walletClient.signMessage({
363
390
  account: activeAccount,
364
391
  message: messageToSign,
365
392
  });
@@ -370,15 +397,15 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
370
397
  }
371
398
  clearActiveAccount() {
372
399
  localStorage.removeItem(this.activeAccountKey);
373
- this.activeAccount = undefined;
400
+ this.setActiveAccount(undefined);
374
401
  }
375
402
  clearSession() {
376
403
  localStorage.removeItem(this.sessionTopicKey);
377
404
  this.session = undefined;
378
405
  }
379
- setActiveAccount(account) {
406
+ setWCActiveAccount(account) {
380
407
  localStorage.setItem(this.activeAccountKey, account);
381
- this.activeAccount = account;
408
+ this.setActiveAccount(account);
382
409
  this.emit('accountChange', { accounts: [account] });
383
410
  }
384
411
  setSession(session) {
@@ -418,11 +445,17 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
418
445
  return _super.getNetwork.call(this);
419
446
  });
420
447
  }
421
- providerSwitchNetwork({ network, provider, }) {
448
+ providerSwitchNetwork({ network, }) {
422
449
  const _super = Object.create(null, {
423
450
  providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
424
451
  });
425
452
  return _tslib.__awaiter(this, void 0, void 0, function* () {
453
+ const supportedNetworks = yield this.getSupportedNetworks();
454
+ if (!(supportedNetworks === null || supportedNetworks === void 0 ? void 0 : supportedNetworks.includes(network.chainId.toString()))) {
455
+ const error = new utils.DynamicError('Network switching is not available at this time. The user should manually switch network in their wallet');
456
+ error.code = 'network_switching_only_available_in_wallet';
457
+ throw error;
458
+ }
426
459
  const currentNetworkId = yield this.getNetwork();
427
460
  if (currentNetworkId && currentNetworkId === network.chainId) {
428
461
  return;
@@ -433,10 +466,14 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
433
466
  if (!this.supportsNetworkSwitching()) {
434
467
  throw new utils.DynamicError('Network switching not supported');
435
468
  }
436
- if (!provider) {
437
- throw new utils.DynamicError('Provider not found');
469
+ const walletClient = yield this.getWalletClientFromInitializedProvider();
470
+ if (this.isMetaMask()) {
471
+ const deepLink = this.getDeepLink();
472
+ if (deepLink) {
473
+ window.location.href = deepLink;
474
+ }
438
475
  }
439
- yield _super.providerSwitchNetwork.call(this, { network, provider });
476
+ yield _super.providerSwitchNetwork.call(this, { network, provider: walletClient });
440
477
  this.currentChainId = network.chainId;
441
478
  this.hasSwitchedNetwork = true;
442
479
  this.emit('chainChange', { chain: String(network.chainId) });
@@ -449,10 +486,11 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
449
486
  this.refreshSession();
450
487
  this.isInitialized = true;
451
488
  }
452
- if (!this.activeAccount) {
489
+ const activeAccount = this.getActiveAccount();
490
+ if (!(activeAccount === null || activeAccount === void 0 ? void 0 : activeAccount.address)) {
453
491
  return [];
454
492
  }
455
- return [this.activeAccount];
493
+ return [activeAccount.address];
456
494
  });
457
495
  }
458
496
  isMetaMask() {
@@ -462,13 +500,14 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
462
500
  getSupportedNetworks() {
463
501
  var _a;
464
502
  return _tslib.__awaiter(this, void 0, void 0, function* () {
465
- // MM allows you to switch to any network the first time, even if it's not enabled in MM
466
- // so we should consider all networks as supported if network switching hasn't been triggered yet
467
- if (this.isMetaMask() && !this.hasSwitchedNetwork) {
468
- return this.evmNetworks.map((network) => network.chainId.toString());
469
- }
470
503
  yield this.initProvider();
471
504
  this.refreshSession();
505
+ if (this.isMetaMask()) {
506
+ if (this.hasSwitchedNetwork) {
507
+ return [String(this.currentChainId)];
508
+ }
509
+ return this.evmNetworks.map((network) => network.chainId.toString());
510
+ }
472
511
  if (!this.session) {
473
512
  return [];
474
513
  }
@@ -1,7 +1,6 @@
1
1
  import type { SessionTypes } from '@walletconnect/types';
2
- import { Hex, WalletClient } from 'viem';
2
+ import { Chain, GetAddressOpts, DeepLinkVariant, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
3
3
  import { EvmNetwork } from '@dynamic-labs/types';
4
- import { Chain, DeepLinkVariant, FetchPublicAddressOpts, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
5
4
  import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
6
5
  export type WalletConnectOpts = EthWalletConnectorOpts & {
7
6
  projectId?: string;
@@ -14,7 +13,6 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
14
13
  connectedChain: Chain;
15
14
  name: string;
16
15
  session: SessionTypes.Struct | undefined;
17
- activeAccount: Hex | undefined;
18
16
  isInitialized: boolean;
19
17
  initializePromise: Promise<void> | undefined;
20
18
  canConnectViaQrCode: boolean;
@@ -29,6 +27,8 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
29
27
  private getMappedChains;
30
28
  private getMappedChainsByPreferredOrder;
31
29
  private initConnection;
30
+ private createProvider;
31
+ private getWalletClientFromInitializedProvider;
32
32
  private createInitProviderPromise;
33
33
  private initProvider;
34
34
  private refreshSession;
@@ -42,10 +42,12 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
42
42
  private set hasSwitchedNetwork(value);
43
43
  private get hasSwitchedNetwork();
44
44
  supportsNetworkSwitching(): boolean;
45
+ private sessionEventHandler;
46
+ private sessionDeleteHandler;
45
47
  setupEventListeners(): void;
46
48
  teardownEventListeners(): void;
47
- getWalletClient(): {
48
- account: undefined;
49
+ getWalletClient(chainId?: string): {
50
+ account: import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined;
49
51
  batch?: {
50
52
  multicall?: boolean | {
51
53
  batchSize?: number | undefined;
@@ -53,7 +55,7 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
53
55
  } | undefined;
54
56
  } | undefined;
55
57
  cacheTime: number;
56
- chain: undefined;
58
+ chain: import("viem").Chain;
57
59
  key: string;
58
60
  name: string;
59
61
  pollingInterval: number;
@@ -62,20 +64,20 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
62
64
  type: string;
63
65
  uid: string;
64
66
  addChain: (args: import("viem").AddChainParameters) => Promise<void>;
65
- deployContract: <const abi extends import("viem").Abi | readonly unknown[], chainOverride extends import("viem").Chain | undefined>(args: import("viem").DeployContractParameters<abi, undefined, undefined, chainOverride>) => Promise<`0x${string}`>;
67
+ deployContract: <const abi extends import("viem").Abi | readonly unknown[], chainOverride extends import("viem").Chain | undefined>(args: import("viem").DeployContractParameters<abi, import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, chainOverride>) => Promise<`0x${string}`>;
66
68
  getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
67
69
  getChainId: () => Promise<number>;
68
70
  getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
69
- prepareTransactionRequest: <TParameterType extends import("viem").PrepareTransactionRequestParameterType, TChainOverride extends import("viem").Chain | undefined = undefined, TAccountOverride extends `0x${string}` | import("viem").Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride, TAccountOverride, TParameterType>) => Promise<import("viem").PrepareTransactionRequestReturnType<import("viem").Chain, undefined, TChainOverride, TAccountOverride, TParameterType>>;
71
+ prepareTransactionRequest: <TParameterType extends import("viem").PrepareTransactionRequestParameterType, TChainOverride extends import("viem").Chain | undefined = undefined, TAccountOverride extends `0x${string}` | import("viem").Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, TChainOverride, TAccountOverride, TParameterType>) => Promise<import("viem").PrepareTransactionRequestReturnType<import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, TChainOverride, TAccountOverride, TParameterType>>;
70
72
  requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
71
73
  requestPermissions: (args: {
72
74
  [x: string]: Record<string, any>;
73
75
  eth_accounts: Record<string, any>;
74
76
  }) => Promise<import("viem").RequestPermissionsReturnType>;
75
77
  sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
76
- sendTransaction: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_1>) => Promise<`0x${string}`>;
77
- signMessage: (args: import("viem").SignMessageParameters<undefined>) => Promise<`0x${string}`>;
78
- signTransaction: <TChainOverride_2 extends import("viem").Chain | undefined>(args: import("viem").SignTransactionParameters<undefined, undefined, TChainOverride_2>) => Promise<`0x${string}`>;
78
+ sendTransaction: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, TChainOverride_1>) => Promise<`0x${string}`>;
79
+ signMessage: (args: import("viem").SignMessageParameters<import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined>) => Promise<`0x${string}`>;
80
+ signTransaction: <TChainOverride_2 extends import("viem").Chain | undefined>(args: import("viem").SignTransactionParameters<import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, TChainOverride_2>) => Promise<`0x${string}`>;
79
81
  signTypedData: <const TTypedData extends {
80
82
  [x: string]: readonly import("viem").TypedDataParameter[];
81
83
  [x: `string[${string}]`]: undefined;
@@ -283,10 +285,10 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
283
285
  uint256?: undefined;
284
286
  } | {
285
287
  [key: string]: unknown;
286
- }, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, undefined>) => Promise<`0x${string}`>;
288
+ }, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined>) => Promise<`0x${string}`>;
287
289
  switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
288
290
  watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
289
- writeContract: <const abi_1 extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi_1, "nonpayable" | "payable">, args extends import("viem").ContractFunctionArgs<abi_1, "pure" | "view", functionName>, TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_1, functionName, args, undefined, undefined, TChainOverride_3>) => Promise<`0x${string}`>;
291
+ writeContract: <const abi_1 extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi_1, "nonpayable" | "payable">, args extends import("viem").ContractFunctionArgs<abi_1, "pure" | "view", functionName>, TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_1, functionName, args, import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, TChainOverride_3>) => Promise<`0x${string}`>;
290
292
  extend: <const client extends {
291
293
  [x: string]: unknown;
292
294
  account?: undefined;
@@ -300,9 +302,9 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
300
302
  transport?: undefined;
301
303
  type?: undefined;
302
304
  uid?: undefined;
303
- } & Partial<Pick<import("viem").PublicActions<import("viem").CustomTransport, undefined, undefined>, "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<undefined, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<undefined, undefined>>;
305
+ } & Partial<Pick<import("viem").PublicActions<import("viem").CustomTransport, import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined>, "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<import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<import("viem").Chain, import("viem").JsonRpcAccount<`0x${string}`> | import("viem").LocalAccount<string, `0x${string}`> | undefined>>;
304
306
  } | undefined;
305
- fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
307
+ getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
306
308
  /**
307
309
  * WalletConnect V2 will fail to send the sign message request if the chainId
308
310
  * is not the same as the one in the session. This method will wait for the
@@ -319,13 +321,12 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
319
321
  signMessage(messageToSign: string): Promise<string | undefined>;
320
322
  private clearActiveAccount;
321
323
  private clearSession;
322
- private setActiveAccount;
324
+ private setWCActiveAccount;
323
325
  private setSession;
324
326
  endSession(): Promise<void>;
325
327
  getNetwork(): Promise<number | undefined>;
326
- providerSwitchNetwork({ network, provider, }: {
328
+ providerSwitchNetwork({ network, }: {
327
329
  network: EvmNetwork;
328
- provider: WalletClient;
329
330
  }): Promise<void>;
330
331
  getConnectedAccounts(): Promise<string[]>;
331
332
  private isMetaMask;