@wagmi/connectors 2.3.0 → 2.4.0-cjs

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/dist/ledger.js CHANGED
@@ -1,103 +1,120 @@
1
- import {
2
- normalizeChainId
3
- } from "./chunk-OQILYQDO.js";
4
- import {
5
- Connector,
6
- __privateAdd,
7
- __privateGet,
8
- __privateMethod,
9
- __privateSet,
10
- __publicField
11
- } from "./chunk-QYMCVNHT.js";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ var _chunkQYMCVNHTjs = require('./chunk-QYMCVNHT.js');
12
12
 
13
13
  // src/ledger.ts
14
- import {
15
- SupportedProviders,
16
- loadConnectKit
17
- } from "@ledgerhq/connect-kit-loader";
18
- import {
19
- SwitchChainError,
20
- UserRejectedRequestError,
21
- createWalletClient,
22
- custom,
23
- getAddress,
24
- numberToHex
25
- } from "viem";
26
- var _provider, _switchChain, switchChain_fn;
27
- var LedgerConnector = class extends Connector {
28
- constructor({
29
- chains,
30
- options = { enableDebugLogs: false }
31
- } = {}) {
32
- super({ chains, options });
33
- __privateAdd(this, _switchChain);
34
- __publicField(this, "id", "ledger");
35
- __publicField(this, "name", "Ledger");
36
- __publicField(this, "ready", true);
37
- __privateAdd(this, _provider, void 0);
38
- __publicField(this, "onAccountsChanged", (accounts) => {
14
+
15
+
16
+
17
+ var _connectkitloader = require('@ledgerhq/connect-kit-loader');
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ var _viem = require('viem');
26
+ var _provider, _initProviderPromise, _isV1, _createProvider, createProvider_fn, _initProvider, initProvider_fn, _setupListeners, setupListeners_fn, _removeListeners, removeListeners_fn;
27
+ var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
28
+ constructor(config) {
29
+ super({
30
+ ...config,
31
+ options: { ...config.options }
32
+ });
33
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _createProvider);
34
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _initProvider);
35
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _setupListeners);
36
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _removeListeners);
37
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "id", "ledger");
38
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "name", "Ledger");
39
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "ready", true);
40
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _provider, void 0);
41
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _initProviderPromise, void 0);
42
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _isV1, void 0);
43
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
39
44
  if (accounts.length === 0)
40
45
  this.emit("disconnect");
41
46
  else
42
- this.emit("change", { account: getAddress(accounts[0]) });
47
+ this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
43
48
  });
44
- __publicField(this, "onChainChanged", (chainId) => {
45
- const id = normalizeChainId(chainId);
49
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
50
+ const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
46
51
  const unsupported = this.isChainUnsupported(id);
47
52
  this.emit("change", { chain: { id, unsupported } });
48
53
  });
49
- __publicField(this, "onDisconnect", () => {
54
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onDisconnect", () => {
50
55
  this.emit("disconnect");
51
56
  });
57
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onConnect", () => {
58
+ this.emit("connect", {});
59
+ });
60
+ _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _isV1, this.walletConnectVersion === 1);
61
+ }
62
+ get walletConnectVersion() {
63
+ if (this.options.walletConnectVersion)
64
+ return this.options.walletConnectVersion;
65
+ else if (this.options.projectId)
66
+ return 2;
67
+ return 1;
52
68
  }
