@dynamic-labs/ethereum 1.3.1 → 1.4.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.
@@ -3,18 +3,20 @@
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 accounts = require('viem/accounts');
9
10
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
10
11
  var walletBook = require('@dynamic-labs/wallet-book');
11
12
  var utils = require('@dynamic-labs/utils');
13
+ var viemUtils = require('@dynamic-labs/viem-utils');
12
14
  var EthWalletConnector = require('../EthWalletConnector.cjs');
13
15
  var parseIntSafe = require('../utils/parseIntSafe.cjs');
14
16
 
15
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
18
 
17
- var Provider__default = /*#__PURE__*/_interopDefaultLegacy(Provider);
19
+ var EthereumProvider__default = /*#__PURE__*/_interopDefaultLegacy(EthereumProvider);
18
20
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
19
21
 
20
22
  const activeAccountKey = (walletName) => `dynamic-wc2-active-account-${walletName}`;
@@ -35,6 +37,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
35
37
  // When trying to switch network for MetaMask, the switch promise gets stuck
36
38
  // if the switch got trigged once already, so we need to keep track of that
37
39
  this._hasSwitchedNetwork = false;
40
+ this.sessionEventHandler = () => { };
41
+ this.sessionDeleteHandler = () => { };
38
42
  this.name = opts.walletName;
39
43
  this.projectId = opts.projectId;
40
44
  this.deepLinkPreference = opts.deepLinkPreference || 'native';
@@ -60,7 +64,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
60
64
  }
61
65
  const reorderedChains = this.preferredChains.filter((chain) => allChains.includes(chain));
62
66
  const remainingChains = allChains.filter((chain) => !this.preferredChains.includes(chain));
63
- return [...reorderedChains, ...remainingChains];
67
+ return [...reorderedChains, ...remainingChains].map((chain) => Number(chain.split(':')[1]));
64
68
  }
65
69
  initConnection() {
66
70
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -69,44 +73,51 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
69
73
  throw new utils.DynamicError('No provider found (init connection)');
70
74
  }
71
75
  // this means there is already a connection in progress, so don't call connect again
72
- if (provider === null || provider === void 0 ? void 0 : provider.uri) {
76
+ if (provider === null || provider === void 0 ? void 0 : provider.signer.uri) {
73
77
  return;
74
78
  }
75
- const optionalNamespaces = {
76
- eip155: {
77
- chains: this.getMappedChainsByPreferredOrder(),
78
- events: ['chainChanged', 'accountsChanged'],
79
- methods: [
80
- 'eth_chainId',
81
- 'eth_signTypedData',
82
- 'eth_signTransaction',
83
- 'eth_sign',
84
- 'personal_sign',
85
- 'eth_sendTransaction',
86
- 'eth_signTypedData_v4',
87
- 'wallet_switchEthereumChain',
88
- 'wallet_addEthereumChain',
89
- ],
90
- rpcMap: this.evmNetworkRpcMap(),
91
- },
92
- };
93
- provider
94
- .connect({
95
- optionalNamespaces,
96
- })
97
- .catch((e) => {
79
+ provider.connect().catch((e) => {
98
80
  walletConnectorCore.logger.error(e);
99
81
  ee.emit('walletconnect_connection_failed', e);
100
82
  });
101
83
  });
102
84
  }
103
- createInitProviderPromise() {
85
+ createProvider() {
104
86
  return _tslib.__awaiter(this, void 0, void 0, function* () {
105
- const provider = yield Provider__default["default"].init({
106
- logger: walletConnectorCore.logger.logLevel.toLowerCase() === 'debug' ? 'debug' : undefined,
87
+ return EthereumProvider__default["default"].init({
88
+ events: ['chainChanged', 'accountsChanged'],
89
+ methods: [],
90
+ optionalChains: this.getMappedChainsByPreferredOrder(),
91
+ optionalMethods: [
92
+ 'eth_chainId',
93
+ 'eth_signTypedData',
94
+ 'eth_signTransaction',
95
+ 'eth_sign',
96
+ 'personal_sign',
97
+ 'eth_sendTransaction',
98
+ 'eth_signTypedData_v4',
99
+ 'wallet_switchEthereumChain',
100
+ 'wallet_addEthereumChain',
101
+ ],
107
102
  projectId: this.projectId,
103
+ rpcMap: this.evmNetworkRpcMap(),
104
+ showQrModal: false,
105
+ });
106
+ });
107
+ }
108
+ getWalletClientFromInitializedProvider() {
109
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
110
+ const walletConnect = this.createProvider();
111
+ const walletClient = viem.createWalletClient({
112
+ account: this.activeAccount ? accounts.toAccount(this.activeAccount) : undefined,
113
+ transport: viem.custom(yield walletConnect),
108
114
  });
109
- WalletConnectV2.provider = provider;
115
+ return walletClient;
116
+ });
117
+ }
118
+ createInitProviderPromise() {
119
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
120
+ WalletConnectV2.provider = yield this.createProvider();
110
121
  this.teardownEventListeners();
111
122
  this.setupEventListeners();
112
123
  });
@@ -182,7 +193,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
182
193
  if (!WalletConnectV2.provider) {
183
194
  return;
184
195
  }
185
- WalletConnectV2.provider.client.on('session_event', ({ params }) => {
196
+ this.sessionEventHandler = ({ params, }) => {
186
197
  walletConnectorCore.logger.debug('session_event was called', { params });
187
198
  if (!params || !params.event) {
188
199
  walletConnectorCore.logger.debug('session_event was called without params or params.event');
@@ -191,12 +202,17 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
191
202
  const { name, data } = params.event;
192
203
  if (name === 'chainChanged') {
193
204
  const chainId = parseIntSafe.parseIntSafe(data);
205
+ if (chainId === this.currentChainId) {
206
+ walletConnectorCore.logger.debug(`ignoring chainChanged event with same chain id as current chain id: ${chainId}`);
207
+ return;
208
+ }
194
209
  if (chainId === undefined) {
195
210
  walletConnectorCore.logger.debug(`received unexpected data for chainChanged: ${data} with type ${typeof data}}`);
196
211
  return;
197
212
  }
198
213
  this.currentChainId = chainId;
199
214
  this.emit('chainChange', { chain: String(chainId) });
215
+ this.hasSwitchedNetwork = true;
200
216
  // When a user switches network from their wallet, we need the provider to change network
201
217
  // such that any future calls to `getNetwork` will return the correct network
202
218
  this.switchNetwork({ networkChainId: chainId });
@@ -210,24 +226,28 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
210
226
  const account = data[0].split(':')[2];
211
227
  this.setActiveAccount(account);
212
228
  }
213
- });
214
- WalletConnectV2.provider.client.on('session_delete', () => _tslib.__awaiter(this, void 0, void 0, function* () {
229
+ };
230
+ WalletConnectV2.provider.on('session_event', this.sessionEventHandler);
231
+ this.sessionDeleteHandler = () => _tslib.__awaiter(this, void 0, void 0, function* () {
215
232
  this.endSession();
216
233
  this.emit('disconnect');
217
- }));
234
+ });
235
+ WalletConnectV2.provider.on('session_delete', this.sessionDeleteHandler);
218
236
  }
219
237
  teardownEventListeners() {
220
238
  if (!WalletConnectV2.provider) {
221
239
  return;
222
240
  }
223
- WalletConnectV2.provider.client.removeAllListeners('session_event');
224
- WalletConnectV2.provider.client.removeAllListeners('session_delete');
241
+ WalletConnectV2.provider.off('session_event', this.sessionEventHandler);
242
+ WalletConnectV2.provider.off('session_delete', this.sessionDeleteHandler);
225
243
  }