53
- async connect() {
69
+ async connect({ chainId } = {}) {
54
70
  try {
55
71
  const provider = await this.getProvider({ create: true });
56
- if (provider.on) {
57
- provider.on("accountsChanged", this.onAccountsChanged);
58
- provider.on("chainChanged", this.onChainChanged);
59
- provider.on("disconnect", this.onDisconnect);
72
+ _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _setupListeners, setupListeners_fn).call(this);
73
+ if (!provider.session) {
74
+ this.emit("message", { type: "connecting" });
75
+ await provider.request({
76
+ method: "eth_requestAccounts"
77
+ });
78
+ }
79
+ const account = await this.getAccount();
80
+ let id = await this.getChainId();
81
+ let unsupported = this.isChainUnsupported(id);
82
+ if (chainId && id !== chainId) {
83
+ const chain = await this.switchChain(chainId);
84
+ id = chain.id;
85
+ unsupported = this.isChainUnsupported(id);
60
86
  }
61
- this.emit("message", { type: "connecting" });
62
- const accounts = await provider.request({
63
- method: "eth_requestAccounts"
64
- });
65
- const account = getAddress(accounts[0]);
66
- const id = await this.getChainId();
67
- const unsupported = this.isChainUnsupported(id);
68
- this.switchChain = __privateMethod(this, _switchChain, switchChain_fn);
69
87
  return {
70
88
  account,
71
- chain: { id, unsupported }
89
+ chain: { id, unsupported },
90
+ provider
72
91
  };
73
92
  } catch (error) {
74
- if (error.code === 4001) {
75
- throw new UserRejectedRequestError(error);
76
- }
77
- if (error.code === -32002) {
78
- throw error instanceof Error ? error : new Error(String(error));
93
+ if (/user rejected/i.test(_optionalChain([error, 'optionalAccess', _ => _.message]))) {
94
+ throw new (0, _viem.UserRejectedRequestError)(error);
79
95
  }
80
96
  throw error;
81
97
  }
82
98
  }
83
99
  async disconnect() {
84
100
  const provider = await this.getProvider();
85
- if (provider?.disconnect) {
86
- await provider.disconnect();
87
- }
88
- if (provider?.removeListener) {
89
- provider.removeListener("accountsChanged", this.onAccountsChanged);
90
- provider.removeListener("chainChanged", this.onChainChanged);
91
- provider.removeListener("disconnect", this.onDisconnect);
101
+ try {
102
+ if (_optionalChain([provider, 'optionalAccess', _2 => _2.disconnect]))
103
+ await provider.disconnect();
104
+ } catch (error) {
105
+ if (!/No matching key/i.test(error.message))
106
+ throw error;
107
+ } finally {
108
+ _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
109
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _isV1) && typeof localStorage !== "undefined" && localStorage.removeItem("walletconnect");
92
110
  }
93
- typeof localStorage !== "undefined" && localStorage.removeItem("walletconnect");
94
111
  }
95
112
  async getAccount() {
96
113
  const provider = await this.getProvider();
97
114
  const accounts = await provider.request({
98
115
  method: "eth_accounts"
99
116
  });
100
- const account = getAddress(accounts[0]);
117
+ const account = _viem.getAddress.call(void 0, accounts[0]);
101
118
  return account;
102
119
  }
103
120
  async getChainId() {
@@ -105,32 +122,17 @@ var LedgerConnector = class extends Connector {
105
122
  const chainId = await provider.request({
106
123
  method: "eth_chainId"
107
124
  });
108
- return normalizeChainId(chainId);
125
+ return _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
109
126
  }
110
127
  async getProvider({ chainId, create } = {
111
128
  create: false
112
129
  }) {
113
- if (!__privateGet(this, _provider) || chainId || create) {
114
- const connectKit = await loadConnectKit();
115
- if (this.options.enableDebugLogs) {
116
- connectKit.enableDebugLogs();
117
- }
118
- const rpc = this.chains.reduce(
119
- (rpc2, chain) => ({
120
- ...rpc2,
121
- [chain.id]: chain.rpcUrls.default.http[0]
122
- }),
123
- {}
124
- );
125
- connectKit.checkSupport({
126
- bridge: this.options.bridge,
127
- providerType: SupportedProviders.Ethereum,
128
- chainId: chainId || this.options.chainId,
129
- rpc: { ...rpc, ...this.options?.rpc }
130
- });
131
- __privateSet(this, _provider, await connectKit.getProvider());
130
+ if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider) || _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _isV1) && create) {
131
+ await _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
132
132
  }
133
- return __privateGet(this, _provider);
133
+ if (chainId)
134
+ await this.switchChain(chainId);
135
+ return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
134
136
  }
135
137
  async getWalletClient({ chainId } = {}) {
136
138
  const [provider, account] = await Promise.all([
@@ -140,53 +142,119 @@ var LedgerConnector = class extends Connector {
140
142
  const chain = this.chains.find((x) => x.id === chainId);
141
143
  if (!provider)
142
144
  throw new Error("provider is required.");
143
- return createWalletClient({
144
- account,
145
- chain,
146
- transport: custom(provider)
147
- });
145
+ return _viem.createWalletClient.call(void 0, { account, chain, transport: _viem.custom.call(void 0, provider) });
148
146
  }
149
147
  async isAuthorized() {
150
148
  try {
151
149
  const account = await this.getAccount();
152
150
  return !!account;
153
- } catch {
151
+ } catch (e) {
154
152
  return false;
155
153
  }
156
154
  }
155
+ async switchChain(chainId) {
156
+ const chain = this.chains.find((chain2) => chain2.id === chainId);
157
+ if (!chain)
158
+ throw new (0, _viem.SwitchChainError)(new Error("chain not found on connector."));
159
+ try {
160
+ const provider = await this.getProvider();
161
+ await provider.request({
162
+ method: "wallet_switchEthereumChain",
163
+ params: [{ chainId: _viem.numberToHex.call(void 0, chainId) }]
164
+ });
165
+ return chain;
166
+ } catch (error) {
167
+ const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _3 => _3.message]);
168
+ if (/user rejected request/i.test(message)) {
169
+ throw new (0, _viem.UserRejectedRequestError)(error);
170
+ }
171
+ throw new (0, _viem.SwitchChainError)(error);
172
+ }
173
+ }
157
174
  };
158
175
  _provider = new WeakMap();
159
- _switchChain = new WeakSet();
160
- switchChain_fn = async function(chainId) {
161
- const provider = await this.getProvider();
162
- const id = numberToHex(chainId);
163
- try {
164
- await Promise.race([
165
- provider.request({
166
- method: "wallet_switchEthereumChain",
167
- params: [{ chainId: id }]
168
- }),
169
- new Promise(
170
- (res) => this.on("change", ({ chain }) => {
171
- if (chain?.id === chainId)
172
- res(chainId);
173
- })
176
+ _initProviderPromise = new WeakMap();
177
+ _isV1 = new WeakMap();
178
+ _createProvider = new WeakSet();
179
+ createProvider_fn = async function() {
180
+ if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _initProviderPromise) && typeof window !== "undefined") {
181
+ _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _initProviderPromise, _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _initProvider, initProvider_fn).call(this));
182
+ }
183
+ return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _initProviderPromise);
184
+ };
185
+ _initProvider = new WeakSet();
186
+ initProvider_fn = async function() {
187
+ const connectKit = await _connectkitloader.loadConnectKit.call(void 0, );
188
+ if (this.options.enableDebugLogs) {
189
+ connectKit.enableDebugLogs();
190
+ }
191
+ let checkSupportOptions;
192
+ if (_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _isV1)) {
193
+ const { chainId, bridge } = this.options;
194
+ checkSupportOptions = {
195
+ providerType: _connectkitloader.SupportedProviders.Ethereum,
196
+ walletConnectVersion: 1,
197
+ chainId,
198
+ bridge,
199
+ rpc: Object.fromEntries(
200
+ this.chains.map((chain) => [
201
+ chain.id,
202
+ chain.rpcUrls.default.http[0]
203
+ ])
204
+ )
205
+ };
206
+ } else {
207
+ const {
208
+ projectId,
209
+ requiredChains,
210
+ requiredMethods,
211
+ optionalMethods,
212
+ requiredEvents,
213
+ optionalEvents
214
+ } = this.options;
215
+ const optionalChains = this.chains.map(({ id }) => id);
216
+ checkSupportOptions = {
217
+ providerType: _connectkitloader.SupportedProviders.Ethereum,
218
+ walletConnectVersion: 2,
219
+ projectId,
220
+ chains: requiredChains,
221
+ optionalChains,
222
+ methods: requiredMethods,
223
+ optionalMethods,
224
+ events: requiredEvents,
225
+ optionalEvents,
226
+ rpcMap: Object.fromEntries(
227
+ this.chains.map((chain) => [
228
+ chain.id,
229
+ chain.rpcUrls.default.http[0]
230
+ ])
174
231
  )
175
- ]);
176
- return this.chains.find((x) => x.id === chainId) ?? {
177
- id: chainId,
178
- name: `Chain ${id}`,
179
- network: `${id}`,
180
- nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
181
- rpcUrls: { default: { http: [""] }, public: { http: [""] } }
182
232
  };
183
- } catch (error) {
184
- const message = typeof error === "string" ? error : error?.message;
185
- if (/user rejected request/i.test(message))
186
- throw new UserRejectedRequestError(error);
187
- throw new SwitchChainError(error);
188
233
  }
234
+ connectKit.checkSupport(checkSupportOptions);
235
+ _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _provider, await connectKit.getProvider());
189
236
  };
190
- export {
191
- LedgerConnector
237
+ _setupListeners = new WeakSet();
238
+ setupListeners_fn = function() {
239
+ if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
240
+ return;
241
+ _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
242
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("accountsChanged", this.onAccountsChanged);
243
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("chainChanged", this.onChainChanged);
244
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("disconnect", this.onDisconnect);
245
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("session_delete", this.onDisconnect);
246
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("connect", this.onConnect);
192
247
  };
248
+ _removeListeners = new WeakSet();
249
+ removeListeners_fn = function() {
250
+ if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
251
+ return;
252
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
253
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("chainChanged", this.onChainChanged);
254
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("disconnect", this.onDisconnect);
255
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("session_delete", this.onDisconnect);
256
+ _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("connect", this.onConnect);
257
+ };
258
+
259
+
260
+ exports.LedgerConnector = LedgerConnector;
@@ -1,6 +1,6 @@
1
1
  import { Chain } from '@wagmi/chains';
2
2
  import { InjectedConnectorOptions, InjectedConnector } from './injected.js';
3
- import { W as WindowProvider } from './base-0473abd3.js';
3
+ import { W as WindowProvider } from './base-2dd7facf.js';
4
4
  import 'viem';
5
5
  import 'eventemitter3';
6
6
 
package/dist/metaMask.js CHANGED
@@ -1,25 +1,25 @@
1
- import {
2
- InjectedConnector
3
- } from "./chunk-4BSCIAHY.js";
4
- import {
5
- ConnectorNotFoundError
6
- } from "./chunk-ZCAPXGBX.js";
7
- import "./chunk-OQILYQDO.js";
8
- import {
9
- __privateAdd,
10
- __privateGet,
11
- __privateSet,
12
- __publicField
13
- } from "./chunk-QYMCVNHT.js";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkZ2P63ELMjs = require('./chunk-Z2P63ELM.js');
4
+
5
+
6
+ var _chunkZCAPXGBXjs = require('./chunk-ZCAPXGBX.js');
7
+ require('./chunk-OQILYQDO.js');
8
+
9
+
10
+
11
+
12
+
13
+ var _chunkQYMCVNHTjs = require('./chunk-QYMCVNHT.js');
14
14
 
15
15
  // src/metaMask.ts
16
- import {
17
- ResourceUnavailableRpcError,
18
- UserRejectedRequestError,
19
- getAddress
20
- } from "viem";
16
+
17
+
18
+
19
+
20
+ var _viem = require('viem');
21
21
  var _UNSTABLE_shimOnConnectSelectAccount;
22
- var MetaMaskConnector = class extends InjectedConnector {
22
+ var MetaMaskConnector = class extends _chunkZ2P63ELMjs.InjectedConnector {
23
23
  constructor({
24
24
  chains,
25
25
  options: options_
@@ -29,7 +29,7 @@ var MetaMaskConnector = class extends InjectedConnector {
29
29
  shimDisconnect: true,
30
30
  getProvider() {
31
31
  function getReady(ethereum2) {
32
- const isMetaMask = !!ethereum2?.isMetaMask;
32
+ const isMetaMask = !!_optionalChain([ethereum2, 'optionalAccess', _ => _.isMetaMask]);
33
33
  if (!isMetaMask)
34
34
  return;
35
35
  if (ethereum2.isBraveWallet && !ethereum2._events && !ethereum2._state)
@@ -67,23 +67,23 @@ var MetaMaskConnector = class extends InjectedConnector {
67
67
  if (typeof window === "undefined")
68
68
  return;
69
69
  const ethereum = window.ethereum;
70
- if (ethereum?.providers)
70
+ if (_optionalChain([ethereum, 'optionalAccess', _2 => _2.providers]))
71
71
  return ethereum.providers.find(getReady);
72
72
  return getReady(ethereum);
73
73
  },
74
74
  ...options_
75
75
  };
76
76
  super({ chains, options });
77
- __publicField(this, "id", "metaMask");
78
- __publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
79
- __privateAdd(this, _UNSTABLE_shimOnConnectSelectAccount, void 0);
80
- __privateSet(this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
77
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "id", "metaMask");
78
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
79
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _UNSTABLE_shimOnConnectSelectAccount, void 0);
80
+ _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
81
81
  }
82
82
  async connect({ chainId } = {}) {
83
83
  try {
84
84
  const provider = await this.getProvider();
85
85
  if (!provider)
86
- throw new ConnectorNotFoundError();
86
+ throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
87
87
  if (provider.on) {
88
88
  provider.on("accountsChanged", this.onAccountsChanged);
89
89
  provider.on("chainChanged", this.onChainChanged);
@@ -91,7 +91,7 @@ var MetaMaskConnector = class extends InjectedConnector {
91
91
  }
92
92
  this.emit("message", { type: "connecting" });
93
93
  let account = null;
94
- if (__privateGet(this, _UNSTABLE_shimOnConnectSelectAccount) && this.options?.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey)) {
94
+ if (_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _UNSTABLE_shimOnConnectSelectAccount) && _optionalChain([this, 'access', _3 => _3.options, 'optionalAccess', _4 => _4.shimDisconnect]) && !_optionalChain([this, 'access', _5 => _5.storage, 'optionalAccess', _6 => _6.getItem, 'call', _7 => _7(this.shimDisconnectKey)])) {
95
95
  account = await this.getAccount().catch(() => null);
96
96
  const isConnected = !!account;
97
97
  if (isConnected)
@@ -103,8 +103,8 @@ var MetaMaskConnector = class extends InjectedConnector {
103
103
  account = await this.getAccount();
104
104
  } catch (error) {
105
105
  if (this.isUserRejectedRequestError(error))
106
- throw new UserRejectedRequestError(error);
107
- if (error.code === new ResourceUnavailableRpcError(error).code)
106
+ throw new (0, _viem.UserRejectedRequestError)(error);
107
+ if (error.code === new (0, _viem.ResourceUnavailableRpcError)(error).code)
108
108
  throw error;
109
109
  }
110
110
  }
@@ -112,7 +112,7 @@ var MetaMaskConnector = class extends InjectedConnector {
112
112
  const accounts = await provider.request({
113
113
  method: "eth_requestAccounts"
114
114
  });
115
- account = getAddress(accounts[0]);
115
+ account = _viem.getAddress.call(void 0, accounts[0]);
116
116
  }
117
117
  let id = await this.getChainId();
118
118
  let unsupported = this.isChainUnsupported(id);
@@ -121,19 +121,19 @@ var MetaMaskConnector = class extends InjectedConnector {
121
121
  id = chain.id;
122
122
  unsupported = this.isChainUnsupported(id);
123
123
  }
124
- if (this.options?.shimDisconnect)
125
- this.storage?.setItem(this.shimDisconnectKey, true);
124
+ if (_optionalChain([this, 'access', _8 => _8.options, 'optionalAccess', _9 => _9.shimDisconnect]))
125
+ _optionalChain([this, 'access', _10 => _10.storage, 'optionalAccess', _11 => _11.setItem, 'call', _12 => _12(this.shimDisconnectKey, true)]);
126
126
  return { account, chain: { id, unsupported }, provider };
127
127
  } catch (error) {
128
128
  if (this.isUserRejectedRequestError(error))
129
- throw new UserRejectedRequestError(error);
129
+ throw new (0, _viem.UserRejectedRequestError)(error);
130
130
  if (error.code === -32002)
131
- throw new ResourceUnavailableRpcError(error);
131
+ throw new (0, _viem.ResourceUnavailableRpcError)(error);
132
132
  throw error;
133
133
  }
134
134
  }
135
135
  };
136
136
  _UNSTABLE_shimOnConnectSelectAccount = new WeakMap();
137
- export {
138
- MetaMaskConnector
139
- };
137
+
138
+
139
+ exports.MetaMaskConnector = MetaMaskConnector;
@@ -1,6 +1,6 @@
1
1
  import * as viem from 'viem';
2
2
  import { Chain } from '@wagmi/chains';
3
- import { c as WalletClient, C as Connector, a as ConnectorData } from '../base-0473abd3.js';
3
+ import { c as WalletClient, C as Connector, a as ConnectorData } from '../base-2dd7facf.js';
4
4
  import EventEmitter from 'eventemitter3';
5
5
 
6
6
  type MockProviderOptions = {