226
- getWalletClient() {
244
+ getWalletClient(chainId) {
227
245
  if (!WalletConnectV2.provider) {
228
246
  return;
229
247
  }
230
248
  return viem.createWalletClient({
249
+ account: this.activeAccount ? accounts.toAccount(this.activeAccount) : undefined,
250
+ chain: viemUtils.chainsMap[chainId !== null && chainId !== void 0 ? chainId : String(this.currentChainId)],
231
251
  transport: viem.custom(WalletConnectV2.provider),
232
252
  });
233
253
  }
@@ -237,7 +257,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
237
257
  if (this.activeAccount) {
238
258
  return this.activeAccount;
239
259
  }
240
- if (!WalletConnectV2.provider || !((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri)) {
260
+ if (!WalletConnectV2.provider || !((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.signer.uri)) {
241
261
  walletConnectorCore.logger.debug('No WC2 provider found, re-initializing...');
242
262
  yield this.endSession();
243
263
  yield this.init();
@@ -247,13 +267,13 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
247
267
  // finish setting up the connection URI and making it available
248
268
  // on the provider
249
269
  yield new Promise((resolve) => setTimeout(resolve, 1000));
250
- if (!WalletConnectV2.provider || !((_b = WalletConnectV2.provider) === null || _b === void 0 ? void 0 : _b.uri)) {
270
+ if (!WalletConnectV2.provider || !((_b = WalletConnectV2.provider) === null || _b === void 0 ? void 0 : _b.signer.uri)) {
251
271
  walletConnectorCore.logger.debug('No WC2 provider found, escaping and throwing error');
252
272
  throw new utils.DynamicError('No provider found');
253
273
  }
254
274
  }
255
275
  const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key);
256
- walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
276
+ walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnectV2.provider.signer.uri, metadata, {
257
277
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
258
278
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
259
279
  }, this.deepLinkPreference);
@@ -266,7 +286,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
266
286
  const error = new utils.DynamicError('Connection rejected. Please try again.');
267
287
  error.code = 'connection_rejected';
268
288
  if (WalletConnectV2.provider) {
269
- WalletConnectV2.provider.uri = undefined;
289
+ WalletConnectV2.provider.signer.uri = undefined;
270
290
  // this is needed for mobile to work when using universal links.
271
291
  // if the user cancels the connection, we need to re-initialize the provider
272
292
  // so that the async work is done ahead of time, before the user tries to connect again,
@@ -275,13 +295,19 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
275
295
  }
276
296
  reject(error);
277
297
  });
278
- WalletConnectV2.provider.on('connect', ({ session }) => {
298
+ WalletConnectV2.provider.on('connect', () => {
299
+ var _a;
300
+ const session = (_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.session;
279
301
  if (!session) {
280
302
  reject(new utils.DynamicError('No session found'));
303
+ return;
281
304
  }
282
305
  this.setSession(session);
283
306
  this.setActiveAccount(session.namespaces.eip155.accounts[0].split(':')[2]);
284
- resolve(this.activeAccount);
307
+ this.getNetwork().then((chainId) => {
308
+ this.currentChainId = chainId;
309
+ resolve(this.activeAccount);
310
+ });
285
311
  });
286
312
  });
287
313
  });
@@ -299,10 +325,12 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
299
325
  */
300
326
  waitForSignMessage(signMessageFn, messageToSign) {
301
327
  return _tslib.__awaiter(this, void 0, void 0, function* () {
302
- const raceConditionPromise = new Promise((resolve) => {
328
+ const raceConditionPromise = new Promise((resolve, reject) => {
303
329
  // Create listener for chain change event
304
330
  this.on('chainChange', () => resolve({ success: false }));
305
- signMessageFn(messageToSign).then((result) => resolve({ signedMessage: result, success: true }));
331
+ signMessageFn(messageToSign)
332
+ .then((result) => resolve({ signedMessage: result, success: true }))
333
+ .catch(reject);
306
334
  });
307
335
  const signedMessageResult = yield raceConditionPromise;
308
336
  if (signedMessageResult.success === false) {
@@ -321,7 +349,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
321
349
  metadata,
322
350
  mode: 'regular',
323
351
  preference: this.deepLinkPreference,
324
- uri: (_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.uri,
352
+ uri: (_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.signer.uri,
325
353
  });
326
354
  if (!deepLink) {
327
355
  return;
@@ -335,10 +363,6 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
335
363
  if (!this.session) {
336
364
  throw new utils.DynamicError('no session');
337
365
  }
338
- const web3Provider = this.getWalletClient();
339
- if (!web3Provider) {
340
- throw new utils.DynamicError('No WalletConnect provider found to handle signing');
341
- }
342
366
  const deepLink = this.getDeepLink();
343
367
  if (utils.isMobile() && deepLink) {
344
368
  window.location.href = deepLink;
@@ -348,7 +372,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
348
372
  if (!activeAccount) {
349
373
  return;
350
374
  }
351
- return web3Provider.signMessage({
375
+ const walletClient = yield this.getWalletClientFromInitializedProvider();
376
+ return walletClient.signMessage({
352
377
  account: activeAccount,
353
378
  message: messageToSign,
354
379
  });
@@ -407,11 +432,17 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
407
432
  return _super.getNetwork.call(this);
408
433
  });
409
434
  }
410
- providerSwitchNetwork({ network, provider, }) {
435
+ providerSwitchNetwork({ network, }) {
411
436
  const _super = Object.create(null, {
412
437
  providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
413
438
  });
414
439
  return _tslib.__awaiter(this, void 0, void 0, function* () {
440
+ const supportedNetworks = yield this.getSupportedNetworks();
441
+ if (!(supportedNetworks === null || supportedNetworks === void 0 ? void 0 : supportedNetworks.includes(network.chainId.toString()))) {
442
+ const error = new utils.DynamicError('Network switching is not available at this time. The user should manually switch network in their wallet');
443
+ error.code = 'network_switching_only_available_in_wallet';
444
+ throw error;
445
+ }
415
446
  const currentNetworkId = yield this.getNetwork();
416
447
  if (currentNetworkId && currentNetworkId === network.chainId) {
417
448
  return;
@@ -422,10 +453,14 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
422
453
  if (!this.supportsNetworkSwitching()) {
423
454
  throw new utils.DynamicError('Network switching not supported');
424
455
  }
425
- if (!provider) {
426
- throw new utils.DynamicError('Provider not found');
456
+ const walletClient = yield this.getWalletClientFromInitializedProvider();
457
+ if (this.isMetaMask()) {
458
+ const deepLink = this.getDeepLink();
459
+ if (deepLink) {
460
+ window.location.href = deepLink;
461
+ }
427
462
  }
428
- yield _super.providerSwitchNetwork.call(this, { network, provider });
463
+ yield _super.providerSwitchNetwork.call(this, { network, provider: walletClient });
429
464
  this.currentChainId = network.chainId;
430
465
  this.hasSwitchedNetwork = true;
431
466
  this.emit('chainChange', { chain: String(network.chainId) });
@@ -451,13 +486,14 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
451
486
  getSupportedNetworks() {
452
487
  var _a;
453
488
  return _tslib.__awaiter(this, void 0, void 0, function* () {
454
- // MM allows you to switch to any network the first time, even if it's not enabled in MM
455
- // so we should consider all networks as supported if network switching hasn't been triggered yet
456
- if (this.isMetaMask() && !this.hasSwitchedNetwork) {
457
- return this.evmNetworks.map((network) => network.chainId.toString());
458
- }
459
489
  yield this.initProvider();
460
490
  this.refreshSession();
491
+ if (this.isMetaMask()) {
492
+ if (this.hasSwitchedNetwork) {
493
+ return [String(this.currentChainId)];
494
+ }
495
+ return this.evmNetworks.map((network) => network.chainId.toString());
496
+ }
461
497
  if (!this.session) {
462
498
  return [];
463
499
  }
@@ -1,5 +1,5 @@
1
1
  import type { SessionTypes } from '@walletconnect/types';
2
- import { Hex, WalletClient } from 'viem';
2
+ import { Hex } from 'viem';
3
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';
@@ -29,6 +29,8 @@ export declare class WalletConnectV2 extends EthWalletConnector {
29
29
  private getMappedChains;
30
30
  private getMappedChainsByPreferredOrder;
31
31
  private initConnection;
32
+ private createProvider;
33
+ private getWalletClientFromInitializedProvider;
32
34
  private createInitProviderPromise;
33
35
  private initProvider;
34
36
  private refreshSession;
@@ -42,10 +44,12 @@ export declare class WalletConnectV2 extends EthWalletConnector {
42
44
  private set hasSwitchedNetwork(value);
43
45
  private get hasSwitchedNetwork();
44
46
  supportsNetworkSwitching(): boolean;
47
+ private sessionEventHandler;
48
+ private sessionDeleteHandler;
45
49
  setupEventListeners(): void;
46
50
  teardownEventListeners(): void;
47
- getWalletClient(): {
48
- account: undefined;
51
+ getWalletClient(chainId?: string): {
52
+ account: import("viem").JsonRpcAccount | undefined;
49
53
  batch?: {
50
54
  multicall?: boolean | {
51
55
  batchSize?: number | undefined;
@@ -53,7 +57,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
53
57
  } | undefined;
54
58
  } | undefined;
55
59
  cacheTime: number;
56
- chain: undefined;
60
+ chain: import("viem").Chain;
57
61
  key: string;
58
62
  name: string;
59
63
  pollingInterval: number;
@@ -62,20 +66,20 @@ export declare class WalletConnectV2 extends EthWalletConnector {
62
66
  type: string;
63
67
  uid: string;
64
68
  addChain: (args: import("viem").AddChainParameters) => Promise<void>;
65
- deployContract: <const TAbi extends import("viem").Abi | readonly unknown[], TChainOverride extends import("viem").Chain | undefined = undefined>(args: import("viem").DeployContractParameters<TAbi, undefined, undefined, TChainOverride>) => Promise<`0x${string}`>;
69
+ deployContract: <const TAbi extends import("viem").Abi | readonly unknown[], TChainOverride extends import("viem").Chain | undefined = undefined>(args: import("viem").DeployContractParameters<TAbi, import("viem").Chain, import("viem").JsonRpcAccount | undefined, TChainOverride>) => Promise<`0x${string}`>;
66
70
  getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
67
71
  getChainId: () => Promise<number>;
68
72
  getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
69
- prepareTransactionRequest: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride_1>) => Promise<import("viem").PrepareTransactionRequestReturnType>;
73
+ prepareTransactionRequest: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<import("viem").Chain, import("viem").JsonRpcAccount | undefined, TChainOverride_1>) => Promise<import("viem").PrepareTransactionRequestReturnType>;
70
74
  requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
71
75
  requestPermissions: (args: {
72
76
  [x: string]: Record<string, any>;
73
77
  eth_accounts: Record<string, any>;
74
78
  }) => Promise<import("viem").RequestPermissionsReturnType>;
75
79
  sendRawTransaction: (args: import("node_modules/viem/_types/actions/wallet/sendRawTransaction").SendRawTransactionParameters) => Promise<`0x${string}`>;
76
- sendTransaction: <TChainOverride_2 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_2>) => Promise<`0x${string}`>;
77
- signMessage: (args: import("viem").SignMessageParameters<undefined>) => Promise<`0x${string}`>;
78
- signTransaction: <TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("node_modules/viem/_types/actions/wallet/signTransaction").SignTransactionParameters<undefined, undefined, TChainOverride_3>) => Promise<`0x${string}`>;
80
+ sendTransaction: <TChainOverride_2 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<import("viem").Chain, import("viem").JsonRpcAccount | undefined, TChainOverride_2>) => Promise<`0x${string}`>;
81
+ signMessage: (args: import("viem").SignMessageParameters<import("viem").JsonRpcAccount | undefined>) => Promise<`0x${string}`>;
82
+ signTransaction: <TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("node_modules/viem/_types/actions/wallet/signTransaction").SignTransactionParameters<import("viem").Chain, import("viem").JsonRpcAccount | undefined, TChainOverride_3>) => Promise<`0x${string}`>;
79
83
  signTypedData: <const TTypedData extends {
80
84
  [x: string]: readonly import("viem").TypedDataParameter[];
81
85
  [x: `string[${string}]`]: undefined;
@@ -283,10 +287,10 @@ export declare class WalletConnectV2 extends EthWalletConnector {
283
287
  uint256?: undefined;
284
288
  } | {
285
289
  [key: string]: unknown;
286
- }, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, undefined>) => Promise<`0x${string}`>;
290
+ }, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, import("viem").JsonRpcAccount | undefined>) => Promise<`0x${string}`>;
287
291
  switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
288
292
  watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
289
- writeContract: <const TAbi_1 extends import("viem").Abi | readonly unknown[], TFunctionName extends string, TChainOverride_4 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<TAbi_1, TFunctionName, undefined, undefined, TChainOverride_4>) => Promise<`0x${string}`>;
293
+ writeContract: <const TAbi_1 extends import("viem").Abi | readonly unknown[], TFunctionName extends string, TChainOverride_4 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<TAbi_1, TFunctionName, import("viem").Chain, import("viem").JsonRpcAccount | undefined, TChainOverride_4>) => Promise<`0x${string}`>;
290
294
  extend: <const client extends {
291
295
  [x: string]: unknown;
292
296
  account?: undefined;
@@ -300,7 +304,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
300
304
  transport?: undefined;
301
305
  type?: undefined;
302
306
  uid?: undefined;
303
- } & Partial<Pick<import("viem").PublicActions, "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, "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>>;
307
+ } & Partial<Pick<import("viem").PublicActions, "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, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, import("viem").Chain, import("viem").JsonRpcAccount | undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<import("viem").Chain, import("viem").JsonRpcAccount | undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, import("viem").Chain, import("viem").JsonRpcAccount | undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<import("viem").Chain, import("viem").JsonRpcAccount | undefined>>;
304
308
  } | undefined;
305
309
  fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
306
310
  /**
@@ -323,9 +327,8 @@ export declare class WalletConnectV2 extends EthWalletConnector {
323
327
  private setSession;
324
328
  endSession(): Promise<void>;
325
329
  getNetwork(): Promise<number | undefined>;
326
- providerSwitchNetwork({ network, provider, }: {
330
+ providerSwitchNetwork({ network, }: {
327
331
  network: EvmNetwork;
328
- provider: WalletClient;
329
332
  }): Promise<void>;
330
333
  getConnectedAccounts(): Promise<string[]>;
331
334
  private isMetaMask;